Exemplo n.º 1
0
        public static int RegisterTask(COREobject core, string Block, string TaskName, string Button = "", int ModelId = -1, DateTime?StartTime = null, int Minutes = -1)
        {
            string hostname   = TapestryUtils.GetServerHostName();
            string appName    = core.Application.Name;
            string serverName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

            string systemAccName = WebConfigurationManager.AppSettings["SystemAccountName"];
            string systemAccPass = WebConfigurationManager.AppSettings["SystemAccountPass"];

            string targetUrl;

            if (serverName == "localhost")
            {
                targetUrl = $"https://omnius-as.azurewebsites.net/{appName}/{Block}/Get?modelId={ModelId}&User={systemAccName}&Password={systemAccPass}";
            }
            else
            {
                targetUrl = $"{hostname}/{appName}/{Block}/Get?modelId={ModelId}&User={systemAccName}&Password={systemAccPass}";
            }

            if (Button != "")
            {
                targetUrl += $"&button={Button}";
            }

            DateTime time;

            if (StartTime != null)
            {
                time = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(StartTime.Value, DateTimeKind.Unspecified),
                                                     TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"));
            }
            else
            {
                time = DateTime.Now.AddMinutes(Minutes);
            }

            var newTask = new Task
            {
                AppId      = core.Application.Id,
                Active     = true,
                Name       = TaskName,
                Type       = ScheduleType.ONCE,
                Url        = targetUrl,
                Repeat     = false,
                Start_Time = new TimeSpan(time.Hour, time.Minute, 0),
                Start_Date = time
            };
            var cortex = new Cortex.Cortex();

            cortex.Save(newTask);

            return(newTask.Id.Value);
        }
Exemplo n.º 2
0
        public static void UnregisterTask(COREobject core, string Block, string Button = "", int ModelId = -1)
        {
            string hostname   = TapestryUtils.GetServerHostName();
            string appName    = core.Application.Name;
            string serverName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

            string targetUrl;

            targetUrl = $"{hostname}/{appName}/{Block}/Get?modelId={ModelId}&User=Scheduler&Password=194GsQwd/AgB4ZZnf_uF";

            if (Button != "")
            {
                targetUrl += $"&button={Button}";
            }

            var cortex = new Cortex.Cortex();

            cortex.Delete(targetUrl);
        }
Exemplo n.º 3
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            COREobject core = COREobject.i;

            string hostname   = TapestryUtils.GetServerHostName();
            string appName    = core.Application.Name;
            string blockName  = (string)vars["Block"];
            string button     = vars.ContainsKey("Button") ? (string)vars["Button"] : "";
            int    modelId    = vars.ContainsKey("ModelId") ? (int)vars["ModelId"] : -1;
            string serverName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

            string targetUrl;

            targetUrl = $"{hostname}/{appName}/{blockName}/Get?modelId={modelId}&User=Scheduler&Password=194GsQwd/AgB4ZZnf_uF";

            if (button != "")
            {
                targetUrl += $"&button={button}";
            }

            var cortex = new Cortex.Cortex();

            cortex.Delete(targetUrl);
        }
Exemplo n.º 4
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            Application app = COREobject.i.Application;

            bool   isutc      = vars.ContainsKey("InputIsUtc") ? (bool)vars["InputIsUtc"] : false;
            string hostname   = TapestryUtils.GetServerHostName();
            string appName    = app.Name;
            string blockName  = (string)vars["Block"];
            string button     = vars.ContainsKey("Button") ? (string)vars["Button"] : "";
            int    modelId    = vars.ContainsKey("ModelId") ? (int)vars["ModelId"] : -1;
            string serverName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

            string systemAccName = WebConfigurationManager.AppSettings["SystemAccountName"];
            string systemAccPass = WebConfigurationManager.AppSettings["SystemAccountPass"];

            string targetUrl;

            if (serverName == "localhost")
            {
                targetUrl = $"https://omnius-as.azurewebsites.net/{appName}/{blockName}/Get?modelId={modelId}&User={systemAccName}&Password={systemAccPass}";
            }
            else
            {
                targetUrl = $"{hostname}/{appName}/{blockName}/Get?modelId={modelId}&User={systemAccName}&Password={systemAccPass}";
            }

            if (button != "")
            {
                targetUrl += $"&button={button}";
            }

            string   taskName = (string)vars["TaskName"];
            DateTime time;

            if (vars.ContainsKey("StartTime"))
            {
                var localTime = (DateTime)vars["StartTime"];
                if (!isutc)
                {
                    time = TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(localTime, DateTimeKind.Unspecified),
                                                         TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"));
                }
                else
                {
                    time = localTime;
                }
            }
            else
            {
                int minutes = Convert.ToInt32(vars["Minutes"]);
                time = DateTime.Now.AddMinutes(minutes);
            }

            var newTask = new Task
            {
                AppId      = app.Id,
                Active     = true,
                Name       = taskName,
                Type       = ScheduleType.ONCE,
                Url        = targetUrl,
                Repeat     = false,
                Start_Time = new TimeSpan(time.Hour, time.Minute, 0),
                Start_Date = time
            };
            var cortex = new Cortex.Cortex();

            cortex.Save(newTask);

            outputVars["TaskId"] = newTask.Id;
        }