當前位置: 首頁>>代碼示例>>C#>>正文


C# Log.write方法代碼示例

本文整理匯總了C#中System.Log.write方法的典型用法代碼示例。如果您正苦於以下問題:C# Log.write方法的具體用法?C# Log.write怎麽用?C# Log.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Log的用法示例。


在下文中一共展示了Log.write方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: buttonValuesApply_Click

 private void buttonValuesApply_Click(object sender, EventArgs e)
 {
     try {
         Settings.Default.fuelLiterToKilometer = float.Parse(textBoxValuesFuelToKilometers.Text);
         Settings.Default.fuelLiterToCost = float.Parse(textBoxValuesFuelToCost.Text);
         Settings.Default.Save();
         MessageBox.Show(this, "Fuel and Cost has been saved!", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
     } catch (Exception exception) {
         Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
         string logData = DateTime.Now.ToString() + "\t\t Exception \t\t" + "Values" + " : " + exception.Message;
         log.write(logData);
         MessageBox.Show(this, "Wrong Format! Please try again. Ex. '10.00'", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:14,代碼來源:FormAdvanceSettings.cs

示例2: dataTableToText

        public void dataTableToText(DataTable dataTable, string fileName)
        {
            StreamWriter streamWriter;
            streamWriter = new StreamWriter(fileName, true);
            try {

                streamWriter.Write("ReportType\t\t\t" + Enum.GetName(typeof(ReportType), reportType) + "\r\n");
                streamWriter.Write("CompanyName\t\t\t" + reportInformation.companyName + "\r\n");

                if (
                    this.reportType == ReportType.HISTORICAL ||
                    this.reportType == ReportType.RUNNING ||
                    this.reportType == ReportType.IDLING ||
                    this.reportType == ReportType.GEOFENCE ||
                    this.reportType == ReportType.ACC ||
                    this.reportType == ReportType.OVERSPEED ||
                    this.reportType == ReportType.EXTERNAL_POWER_CUT
                    ) {

                    streamWriter.Write("VehicleRegistration\t" + reportInformation.trackerVehicleReg + "\r\n");
                    streamWriter.Write("VehicleModel\t\t\t" + reportInformation.trackerVehicleModel + "\r\n");
                    streamWriter.Write("OwnerName\t\t\t" + reportInformation.trackerOwnerName + "\r\n");
                    streamWriter.Write("DriverName\t\t\t" + reportInformation.trackerDriverName + "\r\n");
                    streamWriter.Write("DeviceImei\t\t\t" + reportInformation.trackerDeviceImei + "\r\n");
                }

                switch (this.reportType) {
                    case ReportType.RUNNING:
                        streamWriter.Write("Total Distance\t\t\t" + reportInformation.summaryTotalDistance + "\r\n");
                        streamWriter.Write("Total Fuel\t\t\t" + reportInformation.summaryTotalFuel + "\r\n");
                        streamWriter.Write("Total Cosl\t\t\t" + reportInformation.summaryTotalCost + "\r\n");
                        streamWriter.Write("Total Running Time\t\t\t" + reportInformation.summaryTotalRunningTime + "\r\n");
                        break;
                    case ReportType.IDLING:
                        streamWriter.Write("Total Distance\t\t\t" + reportInformation.summaryTotalDistance + "\r\n");
                        streamWriter.Write("Total Fuel\t\t\t" + reportInformation.summaryTotalFuel + "\r\n");
                        streamWriter.Write("Total Cosl\t\t\t" + reportInformation.summaryTotalCost + "\r\n");
                        streamWriter.Write("Total Idling Time\t\t\t" + reportInformation.summaryTotalIdlingTime + "\r\n");
                        break;
                    case ReportType.GEOFENCE:
                        streamWriter.Write("Total Distance\t\t\t" + reportInformation.summaryTotalDistance + "\r\n");
                        streamWriter.Write("Total Fuel\t\t\t" + reportInformation.summaryTotalFuel + "\r\n");
                        streamWriter.Write("Total Cosl\t\t\t" + reportInformation.summaryTotalCost + "\r\n");
                        streamWriter.Write("Total Geofence Active Time\t\t\t" + reportInformation.summaryTotalGeofenceActiveTime + "\r\n");
                        break;
                    case ReportType.ACC:
                        streamWriter.Write("Total Distance\t\t\t" + reportInformation.summaryTotalDistance + "\r\n");
                        streamWriter.Write("Total Fuel\t\t\t" + reportInformation.summaryTotalFuel + "\r\n");
                        streamWriter.Write("Total Cosl\t\t\t" + reportInformation.summaryTotalCost + "\r\n");
                        streamWriter.Write("Total ACC Active Time\t\t\t" + reportInformation.summaryTotalAccActiveTime + "\r\n");
                        break;
                    case ReportType.EXTERNAL_POWER_CUT:
                        streamWriter.Write("Total Distance\t\t\t" + reportInformation.summaryTotalDistance + "\r\n");
                        streamWriter.Write("Total Fuel\t\t\t" + reportInformation.summaryTotalFuel + "\r\n");
                        streamWriter.Write("Total Cosl\t\t\t" + reportInformation.summaryTotalCost + "\r\n");
                        streamWriter.Write("Total ExternalPower Cut Time\t\t\t" + reportInformation.summaryTotalExternalPowerCutTime + "\r\n");
                        break;
                    case ReportType.TRACKERS_GEOFENCE:
                        streamWriter.Write("Total Distance\t\t\t" + reportInformation.summaryTotalDistance + "\r\n");
                        streamWriter.Write("Total Fuel\t\t\t" + reportInformation.summaryTotalFuel + "\r\n");
                        streamWriter.Write("Total Cost\t\t\t" + reportInformation.summaryTotalCost + "\r\n");
                        break;
                }
                if (
                  this.reportType == ReportType.HISTORICAL ||
                  this.reportType == ReportType.RUNNING ||
                  this.reportType == ReportType.IDLING ||
                  this.reportType == ReportType.GEOFENCE ||
                  this.reportType == ReportType.ACC ||
                  this.reportType == ReportType.OVERSPEED ||
                  this.reportType == ReportType.EXTERNAL_POWER_CUT
                  ) {
                    streamWriter.Write("DateTime From\t\t\t" + reportInformation.summaryDateTimeFrom + "\r\n");
                    streamWriter.Write("DateTime To\t\t\t" + reportInformation.summaryDateTimeTo + "\r\n");
                }
                streamWriter.Write("Created On\t\t\t" + DateTime.Now.ToString() + "\r\n\r\n");
                //====================================================
                foreach (DataColumn dataColumn in dataTable.Columns) {
                    streamWriter.Write(dataColumn.ColumnName + "\t\t");
                }
                streamWriter.Write("\r\n");

                foreach (DataRow dataRow in dataTable.Rows) {
                    for (int index = 0; index < dataTable.Columns.Count; index++) {
                        streamWriter.Write(dataRow[index] + "\t\t");
                    }
                    streamWriter.Write("\r\n");
                }
            } catch (Exception exception) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t Exception \t\t" + exception.Message;
                log.write(logData);
            } finally {
                streamWriter.Close();
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:96,代碼來源:Export.cs

示例3: OnOpenDocument

        public override void OnOpenDocument(PdfWriter writer, Document document)
        {
            try {

                baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                pdfContentByte = writer.DirectContent;
                pdfTemplate = pdfContentByte.CreateTemplate(50, 50);
            } catch (DocumentException documentException) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t documentException \t\t" + documentException.Message;
                log.write(logData);
            } catch (System.IO.IOException ioException) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t documentException \t\t" + ioException.Message;
                log.write(logData);
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:17,代碼來源:Export.cs

示例4: run

        void run(object state)
        {
            pictureBoxLoading.Invoke(new MethodInvoker(delegate {
                pictureBoxLoading.Visible = true;
            }));

            try {

                database = new Database(Settings.Default.DatabaseHost, Settings.Default.DatabaseUsername, Settings.Default.DatabasePassword);

                Query query = new Query(database);

                query.getCompany(company);
                query.getUser(company, user);

                if (user.AccessLevel != 1) {

                    int isExpired = company.DateTimeExpired.CompareTo(DateTime.Now);

                    if (isExpired == -1)
                        throw new QueryException(1, "This company is expired.");
                    if (!company.IsActive)
                        throw new QueryException(1, "Company is deactivated.");

                    isExpired = user.DateTimeExpired.CompareTo(DateTime.Now);

                    if (isExpired == -1)
                        throw new QueryException(1, "This user is expired.");
                    if (!user.IsActive)
                        throw new QueryException(1, "User is deactivated.");
                }
                //=============================Login successful

                query.fillGeofences(company);

                query.fillUsers(company, user);

                query.fillCollection(company);

                query.fillTrackers(company);

                query.fillPois(company);

                this.Invoke(new MethodInvoker(delegate {
                    Settings.Default.accountRememberMe = (bool)user.RememberMe;
                    Settings.Default.accountCompanyUsername = company.Username;
                    Settings.Default.accountUsername = user.Username;
                    Settings.Default.accountPassword = user.Password;
                    Settings.Default.Save();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }));
            } catch (QueryException queryException) {
                this.Invoke(new MethodInvoker(delegate {
                    MessageBox.Show(this, queryException.Message, "Query Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                    string logData = DateTime.Now.ToString() + "\t\t queryException \t\t" + queryException.Message;
                    log.write(logData);
                }));
            } catch (DatabaseException databaseException){
                this.Invoke(new MethodInvoker(delegate {
                    MessageBox.Show(this, databaseException.Message, "DatabaseException", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                    string logData = DateTime.Now.ToString() + "\t\t DatabaseException \t\t" + databaseException.Message;
                    log.write(logData);
                }));

            } finally {
                try {
                    pictureBoxLoading.Invoke(new MethodInvoker(delegate {
                        pictureBoxLoading.Visible = false;
                    }));
                } catch {

                }
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:80,代碼來源:DialogLogin.cs

示例5: buttonLogin_Click

        private void buttonLogin_Click(object sender, EventArgs e)
        {
            /*
             *  Validate Inputs
             *
             */
            if (String.IsNullOrEmpty(textBoxCompany.Text)) {
                errorProviderDatabaseConfiguration.SetError(textBoxCompany, "Field is empty.");
            } else {
                errorProviderDatabaseConfiguration.SetError(textBoxCompany, String.Empty);
            }

            if (String.IsNullOrEmpty(textBoxUsername.Text)) {
                errorProviderDatabaseConfiguration.SetError(textBoxUsername, "Field is empty.");
            } else {
                errorProviderDatabaseConfiguration.SetError(textBoxUsername, String.Empty);
            }

            if (String.IsNullOrEmpty(textBoxPassword.Text)) {
                errorProviderDatabaseConfiguration.SetError(textBoxPassword, "Field is empty.");
            } else {
                errorProviderDatabaseConfiguration.SetError(textBoxPassword, String.Empty);
            }

            if (String.IsNullOrEmpty(textBoxCompany.Text) || String.IsNullOrEmpty(textBoxUsername.Text) || String.IsNullOrEmpty(textBoxPassword.Text) || (String.IsNullOrEmpty(textBoxCompany.Text))) {
                return;
            }

            try {

                company.Username = textBoxCompany.Text;
                user.Username = textBoxUsername.Text;
                user.Password = textBoxPassword.Text;
                user.RememberMe = checkBoxRememberMe.Checked;

                ThreadPool.QueueUserWorkItem(new WaitCallback(run), null);

            } catch (DatabaseException databaseException) {
                MessageBox.Show(this, databaseException.Message, "Database Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t databaseException \t\t" + databaseException.Message;
                log.write(logData);
            } finally {
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:45,代碼來源:DialogLogin.cs

示例6: buttonFilter_Click

        private void buttonFilter_Click(object sender, EventArgs e)
        {
            if (tabControl == null)
                return;

            if (tabControl.TabPages.Count == 0)
                return;

            TabPage tabPage = tabControl.SelectedTab;
            TableLayoutPanel TableLayoutInformation = (TableLayoutPanel)tabPage.Controls[0];
            DataGridView dataGridViewInformation = (DataGridView)TableLayoutInformation.Controls[0];

            try {
                if (comboBoxFilterContains.Enabled == true) {
                    string rowFilter = "";
                    if (!String.IsNullOrEmpty(comboBoxFilterContains.Text)) {
                        rowFilter = string.Format("[{0}] = '{1}'", comboBoxColumn.SelectedItem.ToString(), comboBoxFilterContains.Text);
                    }
                    (dataGridViewInformation.DataSource as DataTable).DefaultView.RowFilter = rowFilter;
                } else if (comboBoxFilterValueFrom.Enabled == true && comboBoxFilterValueTo.Enabled == true) {

                    double valueFrom = double.Parse(comboBoxFilterValueFrom.Text);
                    double valueTo = double.Parse(comboBoxFilterValueTo.Text);
                    string rowFilter = "";

                    if (valueFrom < valueTo) {
                        rowFilter = comboBoxColumn.Text + " >= " + valueFrom.ToString() + " and " + comboBoxColumn.Text + " <= " + valueTo.ToString();
                    } else if (valueFrom > valueTo) {
                        rowFilter = comboBoxColumn.Text + " <= " + valueFrom.ToString() + " and " + comboBoxColumn.Text + " >= " + valueTo.ToString();
                    } else if (valueFrom == valueTo) {
                        rowFilter = comboBoxColumn.Text + " = " + valueFrom.ToString();
                    }

                    (dataGridViewInformation.DataSource as DataTable).DefaultView.RowFilter = rowFilter;
                }

            } catch (Exception exception) {
                MessageBox.Show(this, exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\tException\t\t" + exception.Message;
                log.write(logData);
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:43,代碼來源:FormMain.cs

示例7: threadShortQuery

        public void threadShortQuery(object uncast)
        {
            #region -instances
            DataTable dataTableDetails = new DataTable();
            Hashtable hashTable = (Hashtable)uncast;
            Query query = new Query(database);

            Tracker tracker = (Tracker)hashTable["tracker"];

            DateTime dateTimeFrom = (DateTime)hashTable["dateTimeFrom"];
            DateTime dateTimeTo = (DateTime)hashTable["dateTimeTo"];

            DataGridView dataGridViewInformation = (DataGridView)hashTable["dataGridViewInformation"];

            string comboBoxReportTypeText = (string)hashTable["comboBoxReportTypeItem"];
            ReportType reportType = (ReportType)Enum.Parse(typeof(ReportType), comboBoxReportTypeText);

            int queryLimit = ((int)hashTable["limit"]);
            int offset = (int)hashTable["offset"];
            #endregion
            #region -loop

            try {
                #region querySelection
                switch (reportType) {
                    case ReportType.HISTORICAL:
                        dataTableDetails = query.getTrackerHistoricalData(this.company, this.user, dateTimeFrom, dateTimeTo, queryLimit, offset, tracker);
                        break;
                    case ReportType.IDLING:
                        dataTableDetails = query.getTrackerIdlingData(this.company, this.user, dateTimeFrom, dateTimeTo, queryLimit, offset, tracker);
                        break;
                    case ReportType.RUNNING:
                        dataTableDetails = query.getTrackerRunningData(this.company, this.user, dateTimeFrom, dateTimeTo, queryLimit, offset, tracker);
                        break;
                    case ReportType.GEOFENCE:
                        dataTableDetails = query.getTrackerGeofence(this.company, this.user, dateTimeFrom, dateTimeTo, queryLimit, offset, tracker);
                        break;
                    case ReportType.TRACKERS:
                        //dataTableDetails = query.getTrackers(this.account, userId);
                        break;
                    case ReportType.ALL_COMPANIES:
                        //dataTableDetails = query.getAllCompanies();
                        break;
                    case ReportType.ALL_TRACKERS:
                        //dataTableDetails = query.getAllTrackers();
                        break;

                }
                #endregion
                #region updateDataGridView
                this.Invoke(new MethodInvoker(delegate {
                    dataGridViewInformation.DataSource = dataTableDetails;
                }));
                #endregion
            } catch (QueryException queryException) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t queryException \t\t" + tracker.VehicleRegistration + " : " + queryException.Message;
                log.write(logData);

            } catch (MySqlException mySqlException) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t mySqlException \t\t" + tracker.VehicleRegistration + " : " + mySqlException.Message;
                log.write(logData);
                if (mySqlException.ErrorCode == -2147467259) {

                } else {

                }
            } catch (Exception exception) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t exception \t\t" + tracker.VehicleRegistration + " : " + exception.Message;
                log.write(logData);

            }

            #endregion
            updateProgressBarStatus(100);
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:78,代碼來源:FormMain.cs

示例8: threadLoadFilters

        public void threadLoadFilters(object uncast)
        {
            try {

                this.BeginInvoke(new MethodInvoker(delegate() {

                    comboBoxCollection.Items.Clear();

                    User user = (User)comboBoxUser.SelectedItem;

                    foreach (Collection collection in user.Collections) {
                        comboBoxCollection.Items.Add(collection);
                    }

                    comboBoxCollection.DisplayMember = "Name";

                    comboBoxCollection.SelectedItem = comboBoxCollection.Items[0];

                    ContextMenuStrip contextMenuStripCheckedListBoxTrackers = new ContextMenuStrip();
                    ToolStripItem toolStripItemCheckedListBoxTrackersCheckAll = contextMenuStripCheckedListBoxTrackers.Items.Add("Check all");
                    toolStripItemCheckedListBoxTrackersCheckAll.Click += toolStripItemCheckedListBoxTrackersCheckAll_Click;
                    ToolStripItem toolStripItemCheckedListBoxTrackersUncheckAll = contextMenuStripCheckedListBoxTrackers.Items.Add("Uncheck all");
                    toolStripItemCheckedListBoxTrackersUncheckAll.Click += toolStripItemCheckedListBoxTrackersUncheckAll_Click;
                    ToolStripItem toolStripItemCheckedNextGroup = contextMenuStripCheckedListBoxTrackers.Items.Add("Check Next 10 items");
                    toolStripItemCheckedNextGroup.Click += toolStripItemCheckedNextGroup_Click;
                    ToolStripItem toolStripItemCheckedPrevGroup = contextMenuStripCheckedListBoxTrackers.Items.Add("Check Prev 10 items");
                    toolStripItemCheckedPrevGroup.Click += toolStripItemCheckedPrevGroup_Click;

                    ToolStripItem toolStripItemSortAscending = contextMenuStripCheckedListBoxTrackers.Items.Add("Sort/Unsort");
                    toolStripItemSortAscending.Click += toolStripItemSortAscending_Click;

                    checkedListBoxTrackers.ContextMenuStrip = contextMenuStripCheckedListBoxTrackers;
                    checkedListBoxTrackers.ItemCheck += checkedListBoxTrackers_ItemCheck;
                    checkedListBoxTrackers.ResumeLayout();

                }));
            } catch (QueryException queryException) {
                this.Invoke(new MethodInvoker(delegate() {
                    MessageBox.Show(this, queryException.Message, "Query Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }));
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t queryException \t\t" + queryException.Message;
                log.write(logData);
            } finally {
                updateProgressBarStatus(100);
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:47,代碼來源:FormMain.cs

示例9: prepareExport


//.........這裏部分代碼省略.........
            if (dataGridViewInformation == null)
                return;

            DataTable dataTable = new DataTable();

            foreach (DataGridViewColumn dataGridViewColumn in dataGridViewInformation.Columns) {
                if (dataGridViewColumn.Visible)
                    dataTable.Columns.Add(dataGridViewColumn.Name, dataGridViewColumn.ValueType);
            }

            foreach (DataGridViewRow dataGridViewRow in dataGridViewInformation.Rows) {
                DataRow dataRow = dataTable.NewRow();
                foreach (DataColumn dataColumn in dataTable.Columns) {
                    dataRow[dataColumn.ColumnName] = dataGridViewRow.Cells[dataColumn.ColumnName].Value;
                }
                dataTable.Rows.Add(dataRow);
            }

            ExportFileType exportFileType = (ExportFileType)(Enum.Parse(typeof(ExportFileType), comboBoxExportFileType.Text));
            ReportType reportType = (ReportType)(Enum.Parse(typeof(ReportType), dataGridViewInformation.Name));

            ReportInformation reportInformation = new ReportInformation();

            TableLayoutPanel tableLayoutPanelParent = (TableLayoutPanel)tabPage.Controls[0];
            TableLayoutPanel tableLayoutPanelRight = (TableLayoutPanel)tableLayoutPanelParent.Controls[2];

            ListView listViewDetails = (ListView)tableLayoutPanelRight.Controls[0];

            reportInformation.companyName = listViewDetails.Items[0].SubItems[1].Text;
            reportInformation.userName = listViewDetails.Items[1].SubItems[1].Text;

            if (reportType == ReportType.HISTORICAL || reportType == ReportType.RUNNING || reportType == ReportType.IDLING || reportType == ReportType.ACC || reportType == ReportType.GEOFENCE || reportType == ReportType.OVERSPEED || reportType == ReportType.ACC) {
                reportInformation.trackerVehicleReg = listViewDetails.Items[2].SubItems[1].Text;
                reportInformation.trackerVehicleModel = listViewDetails.Items[3].SubItems[1].Text;
                reportInformation.trackerOwnerName = listViewDetails.Items[4].SubItems[1].Text;
                reportInformation.trackerDriverName = listViewDetails.Items[5].SubItems[1].Text;

                reportInformation.trackerDeviceImei = listViewDetails.Items[6].SubItems[1].Text;
                reportInformation.trackerSimNumber = listViewDetails.Items[7].SubItems[1].Text;
                reportInformation.trackerVehicleCreated = listViewDetails.Items[8].SubItems[1].Text;
                reportInformation.trackerDeviceExpiry = listViewDetails.Items[9].SubItems[1].Text;

            }

            ListView listViewSummary = (ListView)tableLayoutPanelRight.Controls[1];
            reportInformation.summaryDateTimeFrom = listViewSummary.Items[0].SubItems[1].Text;
            reportInformation.summaryDateTimeTo = listViewSummary.Items[1].SubItems[1].Text;

            if (reportType == ReportType.RUNNING) {
                reportInformation.summaryTotalDistance = listViewSummary.Items[2].SubItems[1].Text;
                reportInformation.summaryTotalFuel = listViewSummary.Items[3].SubItems[1].Text;
                reportInformation.summaryTotalCost = listViewSummary.Items[4].SubItems[1].Text;
                reportInformation.summaryTotalRunningTime = listViewSummary.Items[5].SubItems[1].Text;
            } else if (reportType == ReportType.IDLING) {
                reportInformation.summaryTotalDistance = listViewSummary.Items[2].SubItems[1].Text;
                reportInformation.summaryTotalFuel = listViewSummary.Items[3].SubItems[1].Text;
                reportInformation.summaryTotalCost = listViewSummary.Items[4].SubItems[1].Text;
                reportInformation.summaryTotalIdlingTime = listViewSummary.Items[5].SubItems[1].Text;
            } else if (reportType == ReportType.GEOFENCE) {
                reportInformation.summaryTotalDistance = listViewSummary.Items[2].SubItems[1].Text;
                reportInformation.summaryTotalFuel = listViewSummary.Items[3].SubItems[1].Text;
                reportInformation.summaryTotalCost = listViewSummary.Items[4].SubItems[1].Text;
                reportInformation.summaryTotalGeofenceActiveTime = listViewSummary.Items[5].SubItems[1].Text;
            } else if (reportType == ReportType.ACC) {
                reportInformation.summaryTotalDistance = listViewSummary.Items[2].SubItems[1].Text;
                reportInformation.summaryTotalFuel = listViewSummary.Items[3].SubItems[1].Text;
                reportInformation.summaryTotalCost = listViewSummary.Items[4].SubItems[1].Text;
                reportInformation.summaryTotalAccActiveTime = listViewSummary.Items[5].SubItems[1].Text;
            } else if (reportType == ReportType.TRACKERS_GEOFENCE) {
                reportInformation.summaryTotalDistance = listViewSummary.Items[2].SubItems[1].Text;
                reportInformation.summaryTotalFuel = listViewSummary.Items[3].SubItems[1].Text;
                reportInformation.summaryTotalCost = listViewSummary.Items[4].SubItems[1].Text;
            }

            if (string.IsNullOrEmpty(comboBoxExportFileType.Text))
                return;

            try {
                Export export = new Export(exportFileType, reportType);
                export.parentDirectory = "TqatExportFiles";
                export.path = comboBoxExportFilePath.Text;
                export.title = reportInformation.trackerVehicleReg;//tabControl.TabPages[0].Name;

                if (!File.Exists(Settings.Default.UserLogoPath)) {
                    export.logoPath = Directory.GetCurrentDirectory() + "\\logo.png";
                } else {
                    export.logoPath = Settings.Default.UserLogoPath;
                }
                export.companyName = company.DisplayName;
                export.reportInformation = reportInformation;
                if (!export.dataTable(dataTable, openTheFile)) {
                    throw new Exception();
                }
            } catch (Exception exception) {
                MessageBox.Show(this, exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\tException\t\t" + exception.Message;
                log.write(logData);
            }
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:101,代碼來源:FormMain.cs

示例10: threadFunctionQuery


//.........這裏部分代碼省略.........
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50));
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50));
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50));
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50));
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100));
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
                    tableLayoutPanelBottom.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100));

                    tableLayoutPanelBottom.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
                    tableLayoutPanelBottom.Controls.Add(buttonFirst, 0, 0);
                    tableLayoutPanelBottom.Controls.Add(buttonPrev, 1, 0);
                    tableLayoutPanelBottom.Controls.Add(buttonNext, 2, 0);
                    tableLayoutPanelBottom.Controls.Add(buttonLast, 3, 0);
                    tableLayoutPanelBottom.Controls.Add(LabelPageNumber, 4, 0);
                    tableLayoutPanelBottom.Controls.Add(LabelTotalPageNumber, 5, 0);
                    tableLayoutPanelBottom.Controls.Add(LabelDataCount, 6, 0);
                    tableLayoutPanelBottom.Controls.Add(labelDetails, 7, 0);
                    #endregion
                    #region tableLayoutInformationParent
                    TableLayoutPanel tableLayoutInformationParent = new TableLayoutPanel();
                    tableLayoutInformationParent.RowStyles.Clear();
                    tableLayoutInformationParent.ColumnStyles.Clear();
                    tableLayoutInformationParent.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
                    tableLayoutInformationParent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 250));
                    tableLayoutInformationParent.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
                    tableLayoutInformationParent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40));
                    tableLayoutInformationParent.Controls.Add(dataGridView, 0, 0);
                    tableLayoutInformationParent.Controls.Add(tableLayoutPanelBottom, 0, 1);
                    tableLayoutInformationParent.Controls.Add(tableLayoutPanelRight, 1, 0);
                    //tableLayoutInformationParent.Controls.Add(labelDetails, 1, 1);
                    tableLayoutInformationParent.Dock = DockStyle.Fill;
                    #endregion
                    #region tabPageAndTabControls
                    TabPage tabPage = new TabPage(tabPageName);
                    tabPage.Name = reportItemName;

                    tabPage.Tag = hashTable;
                    tabPage.Controls.Add(tableLayoutInformationParent);

                    hashTable["dataGridViewInformation"] = dataGridView;

                    if (tabControl != null) {
                        this.Invoke(new MethodInvoker(delegate {
                            tabControl.TabPages.Add(tabPage);
                            tabControl.SelectTab(tabPage);
                            tabControl.Click += tabControl_Click;
                            tabControl.Refresh();
                            Application.DoEvents();
                        }));
                    }
                    #endregion
                    break;
                } catch (QueryException queryException) {
                    Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                    string logData = "";
                    if (tracker != null)
                        logData = DateTime.Now.ToString() + "\t\t queryException \t\t" + tracker.VehicleRegistration + " : " + queryException.Message;
                    else
                        logData = DateTime.Now.ToString() + "\t\t queryException \t\t" + queryException.Message;

                    log.write(logData);
                    break;
                } catch (MySqlException mySqlException) {
                    Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                    string logData = "";
                    if (tracker != null)
                        logData = DateTime.Now.ToString() + "\t\t mySqlException \t\t" + tracker.VehicleRegistration + " : " + mySqlException.Message;
                    else
                        logData = DateTime.Now.ToString() + "\t\t mySqlException \t\t" + mySqlException.Message;
                    log.write(logData);
                    if (mySqlException.ErrorCode == -2147467259) {
                        //requery
                        if (count == 2) {
                            break;
                        }
                    } else {
                        break;
                    }
                } catch (Exception exception) {
                    Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                    string logData = "";
                    if (tracker != null) {
                        logData = DateTime.Now.ToString() + "\t\t exception \t\t" + tracker.VehicleRegistration + " : " + exception.Message;
                    } else {
                        logData = DateTime.Now.ToString() + "\t\t exception \t\t" + exception.Message;
                    }
                    log.write(logData);
                    break;
                }
            }
            #endregion
            #region -updateProgressBarStatus
            lock (this.progressBarStatus) {
                workerThreadFinished++;
                double result = workerThreadFinished / workerThreadCount;
                double progressValue = result * (double)progressBarStatus.Maximum;
                updateProgressBarStatus((int)progressValue);
            }
            #endregion
        }
開發者ID:rhalf,項目名稱:AtsTqatProReportingTool,代碼行數:101,代碼來源:FormMain.cs


注:本文中的System.Log.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。