Exemplo n.º 1
0
        public static String SaveLogProcedure(Models.ProcedureSchedule procedureschedule, String process, String message, int logLevel, Models.Parameter parameter)
        {
            Models.GAContext context = new Models.GAContext();

            String logFolder        = parameter.PathLog;
            int    logLevelDatabase = parameter.LogLevelUpdate;
            String logName          = "";
            String logLevelName     = "Message";

            if (logLevel == 1)
            {
                logLevelName = "Error";
            }

            DateTime today = DateTime.Now;

            logName = "GA-Procedure-" + procedureschedule.Schedule.Year.ToString().PadLeft(4, '0') + "-" + procedureschedule.Schedule.Month.ToString().PadLeft(2, '0') + "-" + procedureschedule.Schedule.Day.ToString().PadLeft(2, '0') + "-" + procedureschedule.Procedure.Name + "-" + procedureschedule.Id + ".log";

            try
            {
                if (!logFolder.EndsWith("\\"))
                {
                    logFolder += "\\";
                }
                logFolder += "Procedures\\";
                System.IO.Directory.CreateDirectory(logFolder);

                if (logLevel <= logLevelDatabase)
                {
                    System.IO.File.AppendAllText(logFolder + logName, DateTime.Now.ToString() + " - " + logLevelName + " - " + process + " - " + message + System.Environment.NewLine);
                }
            }

            catch (Exception error)
            {
                return(error.ToString());
            }

            return(null);
        }
Exemplo n.º 2
0
        public static void Initialize_Context_in_Startup(IServiceProvider serviceProvider)
        {
            IServiceScope serviceScope = serviceProvider.GetService <IServiceScopeFactory>().CreateScope();

            Context = serviceScope.ServiceProvider.GetService <GAContext>();
        }