Exemplo n.º 1
0
        public List <CasecAccountInfo> Provide(FormDataCollection form)
        {
            var contactId = form.Get("contactId").ToInt32();
            var list      = CasecAccountRepository.Provide(contactId);

            if (!list.IsNullOrEmpty())
            {
                foreach (var item in list)
                {
                    item.DateTimeString    = item.DateTime.ToString("dd/MM/yyyy");
                    item.CreatedDateString = item.CreatedDate.ToString("dd/MM/yyyy");
                    item.StatusString      = ObjectExtensions.GetEnumDescription((StatusCasecType)item.StatusCasecAccountId);

                    // Call WS
                    if (item.StatusCasecAccountId == (int)StatusCasecType.Used)
                    {
                        var result = (new HelpUtils()).SendCasecAccount(item);
                        if (result.Code == 0)
                        {
                            ContactLevelInfoRepository.UpdateHasCasecAccount(contactId, true);
                        }
                    }
                }
                return(list);
            }
            return(null);
        }
Exemplo n.º 2
0
        public CasecAccountInfo SelectCasecAccount()
        {
            var info  = CasecAccountRepository.SelectCasecAccount();
            var model = new CasecAccountInfo
            {
                ContactId = info.ContactId,
                Account   = info.Account,
                Password  = info.Password
            };

            //gọi link của CongNN truyền vào các tham số contactId, Account, Password trên

            return(model);
        }
Exemplo n.º 3
0
        public List <CasecAccountInfo> GetAllByContactId(int contactId)
        {
            var list = CasecAccountRepository.GetAllByContactId(contactId);

            if (!list.IsNullOrEmpty())
            {
                foreach (var item in list)
                {
                    item.DateTimeString    = item.DateTime.ToString("dd/MM/yyyy");
                    item.CreatedDateString = item.CreatedDate.ToString("dd/MM/yyyy");
                    item.StatusString      = ObjectExtensions.GetEnumDescription((StatusCasecType)item.StatusCasecAccountId);
                }
                return(list);
            }
            return(null);
        }
Exemplo n.º 4
0
        public ActionResult CasecAccountInfo(FormCollection forms, HttpPostedFileBase excelfile)
        {
            if (excelfile.FileName.EndsWith(".xls") || excelfile.FileName.EndsWith(".xlsx"))
            {
                var now          = DateTime.Now;
                var fullFileDir  = Server.MapPath("/UploadFileCasecAccount");
                var fullFilePath = Server.MapPath("/UploadFileCasecAccount/") + string.Format("{0}_{1}_{2}_{3}_{4}_{5}_", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + excelfile.FileName;
                if (!Directory.Exists(fullFileDir))
                {
                    Directory.CreateDirectory(fullFileDir);
                }
                excelfile.SaveAs(fullFilePath);

                List <CasecAccountInfo> list = new List <CasecAccountInfo>();
                list = CasecAccountRepository.GetAll();
                using (var stream = System.IO.File.Open(fullFilePath, FileMode.Open, FileAccess.Read))
                {
                    using (var dr = ExcelReaderFactory.CreateOpenXmlReader(stream))
                    {
                        while (dr.Read())
                        {
                            if (dr[0] != null)
                            {
                                string account  = dr[0].ToString();
                                string password = dr[1] == null ? string.Empty : dr[1].ToString();

                                bool check = list.Any(x => x.Account == account);
                                if (!check)
                                {
                                    CasecAccountRepository.Insert(account, password);
                                }
                            }
                        }
                    }
                }
                ViewBag.Message = "Update thêm tài khoản thành công,  vui lòng check lại số lượng tài khoản";
            }
            else
            {
                ViewBag.Message = "File ko đúng định dạng";
            }
            return(View());
        }
Exemplo n.º 5
0
        private ContactLevelInfoModel InitModel(ContactInfo contactInfo, ContactLevelInfo contactLevelInfo)
        {
            var model = new ContactLevelInfoModel
            {
                ContactInfo      = contactInfo,
                ContactLevelInfo = contactLevelInfo,
            };

            if (model.ContactLevelInfo != null)
            {
                // AppointmentTime
                if (model.ContactLevelInfo.AppointmentTime != null)
                {
                    model.AppointmentTime = model.ContactLevelInfo.AppointmentTime.Value.ToString("dd/MM/yyyy");
                }
            }

            if (model.ContactInfo != null)
            {
                // Phone
                var listPhone = PhoneRepository.GetByContact(contactInfo.Id);
                if (listPhone != null)
                {
                    model.ContactInfo.Mobile1 = listPhone.Count > 0 ? listPhone[0].PhoneNumber : string.Empty;
                    model.ContactInfo.Mobile2 = listPhone.Count > 1 ? listPhone[1].PhoneNumber : string.Empty;
                    model.ContactInfo.Mobile3 = listPhone.Count > 2 ? listPhone[2].PhoneNumber : string.Empty;
                }

                // Birthday
                if (model.ContactInfo.Birthday != null)
                {
                    model.Birthday = model.ContactInfo.Birthday.Value.ToString("dd/MM/yyyy");
                }
            }
            else
            {
                model.ContactInfo = new ContactInfo();
            }

            // StatusMaps
            List <StatusMapInfo> statusMaps;

            if (StoreData.ListStatusMap != null && StoreData.ListStatusMap.Count > 0)
            {
                statusMaps = model.ContactInfo == null
                                     ? StoreData.ListStatusMap
                                     : StoreData.ListStatusMap.Where(c => c.LevelId == model.ContactInfo.LevelId).ToList();
            }
            else
            {
                statusMaps = model.ContactInfo == null
                                         ? StatusMapRepository.GetAll()
                                         : StatusMapRepository.GetAllByLevelId(model.ContactInfo.LevelId);
            }
            ViewBag.StatusMaps = statusMaps != null && statusMaps.Count > 0
                                     ? statusMaps.Where(c => c.StatusMapType == (int)EmployeeType.Consultant).ToList()
                                     : new List <StatusMapInfo>();
            // CasecAccountInfo
            var casecAccounts = CasecAccountRepository.GetAllByContactId(contactLevelInfo.ContactId) ?? new List <CasecAccountInfo>();

            model.CasecAccountInfo = casecAccounts.FirstOrDefault(c => c.StatusCasecAccountId == (int)StatusCasecType.Used);
            model.ContactLevelInfo.HasCasecAccount       = model.CasecAccountInfo != null;
            model.ContactLevelInfo.HasCasecAccountHidden = model.ContactLevelInfo.HasCasecAccount;

            // TopicaAccountInfo
            var topicaAccounts = TopicaAccountRepository.GetAllByContactId(contactLevelInfo.ContactId) ?? new List <TopicaAccountInfo>();

            model.TopicaAccountInfo = topicaAccounts.FirstOrDefault(c => c.StatusTopicaAccountId == (int)StatusTopicaType.Used);
            model.ContactLevelInfo.HasTopicaAccount      = model.TopicaAccountInfo != null;
            model.ContactLevelInfo.HasCasecAccountHidden = model.ContactLevelInfo.HasTopicaAccount;

            // TestResultCasecInfo
            model.TestResultCasecInfo = TestResultRepository.GetResultCasecCurent(contactLevelInfo.ContactId);
            if (model.TestResultCasecInfo != null)
            {
                if (model.TestResultCasecInfo.FullName == null || model.TestResultCasecInfo.FullName == "")
                {
                    model.TestResultCasecInfo.FullName = model.ContactInfo.Fullname;
                }
                model.ContactLevelInfo.HasPointTestCasec = true;
                var casecAccount = casecAccounts.FirstOrDefault(c => c.Id == model.TestResultCasecInfo.CasecAccountId) ?? new CasecAccountInfo();
                model.TestResultCasecInfo.Account  = casecAccount.Account;
                model.TestResultCasecInfo.Password = casecAccount.Password;
            }
            else
            {
                model.ContactLevelInfo.HasPointTestCasec = false;
            }
            model.ContactLevelInfo.HasPointTestCasecHidden = model.ContactLevelInfo.HasPointTestCasec;

            // TestResultTopicaInfo
            model.TestResultTopicaInfo = TestResultRepository.GetResultTopicaCurent(contactLevelInfo.ContactId);
            if (model.TestResultTopicaInfo != null)
            {
                if (model.TestResultTopicaInfo.FullName == null || model.TestResultTopicaInfo.FullName == "")
                {
                    model.TestResultTopicaInfo.FullName = model.ContactInfo.Fullname;
                }
                model.ContactLevelInfo.HasPointTestTopica = true;
                var topicaAccount = topicaAccounts.FirstOrDefault(c => c.Account == model.TestResultTopicaInfo.Account) ?? new TopicaAccountInfo();
                model.TestResultTopicaInfo.Account  = topicaAccount.Account;
                model.TestResultTopicaInfo.Password = topicaAccount.Password;
            }
            else
            {
                model.ContactLevelInfo.HasPointTestTopica = false;
            }
            model.ContactLevelInfo.HasPointTestCasecHidden = model.ContactLevelInfo.HasPointTestTopica;

            // TestResultInterviewInfo
            model.TestResultInterviewInfo = TestResultRepository.GetResultInterviewCurent(contactLevelInfo.ContactId);
            if (model.TestResultInterviewInfo != null)
            {
                if (model.TestResultInterviewInfo.FullName == null || model.TestResultInterviewInfo.FullName == "")
                {
                    model.TestResultInterviewInfo.FullName = model.ContactInfo.Fullname;
                }
                model.ContactLevelInfo.HasPointInterview = true;
            }
            else
            {
                model.ContactLevelInfo.HasPointInterview = false;
            }
            model.ContactLevelInfo.HasPointInterviewHidden = model.ContactLevelInfo.HasPointInterview;

            // TestResultLinkSb100Info
            model.TestResultLinkSb100Info = TestResultRepository.GetResultLinkSb100Curent(contactLevelInfo.ContactId);

            return(model);
        }
Exemplo n.º 6
0
        public int CheckSumCasecAccount()
        {
            int count = CasecAccountRepository.CheckCountCasecRest();

            return(count);
        }