public async Task <string> CreateTopicGroup(string SenderTokenID, string SenderTopicName) { FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); // string token = "euGW0vssj4c:APA91bGAL3ks7gOTG6c8NIMfw698cwT2YQLO9iXEM_OCLgv7EdtNVg2m_xFye7WL056tPFtV_S8NqMT-rv_zDh8sg0YZXJMqhzo4UaUu553gXdcRy5XssoB63z81VmXrmDPyN36raY3g"; // SenderTokenID = token; // string SERVER_API_KEY = "AAAAPYj679o:APA91bEKN3E2csYZVghk3DpyHbVWn43gzTbYZ_z8rjIoDuVxWpALbHL_v6OEx8RQTfP5pQ7KD_JNeSJwJmFIx3Aq-OYcq5fid1mYhrF4fgPV3CjEeNFTttIhZxs7158hkUr_WzC_NHqtByTQho0_2wUoiWZt6rY-4Q"; //var SENDER_ID = "264291151834"; // string SERVER_API_KEY = fcmDetails.SERVER_API_KEY; //var SENDER_ID = fcmDetails.PROJECT_KEY; WebRequest tRequest; String sResponseFromServer; tRequest = WebRequest.Create("https://iid.googleapis.com/iid/v1/" + SenderTokenID + "/rel/topics/" + SenderTopicName); tRequest.Method = "post"; tRequest.Headers.Add(string.Format("Authorization: key={0}", fcmDetails.SERVER_API_KEY)); tRequest.Headers.Add(string.Format("project_id:{0}", fcmDetails.PROJECT_KEY)); tRequest.ContentType = "application/json"; tRequest.ContentLength = 0; try { tRequest.GetRequestStream(); /* Stream dataStream; * * using (WebResponse tResponse = tRequest.GetResponse()) * { * using (Stream stream = tResponse.GetResponseStream()) * { * // XmlTextReader reader = new XmlTextReader(stream); * // var json = serializer.Serialize(stream); * * dataStream = tResponse.GetResponseStream(); * StreamReader tReader = new StreamReader(dataStream); * sResponseFromServer = tReader.ReadToEnd(); * tReader.Close(); * dataStream.Close(); * tResponse.Close(); * } * }*/ } catch (Exception ex) { sResponseFromServer = ex.Message.ToString(); } sResponseFromServer = await CheckTopicGroup(SenderTokenID, SenderTopicName); return(sResponseFromServer); }
public async Task <cStatus> GetfcmsubcriptioncheckAsync(string DeviceID) { cStatus st = new cStatus(); FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); string uri; //uri = "https://iid.googleapis.com/iid/info/f0l3VKFi_bs:APA91bEvLlgSHIwB3zJv3YEL_jkjxXRVzWY85jNe4_6tSC-IE7oh-FqJBajA9nuDNI7pZCZ1eqa2aDjCCpK9bS7jW0ONezffGvRMs7q4lbyVGEYkKLv4tH9wE26b80aSLM5sdowG349G?details=true"; uri = "https://iid.googleapis.com/iid/info/" + DeviceID + "?details=true"; try { var client = new RestClient(uri); var request = new RestRequest(Method.GET); request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY)); request.AddHeader("Content-Type", "application/json"); request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY)); IRestResponse <cFCMSubscribed> asyncHandle = await client.ExecuteGetTaskAsync <cFCMSubscribed>(request); //return asyncHandle.Content.ToString(); st.DesctoDev = asyncHandle.Content.ToString(); if (st.DesctoDev.Contains("THANDORA_ADMIN") && st.DesctoDev.Contains("INDIA")) { st.StatusMsg = "THANDORA Installed successfully"; st.StatusID = 0; } else { st.StatusMsg = "THANDORA Installation failed. Please install it again. "; st.StatusID = 1; } return(st); } catch (Exception ex) { st.StatusID = 1;// Notification failure st.StatusMsg = ex.Message.ToString(); return(st); } }
public async Task <string> CheckTopicGroup(string SenderTokenID, string SenderTopicName) { // string token = "euGW0vssj4c:APA91bGAL3ks7gOTG6c8NIMfw698cwT2YQLO9iXEM_OCLgv7EdtNVg2m_xFye7WL056tPFtV_S8NqMT-rv_zDh8sg0YZXJMqhzo4UaUu553gXdcRy5XssoB63z81VmXrmDPyN36raY3g"; // SenderTokenID = token; FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); // string SERVER_API_KEY = "AAAAPYj679o:APA91bEKN3E2csYZVghk3DpyHbVWn43gzTbYZ_z8rjIoDuVxWpALbHL_v6OEx8RQTfP5pQ7KD_JNeSJwJmFIx3Aq-OYcq5fid1mYhrF4fgPV3CjEeNFTttIhZxs7158hkUr_WzC_NHqtByTQho0_2wUoiWZt6rY-4Q"; // var SENDER_ID = "264291151834"; //string SERVER_API_KEY = fcmDetails.SERVER_API_KEY; //var SENDER_ID = fcmDetails.PROJECT_KEY; WebRequest tRequest; String sResponseFromServer; tRequest = WebRequest.Create("https://iid.googleapis.com/iid/info/" + SenderTokenID + "?details=true"); tRequest.Method = "get"; //tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8"; tRequest.Headers.Add(string.Format("Authorization: key={0}", fcmDetails.SERVER_API_KEY)); tRequest.Headers.Add(string.Format("project_id:{0}", fcmDetails.PROJECT_KEY)); tRequest.ContentType = "application/json"; //tRequest.UseDefaultCredentials = true; var postData = new { operation = "create", notification_key_name = "Thandora-603103", }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(postData); Byte[] byteArray = Encoding.UTF8.GetBytes(json); tRequest.ContentLength = 0; try { Stream dataStream; using (WebResponse tResponse = tRequest.GetResponse()) { using (Stream stream = tResponse.GetResponseStream()) { // XmlTextReader reader = new XmlTextReader(stream); // var json = serializer.Serialize(stream); dataStream = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStream); sResponseFromServer = tReader.ReadToEnd(); tReader.Close(); dataStream.Close(); tResponse.Close(); if (sResponseFromServer.Contains(SenderTopicName)) { sResponseFromServer = "Topic Created/Subscribed in the Name of " + SenderTopicName; } } } // tRequest.GetRequestStream(); // WebResponse tResponse = tRequest.GetResponse(); } catch (Exception ex) { sResponseFromServer = ex.Message.ToString(); } return(sResponseFromServer); }
public async Task <cStatus> SubscriberNotificationAsync(string DeviceID, string subscriber, string msg) { cStatus st = new cStatus(); FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); string uri; uri = "https://fcm.googleapis.com/fcm/send"; try { var client = new RestClient(uri); var request = new RestRequest(Method.POST); request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY)); request.AddHeader("content-type", "application/json"); request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY)); var postData = new { to = DeviceID, data = new { MessageID = 1 }, priority = "high", notification = new { body = subscriber + msg, title = "Subscription update", icon = "myicon" } }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(postData); //request.AddParameter("application/json", "{\r\n \"to\" : \""+DeviceID+"\"\r\n \"data\":{\r\n \t \"enquiryID\": "+enquiryid.ToString()+"\r\n }\r\n \r\n \"notification\":\r\n {\r\n \"body\": \""+enquirymessage+"\",\r\n \"title\":\""+FromUser +"\",\r\n \"icon\": \"myicon\"\r\n }\r\n }", ParameterType.RequestBody); //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new // { body = enquirymessage, title = FromUser,icon = "myicon" } }) , ParameterType.RequestBody); request.AddParameter("application/json", json, ParameterType.RequestBody); /*var rs = client.Execute(request); * sResponseFromServer = rs.Content.ToString(); * return sResponseFromServer;*/ //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete); IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request); //return asyncHandle.Content.ToString(); st.DesctoDev = asyncHandle.Content.ToString(); st.returnID = asyncHandle.Data.success; st.StatusID = asyncHandle.Data.failure; //return asyncHandle.Data.success.ToString(); return(st); } catch (Exception ex) { st.StatusID = 1;// Notification failure st.StatusMsg = ex.Message.ToString(); return(st); } }
public async Task <cStatus> EnquiryNotificationAsync(string DeviceID, string FromUser, string Message, int id, string NotifyType, int senderID) { cStatus st = new cStatus(); FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); string uri; uri = "https://fcm.googleapis.com/fcm/send"; try { var client = new RestClient(uri); var request = new RestRequest(Method.POST); request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY)); request.AddHeader("content-type", "application/json"); request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY)); /*var postData = new * { * to = DeviceID, * data = new * { * MessageID = enquiryid * }, * * notification = new * { * body = enquirymessage, * title = FromUser, * icon = "myicon" * } * };*/ int typeid = 0; if (NotifyType == "Comments") { typeid = 2; } if (NotifyType == "Enquiry") { typeid = 3; } if (NotifyType == "Feedback") { typeid = 4; } var postData = new { to = DeviceID, data = new { title = NotifyType, message = Message, SenderName = FromUser, imageUrl = "", messageId = id, SenderID = senderID, notificationType = typeid //(1->PostMessage, 2-- > Comment, 3 --> Enquiry, and so on) }, priority = "high" }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(postData); //request.AddParameter("application/json", "{\r\n \"to\" : \""+DeviceID+"\"\r\n \"data\":{\r\n \t \"enquiryID\": "+enquiryid.ToString()+"\r\n }\r\n \r\n \"notification\":\r\n {\r\n \"body\": \""+enquirymessage+"\",\r\n \"title\":\""+FromUser +"\",\r\n \"icon\": \"myicon\"\r\n }\r\n }", ParameterType.RequestBody); //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new // { body = enquirymessage, title = FromUser,icon = "myicon" } }) , ParameterType.RequestBody); request.AddParameter("application/json", json, ParameterType.RequestBody); /*var rs = client.Execute(request); * sResponseFromServer = rs.Content.ToString(); * return sResponseFromServer;*/ //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete); IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request); //return asyncHandle.Content.ToString(); st.DesctoDev = asyncHandle.Content.ToString(); st.returnID = asyncHandle.Data.success; st.StatusID = asyncHandle.Data.failure; //return asyncHandle.Data.success.ToString(); return(st); } catch (Exception ex) { st.StatusID = 1;// Notification failure st.StatusMsg = ex.Message.ToString(); return(st); } }
private async Task <IHttpActionResult> EnquiryNotification(string DeviceID, string FromUser, string enquirymessage, int enquiryid) { string toGroup; FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); //var value = "New TELLER:" + TellerService; WebRequest tRequest; String sResponseFromServer; tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); tRequest.Method = "post"; //tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8"; tRequest.Headers.Add(string.Format("Authorization: key={0}", fcmDetails.SERVER_API_KEY)); tRequest.Headers.Add(string.Format("Sender: id={0}", fcmDetails.PROJECT_KEY)); tRequest.ContentType = "application/json;charset=UTF-8"; //toGroup = "/topics/" + GroupName; var postData = new { //registration_ids = deviceids, //to=devicegroup, //to= "ckZ8rtZ6r1I:APA91bHvdVlS7p7-XdQMWAVI1zpG6LfU40Mrllj9u2wRtGhnQ-GUPk43BjtfsDadoJmYviCsn1mMluXaJfWrldLWLccddgAE1cUVIbVP1a7JSo3IIlraZoi4qipt8v-1owIavTniwahd", to = DeviceID, //to = toGroup, data = new { MessageID = enquiryid }, notification = new { body = enquirymessage, title = FromUser, icon = "myicon" } }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(postData); Byte[] byteArray = Encoding.UTF8.GetBytes(json); //Console.WriteLine(data); // Byte[] byteArray = Encoding.UTF8.GetBytes(postData); tRequest.ContentLength = byteArray.Length; try { Stream dataStream; //Stream dataStream = tRequest.GetRequestStream(); using (dataStream = tRequest.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); } WebResponse tResponse = tRequest.GetResponse(); // dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); dataStream = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStream); sResponseFromServer = tReader.ReadToEnd(); tReader.Close(); dataStream.Close(); tResponse.Close(); } catch (Exception ex) { sResponseFromServer = ex.Message.ToString(); } // return sResponseFromServer; return(Ok(sResponseFromServer)); }
public async Task <cStatus> NewTellerNotificationAsync(string GroupName, string TellerName, string TellerService, int senderID) { string toGroup, uri; cStatus st = new cStatus(); FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); var value = "New TELLER:" + TellerService; uri = "https://fcm.googleapis.com/fcm/send"; toGroup = "/topics/" + GroupName; try { var client = new RestClient(uri); var request = new RestRequest(Method.POST); request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY)); request.AddHeader("content-type", "application/json"); request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY)); var postData = new { //registration_ids = deviceids, //to=devicegroup, //to= "ckZ8rtZ6r1I:APA91bHvdVlS7p7-XdQMWAVI1zpG6LfU40Mrllj9u2wRtGhnQ-GUPk43BjtfsDadoJmYviCsn1mMluXaJfWrldLWLccddgAE1cUVIbVP1a7JSo3IIlraZoi4qipt8v-1owIavTniwahd", to = toGroup, data = new { title = " available in THANDORA", message = TellerName + " joined in Thandora as " + TellerService, SenderName = TellerName, imageUrl = "", messageId = senderID, SenderID = senderID, notificationType = 4 //(1->PostMessage, 2-- > Comment, 3 --> Enquiry, 4 -> New Teller and so on) }, priority = "high", /* data = new * { * MessageID = 1 * },*/ /*notification = new * { * body = TellerName + " joined in Thandora as " + TellerService, * title = TellerName + " using THANDORA", * icon = "myicon" * }*/ }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(postData); //request.AddParameter("application/json", "{\r\n \"to\" : \""+DeviceID+"\"\r\n \"data\":{\r\n \t \"enquiryID\": "+enquiryid.ToString()+"\r\n }\r\n \r\n \"notification\":\r\n {\r\n \"body\": \""+enquirymessage+"\",\r\n \"title\":\""+FromUser +"\",\r\n \"icon\": \"myicon\"\r\n }\r\n }", ParameterType.RequestBody); //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new // { body = enquirymessage, title = FromUser,icon = "myicon" } }) , ParameterType.RequestBody); request.AddParameter("application/json", json, ParameterType.RequestBody); /*var rs = client.Execute(request); * sResponseFromServer = rs.Content.ToString(); * return sResponseFromServer;*/ //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete); IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request); //return asyncHandle.Content.ToString(); st.DesctoDev = asyncHandle.Content.ToString(); st.returnID = asyncHandle.Data.success; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE st.StatusID = asyncHandle.Data.failure; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE //return asyncHandle.Data.success.ToString(); return(st); } catch (Exception ex) { st.StatusID = 1; st.StatusMsg = ex.Message.ToString(); return(st); } }
public async Task PostMessageforEachDeviceAsync(string titlebroadcast, string DeviceID, string SenderName, string msgCategory, string message, string imgPath, int MsgID, int senderID) { string uri; cStatus st = new cStatus(); FCMController fcm = new FCMController(); ctblFCM fcmDetails = new ctblFCM(); fcmDetails = (ctblFCM)fcm.GetctblFCM(1); string value; if (message.Length > 50) { value = message.Substring(0, 40) + "..."; } else { value = message; } uri = "https://fcm.googleapis.com/fcm/send"; /* if (SenderName.Equals("THANDORA ADMIN") == true) * { * toGroup = "/topics/THANDORA_ADMIN"; * } * else * { * toGroup = "/topics/" + GroupName; * } */ try { var client = new RestClient(uri); var request = new RestRequest(Method.POST); request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY)); request.AddHeader("content-type", "application/json"); request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY)); var postData = new { //registration_ids = deviceids, //to=devicegroup, //to= "ckZ8rtZ6r1I:APA91bHvdVlS7p7-XdQMWAVI1zpG6LfU40Mrllj9u2wRtGhnQ-GUPk43BjtfsDadoJmYviCsn1mMluXaJfWrldLWLccddgAE1cUVIbVP1a7JSo3IIlraZoi4qipt8v-1owIavTniwahd", //to = toGroup, to = DeviceID, data = new { title = titlebroadcast + "/" + msgCategory, message = value, SenderName = SenderName, imageUrl = imgPath, messageId = MsgID, SenderID = senderID, notificationType = "1" //(1->PostMessage, 2-- > EnquiryReply and so on) }, priority = "high" /*notification = new * { * body = value, * title = titlebroadcast + "/" + msgCategory + "/" + SenderName, * icon = "myicon" * }*/ }; var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(postData); //request.AddParameter("application/json", "{\r\n \"to\" : \""+DeviceID+"\"\r\n \"data\":{\r\n \t \"enquiryID\": "+enquiryid.ToString()+"\r\n }\r\n \r\n \"notification\":\r\n {\r\n \"body\": \""+enquirymessage+"\",\r\n \"title\":\""+FromUser +"\",\r\n \"icon\": \"myicon\"\r\n }\r\n }", ParameterType.RequestBody); //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new // { body = enquirymessage, title = FromUser,icon = "myicon" } }) , ParameterType.RequestBody); request.AddParameter("application/json", json, ParameterType.RequestBody); /*var rs = client.Execute(request); * sResponseFromServer = rs.Content.ToString(); * return sResponseFromServer;*/ //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete); IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request); //return asyncHandle.Content.ToString(); st.DesctoDev = asyncHandle.Content.ToString(); st.returnID = asyncHandle.Data.success; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE st.StatusID = asyncHandle.Data.failure; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE //return asyncHandle.Data.success.ToString(); } catch (Exception ex) { st.StatusID = 1;// Notification failure st.StatusMsg = ex.Message.ToString(); } }
public async Task <IHttpActionResult> PostctblSender([FromBody] ctblSender ctblSender) { cStatus status = new cStatus(); string retvalue; try { string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { SqlCommand cmd = new SqlCommand("sp_new_sender", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramSendName = new SqlParameter(); paramSendName.ParameterName = "@SenderName"; paramSendName.Value = ctblSender.SenderName; cmd.Parameters.Add(paramSendName); SqlParameter paramSenderPhone = new SqlParameter(); paramSenderPhone.ParameterName = "@SenderPhone"; paramSenderPhone.Value = ctblSender.SenderPhone; cmd.Parameters.Add(paramSenderPhone); if (ctblSender.deviceTokenID == null) { ctblSender.deviceTokenID = "Assigned by API"; /* status.StatusID = 1; * status.DesctoDev = "FCM Device id null "; * status.StatusMsg = " FCM Device id null "; * return Ok(status);*/ } SqlParameter paramdeviceTokenID = new SqlParameter(); paramdeviceTokenID.ParameterName = "@IME"; paramdeviceTokenID.Value = ctblSender.deviceTokenID; cmd.Parameters.Add(paramdeviceTokenID); SqlParameter paramRecSIMNO = new SqlParameter(); paramRecSIMNO.ParameterName = "@SIMNO"; paramRecSIMNO.Value = ctblSender.SIMNO; cmd.Parameters.Add(paramRecSIMNO); SqlParameter paramSenderContactNo_1 = new SqlParameter(); paramSenderContactNo_1.ParameterName = "@SenderContactNo_1"; paramSenderContactNo_1.Value = ctblSender.SenderContactNo_1; cmd.Parameters.Add(paramSenderContactNo_1); /* SqlParameter paramSenderContactNo_2 = new SqlParameter(); * paramSenderContactNo_2.ParameterName = "@SenderContactNo_2"; * paramSenderContactNo_2.Value = ctblSender.SenderContactNo_2; * cmd.Parameters.Add(paramSenderContactNo_2); */ SqlParameter paramContactHide = new SqlParameter(); paramContactHide.ParameterName = "@ContactHide"; paramContactHide.Value = ctblSender.ContactHide; cmd.Parameters.Add(paramContactHide); SqlParameter paramcServiceType = new SqlParameter(); paramcServiceType.ParameterName = "@cServiceType"; paramcServiceType.Value = ctblSender.cServiceType; cmd.Parameters.Add(paramcServiceType); SqlParameter paramServiceDesc = new SqlParameter(); paramServiceDesc.ParameterName = "@ServiceDesc"; if (ctblSender.ServiceDesc == null) { ctblSender.ServiceDesc = " "; } paramServiceDesc.Value = ctblSender.ServiceDesc; cmd.Parameters.Add(paramServiceDesc); SqlParameter paramPOSTCODE = new SqlParameter(); paramPOSTCODE.ParameterName = "@POSTCODE"; paramPOSTCODE.Value = ctblSender.POSTCODE; cmd.Parameters.Add(paramPOSTCODE); SqlParameter paramAddress = new SqlParameter(); paramAddress.ParameterName = "@Address"; if (ctblSender.Address == null) { ctblSender.Address = " "; } paramAddress.Value = ctblSender.Address; cmd.Parameters.Add(paramAddress); SqlParameter paramlogopath = new SqlParameter(); paramlogopath.ParameterName = "@logopath"; paramlogopath.Value = ctblSender.logopath; cmd.Parameters.Add(paramlogopath); cmd.Parameters.Add("@LastInsertedID", SqlDbType.Int); cmd.Parameters["@LastInsertedID"].Direction = ParameterDirection.Output; con.Open(); cmd.ExecuteNonQuery(); con.Close(); //retvalue = cmd.Parameters["@LastInsertedID"].Value.ToString(); retvalue = cmd.Parameters["@LastInsertedID"].Value.ToString(); status.returnID = int.Parse(retvalue); if (status.returnID == -5) { status.StatusID = 1; status.DesctoDev = " Name Restricted "; status.StatusMsg = " Name Restricted "; } if (status.returnID == -4) { status.StatusID = 1; status.DesctoDev = "Restricted word in Name "; status.StatusMsg = " Restricted word in Name "; } if (status.returnID == -3) { status.StatusID = 1; status.DesctoDev = "Restricted word in Description "; status.StatusMsg = " Restricted word in Description "; } if (status.returnID == -2) { status.StatusID = 1; status.DesctoDev = "-2 is the error code for invalid POSTAL code. "; status.StatusMsg = " Invalid POSTAL Code. "; } if (status.returnID >= 100000) { // Whenever a new TELLER is added, a new TOPIC will be created in FCM on the TELLER ID. So that the notification //will be published on the TELLER topic name, it will reach automatically all the subcribers of the TELLER. //Every LISTENER & TELLER should be subscribed to the below TOPIC mandatory according to their POSTCODE //FirebaseMessaging.getInstance().subscribeToTopic("POSTCODE); //FirebaseMessaging.getInstance().subscribeToTopic("POSTCODE); //Whenever a receiver subcribing a TELLER from Services menu that time the below line should be exeucted from the client. //FirebaseMessaging.getInstance().subscribeToTopic("SenderID"); //DeviceGroupController dgc = new DeviceGroupController(); //Task<string> s= dgc.CreateTopicGroup(ctblSender.deviceTokenID, status.returnID.ToString()); status.StatusID = 0; //status.DesctoDev = s.ToString(); status.StatusMsg = " User Successfully Created/Updated "; status.userType = "S"; SendNotificationController s = new SendNotificationController(); string msg; FCMController fcm = new FCMController(); cStatus st = new cStatus(); if (ctblSender.cServiceType != "Personal Use" && ctblSender.cServiceType != "Home Maker") { st = await s.NewTellerNotificationAsync(ctblSender.POSTCODE, ctblSender.SenderName, ctblSender.cServiceType, status.returnID); msg = "@POSTCODE:" + ctblSender.POSTCODE + "@SenderName:" + ctblSender.SenderName + "New user joined @ServiceType:" + ctblSender.cServiceType; if (st.DesctoDev.Contains("message_id")) { status.StatusMsg = "Broadcast success"; await fcm.PostFCMResponse(st.DesctoDev, msg, "Y"); } else { status.StatusMsg = "Broadcast failed"; await fcm.PostFCMResponse(st.DesctoDev, msg, "N"); } } ctblEnquiry enq = new ctblEnquiry(); string str; enq.EnquiryID = 0; str = @"Welcome to Thandora a Business/Social media app to promote your business and services. All business users requested to update your Address, Profile picture, business descriptions clearly with commonly searched key words specific to your business. Any search/enquiry on Thandora related to your business area or business name, would be notified to you through SMS and Thandora notification. If you are NOT posting for 30 calendar days, your name and services will be made dormant and made unavailable to public. You can invite your friends/neighbors/business partners/workers/staffs/contractors/owners to promote their business and services. WEB: http://www.thandora.co FB: https://www.facebook.com/search/top/?q=thandora%20-%20a%20business%20app Regards Thandora Admin"; enq.EnquiryMessage = str; enq.FromUserID = 100089; enq.FromUserType = "S"; enq.ToUserID = status.returnID; enq.ToUserType = "S"; enq.AnswerID = 0; MessageController mc = new MessageController(); mc.PostEnquiry(enq); AuthorizationController ac = new AuthorizationController(); ac.RefreshUsers(); } } } catch (Exception ex) { retvalue = ex.Message.ToString(); status.StatusID = 1; status.StatusMsg = retvalue; } return(Ok(status)); }