Пример #1
0
 public static bool SendContentToReceiver(Guid regularContentGuid, Guid privateNumberGuid,
                                          Guid userGuid, Business.SmsSentPeriodType periodType, int period,
                                          DateTime effectiveDateTime)
 {
     Business.Content contentController = new Business.Content();
     return(contentController.SendContentToReceiver(regularContentGuid, privateNumberGuid, userGuid, periodType, period, effectiveDateTime));
 }
Пример #2
0
 public bool SendContentToReceiver(Guid regularContentGuid, Guid privateNumberGuid,
                                   Guid userGuid, Business.SmsSentPeriodType periodType, int period,
                                   DateTime effectiveDateTime)
 {
     return(ExecuteSPCommand("SendContentToReceiver",
                             "@RegularContentGuid", regularContentGuid,
                             "@PrivateNumberGuid", privateNumberGuid,
                             "@UserGuid", userGuid,
                             "@PeriodType", periodType,
                             "@Period", period,
                             "@EffectiveDateTime", effectiveDateTime));
 }
        private void SendContentToReceivers(Guid regularContentGuid, Guid privateNumberGuid,
                                            Guid userGuid, Business.SmsSentPeriodType periodType, int period,
                                            DateTime effectiveDateTime)
        {
            try
            {
                Facade.Content.SendContentToReceiver(regularContentGuid, privateNumberGuid, userGuid, periodType, period, effectiveDateTime);
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n ProcessRegularContent : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n ProcessRegularContent : {0}", ex.StackTrace));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));
            }
        }
        private void ProcessRegularContent(Guid regularContentGuid, Guid privateNumberGuid, Business.RegularContentType type,
                                           string config, Business.WarningType warningType, Guid userGuid, Business.SmsSentPeriodType periodType,
                                           int period, DateTime effectiveDateTime)
        {
            try
            {
                string response = string.Empty;
                Business.RegularContentSerialization regularContentSerialization = (Business.RegularContentSerialization)GeneralLibrary.SerializationTools.DeserializeXml(config, typeof(Business.RegularContentSerialization));

                switch (type)
                {
                case Business.RegularContentType.URL:
                    try
                    {
                        using (var wb = new WebClient())
                        {
                            response = wb.DownloadString(regularContentSerialization.URL);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n RegularContentType.URL URL: {0}", regularContentSerialization.URL));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n RegularContentType.URL Response: {0}", response));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n RegularContentType.URL DownloadString: {0}", ex.Message));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));

                        switch (warningType)
                        {
                        case Business.WarningType.Sms:
                            //Facade.ScheduledSms.InsertSms()
                            break;
                        }

                        throw ex;
                    }

                    if (!string.IsNullOrEmpty(response))
                    {
                        Facade.RegularContent.SendURLContentToReceiver(regularContentGuid, privateNumberGuid, userGuid, response, periodType, period, effectiveDateTime);
                    }

                    break;

                case Business.RegularContentType.DB:
                    try
                    {
                        DataTable dataTable = new DataTable();
                        dataAdapter = new SqlDataAdapter();
                        command     = new SqlCommand();
                        connection  = new SqlConnection(regularContentSerialization.ConnectionString);

                        command.CommandType    = CommandType.Text;
                        command.CommandText    = regularContentSerialization.Query;
                        command.Connection     = connection;
                        command.CommandTimeout = 60;

                        dataAdapter.SelectCommand = command;

                        connection.Open();
                        dataAdapter.Fill(dataTable);

                        if (dataTable.Rows.Count > 0)
                        {
                            response = dataTable.Rows[0][regularContentSerialization.Field].ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n RegularContentType.DB Guid: {0}", regularContentGuid));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n RegularContentType.DB Error: {0}", ex.Message));

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));

                        switch (warningType)
                        {
                        case Business.WarningType.Sms:
                            //Facade.ScheduledSms.InsertSms()
                            break;
                        }

                        throw ex;
                    }

                    if (!string.IsNullOrEmpty(response))
                    {
                        Facade.RegularContent.SendDBContentToReceiver(regularContentGuid, privateNumberGuid, userGuid, response, periodType, period, effectiveDateTime);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n ProcessRegularContent : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n ProcessRegularContent : {0}", ex.StackTrace));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.RegularContent, string.Format("\r\n-------------------------------------------------------------------------"));
            }
        }