コード例 #1
0
        public static void SaveAsLNSchedule()
        {
            Console.Clear();
            try
            {
                clsConsole.WriteLine("\r\n Complete saving as Schedule ...", ConsoleColor.Red);
                WorkbookExcel.SaveAs(LNSchedule, SaveAsExcelFormat, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);
            }
            catch (Exception)
            {
                clsConsole.WriteLine("\r\n Complete saving Copy of Schedule ...", ConsoleColor.Red);
                WorkbookExcel.SaveAs(CopyofLNSchedule, SaveAsExcelFormat, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);
                ScheduleCopyExisted = true;
            }

            WorkbookExcel.Close();

            ExcelApp.Quit();
        }
コード例 #2
0
        public static void TransmittalProcess(ProjectSet projectSet)
        {
            Console.Clear();

            switch (projectSet)
            {
            case ProjectSet.Caselaw:
                MessageBox.Show(projectSet.ToString() + "======" + clsReports.FilesCountReports.Caselaw);

                clsConsole.WriteLine(string.Format("\r\n [{0}]CASELAW", clsReports.FilesCountReports.Caselaw), ConsoleColor.Cyan);
                TransmittalFileInfos = new DirectoryInfo(InputTransCaselaw).GetFiles("*.*").Where(p => Regex.IsMatch(p.Extension, "\\.(xml|visf|txt|out)", RegexOptions.IgnoreCase)).ToList();
                break;

            case ProjectSet.NonVirgo:
                MessageBox.Show(projectSet.ToString() + "======" + clsReports.FilesCountReports.NonVirgo);

                clsConsole.WriteLine(string.Format("\r\n [{0}]NON-VIRGO", clsReports.FilesCountReports.NonVirgo), ConsoleColor.Cyan);
                TransmittalFileInfos = new DirectoryInfo(InputTransNonVirgo).GetFiles("*.*").Where(p => Regex.IsMatch(p.Extension, "\\.(xml|visf|txt|out)", RegexOptions.IgnoreCase)).ToList();
                break;

            case ProjectSet.Virgo:
                MessageBox.Show(projectSet.ToString() + "======" + clsReports.FilesCountReports.Virgo);

                clsConsole.WriteLine(string.Format("\r\n [{0}]VIRGO", clsReports.FilesCountReports.NonVirgo), ConsoleColor.Cyan);
                TransmittalFileInfos = new DirectoryInfo(InputTransCaselaw).GetFiles("*.*").Where(p => Regex.IsMatch(p.Extension, "\\.(xml|visf|txt|out)", RegexOptions.IgnoreCase)).ToList();
                break;

            case ProjectSet.CaseRelated:
                MessageBox.Show(projectSet.ToString() + "======" + clsReports.FilesCountReports.CaseRelated);

                clsConsole.WriteLine(string.Format("\r\n [{0}]CASE RELATED", clsReports.FilesCountReports.CaseRelated), ConsoleColor.Cyan);
                TransmittalFileInfos = new DirectoryInfo(InputTransCaseRelated).GetFiles("*.*").Where(p => Regex.IsMatch(p.Extension, "\\.(xml|visf|txt|out)", RegexOptions.IgnoreCase)).ToList();
                break;

            case ProjectSet.StateNet:
                MessageBox.Show(projectSet.ToString() + "======" + clsReports.FilesCountReports.StateNet);

                clsConsole.WriteLine(string.Format("\r\n [{0}]STATE NET", clsReports.FilesCountReports.StateNet), ConsoleColor.Cyan);
                TransmittalFileInfos = new DirectoryInfo(InputTransStateNet).GetFiles("*.*").Where(p => Regex.IsMatch(p.Extension, "\\.(xml|visf|txt|out)", RegexOptions.IgnoreCase)).ToList();
                break;

            case ProjectSet.SecuritiesMosaic:
                MessageBox.Show(projectSet.ToString() + "======" + clsReports.FilesCountReports.SecuritiesMosaic);

                clsConsole.WriteLine(string.Format("\r\n [{0}]SECURITIES MOSAIC", clsReports.FilesCountReports.StateNet), ConsoleColor.Cyan);
                TransmittalFileInfos = new DirectoryInfo(InputTransSecuritiesMosaic).GetFiles("*.*").Where(p => Regex.IsMatch(p.Extension, "\\.(xml|visf|txt|out)", RegexOptions.IgnoreCase)).ToList();
                break;
            }

            MessageBox.Show("File count: " + TransmittalFileInfos.Count);

            SheetName = clsExcel.GetWorkSheetName(projectSet);

            if (!string.IsNullOrEmpty(SheetName))
            {
                if (TransmittalFileInfos.Count > 0)
                {
                    Debug.WriteLine(SheetName + "======" + TransmittalFileInfos.Count);
                    listJobnames = new List <clsReports.Jobnames>();
                    string fileName = string.Empty;
                    WorksheetExcel = (Microsoft.Office.Interop.Excel.Worksheet)WorkbookExcel.Worksheets[SheetName];
                    WorksheetExcel.Select();
                    TransmittalFileInfos.ForEach(f =>
                    {
                        fileName = Path.GetFileNameWithoutExtension(f.FullName);
                        Debug.WriteLine("Chay ky tu " + f.Name);
                        if (!fileName.Equals("manifest", StringComparison.OrdinalIgnoreCase))
                        {
                            clsConsole.Write(string.Format(" *** Searching {0} on delivery Schedule", fileName), ConsoleColor.DarkGray, false);
                            bool flag = clsExcel.SearchValue(fileName, WorksheetExcel);
                            if (flag)
                            {
                                range = (Microsoft.Office.Interop.Excel.Range)WorksheetExcel.Application.ActiveCell;
                                if (range.Value == fileName)
                                {
                                    clsConsole.WriteLine(" ... ok", ConsoleColor.Green);
                                    try
                                    {
                                        ImportValueToCell(SheetName, f);
                                        listJobnames.Add(new clsReports.Jobnames
                                        {
                                            FileName    = fileName,
                                            ActualChars = Charcount
                                        });
                                    }
                                    catch (Exception ex)
                                    {
                                        errorCount++;
                                    }
                                }
                                else
                                {
                                    errorCount++;
                                    clsConsole.WriteLine(string.Format(" ... not found", fileName), ConsoleColor.Red);
                                }
                            }
                            else
                            {
                                clsConsole.WriteLine(string.Format(" ... try again", fileName), ConsoleColor.Red);
                                if (SheetName.Equals("CASE LAW") || SheetName.Equals("VIRGO"))
                                {
                                    tempFilesNotFound.Add(f);
                                }
                            }
                        }
                        else
                        {
                            f.Delete();
                        }
                    });

                    Action <string> runTrialCourt = strWorkSheet =>
                    {
                        Console.Clear();
                        clsConsole.WriteLine("\r\n ************ Trying to run with Trial Court ...", ConsoleColor.Red);
                        int indexPass = 0;
                        SheetName      = strWorkSheet;
                        WorksheetExcel = (Microsoft.Office.Interop.Excel.Worksheet)WorkbookExcel.Worksheets[SheetName];
                        WorksheetExcel.Select();
                        tempFilesNotFound.ForEach(fnf =>
                        {
                            fileName = Path.GetFileNameWithoutExtension(fnf.FullName);
                            if (!fileName.Equals("manifest", StringComparison.OrdinalIgnoreCase))
                            {
                                clsConsole.Write(string.Format(" *** Searching {0} on delivery Schedule", fileName), ConsoleColor.DarkGray, false);
                                bool flag = clsExcel.SearchValue(fileName, WorksheetExcel);
                                if (flag)
                                {
                                    range = (Microsoft.Office.Interop.Excel.Range)WorksheetExcel.Application.ActiveCell;
                                    if (range.Value == fileName)
                                    {
                                        clsConsole.WriteLine(" ... ok", ConsoleColor.Green);
                                        try
                                        {
                                            ImportValueToCell(SheetName, fnf);
                                            listJobnames.Add(new clsReports.Jobnames
                                            {
                                                FileName    = fileName,
                                                ActualChars = Charcount
                                            });
                                            indexPass++;
                                        }
                                        catch (Exception ex)
                                        {
                                            errorCount++;
                                        }
                                    }
                                    else
                                    {
                                        errorCount++;
                                        clsConsole.WriteLine(string.Format(" ... not found", fileName), ConsoleColor.Red);
                                    }
                                }
                                else
                                {
                                    clsConsole.WriteLine("Not found", ConsoleColor.Red);
                                }
                            }
                            else
                            {
                                fnf.Delete();
                            }
                        });
                        if (indexPass == tempFilesNotFound.Count)
                        {
                            tempFilesNotFound.Clear();
                        }
                        SheetName = clsExcel.GetWorkSheetName(projectSet);
                    };

                    if (tempFilesNotFound.Count > 0)
                    {
                        try
                        {
                            runTrialCourt("TRIAL COURT CASE LAW");
                        }
                        finally
                        {
                            if (tempFilesNotFound.Count > 0)
                            {
                                runTrialCourt("TRIAL COURT VIRGO");
                            }
                        }
                    }

                    Console.Clear();
                    clsConsole.WriteLine("\r\n Saving LN Schedule ...", ConsoleColor.Red);
                    WorkbookExcel.Save();

                    JobnameReports(projectSet);
                }
                TransmittalFileInfos.Clear();
            }
        }