Exemplo n.º 1
0
        void OutputFile()
        {
            List <int> printcols = new List <int>();

            BackgroundWorker worker = new BackgroundWorker();

            worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                MessageBox.Show("File output complete");
            };
            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                printcols = GetPrintCols(LiveCollection);

                IExportFile file = new ExportFile(_sessionColumnCollection,
                                                  data.AsDataView(), printcols);

                file.OutputFile(OutputFileLocation);


                List <StationSummarySheetType> runSheets = new List <StationSummarySheetType>();
                foreach (SelectionItem <StationSummarySheetType> Item in SummarySheets.selectedItems)
                {
                    runSheets.Add(Item.SelectedItem);
                }

                XbyYShearStationSummary summary = new XbyYShearStationSummary(_sessionColumnCollection,
                                                                              data.AsDataView(), 30, 10, 2, _ogrid, runSheets);

                summary.CreateReport(OutputSummaryFileLocation);
            };
            worker.RunWorkerAsync();
        }
Exemplo n.º 2
0
        void OutPutStationSummary()
        {
            BackgroundWorker worker   = new BackgroundWorker();
            string           filename = string.Empty;
            SaveFileDialog   sf       = new SaveFileDialog();

            sf.Title      = "save data";
            sf.Filter     = "Excel|*.xlsx";
            sf.DefaultExt = ".xlsx";
            sf.FileName   = this.Collection.DisplayName + "_stnSummary";
            sf.ShowDialog();

            if (sf.FileName != "")
            {
                filename = sf.FileName;
            }
            else
            {
                return;
            }

            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                XbyYShearStationSummary summary = null;
                try
                {
                    IsOutputtingSummary = true;
                    summary             = new XbyYShearStationSummary(_collection.ColumnCollection,
                                                                      _collection.DownloadedData[0].AsDataView(), 30, 10, 2, (int)_derivedWSColIndex, _shearedWS.Alpha);

                    //set  property true or false for single grids to be  printed
                    summary.RunIndividualGrids = false;
                    summary.CreateReport(filename);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error calculating station summary: " + e.Message + " " + e.Source);
                    //StreamWriter fs = new StreamWriter(Path.GetPathRoot(filename) + @"\LOG_" + Path.GetFileNameWithoutExtension(filename) + ".txt", false);
                    // summary.log.ForEach(c => fs.WriteLine(c));
                    //fs.Close();
                }
                finally
                {
                    //MessageBox.Show("done!");
                    IsOutputtingSummary = false;
                }
            };
            worker.RunWorkerAsync();
        }
Exemplo n.º 3
0
        void OutPutSummary()
        {
            BackgroundWorker worker   = new BackgroundWorker();
            string           filename = string.Empty;
            SaveFileDialog   sf       = new SaveFileDialog();

            sf.Title      = "save data";
            sf.Filter     = "Excel|*.xlsx";
            sf.DefaultExt = ".xlsx";
            sf.FileName   = "Unified" + "_StnSummary_" + DateTime.Now.ToShortDateString().Replace(@"/", "");
            DialogResult result = sf.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            if (sf.FileName != "")
            {
                filename = sf.FileName;
            }
            else
            {
                return;
            }



            worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                SummaryIsProcessing = false;
            };
            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                XbyYShearStationSummary summary = null;

                try
                {
                    SummaryIsProcessing = true;

                    //create the DataTable
                    if (_unifiedData != null)
                    {
                        _unifiedData.Clear();
                    }
                    BuildDataTable();
                    //create column collection
                    ColumnCollection = new SessionColumnCollection(_unifiedData);


                    //add column def and add configs

                    ISessionColumn hubws = ColumnCollection[HubHeight.ToString() + "m"];
                    hubws.ColumnType   = SessionColumnType.WSAvgShear;
                    hubws.IsCalculated = true;
                    hubws.IsComposite  = true;
                    SensorConfig config = new SensorConfig()
                    {
                        StartDate = _startDate, EndDate = _endDate, Height = HubHeight
                    };
                    hubws.Configs.Add(config);

                    ISessionColumn upperws = ColumnCollection[UpperHeight.ToString().Replace(".", "_") + "m"];
                    upperws.ColumnType  = SessionColumnType.WSAvg;
                    upperws.IsComposite = true;
                    config = new SensorConfig()
                    {
                        StartDate = _startDate, EndDate = _endDate, Height = UpperHeight
                    };
                    upperws.Configs.Add(config);

                    ISessionColumn lowerws = ColumnCollection[LowerHeight.ToString().Replace(".", "_") + "m"];
                    lowerws.ColumnType  = SessionColumnType.WSAvg;
                    lowerws.IsComposite = true;
                    config = new SensorConfig()
                    {
                        StartDate = _startDate, EndDate = _endDate, Height = LowerHeight
                    };
                    lowerws.Configs.Add(config);

                    ISessionColumn wd = ColumnCollection["WD"];
                    wd.ColumnType  = SessionColumnType.WDAvg;
                    wd.IsComposite = true;
                    config         = new SensorConfig()
                    {
                        StartDate = _startDate, EndDate = _endDate
                    };
                    wd.Configs.Add(config);


                    //get axis selections from UI
                    IAxis Xaxis = GetAxis(_xShearAxis, _xBinWidth);
                    IAxis Yaxis = GetAxis(_yShearAxis, _yBinWidth);

                    //calculate alpha
                    AlphaFactory afactory = new AlphaFactory();
                    Alpha        alpha    = (Alpha)afactory.CreateAlpha(_unifiedData, AlphaFilterMethod.Coincident, upperws, lowerws, Xaxis, Yaxis);
                    alpha.SourceDataSet = this.DisplayName;
                    alpha.CalculateAlpha();

                    string xBin = string.Empty;
                    string yBin = string.Empty;

                    if (Xaxis.AxisType == AxisType.WD)
                    {
                        var wdaxis = (WindDirectionAxis)Xaxis;
                        xBin = " " + wdaxis.BinWidth.ToString() + " deg";
                    }
                    if (Xaxis.AxisType == AxisType.WS)
                    {
                        var wsaxis = (WindSpeedAxis)Xaxis;
                        xBin = " " + wsaxis.BinWidth.ToString() + " m/s";
                    }
                    if (Yaxis.AxisType == AxisType.WD)
                    {
                        var wdaxis = (WindDirectionAxis)Yaxis;
                        yBin = " " + wdaxis.BinWidth.ToString() + " deg";
                    }
                    if (Yaxis.AxisType == AxisType.WS)
                    {
                        var wsaxis = (WindSpeedAxis)Yaxis;
                        yBin = " " + wsaxis.BinWidth.ToString() + " m/s";
                    }

                    //Set up column metadata for the summary run
                    summary = new XbyYShearStationSummary(ColumnCollection, _unifiedData.AsDataView(), 30, 10, 2, alpha);

                    summary.CreateReport(filename);
                    SummaryIsProcessing = false;
                }
                catch (ApplicationException e)
                {
                    MessageBox.Show("Error calculating station summary: " + e.Message + " " + e.Source);
                    StreamWriter fs = new StreamWriter(Path.GetDirectoryName(filename) + @"\LOG_" + Path.GetFileNameWithoutExtension(filename) + ".txt", false);
                    summary.log.ForEach(c => fs.WriteLine(c));
                    fs.Close();
                }
                finally
                {
                    SummaryIsProcessing = false;
                }
            };
            worker.RunWorkerAsync();
        }