public void ChangeScanningToWait() { using (var db = new APKDWContext()) { db.Database.ExecuteSqlCommand("dbo.[NotScanningToWait]"); } }
/// <summary> /// 获取未更新列表 /// </summary> /// <param name="topNum"></param> /// <returns></returns> public List<string> GetNotNoticeList(int topNum) { using (var db = new APKDWContext()) { var list = new List<string>(); var myQuery = (from x in db.T_ProductApk where x.ScanFlag == 3 select x).Take<T_ProductApk>(topNum); list = myQuery.Select(x => x.ID.ToString()).ToList(); return list; } }
/// <summary> /// 批量更新未提醒列表 /// </summary> /// <param name="idList"></param> public void BatchNotNoticeScaning(List<string> idList) { using (var db=new APKDWContext()) { string list = string.Format("{0}", string.Join(",", idList.ToArray())); var para = new SqlParameter[] { new SqlParameter { ParameterName = "@ID", SqlDbType = SqlDbType.VarChar, Value = list.ToString() } }; db.Database.ExecuteSqlCommand("dbo.[NotNoticeBatchUpdateScanning] @ID", para); } }
/// <summary> /// 提交未更新 /// </summary> /// <param name="strId"></param> public void PostNotNotice(string strId) { var entity = new T_ProductApk(); try { using (var scope = TransactionUtilities.CreateTransactionScopeWithNoLock()) { var db = new APKDWContext(); var id = int.Parse(strId); entity = db.T_ProductApk.Find(id); entity.ScanFlag = 1; var sd=ALiYunOssHelp.Update("sd", @"C:\Users\donson\Desktop\QQ图片20160128113942.png"); entity.RemoteFilePath = sd; db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); scope.Complete(); } } catch (InvalidOperationException e) { lock (_myLock) { //LoggerHelper.Log("【发起提醒】失败,失败原因:" + (e.InnerException == null ? e.Message : e.InnerException.ToString())); } } catch (Exception ex) { lock (_myLock) { //LoggerHelper.Log("【未提醒】失败,失败原因:" + (ex.InnerException == null ? ex.Message : ex.InnerException.ToString())); //避免数据库异常下,无法记录错误日志 var db = new APKDWContext(); entity.ScanFlag = 1; db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } } }