小编Blo*_*ops的帖子

RTK 查询使用 getState() 从另一个切片获取状态

我昨天刚开始使用 redux,在阅读了不同的库后,我决定使用 RTK 的切片路线。

对于我的异步,我决定使用 RTK 查询,而不是使用 createAsyncThunk,并且我有一个关于从另一个切片访问状态的正确方法的问题。

slice1 包含一些用户数据,例如:

export const initialState: IUserState = {
   name: 'example',
   id: null,
};
Run Code Online (Sandbox Code Playgroud)

在我的 slice2 中,我有一个函数想要执行getSomethingByUserId(id)和我当前的实现之类的操作:

interface IApiResponse {
  success: true;
  result: IGotSomethingData[];
}

const getsomethingSlice: any = createApi({
  reducerPath: 'api',
  baseQuery: fetchBaseQuery({
    baseUrl: 'https://someapibase',
  }),
  endpoints(builder) {
    return {
      fetchAccountAssetsById: builder.query<IApiResponse, null>({
        query() {
          console.log('store can be called here', store.getState().user.id);
          return `/apipath?id=${store.getState().user.id}`;
        },
      }),
    };
  },
});

export default getsomethingSlice;
export const { useFetchAccountAssetsByIdQuery } = getsomethingSlice;
Run Code Online (Sandbox Code Playgroud)

正如我在某处读到的,markikson 提到导入 …

reactjs redux redux-thunk redux-toolkit rtk-query

21
推荐指数
1
解决办法
2万
查看次数

在不使用 POST 的情况下处理 Remix.run 中的操作

我阅读了关于操作的 Remix 文档,我可以找到的关于操作的大部分信息是它使用带有按钮提交的表单 POST 来触发操作

export default function Game() {
    const counter = useLoaderData();

    return (
        <>
            <div>{counter}</div>
            <div>
                <Form method="post">
                    <button type="submit">click</button>
                </Form>
            </div>
        </>
    );
}
Run Code Online (Sandbox Code Playgroud)

但是,对于其他诸如拖放组件的操作,如何触发该操作,在拖放组件后应触发操作帖子

javascript node.js reactjs remix.run

13
推荐指数
1
解决办法
1万
查看次数

500 - 请求超时

我有一个运行大约4分30秒的脚本,我已经在我的aspx网页的配置页面中将默认超时时间更改为3600秒

它没有返回500 - IIS 8上的开发版本和上载版本的请求超时错误.

但是,当我将它上传到azure的实时站点时,它返回500 - 请求超时错误.

Azure是否会覆盖这些设置?

CONFIGS:

<configuration>
  <system.web>
    <httpRuntime executionTimeout="3600" />
    <sessionState timeout="360" />
    <compilation debug="false" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral/>
      </assemblies>
    </compilation>
  </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

编辑:

我将SCM_COMMAND_IDLE_TIMEOUT添加到具有3600值的azure应用程序设置中,但它没有修复错误,现在尝试提高我的代码性能:

原版的:

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

Dictionary<int, Dictionary<DateTime, float>> d_PhoneNo_DateDataList = new Dictionary<int, Dictionary<DateTime, float>>();

string sqlcommand = "SELECT ---- FROM ---- INNER JOIN ---- ON ---- = ---- WHERE PhoneNo=@PhoneNo AND date BETWEEN @Date1 AND @Date2";
string strConnectionString = ConfigurationManager.ConnectionStrings["---"].ConnectionString;

using …
Run Code Online (Sandbox Code Playgroud)

c# asp.net azure

10
推荐指数
2
解决办法
6564
查看次数

根据用户名获取AD详细信息

我有一个代码从AD检索用户的详细信息,如电子邮件地址,电话号码等.我目前使用的代码是:

Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
msgbox(strUser)
Set objUser = GetObject("LDAP://" & strUser)
Run Code Online (Sandbox Code Playgroud)

它获取当前登录用户的详细信息.但我现在需要做的是解析用户的用户名并根据该用户名检索详细信息.

我试图将objSysinfo.UserName更改为用户名并返回空白.

Set objSysInfo = CreateObject("ADSystemInfo")
strUser = "SomeUserName"
msgbox(strUser)
Set objUser = GetObject("LDAP://" & strUser)
Run Code Online (Sandbox Code Playgroud)

我应该如何根据提供的用户名从AD中检索详细信息?

vbscript vba active-directory

9
推荐指数
1
解决办法
5万
查看次数

在 Remix.run 中处理 UI 状态

我正在尝试混音,哦天哪..我坚持创建一个简单的计数器(单击按钮增加计数)

我想我不应该使用 useState 钩子,所以我尝试了加载器和操作,因为我相信这是应该在 Remix 中处理它的地方

我的组件上有:

export default function Game() {
    const counter = useLoaderData();

    return (
        <>
            <div>{counter}</div>
            <div>
                <Form method="post">
                    <button type="submit">click</button>
                </Form>
            </div>
        </>
    );
}
Run Code Online (Sandbox Code Playgroud)

服务器:

import { ActionFunction, LoaderFunction } from 'remix';

let counter: number = 0;

export const loader: LoaderFunction = async () => {
    console.log('game object!', counter);
    return counter;
};

export let action: ActionFunction = async ({ request, params }) => {
    console.log('[action] game object!', ++counter);
    return counter;
};
Run Code Online (Sandbox Code Playgroud)

上面的代码每次点击时计数器都会重置为 0

查看了一些存储库,我可以找到存储在 …

javascript node.js reactjs remix.run

7
推荐指数
1
解决办法
1万
查看次数

在Android上获取背景中的像素颜色

我需要创建一个服务,不断检查Android屏幕的坐标是否有像素的颜色.

例如.

Bitmap bitmap = ((BitmapDrawable)getBackground()).getBitmap();
int pixel = bitmap.getPixel(x,y);

if(pixel == Color.MAGENTA){
   //Stop Service
}
Run Code Online (Sandbox Code Playgroud)

然而,不仅仅是我的应用程序,我需要它在后台服务,即使我切换应用程序时仍会检查颜色.

假设设备已植根,是否有任何超级用户命令可以满足我的需求?

android android-service

6
推荐指数
1
解决办法
2838
查看次数

排序多个列表

我有3个列表包含:索引,名称,年龄

例:

List<int> indexList = new List<int>();
indexList.Add(3);
indexList.Add(1);
indexList.Add(2);
List<string> nameList = new List<string>();
nameList.Add("John");
nameList.Add("Mary");
nameList.Add("Jane");
List<int> ageList = new List<int>();
ageList.Add(16);
ageList.Add(17);
ageList.Add(18);
Run Code Online (Sandbox Code Playgroud)

我现在必须根据indexList对所有3个列表进行排序.

如何在对其他2个列表进行排序时对indexList使用.sort()

c# sorting

5
推荐指数
2
解决办法
1496
查看次数

片段中的对话框崩溃了Android应用程序.android.view.WindowsManager $ BadTokenException

我试图创建一个对话框,但当我尝试运行代码时它崩溃了.我想在我的listview中选择一个项目时运行它,这是我的片段,现在我只想尝试显示对话框而不传入任何内容

这是我的java代码:

        myInfoList.setAdapter(new CustomAdapter(details , getActivity().getApplicationContext()));

        myInfoList.setOnItemClickListener(new OnItemClickListener() {
               public void onItemClick(AdapterView<?> a, View v, int position, long id) {
                   //System.out.println("Name: "+details.get(position).getSub();
                   //String s = details.get(position).getDescription();
                   final Dialog dialog = new Dialog(getActivity().getApplicationContext());
                   dialog.setContentView(R.layout.purchase);
                   dialog.setTitle("Title");

                   Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
                    // if button is clicked, close the custom dialog
                    dialogButton.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            dialog.dismiss();
                        }
                    });

                    dialog.show();
               }
       });
Run Code Online (Sandbox Code Playgroud)

logcat的:

07-06 12:05:16.012: V/21st Polling:(12319): clicked
07-06 12:05:16.957: D/AndroidRuntime(12319): Shutting down VM
07-06 12:05:16.957: W/dalvikvm(12319): threadid=1: thread …
Run Code Online (Sandbox Code Playgroud)

java android

3
推荐指数
2
解决办法
2824
查看次数

具有可空日期时间的C#Null条件运算符

我试图学习使用null条件运算符,但似乎无法让它工作,

string datetest = DOInfolist[i].RentalItem.SimCard.DateIn[u].Value.ToShortDateString() ?? "Empty";
Run Code Online (Sandbox Code Playgroud)

DateIn是一个nullable DateTime(List<Datetime?>)列表.

我做了调试,所有的值DateIn[u]都给了null.

我究竟做错了什么?

c#

3
推荐指数
1
解决办法
807
查看次数

正确的循环SQL查询的方法?

我有一个列表,通过传递学生班级列表来检索学生的成绩,

然后通过数据库查询学生的姓名来提取学生成绩.这段代码工作正常但是,当studentList的大小增加时,这段代码的执行速度很慢,

通过SQL查询循环列表的正确方法是什么?

private List<StudentClass> getStudentGrades(List<StudentClass> studentList)
{
    for (int i =0; i < studentList.Count; i++)
    {
        string sqlcommand = "SELECT StudentGrades FROM Students WHERE StudentName=@StudentName";
        conn.Open();
        using (SqlCommand cmd = new SqlCommand(sqlcommand, conn))
        {
            cmd.Parameters.AddWithValue("@StudentName", studentList[i].StudentName);
            cmd.ExecuteNonQuery();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Reader())
            {
                studentList[i].StudentGrades = int.Parse(reader["StudentGrades"].ToString());
            }
        }
    }

    return studentList;
}

public class StudentClass
{
    public string StudentName {get; set; }
    public int StudentGrades {get; set; }
}
Run Code Online (Sandbox Code Playgroud)

c# mysql sql-server

1
推荐指数
1
解决办法
84
查看次数