/// <summary>
        /// گزارش کارکرد یک روز پرسنل جاری را بر می گرداند
        /// </summary>
        /// <param name="dayDate">تاریخ</param>
        /// <returns>سطر گزارش کارکرد</returns>
        public PersonalMonthlyReportRow GetPersonDailyReport(DateTime dayDate)
        {
            try
            {
                IList <PersonalMonthlyReportRow> DailyRows = new List <PersonalMonthlyReportRow>();

                if (IsValidPeson())
                {
                    PersianDateTime p = new PersianDateTime(dayDate);
                    DateTime        endOfMonth;
                    if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                    {
                        endOfMonth = PersianDateTime.GetEndOfShamsiMonth(p.Year, p.Month).GregorianDate;
                    }
                    else
                    {
                        endOfMonth = new DateTime(dayDate.Year, dayDate.Month, DateTime.DaysInMonth(dayDate.Year, dayDate.Month));
                    }

                    BTemp          bTemp = new BTemp();
                    List <decimal> list  = new List <decimal>();
                    list.Add(this.workingPersonId);
                    string operationGUID = bTemp.InsertTempList(list);
                    gtsEngineWS.GTS_ExecuteByPersonIdAndToDate(BUser.CurrentUser.UserName, this.workingPersonId, dayDate.AddDays(1));
                    PersonalMonthlyReport Result = new PersonalMonthlyReport(this.workingPersonId, endOfMonth, new PersianDateTime(endOfMonth).Month, dayDate, dayDate);
                    Result.LanguageName = sysLanguageResource;

                    DailyRows = Result.PersonalMonthlyReportRows;

                    return(DailyRows.First());
                }
                else
                {
                    throw new IllegalServiceAccess(String.Format("این سرویس بعللت اعتبارسنجی قابل دسترسی نمیباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                }
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BPersonMonthlyWorkedTime", "GetPersonDailyReport");

                throw ex;
            }
        }
        /// <summary>
        /// نمای گرافیکی گزارش کارکرد ماهیانه کاربر جاری را برمی گرداند
        /// </summary>
        /// <param name="year">سال</param>
        /// <param name="month">ماه</param>
        /// <param name="fromDate">تاریخ ابتدا</param>
        /// <param name="toDate">تاریخ انتها</param>
        /// <returns>لیست سطرهای گزارش کارکرد</returns>
        public IList <PersonalMonthlyReportRow> GetPersonGanttChart(int year, int month, string fromDate, string toDate)
        {
            IList <PersonalMonthlyReportRow> DailyRows = new List <PersonalMonthlyReportRow>();

            try
            {
                if (Utility.IsEmpty(fromDate) || Utility.IsEmpty(toDate))
                {
                    throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.PersonDateRangeIsNotDefiend, String.Format("برای شخص {0} رینج محاسبات تعریف نشده است", workingPersonId), ExceptionSrc);
                }
                if (IsValidPeson())
                {
                    DateTime from, to;
                    if (sysLanguageResource == LanguagesName.Parsi)
                    {
                        from = Utility.ToMildiDate(fromDate);
                        to   = Utility.ToMildiDate(toDate);
                    }
                    else
                    {
                        from = Utility.ToMildiDateTime(fromDate);
                        to   = Utility.ToMildiDateTime(toDate);
                    }
                    gtsEngineWS.GTS_ExecuteByPersonID(BUser.CurrentUser.UserName, this.workingPersonId);
                    PersonalMonthlyReport Result = new PersonalMonthlyReport(this.workingPersonId, from, to);
                    Result.LanguageName = sysLanguageResource;

                    DailyRows = Result.PersonalGanttChartRows;
                }
                else
                {
                    throw new IllegalServiceAccess(String.Format("این سرویس بعللت اعتبارسنجی قابل دسترسی نمیباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                }
                return(DailyRows);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BPersonMonthlyWorkedTime", "GetPersonMonthlyReport");

                throw ex;
            }
        }
        /// <summary>
        /// برای تست استفاده میشود
        /// </summary>
        /// <param name="username"></param>
        //public BPersonMonthlyWorkedTime(string username)
        //{
        //    this.Username = username;
        //    if (AppSettings.BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
        //    {
        //        this.sysLanguageResource = LanguagesName.Parsi;
        //    }
        //    else if (AppSettings.BLanguage.CurrentSystemLanguage == LanguagesName.English)
        //    {
        //        this.sysLanguageResource = LanguagesName.English;
        //    }
        //}

        #endregion

        /// <summary>
        /// سطرهای گزارش کارکرد ماهانه را برای یک دوره یک ماهه برمیگرداند
        /// </summary>
        /// <param name="year">سال</param>
        /// <param name="month">ماه</param>
        /// <param name="fromDate">از تاریخ</param>
        /// <param name="toDate">تا تاریخ</param>
        /// <param name="DailyRows">لیست سطرهای روز گزارش کارکرد</param>
        /// <param name="MonthlyRow">لیست سطرهای ماه گزارش کارکرد</param>
        public void GetPersonMonthlyReport(int year, int month, string fromDate, string toDate, out IList <PersonalMonthlyReportRow> DailyRows, out PersonalMonthlyReportRow MonthlyRow)
        {
            try
            {
                if (Utility.IsEmpty(fromDate) || Utility.IsEmpty(toDate))
                {
                    throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.PersonDateRangeIsNotDefiend, String.Format("برای شخص {0} رینج محاسبات تعریف نشده است", workingPersonId), ExceptionSrc);
                }
                if (IsValidPeson())
                {
                    DateTime date = new DateTime(year, month, Utility.GetEndOfMiladiMonth(year, month));
                    if (sysLanguageResource == LanguagesName.Parsi)
                    {
                        date = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, month, Utility.GetEndOfPersianMonth(year, month)));
                    }
                    DateTime from, to;
                    if (sysLanguageResource == LanguagesName.Parsi)
                    {
                        from = Utility.ToMildiDate(fromDate);
                        to   = Utility.ToMildiDate(toDate);
                    }
                    else
                    {
                        from = Utility.ToMildiDateTime(fromDate);
                        to   = Utility.ToMildiDateTime(toDate);
                    }
                    //BTemp bTemp = new BTemp();
                    //List<decimal> list = new List<decimal>();
                    //list.Add(this.workingPersonId);
                    //string operationGUID = bTemp.InsertTempList(list);
                    //gtsEngineWS.GTS_ExecutePersonsByToDateGUID(BUser.CurrentUser.UserName, operationGUID, to);
                    //bTemp.DeleteTempList(operationGUID);
                    gtsEngineWS.GTS_ExecuteByPersonID(BUser.CurrentUser.UserName, this.workingPersonId);
                    PersonalMonthlyReport Result = new PersonalMonthlyReport(this.workingPersonId, date, month, from, to);
                    Result.LanguageName = sysLanguageResource;

                    DailyRows  = Result.PersonalMonthlyReportRows;
                    MonthlyRow = DailyRows.FirstOrDefault();

                    foreach (PersonalMonthlyReportRow row in DailyRows)
                    {
                        //Day State Title
                        //fa:{0};en:{1}
                        if (!Utility.IsEmpty(row.DayStateTitle) && row.DayStateTitle.Contains(';'))
                        {
                            if (BLanguage.CurrentLocalLanguage == LanguagesName.Parsi)
                            {
                                row.DayStateTitle = Utility.Spilit(row.DayStateTitle, ';')[0].Replace("fa:", "");
                            }
                            else
                            {
                                row.DayStateTitle = Utility.Spilit(row.DayStateTitle, ';')[1].Replace("en:", "");
                            }
                        }
                        else
                        {
                            row.DayStateTitle = "";
                        }
                    }
                }
                else
                {
                    throw new IllegalServiceAccess(String.Format("این سرویس بعللت اعتبارسنجی قابل دسترسی نمیباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                }
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BPersonMonthlyWorkedTime", "GetPersonMonthlyReport");

                throw ex;
            }
        }
        //END OF DNN NOte
        /// <summary>
        /// یک سال را دریافت میکند و 12 ماه را همراه با شروع و پایان آن برمیگرداند
        /// </summary>
        /// <param name="year">سال</param>
        /// <returns>لیست پروکسی بازه های زمانی در یک سال</returns>
        public IList <DateRangeOrderProxy> GetDateRangeOrder(int year)
        {
            using (NHibernateSessionManager.Instance.BeginTransactionOn())
            {
                try
                {
                    if (IsValidPeson())
                    {
                        IList <DateRangeOrderProxy> list = new List <DateRangeOrderProxy>();


                        for (int i = 1; i <= 12; i++)
                        {
                            DateRangeOrderProxy proxy = new DateRangeOrderProxy();
                            DateTime            date  = new DateTime(year, i, DateTime.DaysInMonth(year, i));
                            if (sysLanguageResource == LanguagesName.Parsi)
                            {
                                int endOfMonth = new PersianCalendar().GetDaysInMonth(year, i);
                                date = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, i, endOfMonth));
                            }
                            PersonalMonthlyReport report = personRepository.GetPersonalMonthlyReport(this.workingPersonId, date, i);
                            if (report.DataRangeIsValid)
                            {
                                proxy.Order    = i;
                                proxy.Selected = false;
                                if (sysLanguageResource == LanguagesName.Parsi)
                                {
                                    proxy.FromDate = Utility.ToPersianDate(report.FromDate);
                                    proxy.ToDate   = Utility.ToPersianDate(report.ToDate);
                                }
                                else
                                {
                                    proxy.FromDate = report.FromDate;
                                    proxy.ToDate   = report.ToDate;
                                }
                                if (report.MinDate.Date <= DateTime.Now && DateTime.Now.Date <= report.MaxDate)
                                {
                                    proxy.Selected = true;
                                }
                                list.Add(proxy);
                            }
                        }
                        if (list.Count == 0)
                        {
                            UIValidationExceptions exeptions = new UIValidationExceptions();
                            exeptions.Add(new ValidationException(ExceptionResourceKeys.PersonnelCalculationDateRangeIsNotValuedForSelectedYear, "در سال انتخاب شده محدوده محاسبات به پرسنل تخصیص داده نشده است", ExceptionSrc));
                            throw exeptions;
                        }
                        list = list.OrderBy(x => x.Order).ToList();
                        if (list.Where(x => x.Selected).Count() == 0)
                        {
                            if (Utility.ToPersianDateTime(DateTime.Now).Year == year + 1)//سال قبل
                            {
                                list[list.Count - 1].Selected = true;
                            }
                            else
                            {
                                list[0].Selected = true;
                            }
                        }
                        NHibernateSessionManager.Instance.CommitTransactionOn();
                        return(list);
                    }
                    else
                    {
                        throw new IllegalServiceAccess(String.Format("این سرویس بعللت اعتبارسنجی قابل دسترسی نمیباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                    }
                }
                catch (Exception ex)
                {
                    NHibernateSessionManager.Instance.RollbackTransactionOn();
                    BaseBusiness <Entity> .LogException(ex, "BPersonMonthlyWorkedTime", "GetDateRangeOrder");

                    throw ex;
                }
            }
        }