Ejemplo n.º 1
0
        public async Task <WFChart> Get(string ChartName)
        {
            WFChart result = null;

            result = await _WFContext.WFChart.FromSql("select ChartName, ChartId, ChartDescription from owf.wfChart " + ChartNameSelectTail(ChartName)
                                                      ).SingleOrDefaultAsync <WFChart>();

            return(result);
        }
Ejemplo n.º 2
0
        public async Task Delete(WFChart chart)
        {
            var ChartName = new SqlParameter("ChartName", chart.ChartName);
            var ret       = await _WFContext.Database.ExecuteSqlCommandAsync("delete from owf.WFChart where chartName = @ChartName", ChartName);

            //var ret = await _WFContext.WFChart.FromSql("delete from owf.WFChart where chartName = @ChartName; select ChartName, ChartId, ChartDescription from owf.WFChart where chartName = @ChartName").FirstOrDefaultAsync<WFChart>();
            if (ret != 1)
            {
                throw new SQLWFException(string.Format("Failure to delete \"{0}\" chart - returned value {1} from Delete routine", chart.ChartName, ret));
            }
        }
Ejemplo n.º 3
0
        public async Task <WFChart> Save(WFChart Chart)
        {
            var id        = Chart.ChartId;
            var ChartName = new SqlParameter("ChartName", Chart.ChartName);

            string chartDesc = "";

            if (Chart.ChartDescription != null)
            {
                chartDesc = Chart.ChartDescription;
            }

            var    ChartDescription    = new SqlParameter("ChartDescription", chartDesc); // cannot pass null parameter as Text value to SQL
            string selectCommandScript = " declare @id int;" +
                                         " exec owf.ChartSet @ChartName, @ChartDescription, @id out;" +
                                         " select ChartId, ChartName, ChartDescription from owf.WFChart where ChartId=@id";

            SqlParameter[] arrParam = { ChartName, ChartDescription };

            /*
             * var connection = new SqlConnection(_WFContext.Database.GetDbConnection().ConnectionString);
             * var command = new SqlCommand(selectCommandScript, arrParam, connection);
             *
             * using (var reader = command.ExecuteReader())
             * {
             *  while (reader.Read())
             *  {
             *      Console.WriteLine($"{reader[0]}:{reader[1]} ${reader[2]}");
             *  }
             * }
             */

            var ret = await _WFContext.WFChart.FromSql(selectCommandScript, arrParam).FirstOrDefaultAsync <WFChart>();

            return(ret);
        }