/// <summary> /// Update /// </summary> ///<param name="pChatUser">ChatUser</param> /// <returns>void</returns> /// <Date>2015-01-19T10:21:49</Date> /// <Author>moviedo</Author> public static void Update(ChatUserBE pChatUser) { Database dataBase = null; DbCommand cmd = null; //try //{ dataBase = DatabaseFactory.CreateDatabase(Common.Common.EpironChatLogs_CnnStringName); using (cmd = dataBase.GetStoredProcCommand("[Chat].[ChatUser_u]")) { dataBase.AddInParameter(cmd, "ChatUserId", System.Data.DbType.Int32, pChatUser.ChatUserId); //dataBase.AddInParameter(cmd, "ChatUserPhone", System.Data.DbType.String, pChatUser.ChatUserPhone); dataBase.AddInParameter(cmd, "ChatUserName", System.Data.DbType.String, pChatUser.ChatUserName); dataBase.AddInParameter(cmd, "ChatUserEmail", System.Data.DbType.String, pChatUser.ChatUserEmail); //dataBase.AddInParameter(cmd, "ChatUserModifiedDate", System.Data.DbType.DateTime, pChatUser.ChatUserModifiedDate); dataBase.ExecuteNonQuery(cmd); } //} //catch (Exception ex) //{ // throw Fwk.Exceptions.ExceptionHelper.ProcessException(ex); //} }
public static bool SentEmail(string pMessage, bool wToTheClientFlag, ChatMailSenderBE pChatMailSender, ChatUserBE pChatUser) { try { if (pChatMailSender == null || pChatUser == null) return false; System.Net.Mail.MailMessage wMessage = new System.Net.Mail.MailMessage() ; SmtpClient wSmtpClient = new SmtpClient(pChatMailSender.SMTPServer, pChatMailSender.SMTPPort); //Configuraciones de la cuenta wSmtpClient.UseDefaultCredentials = false; wSmtpClient.Credentials = new System.Net.NetworkCredential(pChatMailSender.UserName, pChatMailSender.Password); wSmtpClient.Timeout = 300000; wSmtpClient.EnableSsl = pChatMailSender.EnableSSL; //wSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; //Configuraciones del email wMessage = new System.Net.Mail.MailMessage() { Body = pMessage,BodyEncoding = Encoding.UTF8, IsBodyHtml = true }; //Configuro el FROM y TO . wMessage.From = new MailAddress(pChatMailSender.Email); string wSubject = string.Empty; if (wToTheClientFlag) { wMessage.To.Add(new MailAddress(pChatUser.ChatUserEmail)); //En el caso de que sea desde la empresa para el cliente wMessage.Subject = "- [Chat Epiron] - "; //<--- completar } else { wMessage.To.Add(new MailAddress(pChatMailSender.Email));//En el caso de que sea desde el cliente para la empresa //El asunto o subject del email para el caso wToTheClientFlag == false, se conforma con el formtamo [TAG]@Email_del_cliente[/TAG] wMessage.Subject = pChatMailSender.TagStartWith + pChatUser.ChatUserEmail + pChatMailSender.TagEndWith; } System.Net.Mail.Attachment wAttachFile = null; //<--- por ahora sin attachments wSmtpClient.Send(wMessage); } catch (Exception ex) { } return true; }
/// <summary> /// Trae los datos sobre la cuenta de email del Usere /// </summary> /// <param name="pChatConfigGuid">id configuración de la cuenta</param> /// <returns></returns> public static ChatUserBE GetByParams(String chatUserPhone) { ChatUserBE wChatUser = null; Database database = null; //try //{ database = DatabaseFactory.CreateDatabase(Common.Common.EpironChatLogs_CnnStringName); using (DbCommand cmd = database.GetStoredProcCommand("[Chat].[ChatUser_g]")) { if (!String.IsNullOrEmpty(chatUserPhone)) { database.AddInParameter(cmd, "ChatUserPhone", DbType.String, chatUserPhone); } using (IDataReader reader = database.ExecuteReader(cmd)) { while (reader.Read()) { wChatUser = new ChatUserBE(); wChatUser.ChatUserId = Convert.ToInt32(reader["ChatUserId"]); if (reader["ChatUserPhone"] != DBNull.Value) { wChatUser.ChatUserPhone = Convert.ToString(reader["ChatUserPhone"]); } if (reader["ChatUserName"] != DBNull.Value) { wChatUser.ChatUserName = Convert.ToString(reader["ChatUserName"]); } if (reader["ChatUserEmail"] != DBNull.Value) { wChatUser.ChatUserEmail = Convert.ToString(reader["ChatUserEmail"]); } } } } return(wChatUser); //} //catch (Exception ex) //{ // throw SecPortalException.ProcessException(ex, typeof(EpironChatDAC), "EpironChatConnectionString"); //} }
internal static int CheckPhoneId(string phoneNumber, String clientName, String email) { ChatUserBE wChatUserBE = GetChatUser(phoneNumber, clientName); if (wChatUserBE != null) return wChatUserBE.ChatUserId; wChatUserBE = new ChatUserBE(); /// Si no existe lo crea wChatUserBE.ChatUserPhone = phoneNumber; wChatUserBE.ChatUserName = clientName; wChatUserBE.ChatUserEmail = email; ChatUserDAC.Insert(wChatUserBE); return wChatUserBE.ChatUserId; }
internal static int CheckPhoneId(string phoneNumber, String clientName, String email) { ChatUserBE wChatUserBE = GetChatUser(phoneNumber, clientName); if (wChatUserBE != null) { return(wChatUserBE.ChatUserId); } wChatUserBE = new ChatUserBE(); /// Si no existe lo crea wChatUserBE.ChatUserPhone = phoneNumber; wChatUserBE.ChatUserName = clientName; wChatUserBE.ChatUserEmail = email; ChatUserDAC.Insert(wChatUserBE); return(wChatUserBE.ChatUserId); }
/// <summary> /// /// </summary> /// <param name="phone"></param> /// <param name="clientName"></param> /// <returns></returns> static ChatUserBE GetChatUser(string phoneNumber, String clientName) { bool needUpdate = false; //String id = String.Concat(clientName, "$", phone); ChatUserBE userBE = ChatUserDAC.GetByParams(phoneNumber); if (userBE != null) { //Si esta en null directamtente le seteamos el clientName (este caso no deberia existir pero fisicamente es posible) //if (String.IsNullOrEmpty(userBE.ChatUserPhone)) //{ // userBE.ChatUserPhone = phoneNumber; // needUpdate = true; //} //Actualiza el nombre del cliente si es necesario if (!String.IsNullOrEmpty(clientName)) { if (userBE.ChatUserName.Trim().CompareTo(clientName.Trim()) != 0) { userBE.ChatUserName = clientName; needUpdate = true; } } if (needUpdate) { ChatUserDAC.Update(userBE); } return(userBE); } else { return(null); } }
public ActionResult SendEmail(string cellPhone, string email, string emailBody, bool toTheClientFlag, string pGuid, int pRoomId, int pIsNoOperator) { try { ChatMailSenderBE wChatMailSenderBE = null; if (pGuid == "0") { ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(null); wChatMailSenderBE = EpironChatEmailBC.GetChatMailSenderByCongGuid(chatConfigBE.ChatConfigGuid); } else { Guid wGuid = new Guid(pGuid); wChatMailSenderBE = EpironChatEmailBC.GetChatMailSenderByCongGuid(wGuid); } ChatUserBE wChatUserBE = new ChatUserBE(); wChatUserBE.ChatUserEmail = email; //<--usaremos el email que el usuario nos provee, aunque este tenga uno previo, no lo modificaremos en la base if (toTheClientFlag) { string css = @" <style>.bubbleOwn { position: relative; width: 60%; /*height: 35px;*/ padding: 5px; background-color: #71C837; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; left: 1px; clear: both; margin:6px 0px 1px 8px; border: 1px solid #CCC; /*min-height: 35px;*/ } .bubbleThey { position: relative; width: 60%; /*height: 35px;*/ padding: 2px; background: white; border: 1px solid #CCC; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; float: right; margin-right: 1px; clear: both; margin:6px 8px 1px 0px; /*min-height: 35px;*/ } ._time { float: right; font-size: 10px; } </style>"; emailBody = css + emailBody; } bool isSent = EmailHelper.SentEmail(emailBody, toTheClientFlag, wChatMailSenderBE, wChatUserBE); if (isSent) { //se registra en la base que se ha enviado un email ChatEmailMessageBE wChatEmailMessageBE = new ChatEmailMessageBE(); // pIsNoOperator <-- Indica si este email se envia tras no encontrar operadores disponibles wChatEmailMessageBE.ChatDescription = pIsNoOperator == 1 ? "SIN-OPERADORES" : null; wChatEmailMessageBE.EmailFrom = wChatMailSenderBE.Email; if (pRoomId != 0) wChatEmailMessageBE.ChatRoomId = pRoomId; else wChatEmailMessageBE.ChatRoomId = null; wChatEmailMessageBE.Body = emailBody; if (toTheClientFlag) { wChatEmailMessageBE.Subject = "-Subject-"; wChatEmailMessageBE.DeliveredTo = wChatUserBE.ChatUserEmail; } else { wChatEmailMessageBE.Subject = wChatMailSenderBE.TagStartWith + wChatUserBE.ChatUserEmail + wChatMailSenderBE.TagEndWith; wChatEmailMessageBE.DeliveredTo = wChatMailSenderBE.Email; } bool saved = EpironChatEmailBC.InsertChatEmailMessage(wChatEmailMessageBE); if (saved) { return Json(new { Result = "OK", Message = "Correo enviado correctamente" }); } else { return Json(new { Result = "OK", Message = "Error al Guardar el Email" }); //<-- Revisar si se debe o no avisar al cliente } } else { return Json(new { Result = "OK", Message = "Error al Enviar Correo" }); //<-- Revisar si se debe o no avisar al cliente } } catch (Exception ex) { return Json(new { Result = "ERROR", Message = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex) }); } }
public ActionResult SendEmail(string cellPhone, string email, string emailBody, bool toTheClientFlag, string pGuid, int pRoomId, int pIsNoOperator) { try { ChatMailSenderBE wChatMailSenderBE = null; if (pGuid == "0") { ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(null); wChatMailSenderBE = EpironChatEmailBC.GetChatMailSenderByCongGuid(chatConfigBE.ChatConfigGuid); } else { Guid wGuid = new Guid(pGuid); wChatMailSenderBE = EpironChatEmailBC.GetChatMailSenderByCongGuid(wGuid); } ChatUserBE wChatUserBE = new ChatUserBE(); wChatUserBE.ChatUserEmail = email; //<--usaremos el email que el usuario nos provee, aunque este tenga uno previo, no lo modificaremos en la base if (toTheClientFlag) { string css = @" <style>.bubbleOwn { position: relative; width: 60%; /*height: 35px;*/ padding: 5px; background-color: #71C837; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; left: 1px; clear: both; margin:6px 0px 1px 8px; border: 1px solid #CCC; /*min-height: 35px;*/ } .bubbleThey { position: relative; width: 60%; /*height: 35px;*/ padding: 2px; background: white; border: 1px solid #CCC; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; float: right; margin-right: 1px; clear: both; margin:6px 8px 1px 0px; /*min-height: 35px;*/ } ._time { float: right; font-size: 10px; } </style>"; emailBody = css + emailBody; } bool isSent = EmailHelper.SentEmail(emailBody, toTheClientFlag, wChatMailSenderBE, wChatUserBE); if (isSent) { //se registra en la base que se ha enviado un email ChatEmailMessageBE wChatEmailMessageBE = new ChatEmailMessageBE(); // pIsNoOperator <-- Indica si este email se envia tras no encontrar operadores disponibles wChatEmailMessageBE.ChatDescription = pIsNoOperator == 1 ? "SIN-OPERADORES" : null; wChatEmailMessageBE.EmailFrom = wChatMailSenderBE.Email; if (pRoomId != 0) { wChatEmailMessageBE.ChatRoomId = pRoomId; } else { wChatEmailMessageBE.ChatRoomId = null; } wChatEmailMessageBE.Body = emailBody; if (toTheClientFlag) { wChatEmailMessageBE.Subject = "-Subject-"; wChatEmailMessageBE.DeliveredTo = wChatUserBE.ChatUserEmail; } else { wChatEmailMessageBE.Subject = wChatMailSenderBE.TagStartWith + wChatUserBE.ChatUserEmail + wChatMailSenderBE.TagEndWith; wChatEmailMessageBE.DeliveredTo = wChatMailSenderBE.Email; } bool saved = EpironChatEmailBC.InsertChatEmailMessage(wChatEmailMessageBE); if (saved) { return(Json(new { Result = "OK", Message = "Correo enviado correctamente" })); } else { return(Json(new { Result = "OK", Message = "Error al Guardar el Email" })); //<-- Revisar si se debe o no avisar al cliente } } else { return(Json(new { Result = "OK", Message = "Error al Enviar Correo" })); //<-- Revisar si se debe o no avisar al cliente } } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex) })); } }
/// <summary> /// Trae los datos sobre la cuenta de email del Usere /// </summary> /// <param name="pChatConfigGuid">id configuración de la cuenta</param> /// <returns></returns> public static ChatUserBE GetByParams(String chatUserPhone) { ChatUserBE wChatUser = null; Database database = null; //try //{ database = DatabaseFactory.CreateDatabase(Common.Common.EpironChatLogs_CnnStringName); using (DbCommand cmd = database.GetStoredProcCommand("[Chat].[ChatUser_g]")) { if (!String.IsNullOrEmpty(chatUserPhone)) database.AddInParameter(cmd, "ChatUserPhone", DbType.String, chatUserPhone); using (IDataReader reader = database.ExecuteReader(cmd)) { while (reader.Read()) { wChatUser = new ChatUserBE(); wChatUser.ChatUserId = Convert.ToInt32(reader["ChatUserId"]); if (reader["ChatUserPhone"] != DBNull.Value) wChatUser.ChatUserPhone = Convert.ToString(reader["ChatUserPhone"]); if (reader["ChatUserName"] != DBNull.Value) wChatUser.ChatUserName = Convert.ToString(reader["ChatUserName"]); if (reader["ChatUserEmail"] != DBNull.Value) wChatUser.ChatUserEmail = Convert.ToString(reader["ChatUserEmail"]); } } } return wChatUser; //} //catch (Exception ex) //{ // throw SecPortalException.ProcessException(ex, typeof(EpironChatDAC), "EpironChatConnectionString"); //} }
public static bool SentEmail(string pMessage, bool wToTheClientFlag, ChatMailSenderBE pChatMailSender, ChatUserBE pChatUser) { try { if (pChatMailSender == null || pChatUser == null) { return(false); } System.Net.Mail.MailMessage wMessage = new System.Net.Mail.MailMessage(); SmtpClient wSmtpClient = new SmtpClient(pChatMailSender.SMTPServer, pChatMailSender.SMTPPort); //Configuraciones de la cuenta wSmtpClient.UseDefaultCredentials = false; wSmtpClient.Credentials = new System.Net.NetworkCredential(pChatMailSender.UserName, pChatMailSender.Password); wSmtpClient.Timeout = 300000; wSmtpClient.EnableSsl = pChatMailSender.EnableSSL; //wSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; //Configuraciones del email wMessage = new System.Net.Mail.MailMessage() { Body = pMessage, BodyEncoding = Encoding.UTF8, IsBodyHtml = true }; //Configuro el FROM y TO . wMessage.From = new MailAddress(pChatMailSender.Email); string wSubject = string.Empty; if (wToTheClientFlag) { wMessage.To.Add(new MailAddress(pChatUser.ChatUserEmail)); //En el caso de que sea desde la empresa para el cliente wMessage.Subject = "- [Chat Epiron] - "; //<--- completar } else { wMessage.To.Add(new MailAddress(pChatMailSender.Email));//En el caso de que sea desde el cliente para la empresa //El asunto o subject del email para el caso wToTheClientFlag == false, se conforma con el formtamo [TAG]@Email_del_cliente[/TAG] wMessage.Subject = pChatMailSender.TagStartWith + pChatUser.ChatUserEmail + pChatMailSender.TagEndWith; } System.Net.Mail.Attachment wAttachFile = null; //<--- por ahora sin attachments wSmtpClient.Send(wMessage); } catch (Exception ex) { } return(true); }