public List <CMS_MarketingModels> Import(string filePath, string empId, string empName, string empphone, ref string msg) { using (var cxt = new CMS_Context()) { List <CMS_MarketingModels> listMessage = new List <CMS_MarketingModels>(); try { DataTable dtMarketing = _baseFactory.GetDataFromExcel(@filePath, 1); //DataTable dtTime = _baseFactory.GetDataFromExcel(@filePath, 2); decimal rate = GetSMSRate(cxt, (int)Commons.ConfigType.SMSMarketing); for (int i = 0; i < dtMarketing.Rows.Count; i++) { string phone = Convert.ToString(dtMarketing.Rows[i][0]); string smsContent = Convert.ToString(dtMarketing.Rows[i][1]); string subPhone = phone.Substring(0, 2); string subPhone1 = phone.Substring(0, 1); if (!subPhone.Equals("84") && !subPhone1.Equals("0")) { phone = "84" + phone; } if (!string.IsNullOrEmpty(phone)) { string smsConvert = Commons.ConvertUnicodeToWithoutAccent(smsContent); int count2 = smsConvert.Length; int smsFee = count2 / 80; // < 80 = 1sms CMS_MarketingModels model = new CMS_MarketingModels() { CustomerId = empId, CustomerName = string.Format("{0} ({1})", empName, empphone), CountMessage = count2, SendTo = phone, SMSContent = smsContent, SMSType = (int)Commons.SMSType.Marketing, Status = (int)Commons.SMSStatus.Sent, SMSPrice = (smsFee + 1) * rate, SMSRate = rate }; listMessage.Add(model); } } } catch (Exception ex) { NSLog.Logger.Error("Import marketing error: ", ex); } finally { cxt.Dispose(); } return(listMessage); } }