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 BaseGatewayService()
        {
            string signature = ConfigurationManager.AppSettings["Signature"];
            header = new Header(signature, "texto-app", "");
            Request = new Request(null, header, null);
            Request.QueueWorkItem = new QueueWorkItem();

            crypter = new Crypto.Crypter(new ApplicationSettingKeySym());
        }
Esempio n. 3
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. 4
0
        public static string CreateCommand(string signature, string input, IKeySym privateKey)
        {
            IParser<ParamArgs> parser = new CommandParser(); 
            ParamArgs output = parser.Parse(input);
            if (output.Count == 0) throw new OperationCanceledException("Could not parse command.");

            Header header = new Header(signature, "", output.Get<string>("Command"));
            string jsonHeader = Newtonsoft.Json.JsonConvert.SerializeObject(header);

            DynamicData detail = new DynamicData();
            foreach (string key in output.ToDictionary().Keys)
            {
                if (!key.Equals("Command"))
                {
                    detail.Add(key, output.Get<object>(key));
                }
            }
            string jsonDetail = Newtonsoft.Json.JsonConvert.SerializeObject(detail.GetDictionary());
            Crypter crypter = new Crypter(privateKey);

            string final = string.Format(Format, jsonHeader, jsonDetail);
            return crypter.Encrypt(final); 
        }
Esempio n. 5
0
 public Request(IPEndPoint remoteEndPoint, Header header, ExpandoObject data)
 {
     RemoteEndPoint = remoteEndPoint;
     Header = header;
     Data = data;
 }
Esempio n. 6
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;  
            } 
        }