命比纸薄

文章 评论 浏览 29

命比纸薄 2025-02-15 13:30:47

您将需要将文件转换为编码的字节数组,然后将文件转换为字符串以保存。
看到这个帖子
将发布的文件转换为字节数组

映射的文件字段可以是字符串,也可以是字节数组,必须通过编程将图像路径添加到图片字段的方式来给出值。

You will need to convert your file to a encoded byte array and then to string to save it.
See this SO post
Convert posted file to byte array

The not mapped file field can be a string or may be byte array and must be given value by programming the way image path is added to picture field.

将图像上传到.NET 6中的数据库

命比纸薄 2025-02-15 07:23:13

您可以使用 groupby 检查

d = {x : y  for x, y in df.groupby(['Doctor','Patient']) if len(y) > 1}
d
Out[36]: 
{('Aaron', 'Josh'):   Doctor Patient  Days
 1  Aaron    Josh    46
 2  Aaron    Josh    71, ('Jess', 'Manny'):   Doctor Patient  Days
 3   Jess   Manny    55
 4   Jess   Manny    85
 5   Jess   Manny    46}

You may check with groupby

d = {x : y  for x, y in df.groupby(['Doctor','Patient']) if len(y) > 1}
d
Out[36]: 
{('Aaron', 'Josh'):   Doctor Patient  Days
 1  Aaron    Josh    46
 2  Aaron    Josh    71, ('Jess', 'Manny'):   Doctor Patient  Days
 3   Jess   Manny    55
 4   Jess   Manny    85
 5   Jess   Manny    46}

在熊猫数据框架中查找非唯一行

命比纸薄 2025-02-15 07:21:58

您的代码不会在网页的上下文中运行,而是在扩展上下文(弹出,选项,背景脚本/页面等)中,该上下文与单独的浏览器选项卡相似dom,文档窗口 chrome-extension:// url。

解决方案:使用 content Script 访问网页或互动及其内容。

方法1。声明清单

。JSON:

"content_scripts": [{
  "matches": ["*://*.example.com/*"],
  "js": ["contentScript.js"]
}],

页面加载时它将自动运行。在此之后,使用消息传递

Chrome中的消息传递不支持DOM元素,MAP,SET,ARRAYBUFFER,类,功能等。它只能发送与JSON兼容的简单对象和类型,因此您需要手动提取所需的数据并将其作为简单的数组或对象传递。

⚠️您需要重新注射内容脚本在重新加载/安装扩展程序后。

方法2。程序化

  • 清单v3

    使用 chrome.scripting.scripting.executscript.executscript 扩展脚本(如弹出窗口)将内容脚本/函数注入需求选项卡。

    此方法的结果是内容脚本中的最后一个表达式,因此可以用于提取数据。数据必须与JSON兼容,请参见上面的警告。

    必需 permissions 在subest.json中:

    • “脚本” - 强制性;
    • “ activetab” - 理想场景,适用于A响应用户操作(通常单击工具栏中的扩展图标)。安装扩展时不会显示任何权限警告。

    如果不可能进行理想的方案,将允许的站点添加到 host_permissions in asutest.json:

    • “*://////gy.com/” 加上您想要的任何其他网站。

    • “< all_urls>“ ”*://*/“ 这些将使您的扩展名将您的扩展名放在Chrome Web中的超慢评论队列中由于广泛的主机权限而存储。

  • 清单v2与上述差异:

    • 使用 chrome.tabs.executescript 代替 chrome。 scipting.executescript
    • 指定网站或“ activetab” “权限” ,无需“脚本”

Your code doesn't run in the context of the web page, but in an extension context (popup, options, background script/page, etc.), which similarly to a separate browser tab has its own DOM, document, window, and a chrome-extension:// URL.

Solution: use a content script to access the web page or interact with its contents.

  • Content scripts execute in the web page, not in the extension.
  • Content scripts are isolated by default, see how to run code in page context (aka MAIN world).
  • Don't load your content scripts in the extension page.
  • To inspect each context of the extension use its own devtools.

Method 1. Declarative

manifest.json:

"content_scripts": [{
  "matches": ["*://*.example.com/*"],
  "js": ["contentScript.js"]
}],

It will run automatically when the page loads. After that happens, use messaging .

⚠️ Messaging in Chrome doesn't support DOM elements, Map, Set, ArrayBuffer, classes, functions, and so on. It can only send JSON-compatible simple objects and types so you'll need to manually extract the required data and pass it as a simple array or object.

⚠️ You'll need to re-inject content scripts after reloading/installing the extension.

Method 2. Programmatic

  • ManifestV3:

    Use chrome.scripting.executeScript in the extension script (like the popup) to inject a content script/function into a tab on demand.

    The result of this method is the last expression in the content script so it can be used to extract data. Data must be JSON-compatible, see the warning above.

    Required permissions in manifest.json:

    • "scripting" - mandatory;
    • "activeTab" - ideal scenario, suitable for a response to a user action (usually a click on the extension icon in the toolbar). Doesn't show any permission warning when installing the extension.

    If ideal scenario is impossible add the allowed sites to host_permissions in manifest.json:

    • "*://*.example.com/" plus any other sites you want.

    • "<all_urls>" or "*://*/" these will put your extension in a super slow review queue in the Chrome Web Store because of broad host permissions.

  • ManifestV2 differences to the above:

    • Use chrome.tabs.executeScript instead of chrome.scripting.executeScript.
    • Specify sites or "activeTab" in "permissions", no need for "scripting".

从扩展程序访问网页的``窗口''/dom/html

命比纸薄 2025-02-15 02:53:15

本周早些时候,我与MongoDB有一个问题的连接工作室3T,这消耗了整个工作日,因此我放弃了使用Studio 3T来确保时间和其他替代方案。今天,我发现了Studio 3T的简短视频教程,介绍了如何将Studio 3T与MongoDB连接起来。遵循指示,我惊讶于成功建立了联系。

对于您的解决方案,我建议您观看此视频: https://wwww.youtube。 com/watch?v = _ka3-hgnlye

如果此答案对您有所帮助,请记住要为他人突出显示它。

I had a problem connection Studio 3T with MongoDB earlier this week, and it consumed my entire working day, so I gave up on using Studio 3T to ensure time for other things and an alternative. Today I found this short video tutorial by Studio 3T on how to connect Studio 3T with MongoDB. Following the directions, I was surprised that a connection was made successfully.

For your solution, I recommend that you watch this video: https://www.youtube.com/watch?v=_Ka3-HGNlYE

If this answer helps you, remember to tick to highlight it for others.

可以连接到Studio 3T'Connection'Connection“失败”

命比纸薄 2025-02-14 18:25:53

我的猜测是基于您的错误,您正在尝试将空字符串转换为整数,这显然是行不通的。我将使用或操作员检查空字符串,然后简单地解析为零: int(arg或“ 0”)

My guess based on your error is you're trying to convert empty strings into integers, which obviously wouldn't work. I would use the or operator to check for empty strings, and simply resolve to zero: int(arg or "0")

试图拆分数据范围的数据范围时,要出现价值错误的问题

命比纸薄 2025-02-14 17:39:39

有两种情况:

  1. 如果您没有用户中实现的平等和哈希代码方法:

最简单的方法是获取所有用户识别符,例如databaseID或用户名。将其持续到哈希结构中,以进行快速搜索。然后浏览所有用户,接受本集合中未包含的所有用户。

创建一组已记录的用户标识符:

 Set<Long> loggedUserIdentifiers = loggedUsers.stream()
                                   .map(User::getId) // I have chosen Id
                                   .collect(toSet());

现在您可以找到所有未燃烧的用户:

 List<User> unloggedUsers = allUsers.stream()
                            .filter( user -> !loggedUserIdentifiers.contains(user.getId()))
                            .collect(toSet());
  1. 如果您实现了平等和哈希代码,则可以简单地将所有记录的用户从所有用户集合的副本中删除。只需记住先创建一个副本,否则您只会以记录和未登录的用户结束。

      set&lt;用户&gt; AlluserCopy =新的Hashset&lt;&gt;(Allusers); //在列表上也有效
    AlluserCopy.RemoveAll(Loggedusers);
    设置&lt;用户&gt; notloggedusers = set.copyof(alluserCopy);
     

现在,您将拥有一个只有未记录的用户的集合。

There are two cases:

  1. If you do not have equals and hash code methods implemented in User:

then the simplest way would be to get all UserIdentifier, like databaseId or username. Persist it in a hashed structure, for fast search. Then go through all Users and accept all not contained in this collection.

Create a set of logged user Identifiers:

 Set<Long> loggedUserIdentifiers = loggedUsers.stream()
                                   .map(User::getId) // I have chosen Id
                                   .collect(toSet());

Now you can find all not-logged users:

 List<User> unloggedUsers = allUsers.stream()
                            .filter( user -> !loggedUserIdentifiers.contains(user.getId()))
                            .collect(toSet());
  1. If you have equals and hash code implemented, then you could simply remove all logged users from a copy of all Users collection. Just remember to create a copy first, otherwise You will end with only logged and not-logged Users.

    Set<User> allUserCopy = new HashSet<>(allUsers); // works on lists also
    allUserCopy.removeAll(loggedUsers);
    Set<User> notLoggedUsers = Set.copyOf(allUserCopy);
    

Now you will have a collection with only not logged users.

找到数组的非相交元素的最佳方法

命比纸薄 2025-02-14 15:53:47
CREATE temp TABLE table_name (
    state boolean,
    id uuid PRIMARY KEY,
    bsa text
);

INSERT INTO table_name (state, id, bsa)
    VALUES (FALSE, 'b18bde5d-aeb4-492d-b0de-c45437da94ac', 'PPCM');

-Main功能:

CREATE OR REPLACE FUNCTION misc (IN tempdata jsonb)
    RETURNS void
    AS $
DECLARE
    _id uuid;
    _state boolean;
    _bsa text;
BEGIN
    RAISE NOTICE 'jsonb.state: %', tempdata['state']::text;
    RAISE NOTICE 'jsonb.id: %', tempdata['id']::text;
    RAISE NOTICE 'jsonb.bsa: %', tempdata['bsa']::text;
    _id := (tempdata ->> 'id')::text::uuid;
    _state := tempdata['state']::text::boolean;
    _bsa := tempdata ->> 'bsa'::text;
    INSERT INTO table_name (state, id, bsa)
        VALUES (_state, _id, _bsa)
    ON CONFLICT (id)
        DO UPDATE SET
            state = excluded.state;
END
$
LANGUAGE plpgsql;

测试它:

  SELECT
    *
FROM
    misc ('{"bsa": "PCM","state": true,"id": "b18bde5d-aeb4-492d-b0de-c45437da94ac"}');
CREATE temp TABLE table_name (
    state boolean,
    id uuid PRIMARY KEY,
    bsa text
);

INSERT INTO table_name (state, id, bsa)
    VALUES (FALSE, 'b18bde5d-aeb4-492d-b0de-c45437da94ac', 'PPCM');

--main function:

CREATE OR REPLACE FUNCTION misc (IN tempdata jsonb)
    RETURNS void
    AS $
DECLARE
    _id uuid;
    _state boolean;
    _bsa text;
BEGIN
    RAISE NOTICE 'jsonb.state: %', tempdata['state']::text;
    RAISE NOTICE 'jsonb.id: %', tempdata['id']::text;
    RAISE NOTICE 'jsonb.bsa: %', tempdata['bsa']::text;
    _id := (tempdata ->> 'id')::text::uuid;
    _state := tempdata['state']::text::boolean;
    _bsa := tempdata ->> 'bsa'::text;
    INSERT INTO table_name (state, id, bsa)
        VALUES (_state, _id, _bsa)
    ON CONFLICT (id)
        DO UPDATE SET
            state = excluded.state;
END
$
LANGUAGE plpgsql;

test it:

  SELECT
    *
FROM
    misc ('{"bsa": "PCM","state": true,"id": "b18bde5d-aeb4-492d-b0de-c45437da94ac"}');

使用函数采用参数并根据表格进行测试,并基于Postgres中的Cirteria进行更新

命比纸薄 2025-02-14 14:52:33

通过,获取第3个,将其转换为整数,然后总和。

arrays.inject(0) { |acc, triplet| acc += triplet.split(/,/)[2].to_i; acc }

split elements by ,, grab 3rd, convert it to integer, then sum.

arrays.inject(0) { |acc, triplet| acc += triplet.split(/,/)[2].to_i; acc }

如何在阵列中概括第三个位置?

命比纸薄 2025-02-14 12:40:17

首先,让我们澄清为什么 5b:7df 仅显示0x5b和0x7b。您基本上掩盖了以下内容:

b00001011011 <- 0x5B
b11111011111 <- 0x7DF (mask)
------------
b00001011011 <- bitwise AND

只能通过掩盖0x7DF给出相同结果的消息。鉴于0x7DF中只有一个零,只有0x7b可以工作:

b00001111011 <- 0x7B
b11111011111 <- 0x7DF (mask)
------------
b00001011011 <- bitwise AND

现在让我们在掩码的右侧添加零:

b00001011011 <- 0x5B
b11111000000 <- 0x7C0 (mask) (edit : fix typo copy/paste)
------------
b00001000000 <- bitwise AND

遵循相同的逻辑,此掩码将通过B00001000000(0x40)的ID允许消息通过B0000001111111(0x7F)。

如您所见,位面罩不能很好地适应此类范围(HEX/DEC)。例如,更容易滤除0x182、0x282、0x382和0x482(因此, canopen )。
最好的选择是将二进制友好切片范围分开:

  • 0x5b(B1011011)
  • 0x5C至0x5F(B1011100至B10111111)
  • 0x60至0x6F(B1100000到B1101111)
  • 等...

First let's clarify why 5B:7DF shows 0x5B and 0x7B only. You're basically masking the following:

b00001011011 <- 0x5B
b11111011111 <- 0x7DF (mask)
------------
b00001011011 <- bitwise AND

Only messages that give the same result by masking with 0x7DF will be let through. Given there is only one zero in 0x7DF, only 0x7B will work:

b00001111011 <- 0x7B
b11111011111 <- 0x7DF (mask)
------------
b00001011011 <- bitwise AND

Now let's add zeros to the right side of your mask:

b00001011011 <- 0x5B
b11111000000 <- 0x7C0 (mask) (edit : fix typo copy/paste)
------------
b00001000000 <- bitwise AND

Following the same logic, this mask will let messages through with IDs from b00001000000 (0x40) to b00001111111 (0x7F).

As you can see, bit-masks are not very well adapted to this kind of range (hex/dec). It's easier for instance to filter out 0x182, 0x282, 0x382 and 0x482 (hence the distribution of PDO-IDs in CANopen).
Your best bet is to split your range in binary friendly slices:

  • 0x5B (b1011011)
  • 0x5C to 0x5F (b1011100 to b1011111)
  • 0x60 to 0x6F (b1100000 to b1101111)
  • etc...

坎普(socketcan)ID范围过滤功能

命比纸薄 2025-02-14 04:10:16

希望这会有所帮助:

df <- df %>% mutate( ev_1 = case_when 
                     (Col1 <5 ~ paste("Evaluauation: Col1) This Number is Low."),
                      Col1 >5 ~ ("Evaluauation: Col1) This Number is High.")),
                     ev_2 = case_when
                     (Col2 <9 ~ paste("Col2) This number is Low."),
                       Col2>9 ~ paste("Col2) This number is High.")),
                     Evaluation = paste(ev_1 , ev_2)) %>%
  select(-ev_1, -ev_2)
df  


    Col1 Col2                                                          Evaluation
1     1   15  Evaluauation: Col1) This Number is Low. Col2) This number is High.
2     2   14  Evaluauation: Col1) This Number is Low. Col2) This number is High.
3     3   13  Evaluauation: Col1) This Number is Low. Col2) This number is High.
4     4   12  Evaluauation: Col1) This Number is Low. Col2) This number is High.
5     5   11                                       NA Col2) This number is High.
6     6   10 Evaluauation: Col1) This Number is High. Col2) This number is High.
7     7    9                         Evaluauation: Col1) This Number is High. NA
8     8    8  Evaluauation: Col1) This Number is High. Col2) This number is Low.
9     9    7  Evaluauation: Col1) This Number is High. Col2) This number is Low.
10   10    6  Evaluauation: Col1) This Number is High. Col2) This number is Low

Hope this helps:

df <- df %>% mutate( ev_1 = case_when 
                     (Col1 <5 ~ paste("Evaluauation: Col1) This Number is Low."),
                      Col1 >5 ~ ("Evaluauation: Col1) This Number is High.")),
                     ev_2 = case_when
                     (Col2 <9 ~ paste("Col2) This number is Low."),
                       Col2>9 ~ paste("Col2) This number is High.")),
                     Evaluation = paste(ev_1 , ev_2)) %>%
  select(-ev_1, -ev_2)
df  


    Col1 Col2                                                          Evaluation
1     1   15  Evaluauation: Col1) This Number is Low. Col2) This number is High.
2     2   14  Evaluauation: Col1) This Number is Low. Col2) This number is High.
3     3   13  Evaluauation: Col1) This Number is Low. Col2) This number is High.
4     4   12  Evaluauation: Col1) This Number is Low. Col2) This number is High.
5     5   11                                       NA Col2) This number is High.
6     6   10 Evaluauation: Col1) This Number is High. Col2) This number is High.
7     7    9                         Evaluauation: Col1) This Number is High. NA
8     8    8  Evaluauation: Col1) This Number is High. Col2) This number is Low.
9     9    7  Evaluauation: Col1) This Number is High. Col2) This number is Low.
10   10    6  Evaluauation: Col1) This Number is High. Col2) This number is Low

将文本字符串附加到r中的列单元格

命比纸薄 2025-02-13 23:28:52

您可以像文本一样分享代码吗?此外,您不使用外部任务传感器,您必须正确使用时间差,例如dag_b schedue_interval应该比dag_a早。否则,它将不起作用,我认为您没有提到时间表间隔,在DAG A中的Morevoer也无法正确地读取有关它的时间执行Delta

can you please share your code like in text, Moreover you are not using the external task sensor right, you have to use the time difference correctly for example Dag_B schedule_interval should be earlier than Dag_A. Otherwise, it will not work and i dont think you have mentioned the schedule interval, morevoer in DAG A the time execution delta is also not set properly read about it

我有一个externaltasksensor错误,airflowsenSortimeout

命比纸薄 2025-02-13 19:18:15

鉴于您的属性中心XML相对平坦,请考虑新的IO方法, pandas.read_xml 。然后,合并两个数据帧或使用 concat 在数据帧列表上运行迭代加入,该列表要求DateTime设置为索引。

pd.merge

final_df = pd.merge(
    pd.read_xml('PTU.xml'), pd.read_xml('AMS.xml'),
    on = "DataSrvTime", how = "outer"
)

pd.concat

df_list = [
    pd.read_xml(f).set_index("DataSrvTime")
    for f in 
    ['PTU.xml', 'GPS.xml', 'AMS.xml']
]

final_df = pd.concat(df_list, axis=0)

Given your attribute-centric XML is relatively flat, consider the new IO method, pandas.read_xml. Then, merge the two data frames or run an iterative join using concat on a list of data frames which requires the datetime to be set as index.

pd.merge

final_df = pd.merge(
    pd.read_xml('PTU.xml'), pd.read_xml('AMS.xml'),
    on = "DataSrvTime", how = "outer"
)

pd.concat

df_list = [
    pd.read_xml(f).set_index("DataSrvTime")
    for f in 
    ['PTU.xml', 'GPS.xml', 'AMS.xml']
]

final_df = pd.concat(df_list, axis=0)

将不同的XML读取到Pandas DataFrame

命比纸薄 2025-02-13 17:06:32

您应该首先使用“ .netFramework”选择该项目。

Winform基于屏幕中间或父表中间的中间实现通用表单。

我演示了一个简单的登录功能,并弹出了一个新窗口。

父表格显示在屏幕中间。

子形式处于父母形式的中间。

代码逻辑是:封装操作数据库的实体类并控制表单的位置。通过查询数据库来实现登录功能,并显示子形式。并在屏幕中间和子形式中间的子形式形成父母形式。

     public Form1()
    {
        InitializeComponent();
        //Set the form screen to center
        FormBaseOPC.SetScreenMiddle(this);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if(textBox1.Text != "" && textBox2.Text != "")
        {
            Login();
        }
        else
        {
            MessageBox.Show("Enter empty options, please re-enter");
        }
    }

    public void Login()
    {

        Dao dao = new Dao();//Entity classes encapsulate database operations
        string sql = $"select * from t_user where id='{textBox1.Text}' and psw='{textBox2.Text}'";//sql query database
        IDataReader dc = dao.read(sql);
        if (dc.Read())
        {
            Data.UID = dc["id"].ToString();
            Data.UName = dc["name"].ToString(); //Data entity class encapsulates the data queried from the database
            MessageBox.Show("login successful");
            user1 user = new user1();

           // Make the child form in the middle of the parent form
            FormBaseOPC.SetFormMiddle(user);
        }
        else
        {
            MessageBox.Show("Login failed");

        }
        dao.DaoClose();
    }

封装操作表单的位置的实体类:

internal class FormBaseOPC
{
    /// <summary>
    /// 1- Center the form screen
    /// </summary>
    /// <param name="form">The form that needs to be centered</param>
    public static void SetScreenMiddle2(Form form)
    {
        if (form != null)
        {
            //Get the screen setting centering effect
            form.SetBounds((Screen.GetBounds(form).Width / 2) - (form.Width / 2),
                (Screen.GetBounds(form).Height / 2) - (form.Height / 2),
                form.Width, form.Height, BoundsSpecified.Location);
        }
    }

    /// <summary>
    /// 1-The form screen is centered (the system comes with it)
    /// </summary>
    /// <param name="form">The form that needs to be centered</param>
    public static void SetScreenMiddle(Form form)
    {
        if (form != null)
        {
            form.StartPosition = FormStartPosition.CenterScreen;
        }
    }

    /// <summary>
    /// 2- Set to center and open relative to the form
    /// </summary>
    /// <param name="form">The form that needs to be centered</param>
    public static void SetFormMiddle(Form form)
    {
        if (form != null)
        {
            //Set the form to center relative to the parent form
            form.StartPosition = FormStartPosition.CenterParent;
            // show the form
            form.ShowDialog();
            //set focus to current form
            form.Focus();
        }
    }
}

Entity类封装代码:

internal class Dao
{
    SqlConnection conn;
    public SqlConnection connection()
    {
        // write database connection string
        string connStr = "Data source=localhost;Initial Catalog=student;User ID=sa;Password=123456";
        conn = new SqlConnection(connStr);
        conn.Open();
        return conn;
    }

    public SqlCommand command(string sql)
    {
        SqlCommand cmd = new SqlCommand(sql, connection());
        return cmd;
    }

    public int Execute(string sql)
    {
        return command(sql).ExecuteNonQuery();
    }

    public SqlDataReader read(string sql)
    {
        return command(sql).ExecuteReader();
    }
    public void DaoClose()
    {
        conn.Close();
    }
}

 internal class Data
 {
     public static string UID = "", UName = "";
 }

欢迎形式的代码逻辑:

    public user1()
    {
        InitializeComponent();
        label1.Text = $"Welcome to {Data.UName}";
    }

Winform根据屏​​幕中间或父级表格的中间实现通用表单:通过登录函数。登录页面位于屏幕的中间,子形式位于父级的中间。希望它可以帮助您。

you should first select the project with ".netFramework".

enter image description here

WinForm implements a generic form based on the middle of the screen or the middle of the parent form.

I demonstrate a simple login function and pop up a new window.

The parent form is displayed in the middle of the screen.

enter image description here

The child form is in the middle of the parent form.

enter image description here

The code logic is: Encapsulates the entity class that operates the database and controls the position of the form. The login function is implemented by querying the database, and the sub-form is displayed. And make the parent form in the middle of the screen and the child form in the middle of the parent form.

     public Form1()
    {
        InitializeComponent();
        //Set the form screen to center
        FormBaseOPC.SetScreenMiddle(this);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if(textBox1.Text != "" && textBox2.Text != "")
        {
            Login();
        }
        else
        {
            MessageBox.Show("Enter empty options, please re-enter");
        }
    }

    public void Login()
    {

        Dao dao = new Dao();//Entity classes encapsulate database operations
        string sql = 
quot;select * from t_user where id='{textBox1.Text}' and psw='{textBox2.Text}'";//sql query database
        IDataReader dc = dao.read(sql);
        if (dc.Read())
        {
            Data.UID = dc["id"].ToString();
            Data.UName = dc["name"].ToString(); //Data entity class encapsulates the data queried from the database
            MessageBox.Show("login successful");
            user1 user = new user1();

           // Make the child form in the middle of the parent form
            FormBaseOPC.SetFormMiddle(user);
        }
        else
        {
            MessageBox.Show("Login failed");

        }
        dao.DaoClose();
    }

Entity class that encapsulates the position of the manipulation form:

internal class FormBaseOPC
{
    /// <summary>
    /// 1- Center the form screen
    /// </summary>
    /// <param name="form">The form that needs to be centered</param>
    public static void SetScreenMiddle2(Form form)
    {
        if (form != null)
        {
            //Get the screen setting centering effect
            form.SetBounds((Screen.GetBounds(form).Width / 2) - (form.Width / 2),
                (Screen.GetBounds(form).Height / 2) - (form.Height / 2),
                form.Width, form.Height, BoundsSpecified.Location);
        }
    }

    /// <summary>
    /// 1-The form screen is centered (the system comes with it)
    /// </summary>
    /// <param name="form">The form that needs to be centered</param>
    public static void SetScreenMiddle(Form form)
    {
        if (form != null)
        {
            form.StartPosition = FormStartPosition.CenterScreen;
        }
    }

    /// <summary>
    /// 2- Set to center and open relative to the form
    /// </summary>
    /// <param name="form">The form that needs to be centered</param>
    public static void SetFormMiddle(Form form)
    {
        if (form != null)
        {
            //Set the form to center relative to the parent form
            form.StartPosition = FormStartPosition.CenterParent;
            // show the form
            form.ShowDialog();
            //set focus to current form
            form.Focus();
        }
    }
}

Entity class encapsulation code:

internal class Dao
{
    SqlConnection conn;
    public SqlConnection connection()
    {
        // write database connection string
        string connStr = "Data source=localhost;Initial Catalog=student;User ID=sa;Password=123456";
        conn = new SqlConnection(connStr);
        conn.Open();
        return conn;
    }

    public SqlCommand command(string sql)
    {
        SqlCommand cmd = new SqlCommand(sql, connection());
        return cmd;
    }

    public int Execute(string sql)
    {
        return command(sql).ExecuteNonQuery();
    }

    public SqlDataReader read(string sql)
    {
        return command(sql).ExecuteReader();
    }
    public void DaoClose()
    {
        conn.Close();
    }
}

 internal class Data
 {
     public static string UID = "", UName = "";
 }

Code logic for welcome form:

    public user1()
    {
        InitializeComponent();
        label1.Text = 
quot;Welcome to {Data.UName}";
    }

WinForm implements a common form based on the middle of the screen or the middle of the parent form: through the login function. The login page is in the middle of the screen, and the child form is in the middle of the parent form.Hope it helps you.

儿童形式不在主体表格的面板中心打开

命比纸薄 2025-02-13 14:30:50

是的。有几种选择,具体取决于您的特定单词的特殊性。

在您的情况下,第一个更易于测试和实现,不需要音频数据进行培训。

Yes. There are several options, depending on the specificities of your specific words.

The 1st one is easier to test and implement, as you will not need audio data for the training.

MS语音支持自定义词汇吗

命比纸薄 2025-02-13 13:16:57

通常,您只能通过网络发送可序列化值。地图不是可序列化的:

const map = new Map();
map.set('key', 'value');
console.log(JSON.stringify(map));

要么发送可以将其转换为客户端上的地图的数组数组,要么使用其他数据结构(例如普通对象)。例如:

router.get("/list", async (req, res) => {
    try {
        const users = await userCollection.find();
        accessedListEmbed(req);
        const userDataArr = [];
        users.forEach((user) => {
            userDataArr.push([user.userName, user.status]);
        });
        res.json(userDataArr); // make sure to use .json
    } catch (error) {
        // send JSON in the case of an error too so it can be predictably parsed
        res.json({ error: error.message });
    }
});

然后在客户端上:

fetch(..)
    .then(res => res.json())
    .then((result) => {
        if ('error' in result) {
            // do something with result.error and return
        }
        const userDataMap = new Map(result);
        // ...

或类似的东西。

Generally, you can only send serializable values over the network. Maps aren't serializable:

const map = new Map();
map.set('key', 'value');
console.log(JSON.stringify(map));

Either send an array of arrays that can be converted into a Map on the client side, or use another data structure, like a plain object. For example:

router.get("/list", async (req, res) => {
    try {
        const users = await userCollection.find();
        accessedListEmbed(req);
        const userDataArr = [];
        users.forEach((user) => {
            userDataArr.push([user.userName, user.status]);
        });
        res.json(userDataArr); // make sure to use .json
    } catch (error) {
        // send JSON in the case of an error too so it can be predictably parsed
        res.json({ error: error.message });
    }
});

Then on the client-side:

fetch(..)
    .then(res => res.json())
    .then((result) => {
        if ('error' in result) {
            // do something with result.error and return
        }
        const userDataMap = new Map(result);
        // ...

Or something along those lines.

在Express Res.Send中发送地图

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文