Пример #1
0
        public bool DailyEvaulation(IConnectionHandler connectionHandler, Dictionary <Guid, Tools.ModelView.ModifyResult <UserBooth> > keyValuePairs, Dictionary <Guid, Tools.ModelView.ModifyResult <WorkShopUser> > workShopUsers, Dictionary <Guid, Tools.ModelView.ModifyResult <HotelUser> > hotelUsers)
        {
            var list = this.GetCurrentCongress(connectionHandler);

            foreach (var homa in list)
            {
                var keyValuePair = new Tools.ModelView.ModifyResult <UserBooth>();
                var workShopUser = new Tools.ModelView.ModifyResult <WorkShopUser>();
                var hotelUser    = new Tools.ModelView.ModifyResult <HotelUser>();

                if (!this.DailyEvaulationForConfig(connectionHandler, homa.Configuration, keyValuePair, workShopUser, hotelUser))
                {
                    return(false);
                }
                keyValuePairs.Add(homa.Id, keyValuePair);
                workShopUsers.Add(homa.Id, workShopUser);
                hotelUsers.Add(homa.Id, hotelUser);
            }
            return(true);
        }
Пример #2
0
        private bool DailyEvaulationForConfig(IConnectionHandler connectionHandler, Configuration configuration,
                                              Tools.ModelView.ModifyResult <UserBooth> keyValuePairs, Tools.ModelView.ModifyResult <WorkShopUser> workShopUsers, Tools.ModelView.ModifyResult <HotelUser> hotelUsers)
        {
            bool result;

            var userBoothBo = new UserBoothBO();

            if (configuration.DayCountDeleteBoothReserveNotPay != null &&
                configuration.DayCountDeleteBoothReserveNotPay > 0)
            {
                var list = userBoothBo.Where(connectionHandler,
                                             x => x.Booth.CongressId == configuration.CongressId && x.TransactionId == null);
                foreach (var userBooth in list)
                {
                    var dateTime =
                        DateTimeUtil.ShamsiDateToGregorianDate(userBooth.RegisterDate)
                        .AddDays((double)configuration.DayCountDeleteBoothReserveNotPay)
                        .ShamsiDate();
                    if (dateTime.CompareTo(DateTime.Now.ShamsiDate()) < 0)
                    {
                        if (!userBoothBo.Delete(connectionHandler, userBooth))
                        {
                            throw new Exception(Resources.Congress.ErrorInWorkDailyScheduler);
                        }
                        keyValuePairs.AddInform(
                            userBooth, Resources.Congress.BoothChangeStatusEmail, Resources.Congress.BoothChangeStatusSMS
                            );
                    }
                }
            }
            var hotelUserBo = new HotelUserBO();

            if (configuration.DayCountDeleteHotelReserveNotPay != null &&
                configuration.DayCountDeleteHotelReserveNotPay > 0)
            {
                var list = hotelUserBo.Where(connectionHandler,
                                             x => x.Hotel.CongressId == configuration.CongressId && x.TransactionId == null);
                foreach (var hotelUser in list)
                {
                    var user     = hotelUser;
                    var dateTime =
                        DateTimeUtil.ShamsiDateToGregorianDate(user.RegisterDate)
                        .AddDays((double)configuration.DayCountDeleteHotelReserveNotPay)
                        .ShamsiDate();
                    if (dateTime.CompareTo(DateTime.Now.ShamsiDate()) < 0)
                    {
                        if (!hotelUserBo.Delete(connectionHandler, hotelUser))
                        {
                            throw new Exception(Resources.Congress.ErrorInWorkDailyScheduler);
                        }
                        if (hotelUsers.InformList.All(x => x.obj.UserId != user.UserId))
                        {
                            hotelUsers.AddInform(

                                user,
                                Resources.Congress.HotelChangeStatusEmail, Resources.Congress.HotelChangeStatusSMS
                                );
                        }

                        if (!user.User.ParentId.HasValue || hotelUsers.InformList.Any(x => x.obj.UserId == user.User.ParentId))
                        {
                            continue;
                        }
                        hotelUsers.AddInform(

                            new HotelUser()
                        {
                            UserId  = (Guid)user.User.ParentId,
                            HotelId = user.HotelId,
                            Status  = user.Status
                        },
                            Resources.Congress.HotelChangeStatusEmail, Resources.Congress.HotelChangeStatusSMS
                            );
                    }
                }
            }
            var workShopUserBo = new WorkShopUserBO();

            if (configuration.DayCountDeleteWorkShopReserveNotPay != null &&
                configuration.DayCountDeleteWorkShopReserveNotPay > 0)
            {
                var list = workShopUserBo.Where(connectionHandler,
                                                x =>
                                                x.WorkShop.CongressId == configuration.CongressId && x.TransactionId == null);
                foreach (var shopUser in list)
                {
                    var workShopUser = shopUser;
                    var addDays      =
                        DateTimeUtil.ShamsiDateToGregorianDate(workShopUser.RegisterDate)
                        .AddDays((double)configuration.DayCountDeleteWorkShopReserveNotPay);
                    var dateTime = addDays.ShamsiDate();
                    if (dateTime.CompareTo(DateTime.Now.ShamsiDate()) < 0)
                    {
                        if (!workShopUserBo.Delete(connectionHandler, shopUser))
                        {
                            throw new Exception(Resources.Congress.ErrorInWorkDailyScheduler);
                        }
                        if (workShopUsers.InformList.All(x => x.obj.UserId != workShopUser.UserId))
                        {
                            workShopUsers.AddInform(

                                workShopUser,
                                Resources.Congress.WorkShopChangeStatusEmail,
                                Resources.Congress.WorkShopChangeStatusSMS
                                );
                        }

                        if (!workShopUser.User.ParentId.HasValue ||
                            workShopUsers.InformList.Any(x => x.obj.UserId == workShopUser.User.ParentId))
                        {
                            continue;
                        }
                        workShopUsers.AddInform(


                            new WorkShopUser()
                        {
                            UserId     = (Guid)workShopUser.User.ParentId,
                            WorkShopId = workShopUser.WorkShopId,
                            Status     = workShopUser.Status
                        }
                            , Resources.Congress.WorkShopChangeStatusEmail
                            , Resources.Congress.WorkShopChangeStatusSMS
                            );
                    }
                }
            }
            result = true;

            return(result);
        }