Beispiel #1
0
        /// <summary>
        /// Used to Read the Settings.ini file.
        /// </summary>
        /// <param name="FileName">Contains the Settings file name with extension.</param>
        /// <param name="NumberOfFields">Number of Fields in the Settings File. (Default 9)</param>
        /// <param name="ValuePosition">The Number of Strings in One Line before the value of the fieldName. (Default 0-3)</param>
        private static void ReadSettingsFile(SendingEmail sender, int ValuePosition = 3)
        {
            string line;
            int    count = 0;

            string[] values = new string[MAX_SETTINGS_FIELDS];



            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader(SettingsFileName);
            while ((line = file.ReadLine()) != null)
            {
                values[count] = line.Split(' ')[ValuePosition];
                System.Console.WriteLine(count + " Value: " + values[count]);
                count++;
            }
            sender = new SendingEmail(values[0],
                                      values[1],
                                      values[2],
                                      values[3],
                                      values[4],
                                      values[16],
                                      values[21],
                                      values[22],
                                      values[23],
                                      values[24]);
            PathToXMLFiles        = values[5];
            PathToWordTemplate    = values[6];
            InterviewDoobloAPIurl = values[7];
            PathToWordDoc         = values[8];
            PathToPDFFile         = values[9];
            SurveyID       = values[10];
            RESTAPIKey     = values[11];
            DoobloUserName = values[12];
            DoobloPassWord = values[13];
            int.TryParse(values[14], out CountOfDatabaseRecordsFetched);
            int.TryParse(values[15], out NumberOfFieldsFromXML);
            XMLFileName          = values[17];
            WordDocFileName      = values[18];
            PDFFileName          = values[19];
            WordTemplateFileName = values[20];
            ClientsHistory       = values[25];

            Console.WriteLine($"Number of Fields Parsed: { count }");

            file.Close();
            System.Console.ReadLine();
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            string[] Names, Values;
            int      InterviewID = 42;

            try
            {
                MainProgram      mail      = new MainProgram();
                CreateWordDoc    creator   = new CreateWordDoc();
                SendingEmail     sender    = new SendingEmail();
                WordToPDF        converter = new WordToPDF();
                ExtractFieldsXML job       = new ExtractFieldsXML();

                ReadSettingsFile(sender);

                int count = mail.ReadWithRESTSaveXMLReportFile();

                for (int i = 0; i < count; i++)
                {
                    try
                    {
                        InterviewID = ProcessedInterviewIDs.ElementAt <int>(i);

                        job.ExtractFieldsfromXML(InterviewID, PathToXMLFiles + XMLFileName,
                                                 NumberOfFieldsFromXML, out Names, out Values);

                        creator.CreateWordDocFromFields(InterviewID, PathToWordTemplate + WordTemplateFileName, PathToWordDoc + WordDocFileName, Names, Values);

                        string PDFFilePathFileName = PathToPDFFile + PDFFileName.Replace(".pdf", "") + "_" + Values[9] + ".pdf";

                        string WordFilePathFileName = PathToWordDoc + WordDocFileName;

                        converter.ConvertDOCtoPDF(InterviewID, WordFilePathFileName, PDFFilePathFileName);

                        sender.SendEmail(InterviewID, PDFFilePathFileName, Values[10]);
                    } catch (Exception e)
                    {
                        S.WriteLine($"Error in Processing Record ID: { InterviewID }.");
                        S.WriteLine("Exception " + e);
                        if (i <= count - 2)
                        {
                            S.WriteLine("Moving to next record.");
                        }
                        else
                        {
                            S.WriteLine("All records processed.");
                        }
                        continue;
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            finally
            {
                System.Console.ReadLine();
            }
        }