示例#1
0
        public static void OpenUrl(COREobject core, string Block, string Button = "", int ModelId = -1)
        {
            DBConnection db = core.Entitron;

            string hostname   = TapestryUtils.GetServerHostName();
            string appName    = db.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}";
            }

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(targetUrl);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        }
示例#2
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            DBConnection db = COREobject.i.Entitron;

            string hostname   = TapestryUtils.GetServerHostName();
            string appName    = db.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 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}";
            }

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(targetUrl);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        }
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            var number      = vars["Number"];
            var maxDecimals = vars["MaxDecimals"];

            outputVars["Result"] = TapestryUtils.DoubleToHex(Convert.ToDouble(number), (int)maxDecimals);
        }
示例#4
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> invertedVars, Message message)
        {
            COREobject core = COREobject.i;

            string hostname = TapestryUtils.GetServerHostName();
            string appName  = core.Application.Name;

            outputVars["Result"] = $"{hostname}/{appName}";
        }
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> invertedVars, Message message)
        {
            COREobject core      = COREobject.i;
            string     hostname  = TapestryUtils.GetServerHostName();
            string     appName   = core.Application.Name;
            string     blockName = (string)vars["BlockName"];
            int        modelId   = (int)vars["Id"];

            outputVars["Result"] = $"{hostname}/{appName}/{blockName}?modelId={modelId}";
        }
示例#6
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);
        }
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            DBConnection db = COREobject.i.Entitron;

            bool searchInShared = vars.ContainsKey("SearchInShared") ? (bool)vars["SearchInShared"] : false;

            string tableName = vars.ContainsKey("TableName")
                ? (string)vars["TableName"]
                :(string)vars["__TableName__"];
            DBTable table = db.Table(tableName, searchInShared);

            if (table == null)
            {
                throw new Exception($"Queried table not found! (Table: {tableName}, Action: {Name} ({Id}))");
            }
            if (!vars.ContainsKey("JArray"))
            {
                throw new Exception("JArray parameter not passed!");
            }

            JArray jarray = (JArray)vars["JArray"];

            foreach (JObject jo in jarray)
            {
                Dictionary <string, object> parsedColumns = new Dictionary <string, object>();
                TapestryUtils.ParseJObjectRecursively(jo, parsedColumns);

                DBItem parsedRow = new DBItem(db, null);
                foreach (var parsedCol in parsedColumns)
                {
                    parsedRow[parsedCol.Key] = parsedCol.Value;
                }

                DBItem item = new DBItem(db, table);
                foreach (DBColumn col in table.Columns)
                {
                    if (col.Name == DBCommandSet.PrimaryKey)
                    {
                        continue;
                    }
                    string parsedColName = (col.Name == "ext_id") ? DBCommandSet.PrimaryKey : col.Name;
                    item[col.Name] = parsedRow[parsedColName];
                }

                table.Add(item);
            }
            db.SaveChanges();

            outputVars["Result"] = "Successful";
        }
示例#8
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);
        }
示例#9
0
        private void SetDBItemValues(ref DBItem item, IEnumerable <DBColumn> columns, JToken values)
        {
            Dictionary <string, object> parsedValues = new Dictionary <string, object>();

            TapestryUtils.ParseJObjectRecursively((JObject)values, parsedValues);

            foreach (DBColumn column in columns)
            {
                if (column.Name == DBCommandSet.PrimaryKey)
                {
                    continue;
                }

                if (parsedValues[column.Name] != null)
                {
                    item[column.Name] = parsedValues[column.Name];
                }
                if (column.Name == extIdColumnName)
                {
                    item[column.Name] = parsedValues[diffIdColumnName];
                }
            }
        }
        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);
        }
示例#11
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;
        }
示例#12
0
 public static string GetHostUrl(COREobject core)
 {
     return(TapestryUtils.GetServerHostName());
 }
示例#13
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            JArray jarray = (JArray)vars["JArray"];

            if (jarray.HasValues)
            {
                DBConnection db = COREobject.i.Entitron;

                bool searchInShared = vars.ContainsKey("SearchInShared") ? (bool)vars["SearchInShared"] : false;

                string tableName = vars.ContainsKey("TableName")
                    ? (string)vars["TableName"]
                    : (string)vars["__TableName__"];
                DBTable table = db.Table(tableName, searchInShared);
                if (table == null)
                {
                    throw new Exception($"Queried table not found (Tabulka: {tableName}, Akce: {Name} ({Id}))");
                }
                var listDbItem = table.Select().ToList();
                //check if table has column (IsDeleted),if no , the result is null
                var columnIsDeletedExist = table.Columns.SingleOrDefault(c => c.Name == "IsDeleted");


                string uniqueCol;
                string uniqueExtCol; //basicly foreign key
                if (vars.ContainsKey("UniqueCol"))
                {
                    uniqueCol    = (string)vars["UniqueCol"];
                    uniqueExtCol = uniqueCol;
                }
                else
                {
                    uniqueCol    = "ext_id";
                    uniqueExtCol = DBCommandSet.PrimaryKey;
                }
                if (!table.Columns.Any(c => c.Name == uniqueCol))
                {
                    throw new Exception($"Table column named '{uniqueCol}' not found!");
                }
                foreach (JObject jo in jarray)
                {
                    if (columnIsDeletedExist != null)
                    {
                        //if theres column IsDeleted, check if the entity is in rising, if not, set isDeleted to true.
                        for (int i = 0; i < listDbItem.Count; i++)
                        {
                            if (!jarray.Any(j => j["id"].ToString() == listDbItem[i]["ext_id"].ToString()))
                            {
                                DBItem foundItem = listDbItem[i];
                                foundItem["IsDeleted"] = true;
                                table.Update(foundItem, (int)foundItem["id"]);
                            }
                        }
                    }
                    Dictionary <string, object> parsedColumns = new Dictionary <string, object>();
                    TapestryUtils.ParseJObjectRecursively(jo, parsedColumns);
                    DBItem parsedRow = new DBItem(db, table, parsedColumns);

                    DBItem updatedRow = table.Select().Where(c => c.Column(uniqueCol).Equal(parsedRow[uniqueExtCol])).FirstOrDefault();

                    if (updatedRow != null) //update
                    {
                        foreach (var col in parsedRow.getColumnNames())
                        {
                            if (updatedRow.getColumnNames().Contains(col) && col != DBCommandSet.PrimaryKey && col != uniqueCol)
                            {
                                updatedRow[col] = parsedRow[col];
                            }
                        }
                        table.Update(updatedRow, (int)updatedRow[DBCommandSet.PrimaryKey]);
                    }
                    else // insert row if it does not exist
                    {
                        DBItem item = new DBItem(db, table);
                        foreach (DBColumn col in table.Columns)
                        {
                            if (col.Name == DBCommandSet.PrimaryKey)
                            {
                                continue;
                            }
                            string parsedColName = (col.Name == "ext_id") ? DBCommandSet.PrimaryKey : col.Name;
                            item[col.Name] = parsedRow[parsedColName];
                        }

                        table.Add(item);
                    }
                }
                db.SaveChanges();
                outputVars["Result"] = true;
            }
            else
            {
                Watchtower.OmniusLog.Log($"{Name}: Input JArray has no values! Action aborted", Watchtower.OmniusLogLevel.Warning);
                outputVars["Result"] = false;
            }
        }
示例#14
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> invertedVars, Message message)
        {
            string hostname = TapestryUtils.GetServerHostName();

            outputVars["Result"] = $"{hostname}";
        }
示例#15
0
 public static string ConvertToHex(COREobject core, double Number, int MaxDecimals)
 {
     return(TapestryUtils.DoubleToHex(Number, MaxDecimals));
 }