//public static void CallingMethod() //{ // UserRightPermission userRightPermission = db.UserRightPermission // .Where(s => s.UserRightPermissionID == AppUtils.CurrentUserRightPermission).FirstOrDefault(); // if (!string.IsNullOrEmpty(userRightPermission.UserRightPermissionDetails)) // { // AppUtils.lstAccessList = db.UserRightPermission // .Where(s => s.UserRightPermissionID == // AppUtils.CurrentUserRightPermission) //AppUtils.UserRightPermissionIDIsAdminUser) // .Select(s => s.UserRightPermissionDetails) // .FirstOrDefault().Split(',').ToList(); // } //} public static SMSReturnDetails SendSMS(string Sender, string ID, string Pass, string destination, string message) { string html = string.Empty; string url = @"http://sms.walletmix.biz/sms-api/apiAccess?username="******"&password="******"&type=0&destination=" + destination + "&source=" + Sender + "&message=" + message + ""; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.AutomaticDecompression = DecompressionMethods.GZip; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { html = reader.ReadToEnd(); } SMSReturnDetails SMSReturnDetails = JsonConvert.DeserializeObject <SMSReturnDetails>(html); return(SMSReturnDetails); }
public ActionResult SendSMSToClient(string message, bool IsCheckAll, string[] IfIsCheckAllThenNonCheckList, string[] IfNotCheckAllThenCheckList, int ForWhichTypeSMSIsThat, int UserType = 0, int ZoneID = 0) { try { List <ClientDetails> lstClientDetails = new List <ClientDetails>(); if (IsCheckAll) { var clientDetails = db.ClientDetails.AsQueryable(); if (UserType != 0 && ZoneID != 0) { clientDetails = clientDetails.Where(x => x.Status == UserType && x.ZoneID == ZoneID).AsQueryable(); } else if (UserType != 0) { clientDetails = clientDetails.Where(x => x.Status == UserType).AsQueryable(); } else if (ZoneID != 0) { clientDetails = clientDetails.Where(x => x.ZoneID == ZoneID).AsQueryable(); } else { var test = ""; } if (IfIsCheckAllThenNonCheckList != null) { List <int> lstClientDetailsInInt = IfIsCheckAllThenNonCheckList.Select(int.Parse).ToList(); //lstClientDetails = clientDetails/*.AsEnumerable().Where(x => !lstClientDetailsInInt.Contains(x.ClientDetailsID))*/.ToList(); var lstClientPhoneNumberWithID = clientDetails.Where(x => !lstClientDetailsInInt.Contains(x.ClientDetailsID)).Select(x => new SendSMSCustomInformation { ClientID = x.ClientDetailsID, Phone = x.ContactNumber }).ToList(); //var lstClientDetails2 = clientDetails.ToList().Where(x => !lstClientDetailsInInt.Contains(x.ClientDetailsID)).ToList(); //lstClientDetails = clientDetails.ToList(); Session["IdListForSMSSend"] = lstClientPhoneNumberWithID; } else { Session["IdListForSMSSend"] = clientDetails.Select(x => new SendSMSCustomInformation { ClientID = x.ClientDetailsID, Phone = x.ContactNumber }).ToList(); } } else { if (IfNotCheckAllThenCheckList != null) { //var clientList = db.ClientDetails.Where(x => IfNotCheckAllThenCheckList.Any(o => o == x.ClientDetailsID.ToString())); List <int> lstClientDetailsInInt = IfNotCheckAllThenCheckList.Select(int.Parse).ToList(); var clientList = db.ClientDetails.Where(x => lstClientDetailsInInt.Contains(x.ClientDetailsID)); var lstCLientPhoneNumberWithID = clientList.Select(x => new SendSMSCustomInformation { ClientID = x.ClientDetailsID, Phone = x.ContactNumber }).ToList(); Session["IdListForSMSSend"] = lstCLientPhoneNumberWithID; } } //var aa = clientDetails.ToList(); List <string> lstMobileNumber = new List <string>(); List <SendSMSCustomInformation> clnIdList = Session["IdListForSMSSend"] as List <SendSMSCustomInformation>; List <SendSMSCustomInformation> lsttemp = new List <SendSMSCustomInformation>(); //if (IsCheckAll) //{ // if (IfIsCheckAllThenNonCheckList != null) // { // lsttemp = clnIdList.Where(x => !IfIsCheckAllThenNonCheckList.Contains(x.ClientID.ToString())).ToList(); // } // else // { // lsttemp = clnIdList; // } //} //else //{ // if (IfNotCheckAllThenCheckList != null) // { // lsttemp = clnIdList.Where(x => IfNotCheckAllThenCheckList.Contains(x.ClientID.ToString())).ToList(); ; // } // //else // //{ // // lsttemp = clnIdList; // //} //} //if (IsCheckAll) //{ // if (IfIsCheckAllThenNonCheckList != null) // { // clnIdList.RemoveAll(x => IfIsCheckAllThenNonCheckList.Contains(x.ClientID.ToString())); // } //} //else //{ // if (IfNotCheckAllThenCheckList != null) // { // clnIdList.RemoveAll(x => !IfNotCheckAllThenCheckList.Contains(Convert.ToString(x.ClientID))); // } //} //List<SendSMSCustomInformation> lsttemp2 = TempData["IdListForSMSSendTemp"] as List<SendSMSCustomInformation>; //OptionSettings os = db.OptionSettings.Where(s => s.OptionSettingsName == AppUtils.SMSOptionName && s.Status == AppUtils.SendSMSStatusTrue).FirstOrDefault(); if ((bool)Session["SMSOptionEnable"]) { foreach (var client in clnIdList) { try { //send sms here SMSSenderIDPass smsSenderIdPass = db.SMSSenderIDPass.Where(s => s.Status == AppUtils.SMSGlobalStatusIsTrue).FirstOrDefault(); if (smsSenderIdPass != null) { SMSReturnDetails SMSReturnDetailsClient = AppUtils.SendSMS(smsSenderIdPass.Sender, smsSenderIdPass.ID, smsSenderIdPass.Pass, client.Phone, message); if (SMSReturnDetailsClient.statusCode == AppUtils.ReturnMessageStatusCodeIsSuccess) { } else { lstMobileNumber.Add(client.Phone); } } } catch (Exception e) { lstMobileNumber.Add(client.Phone); } } } return(Json(new { sendSMSSuccess = true, lstMobileUnableToSendSMS = lstMobileNumber }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { sendSMSFail = true }, JsonRequestBehavior.AllowGet)); } }