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 tstalarm BuildAlarmMdl(Alarm_AlarmType _alty, string _subj, string _bdtx, string _reci, string _cc, string _mtyp, DateTime _extm, string _remk) { tstalarm obj = new tstalarm(); obj.alty = _alty.ToString(); obj.alid = Function.GetGUID(); obj.alst = Alarm_AlarmStatus.Unhandled.ToString(); obj.apnm = Parameter.APPLICATION_NAME; obj.bdtx = _bdtx; obj.cc = _cc == null?string.Empty:_cc; obj.crtm = DateTime.Now; obj.crur = Function.GetCurrentUser(); obj.reci = _reci == null?"Unknown":_reci; obj.remk = _remk; obj.subj = _subj; obj.mtyp = _mtyp; obj.extm = _extm; return(obj); }
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 void CreateAlarmForBoard(tstalarm obj) { try { string sText = @"<Alarms> <Alarm> <AlarmType>" + obj.alty + @"</AlarmType> <Subject>" + obj.subj + @"</Subject> <Recipients>" + obj.reci + @"</Recipients> <CC>" + obj.cc + @"</CC> <BodyText>" + obj.bdtx + @"</BodyText> <Comments>" + obj.remk + @"</Comments> <Application>" + obj.apnm + @"</Application> <Creator>" + obj.crur + @"</Creator> <CreatedTime>" + obj.crtm.Value.ToString("yyyy-MM-dd HH:mm:ss") + @"</CreatedTime> </Alarm> </Alarms>"; client.SendAlarm(sText); } catch (Exception ex) { throw new UtilException(ex.Message, ex); } }
public void AddRecStatusToObject(object _obj, string _action, string _lgtx, out tstalarm alarmMdl) { tstrecst recst = new tstrecst(); recst.actn = _action; recst.attm = DateTime.Now; recst.atur = Function.GetCurrentUser(); recst.ownr = Function.GetCurrentUser(); recst.rfid = _obj.GetType().GetProperty("rfid").GetValue(_obj, null).ToString(); recst.sttm = DateTime.Now; recst.stus = "Unconfirmed"; recst.cftm = null; recst.cfur = null; //_obj.GetType().GetProperty("rfid").SetValue(_obj, recst.rfid, null); _obj.GetType().GetProperty("tstrecst").SetValue(_obj, recst, null); string emno = _obj.GetType().GetProperty("emno").GetValue(_obj, null).ToString(); alarmMdl = new alarmBll().BuildAlarmMdl(Alarm_AlarmType.Board, "[" + _action + "]" + _obj.GetType().Name, _lgtx, new stalsubsBll().GetRecipicientsBoard(emno), string.Empty, "Adding", DateTime.Now.AddDays(1), string.Empty); }
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 { } }
public void Publish(List <vw_employment> lstEmp, string trcd, string isEmail, string isBoard) { try { List <ColumnInfo> lstParameters = new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "trcd", ColumnValue = trcd } }; ttrtraing tra = new BaseBll().GetSelectedObject <ttrtraing>(lstParameters); if (tra == null) { return; } using (TransactionScope scope = new TransactionScope()) { for (int i = 0; i < lstEmp.Count; i++) { vw_employment emp = lstEmp[i]; ttrtraatt att = new ttrtraatt(); att.emno = emp.emno; att.isat = "N"; att.isrg = "N"; att.lmtm = DateTime.Now; att.lmur = Function.GetCurrentUser(); att.trcd = trcd; DoInsert <ttrtraatt>(att); alarmBll alaBll = new alarmBll(); if (isEmail == "Y") { //发Email tstalarm alarmMdl = alaBll.BuildAlarmMdl(Alarm_AlarmType.Email, "Training: " + tra.trnm, alaBll.BuildTrainingAlarmBody(tra, att.emno), emp.emno, string.Empty, "Training", DateTime.Now.AddDays(1), string.Empty); DoInsert <tstalarm>(alarmMdl); } if (isBoard == "Y") { //发送Board tstalarm alarmMdl = alaBll.BuildAlarmMdl(Alarm_AlarmType.Board, "Training: " + tra.trnm, alaBll.BuildTrainingAlarmBody(tra, att.emno), emp.emno, string.Empty, "Training", DateTime.Now.AddDays(1), string.Empty); DoInsert <tstalarm>(alarmMdl); } //update ispb标识 tra.ispb = "Y"; DoUpdate <ttrtraing>(tra, lstParameters); } scope.Complete(); } } catch (Exception ex) { throw ex; } }
public void UpdateRecStatusToObject(object _obj, string _action, string _lgtx, out tstalarm alarmMdl) { PropertyInfo prop = _obj.GetType().GetProperty("tstrecst"); tstrecst rec = prop.GetValue(_obj, null) as tstrecst; rec.actn = "Update"; rec.attm = DateTime.Now; rec.atur = Function.GetCurrentUser(); rec.stus = "Unconfirmed"; string emno = _obj.GetType().GetProperty("emno").GetValue(_obj, null).ToString(); alarmMdl = new alarmBll().BuildAlarmMdl(Alarm_AlarmType.Board, "[" + _action + "] " + _obj.GetType().Name, _lgtx, new stalsubsBll().GetRecipicientsBoard(emno), string.Empty, "Updating", DateTime.Now.AddDays(1), string.Empty); }