/// <summary> /// Search Item Details in Card Tab of Chat /// </summary> /// <param name="SearchText"></param> /// <returns></returns> public List <CustomItemSearchResponseModel> ChatItemDetailsSearch(int TenantID, string Programcode, string ClientAPIURL, string SearchText) { List <CustomItemSearchResponseModel> ItemList = new List <CustomItemSearchResponseModel>(); List <CustomItemSearchResponseModel> ApprovedImageItemList = new List <CustomItemSearchResponseModel>(); ClientCustomGetItemOnSearch SearchItemRequest = new ClientCustomGetItemOnSearch(); MySqlCommand cmd = new MySqlCommand(); DataSet ds = new DataSet(); string ClientAPIResponse = string.Empty; string CardItemsIds = string.Empty; string SKUItemCodes = string.Empty; try { #region call client api for getting item list SearchItemRequest.programcode = Programcode; SearchItemRequest.searchCriteria = SearchText; try { string JsonRequest = JsonConvert.SerializeObject(SearchItemRequest); ClientAPIResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetItemsByArticlesSKUID", JsonRequest); if (!string.IsNullOrEmpty(ClientAPIResponse)) { ItemList = JsonConvert.DeserializeObject <List <CustomItemSearchResponseModel> >(ClientAPIResponse); } if (ItemList.Count > 0) { SKUItemCodes = string.Join(',', ItemList.Where(x => string.IsNullOrEmpty(x.imageURL) && !string.IsNullOrEmpty(x.uniqueItemCode)). Select(x => x.uniqueItemCode).ToList()); if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } cmd = new MySqlCommand("SP_GetDisabledCardItemsConfiguration", conn); cmd.Connection = conn; cmd.Parameters.AddWithValue("@_TenantID", TenantID); cmd.Parameters.AddWithValue("@_ProgramCode", Programcode); cmd.Parameters.AddWithValue("@_SKUItemCodes", string.IsNullOrEmpty(SKUItemCodes) ? "" : SKUItemCodes); cmd.CommandType = CommandType.StoredProcedure; MySqlDataAdapter da = new MySqlDataAdapter(); da.SelectCommand = cmd; da.Fill(ds); if (ds != null && ds.Tables != null) { #region disable card items from the API response if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { CardItemsIds = ds.Tables[0].Rows[0]["CardItemID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["CardItemID"]); if (!string.IsNullOrEmpty(CardItemsIds)) { string[] CardItemsIDArr = CardItemsIds.Split(new char[] { ',' }); if (CardItemsIDArr.Contains("1")) { ItemList = ItemList.Select(x => { x.uniqueItemCode = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("2")) { ItemList = ItemList.Select(x => { x.categoryName = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("3")) { ItemList = ItemList.Select(x => { x.subCategoryName = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("4")) { ItemList = ItemList.Select(x => { x.brandName = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("5")) { ItemList = ItemList.Select(x => { x.color = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("6")) { ItemList = ItemList.Select(x => { x.size = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("7")) { ItemList = ItemList.Select(x => { x.price = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("8")) { ItemList = ItemList.Select(x => { x.url = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("9")) { ItemList = ItemList.Select(x => { x.imageURL = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("10")) { ItemList = ItemList.Select(x => { x.productName = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("11")) { ItemList = ItemList.Select(x => { x.discount = ""; return(x); }).ToList(); } if (CardItemsIDArr.Contains("12")) { ItemList = ItemList.Select(x => { x.colorCode = ""; return(x); }).ToList(); } } } #endregion #region update imageUrl of the items whose card iamge upload has been approved if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[1].Rows) { ApprovedImageItemList.Add(new CustomItemSearchResponseModel() { uniqueItemCode = dr["ItemID"] == DBNull.Value ? string.Empty : Convert.ToString(dr["ItemID"]), imageURL = dr["ImageURL"] == DBNull.Value ? string.Empty : Convert.ToString(dr["ImageURL"]), }); } if (ApprovedImageItemList.Count > 0) { foreach (CustomItemSearchResponseModel carditem in ItemList) { carditem.imageURL = ApprovedImageItemList.Where(x => x.uniqueItemCode.Equals(carditem.uniqueItemCode)).Select(x => x.imageURL).FirstOrDefault(); } } } #endregion } } } catch (Exception) { throw; } #endregion } catch (Exception) { throw; } return(ItemList); }
/// <summary> /// send Message To Customer /// </summary> /// <param name="ChatID"></param> /// <param name="MobileNo"></param> /// <param name="ProgramCode"></param> /// <param name="Messsage"></param> /// <param name="ClientAPIURL"></param> /// <param name="CreatedBy"></param> /// <returns></returns> public int SendMessageToCustomer(int ChatID, string MobileNo, string ProgramCode, string Message, string WhatsAppMessage, string ImageURL, string ClientAPIURL, int CreatedBy, int InsertChat) { MySqlCommand cmd = new MySqlCommand(); int resultCount = 0; CustomerChatModel ChatMessageDetails = new CustomerChatModel(); ClientCustomSendTextModel SendTextRequest = new ClientCustomSendTextModel(); ClientCustomSendImageModel SendImageRequest = new ClientCustomSendImageModel(); string ClientAPIResponse = string.Empty; string ClientImageAPIResponse = string.Empty; //bool isMessageSent = false; try { #region call client api for sending message to customer if (string.IsNullOrEmpty(ImageURL)) { SendTextRequest.To = MobileNo; SendTextRequest.textToReply = Message; SendTextRequest.programCode = ProgramCode; string JsonRequest = JsonConvert.SerializeObject(SendTextRequest); ClientAPIResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/SendText", JsonRequest); } if (!string.IsNullOrEmpty(ImageURL)) { SendImageRequest.To = MobileNo; SendImageRequest.textToReply = WhatsAppMessage; SendImageRequest.programCode = ProgramCode; SendImageRequest.imageUrl = ImageURL; string JsonRequests = JsonConvert.SerializeObject(SendImageRequest); ClientImageAPIResponse = CommonService.SendImageApiRequest(ClientAPIURL + "api/ChatbotBell/SendImage", JsonRequests); } //if (!string.IsNullOrEmpty(ClientAPIResponse)) //{ // isMessageSent = Convert.ToBoolean(ClientAPIResponse); // if (isMessageSent && ChatID > 0 && InsertChat.Equals(1)) // { // ChatMessageDetails.ChatID = ChatID; // ChatMessageDetails.Message = Message; // ChatMessageDetails.ByCustomer = false; // ChatMessageDetails.ChatStatus = 1; // ChatMessageDetails.StoreManagerId = CreatedBy; // ChatMessageDetails.CreatedBy = CreatedBy; // resultCount = SaveChatMessages(ChatMessageDetails); // } //} #endregion } catch (Exception) { throw; } return(resultCount); }
/// <summary> /// Campaign Share SMS /// </summary> /// <param name="objRequest"></param> /// <param name="ClientAPIURL"></param> /// <param name="TenantID"></param> /// <param name="UserID"></param> /// <returns></returns> public int CampaignShareSMS(ShareChatbotModel objRequest, string ClientAPIURL, string SMSsenderId, int TenantID, int UserID) { DataSet ds = new DataSet(); int result = 0; string Message = ""; CampaignStatusResponse obj = new CampaignStatusResponse(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_HSCampaignShareSMS", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@_TenantID", TenantID); cmd.Parameters.AddWithValue("@_StoreID", objRequest.StoreID); cmd.Parameters.AddWithValue("@_ProgramCode", objRequest.ProgramCode); cmd.Parameters.AddWithValue("@_CustomerID", objRequest.CustomerID); cmd.Parameters.AddWithValue("@_CustomerMobileNumber", objRequest.CustomerMobileNumber); cmd.Parameters.AddWithValue("@_StoreManagerId", objRequest.StoreManagerId); cmd.Parameters.AddWithValue("@_CampaignScriptID", objRequest.CampaignScriptID); cmd.Parameters.AddWithValue("@_CreatedBy", UserID); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { Message = ds.Tables[0].Rows[0]["Message"] == DBNull.Value ? String.Empty : Convert.ToString(ds.Tables[0].Rows[0]["Message"]); SMSsenderId = ds.Tables[0].Rows[0]["SmsSenderID"] == DBNull.Value ? String.Empty : Convert.ToString(ds.Tables[0].Rows[0]["SmsSenderID"]); } if (!String.IsNullOrEmpty(Message)) { ChatSendSMS chatSendSMS = new ChatSendSMS { MobileNumber = objRequest.CustomerMobileNumber.TrimStart('0').Length > 10 ? objRequest.CustomerMobileNumber : "91" + objRequest.CustomerMobileNumber.TrimStart('0'), SenderId = SMSsenderId, SmsText = Message }; string apiReq = JsonConvert.SerializeObject(chatSendSMS); apiResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/SendSMS", apiReq); ChatSendSMSResponse chatSendSMSResponse = new ChatSendSMSResponse(); chatSendSMSResponse = JsonConvert.DeserializeObject <ChatSendSMSResponse>(apiResponse); if (chatSendSMSResponse != null) { result = chatSendSMSResponse.Id; } if (result > 0) { UpdateResponseShare(objRequest.CustomerID, "Contacted Via SMS"); } } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(result); }
/// <summary> /// InsertBroadCastDetails /// </summary> /// <param name="tenantID"></param> /// <param name="userID"></param> /// <param name="programcode"></param> /// <param name="storeCode"></param> /// <param name="campaignCode"></param> /// <param name="channelType"></param> /// <returns></returns> public int InsertBroadCastDetails(int tenantID, int userID, string programcode, string storeCode, string campaignCode, string channelType, string ClientAPIURL) { int result = 0; CampaignStatusResponse obj = new CampaignStatusResponse(); try { string strpostionNumber = ""; string strpostionName = ""; GetWhatsappMessageDetailsResponse getWhatsappMessageDetailsResponse = new GetWhatsappMessageDetailsResponse(); try { if (channelType.Equals("Whatsapp")) { GetWhatsappMessageDetailsModal getWhatsappMessageDetailsModal = new GetWhatsappMessageDetailsModal() { ProgramCode = programcode }; string apiBotReq = JsonConvert.SerializeObject(getWhatsappMessageDetailsModal); string apiBotResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetWhatsappMessageDetails", apiBotReq); if (!string.IsNullOrEmpty(apiBotResponse.Replace("[]", "").Replace("[", "").Replace("]", ""))) { getWhatsappMessageDetailsResponse = JsonConvert.DeserializeObject <GetWhatsappMessageDetailsResponse>(apiBotResponse.Replace("[", "").Replace("]", "")); } if (getWhatsappMessageDetailsResponse != null) { if (getWhatsappMessageDetailsResponse.Remarks != null) { string ObjRemark = getWhatsappMessageDetailsResponse.Remarks.Replace("\r\n", ""); string[] ObjSplitComma = ObjRemark.Split(','); if (ObjSplitComma.Length > 0) { for (int i = 0; i < ObjSplitComma.Length; i++) { strpostionNumber += ObjSplitComma[i].Split('-')[0].Trim().Replace("{", "").Replace("}", "") + ","; strpostionName += ObjSplitComma[i].Split('-')[1].Trim() + ","; } } strpostionNumber = strpostionNumber.TrimEnd(','); strpostionName = strpostionName.TrimEnd(','); } } } } catch (Exception) { getWhatsappMessageDetailsResponse = new GetWhatsappMessageDetailsResponse(); } conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_HSInsertBroadCastDetails", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@_Programcode", programcode); cmd.Parameters.AddWithValue("@_StoreCode", storeCode); cmd.Parameters.AddWithValue("@_CampaignCode", campaignCode); cmd.Parameters.AddWithValue("@_ChannelType", channelType); cmd.Parameters.AddWithValue("@_strpostionNumber", strpostionNumber); cmd.Parameters.AddWithValue("@_strpostionName", strpostionName); cmd.Parameters.AddWithValue("@_TemplateName", getWhatsappMessageDetailsResponse.TemplateName); cmd.Parameters.AddWithValue("@_TenantID", tenantID); cmd.Parameters.AddWithValue("@_UserID", userID); result = Convert.ToInt32(cmd.ExecuteNonQuery()); } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(result); }
public List <CustomerMaster> GetCustomerByAPI(string searchText, int TenantId, int UserID) { List <CustomerMaster> customerMasters = new List <CustomerMaster>(); CustomSearchCustomer apiSearchCustomer = new CustomSearchCustomer(); List <CustomCustomerDetails> customCustomerDetails = new List <CustomCustomerDetails>(); int InsertedCustID = 0; try { apiSearchCustomer.programCode = "Bata"; apiSearchCustomer.mobileNumber = searchText; apiSearchCustomer.customerName = ""; apiSearchCustomer.email = ""; apiSearchCustomer.securityToken = apisecurityToken; apiSearchCustomer.userID = 3; apiSearchCustomer.appID = 7; string apiReq = JsonConvert.SerializeObject(apiSearchCustomer); apiResponse = CommonService.SendApiRequest(apiURL, apiReq); if (!string.IsNullOrEmpty(apiResponse)) { ApiResponse = JsonConvert.DeserializeObject <CustomResponse>(apiResponse); if (ApiResponse != null) { customCustomerDetails = JsonConvert.DeserializeObject <List <CustomCustomerDetails> >(Convert.ToString((ApiResponse.Responce))); if (customCustomerDetails != null) { if (customCustomerDetails.Count > 0) { for (int k = 0; k < customCustomerDetails.Count; k++) { CustomerMaster customerDetails = new CustomerMaster(); customerDetails.TenantID = TenantId; customerDetails.CustomerName = customCustomerDetails[k].CustomerName; customerDetails.CreatedBy = UserID; customerDetails.CustomerPhoneNumber = customCustomerDetails[k].MobileNumber; customerDetails.CustomerEmailId = customCustomerDetails[k].Email; customerDetails.GenderID = customCustomerDetails[k].Gender.ToLower().Equals("male") ? 1 : 2; customerDetails.AltEmailID = customCustomerDetails[k].Email; customerDetails.AltNumber = customCustomerDetails[k].MobileNumber; customerDetails.IsActive = Convert.ToInt16(true); //call add customer InsertedCustID = addCustomerDetails(customerDetails, TenantId); if (InsertedCustID > 0) { customerDetails.CustomerID = InsertedCustID; } customerMasters.Add(customerDetails); } } } } } } catch (Exception) { throw; } return(customerMasters); }
/// <summary> /// Campaign Share Chat bot /// </summary> /// <param name="objRequest"></param> /// <param name="ClientAPIURL"></param> /// <param name="TenantID"></param> /// <param name="UserID"></param> /// <returns></returns> public int CampaignShareChatbot(ShareChatbotModel objRequest, string ClientAPIURL, int TenantID, int UserID, string ProgramCode) { DataSet ds = new DataSet(); int result = 0; int resultApi = 0; string Message = ""; CampaignStatusResponse obj = new CampaignStatusResponse(); try { GetWhatsappMessageDetailsResponse getWhatsappMessageDetailsResponse = new GetWhatsappMessageDetailsResponse(); string strpostionNumber = ""; string strpostionName = ""; string additionalInfo = ""; try { GetWhatsappMessageDetailsModal getWhatsappMessageDetailsModal = new GetWhatsappMessageDetailsModal() { ProgramCode = ProgramCode }; string apiBotReq = JsonConvert.SerializeObject(getWhatsappMessageDetailsModal); string apiBotResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetWhatsappMessageDetails", apiBotReq); if (!string.IsNullOrEmpty(apiBotResponse.Replace("[]", "").Replace("[", "").Replace("]", ""))) { getWhatsappMessageDetailsResponse = JsonConvert.DeserializeObject <GetWhatsappMessageDetailsResponse>(apiBotResponse.Replace("[", "").Replace("]", "")); } if (getWhatsappMessageDetailsResponse != null) { if (getWhatsappMessageDetailsResponse.Remarks != null) { string ObjRemark = getWhatsappMessageDetailsResponse.Remarks.Replace("\r\n", ""); string[] ObjSplitComma = ObjRemark.Split(','); if (ObjSplitComma.Length > 0) { for (int i = 0; i < ObjSplitComma.Length; i++) { strpostionNumber += ObjSplitComma[i].Split('-')[0].Trim().Replace("{", "").Replace("}", "") + ","; strpostionName += ObjSplitComma[i].Split('-')[1].Trim() + ","; } } strpostionNumber = strpostionNumber.TrimEnd(','); strpostionName = strpostionName.TrimEnd(','); } } } catch (Exception) { getWhatsappMessageDetailsResponse = new GetWhatsappMessageDetailsResponse(); } conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_HSCampaignShareChatbot", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@_TenantID", TenantID); cmd.Parameters.AddWithValue("@_StoreID", objRequest.StoreID); cmd.Parameters.AddWithValue("@_ProgramCode", objRequest.ProgramCode); cmd.Parameters.AddWithValue("@_CustomerID", objRequest.CustomerID); cmd.Parameters.AddWithValue("@_CustomerMobileNumber", objRequest.CustomerMobileNumber); cmd.Parameters.AddWithValue("@_StoreManagerId", objRequest.StoreManagerId); cmd.Parameters.AddWithValue("@_CampaignScriptID", objRequest.CampaignScriptID); cmd.Parameters.AddWithValue("@_CreatedBy", UserID); cmd.Parameters.AddWithValue("@_strpostionNumber", strpostionNumber); cmd.Parameters.AddWithValue("@_strpostionName", strpostionName); //result = Convert.ToInt32(cmd.ExecuteNonQuery()); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { result = ds.Tables[0].Rows[0]["ChatID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["ChatID"]); Message = ds.Tables[0].Rows[0]["Message"] == DBNull.Value ? String.Empty : Convert.ToString(ds.Tables[0].Rows[0]["Message"]); additionalInfo = ds.Tables[0].Rows[0]["additionalInfo"] == DBNull.Value ? String.Empty : Convert.ToString(ds.Tables[0].Rows[0]["additionalInfo"]); } if (!String.IsNullOrEmpty(Message)) { try { List <string> additionalList = new List <string>(); if (additionalInfo != null) { additionalList = additionalInfo.Split(",").ToList(); } SendFreeTextRequest sendFreeTextRequest = new SendFreeTextRequest { To = objRequest.CustomerMobileNumber.TrimStart('0').Length > 10 ? objRequest.CustomerMobileNumber : "91" + objRequest.CustomerMobileNumber.TrimStart('0'), ProgramCode = ProgramCode, TemplateName = getWhatsappMessageDetailsResponse.TemplateName, AdditionalInfo = additionalList }; string apiReq = JsonConvert.SerializeObject(sendFreeTextRequest); apiResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/SendCampaign", apiReq); //ChatSendSMSResponse chatSendSMSResponse = new ChatSendSMSResponse(); //chatSendSMSResponse = JsonConvert.DeserializeObject<ChatSendSMSResponse>(apiResponse); //if (chatSendSMSResponse != null) //{ // resultApi = chatSendSMSResponse.Id; //} if (apiResponse.Equals("true")) { UpdateResponseShare(objRequest.CustomerID, "Contacted Via Chatbot"); } } catch (Exception) { } } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(result); }
/// <summary> /// Insert Card Image Upload /// </summary> /// <param name="TenantID"></param> /// <param name="ProgramCode"></param> /// <param name="ItemID"></param> /// <param name="ImageUrl"></param> /// <param name="CreatedBy"></param> /// <returns></returns> /// public int InsertCardImageUpload(int TenantID, string ProgramCode, string ClientAPIUrl, string SearchText, string ItemID, string ImageUrl, int CreatedBy) { int success = 0; List <CustomItemSearchResponseModel> ItemList = new List <CustomItemSearchResponseModel>(); CustomItemSearchResponseModel CardItemDetails = new CustomItemSearchResponseModel(); string ClientAPIResponse = string.Empty; //string FTPUrl = string.Empty; try { #region call cardimage API for getting ftp link //string JsonRequest = JsonConvert.SerializeObject(new { programCode = ProgramCode }); //ClientAPIResponse = CommonService.SendApiRequest(ClientAPIUrl + "api/ChatbotBell/GetItemImageUrl", JsonRequest); //if (!string.IsNullOrEmpty(ClientAPIResponse)) //{ // DictFtp = JsonConvert.DeserializeObject<Dictionary<string, string>>(ClientAPIResponse); // if (DictFtp.Count > 0) // { // FTPUrl = DictFtp["imageUrl"]; // if (!string.IsNullOrEmpty(FTPUrl)) // { // ImageUrl = FTPUrl + Path.GetFileName(ImageFilePath); // } // } //} #endregion #region call client api for getting item list string JsonRequest = JsonConvert.SerializeObject(new ClientCustomGetItemOnSearch() { programcode = ProgramCode, searchCriteria = SearchText }); ClientAPIResponse = CommonService.SendApiRequest(ClientAPIUrl + "api/ChatbotBell/GetItemsByArticlesSKUID", JsonRequest); if (!string.IsNullOrEmpty(ClientAPIResponse)) { ItemList = JsonConvert.DeserializeObject <List <CustomItemSearchResponseModel> >(ClientAPIResponse); if (ItemList.Count > 0) { CardItemDetails = ItemList.Where(x => x.uniqueItemCode.Equals(ItemID)).ToList().FirstOrDefault(); } } #endregion #region insert image log in DB if (!string.IsNullOrEmpty(ImageUrl)) { if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd = new MySqlCommand { Connection = conn, CommandType = CommandType.StoredProcedure, CommandText = "SP_HSInsertCardImageUpload" }; cmd.Parameters.AddWithValue("@_TenantID", TenantID); cmd.Parameters.AddWithValue("@_ProgramCode", ProgramCode); cmd.Parameters.AddWithValue("@_ItemID", ItemID); cmd.Parameters.AddWithValue("@_ImageUrl", string.IsNullOrEmpty(ImageUrl) ? "" : ImageUrl); cmd.Parameters.AddWithValue("@_CreatedBy", CreatedBy); //the params below are for inserting the details in item_master_inventory table (client table) cmd.Parameters.AddWithValue("@_Category", string.IsNullOrEmpty(CardItemDetails.categoryName) ? "" : CardItemDetails.categoryName); cmd.Parameters.AddWithValue("@_SubCategoryName", string.IsNullOrEmpty(CardItemDetails.subCategoryName) ? "" : CardItemDetails.subCategoryName); cmd.Parameters.AddWithValue("@_BrandName", string.IsNullOrEmpty(CardItemDetails.brandName) ? "" : CardItemDetails.brandName); cmd.Parameters.AddWithValue("@_Colour", string.IsNullOrEmpty(CardItemDetails.color) ? "" : CardItemDetails.color); cmd.Parameters.AddWithValue("@_ColourCode", string.IsNullOrEmpty(CardItemDetails.colorCode) ? "" : CardItemDetails.colorCode); cmd.Parameters.AddWithValue("@_Price", string.IsNullOrEmpty(CardItemDetails.price) ? "" : CardItemDetails.price); cmd.Parameters.AddWithValue("@_Discount", string.IsNullOrEmpty(CardItemDetails.discount) ? "" : CardItemDetails.discount); cmd.Parameters.AddWithValue("@_Size", string.IsNullOrEmpty(CardItemDetails.size) ? "" : CardItemDetails.size); cmd.Parameters.AddWithValue("@_ItemName", string.IsNullOrEmpty(CardItemDetails.productName) ? "" : CardItemDetails.productName); cmd.Parameters.AddWithValue("@_ProductURL", string.IsNullOrEmpty(CardItemDetails.url) ? "" : CardItemDetails.url); success = Convert.ToInt32(cmd.ExecuteScalar()); } #endregion } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(success); }
/// <summary> /// Bulk Upload User /// </summary> /// <param name="TenantID"></param> /// <param name="CreatedBy"></param> /// <param name="UserFor"></param> /// <param name="DataSetCSV"></param> public List <string> BulkUploadUser(int TenantID, int CreatedBy, int UserFor, DataSet DataSetCSV) { XmlDocument xmlDoc = new XmlDocument(); DataSet Bulkds = new DataSet(); List <string> csvLst = new List <string>(); MySqlCommand cmd = null; string SuccesFile = string.Empty; string ErroFile = string.Empty; try { if (DataSetCSV != null && DataSetCSV.Tables.Count > 0) { if (DataSetCSV.Tables[0] != null && DataSetCSV.Tables[0].Rows.Count > 0) { //check if user ulpoad or brandcategory mapping xmlDoc.LoadXml(DataSetCSV.GetXml()); conn.Open(); string[] dtColumns = Array.ConvertAll(DataSetCSV.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray(), d => d.ToLower()); if (dtColumns.Contains("username")) { cmd = new MySqlCommand("SP_BulkUploadStoreUser", conn); cmd.Parameters.AddWithValue("@_tenantID", TenantID); cmd.Parameters.AddWithValue("@_UserFor", UserFor); } else { cmd = new MySqlCommand("SP_BulkUploadStoreBrandCategoryMapping", conn); } cmd.Connection = conn; cmd.Parameters.AddWithValue("@_xml_content", xmlDoc.InnerXml); cmd.Parameters.AddWithValue("@_node", Xpath); cmd.Parameters.AddWithValue("@_createdBy", CreatedBy); cmd.CommandType = CommandType.StoredProcedure; MySqlDataAdapter da = new MySqlDataAdapter(); da.SelectCommand = cmd; da.Fill(Bulkds); if (Bulkds != null && Bulkds.Tables[0] != null && Bulkds.Tables[1] != null) { //for success file SuccesFile = Bulkds.Tables[0].Rows.Count > 0 ? CommonService.DataTableToCsv(Bulkds.Tables[0]) : string.Empty; csvLst.Add(SuccesFile); //for error file ErroFile = Bulkds.Tables[1].Rows.Count > 0 ? CommonService.DataTableToCsv(Bulkds.Tables[1]) : string.Empty; csvLst.Add(ErroFile); } } } } catch (Exception) { throw; } finally { if (DataSetCSV != null) { DataSetCSV.Dispose(); } if (conn != null) { conn.Close(); } } return(csvLst); }
/// <summary> /// Store Bulk Upload SLA /// <param name="TenantID"></param> /// <param name="CreatedBy"></param /// <param name="DataSetCSV"></param /// </summary> /// public List <string> StoreBulkUploadSLA(int TenantID, int CreatedBy, DataSet DataSetCSV) { XmlDocument xmlDoc = new XmlDocument(); DataSet Bulkds = new DataSet(); List <string> csvLst = new List <string>(); string SuccesFile = string.Empty; string ErroFile = string.Empty; try { if (DataSetCSV != null && DataSetCSV.Tables.Count > 0) { if (DataSetCSV.Tables[0] != null && DataSetCSV.Tables[0].Rows.Count > 0) { xmlDoc.LoadXml(DataSetCSV.GetXml()); conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_BulkUploadStoreSLAMaster", conn); cmd.Connection = conn; cmd.Parameters.AddWithValue("@_xml_content", xmlDoc.InnerXml); cmd.Parameters.AddWithValue("@_node", Xpath); //cmd.Parameters.AddWithValue("@_SLAFor", SLAFor); cmd.Parameters.AddWithValue("@_tenantID", TenantID); cmd.Parameters.AddWithValue("@_createdBy", CreatedBy); cmd.CommandType = CommandType.StoredProcedure; MySqlDataAdapter da = new MySqlDataAdapter(); da.SelectCommand = cmd; da.Fill(Bulkds); if (Bulkds != null && Bulkds.Tables[0] != null && Bulkds.Tables[1] != null) { //for success file //if (Bulkds.Tables[0].Rows.Count > 0) //{ SuccesFile = Bulkds.Tables[0].Rows.Count > 0 ? CommonService.DataTableToCsv(Bulkds.Tables[0]) : string.Empty; csvLst.Add(SuccesFile); //uploadcount = UploadSLATarget(Bulkds.Tables[0], TenantID, CreatedBy); //upload SLA Target //} ////for error file //if (Bulkds.Tables[1].Rows.Count > 0) //{ ErroFile = Bulkds.Tables[1].Rows.Count > 0 ? CommonService.DataTableToCsv(Bulkds.Tables[1]) : string.Empty; csvLst.Add(ErroFile); //} } } } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } if (DataSetCSV != null) { DataSetCSV.Dispose(); } } return(csvLst); }
/// <summary> /// Get Key Insight As ChatBot /// </summary> /// <param name="mobileNumber"></param> /// <param name="programCode"></param> /// <param name="tenantID"></param> /// <param name="userID"></param> /// <returns></returns> public string GetKeyInsightAsChatBot(string mobileNumber, string programCode, string campaignID, int tenantID, int userID, string ClientAPIURL) { string obj = ""; DataSet ds = new DataSet(); try { GetWhatsappMessageDetailsResponse getWhatsappMessageDetailsResponse = new GetWhatsappMessageDetailsResponse(); string strpostionNumber = ""; string strpostionName = ""; //string additionalInfo = ""; try { GetWhatsappMessageDetailsModal getWhatsappMessageDetailsModal = new GetWhatsappMessageDetailsModal() { ProgramCode = programCode }; string apiBotReq = JsonConvert.SerializeObject(getWhatsappMessageDetailsModal); string apiBotResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetWhatsappMessageDetails", apiBotReq); if (!string.IsNullOrEmpty(apiBotResponse.Replace("[]", "").Replace("[", "").Replace("]", ""))) { getWhatsappMessageDetailsResponse = JsonConvert.DeserializeObject <GetWhatsappMessageDetailsResponse>(apiBotResponse.Replace("[", "").Replace("]", "")); } if (getWhatsappMessageDetailsResponse != null) { if (getWhatsappMessageDetailsResponse.Remarks != null) { string ObjRemark = getWhatsappMessageDetailsResponse.Remarks.Replace("\r\n", ""); string[] ObjSplitComma = ObjRemark.Split(','); if (ObjSplitComma.Length > 0) { for (int i = 0; i < ObjSplitComma.Length; i++) { strpostionNumber += ObjSplitComma[i].Split('-')[0].Trim().Replace("{", "").Replace("}", "") + ","; strpostionName += ObjSplitComma[i].Split('-')[1].Trim() + ","; } } strpostionNumber = strpostionNumber.TrimEnd(','); strpostionName = strpostionName.TrimEnd(','); } } } catch (Exception) { getWhatsappMessageDetailsResponse = new GetWhatsappMessageDetailsResponse(); } if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd = new MySqlCommand("SP_HSGetKeyInsightAsChatBot", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@_TenantID", tenantID); cmd.Parameters.AddWithValue("@_UserID", userID); cmd.Parameters.AddWithValue("@_ProgramCode", programCode); cmd.Parameters.AddWithValue("@_MobileNumber", mobileNumber); cmd.Parameters.AddWithValue("@_CampaignID", campaignID); cmd.Parameters.AddWithValue("@_strpostionNumber", strpostionNumber); cmd.Parameters.AddWithValue("@_strpostionName", strpostionName); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { obj = ds.Tables[0].Rows[0]["Message"] == DBNull.Value ? String.Empty : Convert.ToString(ds.Tables[0].Rows[0]["Message"]); } } catch (Exception ex) { obj = ""; } return(obj); }
/// <summary> ///Get Customer popup Details List /// </summary> /// <param name="tenantID"></param> /// <param name="userID"></param> /// <param name="mobileNumber"></param> /// <param name="programCode"></param> /// <returns></returns> public StoresCampaignStatusResponse GetCustomerpopupDetailsList(string mobileNumber, string programCode, string campaignID, int tenantID, int userID, string ClientAPIURL) { StoresCampaignStatusResponse obj = new StoresCampaignStatusResponse(); StoreCampaignSearchOrder objOrderSearch = new StoreCampaignSearchOrder(); CustomerpopupDetails objpopupDetails = new CustomerpopupDetails(); StoreCampaignLastTransactionDetails objLastTransactionDetails = new StoreCampaignLastTransactionDetails(); StoreCampaignKeyInsight objkeyinsight = new StoreCampaignKeyInsight(); List <StoreCampaignRecommended> objrecommended = new List <StoreCampaignRecommended>(); List <StoreCampaignRecommended> objrecommendedDetails = new List <StoreCampaignRecommended>(); string apiReq = string.Empty; DataSet ds = new DataSet(); try { objOrderSearch.mobileNumber = mobileNumber; objOrderSearch.programCode = programCode; objOrderSearch.securityToken = apisecurityToken; try { apiReq = JsonConvert.SerializeObject(objOrderSearch); apiResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetUserATVDetails", apiReq); if (!string.IsNullOrEmpty(apiResponse)) { ApiResponse = JsonConvert.DeserializeObject <CustomResponse>(apiResponse); if (apiResponse != null) { objpopupDetails = JsonConvert.DeserializeObject <CustomerpopupDetails>(((apiResponse))); if (objpopupDetails != null) { CustomerpopupDetails popupDetail = new CustomerpopupDetails { name = objpopupDetails.name, mobileNumber = objpopupDetails.mobileNumber, tiername = objpopupDetails.tiername, lifeTimeValue = objpopupDetails.lifeTimeValue, visitCount = objpopupDetails.visitCount }; obj.useratvdetails = popupDetail; } else { CustomerpopupDetails popupDetail = new CustomerpopupDetails { name = "", mobileNumber = "", tiername = "", lifeTimeValue = "", visitCount = "" }; obj.useratvdetails = popupDetail; } } } } catch (Exception) { if (obj.useratvdetails == null) { CustomerpopupDetails popupDetail = new CustomerpopupDetails { name = "", mobileNumber = "", tiername = "", lifeTimeValue = "", visitCount = "" }; obj.useratvdetails = popupDetail; } } try { apiResponse = string.Empty; apiResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetKeyInsight", apiReq); if (!string.IsNullOrEmpty(apiResponse)) { if (!string.IsNullOrEmpty(apiResponse.Replace("[]", ""))) { objkeyinsight = JsonConvert.DeserializeObject <StoreCampaignKeyInsight>(((apiResponse))); if (objkeyinsight != null) { StoreCampaignKeyInsight popupDetail = new StoreCampaignKeyInsight { mobileNumber = objkeyinsight.mobileNumber, insightText = objkeyinsight.insightText }; obj.campaignkeyinsight = popupDetail; } else { StoreCampaignKeyInsight KeyInsight = new StoreCampaignKeyInsight { mobileNumber = "", insightText = ""//GetKeyInsightAsChatBot(mobileNumber, programCode, tenantID, userID) }; obj.campaignkeyinsight = KeyInsight; } } else { StoreCampaignKeyInsight KeyInsight = new StoreCampaignKeyInsight { mobileNumber = "", insightText = ""//GetKeyInsightAsChatBot(mobileNumber, programCode, tenantID, userID) }; obj.campaignkeyinsight = KeyInsight; } } else { StoreCampaignKeyInsight KeyInsight = new StoreCampaignKeyInsight { mobileNumber = "", insightText = "" }; obj.campaignkeyinsight = KeyInsight; } } catch (Exception) { if (obj.campaignkeyinsight == null) { StoreCampaignKeyInsight KeyInsight = new StoreCampaignKeyInsight { mobileNumber = "", insightText = "" }; obj.campaignkeyinsight = KeyInsight; } } if (obj.useratvdetails != null) { bool lifeTimeValuehaszero = false; bool visitCounthaszero = false; if (!string.IsNullOrEmpty(obj.useratvdetails.lifeTimeValue)) { if (decimal.TryParse(obj.useratvdetails.lifeTimeValue, out decimal result)) { if (Convert.ToDouble(obj.useratvdetails.lifeTimeValue).Equals(0)) { lifeTimeValuehaszero = true; } } } if (!string.IsNullOrEmpty(obj.useratvdetails.visitCount)) { if (decimal.TryParse(obj.useratvdetails.visitCount, out decimal result)) { if (Convert.ToDouble(obj.useratvdetails.visitCount).Equals(0)) { visitCounthaszero = true; } } } if ((string.IsNullOrEmpty(obj.useratvdetails.lifeTimeValue) && string.IsNullOrEmpty(obj.useratvdetails.visitCount) || (lifeTimeValuehaszero && visitCounthaszero))) { if (obj.campaignkeyinsight != null) { if (string.IsNullOrEmpty(obj.campaignkeyinsight.insightText)) { StoreCampaignKeyInsight KeyInsight = new StoreCampaignKeyInsight { mobileNumber = mobileNumber, insightText = GetKeyInsightAsChatBot(mobileNumber, programCode, campaignID, tenantID, userID, ClientAPIURL), ShowKeyInsights = false }; obj.campaignkeyinsight = KeyInsight; } } } } try { if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd = new MySqlCommand("SP_HSGetCampaignRecommendedList", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@Tenant_ID", tenantID); cmd.Parameters.AddWithValue("@User_ID", userID); cmd.Parameters.AddWithValue("@mobile_Number", mobileNumber); cmd.Parameters.AddWithValue("@program_Code", programCode); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { StoreCampaignRecommended RecommendedDetail = new StoreCampaignRecommended(); RecommendedDetail.mobileNumber = ds.Tables[0].Rows[i]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["MobileNumber"]); RecommendedDetail.itemCode = ds.Tables[0].Rows[i]["ItemCode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ItemCode"]); RecommendedDetail.category = ds.Tables[0].Rows[i]["Category"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Category"]); RecommendedDetail.subCategory = ds.Tables[0].Rows[i]["SubCategory"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["SubCategory"]); RecommendedDetail.brand = ds.Tables[0].Rows[i]["Brand"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Brand"]); RecommendedDetail.color = ds.Tables[0].Rows[i]["Color"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Color"]); RecommendedDetail.size = ds.Tables[0].Rows[i]["Size"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Size"]); RecommendedDetail.price = ds.Tables[0].Rows[i]["Price"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Price"]); RecommendedDetail.url = ds.Tables[0].Rows[i]["Url"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Url"]); RecommendedDetail.imageURL = ds.Tables[0].Rows[i]["ImageURL"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ImageURL"]); objrecommended.Add(RecommendedDetail); } obj.campaignrecommended = objrecommended; } else { StoreCampaignRecommended RecommendedDetail = new StoreCampaignRecommended(); RecommendedDetail.mobileNumber = ""; RecommendedDetail.itemCode = ""; RecommendedDetail.category = ""; RecommendedDetail.subCategory = ""; RecommendedDetail.brand = ""; RecommendedDetail.color = ""; RecommendedDetail.size = ""; RecommendedDetail.price = ""; RecommendedDetail.url = ""; RecommendedDetail.imageURL = ""; objrecommended.Add(RecommendedDetail); obj.campaignrecommended = objrecommended; } } catch (Exception) { StoreCampaignRecommended RecommendedDetail = new StoreCampaignRecommended(); RecommendedDetail.mobileNumber = ""; RecommendedDetail.itemCode = ""; RecommendedDetail.category = ""; RecommendedDetail.subCategory = ""; RecommendedDetail.brand = ""; RecommendedDetail.color = ""; RecommendedDetail.size = ""; RecommendedDetail.price = ""; RecommendedDetail.url = ""; RecommendedDetail.imageURL = ""; objrecommended.Add(RecommendedDetail); obj.campaignrecommended = objrecommended; } try { apiResponse = string.Empty; apiResponse = CommonService.SendApiRequest(ClientAPIURL + "api/ChatbotBell/GetLastTransactionDetails", apiReq); if (!string.IsNullOrEmpty(apiResponse)) { if (apiResponse != null) { objLastTransactionDetails = JsonConvert.DeserializeObject <StoreCampaignLastTransactionDetails>(((apiResponse))); if (objLastTransactionDetails != null) { //if (objrecommendedDetails.Count > 0) //{ // StoreCampaignLastTransactionDetails LastTransactionDetails = new StoreCampaignLastTransactionDetails(); // LastTransactionDetails.billNo = LastTransactionDetails.billNo; // LastTransactionDetails.billDate = LastTransactionDetails.billDate; ; // LastTransactionDetails.storeName = LastTransactionDetails.storeName; // LastTransactionDetails.amount = LastTransactionDetails.amount; // //LastTransactionDetails.itemDetails = LastTransactionDetails.itemDetails; // obj.lasttransactiondetails = LastTransactionDetails; //} obj.lasttransactiondetails = objLastTransactionDetails; } else { StoreCampaignLastTransactionDetails LastTransactionDetails = new StoreCampaignLastTransactionDetails(); LastTransactionDetails.billNo = ""; LastTransactionDetails.billDate = ""; LastTransactionDetails.storeName = ""; LastTransactionDetails.amount = ""; // LastTransactionDetails.itemDetails = ""; obj.lasttransactiondetails = LastTransactionDetails; } } } } catch (Exception) { if (obj.lasttransactiondetails == null) { StoreCampaignLastTransactionDetails LastTransactionDetails = new StoreCampaignLastTransactionDetails(); LastTransactionDetails.billNo = ""; LastTransactionDetails.billDate = ""; LastTransactionDetails.storeName = ""; LastTransactionDetails.amount = ""; // LastTransactionDetails.itemDetails = ""; obj.lasttransactiondetails = LastTransactionDetails; } } try { if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd = new MySqlCommand("SP_HSGetShareCampaignViaSetting", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@Tenant_ID", tenantID); cmd.Parameters.AddWithValue("@User_ID", userID); cmd.Parameters.AddWithValue("@mobile_Number", mobileNumber); cmd.Parameters.AddWithValue("@program_Code", programCode); ds = new DataSet(); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0].Rows.Count > 0) { ShareCampaignViaSettingModal shareCampaignViaSettingModal = new ShareCampaignViaSettingModal { CustomerName = ds.Tables[0].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["CustomerName"]), CustomerNumber = ds.Tables[0].Rows[0]["CustomerNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["CustomerNumber"]), SmsFlag = ds.Tables[0].Rows[0]["SmsFlag"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["SmsFlag"]), SmsClickCount = ds.Tables[0].Rows[0]["SmsClickCount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["SmsClickCount"]), SmsClickable = ds.Tables[0].Rows[0]["SmsClickable"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["SmsClickable"]), EmailFlag = ds.Tables[0].Rows[0]["EmailFlag"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["EmailFlag"]), EmailClickCount = ds.Tables[0].Rows[0]["EmailClickCount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["EmailClickCount"]), EmailClickable = ds.Tables[0].Rows[0]["EmailClickable"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["EmailClickable"]), MessengerFlag = ds.Tables[0].Rows[0]["MessengerFlag"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["MessengerFlag"]), MessengerClickCount = ds.Tables[0].Rows[0]["MessengerClickCount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["MessengerClickCount"]), MessengerClickable = ds.Tables[0].Rows[0]["MessengerClickable"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["MessengerClickable"]), BotFlag = ds.Tables[0].Rows[0]["BotFlag"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["BotFlag"]), BotClickCount = ds.Tables[0].Rows[0]["BotClickCount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["BotClickCount"]), BotClickable = ds.Tables[0].Rows[0]["BotClickable"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["BotClickable"]), MaxClickAllowed = ds.Tables[0].Rows[0]["MaxClickAllowed"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["MaxClickAllowed"]), }; obj.ShareCampaignViaSettingModal = shareCampaignViaSettingModal; } else { ShareCampaignViaSettingModal shareCampaignViaSettingModal = new ShareCampaignViaSettingModal { CustomerName = "", CustomerNumber = "", SmsFlag = false, SmsClickCount = 0, SmsClickable = false, EmailFlag = false, EmailClickCount = 0, EmailClickable = false, MessengerFlag = false, MessengerClickCount = 0, MessengerClickable = false, BotFlag = false, BotClickCount = 0, BotClickable = false, MaxClickAllowed = 0, }; obj.ShareCampaignViaSettingModal = shareCampaignViaSettingModal; } } catch (Exception) { ShareCampaignViaSettingModal shareCampaignViaSettingModal = new ShareCampaignViaSettingModal { CustomerName = "", CustomerNumber = "", SmsFlag = false, SmsClickCount = 0, SmsClickable = false, EmailFlag = false, EmailClickCount = 0, EmailClickable = false, MessengerFlag = false, MessengerClickCount = 0, MessengerClickable = false, BotFlag = false, BotClickCount = 0, BotClickable = false, MaxClickAllowed = 0, }; obj.ShareCampaignViaSettingModal = shareCampaignViaSettingModal; } } catch (Exception) { } // InsertApiResponseData(obj, userID); return(obj); }
/// <summary> ///Generate Link /// </summary> /// <param name="sentPaymentLink"></param> /// <param name="clientAPIUrlForGenerateToken"></param> /// <param name="clientAPIUrlForGeneratePaymentLink"></param> /// <param name="TenantID"></param> /// <param name="UserID"></param> /// <param name="programCode"></param> /// <returns></returns> public int GenerateLink(SentPaymentLink sentPaymentLink, string clientAPIUrlForGenerateToken, string clientAPIUrlForGeneratePaymentLink, int tenantID, int userID, string programCode) { int result = 0; string apiReq1 = ""; string URLGeneratePaymentLink = ""; DataSet ds = new DataSet(); HSRequestResendPaymentLink hSRequestResendPaymentLink = null; HSRequestGeneratePaymentLink hSRequestGeneratePaymentLink = null; try { if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrderDetailForPaymentLink", conn) { Connection = conn, CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@Invoice_Number", sentPaymentLink.InvoiceNumber); cmd.Parameters.AddWithValue("@tenant_ID", tenantID); cmd.Parameters.AddWithValue("@user_ID", userID); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { hSRequestGeneratePaymentLink = new HSRequestGeneratePaymentLink { merchantTxnID = ds.Tables[0].Rows[0]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["InvoiceNo"]), billDateTime = ds.Tables[0].Rows[0]["billDateTime"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["billDateTime"]), terminalId = ds.Tables[0].Rows[0]["TerminalId"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["TerminalId"]), name = ds.Tables[0].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["CustomerName"]), email = ds.Tables[0].Rows[0]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["EmailID"]), mobile = ds.Tables[0].Rows[0]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["MobileNumber"]), amount = ds.Tables[0].Rows[0]["Amount"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[0]["Amount"]) }; } hSRequestGeneratePaymentLink.programCode = programCode; hSRequestGeneratePaymentLink.storeCode = sentPaymentLink.StoreCode; DateTime dateTime_billdatetime = Convert.ToDateTime(hSRequestGeneratePaymentLink.billDateTime); var settings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-ddTHH:mm:ss.fffZ" }; var json = JsonConvert.SerializeObject(dateTime_billdatetime, settings); var newdate = JsonConvert.DeserializeObject <string>(json); hSRequestGeneratePaymentLink.billDateTime = newdate; HSResponseGeneratePaymentLink responseGeneratePaymentLink = new HSResponseGeneratePaymentLink(); HSRequestGenerateToken hSRequestGenerateToken = new HSRequestGenerateToken(); string apiReq = JsonConvert.SerializeObject(hSRequestGenerateToken); apiResponse = CommonService.SendApiRequestToken(clientAPIUrlForGenerateToken + "connect/token", apiReq); HSResponseGenerateToken hSResponseGenerateToken = new HSResponseGenerateToken(); hSResponseGenerateToken = JsonConvert.DeserializeObject <HSResponseGenerateToken>(apiResponse); if (!string.IsNullOrEmpty(hSResponseGenerateToken.access_Token)) { if (sentPaymentLink.SentPaymentLinkCount > 0) { hSRequestResendPaymentLink = new HSRequestResendPaymentLink { programCode = programCode, tokenId = hSResponseGenerateToken.access_Token, storeCode = sentPaymentLink.StoreCode, billDateTime = hSRequestGeneratePaymentLink.billDateTime, terminalId = hSRequestGeneratePaymentLink.terminalId, merchantTxnID = hSRequestGeneratePaymentLink.merchantTxnID, mobile = hSRequestGeneratePaymentLink.mobile, reason = "ABCD" }; apiReq1 = JsonConvert.SerializeObject(hSRequestResendPaymentLink); URLGeneratePaymentLink = clientAPIUrlForGeneratePaymentLink + "api/ResendPaymentLink"; } else { apiReq1 = JsonConvert.SerializeObject(hSRequestGeneratePaymentLink); URLGeneratePaymentLink = clientAPIUrlForGeneratePaymentLink + "api/GeneratePaymentLink"; } apiResponse1 = CommonService.SendApiRequestMerchantApi(URLGeneratePaymentLink, apiReq1, hSResponseGenerateToken.access_Token); responseGeneratePaymentLink = JsonConvert.DeserializeObject <HSResponseGeneratePaymentLink>(apiResponse1); } if (responseGeneratePaymentLink.returnMessage == "Success") { if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd1 = new MySqlCommand("SP_PHYUpdateOrderDetailForPaymentLink", conn) { Connection = conn, CommandType = CommandType.StoredProcedure }; cmd1.Parameters.AddWithValue("@Invoice_Number", sentPaymentLink.InvoiceNumber); cmd1.Parameters.AddWithValue("@access_Token", hSResponseGenerateToken.access_Token); cmd1.Parameters.AddWithValue("@tenant_ID", tenantID); cmd1.Parameters.AddWithValue("@user_ID", userID); cmd1.CommandType = CommandType.StoredProcedure; result = Convert.ToInt32(cmd1.ExecuteNonQuery()); conn.Close(); } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(result); }
/// <summary> /// CreateShipmentAWB /// </summary> /// <param name="orderID"></param> /// <param name="itemIDs"></param> /// <param name="tenantID"></param> /// <param name="userID"></param> /// <returns></returns> public ReturnShipmentDetails CreateShipmentAWB(int orderID, string itemIDs, int tenantID, int userID, string clientAPIURL) { bool isAWBGenerated = false; bool iSStoreDelivery = false; DataSet ds = new DataSet(); RequestCouriersPartnerAndAWBCode requestCouriersPartnerAndAWBCode = null; ResponseCouriersPartnerAndAWBCode responseCouriersPartnerAndAWBCode = new ResponseCouriersPartnerAndAWBCode(); ResponseGeneratePickup responseGeneratePickup = new ResponseGeneratePickup(); ResponseGenerateManifest responseGenerateManifest = new ResponseGenerateManifest(); ReturnShipmentDetails obj = null; try { // Code for gatting data from table for request AWB client API if (conn != null && conn.State == ConnectionState.Closed) { conn.Open(); } MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrderAWBDetails", conn) { Connection = conn, CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@_TenantID", tenantID); cmd.Parameters.AddWithValue("@_UserID", userID); cmd.Parameters.AddWithValue("@_OrderID", orderID); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { isAWBGenerated = ds.Tables[0].Rows[0]["IsAwbNoGenerated"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["IsAwbNoGenerated"]); } if (ds != null && ds.Tables[1] != null) { requestCouriersPartnerAndAWBCode = new RequestCouriersPartnerAndAWBCode { pickup_postcode = ds.Tables[1].Rows[0]["pickup_postcode"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[0]["pickup_postcode"]), delivery_postcode = ds.Tables[1].Rows[0]["delivery_postcode"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[0]["delivery_postcode"]), weight = ds.Tables[1].Rows[0]["weight"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[0]["weight"]) }; } if (ds != null && ds.Tables[2] != null) { requestCouriersPartnerAndAWBCode.orderDetails = new OrderDetails { order_id = ds.Tables[2].Rows[0]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["InvoiceNo"]), order_date = ds.Tables[2].Rows[0]["Date"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["Date"]), pickup_location = ds.Tables[2].Rows[0]["pickup_location"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["pickup_location"]), channel_id = ds.Tables[2].Rows[0]["channel_id"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["channel_id"]), billing_customer_name = ds.Tables[2].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["CustomerName"]), billing_last_name = ds.Tables[2].Rows[0]["billing_last_name"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_last_name"]), billing_address = ds.Tables[2].Rows[0]["ShippingAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["ShippingAddress"]), billing_address_2 = ds.Tables[2].Rows[0]["billing_address_2"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_address_2"]), billing_city = ds.Tables[2].Rows[0]["City"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["City"]), billing_pincode = ds.Tables[2].Rows[0]["delivery_postcode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["delivery_postcode"]), billing_state = ds.Tables[2].Rows[0]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["State"]), billing_country = ds.Tables[2].Rows[0]["Country"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["Country"]), billing_email = ds.Tables[2].Rows[0]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["EmailID"]), billing_phone = ds.Tables[2].Rows[0]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["MobileNumber"]), billing_alternate_phone = ds.Tables[2].Rows[0]["billing_alternate_phone"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_alternate_phone"]), shipping_is_billing = ds.Tables[2].Rows[0]["shipping_is_billing"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[2].Rows[0]["shipping_is_billing"]), shipping_customer_name = ds.Tables[2].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["CustomerName"]), shipping_last_name = ds.Tables[2].Rows[0]["billing_last_name"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_last_name"]), shipping_address = ds.Tables[2].Rows[0]["ShippingAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["ShippingAddress"]), shipping_address_2 = ds.Tables[2].Rows[0]["billing_address_2"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_address_2"]), shipping_city = ds.Tables[2].Rows[0]["City"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["City"]), shipping_pincode = ds.Tables[2].Rows[0]["delivery_postcode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["delivery_postcode"]), shipping_country = ds.Tables[2].Rows[0]["Country"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["Country"]), shipping_state = ds.Tables[2].Rows[0]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["State"]), shipping_email = ds.Tables[2].Rows[0]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["EmailID"]), shipping_phone = ds.Tables[2].Rows[0]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["MobileNumber"]), payment_method = "Prepaid", shipping_charges = 0, giftwrap_charges = 0, transaction_charges = 0, total_discount = 0, sub_total = ds.Tables[2].Rows[0]["Amount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[2].Rows[0]["Amount"]), length = 10, breadth = 10, height = 2, weight = 1.4, //orderitems = new List<Orderitems>(), }; } if (ds != null && ds.Tables[3] != null) { requestCouriersPartnerAndAWBCode.orderDetails.order_items = ds.Tables[3].AsEnumerable().Select(x => new Orderitems() { name = x.Field <object>("name") == System.DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("name")), sku = x.Field <object>("sku") == System.DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("sku")), units = x.Field <object>("units") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("units")), selling_price = x.Field <object>("selling_price") == System.DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("selling_price")), discount = x.Field <object>("discount") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("discount")), tax = x.Field <object>("tax") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("tax")), hsn = x.Field <object>("hsn") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("hsn")), }).ToList(); } if (ds != null && ds.Tables[4] != null) { iSStoreDelivery = ds.Tables[4].Rows[0]["StoreDelivery"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[4].Rows[0]["StoreDelivery"]); } if (isAWBGenerated == false) { string apiReq = JsonConvert.SerializeObject(requestCouriersPartnerAndAWBCode); apiResponse = CommonService.SendApiRequest(clientAPIURL + "api/ShoppingBag/GetCouriersPartnerAndAWBCode", apiReq); responseCouriersPartnerAndAWBCode = JsonConvert.DeserializeObject <ResponseCouriersPartnerAndAWBCode>(apiResponse); if (responseCouriersPartnerAndAWBCode.data.awb_code == "" && responseCouriersPartnerAndAWBCode.data.courier_name == "") { if (iSStoreDelivery == true) { //CouriersPartner =Store responseCouriersPartnerAndAWBCode.data.courier_name = "Store"; obj = CreateShipment(orderID, itemIDs, tenantID, userID, responseCouriersPartnerAndAWBCode); } else { // insert in PHYOrderReturn table (return tab) int result = SetOrderHasBeenReturn(tenantID, userID, orderID); } } if (responseCouriersPartnerAndAWBCode.data.awb_code != "" || responseCouriersPartnerAndAWBCode.data.courier_name != "") { //Code for GeneratePickup // { "statusCode":"200","data":{ "awb_code":"141123201505566","order_id":"41363502","shipment_id":"41079500","courier_company_id":"51","courier_name":"Xpressbees Surface","rate":100,"is_custom_rate":"0","cod_multiplier":"0","cod_charges":"0","freight_charge":"100","rto_charges":"92","min_weight":"0.5","etd_hours":"112","etd":"Jun 19, 2020","estimated_delivery_days":"5"} } RequestGeneratePickup requestGeneratePickup = new RequestGeneratePickup(); requestGeneratePickup.shipmentId = new List <int>(); requestGeneratePickup.shipmentId.Add(Convert.ToInt32(responseCouriersPartnerAndAWBCode.data.shipment_id)); string apiReq1 = JsonConvert.SerializeObject(requestGeneratePickup); apiResponse = CommonService.SendApiRequest(clientAPIURL + "/api/ShoppingBag/GeneratePickup", apiReq1); responseGeneratePickup = JsonConvert.DeserializeObject <ResponseGeneratePickup>(apiResponse); // need to write Code for update Status shipment pickup //end //Code for GeneratePickup need to move code //Code for GenerateManifest need to move the code string apiReq2 = JsonConvert.SerializeObject(requestGeneratePickup); apiResponse = CommonService.SendApiRequest(clientAPIURL + "/api/ShoppingBag/GenerateManifest", apiReq2); responseGenerateManifest = JsonConvert.DeserializeObject <ResponseGenerateManifest>(apiResponse); // need to write Code for update Status smanifest created //end Code for GenerateManifest need to move the code //} obj = CreateShipment(orderID, itemIDs, tenantID, userID, responseCouriersPartnerAndAWBCode); } } else { // need to write code if isAWBGenerated flag is true // code for return awb ,InvoiceNo.itemIDs need to write code (need to ask) //if (responseCouriersPartnerAndAWBCode.data.awb_code != null) //{ // if (iSStoreDelivery == false) // { // // call rabit MQ and update the AWB in table // } //} } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(obj); }