public virtual void DoDelete <T>(T obj) where T : class { try { using (TransactionScope scope = new TransactionScope()) { string lgtx = new stactlogBll().WriteLog("Delete", obj, null); if (lstRecCfg.Where(p => p.tbnm == typeof(T).Name).ToList().Count > 0) { //需要管理记录状态 tstalarm alarmMdl = null; new strecstsBll().UpdateRecStatusToObject(obj, "Delete", lgtx, out alarmMdl); baseDal.DoInsert <tstalarm>(alarmMdl); } baseDal.DoDelete <T>(obj); scope.Complete(); } } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } finally { } }
public void getRecordLogHistory() { try { string record = this.Request["record"]; Hashtable ht = JavaScriptConvert.DeserializeObject <Hashtable>(record); //List<ColumnInfo> list = JavaScriptConvert.DeserializeObject<List<ColumnInfo>>(ht["params"].ToString()); int start = Convert.ToInt32(this.Request["start"]); int limit = Convert.ToInt32(this.Request["limit"]); List <ColumnInfo> lstParameter = new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "rfid", ColumnValue = ht["rfid"].ToString() } }; stactlogBll bll = new stactlogBll(); int total = 0; List <tstactlog> dataList = bll.GetSelectedRecords <tstactlog>(lstParameter, true, start, start + limit, ref total); string json = JavaScriptConvert.SerializeObject(dataList); Response.Write("{results:" + total + ",rows:" + json + "}"); } catch (Exception ex) { string message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_QueryFail, ex, true) + "'}"; Response.Output.Write(message); } }
public virtual void DoInsert(string _type, object obj) { try { using (TransactionScope scope = new TransactionScope()) { PropertyInfo prop = obj.GetType().GetProperty("rfid"); if (prop != null) { prop.SetValue(obj, Function.GetGUID(), null); } string lgtx = new stactlogBll().WriteLog("Add", obj, null); if (lstRecCfg.Where(p => p.tbnm == obj.GetType().Name).ToList().Count > 0) { //需要管理记录状态 tstalarm alarmMdl = null; new strecstsBll().AddRecStatusToObject(obj, "Add", lgtx, out alarmMdl); baseDal.DoInsert <tstalarm>(alarmMdl); } ReplaceEmptyWithNull(obj); baseDal.DoInsert(_type, obj); scope.Complete(); } } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } finally { } }
public virtual void DoUpdate <T>(T obj, List <ColumnInfo> _parameter) where T : class { try { bool updateRecStatus = false; using (TransactionScope scope = new TransactionScope()) { if (lstRecCfg.Where(p => p.tbnm == typeof(T).Name).ToList().Count > 0) { //需要管理记录状态 updateRecStatus = true; } T oldObj = GetSelectedObject <T>(_parameter); string lgtx = new stactlogBll().WriteLog("Update", obj, oldObj); foreach (PropertyInfo prop in typeof(T).GetProperties()) { if ((prop.PropertyType.IsValueType) || (prop.PropertyType.FullName == "System.String")) { object oldValue = typeof(T).GetProperty(prop.Name).GetValue(oldObj, null); object newValue = typeof(T).GetProperty(prop.Name).GetValue(obj, null); if (oldValue == null) { prop.SetValue(oldObj, newValue, null); } else { if (!oldValue.Equals(newValue) && newValue != null) { prop.SetValue(oldObj, newValue, null); } } } } ReplaceEmptyWithNull(oldObj); if (updateRecStatus) { PropertyInfo prop = oldObj.GetType().GetProperty("tstrecst"); if (prop != null) { tstalarm alarmMdl = null; new strecstsBll().UpdateRecStatusToObject(oldObj, "Update", lgtx, out alarmMdl); baseDal.DoInsert <tstalarm>(alarmMdl); } } baseDal.DoUpdate <T>(obj); scope.Complete(); } } catch (UtilException ex) { throw new UtilException(ex.Message, ex.Code, ex); } catch (Exception ex) { throw new UtilException(ex.Message, ex); } finally { } }