Exemplo n.º 1
0
        public void ConfirmRecord(string rfid)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    List <ColumnInfo> parameters = new List <ColumnInfo>()
                    {
                        new ColumnInfo()
                        {
                            ColumnName = "rfid", ColumnValue = rfid
                        }
                    };
                    tstrecst obj = GetSelectedObject <tstrecst>(parameters);

                    if (obj != null)
                    {
                        obj.cftm = DateTime.Now;
                        obj.cfur = Function.GetCurrentUser();
                        obj.stus = "Confirmed";

                        DoUpdate <tstrecst>(obj);
                    }
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public virtual void DoDelete(string _type, List <ColumnInfo> _parameter)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    List <object> lstObj = GetSelectedRecords(_type, _parameter);
                    if (lstObj.Count > 0)
                    {
                        object       obj  = lstObj.Single <object>();
                        PropertyInfo prop = obj.GetType().GetProperty("tstrecst");

                        if (prop != null)
                        {
                            tstrecst recst = prop.GetValue(obj, null) as tstrecst;
                            if (recst.ownr != Function.GetCurrentUser())
                            {
                                throw new UtilException("You have no permission to delete it.", null);
                            }

                            DoDelete <tstrecst>(recst);
                        }

                        //DoDelete(_type, obj);
                        baseDal.DoDelete(obj);
                    }

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
            finally
            {
            }
        }
Exemplo n.º 4
0
        public virtual void DoMultiDelete <T>(List <ColumnInfo> _parameter) where T : class
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    //baseDal.DoMultiDelete<T>(_parameter);
                    List <T> lstObj = GetSelectedRecords <T>(_parameter, true);
                    for (int i = 0; i < lstObj.Count; i++)
                    {
                        T            obj  = lstObj[i];
                        PropertyInfo prop = obj.GetType().GetProperty("tstrecst");

                        if (prop != null)
                        {
                            tstrecst recst = prop.GetValue(obj, null) as tstrecst;
                            if (recst.ownr != Function.GetCurrentUser())
                            {
                                throw new UtilException("You have no permission to delete it.", null);
                            }

                            //DoDelete<tstrecst>(recst);
                        }

                        DoDelete <T>(obj);
                    }

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
            finally
            {
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public virtual void DoUpdate(string _type, object obj, List <ColumnInfo> _parameter)
        {
            try
            {
                bool updateRecStatus = false;

                using (TransactionScope scope = new TransactionScope())
                {
                    if (lstRecCfg.Where(p => p.tbnm == obj.GetType().Name).ToList().Count > 0)
                    {
                        //需要管理记录状态
                        updateRecStatus = true;
                    }

                    object oldObj = GetSelectedObject(_type, _parameter);

                    new stactlogBll().WriteLog("Update", obj, oldObj);

                    foreach (PropertyInfo prop in obj.GetType().GetProperties())
                    {
                        if ((prop.PropertyType.IsValueType) || (prop.PropertyType.FullName == "System.String"))
                        {
                            object oldValue = obj.GetType().GetProperty(prop.Name).GetValue(oldObj, null);
                            object newValue = obj.GetType().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)
                        {
                            tstrecst rec = prop.GetValue(oldObj, null) as tstrecst;
                            rec.actn = "Update";
                            rec.attm = DateTime.Now;
                            rec.atur = Function.GetCurrentUser();
                            rec.stus = "Unconfirmed";
                        }
                    }

                    DoUpdate <object>(obj);
                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
            finally
            {
            }
        }