Beispiel #1
0
        private void OnDelete(string source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("Source");
            }

            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;
                string number;
                foreach (BaseDataRow message in SelectableRow.ToList())
                {
                    BaseMessageModel model;
                    if (source == "O") // source from Outbox
                    {
                        model  = (BaseMessageModel)message;
                        number = ((Outbox)message).Receiver;
                        db.Execute("UpdateMessageStatus", new
                        {
                            Status = "D",
                            SeqNbr = model.SeqNbr,
                            Sender = number,
                            Source = source.ToUpper()
                        });
                    }
                    else if (source == "I") // source from Inbox
                    {
                        model  = (BaseMessageModel)message;
                        number = model.Sender;
                        db.Execute("UpdateMessageStatus", new
                        {
                            Status = "D",
                            SeqNbr = model.SeqNbr,
                            Sender = number,
                            Source = source.ToUpper()
                        });
                    }
                    else if (source == "D") // source from Draft
                    {
                        ComposeMessageModel compose = (ComposeMessageModel)message;

                        db.Execute("DeleteQueue", new
                        {
                            SeqNbr = compose.SeqNbr
                        });
                    }
                    message.IsSelected = false;
                }
                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
Beispiel #2
0
        private void OnMessageOpen(object args)
        {
            ComposeMessageModel forward = new ComposeMessageModel();

            if (args == null)
            {
                return;
            }
            else if (args.GetType() == typeof(ComposeMessageModel))
            {
                DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(args);
                return;
            }
            Type typeArgs = args.GetType();

            if (typeArgs == typeof(Inbox) || typeArgs == typeof(Spam) || typeArgs == typeof(Trash))
            {
                BaseMessageModel inbox = (BaseMessageModel)args;
                if (typeArgs == typeof(Inbox))
                {
                    ((Inbox)inbox).IsRead = (int)MessageRead.Read;
                }
                else if (typeArgs == typeof(Trash))
                {
                    ((Trash)inbox).IsRead = (int)MessageRead.Read;
                }

                IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);
                db.Execute("UpdateMessageRead", new
                {
                    IsRead = (int)MessageRead.Read,
                    SeqNbr = inbox.SeqNbr
                });
                db.Close();

                forward.Message     = inbox.Message;
                forward.Phonenumber = inbox.Sender;
            }

            Outbox outbox = new Outbox();

            if (typeArgs == typeof(Outbox))
            {
                outbox          = (Outbox)args;
                forward.Message = outbox.Message;
            }
            else if (typeArgs.Name == "SelectedItemCollection")
            {
                outbox          = (Outbox)((System.Collections.IList)args)[0];
                forward.Message = outbox.Message;
            }
            DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(forward);
        }
        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;
            }
        }
        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;  
            } 
        }
        public void OnCompose(object args)
        {
            ComposeMessageModel newMessage = new ComposeMessageModel();

            DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(newMessage);
        }
 public void OnCompose(object args)
 {
     ComposeMessageModel newMessage = new ComposeMessageModel(); 
     DialogService.Instance.ShowDialog<Views.Dialogs.ComposeMessage>(newMessage);
 }