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
        public static int LogCreateContactTvts(ContactInfo entity)
        {
            try
            {
                var log = new ActivityLogInfo
                {
                    FunctionId = entity.Id,
                    CreatedBy = UserRepository.GetCurrentUserInfo().UserID,
                    FunctionType = (int)LogFunctionType.CreateContactTvts,
                };
                log.Id = Create(log);

                LogObjectChange(entity, log,
                                LogPropertyType.Contacts_StatusMap_Consultant,
                                LogPropertyType.Contacts_StatusCare_Consultant,
                                LogPropertyType.Contacts_Level,
                                LogPropertyType.Contacts_Type,
                                LogPropertyType.Contacts_Channel,
                                LogPropertyType.Contacts_Branch,
                                LogPropertyType.Contacts_Status,
                                LogPropertyType.Contacts_User_Consultant,
                                LogPropertyType.Contacts_HandoverDate_Consultant,
                                LogPropertyType.Contacts_AppointmentDate_Consultant);
                return log.Id;
            }
            catch
            {
            }
            return 0;
        }
Beispiel #3
0
        public static int LogCareContact(ContactInfo entity, params LogPropertyType[] types)
        {
            try
            {
                var log = new ActivityLogInfo
                {
                    FunctionId = entity.Id,
                    FunctionType = (int)LogFunctionType.CareContactConsultant,
                    CreatedBy = UserRepository.GetCurrentUserInfo().UserID,
                };
                log.Id = Create(log);

                LogObjectChange(entity, log, types);
                return log.Id;
            }
            catch
            {
            }
            return 0;
        }
Beispiel #4
0
        private void DoImport(string file)
        {
            try
            {
                //Create activity log
                var activity = new ActivityLogInfo
                                   {
                                       CreatedDate = DateTime.Now,
                                       CreatedBy = ImportInfo.UserId,
                                       FunctionId = (int)LogFunctionType.ImportExcel,
                                       FunctionType = (int)LogFunctionType.ImportExcel,
                                   };
                activity.Id = ActivityLogRepository.Create(activity);

                //End log
                using (var connection = new SqlConnection(ImportConfig.ConnectionString))
                {
                    connection.Open();

                    SqlTransaction transaction = null;
                    try
                    {
                        transaction = connection.BeginTransaction();
                        // Use one transaction to put all the data in the database
                        var watch = new Stopwatch();
                        watch.Start();
                        var contactIdentity = GetIdentity("Contacts", connection, transaction);
                        using (var stream = File.Open(file, FileMode.Open, FileAccess.Read))
                        {
                            using (var dr = ExcelReaderFactory.CreateOpenXmlReader(stream))
                            {
                                var rowIndex = 0;
                                while (dr.Read())
                                {
                                    if (rowIndex >= 1)
                                    {
                                        #region Read excel row
                                        var name = dr[1] == null ? string.Empty : dr[1].ToString().Trim();
                                        var email = dr[2] == null ? string.Empty : dr[2].ToString().Trim().ToLower();
                                        var mobile = dr[3] == null
                                            ? string.Empty
                                            : Util.CleanAlphabetAndFirstZero(dr[3].ToString().Trim());
                                        var address = dr[4] == null ? string.Empty : dr[4].ToString().Trim();
                                        DateTime? registeredDate;
                                        if (dr[5] == null) registeredDate = null;
                                        else
                                        {
                                            try
                                            {
                                                registeredDate = (DateTime)dr[5];
                                            }
                                            catch
                                            {
                                                registeredDate = dr[5].ToDateTime();
                                            }
                                        }
                                        var campaindTpe = dr[6] == null ? string.Empty : dr[6].ToString().Trim();
                                        var campaindTpeId = StaticData.GetCampaindTpeId(campaindTpe);

                                        var landingPage = dr[7] == null ? string.Empty : dr[7].ToString().Trim();
                                        var landingPageId = StaticData.GetLandingPageId(landingPage);

                                        var channel = dr[8] == null ? string.Empty : dr[8].ToString().Trim();
                                        var channelId = StaticData.GetChannelId(channel, ImportInfo.TypeId, ImportInfo.ChannelId);

                                        var templateAds = dr[9] == null ? string.Empty : dr[9].ToString().Trim();
                                        var templateAdsId = StaticData.GetTemplateAdsId(templateAds);

                                        var searchKeyword = dr[10] == null ? string.Empty : dr[10].ToString().Trim();
                                        var searchKeywordId = StaticData.GetTemplateAdsId(searchKeyword);

                                        var package = dr[11] == null ? string.Empty : dr[11].ToString().Trim();
                                        var packageId = StaticData.GetTemplateAdsId(package);

                                        var code = dr[12] == null ? string.Empty : dr[12].ToString().Trim();

                                        var contactIdDb = 0;
                                        var contactTmpStatus = 0;
                                        var contactInfoDb = string.Empty;
                                        #endregion

                                        #region validate row
                                        if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(mobile) && string.IsNullOrEmpty(email))
                                            continue;
                                        ImportInfo.RowIndex++;
                                        ImportInfo.TotalRow++;

                                        //Contact validation
                                        var error = Validate(mobile, string.Empty, string.Empty, email);

                                        // haihm
                                        if (error == ContactError.EmailFormat)
                                        {
                                            email = null;
                                            error = ContactError.None;
                                        }
                                        if (error != ContactError.None)
                                        {
                                            ImportInfo.ErrorCount++;
                                            contactTmpStatus = (int)error;
                                        }
                                        else
                                        {
                                            //Check if contact is internal duplicate or not
                                            if (IsInternalDuplicate(mobile, string.Empty, string.Empty, email))
                                            {
                                                contactTmpStatus = (int)ContactError.InternalDuplicate;
                                                ImportInfo.InternalDuplicateCount++;
                                            }
                                            else
                                            {
                                                //If not internal duplicate, add to hashtable data
                                                if (!string.IsNullOrEmpty(email)) internalPhoneAndEmails.Add(email);
                                                if (!string.IsNullOrEmpty(mobile)) internalPhoneAndEmails.Add(mobile);
                                                var check = CheckDuplicateProvider.Instance().IsDuplicate(mobile, string.Empty, string.Empty, email, string.Empty, out contactIdDb, out contactInfoDb);
                                                if (check)
                                                {
                                                    ImportInfo.DuplicateCount++;
                                                    contactTmpStatus = (int)ContactError.Duplicate;
                                                }
                                            }

                                        }
                                        ImportInfo.CheckCount++;
                                        #endregion

                                        switch (contactTmpStatus)
                                        {
                                            case (int)ContactError.None:
                                                {
                                                    #region create contact row
                                                    var contactId = contactIdentity + rowIndex;
                                                    var contactRow = dtContacts.NewRow();
                                                    contactRow["Gender"] = 0;
                                                    contactRow["Email"] = email;
                                                    contactRow["Id"] = contactId;
                                                    contactRow["Address"] = address;
                                                    contactRow["Fullname"] = name;
                                                    contactRow["ChannelId"] = channelId;
                                                    contactRow["PackageId"] = packageId;
                                                    contactRow["CreatedDate"] = DateTime.Now;
                                                    contactRow["TypeId"] = ImportInfo.TypeId;
                                                    contactRow["LevelId"] = ImportInfo.LevelId;
                                                    contactRow["CampaindTpeId"] = campaindTpeId;
                                                    contactRow["LandingPageId"] = landingPageId;
                                                    contactRow["TemplateAdsId"] = templateAdsId;
                                                    contactRow["BranchId"] = ImportInfo.BranchId;
                                                    contactRow["ImportId"] = ImportInfo.ImportId;
                                                    contactRow["StatusId"] = (int)StatusType.New;
                                                    contactRow["RegisteredDate"] = registeredDate;
                                                    contactRow["UserImportId"] = ImportInfo.UserId;
                                                    contactRow["SearchKeywordId"] = searchKeywordId;
                                                    contactRow["ImportedDate"] = ImportInfo.ImportedDate;
                                                    contactRow["Code"] = code.IsStringNullOrEmpty() ? string.Empty : code;
                                                    dtContacts.Rows.Add(contactRow);
                                                    #endregion

                                                    #region create phone row
                                                    if (!string.IsNullOrEmpty(mobile))
                                                    {
                                                        var phoneRow = dtPhones.NewRow();
                                                        phoneRow["ContactId"] = contactId;
                                                        phoneRow["PhoneType"] = (int)PhoneType.HomePhone;
                                                        phoneRow["PhoneNumber"] = mobile;
                                                        phoneRow["IsPrimary"] = 1;
                                                        dtPhones.Rows.Add(phoneRow);
                                                    }
                                                    #endregion

                                                    #region create contact level row
                                                    var contactLelveRow = dtContactLevels.NewRow();
                                                    contactLelveRow["ContactId"] = contactId;
                                                    dtContactLevels.Rows.Add(contactLelveRow);
                                                    #endregion

                                                    #region create object changes
                                                    foreach (DataColumn col in dtContacts.Columns)
                                                    {
                                                        if (col.ColumnName != "TypeId" &&
                                                            col.ColumnName != "LevelId" &&
                                                            col.ColumnName != "StatusId" &&
                                                            col.ColumnName != "ChannelId" &&
                                                            col.ColumnName != "BranchId")
                                                            continue;
                                                        var objChange = dtObjectChanges.NewRow();
                                                        objChange["ActivityId"] = activity.Id;
                                                        objChange["ObjectType"] = (int)LogObjectType.Contact;
                                                        objChange["ObjectId"] = contactId;
                                                        var propertyType = 0;
                                                        int? propertyValueInt = null;
                                                        string propertyValueString = null;
                                                        DateTime? propertyValueDateTime = null;
                                                        switch (col.ColumnName)
                                                        {
                                                            case "BranchId":
                                                                propertyType = (int)LogPropertyType.Contacts_Branch;
                                                                propertyValueInt = ImportInfo.BranchId;
                                                                break;
                                                            case "TypeId":
                                                                propertyType = (int)LogPropertyType.Contacts_Type;
                                                                propertyValueInt = ImportInfo.TypeId;
                                                                break;
                                                            case "LevelId":
                                                                propertyType = (int)LogPropertyType.Contacts_Level;
                                                                propertyValueInt = ImportInfo.LevelId;
                                                                break;
                                                            case "StatusId":
                                                                propertyType = (int)LogPropertyType.Contacts_Status;
                                                                propertyValueInt = ImportInfo.Status;
                                                                break;
                                                            case "ChannelId":
                                                                propertyType = (int)LogPropertyType.Contacts_Channel;
                                                                propertyValueInt = channelId;
                                                                break;
                                                        }
                                                        objChange["PropertyType"] = propertyType;
                                                        objChange["PropertyValueInt"] = propertyValueInt;
                                                        objChange["PropertyValueString"] = propertyValueString;
                                                        objChange["PropertyValueDateTime"] = propertyValueDateTime;
                                                        objChange["ChangedDate"] = DateTime.Now;
                                                        dtObjectChanges.Rows.Add(objChange);
                                                    }

                                                    #endregion
                                                }
                                                break;
                                            case (int)ContactError.Duplicate:
                                                {
                                                    #region create contact duplicate
                                                    var sourceTypes = StaticData.GetSourceTypeCheckDuplicate();
                                                    if (!sourceTypes.IsNullOrEmpty() && sourceTypes.Any(c => c.SourceTypeId == ImportInfo.TypeId))
                                                    {
                                                        if (!contactIdDb.IsIntegerNull() && !duplicateContactIds.ContainsKey(contactIdDb))
                                                        {
                                                            duplicateContactIds.Add(contactIdDb, new ContactDuplicateInfo
                                                                                                     {
                                                                                                         ContactId = contactIdDb,
                                                                                                         CreatedDate = DateTime.Now,
                                                                                                         DuplicateInfo = contactInfoDb,
                                                                                                         LevelId = ImportInfo.LevelId,
                                                                                                         ImportId = ImportInfo.ImportId,
                                                                                                         SourceTypeId = ImportInfo.TypeId,
                                                                                                         ContactInfo = new ContactInfo
                                                                                                                           {
                                                                                                                               Code = code,
                                                                                                                               Email = email,
                                                                                                                               Mobile1 = mobile,
                                                                                                                               Fullname = name,
                                                                                                                               ChannelId = channelId,
                                                                                                                               RegisteredDate = registeredDate,
                                                                                                                           }
                                                                                                     });
                                                        }
                                                    }
                                                    #endregion
                                                }
                                                break;
                                            default:
                                                {
                                                    #region create contact temp errors
                                                    var contactRow = dtContactTmps.NewRow();
                                                    var contactId = contactIdentity + rowIndex;
                                                    contactRow["Gender"] = 0;
                                                    contactRow["Email"] = email;
                                                    contactRow["Id"] = contactId;
                                                    contactRow["Fullname"] = name;
                                                    contactRow["Mobile1"] = mobile;
                                                    contactRow["Address"] = address;
                                                    contactRow["ChannelId"] = channelId;
                                                    contactRow["PackageId"] = packageId;
                                                    contactRow["CreatedDate"] = DateTime.Now;
                                                    contactRow["TypeId"] = ImportInfo.TypeId;
                                                    contactRow["LevelId"] = ImportInfo.LevelId;
                                                    contactRow["CampaindTpeId"] = campaindTpeId;
                                                    contactRow["LandingPageId"] = landingPageId;
                                                    contactRow["TemplateAdsId"] = templateAdsId;
                                                    contactRow["BranchId"] = ImportInfo.BranchId;
                                                    contactRow["ImportId"] = ImportInfo.ImportId;
                                                    contactRow["StatusId"] = (int)StatusType.New;
                                                    contactRow["RegisteredDate"] = registeredDate;
                                                    contactRow["UserImportId"] = ImportInfo.UserId;
                                                    contactRow["SearchKeywordId"] = searchKeywordId;
                                                    contactRow["ImportedDate"] = ImportInfo.ImportedDate;
                                                    contactRow["Code"] = code.IsStringNullOrEmpty() ? "TPE_" + contactId : code;
                                                    dtContactTmps.Rows.Add(contactRow);
                                                    #endregion
                                                }
                                                break;
                                        }
                                    }
                                    rowIndex++;
                                }
                            }
                        }

                        watch.Stop();
                        Console.WriteLine("Read file: " + watch.ElapsedMilliseconds);
                        watch.Reset();
                        watch.Restart();

                        // Import
                        ContactBulkImport.ImportContact(dtContacts, connection, transaction);
                        ContactBulkImport.ImportContactLevel(dtContactLevels, connection, transaction);
                        ContactBulkImport.ImportContactPhone(dtPhones, connection, transaction);
                        ContactBulkImport.ImportObjectChanges(dtObjectChanges, connection, transaction);
                        ContactBulkImport.ImportContactTmp(dtContactTmps);

                        watch.Stop();
                        Console.WriteLine("Import file: " + watch.ElapsedMilliseconds);

                        // Load redis
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        if (transaction != null)
                            transaction.Rollback(); // This will not reset IDENT_CURRENT
                    }
                    finally
                    {
                        // Update Duplicate
                        UpdateDuplicate();
                        // Update ImportStatus
                        ImportInfo.ImportStatus = 1;
                        ImportExcelRepository.Update(ImportInfo);

                        // Reload Redis
                        StaticData.LoadToRedis();
                    }
                }

                dtPhones = null;
                dtContacts = null;
                dtContactTmps = null;
                dtContactLevels = null;
                dtObjectChanges = null;
            }
            catch (Exception ex2)
            {
                Console.WriteLine(ex2.ToString());
            }
        }
Beispiel #5
0
        public static int LogCreateContactTvtsDuplicate(ContactInfo entity)
        {
            try
            {
                var log = new ActivityLogInfo
                {
                    FunctionId = entity.Id,
                    CreatedBy = UserRepository.GetCurrentUserInfo().UserID,
                    FunctionType = (int)LogFunctionType.CreateContactTvts,
                };
                log.Id = Create(log);

                LogObjectChange(entity, log, LogPropertyType.Contacts_User_Consultant);
                return log.Id;
            }
            catch
            {
            }
            return 0;
        }
Beispiel #6
0
 private static void LogObjectChange(ContactInfo entity, ActivityLogInfo log, params LogPropertyType[] types)
 {
     foreach (var type in types)
     {
         var logObject = new ActivityObjectChangeInfo
         {
             ActivityId = log.Id,
             ObjectId = entity.Id,
             PropertyType = (int)type,
             ObjectType = (int)LogObjectType.Contact,
         };
         switch (type)
         {
             case LogPropertyType.Contacts_User_Consultant:
                 logObject.PropertyValueInt = entity.UserConsultantId;
                 break;
             case LogPropertyType.Contacts_Type:
                 logObject.PropertyValueInt = entity.TypeId;
                 break;
             case LogPropertyType.Contacts_Level:
                 logObject.PropertyValueInt = entity.LevelId;
                 break;
             case LogPropertyType.Contacts_Channel:
                 logObject.PropertyValueInt = entity.ChannelId;
                 break;
             case LogPropertyType.Contacts_Branch:
                 logObject.PropertyValueInt = entity.BranchId;
                 break;
             case LogPropertyType.Contacts_Status:
                 logObject.PropertyValueInt = entity.StatusId;
                 break;
             case LogPropertyType.Contacts_AppointmentDate_Consultant:
                 logObject.PropertyValueDateTime = entity.AppointmentConsultantDate;
                 break;
             case LogPropertyType.Contacts_HandoverDate_Consultant:
                 logObject.PropertyValueDateTime = entity.HandoverConsultantDate;
                 break;
             case LogPropertyType.Contacts_CallDate_Consultant:
                 logObject.PropertyValueDateTime = entity.CallConsultantDate;
                 break;
             case LogPropertyType.Contacts_RecoveryDate_Consultant:
                 logObject.PropertyValueDateTime = entity.RecoveryConsultantDate;
                 break;
             case LogPropertyType.Contacts_StatusCare_Consultant:
                 logObject.PropertyValueInt = entity.StatusCareConsultantId;
                 break;
             case LogPropertyType.Contacts_StatusMap_Consultant:
                 logObject.PropertyValueInt = entity.StatusMapConsultantId;
                 break;
         }
         ActivityObjectChangeRepository.Create(logObject);
     }
 }
Beispiel #7
0
        public static int LogRecoveryContact(ContactInfo entity)
        {
            try
            {
                var log = new ActivityLogInfo
                {
                    FunctionId = entity.Id,
                    FunctionType = (int)LogFunctionType.RecoveryConsultant,
                    CreatedBy = UserRepository.GetCurrentUserInfo().UserID,
                };
                log.Id = Create(log);

                LogObjectChange(entity, log,
                                LogPropertyType.Contacts_Status,
                                LogPropertyType.Contacts_RecoveryDate_Consultant,
                                LogPropertyType.Contacts_AppointmentDate_Consultant);
                return log.Id;
            }
            catch
            {
            }
            return 0;
        }
Beispiel #8
0
 public static int Create(ActivityLogInfo info)
 {
     return DataProvider.Instance().ActivityLogs_Insert(info.FunctionId, info.FunctionType, info.CreatedBy, info.CreatedDate);
 }
Beispiel #9
0
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            var userCurent = UserContext.GetCurrentUser();
            if (userCurent != null)
            {
                ViewBag.GroupId = userCurent.GroupId;
                ViewBag.GroupType = userCurent.GroupConsultantType;
            }

            // 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 });

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

            // Group
            if (StoreData.ListGroup.IsNullOrEmpty()) StoreData.ListGroup = GroupRepository.GetAll() ?? new List<GroupInfo>();
            StoreData.ListGroup.RemoveAll(c => c.GroupId == 0);
            filterContext.Controller.ViewBag.Groups = StoreData.ListGroup;

            // User
            if (StoreData.ListUser.IsNullOrEmpty()) StoreData.ListUser = UserRepository.GetAll() ?? new List<UserInfo>();
            StoreData.ListUser.RemoveAll(c => c.UserID == 0);
            filterContext.Controller.ViewBag.Users = StoreData.ListUser;

            // Level
            if (StoreData.ListLevel.IsNullOrEmpty()) StoreData.ListLevel = LevelRepository.GetAll() ?? new List<LevelInfo>();
            StoreData.ListLevel.RemoveAll(c => c.LevelId == 0);
            filterContext.Controller.ViewBag.Levels = StoreData.ListLevel;

            // Branch
            if (StoreData.ListBranch.IsNullOrEmpty()) StoreData.ListBranch = BranchRepository.GetAll() ?? new List<BranchInfo>();
            StoreData.ListBranch.RemoveAll(c => c.BranchId == 0);
            filterContext.Controller.ViewBag.Branches = StoreData.ListBranch;

            // Channel
            if (StoreData.ListChannel.IsNullOrEmpty()) StoreData.ListChannel = ChannelRepository.GetAll() ?? new List<ChannelInfo>();
            StoreData.ListChannel.RemoveAll(c => c.ChannelId == 0);
            filterContext.Controller.ViewBag.Channels = StoreData.ListChannel;

            // Collector
            if (StoreData.ListCollector.IsNullOrEmpty()) StoreData.ListCollector = CollectorRepository.GetAll() ?? new List<CollectorInfo>();
            StoreData.ListCollector.RemoveAll(c => c.CollectorId == 0);
            filterContext.Controller.ViewBag.Collectors = StoreData.ListCollector;

            // StatusMap
            if (StoreData.ListStatusMap.IsNullOrEmpty()) StoreData.ListStatusMap = StatusMapRepository.GetAll() ?? new List<StatusMapInfo>();
            StoreData.ListStatusMap.RemoveAll(c => c.Id == 0);
            filterContext.Controller.ViewBag.StatusMaps = StoreData.ListStatusMap;

            // StatusCare
            if (StoreData.ListStatusCare.IsNullOrEmpty()) StoreData.ListStatusCare = CatalogRepository.GetAll<StatusCareInfo>() ?? new List<StatusCareInfo>();
            StoreData.ListStatusCare.RemoveAll(c => c.Id == 0);
            filterContext.Controller.ViewBag.StatusCares = StoreData.ListStatusCare;

            // SourceType
            if (StoreData.ListSourceType.IsNullOrEmpty()) StoreData.ListSourceType = SourceTypeRepository.GetAll() ?? new List<SourceTypeInfo>();
            StoreData.ListSourceType.RemoveAll(c => c.SourceTypeId == 0);
            filterContext.Controller.ViewBag.SourceTypes = StoreData.ListSourceType;

            //Email
            if (StoreData.ListEmail.IsNullOrEmpty()) StoreData.ListEmail = EmailRepository.GetAll() ?? new List<EmailInfo>();
            StoreData.ListEmail.RemoveAll(c => c.Id==0);
            filterContext.Controller.ViewBag.Email = StoreData.ListEmail;

            // EducationLevel
            if (StoreData.ListEducationLevel.IsNullOrEmpty()) StoreData.ListEducationLevel = EducationLevelRepository.GetAll() ?? new List<EducationLevelInfo>();
            StoreData.ListEducationLevel.RemoveAll(c => c.EducationLevelId == 0);
            filterContext.Controller.ViewBag.EducationLevels = StoreData.ListEducationLevel;

            // TimeSlot
            if (StoreData.ListTimeSlot.IsNullOrEmpty()) StoreData.ListTimeSlot = CatalogRepository.GetAll<TimeSlotInfo>() ?? new List<TimeSlotInfo>();
            StoreData.ListTimeSlot.RemoveAll(c => c.Id == 0);
            filterContext.Controller.ViewBag.TimeSlots = StoreData.ListTimeSlot;

            // TeacherType
            if (StoreData.ListTeacherType.IsNullOrEmpty()) StoreData.ListTeacherType = CatalogRepository.GetAll<TeacherTypeInfo>() ?? new List<TeacherTypeInfo>();
            StoreData.ListTeacherType.RemoveAll(c => c.Id == 0);
            filterContext.Controller.ViewBag.TeacherTypes = StoreData.ListTeacherType;

            // Container
            if (StoreData.ListContainer.IsNullOrEmpty()) StoreData.ListContainer = CatalogRepository.GetAll<ContainerInfo>() ?? new List<ContainerInfo>();
            StoreData.ListContainer.RemoveAll(c => c.Id == 0);
            filterContext.Controller.ViewBag.Containers = StoreData.ListContainer;

            // ImportExcel
            if (StoreData.ListImportExcel.IsNullOrEmpty()) StoreData.ListImportExcel = ImportExcelRepository.GetAll() ?? new List<ImportExcelInfo>();
            StoreData.ListImportExcel.RemoveAll(c => c.ImportId == 0);
            filterContext.Controller.ViewBag.ImportExcels = StoreData.ListImportExcel;

            // WebServiceConfig
            if (StoreData.ListWebServiceConfig.IsNullOrEmpty()) StoreData.ListWebServiceConfig = WebServiceConfigRepository.GetAll() ?? new List<WebServiceConfigInfo>();
            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 });

            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
            }
        }