Esempio n. 1
0
        private static void Import()
        {
            StreamReader reader;

            try
            {
                reader = new StreamReader(ImportPath + ImportFile + ".txt");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Couldn't open " + ImportPath + ImportFile + ".txt");
                return;
            } string textLine;

            while (!string.IsNullOrEmpty(textLine = reader.ReadLine()))
            {
                string[] text = textLine.Split('|');
                DbDocumentBoxidPosting boxidPosting    = new DbDocumentBoxidPosting();
                DbDocumentImagePosting docImagePosting = Factory.DbDocumentImagePostingQuery.GetDocumentImagePostingByImageID(text[0]);
                if (docImagePosting != null)
                {
                    boxidPosting.DocumentID = docImagePosting.DocumentID;
                    boxidPosting.Message    = text[3];
                    boxidPosting.Status     = text[2];
                    try
                    {
                        Factory.DbDocumentBoxIDPostingService.Update(boxidPosting);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
        }
Esempio n. 2
0
        public static void ReadExportImageLogfile()
        {
            Console.WriteLine("Read yesterday logindexfile file for appending today indexfile.");
            StreamReader reader;

            string fileOutPath = ImportPath;
            //DateTime yesterday = DateTime.Now.AddDays(-1);
            //New version update 27/04/2009
            DateTime yesterday = DateTime.Now;
            //tne_logimageindexfile.txt
            string inPath = @ImportPath + ImportFile + yesterday.ToString("yyMMdd") + ".txt";

            Console.WriteLine("Appending index file for SAP re-read image.");
            try
            {
                reader = new StreamReader(inPath);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Couldn't open " + inPath);
                Console.WriteLine(ex.ToString());
                return;
            }

            string textLine;

            while ((textLine = reader.ReadLine()) != null)
            {
                string[] textField = textLine.Split('|');
                DbDocumentImagePosting docImagePost = imgPostingQuery.GetDocumentImagePostingByImageID(textField[0]);
                if (docImagePost == null)
                {
                    continue;
                }
                if (textField[2] == "s" || textField[2] == "S")
                {
                    try
                    {
                        Interface.Utilities.FileManager.DeleteFile(ImportPath + "temp\\" + docImagePost.ImageDocID);
                    }
                    catch (Exception)
                    {
                    }
                    docImagePost.Status     = textField[2];
                    docImagePost.Message    = textField[3];
                    docImagePost.ImageDocID = textField[1];
                    SaveLogToDatabase(docImagePost.DocumentID.ToString(), "Success", docImagePost.Message);
                    //call Notify function.
                    //imagePostService.NotifyImageFile(docImagePost.DocumentID);
                }
                else
                {
                    docImagePost.Status  = "F";
                    docImagePost.Message = textField[3];
                    //docImagePost.ImageDocID = textField[1];
                    SaveLogToDatabase(docImagePost.DocumentID.ToString(), "Fail", docImagePost.Message);
                }
                imagePostService.Update(docImagePost);
            }

            Console.WriteLine("Append index file success.");
        }