Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txbNum2.Text);
            int rep = Convert.ToInt32(txbRep2.Text);


            this.button2.Text    = "Working";
            this.button2.Enabled = false;
            ThreadStart start2 = () =>
            {
                OilInfoAccess oc  = new OilInfoAccess();
                var           oil = new OilInfoEntity()
                {
                    crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                    crudeName  = DateTime.Now.ToString("yyyyMMddHHmmssfff")
                };
                oil.ID = oc.Insert(oil);
                for (int i = 0; i < num; i++)
                {
                    var item = new OilDataEntity()
                    {
                        calData       = RIPP.Lib.Security.SecurityTool.MyEncrypt(i.ToString()),
                        labData       = i.ToString(),
                        oilInfoID     = oil.ID,
                        oilTableColID = i,
                        oilTableRowID = i
                    };
                    oil.OilDatas.Add(item);
                }
                OilBll.saveTables(oil);
                this.richTextBox2.AppendText(string.Format("已经插入一条原油数据到数据库 {0}\n", DateTime.Now.ToString()));


                double[] r = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                    DateTime dt  = DateTime.Now;
                    var      ooo = OilBll.GetOilById(oil.ID);
                    foreach (var d in ooo.OilDatas)
                    {
                        var ssss = RIPP.Lib.Security.SecurityTool.MyDecrypt(d.calData);
                    }
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;
                }


                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox2.AppendText(string.Format("读取并解密 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button2.Text    = "Run";
                this.button2.Enabled = true;
                this.richTextBox2.AppendText("\n");
            };

            this.Invoke(start2);
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txtNum2.Text);
            int rep = Convert.ToInt32(txtRep2.Text);

            //先搞一条原油数据
            OilInfoAccess oc = new OilInfoAccess();

            this.button2.Text    = "Working";
            this.button2.Enabled = false;
            ThreadStart start2 = () =>
            {
                double[] r = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                    var oil = new OilInfoEntity()
                    {
                        crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                        crudeName  = DateTime.Now.ToString("yyyyMMddHHmmssfff")
                    };
                    oil.ID = oc.Insert(oil);
                    DateTime dt = DateTime.Now;
                    for (int i = 0; i < num; i++)
                    {
                        var item = new OilDataEntity()
                        {
                            calData       = i.ToString(),
                            labData       = i.ToString(),
                            oilInfoID     = oil.ID,
                            oilTableColID = i,
                            oilTableRowID = i
                        };
                        oil.OilDatas.Add(item);
                    }

                    OilBll.saveTables(oil);
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;
                }

                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox2.AppendText(string.Format("插入 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button2.Text    = "Run";
                this.button2.Enabled = true;
                this.richTextBox2.AppendText("\n");
            };

            this.Invoke(start2);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripBtnIn_Click(object sender, EventArgs e)
        {
            this.gridList.EndEdit();

            OilInfoAccess oilInfoAccess = new OilInfoAccess();
            LibManageBll  libManageBll  = new LibManageBll();
            string        alert         = "未导入的原油:";

            foreach (DataGridViewRow row in this.gridList.Rows)
            {
                #region
                if (bool.Parse(row.Cells["select"].Value.ToString()) == true)
                {
                    int        oilInfoId  = int.Parse(row.Cells["ID"].Value.ToString());
                    OilInfoOut oilInfoOut = this._outLib.oilInfoOuts.Where(c => c.ID == oilInfoId).FirstOrDefault();

                    OilInfoEntity oilInfoEntity = new OilInfoEntity();
                    libManageBll.toOilInfoEntity(ref oilInfoEntity, oilInfoOut);   //转换为OilInfoEntity
                    oilInfoEntity.ID = OilBll.save(oilInfoEntity);

                    if (oilInfoEntity.ID == -1)
                    {
                        DialogResult r = MessageBox.Show(oilInfoEntity.crudeIndex + "原油已存在!是否要更新", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (r == DialogResult.Yes)
                        {
                            oilInfoAccess.Delete("crudeIndex='" + oilInfoEntity.crudeIndex + "'"); //删除原油信息数据
                            oilInfoEntity.ID = OilBll.save(oilInfoEntity);                         //重新插入原油信息

                            libManageBll.toOilDatas(ref oilInfoEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                            OilBll.saveTables(oilInfoEntity);

                            DatabaseA.FrmOpenA frmOpenA = (DatabaseA.FrmOpenA)GetChildFrm("frmOpenA");
                            if (frmOpenA != null)  //如果打开原油库A的窗口存在,则更新
                            {
                                frmOpenA.refreshGridList(false);
                            }
                        }
                        else
                        {
                            alert += oilInfoEntity.crudeIndex + "  ";
                        }
                    }
                    else
                    {
                        try
                        {
                            libManageBll.toOilDatas(ref oilInfoEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                            OilBll.saveTables(oilInfoEntity);

                            DatabaseA.FrmOpenA frmOpenA = (DatabaseA.FrmOpenA)GetChildFrm("frmOpenA");
                            if (frmOpenA != null)  //如果打开原油库A的窗口存在,则更新
                            {
                                frmOpenA.refreshGridList(false);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("原油导入错误!" + ex.ToString());
                            return;
                        }
                        MessageBox.Show(oilInfoEntity.crudeName + "原油导入成功!");
                    }
                }
                #endregion
            }

            if (alert != "未导入的原油:")
            {
                MessageBox.Show(alert, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }