Пример #1
0
        public ActionResult DataModelView(Dictionary <string, string> queryvalues)
        {
            int           id      = queryvalues.ContainsKey("id") ? Convert.ToInt32(queryvalues["id"]) : 0;
            int           isFirst = queryvalues.ContainsKey("isFirst") ? Convert.ToInt32(queryvalues["isFirst"]) : 0;
            ModelBaseData model   = new ModelBaseData();
            //根据ID获取模版数据
            PagedList <ModelBaseData> t = ScaleRecordBLL.GetModelByID(id);

            if (t.Count > 0)
            {
                ViewData["id"]  = id;
                model.ID        = id;
                model.ModelName = t[0].ModelName;
                //根据参数生成查询控件
                model.Para = t[0].Para;
                //不是首次查询
                if (isFirst == 0)
                {
                    string[] parameter = new string[queryvalues.Count];
                    foreach (string key in queryvalues.Keys)
                    {
                        //使用选择的值(value)替换脚本中的变量({para})
                        t[0].Model    = t[0].Model.Replace("{" + key + "}", queryvalues[key]);
                        ViewData[key] = queryvalues[key];
                    }
                    model.Model = t[0].Model;
                    try
                    {
                        model.DataList = new List <object>(ScaleRecordBLL.GetModelData(model.Model, model.ID));
                    }
                    catch (Exception ex) {
                        model.isError = ex.Message;
                    }
                }
            }
            else
            {
                ViewData["id"] = 0;
                model.ID       = 0;
                model.Para     = "";
                model.DataList = "";
            }
            return(View(model));
        }
Пример #2
0
 internal static int AddModel(ModelBaseData model)
 {
     using (var cn = new MySqlConnection(sqlconnectionString))
     {
         if (model.ID == 0)
         {
             cn.Open();
             int i = cn.Execute(@"insert into " + database3 + @".S_DataModel(ModelName ,Para ,Model ,Createtime ) select @ModelName ,@Para ,@Model ,now();", model);
             cn.Close();
             return(i);
         }
         else
         {
             cn.Open();
             int i = cn.Execute(@"update " + database3 + @".S_DataModel set ModelName = @ModelName ,Para = @Para ,Model = @Model ,Createtime = now() where id = @ID ;", model);
             cn.Close();
             return(i);
         }
     }
 }
Пример #3
0
 public static int AddModel(ModelBaseData model)
 {
     return(DAL.Console.AddModel(model));
 }
Пример #4
0
        public ActionResult DataModelEdit(Dictionary <string, string> queryvalues)
        {
            int           id    = queryvalues.ContainsKey("id") ? Convert.ToInt32(queryvalues["id"]) : 0;
            ModelBaseData model = new ModelBaseData();

            if (Request.IsAjaxRequest())
            {
                //1:begindate:开始时间_1:enddate:结束时间_2:agent:代理ID
                model.Para = "";
                foreach (string key in queryvalues.Keys)
                {
                    switch (key)
                    {
                    case "ID":
                        model.ID = Convert.ToInt32(queryvalues[key]);
                        continue;

                    case "ModelName":
                        model.ModelName = queryvalues[key];
                        continue;

                    case "Model":
                        model.Model = queryvalues[key];
                        continue;

                    default:
                        string[] sArray = queryvalues[key].ToString().Split(',');
                        if (sArray.Length != 2)
                        {
                            return(Json(new { result = Result.ParaFormError }));
                        }
                        else
                        {
                            model.Para += "_" + sArray[1] + ":" + key + ":" + ((sArray[0] == "")? key: sArray[0]);
                            continue;
                        }
                    }
                }
                int result = ScaleRecordBLL.AddModel(model);
                if (result == 1)
                {
                    return(Json(new { result = Result.Normal }));
                }
                else if (result == 0)
                {
                    return(Json(new { result = Result.ResultError }));
                }
                else
                {
                    return(Json(new { result = Result.ResultExcept }));
                }
            }
            //根据ID获取模版数据
            PagedList <ModelBaseData> t = ScaleRecordBLL.GetModelByID(id);

            if (t.Count > 0)
            {
                model = t[0];
            }
            return(View(model));
        }