Пример #1
0
        protected override void SaveTranslatedFile(XmlDocument TranslatedDocument)
        {
            LogMessage("Creating Totals Report");
            XmlDocument ConvertedSourceDoc = new XmlDocument();

            ConvertedSourceDoc.Load(SourceDocument);
            SendTotalsReport(TranslateSupport.GenerateSummaryReport(ConvertedSourceDoc, TranslatedDocument));

            XmlNodeList list = TranslatedDocument.SelectNodes("//" + NewDocumentRoot + "/*");

            //// create a writer and open the file
            string OutFile = PluginConfig.GetValue("TemporaryWorkFolder") + "\\translated.tmp";

            using (TextWriter tw = new StreamWriter(OutFile, false))
            {
                foreach (XmlNode node in list)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int x = 0; x < node.Attributes.Count; x++)
                    {
                        sb.Append(node.Attributes[x].Value.ToString() + "\t");
                    }
                    tw.WriteLine(sb.ToString());
                }
                tw.Close();
            }
            if (storeRegInfo != null)
            {
                storeRegInfo.SaveTransactionInfo();
            }

            //Do out translate clean up tasks here
            SplitTranslatedFile(OutFile, 1);
            CopyToSiris();
            MoveFilesToBackup();
            LogMessage("-------------------------------Translate Complete-------------------------------");
        }
Пример #2
0
        void IOrderTranslateItem_OnPreProcess()
        {
            LogMessage("-------------------------------Translate Started-------------------------------");

            TranslateSupport support = new TranslateSupport(PluginConfig);

            SkuFile = support.SkuList();

            string TempFolder = PluginConfig.GetValue("TemporaryWorkFolder");

            _OrderHeaderFile  = TempFolder + "\\OrderHeaderMerge";
            _OrderDetailFile  = TempFolder + "\\OrderDetailMerge";
            _OrderPaymentFile = TempFolder + "\\OrderPaymentMerge";

            LogMessage("Removing old files.");
            if (File.Exists(_OrderHeaderFile))
            {
                File.Delete(_OrderHeaderFile);
            }
            if (File.Exists(_OrderDetailFile))
            {
                File.Delete(_OrderDetailFile);
            }
            if (File.Exists(_OrderPaymentFile))
            {
                File.Delete(_OrderPaymentFile);
            }

            DirectoryInfo dirinfo = new DirectoryInfo(base.SourceFileLocation);

            //if email field is left blank this check is skipped
            if (!String.IsNullOrEmpty(PluginConfig.GetValue("DuplicateFilesEmail")))
            {
                //Remove any files from the download directory if they have already been processed.  Reprocessing those files will cause problems if sent to SIRIS.
                List <string> FilesRemoved = new List <string>();
                List <string> FilesKept    = new List <string>();
                TranslateSupport.RemoveProcessedFiles(dirinfo.GetFiles(), PluginConfig.GetValue("WebLincBackupFolder"), out FilesRemoved, out FilesKept);
                if (FilesRemoved.Count != 0)
                {
                    StringBuilder Body = new StringBuilder();
                    Body.Append("Processing of the following files was skipped because they have been previously processed. <BR>");
                    foreach (string file in FilesRemoved)
                    {
                        Body.Append(file + "<BR>");
                    }

                    Body.Append("____________________________________________________________<BR>");
                    if (FilesKept.Count > 0)
                    {
                        Body.Append("The following files were still processed<BR>");
                        foreach (string file in FilesKept)
                        {
                            Body.Append(file + "<BR>");
                        }
                    }
                    else
                    {
                        Body.Append("NO other files were processed.<BR>");
                    }

                    SendEmail("*****@*****.**", PluginConfig.GetValue("DuplicateFilesEmail").Split(';'), "Duplicate Internet Order Files Found", Body.ToString(), null);
                    LogMessage(Body.ToString().Replace("<BR>", "\r\n"));

                    dirinfo = new DirectoryInfo(base.SourceFileLocation);
                }
            }


            LogMessage("Merging all OrderHeader files");
            TranslateSupport.MergeFiles(dirinfo.GetFiles("*orderheader*.*"), _OrderHeaderFile);
            LogMessage("Merging all OrderDetail files");
            TranslateSupport.MergeFiles(dirinfo.GetFiles("*orderdetail*.*"), _OrderDetailFile);
            LogMessage("Merging all OrderPayment files");
            TranslateSupport.MergeFiles(dirinfo.GetFiles("*orderpayment*.*"), _OrderPaymentFile);
        }