Beispiel #1
0
 public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
 {
     try
     {
         //Apply logging
         var objChanges = HttpContext.Current.Items[ContactInfo.CONTACT_CHANGE] as List <ActivityObjectChangeInfo>;
         if (objChanges != null)
         {
             var activityInfo = new ActivityLogInfo
             {
                 FunctionId = 0,
                 CreatedBy  = UserContext.GetCurrentUser().UserID
             };
             activityInfo.Id = ActivityLogRepository.Create(activityInfo);
             foreach (var objChange in objChanges)
             {
                 objChange.ActivityId = activityInfo.Id;
                 ActivityObjectChangeRepository.Create(objChange);
             }
         }
         HttpContext.Current.Items[ContactInfo.CONTACT_CHANGE] = null;
     }
     catch
     {
         //Dont throw exception if loging failed
     }
     base.OnActionExecuted(actionExecutedContext);
 }
Beispiel #2
0
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            try
            {
                var userCurent = UserContext.GetCurrentUser();
                if (userCurent != null)
                {
                    ViewBag.GroupId      = userCurent.GroupId;
                    ViewBag.GroupType    = userCurent.GroupConsultantType;
                    ViewBag.UserBranches = UserRepository.GetBranchOfUser(userCurent.UserID);
                }

                //Gói niêm yết
                ViewBag.PackagePriceListed = CatalogRepository.GetAll <PackagePriceListed>();

                // GroupType
                var wbServiceConfigTypes = new Dictionary <int, string>();
                foreach (var item in Enum.GetValues(typeof(WebServiceConfigType)))
                {
                    wbServiceConfigTypes.Add((int)item, ObjectExtensions.GetEnumDescription((WebServiceConfigType)item));
                }
                ViewBag.WebServiceConfigTypes = wbServiceConfigTypes.Select(c => new { Id = c.Key, Name = c.Value });

                // GroupType
                var groupTypes = new Dictionary <int, string>();
                foreach (var item in Enum.GetValues(typeof(GroupConsultantType)))
                {
                    groupTypes.Add((int)item, ObjectExtensions.GetEnumDescription((GroupConsultantType)item));
                }
                ViewBag.GroupTypes = groupTypes.Select(c => new { Id = c.Key, Name = c.Value });

                //Branches
                filterContext.Controller.ViewBag.BranchId = UserContext.GetDefaultBranch();

                //UserId
                filterContext.Controller.ViewBag.UserId = UserContext.GetCurrentUser().UserID;

                // Group
                StoreData.ListGroup.RemoveAll(c => c.GroupId == 0);
                filterContext.Controller.ViewBag.Groups = StoreData.ListGroup;

                // User
                StoreData.ListUser.RemoveAll(c => c.UserID == 0);
                filterContext.Controller.ViewBag.Users = StoreData.ListUser;

                // Level
                filterContext.Controller.ViewBag.Levels = StoreData.ListLevel;

                // Branch
                filterContext.Controller.ViewBag.Branches = StoreData.ListBranch;

                //Collectors
                filterContext.Controller.ViewBag.Collectors = StoreData.ListCollector;

                //StatusMap
                filterContext.Controller.ViewBag.StatusMaps = StoreData.ListStatusMap ?? new List <StatusMapInfo>();

                //StatusCare
                filterContext.Controller.ViewBag.StatusCares = StoreData.ListStatusCare ?? new List <StatusCareInfo>();

                // SourceType
                filterContext.Controller.ViewBag.SourceTypes = StoreData.ListSourceType ?? new List <SourceTypeInfo>();

                //Email
                filterContext.Controller.ViewBag.Email = StoreData.ListEmail ?? new List <EmailInfo>();

                //EducationLevel
                filterContext.Controller.ViewBag.EducationLevels = StoreData.ListEducationLevel ?? new List <EducationLevelInfo>();

                //TimeSlot
                filterContext.Controller.ViewBag.TimeSlots = StoreData.ListTimeSlot ?? new List <TimeSlotInfo>();

                //TeacherType
                filterContext.Controller.ViewBag.TeacherTypes = StoreData.ListTeacherType ?? new List <TeacherTypeInfo>();

                // Container
                filterContext.Controller.ViewBag.Containers = StoreData.ListContainer ?? new List <ContainerInfo>();

                //Import Excels
                filterContext.Controller.ViewBag.ImportExcels = StoreData.ListImportExcel ?? new List <ImportExcelInfo>();

                // WebServiceConfig
                StoreData.ListWebServiceConfig.RemoveAll(c => c.Id == 0);

                // StatusConnectType
                var statusConnectType = new Dictionary <int, string>();
                foreach (var item in Enum.GetValues(typeof(StatusConnectType)))
                {
                    statusConnectType.Add((int)item, ObjectExtensions.GetEnumDescription((StatusConnectType)item));
                }
                ViewBag.StatusConnectTypes = statusConnectType.Select(c => new { Id = c.Key, Name = c.Value });

                // Product
                //if (StoreData.ListProduct.IsNullOrEmpty())
                //{
                //    StoreData.ListProduct = ProductRepository.GetAll() ?? new List<ProductInfo>();
                //}
                filterContext.Controller.ViewBag.Products = StoreData.ListProduct ?? new List <ProductInfo>();

                // Quality
                //if (StoreData.ListQuality.IsNullOrEmpty())
                //{
                //    StoreData.ListQuality = QualityRepository.GetAll() ?? new List<QualityInfo>();
                //}
                filterContext.Controller.ViewBag.Quality = StoreData.ListQuality ?? new List <QualityInfo>();

                // FeeMoneyType
                filterContext.Controller.ViewBag.FeeMoneyType = StoreData.ListFeeMoneyType;

                // PackageFeeEdu
                filterContext.Controller.ViewBag.PackageFeeEdu = StoreData.ListPackageFeeEdu;
            }
            catch (Exception ex)
            {
            }

            try
            {
                //Apply logging
                var objChanges = HttpContext.Items[ContactInfo.CONTACT_CHANGE] as List <ActivityObjectChangeInfo>;
                if (objChanges != null)
                {
                    var activityInfo = new ActivityLogInfo
                    {
                        FunctionId = 0,
                        CreatedBy  = UserContext.GetCurrentUser().UserID
                    };
                    activityInfo.Id = ActivityLogRepository.Create(activityInfo);
                    foreach (var objChange in objChanges)
                    {
                        objChange.ActivityId = activityInfo.Id;
                        ActivityObjectChangeRepository.Create(objChange);
                    }
                }
                HttpContext.Items[ContactInfo.CONTACT_CHANGE] = null;
            }
            catch
            {
                //Dont throw exception if loging failed
            }
        }