DBImport V3.7 release and software stability (automatic exit problem) solution process sharing, dbimportv3.7

Source: Internet
Author: User

DBImport V3.7 release and software stability (automatic exit problem) solution process sharing, dbimportv3.7
DBImport V3.7 introduction:

1: first, introduce the highlights:

Major upgrade functions:

1: added the (Truncate Table) Clear Table insertion function:

Removing and plugging can ensure data consistency between the two databases. You like this function very much.

2: add the red part to the Information bar:

There are too many black information, and sometimes the error information is flooded. The separate red block Identification error information is displayed, which is clear.

3: Add and save all the configurations and restore the configurations:

Previously, only the configuration of the database link was saved. For, all configurations, including the table name, were included.

4: added the auto-start parameter for the scheduled function startup:

The auto-start parameter is-true or-1. The next version is processed as a service. You can restart your computer to continue the service.

5: Solve the software stability (automatic exit) problem.

: Click to download

 

The following describes how to solve the problem:

Remember that when I published the ASP. NET Aries framework, there was a demo address: http://aries.cyqdata.com.

Because there are always people who do not delete users or data or modify login passwords, to prevent this situation:

I put DBImport on the server and enabled the timing function, so I thought it would be okay once and for all.

As a result, when the software runs, it automatically exits and then needs to be executed manually.

Therefore, the current scheme locks the read-only attribute of the file to prevent users from modifying data.

 

Today, I just remembered that I had to solve it, so I had the following content:

Solution Process: 1: confirm the situation first:

Run the software separately, enable the timing function, and then go out for a lap. Let's look back at the result:

After multiple confirmations, the problem is not simple:

A: No response is returned when the system gets stuck.

B: throwing an exception is defined as Application. Run (when running independently, the system exits the software directly ).

2: You can view exceptions through intelliitrace:

"Intelliitrace events and call information" Is Enabled:

Run F5.Try to read or write the protected memory. This usually indicates that other memory is damaged.".

I thought the problem was found, and the result was falling into the trap.

1: When a method returns the array T [] GetList (), this exception is thrown. 2: When the Dictionary adds an array Add (key, T []), this exception is thrown. 3: If the method parameter is an array like public MDataTable Select (params object [] selectColumns), this exception is thrown.

 

Okay, where is this array offending Microsoft? It's about to be so bullied.

After changing the code for half a day, the code for the T [] array is changed to List <T>. Generally, the code runs normally again.

After all, some public methods have difficulty modifying the params parameter, so you have to change the option to "only intelliitrace events ".

Run. After a Bug occurs, click "All interrupted:

Then we can see the execution event:

Combined with the error information recorded by yourself:

I reviewed the code and finally found a Bug:

                if (isGoOn)                {                    using (SqlBulkCopy sbc = new SqlBulkCopy(con, (keepID ? SqlBulkCopyOptions.KeepIdentity : SqlBulkCopyOptions.Default) | SqlBulkCopyOptions.FireTriggers, sqlTran))                    {                        sbc.BatchSize = 100000;                        sbc.DestinationTableName = SqlFormat.Keyword(mdt.TableName, DalType.MsSql);                        sbc.BulkCopyTimeout = AppConfig.DB.CommandTimeout;                        foreach (MCellStruct column in mdt.Columns)                        {                            sbc.ColumnMappings.Add(column.ColumnName, column.ColumnName);                        }                        sbc.WriteToServer(mdt);                    }                }                if (_dalHelper == null)                {                    con.Close();                    con = null;                }                else if (isCreateDal)                {                    _dalHelper.EndTransaction();                    _dalHelper.Dispose();                }

In this Code, the link cannot be closed in case of exceptions. The key point is that it still starts a transaction. I didn't expect it to be too old, and there was still a loss in the hundred secrets.

So after running for a long time, the connection pool is exhausted, and the transaction gets stuck, the interface will enter a long period of time and become stuck..

Locate the problem and fix it. Close the link and put it in Try finally:

finally            {                if (_dalHelper == null)                {                    con.Close();                    con = null;                }                else if (isCreateDal)                {                    _dalHelper.EndTransaction();                    _dalHelper.Dispose();                }}
2nd problems: the problem of automatic exit, with experience.

After all, when I started my business and wrote weibo fan Genie, I met:

For Winform software, do not operate the UI in the thread. Do not trust StartForm. checkforillegalcrossthreadcils = false;

As a result, all the code is changed to the main thread delegate call method, similar to the following code:

private delegate void SetTextHandle(string id, string value);        private void ThreadSetText(string id, string value)        {            this.Controls.Find(id, true)[0].Text = value;        }        private void SetText(string id, string value)        {            if (this.InvokeRequired)            {                this.Invoke(new SetTextHandle(ThreadSetText), new object[] { id, value });            }            else            {                ThreadSetText(id, value);            }        }

Now, the stability problem has been solved. Have a good weekend!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.