コード例 #1
0
        public void ExportData()
        {
            if (MakeTempTableAccess())
            {
                Connections cons = new Connections();

                ExportToExcel ops = new ExportToExcel
                {
                    DatabaseName  = msAccessFileName,
                    Headers       = false,
                    ExcelFileName = msExcelFile,
                    TableName     = TempTableName,
                    WorkSheetName = "Report1"
                };

                HasErrors = !ops.Execute();
                if (HasErrors)
                {
                    ExeptionMessage = ops.ExceptionMessage;
                }
                RecordsInserted = ops.RecordsInserted;
            }
        }
コード例 #2
0
        /// <summary>
        /// Execute Action
        /// </summary>
        /// <param name="oActionCallingContext"></param>
        /// <returns></returns>
        public bool Execute(ActionCallingContext oActionCallingContext)
        {
            SelectionSet Set            = new SelectionSet();
            Project      CurrentProject = Set.GetCurrentProject(true);
            string       ProjectName    = CurrentProject.ProjectName;

            Debug.WriteLine(ProjectName);
            string xlsFileName = Path.GetDirectoryName(CurrentProject.ProjectFullName);

            xlsFileName = Path.Combine(xlsFileName, $"{ DateTime.Now.Year }.{ DateTime.Now.Month }.{ DateTime.Now.Day }_" + Settings.Default.outputFileName);
            // Show ProgressBar
            Progress progress = new Progress("SimpleProgress");

            progress.SetAllowCancel(true);
            progress.SetAskOnCancel(true);
            progress.SetTitle("Wire mark export");
            progress.ShowImmediately();
            progress.BeginPart(25.0, "Export label : ");
            try
            {
                // Executing Action "label"
                ExportXML.Execute(xmlExportFileName);

                if (progress.Canceled())
                {
                    progress.EndPart(true);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler("ExportXML", ex);
                return(false);
            }

            progress.EndPart();
            progress.BeginPart(25.0, "Parse XML : ");
            try
            {
                // Getting object from XML
                ParseXMLWireFile();

                if (progress.Canceled())
                {
                    progress.EndPart(true);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler("ParseXMLWireFile", ex);
                return(false);
            }
            progress.EndPart();
            progress.BeginPart(10.0, "Write data to Excel : " + xlsFileName);
            try
            {
                // Export to excel
                // Creating *.xls file
                ExportToExcel.Execute(listOfLines, xlsFileName, progress);

                if (progress.Canceled())
                {
                    progress.EndPart(true);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler("ExportToExcel.Execute", ex);
                return(false);
            }
            finally
            {
                progress.EndPart(true);
            }

            return(true);
        }