//public static Worksheet GetWorksheetFromPath(string strEntireFileName = null)
        //{


        //}


        #region ExportEvaluationToExcel for ResultPtLt
        /// <summary>
        /// 将指标值导出到Excel中
        /// </summary>
        /// <param name="pParameterResultToExcel">指标结果信息</param>
        /// <param name="strSavePath">保存路径</param>
        /// <remarks>导出时,Excel显示的指标信息为到该点时的指标信息</remarks>
        public static void ExportEvaluationToExcel(CParameterResult pParameterResultToExcel, CParameterInitialize pParameterInitialize, string strSuffix)
        {
            ////为应付Excel的bug,加入以下两行代码
            //System.Globalization.CultureInfo CurrentCI = System.Threading.Thread.CurrentThread.CurrentCulture;
            //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            StatusStrip          ststMain    = pParameterInitialize.ststMain;
            ToolStripStatusLabel tsslTime    = pParameterInitialize.tsslTime;
            ToolStripStatusLabel tsslMessage = pParameterInitialize.tsslMessage;
            ToolStripProgressBar tspbMain    = pParameterInitialize.tspbMain;

            tsslMessage.Text = "正在将指标值导出到Excel...";
            ststMain.Refresh();
            long lngStartTime = System.Environment.TickCount;

            Excel.Application pExcelAPP = new Excel.Application();
            pExcelAPP.Visible = false;
            Workbook  pWorkBook   = pExcelAPP.Workbooks.Add(true);
            Worksheet pWorksheet  = pWorkBook.Worksheets[1] as Worksheet;
            string    strSavePath = pParameterInitialize.strSavePath;
            string    strfilename = System.IO.Path.GetFileNameWithoutExtension(strSavePath);

            switch (pParameterResultToExcel.strEvaluationMethod)
            {
            case "Integral":
            {
                ExportIntegralEvaluation(pParameterResultToExcel, ref pWorksheet, ref tspbMain);
                strfilename = strfilename + "Integral";
                break;
            }

            case "Translation":
            {
                ExportTranslationEvaluation(pParameterResultToExcel, ref pWorksheet, ref tspbMain);
                strfilename = strfilename + "Translation";
                break;
            }

            case "Deflection":
            {
                ExportTranslationEvaluation(pParameterResultToExcel, ref pWorksheet, ref tspbMain);
                strfilename = strfilename + "Deflection";
                break;
            }

            default: throw new ArgumentException("调用的评价指标值导出方法不存在!");
            }


            pWorksheet.Columns.AutoFit();
            pExcelAPP.DisplayAlerts = false;
            pWorkBook.SaveAs(strSavePath + "\\" + strfilename + strSuffix, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            pExcelAPP.Quit();

            long lngEndTime = System.Environment.TickCount;
            long lngTime    = lngEndTime - lngStartTime;

            tsslTime.Text    = "导出运行时间:" + Convert.ToString(lngTime) + "ms"; //显示运行时间
            tsslMessage.Text = "详细信息已导出到Excel!";
        }
Esempio n. 2
0
 private void StatusStrip_Update(double time)
 {
     StatusStrip.Invalidate();
     UpdateFPSLabel(this.FrameTracker.averageFramePerSecond);
     UpdateKeyStateLabel(this.tks);
     UpdateTimeLabel(time);
     StatusStrip.Refresh();
 }
Esempio n. 3
0
        /**
         * Szyfrowanie pliku
         */
        public void EncryptFile(string inputFileName, string outputFileName, UInt64 key1, UInt64 key2, UInt64 key3,
                                ToolStripStatusLabel statusLabel, StatusStrip statusStrip)
        {
            // sprawdzenie czy plik istnieje
            if (!File.Exists(inputFileName))
            {
                statusLabel.Text = "Plik nie istnieje";
                return;
            }
            FileStream fileStreamRead = new FileStream(inputFileName, FileMode.Open);

            // sprawdzenie rozmiaru pliku, wymagana wieloktorność 8 bajtów (64 bity)
            if (fileStreamRead.Length % 8 != 0)
            {
                statusLabel.Text = "Rozmiar pliku musi być wielokrotnością 8 bajtów";
                return;
            }

            FileStream fileStreamWrite = new FileStream(outputFileName, FileMode.Create, FileAccess.Write);

            int    block_count = (int)(fileStreamRead.Length / 8);
            UInt64 block       = 0;

            for (int i = 0; i < fileStreamRead.Length; i += 8)
            {
                // tworzenie bloku
                block = (UInt64)fileStreamRead.ReadByte();  // pierwszy bajt
                for (int j = 1; j < 8; j++)
                {
                    UInt64 blockByte = (UInt64)fileStreamRead.ReadByte();
                    blockByte <<= (j * 8);
                    block      |= blockByte;
                }

                // szyfrowanie bloku
                UInt64 result = EncryptBlock(block, key1, key2, key3);

                // zapisywanie bloku w pliku
                byte resultByte = (byte)(result & (UInt64)0xff);  // pierwszy bajt
                fileStreamWrite.WriteByte(resultByte);
                for (int j = 1; j < 8; j++)
                {
                    resultByte = (byte)((result >> (8 * j)) & 0x00000000000000ff);
                    fileStreamWrite.WriteByte(resultByte);
                }
                if ((i % 16000) == 0)
                {
                    statusLabel.Text = "Zaszyfrowano " + ((i + 8) / 8).ToString() + " / " + block_count.ToString() + " bloków";
                    statusStrip.Refresh();
                    Application.DoEvents();
                }
            }
            statusLabel.Text = "Zaszyfrowano " + block_count.ToString() + " / " + block_count.ToString() + " bloków";
            fileStreamWrite.Close();
            fileStreamRead.Close();
        }
Esempio n. 4
0
        public void Progress(string key, int percent, string message)
        {
            defaultStatusPanel.Caption = percent == 0 ? message : String.Format("{0}... {1}%", message, percent);

            if (!statusStrip.InvokeRequired)
            {
                // most actions happen on one thread and the status bar never repaints itself until the end of a process unless
                // we call Application.DoEvents() or refresh the control.
                statusStrip.Refresh();
            }
        }
Esempio n. 5
0
        public async static void FlashStrip(this StatusStrip statusStrip, Color flashColor, int flashes)
        {
            var originalColor = statusStrip.BackColor;
            int flashDelay    = 200;

            for (int i = 0; i < flashes; i++)
            {
                statusStrip.BackColor = flashColor;
                statusStrip.Refresh();

                await Task.Delay(flashDelay);

                statusStrip.BackColor = originalColor;
                statusStrip.Refresh();

                await Task.Delay(flashDelay);
            }

            statusStrip.BackColor = originalColor;
        }
Esempio n. 6
0
 private void RowsAddedToTable(int count)
 {
     if (progress1.Maximum >= progress1.Value + count)
     {
         progress1.Value += count;
     }
     else
     {
         progress1.Value = 0;
     }
     statusStrip1.Refresh();
 }
Esempio n. 7
0
 private void Start_Click(object sender, EventArgs e)
 {
     if (backgroundWorker.IsBusy != true)
     {
         StatusStripLabel.Text = "Started...";
         StatusStrip.Refresh();
         progressBar.Visible = true;
         Cancel.Enabled      = true;
         progressBar.Minimum = 1;
         progressBar.Maximum = Directory.EnumerateFiles(SourceDirectory.Text, "*.pdf", SearchOption.AllDirectories).ToArray().Length;
         progressBar.Step    = 1;
         backgroundWorker.RunWorkerAsync();
     }
 }
Esempio n. 8
0
        private void startScan()
        {
            table.Rows.Clear();

            ROMScanner scanner = new ROMScanner();

            scanner.datfilesLoadStart += delegate {
                statusText.Text = "Loading datfiles";
                statusBar.Refresh();
            };

            scanner.datfilesLoadEnd += delegate {
                statusText.Text = "Datfiles loaded";
                statusBar.Refresh();
            };

            scanner.exceptionHappened += addArchiveException;

            scanner.haveRow += addRow;

            scanner.runningWorkersUpdated += runningWorkersUpdated;

            scanner.startScan();
        }
Esempio n. 9
0
 public void Progress(string KeyOfSender, int Percent, string Message)
 {
     if (Percent == 0)
     {
         _progress.Visible   = false;
         _progressLabel.Text = "";
     }
     else
     {
         _progress.Visible   = true;
         _progress.Value     = Percent;
         _progressLabel.Text = Message;
     }
     _statusStrip.Refresh();
 }
Esempio n. 10
0
    private Dictionary <String, String> openToDirectory(String fileName)
    {
        Dictionary <String, String> d = new Dictionary <String, String>();
        int i = 0;

        try {
            string[] lines      = File.ReadAllLines(fileName);
            string   row        = "";
            string   brokenLine = "";
            int      firstMark  = 0;
            foreach (string line in lines)
            {
                i++;
                if (line.TrimStart().StartsWith("#") || line.Length == 0)
                {
                    continue;
                }
                firstMark = line.IndexOf("=");
                if (firstMark >= 0)
                {
                    row = line.Trim();
                    string[] keyAndValue = row.Split('=');
                    keyAndValue[0] = keyAndValue[0].Trim();
                    keyAndValue[1] = keyAndValue[1].Trim();
                    d.Add(keyAndValue[0], keyAndValue[1] + brokenLine);
                    //System.Console.WriteLine(i+"\t"+keyAndValue[0].Trim()+"\t"+keyAndValue[1].Trim()+"\n\t"+brokenLine);
                    if (!keys.Contains(keyAndValue[0]))
                    {
                        keys.Add(keyAndValue[0]);
                    }
                    brokenLine = "";
                }
                else
                {
                    brokenLine = line.TrimEnd();
                    continue;
                }
            }
            //keys = keys.Distinct().ToList();
            System.Console.WriteLine(keys.Count.ToString());
            statusLabel2.Text = d.Count.ToString();
            statusStrip.Refresh();
        } catch (Exception e2) {
            statusLabel.Text = e2.Message + " (row num: " + i + ")";
        }
        return(d);
    }
Esempio n. 11
0
 private void SetStatus(string t)
 {
     ss.Items[0].Text = t;
     ss.Refresh();
 }
Esempio n. 12
0
        /// <summary>计算Translation指标值,并保存输出</summary>
        /// <returns>Translation指标值</returns>
        /// <remarks></remarks>
        public double CalTranslation()
        {
            CParameterResult     ParameterResult     = _pDataRecords.ParameterResult;
            List <CPoint>        resultptlt          = ParameterResult.CResultPtLt;
            CParameterInitialize ParameterInitialize = _pDataRecords.ParameterInitialize;
            StatusStrip          ststMain            = ParameterInitialize.ststMain;
            ToolStripStatusLabel tsslTime            = ParameterInitialize.tsslTime;
            ToolStripStatusLabel tsslMessage         = ParameterInitialize.tsslMessage;
            ToolStripProgressBar tspbMain            = ParameterInitialize.tspbMain;

            tsslMessage.Text = "正在计算Translation...";
            ststMain.Refresh();
            long lngStartTime = System.Environment.TickCount;

            //生成计算Translation指标值的线段
            List <CPoint> CFrPtLtToExcel  = new List <CPoint>();
            List <CPoint> CToPtLtToExcel  = new List <CPoint>();
            List <CPoint> translationptlt = new List <CPoint>();
            int           intptnum        = 0;

            for (int i = 0; i < resultptlt.Count; i++)
            {
                for (int j = 0; j < resultptlt[i].CorrespondingPtLt.Count; j++)
                {
                    double dblX = resultptlt[i].CorrespondingPtLt[j].X - resultptlt[i].X;
                    double dblY = resultptlt[i].CorrespondingPtLt[j].Y - resultptlt[i].Y;
                    CPoint cpt  = new CPoint(intptnum, dblX, dblY);
                    translationptlt.Add(cpt);

                    CFrPtLtToExcel.Add(resultptlt[i]);
                    CToPtLtToExcel.Add(resultptlt[i].CorrespondingPtLt[j]);
                    intptnum = intptnum + 1;
                }
                tspbMain.Value = (i + 1) * 50 / (resultptlt.Count);
            }

            //添加第一个元素
            List <double> dblTranslationLt    = new List <double>();
            List <double> dblSumTranslationLt = new List <double>();

            dblTranslationLt.Add(0);
            dblSumTranslationLt.Add(0);
            double dblSumLenth = 0;

            for (int i = 1; i < translationptlt.Count; i++)
            {
                double dblLength = CGeoFunc.CalDis(translationptlt[i - 1], translationptlt[i]);
                dblTranslationLt.Add(dblLength);
                dblSumLenth = dblSumLenth + dblLength;
                dblSumTranslationLt.Add(dblSumLenth);

                tspbMain.Value = (i + 1) * 50 / (translationptlt.Count) + 50;
            }

            CParameterResult pParameterResultToExcel = new CParameterResult();

            pParameterResultToExcel.strEvaluationMethod = "Translation";
            pParameterResultToExcel.FromPtLt            = CFrPtLtToExcel;
            pParameterResultToExcel.ToPtLt              = CToPtLtToExcel;
            pParameterResultToExcel.TranlationPtLt      = translationptlt;
            pParameterResultToExcel.dblTranslationLt    = dblTranslationLt;
            pParameterResultToExcel.dblSumTranslationLt = dblSumTranslationLt;
            _pDataRecords.ParameterResultToExcel        = pParameterResultToExcel;

            long lngEndTime = System.Environment.TickCount;
            long lngTime    = lngEndTime - lngStartTime;

            tsslTime.Text    = "TranslationRunning Time: " + Convert.ToString(lngTime) + "ms"; //显示运行时间
            tsslMessage.Text = "Translation计算完成!";

            return(dblSumLenth);
        }
Esempio n. 13
0
        private void UpdateCommStrip()
        {
            if (DoReconnect)
            {
                DoReconnect    = false;
                timer1.Enabled = false;
                Thread.Sleep(100);
                Reconnect();
            }

            string commStatus = dv.GetCommStatus();

            switch (dv.GetCommState())
            {
            case CommunicationState.HWFind:
                CommMode = eCommMode.FindingHW;
                break;

            case CommunicationState.Idle:
                CommMode = eCommMode.Closed;
                break;

            case CommunicationState.Ready:
                CommMode = eCommMode.Running;
                string hwid = commStatus.Substring(commStatus.IndexOf("HW:") + 3, 4);
                if (hwid != "3002" &&
                    hwid != "3003" &&
                    hwid != "3004" &&
                    hwid != "3005" &&
                    hwid != "3006" &&
                    hwid != "3009"
                    )
                {
                    dv.Close();
                    DoReconnect = true;
                }
                break;

            default:
                CommMode = eCommMode.Closed;
                break;
            }

            toolStripStatusLabel.Text = commStatus;

            if (ControllerObj.DeviceID != deviceID.Unsupported && ControllerObj.DeviceID != m_DeviceID)
            {
                m_DeviceID = ControllerObj.DeviceID;
                groupBoxApplicationSelection.Text = ControllerObj.DeviceID.ToString();
            }

            pnlBootloader.Visible = false;
            switch (CommMode)
            {
            case eCommMode.Bootloader:
                groupBoxApplicationSelection.Enabled = false;
                CommStripButton.Image = ImageGreen;
                pnlBootloader.Visible = true;
                break;

            case eCommMode.FindingHW:
                groupBoxApplicationSelection.Enabled = false;
                CommStripButton.Image = ImageYellow;
                break;

            case eCommMode.Running:
                groupBoxApplicationSelection.Enabled = true;
                CommStripButton.Image = ImageGreen;
                break;

            case eCommMode.Closed:
                groupBoxApplicationSelection.Enabled = false;
                CommStripButton.Image = ImageRed;
                DoReconnect           = true;
                break;
            }
            CommStrip.Refresh();
        }
Esempio n. 14
0
    static private void ButtonClick(object sender, EventArgs e)
    {
        OpenFileDialog openDialog = new OpenFileDialog();

        openDialog.Title  = "Select A File";
        openDialog.Filter = "MJK Files (*.mjk)|*.mjk" + "|" +
                            "Text Files (*.txt)|*.txt" + "|" +
                            "All Files (*.*)|*.*";
        openDialog.InitialDirectory = Environment.CurrentDirectory;
        if (openDialog.ShowDialog() == DialogResult.OK)
        {
            statusLabel.Text = openDialog.FileName;

            int    i   = 0;
            string row = String.Empty;
            try {
                //String file = File.ReadAllText(myLabel.Text);
                string[] lines = File.ReadAllLines(statusLabel.Text, Encoding.Default);

                pontok = new List <Dictionary <String, String> >();
                foreach (string line in lines)
                {
                    i++;

                    if (line.Contains("Meghat") || line.Contains("Y=") || line.Contains("X=") || line.Contains("h=") || line.Contains("hib") || line.Contains("Dátum"))
                    {
                        row += line + ";";
                    }
                    else if ((Regex.Match(line, @"-{20,}")).Success)
                    {
                        row = Regex.Replace(row, @"(\s{2,}|\t+)", ";");
                        row = Regex.Replace(row, @"=", ":");

                        //Hashtable pont = new Hashtable();
                        Dictionary <String, String> pont = new  Dictionary <String, String>();
                        foreach (string data in row.Split(';'))
                        {
                            string[] kv = data.Split(':');
                            if (kv.Length == 2)
                            {
                                pont.Add(kv[0], kv[1]);
                            }
                        }
                        if (!pont.Count.Equals(0))
                        {
                            pontok.Add(pont);
                        }
                        row = String.Empty;
                    }
                    System.Console.Write("pontok feltöltése: " + i + "/" + lines.Length + "\r");
                    statusLabel2.Text = i + "/" + lines.Length;
                    statusStrip.Refresh();
                }
                System.Console.WriteLine("\nPontok száma: " + pontok.Count);

                // Adatok
                //dataGridView.AutoGenerateColumns = false;
                dataGridView.DataSource = null;
                //dataTable.Reset();
                //dataTable.Clear();
                DataTable dataTable = new DataTable();

                // Fejléc
                foreach (var key in pontok[0].Keys)
                {
                    dataTable.Columns.Add(key.ToString(), typeof(string));
                }

                //foreach ( Hashtable p in pontok ) {
                i = 0;
                foreach (Dictionary <String, String> p in pontok)
                {
                    i++;
                    //foreach (DictionaryEntry entry in p) {
                    List <string> r = new List <string>();
                    foreach (KeyValuePair <String, String> entry in p)
                    {
                        r.Add(entry.Value);
                    }
                    dataTable.Rows.Add(r.ToArray());
                    System.Console.Write("dataTable feltöltés: " + i + "/" + pontok.Count + "\r");
                }
                System.Console.WriteLine("\ndataTable száma: " + dataTable.Rows.Count);

                System.Console.WriteLine("table to grid..." + DateTime.Now.ToString("h:mm:ss tt"));
                dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;                 // Enélkül folyamatosan újraszámol, igazítja a cellákat, ami sokszorosára növeli az időigényt.
                dataGridView.DataSource          = dataTable;
                System.Console.WriteLine("done." + DateTime.Now.ToString("h:mm:ss tt"));
                foreach (DataGridViewRow dgrow in dataGridView.Rows)
                {
                    dgrow.HeaderCell.Value           = String.Format("{0}", dgrow.Index + 1);
                    dgrow.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                }
                //dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
                dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                //dataGridView.Update();
                //dataGridView.Refresh();
                System.Console.WriteLine("->" + DateTime.Now.ToString("h:mm:ss tt"));
            } catch (Exception e2) {
                statusLabel.Text = e2.Message + " (sorszám: " + i + ")";
                System.Console.WriteLine("[" + row + "]");
            }
        }
    }
Esempio n. 15
0
        /// <summary>计算Translation指标值,并保存输出</summary>
        /// <returns>Translation指标值</returns>
        /// <remarks>further weighted by the ratio</remarks>
        public double CalRatioTranslation()
        {
            //MessageBox.Show("wrong call in ctranslation!");

            CParameterResult     ParameterResult     = _pDataRecords.ParameterResult;
            List <CPoint>        resultptlt          = ParameterResult.CResultPtLt;
            CParameterInitialize ParameterInitialize = _pDataRecords.ParameterInitialize;
            StatusStrip          ststMain            = ParameterInitialize.ststMain;
            ToolStripStatusLabel tsslTime            = ParameterInitialize.tsslTime;
            ToolStripStatusLabel tsslMessage         = ParameterInitialize.tsslMessage;
            ToolStripProgressBar tspbMain            = ParameterInitialize.tspbMain;

            tsslMessage.Text = "正在计算Translation...";
            ststMain.Refresh();
            long lngStartTime = System.Environment.TickCount;

            //生成计算Translation指标值的线段
            List <CPoint> CFrPtLtToExcel  = new List <CPoint>();
            List <CPoint> CToPtLtToExcel  = new List <CPoint>();
            List <CPoint> translationptlt = new List <CPoint>();
            List <double> dblWeightlt     = new List <double>();  //记录相应的权重值(注意:由于程序的需要,再后面的计算中,有意使得dblWeightlt[0]==0)
            double        dblSumLength    = _pDataRecords.ParameterResult.FromCpl.pPolyline.Length + _pDataRecords.ParameterResult.ToCpl.pPolyline.Length;



            int    intptnum  = 0;
            CPoint frlastcpt = resultptlt[0];
            CPoint tolastcpt = resultptlt[0].CorrespondingPtLt[0];

            for (int i = 0; i < resultptlt.Count; i++)
            {
                for (int j = 0; j < resultptlt[i].CorrespondingPtLt.Count; j++)
                {
                    double dblX = resultptlt[i].CorrespondingPtLt[j].X - resultptlt[i].X;
                    double dblY = resultptlt[i].CorrespondingPtLt[j].Y - resultptlt[i].Y;
                    CPoint cpt  = new CPoint(intptnum, dblX, dblY);
                    translationptlt.Add(cpt);

                    double dblLengthi = CGeoFunc.CalDis(resultptlt[i], frlastcpt);                      //计算权重值长度
                    double dblLengthj = CGeoFunc.CalDis(resultptlt[i].CorrespondingPtLt[j], tolastcpt); //计算权重值长度
                    double dblWeight  = (dblLengthi + dblLengthj) / dblSumLength;
                    dblWeightlt.Add(dblWeight);
                    tolastcpt = resultptlt[i].CorrespondingPtLt[j];  //更新tolastcpt

                    CFrPtLtToExcel.Add(resultptlt[i]);
                    CToPtLtToExcel.Add(resultptlt[i].CorrespondingPtLt[j]);
                    intptnum = intptnum + 1;
                }
                frlastcpt      = resultptlt[i]; //更新frlastcpt
                tspbMain.Value = (i + 1) * 50 / (resultptlt.Count);
            }

            //添加第一个元素
            List <double> dblTranslationLt    = new List <double>();
            List <double> dblSumTranslationLt = new List <double>();

            dblTranslationLt.Add(0);
            dblSumTranslationLt.Add(0);
            double dblSumTranslation = 0;

            for (int i = 1; i < translationptlt.Count; i++)
            {
                double dblRatioLength = CGeoFunc.CalDis(translationptlt[i - 1], translationptlt[i]) * dblWeightlt[i];
                dblTranslationLt.Add(dblRatioLength);
                dblSumTranslation = dblSumTranslation + dblRatioLength;
                dblSumTranslationLt.Add(dblSumTranslation);

                tspbMain.Value = (i + 1) * 50 / (translationptlt.Count) + 50;
            }

            CParameterResult pParameterResultToExcel = new CParameterResult();

            pParameterResultToExcel.strEvaluationMethod = "Translation";
            pParameterResultToExcel.FromPtLt            = CFrPtLtToExcel;
            pParameterResultToExcel.ToPtLt              = CToPtLtToExcel;
            pParameterResultToExcel.TranlationPtLt      = translationptlt;
            pParameterResultToExcel.dblTranslationLt    = dblTranslationLt;
            pParameterResultToExcel.dblSumTranslationLt = dblSumTranslationLt;
            _pDataRecords.ParameterResultToExcel        = pParameterResultToExcel;

            long lngEndTime = System.Environment.TickCount;
            long lngTime    = lngEndTime - lngStartTime;

            tsslTime.Text    = "TranslationRunning Time: " + Convert.ToString(lngTime) + "ms"; //显示运行时间
            tsslMessage.Text = "Translation计算完成!";

            return(dblSumTranslation);
            //return 0;
        }
Esempio n. 16
0
        private void btnCheckCompanies_Click(object sender, EventArgs e)
        {
            this.UseWaitCursor        = true;
            btnCheckCompanies.Enabled = false;
            btnSelectAll.Enabled      = false;
            btnSelectNone.Enabled     = false;
            btnClose.Enabled          = false;

            clsCoreChecks CoreChecks = new clsCoreChecks();
            clsTransactionHeaderChecks         TransactionHeaderChecks         = new clsTransactionHeaderChecks();
            clsTransactionLineChecks           TransactionLineChecks           = new clsTransactionLineChecks();
            clsTransactionLineJobCostingChecks TransactionLineJobCostingChecks = new clsTransactionLineJobCostingChecks();
            clsTransactionLineStockCheck       TransactionLineStockChecks      = new clsTransactionLineStockCheck();
            clsHistoryChecks       HistoryChecks       = new clsHistoryChecks();
            clsHistoryCalculations HistoryCalculations = new clsHistoryCalculations();

            //SS:01/03/2018:2018-R1:ABSEXCH-19796: When Running the ExchDVT.exe, SQL Admin Passwords are visible in dump file.
            ADODB.Connection conn = new ADODB.Connection();

            ADODB.Command cmd = new ADODB.Command();
            cmd.CommandText = "IF EXISTS (SELECT * FROM sys.tables WHERE name LIKE 'SQLDataValidation%') DROP TABLE common.SQLDataValidation; " +
                              "CREATE TABLE common.SQLDataValidation(IntegrityErrorNo varchar(50), " +
                              "IntegrityErrorCode varchar(50), " +
                              "Severity varchar(50), " +
                              "IntegrityErrorMessage varchar(max), " +
                              "IntegritySummaryDescription varchar(max), " +
                              "SchemaName varchar(10), " +
                              "TableName varchar(100), " +
                              "PositionId int);";

            cmd.CommandTimeout = 10000;

            if (conn.State == 0)
            {
                if (connPassword.Trim() == "")
                {
                    conn.Open();
                }
                else
                {
                    conn.Open(ExchequerCommonSQLConnection, "", connPassword.Trim(),
                              (int)ConnectModeEnum.adModeUnknown);
                }
            }
            conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

            try
            {
                Object recAff;
                cmd.ActiveConnection = conn;
                cmd.CommandType      = ADODB.CommandTypeEnum.adCmdText;
                cmd.Execute(out recAff, Type.Missing, (int)ADODB.CommandTypeEnum.adCmdText);
                Console.WriteLine("Table Created Successfully...");

                if (conn.State == 1)
                {
                    conn.Close();
                }
            }
            catch
            {
                throw;
            }

            // Build List of Companies to check
            tsProgressBar.Value   = 0;
            tsProgressBar.Maximum = (lvCompanies.CheckedItems.Count * 37) + 1;

            foreach (ListViewItem lvItem in lvCompanies.CheckedItems)
            {
                string Company = lvItem.SubItems[1].Text.ToString();
                tsCheckStatus.Text = "Checking " + Company;
                IncrementToolbar();
                StatusStrip.Refresh();

                // Run Core Checks
                // Check for inverted currencies if system either Euro or Multi-Currency
                if (MultiCurrency == true)
                {
                    CoreChecks.CheckInvertedCurrencies(ExchequerCommonSQLConnection, Company, connPassword);
                }
                IncrementToolbar();

                //SS:01/03/2018:2018-R1:ABSEXCH-19796: When Running the ExchDVT.exe, SQL Admin Passwords are visible in dump file.
                // Run Transaction Header Checks
                // Check for Transaction Headers with Zero Folio Number
                TransactionHeaderChecks.TransactionZeroFolioNum(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check if Transaction Header Trader Codes Exist
                TransactionHeaderChecks.TransactionTraderCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Control GL codes exist if they are set
                TransactionHeaderChecks.TransactionCheckControlGLCodesExistIfSet(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Control GL Codes are not Headers
                TransactionHeaderChecks.TransactionCheckControlGLNotHeaders(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Currency Codes exist
                TransactionHeaderChecks.TransactionCheckCurrencyCodeExists(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Run Transaction Line Checks
                // Check Transaction Header exists for non RUN transaction lines
                TransactionLineChecks.TransactionLineExistsWithNoTransactionHeader(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check if Transaction Lines exist with invalid GL Code
                TransactionLineChecks.TransactionLineExistWithInvalidGLCode(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check if Transaction Lines exist with Header GL Code
                TransactionLineChecks.TransactionLineExistWithHeaderGLCode(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check if Transction Lines exist with invalid Trader Code
                TransactionLineChecks.TransactionLineExistInvalidTraderCode(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check if Transaction Line Trader Code is same as Transaction Header Trader Code
                TransactionLineChecks.TransactionLineTraderCodeMatchesHeader(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Transaction Line Currency Codes Exist
                TransactionLineChecks.TransactionLineCurrencyCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Transaction Line VAT Code Exists
                TransactionLineChecks.TransactionLineVATCodeExists(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Transaction Line Inclusive VAT Code Exists
                TransactionLineChecks.TransactionLineInclusiveVATCodeExists(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check Transaction Line Period Matches Header Period
                TransactionLineChecks.TransactionLinePeriodMatchesHeaderPeriod(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check History Currency Codes Exist
                HistoryChecks.HistoryCheckCurrencyCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check History General Ledger Codes Exist
                HistoryChecks.HistoryCheckGLCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                IncrementToolbar();

                // Check if Cost Centres/Departments are used
                if (CCDept[lvItem.Index] == true)
                {
                    // Check Transaction Line Cost Centre Codes Exist
                    TransactionLineChecks.TransactionLineCostCentresExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Transaction Line Department Codes Exist
                    TransactionLineChecks.TransactionLineDepartmentsExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check History Cost Centre Codes Exist
                    HistoryChecks.HistoryCheckCostCentreCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check History Department Codes Exist
                    HistoryChecks.HistoryCheckDepartmentCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();
                }

                // Check if Job Costing enabled
                if (JobCosting[lvItem.Index] == true)
                {
                    // Check Employee Codes on Header exist
                    TransactionHeaderChecks.TransactionCheckEmployeeCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Transaction Line Job Exists
                    TransactionLineJobCostingChecks.TransactionLineJobExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Transaction Line Job check not Contract
                    TransactionLineJobCostingChecks.TransactionLineCheckJobNotContract(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Transaction Line Analysis Code Exists
                    TransactionLineJobCostingChecks.TransactionLineCheckAnalysisCodeExists(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Employee Currency History Codes Exist
                    HistoryChecks.HistoryCheckEmployeeCurrencyCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Employee History Codes Exist
                    HistoryChecks.HistoryCheckEmployeeCodesExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Job Currency History Codes Exist
                    HistoryChecks.HistoryCheckJobCurrencyExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Job History Codes Exist
                    HistoryChecks.HistoryCheckJobExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Analysis Id History Codes Exist
                    HistoryChecks.HistoryCheckAnalysisIdExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();
                }
                else
                {
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                }

                // Check if Stock enabled
                if (StockModule[lvItem.Index] == true)
                {
                    // Check Transaction Line Stock Code Exists
                    TransactionLineStockChecks.TransactionLineStockCodeExists(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Transaction Line Stock Code not a Group
                    TransactionLineStockChecks.TransactionLineStockCodeNotGroup(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check Stock History Stock Codes Exists
                    HistoryChecks.HistoryCheckStockExist(ExchequerCommonSQLConnection, Company, connPassword);
                    IncrementToolbar();

                    // Check if Locations is enabled
                    if (Locations[lvItem.Index] == true)
                    {
                        // Check if Transaction Line Location Codes exist
                        TransactionLineStockChecks.TransactionLineLocationCodeDoesNotExist(ExchequerCommonSQLConnection, Company, connPassword);
                        IncrementToolbar();

                        // Check Stock History Location Codes Exists
                        HistoryChecks.HistoryCheckLocationExist(ExchequerCommonSQLConnection, Company, connPassword);
                        IncrementToolbar();

                        // Check Stock History Stock Location Codes Exists
                        HistoryChecks.HistoryCheckStockLocationExist(ExchequerCommonSQLConnection, Company, connPassword);
                        IncrementToolbar();
                    }
                    else
                    {
                        IncrementToolbar();
                        IncrementToolbar();
                        IncrementToolbar();
                    }
                }
                else
                {
                    IncrementToolbar();
                    IncrementToolbar();
                    IncrementToolbar();
                }

                // Check Profit and Loss Brought Forward
                HistoryCalculations.ProfitAndLossBroughtForward(ExchequerCommonSQLConnection, Company, CommitmentAccounting[lvItem.Index], connPassword);
                IncrementToolbar();
            }

            this.UseWaitCursor        = false;
            btnCheckCompanies.Enabled = true;
            btnSelectAll.Enabled      = true;
            btnSelectNone.Enabled     = true;
            //btnEmailResults.Enabled = true;
            btnSaveResults.Enabled = true;
            btnClose.Enabled       = true;
            tsCheckStatus.Text     = "Checking Completed";

            tsProgressBar.Value = tsProgressBar.Maximum;
            Thread.Sleep(100);
            Application.DoEvents();

            // Display Summary Results in UI
            DisplayResults();
        }
Esempio n. 17
0
            /// <summary>
            /// 【第一步、调用函数 SetUIInChinese 或者 SetUIInUKEnglish】;
            /// 【第二步、调用函数 ChangeLanguageOfUI】;
            /// ------------------------------------------------------------------------
            /// 修改UI界面语言,请先执行设置语言的函数,然后再执行此函数来调用对应的资源来更新UI:
            /// 特别注意:调用此函数后,窗体会恢复到初始状态,还需要根据情况再次设置界面的具体内容,例如 visible/enable等属性;
            /// </summary>
            /// <param name="TargetSource"目标窗体对应的组件资源对象,
            /// 请使用此格式来实例化对象:ComponentResourceManager resource = new ComponentResourceManager(typeof(目标窗体类名称));
            /// 例如:ComponentResourceManager resource = new ComponentResourceManager(typeof(Form1));></param>
            /// <param name="TargetControl">目标控件,可以是窗体(this)或者其它 Control 类型,这里只需要 this 就会自动将窗体里面所有的 Control 更新为对应语言的资源</param>
            public void ChangeLanguageOfUI(ComponentResourceManager TargetSource, Control TargetControl)
            {
                try
                {
                    TargetSource.ApplyResources(TargetControl, TargetControl.Name);
                    TargetControl.ResumeLayout();
                    //TargetControl.Update();
                    TargetControl.Refresh();

                    if (TargetControl is MenuStrip)
                    {
                        //菜单
                        MenuStrip tempMenu = TargetControl as MenuStrip;
                        tempMenu.SuspendLayout();
                        foreach (ToolStripMenuItem item in tempMenu.Items)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                                if (null != item.DropDownItems && item.DropDownItems.Count > 0)
                                {
                                    foreach (ToolStripMenuItem subitem in item.DropDownItems)
                                    {
                                        if (null != subitem)
                                        {
                                            TargetSource.ApplyResources(subitem, subitem.Name);
                                        }
                                    } 
                                }
                            }
                        }
                        tempMenu.ResumeLayout();
                        tempMenu.Update();
                        tempMenu.Refresh();
                    }
                    else if (TargetControl is StatusStrip)
                    {
                        //状态栏
                        StatusStrip tempStatusStrip = TargetControl as StatusStrip;
                        tempStatusStrip.SuspendLayout();
                        foreach (ToolStripStatusLabel item in tempStatusStrip.Items)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                            }
                        }
                        tempStatusStrip.ResumeLayout();
                        tempStatusStrip.Update();
                        tempStatusStrip.Refresh();
                    }
                    else if (TargetControl is ToolStrip)//如果传入的控件是StatusStrip,这里的判断条件也是 true,这可能是因为继承的关系
                    {
                        //工具栏按钮
                        ToolStrip tempToolStrip = TargetControl as ToolStrip;
                        tempToolStrip.SuspendLayout();
                        foreach (ToolStripButton item in tempToolStrip.Items)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                            }
                        }
                        tempToolStrip.ResumeLayout();
                        tempToolStrip.Update();
                        tempToolStrip.Refresh();
                    }
                    else if (TargetControl is Form)
                    {
                        //窗体
                        TargetSource.ApplyResources(TargetControl, "$this");
                        foreach (Control item in TargetControl.Controls)
                        {
                            if (null != item)
                            {
                                ChangeLanguageOfUI(TargetSource, item);
                            }
                        }
                        TargetControl.ResumeLayout();
                        TargetControl.Update();
                        TargetControl.Refresh();
                    }
                    else if (TargetControl is DataGridView)
                    {
                        //DataGridView
                        DataGridView tempDataGridView = TargetControl as DataGridView;
                        foreach (DataGridViewColumn item in tempDataGridView.Columns)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                            }
                        }
                        //tempDataGridView.Update();
                        tempDataGridView.Refresh();
                    }
                    else if (TargetControl is TreeView)
                    {
                        //TreeView
                        TreeView tempTreeView = TargetControl as TreeView;
                        if (tempTreeView.Nodes.Count > 0)
                        {
                            tempTreeView.SuspendLayout();
                            TreeNode[] tempTreeNodes = new TreeNode[tempTreeView.Nodes.Count];
                            for (int i = 0; i < tempTreeView.Nodes.Count; i++)
                            {
                                if (i == 0)
                                {
                                    tempTreeNodes[i] = (TreeNode)TargetSource.GetObject(tempTreeView.Name + ".Nodes");
                                }
                                else
                                {
                                    tempTreeNodes[i] = (TreeNode)TargetSource.GetObject(tempTreeView.Name + ".Nodes" + i.ToString());
                                }
                            }

                            tempTreeView.Nodes.Clear();
                            tempTreeView.Nodes.AddRange(tempTreeNodes);
                            tempTreeView.ResumeLayout();
                        }
                    }
                    else if (TargetControl is CheckedListBox)
                    {
                        //CheckedListBox
                        CheckedListBox tempCheckedListBox = TargetControl as CheckedListBox;
                        if (tempCheckedListBox.Items.Count > 0)
                        {
                            object[] tempCheckedListBoxItems = new object[tempCheckedListBox.Items.Count];
                            for (int i = 0; i < tempCheckedListBox.Items.Count; i++)
                            {
                                if (i == 0)
                                {
                                    tempCheckedListBoxItems[i] = TargetSource.GetString(tempCheckedListBox.Name + ".Items");
                                }
                                else
                                {
                                    tempCheckedListBoxItems[i] = TargetSource.GetString(tempCheckedListBox.Name + ".Items" + i.ToString());
                                }
                            }

                            tempCheckedListBox.Items.Clear();
                            tempCheckedListBox.Items.AddRange(tempCheckedListBoxItems);

                            tempCheckedListBox.ResumeLayout();
                            tempCheckedListBox.Update();
                            tempCheckedListBox.Refresh();
                        }
                    }
                    else if (TargetControl is ListBox)
                    {
                        //ListBox
                        ListBox tempListBox = TargetControl as ListBox;
                        if (tempListBox.Items.Count > 0)
                        {
                            object[] tempListBoxItems = null;// new object[tempListBox.Items.Count];
                            int iItemIndexCount = 0;
                            string TempItem = "";

                            //发生错误:值不能为 null。
                            //参数名: item;    在 System.Windows.Forms.ListBox.ObjectCollection.AddInternal(Object item)

                            for (int i = 0; i < tempListBox.Items.Count; i++)
                            {
                                if (i == 0)
                                {
                                    TempItem = TargetSource.GetString(tempListBox.Name + ".Items");
                                    if (null != TempItem && TempItem != "")
                                    {
                                        tempListBoxItems = new object[1];
                                        //Array.Resize<object>(ref tempListBoxItems, iItemIndexCount + 1);
                                        tempListBoxItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                }
                                else
                                {
                                    TempItem = TargetSource.GetString(tempListBox.Name + ".Items" + i.ToString());
                                    if (null != TempItem && TempItem != "")
                                    {
                                        Array.Resize<object>(ref tempListBoxItems, iItemIndexCount + 1);
                                        tempListBoxItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                }
                            }

                            if (null != tempListBoxItems)
                            {
                                tempListBox.Items.Clear();
                                tempListBox.Items.AddRange(tempListBoxItems);

                                tempListBox.ResumeLayout();
                                tempListBox.Update();
                                tempListBox.Refresh();
                            }
                            else
                            {
                                ErrorMessage.Enqueue("窗体 " + TargetControl.FindForm().Name + " 的ListBox控件 " + TargetControl.Name + " 子项为空或者没有建立多语言版本的资源");
                            }
                        }
                    }
                    else if (TargetControl is ListView)
                    {
                        //ListView
                        ListView tempListView = TargetControl as ListView;
                        if (tempListView.Items.Count > 0)
                        {
                            ListViewItem[] tempTreeNodes = new ListViewItem[tempListView.Items.Count];
                            for (int i = 0; i < tempListView.Items.Count; i++)
                            {
                                if (i == 0)
                                {
                                    tempTreeNodes[i] = (ListViewItem)TargetSource.GetObject(tempListView.Name + ".Items");
                                }
                                else
                                {
                                    tempTreeNodes[i] = (ListViewItem)TargetSource.GetObject(tempListView.Name + ".Items" + i.ToString());
                                }
                            }

                            tempListView.Items.Clear();
                            tempListView.Items.AddRange(tempTreeNodes);
                        }

                        if (tempListView.Columns.Count > 0)
                        {
                            for (int i = 0; i < tempListView.Columns.Count; i++)
                            {
                                TargetSource.ApplyResources(tempListView.Columns[i], "columnHeader" + (i + 1).ToString());
                            }
                        }

                        tempListView.ResumeLayout();
                        tempListView.Update();
                        tempListView.Refresh();
                    }
                    else if (TargetControl is ComboBox)
                    {
                        //ComboBox
                        ComboBox tempComboBox = TargetControl as ComboBox;
                        
                        if (tempComboBox.Items.Count > 0)
                        {
                            tempComboBox.SuspendLayout();
                            object[] AllItems = null;// new object[1];//tempComboBox.Items.Count
                            int iItemIndexCount = 0;
                            string TempItem = "";

                            // 发生错误:值不能为 null。
                            // 参数名: item;    在 System.Windows.Forms.ComboBox.ObjectCollection.AddInternal(Object item)
                            
                            for (int i = 0; i < tempComboBox.Items.Count; i++)
                            {
                                if (iItemIndexCount == 0)
                                {
                                    //Array.Resize<object>(ref AllItems, iItemIndexCount + 1);
                                    TempItem = TargetSource.GetString(tempComboBox.Name + ".Items");
                                    if (null != TempItem && TempItem != "")
                                    {
                                        AllItems = new object[1];
                                        AllItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                    //
                                }
                                else
                                {
                                    TempItem = TargetSource.GetString(tempComboBox.Name + ".Items" + i.ToString());
                                    if (null != TempItem && TempItem != "")
                                    {
                                        Array.Resize<object>(ref AllItems, iItemIndexCount + 1);
                                        AllItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                }
                            }

                            if (null != AllItems)
                            {
                                tempComboBox.Items.Clear();
                                tempComboBox.Items.AddRange(AllItems);
                                tempComboBox.SelectedIndex = 0;

                                tempComboBox.ResumeLayout();
                                //tempComboBox.Update();
                                tempComboBox.Refresh();
                            }
                            else
                            {
                                ErrorMessage.Enqueue("窗体 " + TargetControl.FindForm().Name + " 的ComboBox控件 " + TargetControl.Name + " 子项为空或者没有建立多语言版本的资源");
                            }
                        }
                    }
                    else
                    {
                        if (TargetControl.HasChildren == true)
                        {
                            foreach (Control item in TargetControl.Controls)
                            {
                                if (null != item)
                                {
                                    ChangeLanguageOfUI(TargetSource, item);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //throw ex;
                    ErrorMessage.Enqueue(DateTime.Now.ToString() + "*-*" + "发生错误:" + ex.Message + "; " + ex.StackTrace);
                }
            }