예제 #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
 public Inbox()
 {
     InitializeComponent();  
     model = ObjectPool.Instance.Resolve<MessageCollaborator>();
     if (this.DataContext == null && model != null)
     {
         this.DataContext = model.InboxSource; 
     } 
 }
예제 #5
0
 public MainWindowViewModel(ServerConfiguration serverConfiguration, MessageCollaborator messageCollection, ApplicationSettings applicationSettings, GeneralView generalView, CallView callView,
     PortView portView, SMSView smsView)
 {
     this.serverConfiguration = serverConfiguration;
     this.messageCollection = messageCollection;
     this.applicationSettings = applicationSettings;
     this.generalView = generalView;
     this.callView = callView;
     this.portView = portView;
     this.smsView = smsView; 
 }
예제 #6
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;
            });
        }
예제 #7
0
        internal bool LoadServerConfiguration(IGatewayService service)
        {
            Server.ServerConfiguration serverConfiguration;
            IDataSyncronize message;
            IDataSyncronize contact;  
            
            serverConfiguration = ObjectPool.Instance.Resolve<Server.ServerConfiguration>();

            message = ObjectPool.Instance.Resolve<MessageCollaborator>();
            contact = ObjectPool.Instance.Resolve<DatabaseCollectionViewSource>();

            //if (serverConfiguration == null) // comment this if you want refresh connection
            {
                if (serverConfiguration == null)
                    serverConfiguration = new Server.ServerConfiguration(service);

                if (message == null)
                    message = new MessageCollaborator();

                if (contact == null)
                    contact = new DatabaseCollectionViewSource();

                message.StartSyncronizing();
                contact.StartSyncronizing();

                ObjectPool.Instance.Register<SMSGatewayWpf.ViewModels.Devices.SMSView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.SMSView());
                ObjectPool.Instance.Register<SMSGatewayWpf.ViewModels.Devices.CallView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.CallView());
                ObjectPool.Instance.Register<SMSGatewayWpf.ViewModels.Devices.PortView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.PortView());
                ObjectPool.Instance.Register<SMSGatewayWpf.ViewModels.Devices.GeneralView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.GeneralView());
            }

            ObjectPool.Instance.Register<Server.ServerConfiguration>().ImplementedBy(serverConfiguration);
            ObjectPool.Instance.Register<MessageCollaborator>().ImplementedBy(message);
            ObjectPool.Instance.Register<DatabaseCollectionViewSource>().ImplementedBy(contact);

            OnConfigurationLoaded();
                
            // comment due to disabled load configuration server
            //if (serverConfiguration.General == null)
            //    return false;
            //else
            return true;
        }