Exemplo n.º 1
0
 public bool Post(NoVerifySaveCountryPerson request)
 {
     return(CountryPerson.SaveCountryPerson(request));
 }
 public bool SaveCountryPerson(NoVerifySaveCountryPerson requset)
 {
     using (var db = DbFactory.Open())
     {
         if (string.IsNullOrEmpty(adcd))
         {
             throw new Exception("请重新登录");
         }
         if (!ValidatorHelper.IsMobile(requset.Mobile))
         {
             throw new Exception("手机号码输入错误,请重新输入");
         }
         var info = new CountryPerson();
         var log  = new operateLog();
         log.userName    = RealName;
         log.operateTime = DateTime.Now;
         if (requset.Id != 0)
         {
             info.Id = requset.Id;
             //log.operateMsg = "更新" + requset.name + "的镇级责任人信息";
         }
         //else
         //{
         //    var model = GetCountryPersonInfo(requset.name);
         //    if (model != null)
         //        throw new Exception("已存在");
         //    //log.operateMsg = "新增" + requset.name + "的镇级责任人信息";
         //}
         info.UserName   = requset.name;
         info.CreateTime = DateTime.Now;
         info.Phone      = requset.Mobile;
         info.Position   = requset.Position;
         info.Post       = requset.Post;
         info.Year       = DateTime.Now.Year;
         info.Remark     = requset.Remark;
         info.Country    = RealName;
         info.UpdateName = requset.name;
         info.UpdateTime = DateTime.Now;
         info.CreateName = requset.name;
         info.adcd       = adcd;
         var oldInfo = db.Single <CountryPerson>(x => x.Id == requset.Id);
         if (requset.Id != 0)
         {
             info.AuditNums = oldInfo.AuditNums + 1;
             info.OldData   = JsonTools.ObjectToJson(oldInfo);
             info.NewData   = JsonTools.ObjectToJson(info);
             #region 日志
             try
             {
                 var           adcdInfo = db.Single <ADCDInfo>(w => w.adcd == oldInfo.adcd);
                 StringBuilder sb       = new StringBuilder();
                 sb.Append("在栏目{组织责任/县级防汛防台责任人}下,更新数据{");
                 sb.Append("县级adcd:" + adcdInfo.adnm + "");
                 sb.Append("姓名:" + oldInfo.UserName + "");
                 sb.Append("创建的时间:" + oldInfo.CreateTime + "");
                 sb.Append("电话:" + oldInfo.Phone + "");
                 sb.Append("岗位:" + oldInfo.Position + "");
                 sb.Append("职务:" + oldInfo.Post + "");
                 sb.Append("年份:" + oldInfo.Year + "");
                 sb.Append("标记:" + oldInfo.Remark + "");
                 sb.Append("县的名字:" + oldInfo.Country + "");
                 sb.Append("更改人的名字:" + oldInfo.UpdateName + "");
                 sb.Append("更改的时间:" + oldInfo.UpdateTime + "");
                 sb.Append("创建的人:" + oldInfo.CreateName + "");
                 sb.Append("}为{");
                 sb.Append("县级adcd:" + adcdInfo.adnm + "");
                 sb.Append("姓名:" + info.UserName + "");
                 sb.Append("创建的时间:" + info.CreateTime + "");
                 sb.Append("电话:" + info.Phone + "");
                 sb.Append("岗位:" + info.Position + "");
                 sb.Append("职务:" + info.Post + "");
                 sb.Append("年份:" + info.Year + "");
                 sb.Append("标记:" + info.Remark + "");
                 sb.Append("县的名字:" + info.Country + "");
                 sb.Append("更改人的名字:" + info.UpdateName + "");
                 sb.Append("更改的时间:" + info.UpdateTime + "");
                 sb.Append("创建的人:" + info.CreateName + "");
                 sb.Append("}");
                 logHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新);
             }
             catch (Exception ex) { }
             #endregion
             //"select * from CountryPerson where Phone='" + info.Phone + "' and Position='" + info.Position + "' and UserName='******' and "
             var r = db.Single <CountryPerson>(w => w.Phone == requset.Mobile && w.Position == info.Position && w.UserName == info.UserName && w.Remark == info.Remark && w.Post == info.Post);
             if (r != null)
             {
                 return(false);
             }
             else
             {
                 return(db.Update(info) == 1);
             }
         }
         else
         {
             int count;
             var list = db.Select <AuditCounty>("select * from dbo.AuditCounty where CountyADCD='" + adcd + "' ");
             if (list.Count == 0)
             {
                 count = 1;
             }
             else
             {
                 count = Convert.ToInt32(list[0].AuditNums) + 1;
             }
             info.AuditNums = count;
             info.OldData   = "";
             info.NewData   = "";
             #region 日志
             try
             {
                 StringBuilder sb       = new StringBuilder();
                 var           adcdInfo = db.Single <ADCDInfo>(w => w.adcd == info.adcd);
                 sb.Append("在栏目{组织责任/县级防汛防台责任人}下,新增数据{");
                 sb.Append("县级adcd:" + adcdInfo.adnm + "");
                 sb.Append("姓名:" + info.UserName + "");
                 sb.Append("创建的时间:" + info.CreateTime + "");
                 sb.Append("电话:" + info.Phone + "");
                 sb.Append("岗位:" + info.Position + "");
                 sb.Append("职务:" + info.Post + "");
                 sb.Append("年份:" + info.Year + "");
                 sb.Append("标记:" + info.Remark + "");
                 sb.Append("县的名字:" + info.Country + "");
                 sb.Append("更改人的名字:" + info.UpdateName + "");
                 sb.Append("更改的时间:" + info.UpdateTime + "");
                 sb.Append("创建的人:" + info.CreateName + "");
                 sb.Append("}");
                 logHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增);
             }
             catch (Exception ex)
             {
             }
             #endregion
             if (db.Select <CountryPerson>("select * from CountryPerson where Phone='" + info.Phone + "' and Position='" + info.Position + "' and UserName='******'").ToList().Count == 1)
             {
                 return(false);
             }
             else
             {
                 return(db.Insert(info) == 1);
             }
         }
     }
 }