/// <summary> /// Send SR_Request to only Requestor /// </summary> /// <param name="srId"></param> /// <param name="type"></param> public static void SendSRMailFromPortal(int srId, int type) { // Get body detail SR_ServiceRequest obj = new ServiceRequestDao().GetById(srId); //WFRole role = null; if (obj == null) { return; } string from_email = ConfigurationManager.AppSettings["from_email"]; string host = ConfigurationManager.AppSettings["mailserver_host"]; string port = ConfigurationManager.AppSettings["mailserver_port"]; string poster = "Service Request"; string subject = string.Empty; switch (type) { case Constants.SR_SEND_MAIL_COMMENT: subject = "[CRM-SR] " + Constants.SR_SERVICE_REQUEST_PREFIX + obj.ID + " has been modified"; break; default: if (obj.StatusID == Constants.SR_STATUS_CLOSED) { subject = "[CRM-SR] " + Constants.SR_SERVICE_REQUEST_PREFIX + obj.ID + " has been closed"; } else { subject = "[CRM-SR] " + Constants.SR_SERVICE_REQUEST_PREFIX + obj.ID + " has been forwarded to " + obj.AssignUser; } break; } string body = CreateBodyOfEmail(obj); // string requestorBody = CreateRequestorBodyOfEmail(obj); string to_email = string.Empty; string cc_email = string.Empty; string[] arrIds = new string[] { }; arrIds = obj.InvolveUser.Split(Constants.SEPARATE_INVOLVE_CHAR); List<string> sendList = new List<string>(); List<string> duplicateEmail = new List<string>(); for (int i = 0; i < arrIds.Length - 1; i++) { //check duplicate person on user name if (!sendList.Contains(arrIds[i])) { sendList.Add(arrIds[i]); if (obj.StatusID == Constants.SR_STATUS_CLOSED) //If an email has "Close" status, just only send by "To" section, not cc { if (!duplicateEmail.Contains(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";")) { // only send survey email to SubmitUser if (i == 0) { string surveyBody = CreateSurveyBodyEmail(obj); string survey_email = arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; WebUtils.SendMail(host, port, from_email, poster, survey_email, cc_email, subject, surveyBody); } else to_email += arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; duplicateEmail.Add(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); } } else { //Just send by "To" section only to person who has been assigned, the involved others are by "CC" section. if (string.IsNullOrEmpty(to_email)) { to_email = obj.AssignUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; cc_email = arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; duplicateEmail.Add(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); duplicateEmail.Add(obj.AssignUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email = obj.RequestUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; duplicateEmail.Add(obj.RequestUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); } else //make a cc list mail send. { if (!duplicateEmail.Contains(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";")) { duplicateEmail.Add(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email += arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } } } if (!string.IsNullOrEmpty(obj.CCList)) { string[] array = obj.CCList.Split(';'); foreach (string item in array) { if (!string.IsNullOrEmpty(item)) { string userAdminID = item; if (!duplicateEmail.Contains(item + Constants.LOGIGEAR_EMAIL_DOMAIN + ";")) { duplicateEmail.Add(item + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email += item + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } } #region Get default email from routing page ServiceRequestDao srDao = new ServiceRequestDao(); EmployeeDao emplDao = new EmployeeDao(); SRSettingDao srSettingDao = new SRSettingDao(); SR_Setting srSetting = new SR_Setting(); string bcc_email = String.Empty; string[] aTo = new string[] { }; string[] aCc = new string[] { }; string[] aBcc = new string[] { }; string locationCode = (emplDao.GetByOfficeEmail((obj.RequestUser + Constants.LOGIGEAR_EMAIL_DOMAIN).Trim()) as Employee).LocationCode; if (!String.IsNullOrEmpty(locationCode)) { int officeId = ConvertUtil.ConvertToInt(CommonFunc.GetLocation(locationCode, LocationType.Office)); string proName = (emplDao.GetByOfficeEmail(obj.RequestUser + Constants.LOGIGEAR_EMAIL_DOMAIN) as Employee).Project; if (String.IsNullOrEmpty(proName)) { srSetting = srSettingDao.GetByProjectAndOffice(String.Empty, officeId); } else { srSetting = srSettingDao.GetByProjectAndOffice(proName, officeId); } if (!string.IsNullOrEmpty(srSetting.EmailTo)) { aTo = srSetting.EmailTo.Split(Constants.SEPARATE_CC_LIST); for (int i = 0; i < aTo.Count(); i++) { if (!duplicateEmail.Contains(aTo[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";") && !String.IsNullOrEmpty(aTo[i])) { duplicateEmail.Add(aTo[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); to_email += aTo[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } if(!string.IsNullOrEmpty(srSetting.EmailCc)) { aCc = srSetting.EmailCc.Split(Constants.SEPARATE_CC_LIST); for (int i = 0; i < aCc.Count(); i++) { if (!duplicateEmail.Contains(aCc[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";") && !String.IsNullOrEmpty(aCc[i])) { duplicateEmail.Add(aCc[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email += aCc[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } if(!string.IsNullOrEmpty(srSetting.EmailBcc)) { aBcc = srSetting.EmailBcc.Split(Constants.SEPARATE_CC_LIST); for (int i = 0; i < aBcc.Count(); i++) { if (!duplicateEmail.Contains(aBcc[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";") && !String.IsNullOrEmpty(aBcc[i])) { duplicateEmail.Add(aBcc[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); bcc_email += aBcc[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } } #endregion if (!string.IsNullOrEmpty(to_email)) { //WebUtils.SendMail(host, port, from_email, poster, to_email, cc_email, subject, body); WebUtils.SendMail(host, port, from_email, poster, to_email, cc_email, bcc_email, subject, body); } }
public ActionResult GetListPortalJQGrid(string name, string status, string category, string subcate, string assignto, string role) { #region JQGrid Params string sortColumn = (Request.Params[GridConstants.SORT_COLUMN]).ToString(); string sortOrder = (Request.Params[GridConstants.SORT_ORDER]).ToString(); int pageIndex = Convert.ToInt32(Request.Params[GridConstants.PAGE_INDEX]); int rowCount = Convert.ToInt32(Request.Params[GridConstants.ROW_COUNT]); #endregion // User login var userName = HttpContext.User.Identity.Name; #region search string title = string.Empty; int subcat = 0; int categoryId = 0; int statusId = 0; string assignName = null; if (name != Constants.SR_FIRST_KEY_WORD) { title = name; } if (!string.IsNullOrEmpty(subcate)) { subcat = int.Parse(subcate); } if (!string.IsNullOrEmpty(status)) { statusId = int.Parse(status); } if (!string.IsNullOrEmpty(category)) { categoryId = int.Parse(category); } if (!string.IsNullOrEmpty(assignto)) { assignName = assignto; } #endregion List<sp_SR_GetServiceRequestResult> empList = new List<sp_SR_GetServiceRequestResult>(); if (role == Constants.PORTAL_ROLE_MANAGER) empList = new ServiceRequestDao().GetList(title, subcat, categoryId, statusId, null, null, role, userName); else empList = new ServiceRequestDao().GetList(title, subcat, categoryId, statusId, assignName, userName, null,null); int totalRecords = empList.Count(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rowCount); int currentPage = CommonFunc.SetJqGridPageIndex(totalRecords, pageIndex, rowCount); List<sp_SR_GetServiceRequestResult> finalList = new ServiceRequestDao().Sort(empList, sortColumn, sortOrder) .Skip((currentPage - 1) * rowCount) .Take(rowCount).ToList<sp_SR_GetServiceRequestResult>(); var jsonData = new { total = totalPages, page = currentPage, records = totalRecords, rows = ( from m in finalList select new { i = m.ID, cell = new string[] { "<span class='"+ m.Icon + "'>" + " </span>" , "<a href='javascript: CRM.chooseSR(\""+ Constants.SR_SERVICE_REQUEST_PREFIX + m.ID+"\");'>" +Constants.SR_SERVICE_REQUEST_PREFIX + m.ID +"</a>", m.Title.Length > 20? m.Title.Substring(0, 20)+ "..." :m.Title, m.Category, m.SubCategory, m.Status, m.AssginName, m.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW) } } ).ToArray() }; return Json(jsonData, JsonRequestBehavior.AllowGet); }
/// <summary> /// Send Purchase Request Mail /// </summary> /// <param name="prId">service request id</param> public static void SendSRMail(int srId,int type) { // Get body detail SR_ServiceRequest obj = new ServiceRequestDao().GetById(srId); //WFRole role = null; if (obj == null) { return; } //else //{ // role = roleDao.GetByID(purReq.AssignRole.Value); //} string from_email = ConfigurationManager.AppSettings["from_email"]; string host = ConfigurationManager.AppSettings["mailserver_host"]; string port = ConfigurationManager.AppSettings["mailserver_port"]; string poster = "Service Request"; string subject = string.Empty; switch (type) { case Constants.SR_SEND_MAIL_COMMENT: subject = "[CRM-SR] " + Constants.SR_SERVICE_REQUEST_PREFIX + obj.ID + " has been modified"; break; default: if (obj.StatusID == Constants.SR_STATUS_CLOSED) { subject = "[CRM-SR] " + Constants.SR_SERVICE_REQUEST_PREFIX + obj.ID + " has been closed"; } else { subject = "[CRM-SR] " + Constants.SR_SERVICE_REQUEST_PREFIX + obj.ID + " has been forwarded to " + obj.AssignUser; } break; } string body = CreateBodyOfEmail(obj); // string requestorBody = CreateRequestorBodyOfEmail(obj); string to_email = string.Empty; string cc_email = string.Empty; string[] arrIds = new string[]{}; arrIds = obj.InvolveUser.Split(Constants.SEPARATE_INVOLVE_CHAR); List<string> sendList = new List<string>(); List<string> duplicateEmail = new List<string>(); for (int i = 0; i < arrIds.Length - 1; i++) { //check duplicate person on user name if (!sendList.Contains(arrIds[i])) { sendList.Add(arrIds[i]); if (obj.StatusID == Constants.SR_STATUS_CLOSED) //If an email has "Close" status, just only send by "To" section, not cc { if (!duplicateEmail.Contains(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";")) { // only send survey email to SubmitUser if (i == 0) { string surveyBody = CreateSurveyBodyEmail(obj); string survey_email = arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; WebUtils.SendMail(host, port, from_email, poster, survey_email, cc_email, subject, surveyBody); } duplicateEmail.Add(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); } } else { //Just send by "To" section only to person who has been assigned, the involved others are by "CC" section. if (string.IsNullOrEmpty(to_email)) { to_email = obj.AssignUser + Constants.LOGIGEAR_EMAIL_DOMAIN; cc_email = arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; duplicateEmail.Add(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); duplicateEmail.Add(obj.AssignUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email = obj.RequestUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; duplicateEmail.Add(obj.RequestUser + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); } else //make a cc list mail send. { if (!duplicateEmail.Contains(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";")) { duplicateEmail.Add(arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email += arrIds[i] + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } } } if (!string.IsNullOrEmpty(obj.CCList)) { string[] array = obj.CCList.Split(';'); foreach (string item in array) { if (!string.IsNullOrEmpty(item)) { string userAdminID = item; if (!duplicateEmail.Contains(item + Constants.LOGIGEAR_EMAIL_DOMAIN + ";")) { duplicateEmail.Add(item + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"); cc_email += item + Constants.LOGIGEAR_EMAIL_DOMAIN + ";"; } } } } if (!string.IsNullOrEmpty(to_email)) { WebUtils.SendMail(host, port, from_email, poster, to_email, cc_email, subject, body); //WebUtils.SendMail(host, port, from_email, poster, to_email, cc_email, bcc_email, subject, body); } }
public ActionResult GetListAdminJQGrid(string name, string status, string category, string subcate, string assignto, string startdate, string enddate, string requestor) { #region JQGrid Params string sortColumn = (Request.Params[GridConstants.SORT_COLUMN]).ToString(); string sortOrder = (Request.Params[GridConstants.SORT_ORDER]).ToString(); int pageIndex = Convert.ToInt32(Request.Params[GridConstants.PAGE_INDEX]); int rowCount = Convert.ToInt32(Request.Params[GridConstants.ROW_COUNT]); #endregion #region search string title = string.Empty; int subcat = 0; int categoryId = 0; int statusId = 0; string assignName = null; string requestUser = null; DateTime? fromDate = null; DateTime? toDate = null; if (name != Constants.SR_FIRST_KEY_WORD) { title = name; } if (!string.IsNullOrEmpty(subcate)) { subcat = int.Parse(subcate); } if (!string.IsNullOrEmpty(status)) { statusId = int.Parse(status); } if (!string.IsNullOrEmpty(category)) { categoryId = int.Parse(category); } if (!string.IsNullOrEmpty(assignto)) { assignName = assignto; } if (!string.IsNullOrEmpty(requestor)) { requestUser = requestor; } if (!string.IsNullOrEmpty(startdate)) { fromDate = DateTime.Parse(startdate); } if (!string.IsNullOrEmpty(enddate)) { toDate = DateTime.Parse(enddate); } #endregion int totalRecords = new ServiceRequestDao().GetCountList4Admin(title, subcat, categoryId, statusId, assignName, fromDate, toDate, requestUser); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rowCount); int currentPage = CommonFunc.SetJqGridPageIndex(totalRecords, pageIndex, rowCount); List<SR_ServiceRequest> finalList = new ServiceRequestDao().GetList4Admin(sortColumn,sortOrder, (currentPage - 1) * rowCount, rowCount, title, subcat, categoryId, statusId, assignName, fromDate, toDate, requestUser); var jsonData = new { total = totalPages, page = currentPage, records = totalRecords, rows = ( from m in finalList select new { i = m.ID, cell = new string[] { m.ID.ToString(), "<span class='"+ m.SR_Urgency.Icon + "'>" + " </span>" , "<a href='javascript: CRM.chooseSR(\""+ Constants.SR_SERVICE_REQUEST_PREFIX + m.ID+"\");'>" +Constants.SR_SERVICE_REQUEST_PREFIX+ m.ID +"</a>", m.Title.Length > Constants.SR_MAX_LENGTH_TITLE? m.Title.Substring(0, Constants.SR_MAX_LENGTH_TITLE)+ "..." :m.Title, m.SR_Category.SR_Category1.Name , m.SR_Category.Name, m.SR_Status.Name, m.AssignUser, m.CreateDate.ToString(Constants.DATETIME_FORMAT_VIEW) } } ).ToArray() }; return Json(jsonData, JsonRequestBehavior.AllowGet); }