Exemplo n.º 1
0
        /// <summary>
        /// خلاصه کارتابل را بر می گرداند
        /// </summary>
        /// <param name="userID">کلید اصلی کاربر</param>
        /// <returns>لیست خلاصه کارتابل</returns>
        public IList <KartablSummary> GetKartablSummary(decimal userID)
        {
            try
            {
                BKartabl bKartabl           = new BKartabl();
                IList <KartablSummary> list = kartablRep.GetByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new KartablSummary().Active), true))
                                              .OrderBy(x => x.Order).ToList();
                IDashboardBRequest busRequest = new BRequest();
                int year = 0, month = 0;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    year  = new PersianDateTime(DateTime.Now).Year;
                    month = new PersianDateTime(DateTime.Now).Month;
                }
                else
                {
                    year  = DateTime.Now.Year;
                    month = DateTime.Now.Month;
                }
                foreach (KartablSummary ks in list)
                {
                    if (BLanguage.CurrentLocalLanguage == LanguagesName.Parsi)
                    {
                        ks.Title = ks.FnTitle;
                    }
                    else
                    {
                        ks.Title = ks.EnTitle;
                    }
                    KartablSummaryItems item = (KartablSummaryItems)Enum.Parse(typeof(KartablSummaryItems), ks.Key);

                    int count = 0;

                    switch (item)
                    {
                    case KartablSummaryItems.ConfirmedRequestCount:
                        count    = busRequest.GetAllRequestCount(userID, year, month, RequestState.Confirmed);
                        ks.Value = count.ToString();
                        break;

                    case KartablSummaryItems.NotConfirmedRequestCount:
                        count    = busRequest.GetAllRequestCount(userID, year, month, RequestState.Unconfirmed);
                        ks.Value = count.ToString();
                        break;

                    case KartablSummaryItems.MainRecievedRequestCount:
                        count    = bKartabl.GetManagerKartablRequestCount(userID, year);
                        ks.Value = count == -1 ? "" : count.ToString();
                        break;

                    case KartablSummaryItems.SubstituteRecievedRequestCount:
                        count    = bKartabl.GetSubstituteKartablRequestCount(userID, year);
                        ks.Value = count == -1 ? "" : count.ToString();
                        break;

                    case KartablSummaryItems.InFlowRequestCount:
                        count    = busRequest.GetAllRequestCount(userID, year, RequestState.UnderReview);
                        ks.Value = count.ToString();
                        break;

                    case KartablSummaryItems.PrivateMessageCount:
                        BPrivateMessage busMsg = new BPrivateMessage();
                        ks.Value = Utility.ToString(busMsg.GetAllUnReadRecievedMessagesCount(userID));
                        break;

                    case KartablSummaryItems.UnderReviewRequestSubstituteRequestsCount:
                        try
                        {
                            count = bKartabl.GetAllRequestSubstituteKartableRequestsCount(RequestState.UnderReview, year, month, string.Empty);
                        }
                        catch (Exception)
                        {
                        }
                        ks.Value = count.ToString();
                        break;
                    }
                }

                list = list.Except(list.Where(x => x.Key == KartablSummaryItems.UnderReviewRequestSubstituteRequestsCount.ToString() && x.Value == 0.ToString()).ToList <KartablSummary>()).ToList <KartablSummary>();

                return(list);
            }
            catch (Exception ex)
            {
                BaseBusiness <PublicMessage> .LogException(ex);

                throw ex;
            }
        }