void DataExportController_modelExportStartedEvent(object sender, ModelExportStartedEventHandlerArgs args) { if (modelExportedStartedEvent != null) { modelExportedStartedEvent(sender, args); } }
void DataExportUC_modelExportStartedEvent(object sender, ModelExportStartedEventHandlerArgs e) { SPCModelDataExport export = (SPCModelDataExport)sender; this.pbarSub.Value = 0; this.pbarSub.Maximum = export.ChartCount; this.blblMain.Text = this.pbarMain.Value + " / " + this.pbarMain.Maximum; this.blblSub.Text = "0 / " + export.ChartCount; if (modelExportedStartedEvent != null) { modelExportedStartedEvent(sender, e); } System.Threading.Thread.Sleep(50); Application.DoEvents(); }
internal int Export(string filePath, string startDtts, string endDtts) { exportedSubModel = 0; if (modelExportStartedEvent != null) { var ModelStartedArgs = new ModelExportStartedEventHandlerArgs(); modelExportStartedEvent(this, ModelStartedArgs); } bool hasData = false; using (ExcelWriter writer = new ExcelWriter(filePath)) { writer.WriteStartDocument(); // write a main chart DataTable rawData = GetRawData(startDtts, endDtts, this.ChartID); rawData.TableName = this.ChartID; RemoveSuperflousColumns(rawData); if (rawData.Rows.Count > 0) { hasData = true; writer.WriteSheet("Main-" + ChartID, rawData); exportedSubModel++; } rawData.Dispose(); if (subModelExportCompletedEvent != null) { var subArgs = new SubModelExportCompletedEventHandlerArgs(); subArgs.SubModelRawID = ChartID; subModelExportCompletedEvent(this, subArgs); } // write sub charts foreach (SPCModel sub in this.SubModels) { rawData = GetRawData(startDtts, endDtts, sub.ChartID); rawData.TableName = sub.ChartID; RemoveSuperflousColumns(rawData); if (rawData.Rows.Count > 0) { hasData = true; writer.WriteSheet(sub.ChartID, rawData); exportedSubModel++; } rawData.Dispose(); if (subModelExportCompletedEvent != null) { var subArgs = new SubModelExportCompletedEventHandlerArgs(); subArgs.SubModelRawID = sub.ChartID; subModelExportCompletedEvent(this, subArgs); } } writer.WriteEndDocument(); writer.Close(); } var modelArgs = new ModelExportCompletedEventHandlerArgs(); modelArgs.SPCModelName = this.SPCModelName; modelArgs.exportedModelNum = exportedSubModel; modelArgs.filePath = filePath; if (hasData == false) { System.IO.File.Delete(filePath); modelArgs.filePath = string.Empty; } if (modelExportCompletedEvent != null) { modelExportCompletedEvent(this, modelArgs); } return(exportedSubModel); }