Exemple #1
0
        static bool processFile(ProgArgs args)
        {
            bool success = false; // initiate succss variable

            try
            {
                string line;
                //                StreamReader InFile = new StreamReader(args.TargetDirectory + args.InputFile);
                StreamReader InFile = new StreamReader(args.InputFile);

                //                using (StreamWriter OutFile = new StreamWriter(args.TargetDirectory + args.OutputFile, false))
                using (StreamWriter OutFile = new StreamWriter(args.OutputFile, false))
                {
                    using (Application obApp = OnBaseConnect())
                    {
                        // Get the Unity Form Template (by name or id).
                        FormTemplate nameChangeTemplate = obApp.Core.UnityFormTemplates.Find(@"Member Name Add/Modify");

                        if (nameChangeTemplate != null)
                        {
                            Log.Logger.Debug("FormTemplate Found: {FormTemplateName}", nameChangeTemplate.Name);

                            while ((line = InFile.ReadLine()) != null)
                            {
                                Member member = new Member(line);

                                // Create the Unity Form properties for the template
                                StoreNewUnityFormProperties uFormProps = obApp.Core.Storage.CreateStoreNewUnityFormProperties(nameChangeTemplate);

                                // Add form keywords
                                uFormProps.AddKeyword("Member No.", Convert.ToInt32(member.MemberNo));
                                uFormProps.AddKeyword(@"Last Name (or Business/Trust Name)", member.LastName);
                                uFormProps.AddKeyword("First Name", member.FirstName);

                                // Create the new Unity Form
                                Document newUnityForm = obApp.Core.Storage.StoreNewUnityForm(uFormProps);
                                Log.Logger.Debug(string.Format("Form Created: docid={0}.", newUnityForm.ID));

                                OutFile.WriteLine(line);
                            }
                            success = true;
                        }
                        else
                        {
                            Log.Logger.Error("Unity Form Template Not found!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error("Processing file failed! {ExceptionMessage}", ex.Message);
            }

            return(success);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            LogConfiguration.ConfigureSerilog();
            Log.Logger.Information("Start Processing {AppName}!", System.Configuration.ConfigurationManager.AppSettings["Application.Name"]);


            //Exit code that indicates that the preprocessor ran successfully
            Environment.ExitCode = 0;

            //Ensure that two (3) parameters have been specified
            if (!args.Length.Equals(2))
            {
                Log.Logger.Error("Wrong number of parameters! Invoke with InputFile, ExportFile, TargetDirectory");
                Environment.ExitCode = -1;
            }
            else
            {
                ProgArgs progArgs = new ProgArgs
                {
                    InputFile  = args[0],               // Example: PP_Member_Info.csv
                    OutputFile = args[1]                // Example: PP_Member_Info_out.csv
                };

                if (!File.Exists(progArgs.InputFile))
                {
                    //                    Log.Logger.Error("Input File {InputFile} does NOT exist!", progArgs.TargetDirectory + progArgs.InputFile);
                    Log.Logger.Error("Input File {InputFile} does NOT exist!", progArgs.InputFile);
                    Environment.ExitCode = -3;
                }
                else
                {
                    if (!processFile(progArgs))
                    {
                        Log.Logger.Error("A processing error occurred!");

                        // Exit code that indicates that an error occurred
                        // while running the preprocessor
                        Environment.ExitCode = -4;
                    }
                }
            }

            Log.Logger.Information("Exiting with code: {ExitCode}", Environment.ExitCode);
            LogConfiguration.FlushSerilog();
        }