Example #1
0
        private void backgroundWorkerSearch_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (!isBat)
                {
                    this.BtnSearch.Enabled        = true;
                    this.Cursor                   = Cursors.Default;
                    CEnum.Message_Body[,] mResult = (CEnum.Message_Body[, ])e.Result;
                    if (mResult[0, 0].eName == CEnum.TagName.ERROR_Msg)
                    {
                        MessageBox.Show(mResult[0, 0].oContent.ToString());
                        return;
                    }

                    buttonSaveAS.Enabled = true;
                    result = "";
                    for (int j = 0; j < mResult.GetLength(0); j++)
                    {
                        for (int i = 0; i < mResult.GetLength(1); i++)
                        {
                            if (TxtPwd.Text.Trim() == "" && mResult[j, i].eName == CEnum.TagName.CARD_PDgetusername && mResult[j, i].oContent.ToString() == "" && Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate) != -1 && DateTime.Parse(mResult[j, Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate)].oContent.ToString()).Date >= DateTime.Parse("2006-6-1").Date)
                            {
                                result += config.ReadConfigValue("MAU", mResult[j, i].eName.ToString()) + ":";
                                result += config.ReadConfigValue("MAU", "CARD_ERROR");
                                result += "\r\n";
                            }
                            else
                            {
                                if (mResult[j, i].eName != CEnum.TagName.CARD_PDip)
                                {
                                    result += config.ReadConfigValue("MAU", mResult[j, i].eName.ToString()) + ":";
                                    result += mResult[j, i].oContent.ToString();
                                    result += "\r\n";
                                }
                            }
                        }
                    }
                    FileStream   fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + this.Name + ".txt", FileMode.Create, FileAccess.ReadWrite);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(result);
                    sw.Close();
                    fs.Close();
                    DataTable dt = new DataTable();
                    for (int i = 0; i < mResult.GetLength(1); i++)
                    {
                        dt.Columns.Add(config.ReadConfigValue("MAU", mResult[0, i].eName.ToString()));
                    }

                    for (int j = 0; j < mResult.GetLength(0); j++)
                    {
                        DataRow dr = dt.NewRow();
                        for (int i = 0; i < mResult.GetLength(1); i++)
                        {
                            if (TxtPwd.Text.Trim() == "" && mResult[0, i].eName == CEnum.TagName.CARD_PDgetusername && mResult[0, i].oContent.ToString() == "" && DateTime.Parse(mResult[0, Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate)].oContent.ToString()).Date >= DateTime.Parse("2006-6-1").Date)
                            {
                                dr[config.ReadConfigValue("MAU", mResult[0, i].eName.ToString())] = config.ReadConfigValue("MAU", "CARD_ERROR");
                            }
                            else
                            {
                                dr[config.ReadConfigValue("MAU", mResult[0, i].eName.ToString())] = mResult[0, i].oContent.ToString();
                            }
                        }
                        dt.Rows.Add(dr);
                    }
                    dataGridViewResult.DataSource = dt;
                }
                else
                {
                    this.BtnSearch.Enabled        = true;
                    this.Cursor                   = Cursors.Default;
                    buttonSaveAS.Enabled          = true;
                    dataGridViewResult.DataSource = dataResult;
                    dataGridViewError.DataSource  = dataErr;
                    FileStream   fs = new FileStream(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + this.Name + ".txt", FileMode.Create, FileAccess.ReadWrite);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(result);
                    sw.Close();
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void backgroundWorkerSearch_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (!isBat)
                {
                    lock (typeof(C_Event.CSocketEvent))
                    {
                        e.Result = Operation_Card.GetResult(this.m_ClientEvent, CEnum.ServiceKey.CARD_USERNUM_QUERY, (CEnum.Message_Body[])e.Argument);
                    }
                }
                else
                {
                    CEnum.Message_Body[,] mResult;
                    result     = "";
                    dataErr    = new DataTable();
                    dataResult = new DataTable();
                    dataErr.Columns.Add(config.ReadConfigValue("MAU", "CARD_cardnum"));
                    dataErr.Columns.Add(config.ReadConfigValue("MAU", "QC_CODE_Msg3"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_PDCardPASS"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_cardnum"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_cardtype"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_price"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_use_status"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_Locktype"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_use_username"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "TOEKN_BindDate"));
                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_PDgetusername"));

                    dataResult.Columns.Add(config.ReadConfigValue("MAU", "CARD_PDip"));
                    for (int i = 0; i < paramList.Count; i++)
                    {
                        CEnum.Message_Body[] mContent;
                        string[]             tmp = paramList[i].ToString().Split(' ');
                        if (tmp.GetLength(0) < 2)
                        {
                            mContent             = new CEnum.Message_Body[2];
                            mContent[0].eName    = CEnum.TagName.CARD_cardnum;
                            mContent[0].eTag     = CEnum.TagFormat.TLV_STRING;
                            mContent[0].oContent = tmp[0].Trim();


                            mContent[1].eName    = CEnum.TagName.CARD_cardpass;
                            mContent[1].eTag     = CEnum.TagFormat.TLV_STRING;
                            mContent[1].oContent = "";
                        }
                        else
                        {
                            mContent             = new CEnum.Message_Body[2];
                            mContent[0].eName    = CEnum.TagName.CARD_cardnum;
                            mContent[0].eTag     = CEnum.TagFormat.TLV_STRING;
                            mContent[0].oContent = tmp[0].Trim();


                            mContent[1].eName    = CEnum.TagName.CARD_cardpass;
                            mContent[1].eTag     = CEnum.TagFormat.TLV_STRING;
                            mContent[1].oContent = tmp[1].Trim();
                        }
                        lock (typeof(C_Event.CSocketEvent))
                        {
                            mResult = Operation_Card.GetResult(this.m_ClientEvent, CEnum.ServiceKey.CARD_USERNUM_QUERY, mContent);
                        }
                        if (mResult[0, 0].eName == CEnum.TagName.ERROR_Msg)
                        {
                            DataRow dr = dataErr.NewRow();
                            dr[0] = tmp[0].Trim();
                            dr[1] = mResult[0, 0].oContent.ToString();
                            dataErr.Rows.Add(dr);
                        }
                        else
                        {
                            for (int j = 0; j < mResult.GetLength(1); j++)
                            {
                                if (tmp.GetLength(0) < 2 && mResult[0, j].eName == CEnum.TagName.CARD_PDgetusername && mResult[0, j].oContent.ToString() == "" && Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate) != -1 && DateTime.Parse(mResult[0, Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate)].oContent.ToString()).Date >= DateTime.Parse("2006-6-1").Date)
                                {
                                    result += config.ReadConfigValue("MAU", mResult[0, j].eName.ToString()) + ":";
                                    result += config.ReadConfigValue("MAU", "CARD_ERROR");
                                    result += "\r\n";
                                }
                                else
                                {
                                    if (mResult[0, j].eName != CEnum.TagName.CARD_PDip)
                                    {
                                        result += config.ReadConfigValue("MAU", mResult[0, j].eName.ToString()) + ":";
                                        result += mResult[0, j].oContent.ToString();
                                        result += "\r\n";
                                    }
                                }
                            }
                            result += "\r\n";

                            DataRow dr = dataResult.NewRow();
                            for (int k = 0; k < mResult.GetLength(1); k++)
                            {
                                if (tmp.GetLength(0) < 2 && mResult[0, k].eName == CEnum.TagName.CARD_PDgetusername && mResult[0, k].oContent.ToString() == "" && Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate) != -1 && DateTime.Parse(mResult[0, Operation_Shop.findIdx(mResult, CEnum.TagName.TOEKN_BindDate)].oContent.ToString()).Date >= DateTime.Parse("2006-6-1").Date)
                                {
                                    dr[config.ReadConfigValue("MAU", mResult[0, k].eName.ToString())] = config.ReadConfigValue("MAU", "CARD_ERROR");
                                }
                                else
                                {
                                    dr[config.ReadConfigValue("MAU", mResult[0, k].eName.ToString())] = mResult[0, k].oContent.ToString();
                                }
                            }
                            dataResult.Rows.Add(dr);
                        }
                        this.backgroundWorkerSearch.ReportProgress((int)(((float)(i + 1)) / ((float)paramList.Count) * 100));
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }