Ejemplo n.º 1
0
 public void DeleteGlobalParameters(string type, string name = null)
 {
     using (var connection = new NpgsqlConnection(ConnectionString))
     {
         WorkflowGlobalParameter.DeleteByTypeAndName(connection, type, name);
     }
 }
Ejemplo n.º 2
0
        public void SaveGlobalParameter <T>(string type, string name, T value)
        {
            using (var connection = new NpgsqlConnection(ConnectionString))
            {
                var parameter = WorkflowGlobalParameter.SelectByTypeAndName(connection, type, name).FirstOrDefault();

                if (parameter == null)
                {
                    parameter = new WorkflowGlobalParameter()
                    {
                        Id    = Guid.NewGuid(),
                        Type  = type,
                        Name  = name,
                        Value = JsonConvert.SerializeObject(value)
                    };

                    parameter.Insert(connection);
                }
                else
                {
                    parameter.Value = JsonConvert.SerializeObject(value);

                    parameter.Update(connection);
                }
            }
        }
Ejemplo n.º 3
0
        public List <T> LoadGlobalParameters <T>(string type)
        {
            using (var connection = new NpgsqlConnection(ConnectionString))
            {
                var parameters = WorkflowGlobalParameter.SelectByTypeAndName(connection, type);

                return(parameters.Select(p => JsonConvert.DeserializeObject <T>(p.Value)).ToList());
            }
        }
Ejemplo n.º 4
0
        public T LoadGlobalParameter <T>(string type, string name)
        {
            using (var connection = new NpgsqlConnection(ConnectionString))
            {
                var parameter = WorkflowGlobalParameter.SelectByTypeAndName(connection, type, name).FirstOrDefault();

                if (parameter == null)
                {
                    return(default(T));
                }

                return(JsonConvert.DeserializeObject <T>(parameter.Value));
            }
        }