当前位置: 首页>>代码示例>>C#>>正文


C# DBContext.DoSave方法代码示例

本文整理汇总了C#中DBContext.DoSave方法的典型用法代码示例。如果您正苦于以下问题:C# DBContext.DoSave方法的具体用法?C# DBContext.DoSave怎么用?C# DBContext.DoSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBContext的用法示例。


在下文中一共展示了DBContext.DoSave方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveUser

 public string SaveUser(string json)
 {
     string permission = "membsership-saveuser";
     string entityName = "User";
     string entityJson = Request["entityJson"];
     JsonMessage jr = new JsonMessage();
     DBContext db = new DBContext(EntityFormat);
     try
     {
         if (entityJson == null) throw new Exception("entityJson is null");
         entityJson = Server.UrlDecode(entityJson);
         jr.Result = db.DoSave(permission, entityName, entityJson).GetPrimaryValue();
     }
     catch (Exception ex)
     {
         Utility.LogException(jr, ex);
     }
     finally
     {
         db.Dispose();
     }
     return JsonConvert.SerializeObject(jr);
 }
开发者ID:colys,项目名称:ColysSharp,代码行数:23,代码来源:MembershipController.cs

示例2: SyncJingKongPosData

        public JsonMessage SyncJingKongPosData(string terminal, string json)
        {
            if (DateTime.Now.Day != lastSyncTime.Day) {
                //每天同步一次,一次同步一个月
                SyncHolday();
            }
            lastSyncTime = DateTime.Now;
            while (inUploadRongbao) {
                System.Threading.Thread.Sleep(500);
            }
            if (clients.ContainsKey("xiandaijk")) clients["xiandaijk"].lastAccess = DateTime.Now;
            else {
            //iis reset register again
                RegisterClient("xiandaijk");
            }
            DBContext db = new DBContext(true);
            JsonMessage resultData = new JsonMessage();
            DateTime maxTime = DateTime.MinValue;
            List<TransactionLog> newItemList = new List<TransactionLog>();
            System.Web.HttpContext.Current.Application.Lock();
            try
            {
                LogStep("获取客户信息");
                Customer customerInfo = db.QuerySingle<Customer>(new { terminal = terminal, status = ">-1 " });
                //SourceAccount customerSource = db.QuerySingle<SourceAccount>(customerInfo.sourceAccount.Value);
                if (customerInfo == null) { throw new Exception("获取客户信息is null, terminal:" + terminal); }
                if (customerInfo.discount == null) { throw new Exception("获取客户信息discount is null or NaN,terminal:" + terminal); }
                if (customerInfo.tixianfei == null) { throw new Exception("获取客户信息tixianfei is null or NaN, terminal:" + terminal); }
                if (customerInfo.tixianfeiEles == null) { throw new Exception("获取客户信息tixianfeiEles is null or NaN, terminal:" + terminal); }
                stepName = "解析json : \r\n" + json;
                JingKongResult jkResult = JsonConvert.DeserializeObject<JingKongResult>(json);
                if (jkResult == null) throw new Exception("序列化出错:" + json);
                TransactionLog[] lst = jkResult.ToTransactionArray();
                foreach (TransactionLog localItem in lst)
                {
                    //判断记录是否存在,存在的话忽略,不存在则插入
                    var whereSql = new { terminal = terminal, timeStr = localItem.timeStr, tradeName = localItem.tradeName, tradeMoney = localItem.tradeMoney };
                    stepName = localItem.time + " " + localItem.tradeName + "是否已经保存过";
                    if (db.Exists("", "TransactionLog", whereSql)) continue;
                    LogStep("分析时间,23点后算次日");
                    string tempTime;
                    DateTime datetime = Convert.ToDateTime(localItem.time);
                    if (datetime > maxTime) maxTime = datetime;
                    //tomorrw is holdday
                    if (datetime.Hour > 22) datetime = datetime.AddDays(2);
                    else datetime = datetime.AddDays(1);
                    tempTime = datetime.ToString("yyyy-MM-dd");
                    if (tempTime != lastTransDay)
                    {
                        LogStep("获取是否节假日");
                        lastTransDay = tempTime;
                        GetLocalHolday(tempTime, db);
                        //MyHttpUtility http = new MyHttpUtility();
                        //int tryCount = 10;
                        //while (true)
                        //{
                        //    try
                        //    {
                        //        string timeJson = http.DoGet("http://www.easybots.cn/api/holiday.php?d=" + tempTime);
                        //        if (string.IsNullOrEmpty(timeJson)) throw new Exception("节假日返回值为空");
                        //        string[] tempArr = timeJson.Substring(1, timeJson.Length - 2).Split(':');
                        //        if (tempArr.Length != 2) throw new Exception("节假日返回值有变动");
                        //        isHoldDay = Convert.ToInt32(tempArr[1].Replace('\"', ' ').Trim()) > 0;
                        //        break;
                        //    }
                        //    catch (System.Net.WebException ex)
                        //    {
                        //        tryCount--;
                        //        if (tryCount < 0) { GetLocalHolday(tempTime, db); break; }
                        //        LogError("使用网络节假日发生网络异常,重试"+ tryCount, ex);
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        LogStep("easybots节假日返回异常(" + ex.Message + "),尝试读取本地设置");

                        //    }
                        //    break;
                        //}
                    }
                    LogStep("计算手续费");
                    calcMoney(customerInfo, localItem);
                    LogStep("保存交易记录");
                    localItem.status = 0;
                    db.DoSave("", localItem);
                    newItemList.Add(localItem);
                }
                LogStep("查询是否有结算交易");
                string sql = "select time,id from TransactionLogs where terminal='" + terminal + "' and tradeName in ('批上送结束(平账)','批上送结束(不平账)') and resultCode='00' and status =0";
                DataTable dt = db.QueryTable(sql);
                if (dt.Rows.Count > 0)
                {
                    LogStep("有" + dt.Rows.Count + "笔结算数据,开始结算");
                    foreach (DataRow dr in dt.Rows)
                    {
                        string time = dr["time"].ToString();
                        string sumLogId = dr["id"].ToString();
                        sql = "select max(time) prevTime from TransactionLogs where terminal='" + terminal + "' and Status=0 and tradeName in ('批上送结束(平账)','批上送结束(不平账)') and resultCode='00' and time < '" + time + "'";
                        object o = db.ExecScalar(sql);
                        string prevTime = o.ToString();

//.........这里部分代码省略.........
开发者ID:colys,项目名称:yiletong,代码行数:101,代码来源:HomeController.cs


注:本文中的DBContext.DoSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。