Example #1
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Configuration").ToInputLogString());
            try
            {
                _commonFacade = new CommonFacade();
                ConfigurationViewModel configurationVM = new ConfigurationViewModel();

                configurationVM.SearchFilter = new ConfigureUrlSearchFilter
                {
                    Status     = null,
                    SystemName = string.Empty,
                    Url        = string.Empty,
                    PageNo     = 1,
                    PageSize   = _commonFacade.GetPageSizeStart(),
                    SortField  = "ConfigureUrlId",
                    SortOrder  = "DESC"
                };

                var statusList = _commonFacade.GetStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                configurationVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

                ViewBag.PageSize     = configurationVM.SearchFilter.PageSize;
                ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                ViewBag.Message      = string.Empty;
                return(View(configurationVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Configuration").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #2
0
        public ActionResult List()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch ActivityLog").ToInputLogString());

            try
            {
                CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel();

                if (TempData["CustomerInfo"] != null)
                {
                    custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"];
                    TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab
                }
                else
                {
                    return(RedirectToAction("Search", "Customer"));
                }

                ActivityViewModel activityVM = new ActivityViewModel();
                if (custInfoVM.CustomerId != null)
                {
                    activityVM.CustomerInfo = custInfoVM;
                }

                _commonFacade   = new CommonFacade();
                _activityFacade = new ActivityFacade();

                var subsType = custInfoVM.SubscriptType;

                var today                  = DateTime.Today;
                var month                  = new DateTime(today.Year, today.Month, 1);
                var numMonthsActivity      = _commonFacade.GetNumMonthsActivity();
                var activityStartDateValue = month.AddMonths(-1 * numMonthsActivity); //"2015-01-01".ParseDateTime("yyyy-MM-dd");

                activityVM.SearchFilter = new ActivitySearchFilter
                {
                    ActivityStartDateTime = activityStartDateValue.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime),
                    ActivityEndDateTime   = DateTime.Now.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime),
                    CardNo       = custInfoVM.CardNo,
                    SubsTypeCode = subsType != null ? subsType.SubscriptTypeCode : null,
                    PageNo       = 1,
                    PageSize     = _commonFacade.GetPageSizeStart(),
                    SortField    = "ActivityID",
                    SortOrder    = "DESC"
                };

                ViewBag.PageSize     = activityVM.SearchFilter.PageSize;
                ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                ViewBag.Message      = string.Empty;

                return(View(activityVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch ActivityLog").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #3
0
        public string GetParameter(string paramName)
        {
            _commonFacade = new CommonFacade();
            ParameterEntity param = _commonFacade.GetCacheParamByName(paramName);

            return(param != null ? param.ParamValue : string.Empty);
        }
Example #4
0
        public ActionResult ConfigurationList(ConfigureUrlSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Configuration").Add("SystemName", searchFilter.SystemName)
                        .Add("Url", searchFilter.Url).Add("Status", searchFilter.Status));
            try
            {
                if (ModelState.IsValid)
                {
                    _commonFacade = new CommonFacade();
                    _configFacade = new ConfigurationFacade();
                    ConfigurationViewModel configVM = new ConfigurationViewModel();
                    configVM.SearchFilter = searchFilter;

                    configVM.ConfigureUrlList = _configFacade.GetConfigureURL(searchFilter);
                    ViewBag.PageSize          = configVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList      = _commonFacade.GetPageSizeList();
                    return(PartialView("~/Views/Configuration/_ConfigurationList.cshtml", configVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Configuration").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #5
0
        private int GetMaxRetrieveMail()
        {
            _commonFacade = new CommonFacade();
            ParameterEntity param = _commonFacade.GetCacheParamByName(Constants.ParameterName.MaxRetrieveMail);

            return(param != null?param.ParamValue.ToNullable <int>().Value : 200);
        }
Example #6
0
        public ActionResult MainMenu(string selectedMenu)
        {
            _commonFacade = new CommonFacade();
            int roleValue = this.UserInfo == null ? 0 : this.UserInfo.RoleValue;
            List <MenuEntity> mainMenu = _commonFacade.GetCacheMainMenu(selectedMenu, roleValue);

            return(PartialView("~/Views/MenuNavigator/MainMenu.cshtml", mainMenu));
        }
        private bool ValidateServiceRequest(Header requestHeader)
        {
            _commonFacade = new CommonFacade();
            string doNotCallProfilePath = _commonFacade.GetProfileXml("DoNotCallProfile");
            bool   valid = _commonFacade.VerifyServiceRequest <Header>(requestHeader, doNotCallProfilePath);

            return(valid);
        }
Example #8
0
        public ActionResult NewsList(NewsSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search News").Add("Topic", searchFilter.Topic).ToInputLogString());

            try
            {
                #region "Validation"

                bool isValid = TryUpdateModel(searchFilter);
                if (!string.IsNullOrEmpty(searchFilter.DateFrom) && !searchFilter.AnnounceDate.HasValue)
                {
                    isValid = false;
                    ModelState.AddModelError("txtFromDate", Resource.ValErr_InvalidDate);
                }
                if (!string.IsNullOrEmpty(searchFilter.DateTo) && !searchFilter.ExpiryDate.HasValue)
                {
                    isValid = false;
                    ModelState.AddModelError("txtToDate", Resource.ValErr_InvalidDate);
                }
                if (searchFilter.AnnounceDate.HasValue && searchFilter.ExpiryDate.HasValue &&
                    searchFilter.AnnounceDate.Value > searchFilter.ExpiryDate.Value)
                {
                    isValid = false;
                    ModelState.AddModelError("dvDateRange", Resource.ValErr_InvalidDateRange);
                }

                #endregion

                if (isValid)
                {
                    _newsFacade   = new NewsFacade();
                    _commonFacade = new CommonFacade();
                    NewsViewModel newsVM = new NewsViewModel();
                    newsVM.SearchFilter = searchFilter;

                    newsVM.NewsList      = _newsFacade.GetNewsList(newsVM.SearchFilter);
                    ViewBag.PageSize     = newsVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList = _commonFacade.GetPageSizeList();

                    Logger.Info(_logMsg.Clear().SetPrefixMsg("Search News").ToSuccessLogString());
                    return(PartialView("~/Views/News/_NewsList.cshtml", newsVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search News").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #9
0
        public ActionResult IndividualServiceRequestList(SrSearchFilter searchFilter)
        {
            try
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get IndividualServiceRequestList").Add("UserId", this.UserInfo.UserId)
                            .ToInputLogString());

                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();

                var lstEmployeeUser = new List <UserEntity>();

                // กรณีเลือก ทั้งหมด  FilterType จะมีค่าเป็น null
                if (searchFilter.FilterType == null)
                {
                    _userFacade     = new UserFacade();
                    lstEmployeeUser = _userFacade.GetEmployees(this.UserInfo);
                }

                lstEmployeeUser.Add(this.UserInfo); // add current user

                if (searchFilter.CurrentUserId != UserInfo.UserId)
                {
                    // First Load OR Change User
                    searchFilter.CurrentUserId    = UserInfo.UserId;
                    searchFilter.CanViewAllUsers  = null;
                    searchFilter.CanViewUserIds   = string.Empty;
                    searchFilter.CanViewSrPageIds = string.Empty;
                }

                if (searchFilter.CurrentUserRoleCode != UserInfo.RoleCode)
                {
                    // First Load OR Change Role
                    searchFilter.CurrentUserRoleCode = UserInfo.RoleCode;
                }

                HomeViewModel homeVM = new HomeViewModel();
                homeVM.IndividualSrSearchFilter           = searchFilter;
                homeVM.IndividualSrSearchFilter.OwnerList = lstEmployeeUser;

                homeVM.IndividualServiceRequestList = _customerFacade.GetSrList(homeVM.IndividualSrSearchFilter);
                ViewBag.IndyPageSize     = homeVM.IndividualSrSearchFilter.PageSize;
                ViewBag.IndyPageSizeList = _commonFacade.GetPageSizeList();

                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get IndividualServiceRequestList").ToSuccessLogString());
                return(PartialView("~/Views/Home/_IndividualServiceRequestList.cshtml", homeVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get IndividualServiceRequestList").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
        private bool ValidateInquireDoNotCallRequest(InquireDoNotCallRequest request, out string errorMessage)
        {
            bool validInput = false;

            errorMessage = string.Empty;
            StringBuilder error = new StringBuilder();

            if (request == null)
            {
                error.AppendLine("Request is null");
            }
            else
            {
                _commonFacade = new CommonFacade();
                bool hasAtLeastOneCriteria = request.CisId > 0 ||
                                             !string.IsNullOrWhiteSpace(request.CardNo) ||
                                             !string.IsNullOrWhiteSpace(request.SubscriptionTypeCode) ||
                                             !string.IsNullOrWhiteSpace(request.ProductCode) ||
                                             !string.IsNullOrWhiteSpace(request.PhoneNo) ||
                                             !string.IsNullOrWhiteSpace(request.Email);

                if (!hasAtLeastOneCriteria)
                {
                    error.AppendLine("Must insert at least one search criteria");
                }
                else
                {
                    // Card Info
                    bool hasCardNo           = !string.IsNullOrWhiteSpace(request.CardNo);
                    bool hasSubscriptionType = !string.IsNullOrWhiteSpace(request.SubscriptionTypeCode);
                    bool incompleteCardInfo  = hasCardNo ^ hasSubscriptionType;// exclusive-or: ONLY ONE condition is true
                    if (incompleteCardInfo)
                    {
                        error.AppendLine("Incomplete card info: missing CardNo or SubscriptionTypeCode");
                    }
                    // Total Limit
                    int  doNotCallUploadLimit = _commonFacade.GetDoNotCallUploadTotalRecord();
                    bool validLimitNumber     = request.DataLimit >= 1 && request.DataLimit <= doNotCallUploadLimit;
                    if (!validLimitNumber)
                    {
                        error.AppendLine($"Limit must be between 1 and {doNotCallUploadLimit.FormatNumber()} records");
                    }

                    validInput = validLimitNumber && !incompleteCardInfo;
                }
            }

            if (!validInput)
            {
                errorMessage = error.ToString();
            }

            return(validInput);
        }
Example #11
0
        public ActionResult List(int?customerId = null)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("List SR").ToInputLogString());

            try
            {
                CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel();
                ViewBag.userId = this.UserInfo.UserId;

                if (TempData["CustomerInfo"] != null)
                {
                    custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"];
                    TempData["CustomerInfo"] = custInfoVM; // keep for change Tab
                }
                else
                {
                    return(RedirectToAction("Search", "Customer"));
                }

                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();

                SrViewModel srVM = new SrViewModel();
                srVM.CustomerInfo = custInfoVM;

                if (custInfoVM.CustomerId.HasValue)
                {
                    // SR list
                    srVM.SearchFilter = new SrSearchFilter
                    {
                        CustomerId = custInfoVM.CustomerId.Value,
                        PageNo     = 1,
                        PageSize   = _commonFacade.GetPageSizeStart(),
                        SortField  = "CreateDate",
                        SortOrder  = "ASC"
                    };

                    //srVM.SrList = _customerFacade.GetSrList(srVM.SearchFilter);
                    ViewBag.PageSize     = srVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                    ViewBag.Message      = string.Empty;
                }

                return(View(srVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("List SR").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #12
0
        public ActionResult List(int?customerId = null)
        {
            try
            {
                CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel();

                if (TempData["CustomerInfo"] != null)
                {
                    custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"];
                    TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab
                }
                else
                {
                    return(RedirectToAction("Search", "Customer"));
                }

                Logger.Info(_logMsg.Clear().SetPrefixMsg("List Document").Add("CustomerId", custInfoVM.CustomerId).ToInputLogString());

                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();
                DocumentViewModel documentVM = new DocumentViewModel();
                documentVM.CustomerInfo = custInfoVM;

                if (custInfoVM.CustomerId.HasValue)
                {
                    // Attachment list
                    documentVM.SearchFilter = new AttachmentSearchFilter
                    {
                        CustomerId = custInfoVM.CustomerId.Value,
                        PageNo     = 1,
                        PageSize   = _commonFacade.GetPageSizeStart(),
                        SortField  = "ExpiryDate",
                        SortOrder  = "DESC"
                    };

                    documentVM.AttachmentList = _customerFacade.GetAttachmentList(documentVM.SearchFilter);
                    ViewBag.CurrentUserId     = this.UserInfo.UserId; // for check btnEdit btnDelete
                    ViewBag.PageSize          = documentVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList      = _commonFacade.GetPageSizeList();
                    ViewBag.Message           = string.Empty;
                }

                return(View(documentVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("List Customer").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #13
0
        public ActionResult SRActivityList(ActivitySearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR Activity").ToInputLogString());

            CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel();

            if (TempData["CustomerInfo"] != null)
            {
                custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"];
                TempData["CustomerInfo"] = custInfoVM; // keep for change Tab

                searchFilter.SrOnly     = false;
                searchFilter.CustomerId = custInfoVM.CustomerId;
            }
            else
            {
                return(RedirectToAction("Search", "Customer"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    _commonFacade   = new CommonFacade();
                    _activityFacade = new ActivityFacade();
                    ActivityViewModel activityVM = new ActivityViewModel();

                    activityVM.SearchFilter = searchFilter;
                    activityVM.ActivityList = _activityFacade.GetSRActivityList(searchFilter);

                    ViewBag.PageSize     = activityVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList = _commonFacade.GetPageSizeList();

                    Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Activity").ToSuccessLogString());
                    return(PartialView("~/Views/Activity/_ActivityList.cshtml", activityVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Activity").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #14
0
 public CheckUserRoleAttribute(string screenCode) : base()
 {
     try
     {
         _commonFacade    = new CommonFacade();
         this.AccessRoles = _commonFacade.GetRoleValueByScreenCode(screenCode);
     }
     catch (Exception ex)
     {
         Logger.Error("Exception occur:\n", ex);
         this.AccessRoles = 0;
     }
 }
Example #15
0
        public ActionResult List(string encryptedString)
        {
            int?customerId = encryptedString.ToCustomerId();

            Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").ToInputLogString());

            try
            {
                if (customerId == null)
                {
                    return(RedirectToAction("Search", "Customer"));
                }

                Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").Add("CustomerId", customerId).ToInputLogString());

                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();
                CustomerContactViewModel contactVM  = new CustomerContactViewModel();
                CustomerInfoViewModel    custInfoVM = this.MappingCustomerInfoView(customerId.Value);
                contactVM.CustomerInfo = custInfoVM;

                if (custInfoVM.CustomerId.HasValue)
                {
                    // Contact list
                    contactVM.SearchFilter = new ContactSearchFilter
                    {
                        CustomerId = custInfoVM.CustomerId.Value,
                        PageNo     = 1,
                        PageSize   = _commonFacade.GetPageSizeStart(),
                        SortField  = "CardNo",
                        SortOrder  = "ASC"
                    };

                    contactVM.ContactList = _customerFacade.GetContactList(contactVM.SearchFilter);
                    ViewBag.PageSize      = contactVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList  = _commonFacade.GetPageSizeList();
                    ViewBag.Message       = string.Empty;
                }

                return(View(contactVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #16
0
        public JsonResult LoadFileNewsAttachment(int attachmentId)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Load FileNewsAttachment").ToInputLogString());

            try
            {
                if (TempData["NewsAttachmentList"] != null)
                {
                    var lstNewsAttachment = (List <AttachmentEntity>)TempData["NewsAttachmentList"];
                    TempData["NewsAttachmentList"] = lstNewsAttachment; // keep for download
                    if (lstNewsAttachment != null)
                    {
                        AttachmentEntity selectedAttach = lstNewsAttachment.FirstOrDefault(x => x.AttachmentId == attachmentId);
                        TempData["FILE_DOWNLOAD"] = selectedAttach;

                        _commonFacade = new CommonFacade();
                        string documentFolder = _commonFacade.GetNewsDocumentFolder();
                        string pathFile       = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", documentFolder, selectedAttach.Url);

                        if (!System.IO.File.Exists(pathFile))
                        {
                            return(Json(new
                            {
                                Valid = false,
                                Error = "ไม่พบไฟล์ที่ต้องการ Download",
                                Errors = string.Empty
                            }));
                        }
                    }
                }

                return(Json(new
                {
                    Valid = true
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Load FileNewsAttachment").Add("Error Message", ex.Message).ToFailLogString());
                return(Json(new
                {
                    Valid = false,
                    Error = Resource.Error_System,
                    Errors = string.Empty
                }));
            }
        }
Example #17
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch AuditLog").ToInputLogString());
            try
            {
                _commonFacade   = new CommonFacade();
                _auditlogFacade = new AuditLogFacade();
                AuditLogViewModel auditlogVM = new AuditLogViewModel();

                auditlogVM.SearchFilter = new AuditLogSearchFilter
                {
                    FirstName = string.Empty,
                    LastName  = string.Empty,
                    DateFrom  = string.Empty,
                    DateTo    = string.Empty,
                    Module    = string.Empty,
                    Action    = string.Empty,
                    Status    = null,
                    PageNo    = 1,
                    PageSize  = _commonFacade.GetPageSizeStart(),
                    SortField = "AuditLogId",
                    SortOrder = "DESC"
                };

                var moduleList = _auditlogFacade.GetModule(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.Module = new SelectList((IEnumerable)moduleList, "Key", "Value", string.Empty);

                var actionList = _auditlogFacade.GetAction(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.Action = new SelectList((IEnumerable)actionList, "Key", "Value", string.Empty);

                var statusList = _auditlogFacade.GetStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.Status = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

                ViewBag.PageSize     = auditlogVM.SearchFilter.PageSize;
                ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                ViewBag.Message      = string.Empty;

                return(View(auditlogVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch AuditLog").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #18
0
        public ActionResult GroupServiceRequestList(SrSearchFilter searchFilter)
        {
            try
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get GroupServiceRequestList").Add("UserId", this.UserInfo.UserId).ToInputLogString());

                _userFacade     = new UserFacade();
                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();

                HomeViewModel homeVM = new HomeViewModel();
                homeVM.GroupSrSearchFilter = searchFilter;

                var lstDummyUser = _userFacade.GetDummyUsers(this.UserInfo);
                homeVM.GroupSrSearchFilter.OwnerList = lstDummyUser;

                if (searchFilter.CurrentUserId != UserInfo.UserId)
                {
                    // First Load OR Change User
                    searchFilter.CurrentUserId    = UserInfo.UserId;
                    searchFilter.CanViewAllUsers  = null;
                    searchFilter.CanViewUserIds   = string.Empty;
                    searchFilter.CanViewSrPageIds = string.Empty;
                }

                if (searchFilter.CurrentUserRoleCode != UserInfo.RoleCode)
                {
                    // First Load OR Change Role
                    searchFilter.CurrentUserRoleCode = UserInfo.RoleCode;
                }

                homeVM.GroupServiceRequestList = _customerFacade.GetSrList(homeVM.GroupSrSearchFilter);
                ViewBag.GroupPageSize          = homeVM.GroupSrSearchFilter.PageSize;
                ViewBag.GroupPageSizeList      = _commonFacade.GetPageSizeList();

                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get GroupServiceRequestList").ToSuccessLogString());
                return(PartialView("~/Views/Home/_GroupServiceRequestList.cshtml", homeVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get GroupServiceRequestList").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #19
0
        public ActionResult InitEditContactRelationship(string jsonData)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit ContactRelationship").Add("JsonContactRelationship", jsonData).ToInputLogString());

            try
            {
                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();
                var contactRelationVM = JsonConvert.DeserializeObject <ContactRelationshipViewModel>(jsonData);

                if (contactRelationVM.ListIndex != null)
                {
                    CustomerContactEntity selected =
                        contactRelationVM.ContactRelationshipList[contactRelationVM.ListIndex.Value];
                    contactRelationVM.AccountId      = selected.AccountId;
                    contactRelationVM.RelationshipId = selected.RelationshipId;
                    contactRelationVM.Product        = selected.Product;
                }

                if (contactRelationVM.CustomerId.HasValue)
                {
                    var listAccount = _customerFacade.GetAccountByCustomerId(contactRelationVM.CustomerId.Value);
                    TempData["AccountList"] = listAccount; // keep AccountList

                    contactRelationVM.AccountList = new SelectList((IEnumerable)listAccount.Select(x => new
                    {
                        key   = x.AccountId,
                        value = x.ProductAndAccountNoDisplay
                    }).ToDictionary(t => t.key, t => t.value), "Key", "Value", string.Empty);
                }

                // Get SelectList
                var lstRelationship = _commonFacade.GetRelationshipSelectList();
                TempData["RelationshipList"]       = lstRelationship; // Keep RelationshipList
                contactRelationVM.RelationshipList = new SelectList((IEnumerable)lstRelationship, "Key", "Value", string.Empty);

                return(PartialView("~/Views/Contact/_EditContactRelationship.cshtml", contactRelationVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit ContactRelationship").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #20
0
        public ActionResult CustomerSrList(SrSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR").Add("CustomerId", searchFilter.CustomerId)
                        .ToInputLogString());

            try
            {
                if (ModelState.IsValid)
                {
                    //ViewBag.userId = this.UserInfo.UserId;

                    _commonFacade   = new CommonFacade();
                    _customerFacade = new CustomerFacade();
                    _userFacade     = new UserFacade();
                    SrViewModel srVM = new SrViewModel();
                    srVM.SearchFilter = searchFilter;

                    srVM.SrList          = _customerFacade.GetSrList(srVM.SearchFilter);
                    ViewBag.PageSize     = srVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList = _commonFacade.GetPageSizeList();

                    // Set ViewBag.OwnerList
                    var lstEmployeeUser = _userFacade.GetEmployees(this.UserInfo);
                    lstEmployeeUser.Add(this.UserInfo);                                 // add current user
                    ViewBag.OwnerList = lstEmployeeUser.Select(x => x.UserId).ToList(); // for enabled btnEdit

                    Logger.Info(_logMsg.Clear().SetPrefixMsg("CustomerSrList").ToSuccessLogString());
                    return(PartialView("~/Views/SR/_CustomerSrList.cshtml", srVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #21
0
 private void Dispose(bool disposing)
 {
     if (!this._disposed)
     {
         if (disposing)
         {
             if (_context != null)
             {
                 _context.Dispose();
             }
             if (_commonFacade != null)
             {
                 _commonFacade.Dispose(); _commonFacade = null;
             }
         }
     }
     this._disposed = true;
 }
Example #22
0
        public JsonResult LoadFileAttachment()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Load FileAttachment").ToInputLogString());

            try
            {
                if (TempData["FILE_DOWNLOAD"] != null)
                {
                    AttachmentEntity selectedAttach = (AttachmentEntity)TempData["FILE_DOWNLOAD"];
                    TempData["FILE_DOWNLOAD"] = selectedAttach;

                    _commonFacade = new CommonFacade();
                    string documentFolder = selectedAttach.DocumentLevel == Constants.DocumentLevel.Customer ?
                                            _commonFacade.GetCSMDocumentFolder() : _commonFacade.GetSrDocumentFolder();
                    string pathFile = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", documentFolder, selectedAttach.Url);

                    if (!System.IO.File.Exists(pathFile))
                    {
                        return(Json(new
                        {
                            Valid = false,
                            Error = "ไม่พบไฟล์ที่ต้องการ Download",
                            Errors = string.Empty
                        }));
                    }
                }

                return(Json(new
                {
                    Valid = true
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Load FileAttachment").Add("Error Message", ex.Message).ToFailLogString());
                return(Json(new
                {
                    Valid = false,
                    Error = Resource.Error_System,
                    Errors = string.Empty
                }));
            }
        }
Example #23
0
        public ActionResult InitEdit(string jsonData)
        {
            _commonFacade = new CommonFacade();

            #region "For show in hint"

            ParameterEntity param = _commonFacade.GetCacheParamByName(Constants.ParameterName.RegexFileExt);
            ParameterEntity paramSingleFileSize = _commonFacade.GetCacheParamByName(Constants.ParameterName.SingleFileSize);

            int?limitSingleFileSize = paramSingleFileSize.ParamValue.ToNullable <int>();
            var singleLimitSize     = limitSingleFileSize.HasValue ? (limitSingleFileSize / 1048576) : 0;
            ViewBag.UploadLimitType = string.Format(CultureInfo.InvariantCulture, param.ParamDesc, singleLimitSize);

            #endregion

            List <DocumentTypeEntity> docTypeList = null;
            var attachVM = JsonConvert.DeserializeObject <AttachViewModel>(jsonData);

            if (attachVM.ListIndex != null)
            {
                AttachmentEntity selectedAttach = attachVM.AttachmentList[attachVM.ListIndex.Value];
                attachVM.Filename   = selectedAttach.Filename;
                attachVM.DocName    = selectedAttach.Name;
                attachVM.DocDesc    = selectedAttach.Description;
                attachVM.ExpiryDate = selectedAttach.ExpiryDateDisplay;
                docTypeList         = _commonFacade.GetDocumentTypeList(selectedAttach.AttachTypeList, Constants.DocumentCategory.Announcement);
            }
            else
            {
                docTypeList = _commonFacade.GetActiveDocumentTypes(Constants.DocumentCategory.Announcement);
            }

            if (docTypeList != null)
            {
                attachVM.DocTypeCheckBoxes = docTypeList.Select(x => new CheckBoxes
                {
                    Value   = x.DocTypeId.ToString(),
                    Text    = x.Name,
                    Checked = x.IsChecked
                }).ToList();
            }

            return(PartialView("~/Views/Attachment/_AttachEdit.cshtml", attachVM));
        }
Example #24
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Product").ToInputLogString());

            try
            {
                _commonFacade   = new CommonFacade();
                _commPoolFacade = new CommPoolFacade();

                var statusList = _commPoolFacade.GetSRStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.srstatus = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

                ProductViewModel productVM = new ProductViewModel();
                productVM.SearchFilter = new ProductSearchFilter
                {
                    ProductGroupId = null,
                    ProductId      = null,
                    CampaignId     = null,
                    TypeId         = null,
                    AreaId         = null,
                    SubAreaId      = null,
                    FromSRStatus   = null,
                    ToSRStatus     = null,
                    PageNo         = 1,
                    PageSize       = _commonFacade.GetPageSizeStart(),
                    SortField      = "ProductGroup",
                    SortOrder      = "DESC"
                };

                ViewBag.PageSize     = productVM.SearchFilter.PageSize;
                ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                ViewBag.Message      = string.Empty;

                return(View(productVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Product").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #25
0
        public ActionResult Index()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("List Configuration").ToInputLogString());

            try
            {
                _commonFacade      = new CommonFacade();
                ViewBag.MasterList = _commonFacade.GetMasterList(this.UserInfo.RoleValue);
                return(View());
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(
                    _logMsg.Clear().SetPrefixMsg("List Configuration").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #26
0
        public ActionResult List(string encryptedString)
        {
            int?customerId = encryptedString.ToCustomerId();

            Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("CustomerId", customerId).ToInputLogString());

            try
            {
                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();

                ExistingProductViewModel productVM  = new ExistingProductViewModel();
                CustomerInfoViewModel    custInfoVM = this.MappingCustomerInfoView(customerId.Value);
                productVM.CustomerInfo = custInfoVM;

                if (custInfoVM.CustomerId.HasValue)
                {
                    productVM.SearchFilter = new AccountSearchFilter
                    {
                        CustomerId = custInfoVM.CustomerId.Value,
                        PageNo     = 1,
                        PageSize   = _commonFacade.GetPageSizeStart(),
                        SortField  = "ProductGroup",
                        SortOrder  = "ASC"
                    };

                    productVM.AccountList = _customerFacade.GetAccountList(productVM.SearchFilter);
                    ViewBag.PageSize      = productVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList  = _commonFacade.GetPageSizeList();
                    ViewBag.Message       = string.Empty;
                }

                return(View(productVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #27
0
        public ActionResult SRActivityList(ActivitySearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR Activity").ToInputLogString());

            try
            {
                searchFilter.SrOnly = false;

                if (ModelState.IsValid)
                {
                    _commonFacade   = new CommonFacade();
                    _activityFacade = new ActivityFacade();
                    ActivityViewModel activityVM = new ActivityViewModel();

                    activityVM.SearchFilter = searchFilter;
                    activityVM.ActivityList = _activityFacade.GetSRActivityList(searchFilter);

                    activityVM.SearchFilter.IsConnect = 0;

                    ViewBag.PageSize     = activityVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList = _commonFacade.GetPageSizeList();

                    Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Activity").ToSuccessLogString());
                    return(PartialView("~/Views/Activity/_ActivityList.cshtml", activityVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Activity").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #28
0
        public ActionResult InitEdit(string campaignId, string campaignName, string contractNoRefer)
        {
            CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel();

            if (TempData["CustomerInfo"] != null)
            {
                custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"];
                TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab
            }
            else
            {
                return(RedirectToAction("Search", "Customer"));
            }

            CampaignViewModel campaignVM = new CampaignViewModel();

            campaignVM.FirstName       = custInfoVM.FirstName;
            campaignVM.LastName        = custInfoVM.LastName;
            campaignVM.CustomerType    = custInfoVM.CustomerType;
            campaignVM.CardNo          = custInfoVM.CardNo;
            campaignVM.Email           = custInfoVM.Email;
            campaignVM.CampaignId      = campaignId;
            campaignVM.CampaignName    = campaignName;
            campaignVM.CustomerType    = custInfoVM.CustomerType;
            campaignVM.ChannelId       = this.UserInfo.ChannelId;
            campaignVM.ChannelName     = this.UserInfo.ChannelName;
            campaignVM.ContractNoRefer = contractNoRefer;

            if (custInfoVM.PhoneList != null && custInfoVM.PhoneList.Count > 0)
            {
                campaignVM.PhoneNo = custInfoVM.PhoneList[0].PhoneNo;
            }

            _commonFacade = new CommonFacade();
            var customerTypeList = _commonFacade.GetCustomerTypeSelectList();

            campaignVM.CustomerTypeList = new SelectList((IEnumerable)customerTypeList, "Key", "Value", string.Empty);

            return(PartialView("~/Views/Campaign/_CampaignEdit.cshtml", campaignVM));
        }
Example #29
0
        public ActionResult ProductList(ProductSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Product").Add("ProductGroup", searchFilter.ProductGroupId)
                        .Add("Product", searchFilter.ProductId).Add("Campaign", searchFilter.CampaignId).Add("Type", searchFilter.TypeId)
                        .Add("Area", searchFilter.AreaId).Add("SubArea", searchFilter.SubAreaId).Add("FromSRStatus", searchFilter.FromSRStatus)
                        .Add("ToSRStatus", searchFilter.ToSRStatus));

            try
            {
                if (ModelState.IsValid)
                {
                    _commonFacade  = new CommonFacade();
                    _productFacade = new ProductFacade();

                    ProductViewModel productVM = new ProductViewModel();
                    productVM.SearchFilter = searchFilter;

                    productVM.ProductList = _productFacade.SearchProducts(searchFilter);
                    ViewBag.PageSize      = productVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList  = _commonFacade.GetPageSizeList();

                    return(PartialView("~/Views/Product/_ProductList.cshtml", productVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Product").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Example #30
0
        public ActionResult InitEdit(int?customerId, string campaignId, string campaignName, string contractNoRefer)
        {
            if (customerId == null)
            {
                return(Json(new
                {
                    Valid = false,
                    RedirectUrl = Url.Action("Search", "Customer")
                }));
            }

            CustomerInfoViewModel custInfoVM = this.MappingCustomerInfoView(customerId.Value);
            CampaignViewModel     campaignVM = new CampaignViewModel();

            campaignVM.FirstName       = custInfoVM.FirstName;
            campaignVM.LastName        = custInfoVM.LastName;
            campaignVM.CustomerType    = custInfoVM.CustomerType;
            campaignVM.CardNo          = custInfoVM.CardNo;
            campaignVM.Email           = custInfoVM.Email;
            campaignVM.CampaignId      = campaignId;
            campaignVM.CampaignName    = campaignName;
            campaignVM.CustomerType    = custInfoVM.CustomerType;
            campaignVM.ChannelId       = this.UserInfo.ChannelId;
            campaignVM.ChannelName     = this.UserInfo.ChannelName;
            campaignVM.ContractNoRefer = contractNoRefer;

            if (custInfoVM.PhoneList != null && custInfoVM.PhoneList.Count > 0)
            {
                campaignVM.PhoneNo = custInfoVM.PhoneList[0].PhoneNo;
            }

            _commonFacade = new CommonFacade();
            var customerTypeList = _commonFacade.GetCustomerTypeSelectList();

            campaignVM.CustomerTypeList = new SelectList((IEnumerable)customerTypeList, "Key", "Value", string.Empty);

            return(PartialView("~/Views/Campaign/_CampaignEdit.cshtml", campaignVM));
        }