示例#1
0
        private Document _ParseFile(Stream fileStream, string path)
        {
            var document = new Document();
            var xmlDocument = new XmlDocument();

            xmlDocument.Load(fileStream);

            document.File = path;

            foreach (XmlNode childNode in xmlDocument.ChildNodes[1].ChildNodes)
            {
                switch (childNode.Name)
                {
                    case "Timestamp":
                        document.Timestamp = _GetTimeStamp(childNode);
                        break;
                    case "Summary":
                        document.Summary = _GetSummary(childNode);
                        break;
                    case "MeasurementData":
                        document.MeasurementData = _GetMeasurementData(childNode);
                        break;
                    case "Comments":
                        document.Comments = _GetCommentList(childNode);
                        break;
                    case "Calibrations":
                        document.Calibrations = _GetCalibrationList(childNode);
                        break;
                    case "Adjustments":
                        document.Adjustments = _GetAdjustmentList(childNode);
                        break;
                }
            }

            fileStream.Close();
            Logger.WriteDebugMessage("Parsed file successfully");

            return document;
        }
示例#2
0
        private static void _WriteDeviceInfo(Excel._Worksheet worksheet, Document document)
        {
            worksheet.Cells[1, 1] = "Device Name:";
            worksheet.Cells[1, 2] = document.Summary.Device.Id;
            worksheet.Cells[2, 1] = "Line Name:";
            worksheet.Cells[2, 2] = document.Summary.Line.Name;
            worksheet.Cells[3, 1] = "Product Type:";
            worksheet.Cells[3, 2] = document.Summary.ActiveProduct.Product.ProductType.Name;
            worksheet.Cells[4, 1] = "Product Name:";
            worksheet.Cells[4, 2] = document.Summary.ActiveProduct.Product.Name;

            worksheet.Range["A1", "B4"].Borders.Weight = Excel.XlBorderWeight.xlMedium;
        }
示例#3
0
        public void AddMiscellaneousValues(Document document)
        {
            try
            {
                MainForm.LogWriter.WriteDebugMessage(string.Format("Adding Miscellaneous Data. Device: '{0}' Line: '{1}' Product: '{2}'",
                                                                        document.Summary.Device.Id,
                                                                        document.Summary.Line.Name,
                                                                        document.Summary.ActiveProduct.Product.Name));

                mApplication.ScreenUpdating = false;
                var values = new string[15];

                values[0] = document.MeasurementData.SystemStatus.ToString(CultureInfo.InvariantCulture);
                values[1] = document.MeasurementData.DeviceStatus.ToString(CultureInfo.InvariantCulture);
                values[2] = document.MeasurementData.LineStatus.ToString(CultureInfo.InvariantCulture);
                values[3] = _GetFormatedTimeStamp(document.MeasurementData.Timestamp.Local);

                if (document.Comments.Count > 0)
                {
                    values[4] = document.Comments[0].Text;
                    values[5] = document.Calibrations[0].Username;
                    values[6] = document.Calibrations[0].Channels[0].Name;
                }
                else
                {
                    values[4] = string.Empty;
                    values[5] = string.Empty;
                    values[6] = string.Empty;
                }

                if (document.Calibrations.Count > 0)
                {
                    values[7] = document.Calibrations[0].Channels[0].SavedValue.ToString();
                    values[8] = document.Calibrations[0].Channels[0].Reference.ToString();
                    values[9] = document.Calibrations[0].Channels[0].Deviation.ToString();
                }
                else
                {
                    values[7] = string.Empty;
                    values[8] = string.Empty;
                    values[9] = string.Empty;
                }

                if (document.Adjustments.Count > 0)
                {
                    values[10] = document.Adjustments[0].Username;
                    values[11] = document.Adjustments[0].Channels[0].Name;
                    values[12] = document.Adjustments[0].Channels[0].AverageDeviation.ToString();
                    values[13] = document.Adjustments[0].Channels[0].OriginalGain.ToString();
                    values[14] = document.Adjustments[0].Channels[0].AdjustedGain.ToString();
                }
                else
                {
                    values[10] = string.Empty;
                    values[11] = string.Empty;
                    values[12] = string.Empty;
                    values[13] = string.Empty;
                    values[14] = string.Empty;
                }

                //Add timestamp
                var cell = "A" + (mMiscellaneousDataWorksheet.UsedRange.Rows.Count + 1);

                //Splitview handling?
                mWorkbook.Windows.Item[2].Activate();
                //mMeasurementDataWorksheet.Activate();

                //range.Value2 = document.MeasurementData.Timestamp.Local.ToShortDateString() + " " +
                //                document.MeasurementData.Timestamp.Local.ToLongTimeString() + "." + document.MeasurementData.Timestamp.Local.Millisecond;

                ////Add measuring values
                //cell = "B" + (mMiscellaneousDataWorksheet.UsedRange.Rows.Count);
                var range = mMiscellaneousDataWorksheet.Range[cell, cell].Resize[Missing.Value, values.Length];
                range.Value2 = values;

                //Format row
                cell = "A" + (mMiscellaneousDataWorksheet.UsedRange.Rows.Count);
                range = mMiscellaneousDataWorksheet.Range[cell, cell].Resize[Missing.Value, values.Length];
                range.EntireColumn.AutoFit();
                range.Borders.Weight = Excel.XlBorderWeight.xlThin;

                //Display and focus new row
                mApplication.ScreenUpdating = true;

                //Splitview handling?
                mWorkbook.Windows.Item[2].Activate();
                //mMeasurementDataWorksheet.Activate();
                //range.Activate();

                MainForm.LogWriter.WriteDebugMessage("Added Miscellaneous Data successfully.");
            }
            catch (Exception exception)
            {
                MainForm.LogWriter.WriteFailureMessage("Adding Measuring Data failed!");
                MainForm.LogWriter.WriteException(exception);
                MainForm.ShowErrorMessage(exception);
            }
        }
示例#4
0
        public void AddHeaders(Document document)
        {
            try
            {
                MainForm.LogWriter.WriteDebugMessage(string.Format("Adding Header. Device: '{0}' Line: '{1}' Product: '{2}'",
                                                                        document.Summary.Device.Id,
                                                                        document.Summary.Line.Name,
                                                                        document.Summary.ActiveProduct.Product.Name));

                var channelNames = new string[document.MeasurementData.Channels.Count + 1];
                channelNames[0] = "Timestamp";

                for (var i = 1; i < channelNames.Length; i++)
                {
                    channelNames[i] = document.MeasurementData.Channels[i - 1].Name + " [" + document.MeasurementData.Channels[i - 1].Unit.Name + "]";
                }

                //Add general header for measurement data worksheet
                _WriteDeviceInfo(mMeasurementDataWorksheet, document);

                //Add general header for miscellaneous data worksheet
                _WriteDeviceInfo(mMiscellaneousDataWorksheet, document);

                var miscColumnHeadersRow1 = new[]
                {
                    "System Status",
                    "Device Status",
                    "Line Status",
                    "Timestamp",
                    "Comment",
                    "Calibration",
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    "Adjustment",
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty
                };

                var miscColumnHeadersRow2 = new[]
                {
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    "User Name",
                    "Channel",
                    "Saved Value",
                    "Reference Value",
                    "Deviation",
                    "User Name",
                    "Channel",
                    "Average Deviation",
                    "Original Gain",
                    "New Gain"
                };

                _WriteColumnHeaders(mMeasurementDataWorksheet, "A6", channelNames);
                _WriteColumnHeaders(mMiscellaneousDataWorksheet, "A6", miscColumnHeadersRow1);
                _WriteColumnHeaders(mMiscellaneousDataWorksheet, "A7", miscColumnHeadersRow2);

                _MergeCells(mMiscellaneousDataWorksheet, "A6", "A7");
                _MergeCells(mMiscellaneousDataWorksheet, "B6", "B7");
                _MergeCells(mMiscellaneousDataWorksheet, "C6", "C7");
                _MergeCells(mMiscellaneousDataWorksheet, "D6", "D7");
                _MergeCells(mMiscellaneousDataWorksheet, "E6", "E7");
                _MergeCells(mMiscellaneousDataWorksheet, "F6", "J6");
                _MergeCells(mMiscellaneousDataWorksheet, "K6", "O6");

                mMeasurementDataWorksheet.Application.Windows.Item[1].SplitRow = 6;
                mMeasurementDataWorksheet.Application.Windows.Item[1].FreezePanes = true;

                mMiscellaneousDataWorksheet.Application.Windows.Item[2].SplitRow = 7;
                mMiscellaneousDataWorksheet.Application.Windows.Item[2].FreezePanes = true;
                MainForm.LogWriter.WriteDebugMessage("Added Header successfully.");
            }
            catch (Exception exception)
            {
                MainForm.LogWriter.WriteFailureMessage("Adding Header failed!");
                MainForm.LogWriter.WriteException(exception);
                MainForm.ShowErrorMessage(exception);
            }
        }
示例#5
0
        public void AddMeasurementValues(Document document)
        {
            try
            {
                MainForm.LogWriter.WriteDebugMessage(string.Format("Adding Measuring Data. Device: '{0}' Line: '{1}' Product: '{2}'",
                                                                        document.Summary.Device.Id,
                                                                        document.Summary.Line.Name,
                                                                        document.Summary.ActiveProduct.Product.Name));

                mApplication.ScreenUpdating = false;
                var measurementValues = new double[document.MeasurementData.Channels.Count];

                for (var i = 0; i < measurementValues.Length; i++)
                {
                    if (document.MeasurementData.Channels[i].MeasurementValue.Value != null)
                    {
                        measurementValues[i] = Convert.ToDouble(document.MeasurementData.Channels[i].MeasurementValue.Value);
                    }
                }

                //Add timestamp
                var cell = "A" + (mMeasurementDataWorksheet.UsedRange.Rows.Count + 1);

                //Splitview handling?
                mWorkbook.Windows.Item[1].Activate();
                //mMeasurementDataWorksheet.Activate();
                var range = mMeasurementDataWorksheet.Range[cell];
                range.Value2 = _GetFormatedTimeStamp(document.MeasurementData.Timestamp.Local);

                //Add measuring values
                cell = "B" + (mMeasurementDataWorksheet.UsedRange.Rows.Count);
                range = mMeasurementDataWorksheet.Range[cell, cell].Resize[Missing.Value, measurementValues.Length];
                range.Value2 = measurementValues;

                //Format row
                cell = "A" + (mMeasurementDataWorksheet.UsedRange.Rows.Count);
                range = mMeasurementDataWorksheet.Range[cell, cell].Resize[Missing.Value, measurementValues.Length + 1];
                range.EntireColumn.AutoFit();
                range.Borders.Weight = Excel.XlBorderWeight.xlThin;

                //Display and focus new row
                mApplication.ScreenUpdating = true;

                //Splitview handling?
                mWorkbook.Windows.Item[1].Activate();
                //mMeasurementDataWorksheet.Activate();
                //range.Activate();

                MainForm.LogWriter.WriteDebugMessage("Added Measuring Data successfully.");
            }
            catch (Exception exception)
            {
                MainForm.LogWriter.WriteFailureMessage("Adding Measuring Data failed!");
                MainForm.LogWriter.WriteException(exception);
                MainForm.ShowErrorMessage(exception);
            }
        }