Ejemplo n.º 1
0
        /// <summary>
        /// فیلدهایی که باید مقدار بگیرند را مقدار دهی میکند
        /// </summary>
        /// <param name="proxy"></param>
        /// <param name="personId">کد پرسنلی</param>
        /// <param name="archiveValues">لیست مقادیر مفاعیم نتایج محاسبات شده</param>
        /// <param name="fildsMapList">فیلد های نتایج محاسبات محسبات</param>
        /// <returns></returns>
        private ArchiveCalcValuesProxy SetMapValue(ArchiveCalcValuesProxy proxy, decimal personId, IList <ArchiveConceptValue> archiveValues, IList <ArchiveFieldMap> fildsMapList)
        {
            try
            {
                ArchiveFieldMap map     = null;
                MemberInfo[]    members = proxy.GetType().GetMembers();

                foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person")))
                {
                    PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name);
                    map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault();
                    prop.SetValue(proxy, Empty, null);

                    if (map != null)
                    {
                        ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault();

                        if (cnpValue != null)
                        {
                            string value = Utility.ToString(cnpValue.ChangedValue);
                            switch (cnpValue.Concept.DataType)
                            {
                            case ConceptDataType.Int:
                                value = Utility.ToInteger(value).ToString();
                                break;

                            case ConceptDataType.Hour:
                                value = Utility.IntTimeToTime(Utility.ToInteger(value));
                                break;
                            }
                            prop.SetValue(proxy, value, null);
                        }
                    }
                }
                proxy.ID = Guid.NewGuid().ToString();
                return(proxy);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex);

                throw ex;
            }
        }
Ejemplo n.º 2
0
        public ArchiveCalcValuesProxy SetArchiveValues(int year, int month, decimal personId, ArchiveCalcValuesProxy proxy)
        {
            IList <ArchiveCalcValuesProxy> resultList = new List <ArchiveCalcValuesProxy>();
            int rangeOrder = month;

            try
            {
                UIValidate(personId);
                proxy = ValidateKaheshiKosuratBankSepah(proxy, year, month, personId);
            }
            catch (Exception)
            {
            }



            IList <ArchiveConceptValue> archiveValues = archiveRep.LoadArchiveValueList(new List <decimal>()
            {
                personId
            }, year, rangeOrder);

            IList <ArchiveFieldMap> fildsMapList = mapRep.GetAll();

            if (archiveValues.Any(x => x.PersonId == personId))
            {
                ArchiveFieldMap map     = null;
                MemberInfo[]    members = proxy.GetType().GetMembers();

                #region Data Type Validatin
                UIValidationExceptions exceptions = new UIValidationExceptions();
                foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person")))
                {
                    PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name);

                    map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault();
                    if (map != null && map.Visible)
                    {
                        ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault();

                        if (cnpValue != null)
                        {
                            bool   isValid = false;
                            string pValue  = Utility.ToString(prop.GetValue(proxy, null)).Trim();
                            if (Utility.IsEmpty(pValue))
                            {
                                pValue = "0";
                            }
                            int    value   = 0;
                            string cnpName = "";
                            if (BLanguage.CurrentLocalLanguage == LanguagesName.Parsi)
                            {
                                cnpName = map.FnTitle;
                            }
                            else
                            {
                                cnpName = map.EnTitle;
                            }
                            switch (cnpValue.Concept.DataType)
                            {
                            case ConceptDataType.Int:
                                if (!Utility.IsIntiger(pValue))
                                {
                                    ValidationException exception = new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc);
                                    exception.Data.Add("Info", cnpName);
                                    exceptions.Add(exception);
                                }
                                break;

                            case ConceptDataType.Hour:
                                if (!Utility.IsTime(pValue) && !Utility.IsIntiger(pValue))
                                {
                                    ValidationException exception = new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc);
                                    exception.Data.Add("Info", cnpName);
                                    exceptions.Add(exception);
                                }
                                break;
                            }
                            if (isValid)
                            {
                                cnpValue.ChangedValue = value;
                                archiveRep.SaveOrUpdate(cnpValue);
                            }
                        }
                    }
                }
                if (exceptions.Count > 0)
                {
                    throw exceptions;
                }
                #endregion

                #region Set Value
                foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person")))
                {
                    PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name);

                    map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault();
                    if (map != null && map.Visible)
                    {
                        ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault();

                        if (cnpValue != null)
                        {
                            bool   isValid = false;
                            string pValue  = Utility.ToString(prop.GetValue(proxy, null)).Trim();
                            if (Utility.IsEmpty(pValue))
                            {
                                pValue = "0";
                            }
                            int value = 0;
                            switch (cnpValue.Concept.DataType)
                            {
                            case ConceptDataType.Int:
                                if (Utility.IsIntiger(pValue))
                                {
                                    value   = Utility.ToInteger(pValue);
                                    isValid = true;
                                }
                                break;

                            case ConceptDataType.Hour:
                                if (Utility.IsIntiger(pValue))
                                {
                                    pValue = pValue += ":00";
                                }
                                if (Utility.IsTime(pValue))
                                {
                                    value   = Utility.RealTimeToIntTime(pValue);
                                    isValid = true;
                                }
                                break;
                            }
                            if (isValid)
                            {
                                cnpValue.ModifiedDate     = DateTime.Now;
                                cnpValue.ModifiedPersonId = BUser.CurrentUser.Person.ID;
                                cnpValue.ChangedValue     = value;
                                archiveRep.SaveOrUpdate(cnpValue);
                                BArchiveCalculator.LogUserAction(cnpValue, string.Format("Change Archive for person {0} , Date: {2}/{1}", cnpValue.PersonId.ToString(), month, year));
                            }
                        }
                    }
                }
                #endregion
            }

            return(proxy);
        }
Ejemplo n.º 3
0
        public void SetArchiveValues(int year, int month, decimal personId, ArchiveCalcValuesProxy proxy)
        {
            IList <ArchiveCalcValuesProxy> resultList = new List <ArchiveCalcValuesProxy>();
            int rangeOrder = month;

            IList <ArchiveConceptValue> archiveValues = archiveRep.LoadArchiveValueList(new List <decimal>()
            {
                personId
            }, year, rangeOrder);

            IList <ArchiveFieldMap> fildsMapList = mapRep.GetAll();

            if (archiveValues.Any(x => x.PersonId == personId))
            {
                ArchiveFieldMap map     = null;
                MemberInfo[]    members = proxy.GetType().GetMembers();

                #region Data Type Validatin
                UIValidationExceptions exceptions = new UIValidationExceptions();
                foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person")))
                {
                    PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name);

                    map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault();
                    if (map != null)
                    {
                        ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault();

                        if (cnpValue != null)
                        {
                            bool   isValid = false;
                            string pValue  = Utility.ToString(prop.GetValue(proxy, null));
                            int    value   = 0;
                            string cnpName = "";
                            if (BLanguage.CurrentLocalLanguage == LanguagesName.Parsi)
                            {
                                cnpName = map.FnTitle;
                            }
                            else
                            {
                                cnpName = map.EnTitle;
                            }
                            switch (cnpValue.Concept.DataType)
                            {
                            case ConceptDataType.Int:
                                if (!Utility.IsNumber(pValue))
                                {
                                    exceptions.Add(new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc));
                                }
                                break;

                            case ConceptDataType.Hour:
                                if (!Utility.IsTime(pValue))
                                {
                                    exceptions.Add(new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc));
                                }
                                break;
                            }
                            if (isValid)
                            {
                                cnpValue.ChangedValue = value;
                                archiveRep.SaveOrUpdate(cnpValue);
                            }
                        }
                    }
                }
                if (exceptions.Count > 0)
                {
                    throw exceptions;
                }
                #endregion

                #region Set Value
                foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person")))
                {
                    PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name);

                    map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault();
                    if (map != null)
                    {
                        ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault();

                        if (cnpValue != null)
                        {
                            bool   isValid = false;
                            string pValue  = Utility.ToString(prop.GetValue(proxy, null));
                            int    value   = 0;
                            switch (cnpValue.Concept.DataType)
                            {
                            case ConceptDataType.Int:
                                if (Utility.IsNumber(pValue))
                                {
                                    value   = Utility.ToInteger(pValue);
                                    isValid = true;
                                }
                                break;

                            case ConceptDataType.Hour:
                                if (Utility.IsTime(pValue))
                                {
                                    value   = Utility.RealTimeToIntTime(pValue);
                                    isValid = true;
                                }
                                break;
                            }
                            if (isValid)
                            {
                                cnpValue.ChangedValue = value;
                                archiveRep.SaveOrUpdate(cnpValue);
                            }
                        }
                    }
                }
                #endregion
            }
        }