Exemple #1
0
        protected void button7_Click(object sender, EventArgs e)
        {
            BArchiveCalculator     bus   = new BArchiveCalculator();
            ArchiveCalcValuesProxy proxy = bus.GetArchiveValues(1392, 4, 870).First();

            proxy.P1 = "-9";
            proxy.P2 = "-10";
            proxy.P3 = "-10";
            bus.SetArchiveValues(1392, 4, 870, proxy);
        }
    public string[] UpdateCalculationResult_UpdateCalculationResultPage(string state, string PersonnelID, string Year, string Month, string StrFieldsValCol)
    {
        this.InitializeCulture();

        string[] retMessage = new string[4];

        try
        {
            AttackDefender.CSRFDefender(this.Page);
            UIActionType           uam                    = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper());
            decimal                personnelID            = decimal.Parse(this.StringBuilder.CreateString(PersonnelID), CultureInfo.InvariantCulture);
            int                    year                   = int.Parse(this.StringBuilder.CreateString(Year), CultureInfo.InvariantCulture);
            int                    month                  = int.Parse(this.StringBuilder.CreateString(Month), CultureInfo.InvariantCulture);
            ArchiveCalcValuesProxy archiveCalcValuesProxy = this.CreateFieldsValList_UpdateCalculationResult(this.StringBuilder.CreateString(StrFieldsValCol));
            switch (uam)
            {
            case UIActionType.EDIT:
                archiveCalcValuesProxy = this.UpdateCalculationResultBusiness.SetArchiveValues(year, month, personnelID, archiveCalcValuesProxy);
                break;
            }

            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            string SuccessMessageBody = string.Empty;
            switch (uam)
            {
            case UIActionType.EDIT:
                SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                break;

            case UIActionType.DELETE:
                SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                break;
            }
            retMessage[1] = SuccessMessageBody;
            retMessage[2] = "success";
            retMessage[3] = JsSerializer.Serialize(archiveCalcValuesProxy);
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }
    private ArchiveCalcValuesProxy CreateFieldsValList_UpdateCalculationResult(string StrDayShiftCol)
    {
        Dictionary <string, object> FieldsValDic           = (Dictionary <string, object>) this.JsSerializer.DeserializeObject(StrDayShiftCol);
        ArchiveCalcValuesProxy      archiveCalcValuesProxy = new ArchiveCalcValuesProxy();

        foreach (string key in FieldsValDic.Keys)
        {
            PropertyInfo PInfo = typeof(ArchiveCalcValuesProxy).GetProperty(key);
            PInfo.SetValue(archiveCalcValuesProxy, FieldsValDic[key].ToString(), null);
        }
        return(archiveCalcValuesProxy);
    }
Exemple #4
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;
            }
        }
Exemple #5
0
        /// <summary>
        /// نتایج محاسبات را بارگزاری میکند
        /// </summary>
        /// <param name="year">سال</param>
        /// <param name="month">ماه</param>
        /// <param name="personList">لیست پرسنل</param>
        /// <returns>لیست پروکسی مقادیر نتایج محاسبات محاسبات</returns>
        private IList <ArchiveCalcValuesProxy> GetArchiveValues(int year, int month, IList <Person> personList)
        {
            try
            {
                //personList = this.CheckMaxArrayParamCount(personList);
                IList <ArchiveCalcValuesProxy> resultList = new List <ArchiveCalcValuesProxy>();
                DateTime date       = new DateTime(year, month, Utility.GetEndOfMiladiMonth(year, month));
                int      rangeOrder = month;

                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    date = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, month, Utility.GetEndOfPersianMonth(year, month)));
                }

                var ids = from o in personList
                          select o.ID;
                IList <ArchiveConceptValue> archiveValues = archiveRep.LoadArchiveValueList(ids.ToList(), year, rangeOrder);

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

                foreach (Person prs in personList)
                {
                    if (archiveValues.Any(x => x.PersonId == prs.ID))
                    {
                        ArchiveCalcValuesProxy proxy = new ArchiveCalcValuesProxy()
                        {
                            PersonId = prs.ID, PersonCode = prs.PersonCode, PersonName = prs.Name
                        };
                        proxy = SetMapValue(proxy, prs.ID, archiveValues, fildsMapList);
                        resultList.Add(proxy);
                    }
                }

                return(resultList);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex);

                throw ex;
            }
        }
Exemple #6
0
        private ArchiveCalcValuesProxy ValidateKaheshiKosuratBankSepah(ArchiveCalcValuesProxy archiveCalcProxyObj, int year, int month, decimal personId)
        {
            try
            {
                archiveCalcProxyObj.PersonId = personId;
                PersonRepository             personRep = new PersonRepository(false);
                IRuleRepository              ruleRep   = Rule.GetRuleRepository(false);
                Person                       personObj = personRep.GetById(personId, false);
                PersonRangeAssignment        personRangeAssigmentObj  = new BPerson().GetCurrentRangeAssignment(personId);
                IList <CalculationDateRange> calculationDateRangeList = personRangeAssigmentObj.CalcDateRangeGroup.DateRangeList;
                CalculationDateRange         calculationDateRangeObj  = calculationDateRangeList.FirstOrDefault(f => f.Concept.IdentifierCode == 4005 && f.ToMonth == month);
                int      dayRule  = calculationDateRangeObj.ToDay;
                DateTime ruledate = Utility.ToMildiDate(year.ToString() + "/" + (month < 10 ? "0" + month.ToString() : month.ToString()).ToString() + "/" + (dayRule < 10 ? "0" + dayRule.ToString() : dayRule.ToString()).ToString());
                personObj.InitializeForAccessRules(ruledate, ruledate);
                int          maxOverTime = Convert.ToInt32(personObj.PersonTASpec.R10 == string.Empty ? "0" : personObj.PersonTASpec.R10) * 60;
                AssignedRule ar          = personObj.AssignedRuleList.Where(x => x.FromDate <= ruledate && x.ToDate >= ruledate && x.IdentifierCode == 6029).FirstOrDefault();
                int          zaribBaje   = 1;
                if (ar != null)
                {
                    IList <AssignedRuleParameter> ruleParameterList = ruleRep.GetAssginedRuleParamList(ruledate, ruledate);
                    IList <AssignedRuleParameter> asp = ruleParameterList.Where(x => x.RuleId == ar.RuleId && x.FromDate <= ruledate && x.ToDate >= ruledate).ToList();
                    zaribBaje = 1 + (Utility.ToInteger(asp.SingleOrDefault(a => a.Name == "Third").Value) / 100);
                }

                if (archiveCalcProxyObj.P2 == null || archiveCalcProxyObj.P2.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P2 = "00:00";
                }
                else if (!archiveCalcProxyObj.P2.Contains(":"))
                {
                    archiveCalcProxyObj.P2 = archiveCalcProxyObj.P2.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P3 == null || archiveCalcProxyObj.P3.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P3 = "00:00";
                }
                else if (!archiveCalcProxyObj.P3.Contains(":"))
                {
                    archiveCalcProxyObj.P3 = archiveCalcProxyObj.P3.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P4 == null || archiveCalcProxyObj.P4.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P4 = "00:00";
                }
                else if (!archiveCalcProxyObj.P4.Contains(":"))
                {
                    archiveCalcProxyObj.P4 = archiveCalcProxyObj.P4.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P5 == null || archiveCalcProxyObj.P5.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P5 = "00:00";
                }
                else if (!archiveCalcProxyObj.P5.Contains(":"))
                {
                    archiveCalcProxyObj.P5 = archiveCalcProxyObj.P5.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P6 == null || archiveCalcProxyObj.P6.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P6 = "00:00";
                }
                else if (!archiveCalcProxyObj.P6.Contains(":"))
                {
                    archiveCalcProxyObj.P6 = archiveCalcProxyObj.P6.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P7 == null || archiveCalcProxyObj.P7.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P7 = "00:00";
                }
                else if (!archiveCalcProxyObj.P7.Contains(":"))
                {
                    archiveCalcProxyObj.P7 = archiveCalcProxyObj.P7.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P8 == null || archiveCalcProxyObj.P8.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P8 = "00:00";
                }
                else if (!archiveCalcProxyObj.P8.Contains(":"))
                {
                    archiveCalcProxyObj.P8 = archiveCalcProxyObj.P8.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P11 == null || archiveCalcProxyObj.P11.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P11 = "00:00";
                }
                else if (!archiveCalcProxyObj.P11.Contains(":"))
                {
                    archiveCalcProxyObj.P11 = archiveCalcProxyObj.P11.Trim() + ":00";
                }

                if (archiveCalcProxyObj.P12 == null || archiveCalcProxyObj.P12.Trim() == string.Empty)
                {
                    archiveCalcProxyObj.P12 = "00:00";
                }
                else if (!archiveCalcProxyObj.P12.Contains(":"))
                {
                    archiveCalcProxyObj.P12 = archiveCalcProxyObj.P12.Trim() + ":00";
                }



                int jameSotunhayeEzafeKar = (Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P2)) * zaribBaje) + Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P3)) + Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P4)) + Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P5)) + Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P6)) + Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P7) + Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P8)));

                if (jameSotunhayeEzafeKar > maxOverTime)
                {
                    int tafavotemaxOverTimeSotunha = jameSotunhayeEzafeKar - maxOverTime;
                    archiveCalcProxyObj.P11 = (Utility.IntTimeToTime(tafavotemaxOverTimeSotunha + Utility.RealTimeToIntTime(archiveCalcProxyObj.P11)));
                    if (Utility.RealTimeToIntTime(archiveCalcProxyObj.P3) > tafavotemaxOverTimeSotunha)
                    {
                        archiveCalcProxyObj.P3 = Utility.IntTimeToTime((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P3)) - tafavotemaxOverTimeSotunha));
                    }
                    else
                    {
                        tafavotemaxOverTimeSotunha = tafavotemaxOverTimeSotunha - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P3) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P3));
                        archiveCalcProxyObj.P3     = Utility.IntTimeToTime(0);
                        if (Utility.RealTimeToIntTime(archiveCalcProxyObj.P4) > tafavotemaxOverTimeSotunha)
                        {
                            archiveCalcProxyObj.P4 = Utility.IntTimeToTime((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P4)) - tafavotemaxOverTimeSotunha));
                        }
                        else
                        {
                            tafavotemaxOverTimeSotunha = tafavotemaxOverTimeSotunha - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P4) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P4));
                            archiveCalcProxyObj.P4     = Utility.IntTimeToTime(0);
                            if ((Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) * zaribBaje) > tafavotemaxOverTimeSotunha)
                            {
                                archiveCalcProxyObj.P2 = Utility.IntTimeToTime(Utility.ToInteger((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) * zaribBaje) - tafavotemaxOverTimeSotunha) / zaribBaje));
                            }
                            else
                            {
                                tafavotemaxOverTimeSotunha = tafavotemaxOverTimeSotunha - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) * zaribBaje);
                                archiveCalcProxyObj.P2     = Utility.IntTimeToTime(0);
                                if (Utility.RealTimeToIntTime(archiveCalcProxyObj.P5) > tafavotemaxOverTimeSotunha)
                                {
                                    archiveCalcProxyObj.P5 = Utility.IntTimeToTime((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P5)) - tafavotemaxOverTimeSotunha));
                                }
                                else
                                {
                                    tafavotemaxOverTimeSotunha = tafavotemaxOverTimeSotunha - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P5) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P5));
                                    archiveCalcProxyObj.P5     = Utility.IntTimeToTime(0);
                                }
                            }
                        }
                    }
                }
                //else

                //    archiveCalcProxyObj.P11 = Utility.IntTimeToTime(0);


                int kosurat = Utility.RealTimeToIntTime(archiveCalcProxyObj.P12);
                if (kosurat > 0)
                {
                    if (Utility.RealTimeToIntTime(archiveCalcProxyObj.P3) > kosurat)
                    {
                        archiveCalcProxyObj.P3 = Utility.IntTimeToTime((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P3)) - kosurat));
                    }
                    else
                    {
                        kosurat = kosurat - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P3) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P3));
                        archiveCalcProxyObj.P3 = Utility.IntTimeToTime(0);
                        if (Utility.RealTimeToIntTime(archiveCalcProxyObj.P4) > kosurat)
                        {
                            archiveCalcProxyObj.P4 = Utility.IntTimeToTime((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P4)) - kosurat));
                        }
                        else
                        {
                            kosurat = kosurat - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P4) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P4));
                            archiveCalcProxyObj.P4 = Utility.IntTimeToTime(0);
                            if ((Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) * zaribBaje) > kosurat)
                            {
                                archiveCalcProxyObj.P2 = Utility.IntTimeToTime(Utility.ToInteger((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) * zaribBaje) - kosurat) / zaribBaje));
                            }
                            else
                            {
                                kosurat = kosurat - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P2) * zaribBaje);
                                archiveCalcProxyObj.P2 = Utility.IntTimeToTime(0);
                                if (Utility.RealTimeToIntTime(archiveCalcProxyObj.P5) > kosurat)
                                {
                                    archiveCalcProxyObj.P5 = Utility.IntTimeToTime((Utility.ToInteger(Utility.RealTimeToIntTime(archiveCalcProxyObj.P5)) - kosurat));
                                }
                                else
                                {
                                    kosurat = kosurat - (Utility.RealTimeToIntTime(archiveCalcProxyObj.P5) == -1000 ? 0 : Utility.RealTimeToIntTime(archiveCalcProxyObj.P5));
                                    archiveCalcProxyObj.P5 = Utility.IntTimeToTime(0);
                                }
                            }
                        }
                    }
                }


                return(archiveCalcProxyObj);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex);

                throw ex;
            }
        }
Exemple #7
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);
        }
Exemple #8
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
            }
        }