示例#1
0
        public HttpResponseBase mailSetSave()
        {
            string result = "{success:false}";

            try
            {
                if (!string.IsNullOrEmpty(Request.Params["jsonSave"]))
                {
                    string json = Request.Params["jsonSave"];
                    System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
                    List<Parametersrc> paraList = js.Deserialize<List<Parametersrc>>(json);
                    IParametersrcImplMgr _paraMgr = new BLL.gigade.Mgr.ParameterMgr(connectionString);

                    if (paraList.Count() > 0)
                    {
                        if (paraList[0].Rowid != 0)         //更新
                        {
                            List<Parametersrc> updateList = new List<Parametersrc>();
                            paraList.ForEach(m =>
                            {
                                Parametersrc query = _paraMgr.QueryUsed(new Parametersrc { Rowid = m.Rowid }).FirstOrDefault();
                                query.ParameterCode = m.ParameterCode;
                                updateList.Add(query);
                            });
                            if (_paraMgr.Update(updateList))
                            {
                                result = "{success:true}";
                            }
                        }
                        else                                //保存
                        {
                            string c_kuser = (Session["caller"] as Caller).user_email;
                            paraList.ForEach(m => m.Kuser = c_kuser);
                            if (_paraMgr.Save(paraList))
                            {
                                result = "{success:true}";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }


            this.Response.Clear();
            this.Response.Write(result);
            this.Response.End();
            return this.Response;
        }