예제 #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;
            });
        }
예제 #2
0
        private void OnMarkAsSpam(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;

                foreach (BaseMessageModel message in SelectableRow.ToList())
                {
                    db.Execute("UpdateMessageStatus", new
                    {
                        Status = "S",
                        SeqNbr = message.SeqNbr,
                        Sender = message.Sender,
                        Source = source.ToUpper()
                    });
                    message.IsSelected = false;
                }

                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
예제 #3
0
        private void MarkReadUnread(int read)
        {
            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;

                foreach (Inbox message in SelectableRow.ToList())
                {
                    message.IsRead = read;
                    db.Execute("UpdateMessageRead", new
                    {
                        IsRead = read,
                        SeqNbr = message.SeqNbr
                    });
                    message.IsSelected = false;
                    if (read == (int)MessageRead.Read)
                    {
                        Unread -= 1;
                    }
                }

                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }
예제 #4
0
        private void OnRestore()
        {
            Task.Factory.StartNew(() =>
            {
                IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand db      = dbManager.GetDatabase(DatabaseNames.SMSGW);
                IsBusy = true;
                string number;
                Type messageType;

                foreach (BaseMessageModel message in SelectableRow.ToList())
                {
                    messageType = message.GetType();
                    if (messageType == typeof(Trash))
                    {
                        if (((Trash)message).Source.ToLower() == "inbox")
                        {
                            number = ((Trash)message).Sender;
                        }
                        else
                        {
                            number = ((Trash)message).Receiver;
                        }
                    }
                    else
                    {
                        number = message.Sender;
                    }

                    db.Execute("UpdateMessageStatus", new
                    {
                        Status = "R",
                        SeqNbr = message.SeqNbr,
                        Sender = number,
                        Source = ""
                    });
                    message.IsSelected = false;
                }
                MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>();
                mcsm.ForceSyncronizing();
                SelectableRow.Clear();
                CheckedHeader = false;

                db.Close();
                IsBusy = false;
            });
        }