public JsonResult sendEmail(EmailData data) { string from = "*****@*****.**"; string password = "******"; string subject = data.subject; string body = data.message; foreach (var contact in data.emails) { Thread email = new Thread(delegate() { SendEmail(contact.email, from, password, subject, body); }); email.IsBackground = true; email.Start(); } ResponseNotification response = new ResponseNotification(); response.Success = true; response.Message = "Correos enviados exitosamente"; var jsonResult = Json(response, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }
public async Task <IActionResult> ZaloCallback(string code, string state) { Zalo3rdAppInfo appInfo = new Zalo3rdAppInfo(Int64.Parse(_externalProvider.Value.Zalo.AppId), _externalProvider.Value.Zalo.SecretCode, _externalProvider.Value.Zalo.CallbackUrl); Zalo3rdAppClient appClient = new Zalo3rdAppClient(appInfo); JObject token = appClient.getAccessToken(code); var accessToken = token["access_token"].ToString(); JObject profile = appClient.getProfile(accessToken, "name, id, picture"); var tmpData = profile.ToObject <ExternalUserModel>(); var user = await _userStoreExtend.FindByNameAsync("Zalo" + tmpData.id); if (user != null) { #region Get user zalo var permissions = await _roleStoreExtend.ReadByUser(user.Id); var userInfo = _mapper.Map <UserInfo>(user); userInfo.Permissions = permissions; string[] output = userInfo.FullName.Split(' '); foreach (string s in output) { userInfo.LetterAvatar += s[0]; } userInfo.Avatar = (userInfo.Avatar == null ? "" : _imagePath.Value.URL + userInfo.Avatar); userInfo.PhoneNumber = (userInfo.PhoneNumber == null ? "" : userInfo.PhoneNumber); userInfo.LetterAvatar = userInfo.LetterAvatar.ToUpper(); #endregion var responseLogin = new ResponseNotification(); var response = new Response(); responseLogin.type = 1; response.response = userInfo; responseLogin.response = response; //await PushNotification(state, "Okaylah", "Đăng nhập zalo thành công", "Success", JsonConvert.SerializeObject(responseLogin)); } else { var responseLogin = new ResponseNotification(); responseLogin.type = 1; var responseEr = new ResponseError(); responseEr.status = "404"; responseEr.response = accessToken; responseLogin.response = responseEr; //await PushNotification(state, "Okaylah", "Đăng nhập zalo thất công", "Register", JsonConvert.SerializeObject(responseLogin)); } return(Ok()); }
public ResponseOutput(T data, NotificationType type, int statusCode, string displayNotice, string debuggerNotice) { OutputData = data; OutputNotification = new ResponseNotification(type, statusCode, displayNotice, debuggerNotice); }
public JsonResult sendSmsNotification(List <SmsContact> phones, string message) { var client = new AmazonSimpleNotificationServiceClient(accessKey, secretKey, RegionEndpoint.USEast1); PublishRequest smsRequest = new PublishRequest(); PublishResponse smsResponse = new PublishResponse(); var snsMessageAttributes = new Dictionary <string, MessageAttributeValue>(); ResponseNotification response = new ResponseNotification(); var cont = 0; var phoneCont = 0; foreach (var phone in phones) { phoneCont++; var subscribe = subscribePhoneToTopic(phone.phone); if (subscribe.HttpStatusCode == HttpStatusCode.OK) { cont++; } } if (cont == 0) { response.Success = false; response.Message = "Ocurrió un error al suscribir los contactos"; } //ENVIO DEL SMS if (message != "") { var smsType = new MessageAttributeValue { DataType = "String", StringValue = "Transactional" }; snsMessageAttributes.Add("AWS.SNS.SMS.SMSType", smsType); smsRequest.TopicArn = topicArn; smsRequest.Message = message; smsRequest.MessageAttributes = snsMessageAttributes; //SEND SMS try { smsResponse = client.Publish(smsRequest); var MessageId = smsResponse.MessageId; //DELETE SUSCRIPTORS if (MessageId != "") { DeleteTopicRequest topicToDelete = new DeleteTopicRequest(topicArn); client.DeleteTopic(topicToDelete); } response.Success = true; response.Message = "Sms campain sended with de ID: " + MessageId; } catch (Exception ex) { response.Success = false; response.Message = ex.InnerException.InnerException.Message; } } var jsonResult = Json(response, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }