Exemplo n.º 1
0
        public string DeleteData(string userid, string id)
        {
            IDbTransaction tran = Utility.Database.BeginDbTransaction();//开始事务并返回一个事务对象
            SkyLandDeveloper developer = new SkyLandDeveloper("{}", userid, tran);//获取业务流相关参数
            try
            {

                Para_UsedPhrase usedPhrase = new Para_UsedPhrase();
                usedPhrase.Condition.Add("id = " + id);//设置查询条件,条件为当前用户ID
                Utility.Database.Delete(usedPhrase, tran);
                developer.Commit();//提交事务
                //return JsonConvert.SerializeObject( retContent);
                return Utility.JsonMsg(true, "删除成功!");
            }
            catch (Exception ex)
            {
                developer.RollBack();//回滚事务
                ComBase.Logger(ex);//写日专到本地文件
                return Utility.JsonMsg(false, "删除失败:" + ex.Message);
                //return Utility.JsonMsg(false, "删除失败:" + ex.Message);
            }
        }
Exemplo n.º 2
0
 public object GetUsedPhrase(string userid, string lx)
 {
     DataSet dataSet = null;
     IDbTransaction tran = Utility.Database.BeginDbTransaction();//开始事务并返回一个事务对象
     SkyLandDeveloper developer = new SkyLandDeveloper("{}", userid, tran);//获取业务流相关参数
     try
     {
         GetUsedPhraseDataModel data = new GetUsedPhraseDataModel();
         List<Para_UsedPhrase> usedPhraseList = new List<Para_UsedPhrase>();
         //Para_UsedPhrase list = new Para_UsedPhrase();
         //list.Condition.Add("cjrid = " + userid);//设置查询条件,条件为当前用户ID
         //list.Condition.Add("lx = " + lx);//设置查询条件,条件为常用语类型
         //data.usedPhraseList = Utility.Database.QueryList(list);
         dataSet = Utility.Database.ExcuteDataSet("select * from Para_UsedPhrase where cjrid='" + userid + "' and lx='" + lx + "' order by sypl desc", tran);
         if (dataSet != null && dataSet.Tables.Count > 0 && dataSet.Tables[0] != null)
         {
             string jsonData = JsonConvert.SerializeObject(dataSet.Tables[0]);
             usedPhraseList = (List<Para_UsedPhrase>)JsonConvert.DeserializeObject(jsonData, typeof(List<Para_UsedPhrase>));
         }
         else
         {
             usedPhraseList = new List<Para_UsedPhrase>();
         }
         Para_UsedPhrase userPhrase = new Para_UsedPhrase();
         userPhrase.lx = lx;
         userPhrase.cjrid = userid;
         userPhrase.cjsj = DateTime.Now;
         Utility.Database.Commit(tran);
         return new
         {
             usedPhraseList = usedPhraseList,
             userPhrase = userPhrase
         };
     }
     catch (Exception ex)
     {
         Utility.Database.Commit(tran);
         ComBase.Logger(ex);//写日专到本地文件
         return Utility.JsonMsg(false, ex.Message);
     }
     finally
     {
         if (dataSet != null) dataSet.Dispose();
         tran.Dispose();
     }
 }
Exemplo n.º 3
0
        public string SaveData(string userid, string nr, string lx)
        {
            if (nr == null || nr.ToString() == "") return Utility.JsonResult(true, "数据不能空");
            //UTF8Encoding utf = new UTF8Encoding();
            //lx = utf.GetString(Encoding.Unicode.GetBytes(lx)).Trim();
            //byte[] utf8Bytes = Encoding.UTF8.GetBytes(lx);
            //lx = Encoding.GetEncoding("UTF-8").GetString(utf8Bytes);

            nr = nr.Trim();
            IDbTransaction tran = Utility.Database.BeginDbTransaction();//开始事务并返回一个事务对象
            SkyLandDeveloper developer = new SkyLandDeveloper("{}", userid, tran);//获取业务流相关参数
            try
            {
                Para_UsedPhrase usedPhrase = new Para_UsedPhrase();
                usedPhrase.nr = nr;
                usedPhrase.cjrid = userid;
                usedPhrase.lx = lx;
                usedPhrase.Condition.Add("cjrid=" + userid);
                usedPhrase.Condition.Add("lx=" + lx);
                usedPhrase.Condition.Add("nr=" + nr);
                List<Para_UsedPhrase> list = Utility.Database.QueryList(usedPhrase);
                DataSet ds = Utility.Database.ExcuteDataSet("select isnull(MAX(sypl),0) as sypl from Para_UsedPhrase where cjrid='" + userid + "' and lx='" + lx + "'");
                usedPhrase.sypl = (int)ds.Tables[0].Rows[0]["sypl"] + 1;
                if (list == null || list.Count < 1)
                {
                    usedPhrase.cjsj = DateTime.Now;
                    Utility.Database.Insert(usedPhrase, tran);
                }
                else
                {
                    Utility.Database.Update(usedPhrase, tran);
                }

                developer.Commit();//提交事务
                //return Utility.JsonResult(true, "保存成功!", retContent);
                return Utility.JsonResult(true, "保存成功!");
            }
            catch (Exception ex)
            {
                developer.RollBack();//回滚事务
                ComBase.Logger(ex);//写日专到本地文件
                return Utility.JsonResult(false, "保存失败:" + ex.Message);
                //return Utility.JsonResult(false, "删除失败:" + ex.Message);
            }
        }