Example #1
0
        public Report()
        {
            PlanetVoStatus = new PlanetVo();
            Tec3HStatus    = new Tec3H();

            HavasStatus = false;

            PdvNameChange       = string.Empty;
            LuceneStatus        = false;
            ImportVehicleStatus = false;
            XmlPdvFile          = false;
        }
Example #2
0
        static void Main(string[] args)
        {
            Application app = new Application();

            Report.Report report = new Report.Report();
            PlanetVo      pvo    = new PlanetVo();
            Tec3H         tec3h  = new Tec3H();

            MailItem item;

            string[] tempData;
            string   tempPath;

            string[] emails = Directory.GetFiles(ConfigurationManager.AppSettings["EmailPath"]);

            //PlanetVO XML Zip Report
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Import Vehicle PlanetVo FTP files downloaded successfully"));

            item           = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData       = GetEmailData(item.Body);
            pvo.FtpSuccess = Int32.Parse(tempData[1]);
            pvo.FtpFailure = Int32.Parse(tempData[2]);

            //Tec3H XML Zip Report
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Import Vehicle Tec3H FTP files downloaded successfully"));
            item             = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData         = GetEmailData(item.Body);
            tec3h.FtpSuccess = Int32.Parse(tempData[1]);
            tec3h.FtpFailure = Int32.Parse(tempData[2]);

            //PlanetVO XML Status
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Import Vehicle PlanetVo XML ImportVehicle"));

            item                      = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData                  = GetEmailData(item.Body);
            pvo.ZipFiles              = Int32.Parse(tempData[0]);
            pvo.ImportVehicleRecords  = Int32.Parse(tempData[1]);
            pvo.NotWellFormedXmlCount = tempData[2];
            pvo.NotFoundPos           = tempData[3];

            //Tec3H XML Status
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Import Vehicle Tec3H XML ImportVehicle"));

            item                        = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData                    = GetEmailData(item.Body);
            tec3h.ZipFiles              = Int32.Parse(tempData[0]);
            tec3h.ImportVehicleRecords  = Int32.Parse(tempData[1]);
            tec3h.NotWellFormedXmlCount = tempData[2];
            tec3h.NotFoundPos           = tempData[3];

            //Import Vehicle Stock Evolution
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Import VehicleImport Vehicle Stock Evolution"));
            item                    = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData                = GetEmailData(item.Body);
            pvo.StockCount          = Int32.Parse(tempData[2]);
            pvo.NewStockCount       = Int32.Parse(tempData[4]);
            pvo.DeletedStockCount   = Int32.Parse(tempData[6]);
            tec3h.StockCount        = Int32.Parse(tempData[3]);
            tec3h.NewStockCount     = Int32.Parse(tempData[5]);
            tec3h.DeletedStockCount = Int32.Parse(tempData[7]);

            //Total photo count PlanetVO
            Photo pvoPhoto = new Photo();

            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "PlanetVO Retrieval and processing"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            pvoPhoto.TotalCount = GetPhotoCount(item.Body);

            //Total photo count Tec3H
            Photo tec3HPhoto = new Photo();

            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Tec3H Retrieval and processing"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tec3HPhoto.TotalCount = GetPhotoCount(item.Body);

            //Total photo summary PlanetVO
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "PlanetVO Summary of import vehicle photo"));
            item     = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData = GetEmailData(item.Body);
            pvoPhoto.VehicleToTransfer = Int32.Parse(tempData[1]);
            pvoPhoto.PhotoCount        = Int32.Parse(tempData[2]);
            pvoPhoto.NewPhotoCount     = Int32.Parse(tempData[3]);
            pvoPhoto.Md5ChangeCount    = Int32.Parse(tempData[4]);
            pvoPhoto.FailCount         = Int32.Parse(tempData[5]);

            //Total photo summary Tec3H
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Tec3H Summary of import vehicle photo"));
            item     = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tempData = GetEmailData(item.Body);
            tec3HPhoto.VehicleToTransfer = Int32.Parse(tempData[1]);
            tec3HPhoto.PhotoCount        = Int32.Parse(tempData[2]);
            tec3HPhoto.NewPhotoCount     = Int32.Parse(tempData[3]);
            tec3HPhoto.Md5ChangeCount    = Int32.Parse(tempData[4]);
            tec3HPhoto.FailCount         = Int32.Parse(tempData[5]);

            pvo.PhotoStatus   = pvoPhoto;
            tec3h.PhotoStatus = tec3HPhoto;

            //HAVAS - JSON uploaded
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "HAVAS"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);

            report.HavasStatus = item.Body.Contains("This mail is to inform you that the JSON file was successfully uploaded. Please do not reply to this mail");

            //PDV Name Change
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "PDV Name Change"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            report.PdvNameChange = item.Body.Replace("Batch Execution Successful \r\n\r\n", "");

            //Reset Application pool
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Reset Application Pool"));

            if (!string.IsNullOrEmpty(tempPath))
            {
                item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
                report.ResetApplicationPoolStatus = item.Subject.Contains("Successfully");
            }

            //Export Info
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Export INFO"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            int hour   = item.ReceivedTime.Hour;
            int minute = item.ReceivedTime.Minute;

            int startHour = Int32.Parse(ConfigurationManager.AppSettings["StartHour"]);

            report.ExecutionTime = string.Format("{0:00}h{1:00}m", hour - startHour, minute);

            report.XmlPdvFile = item.Subject.Contains("successfully");

            //Import Vehicle Status
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Import VehicleImport"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            report.ImportVehicleStatus = item.Subject.Contains("Import VehicleImport");

            //Tec3H Missing Argus Report
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "XML Tec3H Missing Argus Report"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            tec3h.VehicleFailedArgus = item.Body.Replace("Détails des véhicules sans Argus\r\n\r\n\r\n", string.Empty).Replace("\n", "<br/>\n");

            //Lucene Generation Status
            tempPath = Array.Find(emails,
                                  s =>
                                  s.Contains(
                                      "Lucene Index"));
            item = (MailItem)app.CreateItemFromTemplate(tempPath, Type.Missing);
            report.LuceneStatus = item.Subject.Contains("successfully");

            report.PlanetVoStatus = pvo;
            report.Tec3HStatus    = tec3h;

            GenerateHtml(report);

            if (File.Exists("Report.json"))
            {
                File.Delete("Report.json");
            }
            File.WriteAllText("Report.json", JsonConvert.SerializeObject(report, Formatting.Indented));
        }