Esempio n. 1
0
        /// <summary>
        /// پس از حذف نتایج محاسبات قبلی , دادههای جدید را کپی میکند
        /// بعلت محدودیت در تعداد پارامتر , دسته دسته نتایج محاسبات میشود
        /// </summary>
        /// <param name="year">سال</param>
        /// <param name="month">ماه</param>
        /// <param name="personList">لیست پرسنل</param>
        /// <param name="overwrite">بازنویسی</param>
        /// <returns>انجام  شد/انجام نشد</returns>
        private bool ArchiveData(int year, int month, IList <Person> personList, bool overwrite)
        {
            //DNN Note
            // ابتدا بررسی می کند که برای اشخاص محاسبات  در این روز انجام شده است یا خیر
            var CFPList       = cfpRe.GetByPersonIDList(personList.Select(c => c.ID).ToList()).ToList();
            var validCFPCount = CFPList.Where(c => c.CalculationIsValid == true && c.Date.Date >= DateTime.Now.Date).Count();

            if (validCFPCount < personList.Count)
            {
                UIValidationExceptions exception = new UIValidationExceptions();
                exception.Add(new ValidationException(ExceptionResourceKeys.PersonCalculationRequied, string.Format("نشانگر محاسبات پرسنل برای {0} نفر بروز نمی باشد, ابتدا انجام محاسبات اجرا شود", personList.Count - validCFPCount), ExceptionSrc));
                throw exception;
            }
            //----------------------------------------------------
            try
            {
                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)));
                }
                int ofset = 2000;
                for (int i = 0; i < personList.Count; i += ofset)
                {
                    var ids = from o in personList
                              .Skip(i)
                              .Take(ofset)
                              select o.ID;

                    if (overwrite)
                    {
                        archiveRep.DeleteArchiveValues(ids.ToList(), year, month);
                    }
                    foreach (decimal id in ids)
                    {
                        if (!overwrite && this.IsArchiveExsits(year, month, id) != ArchiveExistsConditions.NotExists)
                        {
                            continue;
                        }
                        archiveRep.ArchiveConceptValues(id, year, rangeOrder, date, BUser.CurrentUser.Person.ID);
                        //DNN Note
                        var    person = personList.Where(c => c.ID == id).First();
                        string info   = string.Format("نتایج محاسبات برای پرسنل {0} با کد {1} مربوط به ماه {2} سال {3} آرشیو گردید", person.Name, person.BarCode, month, year);
                        base.LogUserAction(info, "Archive", BUser.CurrentUser.UserName, true);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex);

                throw ex;
            }
        }
Esempio n. 2
0
        protected IList <CFP> GetCFPPersons(IList <decimal> personIdList)
        {
            IList <CFP> cfpList = cfpRepository.GetByPersonIDList(personIdList);

            //if (cfp != null && cfp.ID > 0)
            //{
            //    return cfp;
            //}
            return(cfpList);
        }