public ActionResult CCL2() { var collectors = CollectorRepository.GetAll(); collectors.Insert(0, new Domain.Collectors.CollectorInfo { CollectorId = 0, Name = "Tất cả" }); ViewBag.Collectors = collectors; var channels = ChannelRepository.GetAll(); channels.Insert(0, new Domain.Channels.ChannelInfo { ChannelId = 0, Name = "Tất cả" }); ViewBag.Channels = channels; var imports = ImportExcelRepository.GetAll(); foreach (Domain.ImportExcels.ImportExcelInfo info in imports) { if (!string.IsNullOrEmpty(info.FilePath)) { int index = info.FilePath.LastIndexOf("\\"); if (index > -1) { info.FilePath = info.FilePath.Substring(index); } } } imports.Insert(0, new Domain.ImportExcels.ImportExcelInfo { ImportId = 0, FilePath = "Tất cả" }); ViewBag.ImportExcels = imports; return(View()); }
//Lay danh sach CC public ActionResult CCL0() { // Collectors var collectors = CollectorRepository.GetAll(); ViewBag.Collectors = collectors; // LevelCCs ViewBag.LevelCCs = StoreData.ListLevel.Where(x => x.LevelId < 3).ToList(); // ChannelCCs var channels = ChannelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.CC); ViewBag.ChannelCCs = channels; // ImportExcelCCs var importExcels = ImportExcelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.CC); foreach (var item in importExcels) { item.FilePath = (new FileInfo(item.FilePath)).Name; } ViewBag.ImportExcelCCs = importExcels; return(View()); }
public ActionResult Upload(FormCollection forms, HttpPostedFileBase excelfile) { #region "Start Checkpoint" CheckPointApi checkPointApi = new CheckPointApi(); var watch = new Stopwatch(); watch.Start(); checkPointApi.CheckPointNew(UserContext.GetCurrentUser().UserName, "ImportExcel", "Start", 0); #endregion //ViewBag.Filename = fileUpload.FileName; if (excelfile.FileName.EndsWith(".xls") || excelfile.FileName.EndsWith(".xlsx")) { var importInfo = new ImportExcelInfo { UserId = UserContext.GetCurrentUser().UserID, Status = ConvertHelper.ToInt32(forms["Status"]), LevelId = ConvertHelper.ToInt32(forms["LevelId"]), BranchId = ConvertHelper.ToInt32(forms["BranchId"]), ChannelId = ConvertHelper.ToInt32(forms["ChannelId"]), TypeId = ConvertHelper.ToInt32(forms["SourceTypeId"]), CollectorId = ConvertHelper.ToInt32(forms["CollectorId"]), }; var now = DateTime.Now; var fullFileDir = Server.MapPath("/Uploads"); var fullFilePath = Server.MapPath("/Uploads/") + 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); importInfo.TotalRow = 0; importInfo.CheckCount = 0; importInfo.ErrorCount = 0; importInfo.DuplicateCount = 0; importInfo.FilePath = fullFilePath; importInfo.ImportedDate = DateTime.Now; var id = ImportExcelRepository.Create(importInfo); var socketClient = new SocketClient("localhost", Constant.PortImportExcel); socketClient.SendMessage(id.ToString()); ViewBag.Message = id; } else { ViewBag.Message = "InvalidFileFormat"; } #region "End CheckPoint" watch.Stop(); checkPointApi.CheckPointNew(UserContext.GetCurrentUser().UserName, "ImportExcel", "End", watch.ElapsedMilliseconds); #endregion return(View()); }
// GET api/<controller>/5 public ImportExcelModel Get(int id) { var info = ImportExcelRepository.GetInfo(id); var retVal = ImportExcelModel.FromInfo(info); if (retVal.ImportStatus.HasValue && retVal.ImportStatus == 1) { //StoreData.LoadData(); StoreData.LoadImportExcel(); } return(retVal); }
// GET api/<controller> public ImportExcelListModel Get(int page, int rows) { int totalRecords; var model = new ImportExcelListModel { Rows = ImportExcelRepository.Search(string.Empty, page, rows, out totalRecords), Page = page, Total = (totalRecords / rows) + 1, Records = rows }; return(model); }
public ActionResult FilterContactHandover() { // Check account user form var status = StoreData.CheckAccountUseHandover(EmployeeType.Consultant); // ImportExcelCCs var importExcels = ImportExcelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.CC); foreach (var item in importExcels) { item.FilePath = (new FileInfo(item.FilePath)).Name; } ViewBag.Channels = ChannelRepository.GetAll(); ViewBag.ImportExcelCCs = importExcels; ViewBag.StatusMessage = status; ViewBag.StatusCares = StatusCareRepository.GetAll(); ViewBag.StatusMaps = StatusMapRepository.GetAll(); return(View(new ContactCreateModel())); }
public ActionResult DuplicateMOContainer() { // Collectors var collectors = CollectorRepository.GetAll(); ViewBag.Collectors = collectors; // ChannelMOs var channels = ChannelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.MO); ViewBag.ChannelMOs = channels; // ImportExcelMOs var importExcels = ImportExcelRepository.FilterForMOLContainer(UserContext.GetDefaultBranch(), 0); foreach (var item in importExcels) { item.FilePath = (new FileInfo(item.FilePath)).Name; } ViewBag.ImportExcelMOs = importExcels; return(View()); }
public ActionResult FilterContactForImporter() { var statusConnectTypes = new Dictionary <int, string>(); foreach (var item in Enum.GetValues(typeof(StatusConnectType))) { statusConnectTypes.Add((int)item, ObjectExtensions.GetEnumDescription((StatusConnectType)item)); } ViewBag.StatusConnectTypes = statusConnectTypes.Select(c => new { Id = c.Key, Name = c.Value }); var importExcels = ImportExcelRepository.FilterForCampain(UserContext.GetDefaultBranch()); foreach (var item in importExcels) { item.FilePath = (new FileInfo(item.FilePath)).Name; } ViewBag.ImportExcels = importExcels; var channelCCs = ChannelRepository.FilterForCampain(UserContext.GetDefaultBranch()); ViewBag.ChannelCCs = channelCCs; return(View()); }
/// <summary> /// Thread method that does the communication to the client. This /// thread tries to receive from client and if client sends any data /// then parses it and again wait for the client data to come in a /// loop. The recieve is an indefinite time receive. /// </summary> private void SocketListenerThreadStart() { m_lastReceiveDateTime = DateTime.Now; m_currentReceiveDateTime = DateTime.Now; var t = new Timer(CheckClientCommInterval, null, 15000, 15000); while (!m_stopClient) { try { var networkStream = new NetworkStream(m_clientSocket); var streamReader = new StreamReader(networkStream); var importId = ConvertHelper.ToInt32(streamReader.ReadLine()); var importInfo = ImportExcelRepository.GetInfo(importId); if (importInfo == null) { continue; } var importProcess = new ImportProcess(importInfo); var thread = new Thread(StartImport); thread.Start(importProcess); //size = m_clientSocket.Receive(byteBuffer); //m_currentReceiveDateTime = DateTime.Now; //ParseReceiveBuffer(byteBuffer, size); //Console.WriteLine(m_oneLineBuf.ToString()); } catch { m_stopClient = true; m_markedForDeletion = true; } } t.Change(Timeout.Infinite, Timeout.Infinite); }
private void StartQueueImport() { while (!stopFlag) { var importId = 0; Monitor.Enter(Messages.SyncRoot); if (Messages.Count > 0) { importId = ConvertHelper.ToInt32(Messages.Dequeue()); } Monitor.Exit(Messages.SyncRoot); var importInfo = ImportExcelRepository.GetInfo(importId); if (importInfo != null) { var importProcess = new ImportProcess(importInfo); var t = new Thread(importProcess.Start); t.Start(); Console.WriteLine(importInfo.FilePath); } Thread.Sleep(10); } }
public string Edit(FormDataCollection form) { var retVal = string.Empty; var operation = form.Get("oper"); var id = ConvertHelper.ToInt32(form.Get("ImportExcelId")); if (!string.IsNullOrEmpty(operation)) { ImportExcelInfo info; switch (operation) { case "edit": info = ImportExcelRepository.GetInfo(id); if (info != null) { /* * * info.ImportId = form.Get("ImportId"); * * info.UserId = form.Get("UserId"); * * info.TypeId = form.Get("TypeId"); * * info.ChannelId = form.Get("ChannelId"); * * info.CollectorId = form.Get("CollectorId"); * * info.BranchId = form.Get("BranchId"); * * info.Status = form.Get("Status"); * * info.FilePath = form.Get("FilePath"); * * info.TotalRow = form.Get("TotalRow"); * * info.CheckCount = form.Get("CheckCount"); * * info.ErrorCount = form.Get("ErrorCount"); * * info.DuplicateCount = form.Get("DuplicateCount"); * * info.ImportedDate = form.Get("ImportedDate"); * * ImportExcelRepository.Update(info); */ } break; case "add": info = new ImportExcelInfo(); /* * * info.ImportId = form.Get("ImportId"); * * info.UserId = form.Get("UserId"); * * info.TypeId = form.Get("TypeId"); * * info.ChannelId = form.Get("ChannelId"); * * info.CollectorId = form.Get("CollectorId"); * * info.BranchId = form.Get("BranchId"); * * info.Status = form.Get("Status"); * * info.FilePath = form.Get("FilePath"); * * info.TotalRow = form.Get("TotalRow"); * * info.CheckCount = form.Get("CheckCount"); * * info.ErrorCount = form.Get("ErrorCount"); * * info.DuplicateCount = form.Get("DuplicateCount"); * * info.ImportedDate = form.Get("ImportedDate"); * */ ImportExcelRepository.Create(info); break; case "del": ImportExcelRepository.Delete(id); break; } } return(retVal); }
// GET api/<controller> public IEnumerable <ImportExcelInfo> Get() { return(ImportExcelRepository.GetAll()); }
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); var contactDuplicateIdentity = GetIdentity("ContactDuplicates", connection, transaction); using (var stream = File.Open(file, FileMode.Open, FileAccess.Read)) { using (var dr = ExcelReaderFactory.CreateOpenXmlReader(stream)) { //Log bat dau tu 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++; Console.WriteLine("Duplicated in INTERNAL FILE with Mobile: " + mobile + "; \tEmail: " + email + "; \t\t\t\tImportId: " + ImportInfo.ImportId + "; \tImportDate:" + ImportInfo.ImportedDate + "; \tUserImportId:" + ImportInfo.UserId); } else { //If not internal duplicate, add to hashtable data //int check_db_idcts; if (!string.IsNullOrEmpty(email)) { internalPhoneAndEmails.Add(email); } if (!string.IsNullOrEmpty(mobile)) { internalPhoneAndEmails.Add(mobile); } //int check_dulicated; var check = CheckDuplicateProvider.Instance().IsDuplicate(mobile, string.Empty, string.Empty, email, string.Empty, out contactIdDb, out contactInfoDb); //check_db_idcts = ContactRepository.ContactIsDuplicate(mobile, string.Empty, string.Empty, email, string.Empty); //if (check_db_idcts != 0) //{ // check = true; //} //if (!check) //{ // check_dulicated = ContactRepository.ContactIsDuplicate(mobile, string.Empty, string.Empty, email, string.Empty); // if (check_dulicated != 0) check = true; //} if (check) { ImportInfo.DuplicateCount++; contactTmpStatus = (int)ContactError.Duplicate; Console.WriteLine("Duplicated in REDIS CACHE with Mobile: " + mobile + "; \tEmail: " + email + "; \t\t\t\tImportId: " + ImportInfo.ImportId + "; \tImportDate:" + ImportInfo.ImportedDate + "; \tUserImportId:" + ImportInfo.UserId); } } } ImportInfo.CheckCount++; #endregion switch (contactTmpStatus) { case (int)ContactError.None: { #region create contact row // string sTypeId = "01"; //Nguon contact: MO, CC ... 01 la MO if (ImportInfo.TypeId == 3) { sTypeId = "02"; } else if (ImportInfo.TypeId == 4) { sTypeId = "01"; } else if (ImportInfo.TypeId == 5) { sTypeId = "03"; } else if (ImportInfo.TypeId == 6) { sTypeId = "04"; } else if (ImportInfo.TypeId == 8) { sTypeId = "05"; } else if (ImportInfo.TypeId == 9) { sTypeId = "06"; } else if (ImportInfo.TypeId == 10) { sTypeId = "07"; } else if (ImportInfo.TypeId == 11) { sTypeId = "08"; } else { sTypeId = "09"; } var contactId = contactIdentity + rowIndex; var sCode = DateTime.Now.ToString("yyyyMMdd") + sTypeId + contactId.ToString(); 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"] = ImportInfo.Status; //(int)StatusType.New; // HungNV: 18/05/2020 Trường hợp kho 1-6 cần điều kiện container để phân biệt lúc thu hồi contactRow["ContainerId"] = ImportInfo.Status; contactRow["RegisteredDate"] = registeredDate; contactRow["UserImportId"] = ImportInfo.UserId; contactRow["SearchKeywordId"] = searchKeywordId; contactRow["ImportedDate"] = ImportInfo.ImportedDate; contactRow["Code"] = code.IsStringNullOrEmpty() ? sCode : 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); } //Them Mobile vs Email cua moi contact vao cache Redis //CachingProvider.Instance().Set(mobile, contactId.ToString()); //CachingProvider.Instance().Set(email, contactId.ToString()); //list_phone_email_redis.Add(Constant.NameSystem + mobile, contactId.ToString()); //list_phone_email_redis.Add(Constant.NameSystem + email, contactId.ToString()); #endregion //Nếu import vào kho MOL thì save log vào bảng LogContainerMOL #region create log contact kho MOL if (ImportInfo.Status == (int)StatusType.ContainerMOL) { var logContainerMOL = dtLogContainerMOL.NewRow(); logContainerMOL["CreatedDate"] = DateTime.Now; logContainerMOL["StatusContainerType"] = (int)StatusContainerTypeMOL.ImportContainer; logContainerMOL["StatusAddContact"] = (int)StatusAddContact.ImportContact; logContainerMOL["StatusContactFirst"] = ImportInfo.Status; logContainerMOL["StatusContactAfter"] = null; logContainerMOL["ContactId"] = contactId; logContainerMOL["ChannelId"] = channelId; dtLogContainerMOL.Rows.Add(logContainerMOL); } #endregion } break; case (int)ContactError.Duplicate: { #region create contact duplicate var sourceTypes = StaticData.GetSourceTypeCheckDuplicate(); if (!sourceTypes.IsNullOrEmpty() && sourceTypes.Any(c => c.SourceTypeId == ImportInfo.TypeId)) { var contactDuplicateRow = dtContactDuplicate.NewRow(); var contact = ContactRepository.GetInfo(contactIdDb); //update chuyen trang thai contact neu trung chuyen sang kho trung ContactRepository.UpdateChangeStatusId(contactIdDb); int idContactDuplicate = contactDuplicateIdentity + rowIndex; contactDuplicateRow["Id"] = idContactDuplicate; contactDuplicateRow["ContactId"] = contactIdDb; contactDuplicateRow["SourceTypeId"] = ImportInfo.TypeId; contactDuplicateRow["Status"] = contact != null ? contact.StatusId: 0; contactDuplicateRow["ImportId"] = ImportInfo.ImportId; contactDuplicateRow["DuplicateInfo"] = contactInfoDb; contactDuplicateRow["CreatedDate"] = DateTime.Now; contactDuplicateRow["IsNotyfiDuplicate"] = true; dtContactDuplicate.Rows.Add(contactDuplicateRow); } #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; // HungNV: 18/05/2020 Trường hợp kho 1-6 cần điều kiện container để phân biệt lúc thu hồi contactRow["ContainerId"] = ImportInfo.Status; 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(""); Console.WriteLine("Thoi gian read file: " + watch.ElapsedMilliseconds); watch.Reset(); watch.Restart(); dtPhones = RemoveDuplicateRows(dtPhones, "PhoneNumber"); // Import ContactBulkImport.ImportContactPhone(dtPhones, connection, transaction); ContactBulkImport.ImportContact(dtContacts, connection, transaction); ContactBulkImport.ImportContactLevel(dtContactLevels, connection, transaction); ContactBulkImport.ImportObjectChanges(dtObjectChanges, connection, transaction); ContactBulkImport.ImportContactTmp(dtContactTmps); ContactBulkImport.ImportContactDuplicate(dtContactDuplicate, connection, transaction); //Log table LogContainerMOL phuc vu bao cao xuat nhap kho MOL ContactBulkImport.ImportLogContainerMOL(dtLogContainerMOL, connection, transaction); watch.Stop(); Console.WriteLine("Thoi gian Import file: " + watch.ElapsedMilliseconds); Console.WriteLine("Bat dau commit"); transaction.Commit(); Console.WriteLine("Commit thanh cong"); ImportInfo.ImportStatus = 1; } catch (Exception ex) { Console.WriteLine(ex.Message); if (transaction != null) { Console.WriteLine("Commit ko thanh cong. Dang rollback lai"); ImportInfo.ImportStatus = 2; transaction.Rollback(); // This will not reset IDENT_CURRENT } } finally { // Update Duplicate Console.WriteLine("Bat dau vao finally."); UpdateDuplicate(); //ImportInfo.ImportStatus = 1; ImportExcelRepository.Update(ImportInfo); // Load redis if (ImportInfo.ImportStatus == 1) { Console.WriteLine("Update xong trang thai ImportExcel. Bat dau load Redis."); StaticData.LoadToRedis(); Console.WriteLine("Load xong redis"); } } } dtPhones = null; dtContacts = null; dtContactTmps = null; dtContactLevels = null; dtObjectChanges = null; } catch (Exception ex2) { Console.WriteLine(ex2.ToString()); } }