Exemplo n.º 1
0
        public bool ScheduleBroadcast()
        {
            swi        = new Communications();
            swi.APIkey = APIkey;
            swi.APIUrl = APIUrl;

            bool isProceed = false;

            if (ListCode == String.Empty)
            {
                ListCode = swi.CreateContactList(ContactListCampaignName, String.Format("CouncilID: {0}", CouncilID));
            }

            if (ListCode != String.Empty && !swi.isError)
            {
                if (UploadCSVstatusCode == String.Empty)
                {
                    UploadCSVstatusCode = swi.UploadAndImportCSV(ListCode, FullPathToCSV, "true");
                }

                string runDateTime;

                if (!swi.isError)
                {
                    if (isTTS)
                    {
                        isProceed = CreateVoiceCode();

                        if (isProceed)
                        {
                            //Schedule the TTS
                            //Convert datetime to Council's timezone
                            runDateTime = TTSrunOnDateTime.ToString();
                            if (TimeZone != "EST")
                            {
                                string fromTZ = TimeZone;
                                string toTZ   = "EST";
                                runDateTime = swi.TZconvert(TTSrunOnDateTime.ToString(), fromTZ, toTZ);
                            }

                            TTSscheduledAlertCode = swi.CreateScheduledAlert(ListCode, VoiceCode, "0", runDateTime, TTScampaignName);

                            if (swi.isError)
                            {
                                isError      = swi.isError;
                                ErrorMessage = swi.errorMessage;
                                isProceed    = false;
                            }
                        }
                    }
                    else
                    {
                        VoiceCode = "0";
                    }

                    if (isSMS)
                    {
                        isProceed = CreateSmsCode();

                        if (isProceed)
                        {
                            //Schedule the SMS
                            //Convert datetime to Council's timezone
                            runDateTime = SMSrunOnDateTime.ToString();
                            if (TimeZone != "EST")
                            {
                                string fromTZ = TimeZone;
                                string toTZ   = "EST";
                                runDateTime = swi.TZconvert(SMSrunOnDateTime.ToString(), fromTZ, toTZ);
                            }

                            SMSscheduledAlertCode = swi.CreateScheduledAlert(ListCode, "0", SmsCode, runDateTime, SMScampaignName);

                            if (swi.isError)
                            {
                                isError      = swi.isError;
                                ErrorMessage = swi.errorMessage;
                                isProceed    = false;
                            }
                        }
                    }
                    else
                    {
                        SmsCode = "0";
                    }
                }
                else if (swi.isError)
                {
                    isError      = swi.isError;
                    ErrorMessage = swi.errorMessage;
                }
            }
            else if (swi.isError)
            {
                isError      = swi.isError;
                ErrorMessage = swi.errorMessage;
            }

            return(isProceed);
        }