Esempio n. 1
0
        public void SendTcpConnection()
        {
            Header header = new Header("TMMIN", "SMS-GW", "sendSMS");
            Request request = new Request(null, header, null);
            QueueWorkItem item = new QueueWorkItem();
            item.Command = string.Format(GSMClient.Command.CommandCollection.SMSSend, "082125164012", "hallo");
            item.Enabled = true;
            DailyTrigger trigger = new DailyTrigger();
            trigger.RecursEvery = 1;
            item.Schedule = trigger;

            try
            {
                IKeySym keySym = new PrivateKey();
                request.QueueWorkItem = item;
                GSMClient.BaseGSMCommand dbCommand = new GSMClient.TcpCommand("192.168.0.198", 13005, keySym);
                dbCommand.Connection.Open();
                dbCommand.Request = request;
                dbCommand.Write();
                dbCommand.Connection.Close();
            }
            catch (Exception)
            {

            }
        }
Esempio n. 2
0
        public void InserDailyTrigger()
        {
            Header header = new Header("FRITZ", "SMS-GW", "sendSMS");
            Request request = new Request(null, header, null);
            QueueWorkItem item = new QueueWorkItem();
            item.Command = string.Format(GSMClient.Command.CommandCollection.SMSSend, "082125164012", "hai");
            item.Enabled = true;
            DailyTrigger trigger = new DailyTrigger();
            trigger.RecursEvery = 1;
            item.Schedule = trigger;

            IKeySym keySym = new PrivateKey();
            request.QueueWorkItem = item;
            GSMClient.BaseGSMCommand dbCommand = new GSMClient.DbCommand("Data Source=.;Initial Catalog=SMSGW;User Id=sa;Password=sa123;Integrated Security=False;MultipleActiveResultSets=True", "System.Data.SqlClient");
            dbCommand.Request = request;
            dbCommand.Write();
        }   
Esempio n. 3
0
        private void OnSave(ComposeMessageModel model)
        {
            if (string.IsNullOrEmpty(model.Phonenumber))
                return;

            ApplicationSettings settings = ObjectPool.Instance.Resolve<ApplicationSettings>();
            IKeySym keySym = new ApplicationSettingKeySym();
            Header header;
            Request request;
            QueueWorkItem item;
            IGatewayService service;
            IAudioService audio;

            string[] multipleRecipient = model.Phonenumber.Split(';');
            foreach (string phonenumber in multipleRecipient)
            {
                header = new Header(settings.General.Signature, "desktop client", "SMSSend");
                request = new Request(null, header, null);
                item = new QueueWorkItem();
                 

                item.Command = string.Format(GSMClient.Command.CommandCollection.SMSSend, phonenumber, model.Message);
                item.Enabled = model.Enabled;
                if (date.Length > 10)
                {
                    item.Created = DateTime.Parse(date);
                }
                else
                {
                    item.Created = DateTime.Parse(string.Join(" ", new string[] { date, time }));
                }

                switch (model.TriggerOptions)
                {
                    case ViewModels.Message.TriggerOptions.Daily:
                        DailyTrigger dt = new DailyTrigger();
                        dt.RecursEvery = model.RecursDay;

                        item.Schedule = dt;
                        break;
                    case ViewModels.Message.TriggerOptions.Weekly:
                        WeeklyTrigger wt = new WeeklyTrigger();
                        wt.RecursEvery = model.RecursWeek;
                        wt.Sunday = model.WeeklyOptions.Sunday;
                        wt.Monday = model.WeeklyOptions.Monday;
                        wt.Thursday = model.WeeklyOptions.Thursday;
                        wt.Wednesday = model.WeeklyOptions.Wednesday;
                        wt.Friday = model.WeeklyOptions.Friday;
                        wt.Saturday = model.WeeklyOptions.Saturday;

                        item.Schedule = wt;
                        break;
                    case ViewModels.Message.TriggerOptions.Monthly:
                        MonthlyTrigger mt = new MonthlyTrigger();

                        mt.January = model.Months[0].IsSelected;
                        mt.February = model.Months[1].IsSelected;
                        mt.March = model.Months[2].IsSelected;
                        mt.April = model.Months[3].IsSelected;
                        mt.May = model.Months[4].IsSelected;
                        mt.June = model.Months[5].IsSelected;
                        mt.July = model.Months[6].IsSelected;
                        mt.August = model.Months[7].IsSelected;
                        mt.September = model.Months[8].IsSelected;
                        mt.October = model.Months[9].IsSelected;
                        mt.November = model.Months[10].IsSelected;
                        mt.December = model.Months[11].IsSelected;

                        StringBuilder selected = new StringBuilder();
                        foreach (KeyValueOption option in model.Days)
                        {
                            if (option.IsSelected == 1)
                            {
                                selected.Append(option.Title + ",");
                            }
                        }

                        if (selected.Length > 1)
                            mt.Days = selected.ToString().Remove(selected.Length - 1, 1);

                        item.Schedule = mt;
                        break;
                }

                if (!string.IsNullOrEmpty(model.source))
                {
                    if (model.source == "E")
                    {
                        IDbManager dbManager = ObjectPool.Instance.Resolve<IDbManager>();
                        IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW);

                        db.Execute("DeleteQueue", new
                        {
                            SeqNbr = model.SeqNbr
                        });
                        db.Close();
                    }

                }

                request.QueueWorkItem = item;

                service = GatewayManager.Instance.GetService<DbService>();

                this.IsBusy = true;
                this.IsEnabled = false;

                if (settings.General.Sounds)
                {
                    audio = ObjectPool.Instance.Resolve<IAudioService>();
                    audio.Play(AudioEnum.SendMessage);
                }
                Response = service.Execute(request);

                this.IsEnabled = true;
                this.IsBusy = false;  
            } 
        }