예제 #1
0
        public void InsertWeeklyTrigger()
        {
            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;
            WeeklyTrigger week = new WeeklyTrigger();
            week.Monday = 1;
            week.Thursday = 1;
            week.RecursEvery = 1;
            item.Schedule = week;

            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(); 
        }
예제 #2
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;  
            } 
        }
예제 #3
0
        private int GetBetweenDay(WeeklyTrigger trigger)
        {

            int between = 0;
            int startCounting = -1;
            string current = DateTime.Now.DayOfWeek.ToString();
             
            Type typeWeekly = trigger.GetType();
            PropertyInfo propInfo;
            int value;
            for (int x = 2; x >= 1; x--)
            { 
                for (int i = 0; i < days.Length; i++)
                {
                    if (days[i] == current && (startCounting == -1))
                    {
                        if (startCounting == -1)
                            startCounting = i + 1;  
                    }
                    else if (startCounting > 0)
                    {
                        between += 1;
                        propInfo = typeWeekly.GetProperty(days[i]);
                        value = (int)propInfo.GetValue(trigger, null);

                        if (value == 1)
                        { 
                            x = 1;
                            break; 
                        }
                    }  
                }
            }  
            return between;
        }