Пример #1
0
        public SMS_Response send_sms(string type, int booking_id, string mobile_no, string content_dict, string key)
        {
            SMS_Response response = new SMS_Response();

            response.result.type       = type;
            response.result.booking_id = booking_id;
            response.result.mobile_no  = mobile_no;
            Dictionary <string, string> content = JsonConvert.DeserializeObject <Dictionary <string, string> >(content_dict);

            SMS.SMS_Sender sms_sender;
            string         sms_template;

            SMS.SMS_Data sms_data;
            string       sms_text;
            string       sms_complete_url = "";
            string       tag = "tyaari";

            Utils.clsLogger logger = new Utils.clsLogger();
            string          default_sms_gateway = ConfigurationManager.AppSettings["DEFAULT_SMS_GATEWAY"].ToString();

            string[] valid_sms_types = ConfigurationManager.AppSettings["Valid_SMS_Types"].ToString().Split(',');
            try
            {
                if (valid_sms_types.Contains(type))
                {
                    if (type.EndsWith("gds"))
                    {
                        tag = "mantis";
                    }
                    sms_sender       = new SMS.SMS_Sender(default_sms_gateway, type, key);
                    sms_template     = SMS.SMS_Sender.get_sms_template(type);
                    sms_data         = new SMS.SMS_Data(content);
                    sms_text         = sms_data.prepare_booking_sms(sms_template);
                    sms_complete_url = sms_sender.send_sms(mobile_no, sms_text, tag);
                    response.status  = true;
                }
                else
                {
                    throw new System.Exception("Invalid SMS Type");
                }
            }
            catch (System.Exception ex)
            {
                logger.log("error", new Dictionary <string, object>
                {
                    { "booking_id", booking_id },
                    { "mobile_no", mobile_no },
                    { "type", type }
                }, ex.ToString());
                response.status = false;
                response.error  = ex.Message;
            }

            //Log sms into db for accounting purpose;
            SMS.SMS_Sender.log_sms_into_db(booking_id, mobile_no, sms_complete_url, Convert.ToInt32(response.status));
            return(response);
        }
Пример #2
0
        public SMS_Response send_sms(string type, int booking_id, string mobile_no, string content_dict, string key)
        {
            SMS_Response response = new SMS_Response();
            response.result.type = type;
            response.result.booking_id = booking_id;
            response.result.mobile_no = mobile_no;
            Dictionary<string,string> content =  JsonConvert.DeserializeObject<Dictionary<string, string>>(content_dict);

            SMS.SMS_Sender sms_sender;
            string sms_template;
            SMS.SMS_Data sms_data;
            string sms_text;
            string sms_complete_url="";
            string tag = "tyaari";
            Utils.clsLogger logger = new Utils.clsLogger();
            string default_sms_gateway=ConfigurationManager.AppSettings["DEFAULT_SMS_GATEWAY"].ToString();
            string[] valid_sms_types = ConfigurationManager.AppSettings["Valid_SMS_Types"].ToString().Split(',');
            try
            {
                if(valid_sms_types.Contains(type))
                {
                    if (type.EndsWith("gds"))
                        tag = "mantis";
                    sms_sender = new SMS.SMS_Sender(default_sms_gateway,type, key);
                    sms_template = SMS.SMS_Sender.get_sms_template(type);
                    sms_data = new SMS.SMS_Data(content);
                    sms_text = sms_data.prepare_booking_sms(sms_template);
                    sms_complete_url = sms_sender.send_sms(mobile_no, sms_text, tag);
                    response.status = true;
                }
                else
                {
                    throw new System.Exception("Invalid SMS Type");
                }

            }
            catch (System.Exception ex)
            {
                logger.log("error", new Dictionary<string, object>
                {   {"booking_id",booking_id},
                    {"mobile_no",mobile_no},
                    {"type",type}
                }, ex.ToString());
                response.status = false;
                response.error = ex.Message;
            }

            //Log sms into db for accounting purpose;
            SMS.SMS_Sender.log_sms_into_db(booking_id, mobile_no, sms_complete_url, Convert.ToInt32(response.status));
            return response;
        }
Пример #3
0
        public Email_Response send_email(string type, int booking_id, string email_ids, string cc_email_ids, string bcc_email_ids, string subject, string content_dict, string attachments_dict)
        {
            Email_Response response = new Email_Response();
            Email.Email email;
            Utils.clsLogger logger = new Utils.clsLogger();
            Dictionary<string, object> content = new Dictionary<string, object>();
            Dictionary<string, object> attachments = new Dictionary<string, object>();

            if (type == null || type.Trim().Length == 0)
            {
                type = "blank_email";
            }

            content = JsonConvert.DeserializeObject<Dictionary<string, object>>(content_dict);

            if (attachments_dict != null)
            {
                attachments = JsonConvert.DeserializeObject<Dictionary<string, object>>(attachments_dict);
            }

            string[] valid_email_types = ConfigurationManager.AppSettings["Valid_Email_Types"].ToString().Split(',');

            int success = 1;
            try
            {
                response.result.type = type;
                response.result.booking_id = booking_id;
                response.result.email_ids = email_ids;
                response.result.cc_email_ids = cc_email_ids;
                response.result.bcc_email_ids = bcc_email_ids;
                response.status = true;

                if(valid_email_types.Contains(type))
                {
                    email = new Email.Email(type, subject, content,attachments);
                    response.status = email.send_email(booking_id, email_ids, cc_email_ids, bcc_email_ids);
                }
                else
                {
                    throw new System.Exception("Invalid Email Type");
                }
            }
            catch (System.Exception ex)
            {
                success = 0;
                logger.log("error", new Dictionary<string, object>
                {   {"booking_id",booking_id},
                    {"email_ids",email_ids},
                    {"cc_email_ids",cc_email_ids},
                    {"bcc_email_ids",bcc_email_ids},
                    {"type",type}
                }, ex.ToString());
                response.status = false;
                response.error = ex.Message;
            }

            if (success == 1)
            {
                logger.log("info", new Dictionary<string, object>
                {   {"booking_id",booking_id},
                    {"email_ids",email_ids},
                    {"cc_email_ids",cc_email_ids},
                    {"bcc_email_ids",bcc_email_ids},
                    {"type",type}
                }, "success");
            }
            //Log email into db;
            //Email.Email.log_email_into_db(type, booking_id, response.result.email_ids, response.result.cc_email_ids, response.result.bcc_email_ids, response.error, Convert.ToInt32(response.status));
            return response;
        }
Пример #4
0
        public Email_Response send_email(string type, int booking_id, string email_ids, string cc_email_ids, string bcc_email_ids, string subject, string content_dict, string attachments_dict)
        {
            Email_Response response = new Email_Response();

            Email.Email                 email;
            Utils.clsLogger             logger      = new Utils.clsLogger();
            Dictionary <string, object> content     = new Dictionary <string, object>();
            Dictionary <string, object> attachments = new Dictionary <string, object>();

            if (type == null || type.Trim().Length == 0)
            {
                type = "blank_email";
            }

            content = JsonConvert.DeserializeObject <Dictionary <string, object> >(content_dict);

            if (attachments_dict != null)
            {
                attachments = JsonConvert.DeserializeObject <Dictionary <string, object> >(attachments_dict);
            }

            string[] valid_email_types = ConfigurationManager.AppSettings["Valid_Email_Types"].ToString().Split(',');

            int success = 1;

            try
            {
                response.result.type          = type;
                response.result.booking_id    = booking_id;
                response.result.email_ids     = email_ids;
                response.result.cc_email_ids  = cc_email_ids;
                response.result.bcc_email_ids = bcc_email_ids;
                response.status = true;

                if (valid_email_types.Contains(type))
                {
                    email           = new Email.Email(type, subject, content, attachments);
                    response.status = email.send_email(booking_id, email_ids, cc_email_ids, bcc_email_ids);
                }
                else
                {
                    throw new System.Exception("Invalid Email Type");
                }
            }
            catch (System.Exception ex)
            {
                success = 0;
                logger.log("error", new Dictionary <string, object>
                {
                    { "booking_id", booking_id },
                    { "email_ids", email_ids },
                    { "cc_email_ids", cc_email_ids },
                    { "bcc_email_ids", bcc_email_ids },
                    { "type", type }
                }, ex.ToString());
                response.status = false;
                response.error  = ex.Message;
            }

            if (success == 1)
            {
                logger.log("info", new Dictionary <string, object>
                {
                    { "booking_id", booking_id },
                    { "email_ids", email_ids },
                    { "cc_email_ids", cc_email_ids },
                    { "bcc_email_ids", bcc_email_ids },
                    { "type", type }
                }, "success");
            }
            //Log email into db;
            //Email.Email.log_email_into_db(type, booking_id, response.result.email_ids, response.result.cc_email_ids, response.result.bcc_email_ids, response.error, Convert.ToInt32(response.status));
            return(response);
        }