Exemplo n.º 1
0
 private void SendMessage(string msg)
 {
     ledPanel1.Text = "发送中";
     new Thread(() =>
     {
         try
         {
             var client = new APIServiceClient();
             client.ShowText(ClientId, msg);
             ledPanel1.Invoke(new Action(() =>
             {
                 ledPanel1.Text = msg;
             }));
             client.Close();
         }
         catch (Exception ex)
         {
             ledPanel1.Invoke(new Action(() =>
             {
                 ledPanel1.Text = "发送失败";
             }));
             MessageBox.Show("出错了\n" + ex.Message);
         }
     }).Start();
 }
Exemplo n.º 2
0
        public ActionResult StorePageView(int id, string searchData, string specialItems, bool hadError)
        {
            ViewModelData viewModelData = new ViewModelData(id);

            List <string> names = new List <string>
            {
                "leifheanzo",
                "snatti89",
                "unpreti",
                "nixeu",
                "wlop",
                "talros",
                "razaras"
            };

            viewModelData.SimpleList = names;


            IEnumerable <Item> items = specialItems == null?itemRepository.GetItems() : itemRepository.GetSpecialItems();

            viewModelData.Items = items;

            //Check if search exists and try getting the data
            if (searchData != null)
            {
                try
                {
                    JToken data;
                    client = new APIServiceClient();
                    if (!searchData.Contains("by"))
                    {
                        JObject json = JObject.Parse(GetDataAsync(searchData, 0).Result);
                        data = json["results"];
                        viewModelData.ItemsSimple1 = data;
                    }
                    else
                    {
                        //Get the data from the service using API Beta
                        JObject jsonDataVal = JObject.Parse(GetDataAsync(searchData, 1).Result);
                        data = jsonDataVal["rss"]["channel"]["item"];
                        viewModelData.ItemsSimple2 = data;
                    }
                    client.CloseAsync();
                }
                catch
                {
                    ViewBag.msg = "Sorry, there was an Error. The Webservice could be down.";
                }
            }

            if (hadError)
            {
                ViewBag.Message = "An error occured. Try again.";
            }



            return(View(viewModelData));
        }
Exemplo n.º 3
0
 public IndexModel(IConfiguration configuration, IWebHostEnvironment env)
 {
     _env           = env;
     _configuration = configuration;
     ServerName     = _configuration["ServerName"];
     DatabaseName   = _configuration["DatabaseName"];
     DatabaseNameCA = _configuration["DatabaseNameCA"];
     UserName       = _configuration["UserNameADV"];
     Password       = _configuration["Password"];
     Client         = new APIServiceClient();
 }
Exemplo n.º 4
0
 public VendorsController(StaticdbContext TMDB, IConfiguration configuration /*, IWebHostEnvironment env*/)
 {
     _tmdb = TMDB;
     //_env = env;
     _configuration = configuration;
     ServerName     = _configuration["ServerName"];
     DatabaseName   = _configuration["DatabaseName"];
     //DatabaseNameCA = _configuration["DatabaseNameCA"];
     UserName = _configuration["UserNameADV"];
     Password = _configuration["Password"];
     Client   = new APIServiceClient();
 }
Exemplo n.º 5
0
 public ApplicationHeader GetAppHeader(string Username, string CorrelationId)
 {
     using (apiClient = new APIServiceClient(endpoint))
     {
         RequesterDetails requester = GetRequester(CorrelationId, Username);
         RetrieveApplicationHeaderResponse response = apiClient.RetrieveApplicationHeader(requester);
         if (response.StatusCode == "SUCCESS")
         {
             return(response.Header);
         }
         else
         {
             throw new Exception(response.Messages.First().Message);
         }
     }
 }
Exemplo n.º 6
0
 public IList <JobAid> GetJobAids(string Username, string CorrelationId)
 {
     using (apiClient = new APIServiceClient(endpoint))
     {
         RetrieveJobAidsRequest request = new RetrieveJobAidsRequest()
         {
             ApplicationId = Constants.APPLICATION_ID
         };
         RetrieveJobAidsResponse response = apiClient.RetrieveJobAids(GetRequester(CorrelationId, Username), request);
         if (response.StatusCode == "SUCCESS")
         {
             return(response.JobAids);
         }
         else
         {
             throw new Exception(response.Messages.First().Message);
         }
     }
 }
Exemplo n.º 7
0
 public APIServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(APIServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 8
0
 public APIServiceClient(EndpointConfiguration endpointConfiguration) :
     base(APIServiceClient.GetBindingForEndpoint(endpointConfiguration), APIServiceClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 9
0
 public APIServiceClient() :
     base(APIServiceClient.GetDefaultBinding(), APIServiceClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IAPIService.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 10
0
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(APIServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IAPIService));
 }
Exemplo n.º 11
0
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(APIServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IAPIService));
 }
Exemplo n.º 12
0
        private void BindData()
        {
            var client = new APIServiceClient();
            var json   = client.DownloadConfig(ClientId);
            var data   = JsonConvert.DeserializeObject <JObject>(json);

            var messages     = data["messages"].ToObject <List <Model.Message> >();
            var buttons      = data["buttons"].ToObject <List <Model.ClientButton> >();
            var window       = data["window"].ToObject <Model.ClientWindow>();
            var offworkTimes = data["offworktimes"].ToObject <List <Model.OffworkTime> >();

            _offworkButton   = buttons.FirstOrDefault(e => e.Type == Model.ClientButtonType.班);
            _countdownButton = buttons.FirstOrDefault(e => e.Type == Model.ClientButtonType.倒计数);

            this.BeginInvoke(new Action(() =>
            {
                //绑定消息下拉框
                cbxMessage.DataSource = messages.Select(e => e.Content).ToArray();
                //绑定下班时间下拉框
                cbxOffworkTime.DataSource = offworkTimes.Select(e => new TimeSpan(e.Hour, e.Minute, 0).ToString()).ToArray();
                //绑定文字窗口
                //ledPanel1.ChangeLedSize(300, 128);
                ledPanel1.Height    = window.Height + 10;
                ledPanel1.Width     = window.Width + 10;
                ledPanel1.TextAlign = (ContentAlignment)window.TextAlignment;
                ledPanel1.Font      = new Font(window.FontFamily, window.FontSize);
                //判断下班按钮是否可见
                offworkPanel.Visible = _offworkButton != null;
                //加载其他按钮
                buttonContainer.Controls.Clear();
                foreach (var btn in buttons.Where(e => e.Type != ClientButtonType.班))
                {
                    var control = new Button()
                    {
                        Text      = btn.Type.ToString(),
                        BackColor = Color.SteelBlue,
                        ForeColor = Color.White,
                        FlatStyle = FlatStyle.Flat,
                        Width     = 85,
                        Height    = 32
                    };
                    switch (btn.Type)
                    {
                    case ClientButtonType.故障:
                        control.BackColor = Color.Red;
                        break;

                    case ClientButtonType.倒计数:
                        control.BackColor = Color.Peru;
                        break;
                    }
                    //按钮点击事件
                    control.Click += (sender, e) =>
                    {
                        if (btn.Type == ClientButtonType.倒计数)
                        {
                            btnCountDown_Click(sender, e);
                        }
                        else
                        {
                            SendMessage(btn.Message);
                        }
                    };
                    buttonContainer.Controls.Add(control);
                }
            }));
            client.Close();
        }
Exemplo n.º 13
0
 private void SendMessage(string msg)
 {
     ledPanel1.Text = "发送中";
     new Thread(() =>
     {
         try
         {
             var client = new APIServiceClient();
             client.ShowText(ClientId, msg);
             ledPanel1.Invoke(new Action(() =>
             {
                 ledPanel1.Text = msg;
             }));
             client.Close();
         }
         catch (Exception ex)
         {
             ledPanel1.Invoke(new Action(() =>
             {
                 ledPanel1.Text = "发送失败";
             }));
             MessageBox.Show("出错了\n" + ex.Message);
         }
     }).Start();
 }
Exemplo n.º 14
0
        private void BindData()
        {
            var client = new APIServiceClient();
            var json = client.DownloadConfig(ClientId);
            var data = JsonConvert.DeserializeObject<JObject>(json);

            var messages = data["messages"].ToObject<List<Model.Message>>();
            var buttons = data["buttons"].ToObject<List<Model.ClientButton>>();
            var window = data["window"].ToObject<Model.ClientWindow>();
            var offworkTimes = data["offworktimes"].ToObject<List<Model.OffworkTime>>();

            _offworkButton = buttons.FirstOrDefault(e => e.Type == Model.ClientButtonType.下班);
            _countdownButton = buttons.FirstOrDefault(e => e.Type == Model.ClientButtonType.倒计数);

            this.BeginInvoke(new Action(() =>
            {
                //绑定消息下拉框
                cbxMessage.DataSource = messages.Select(e => e.Content).ToArray();
                //绑定下班时间下拉框
                cbxOffworkTime.DataSource = offworkTimes.Select(e => new TimeSpan(e.Hour, e.Minute, 0).ToString()).ToArray();
                //绑定文字窗口
                //ledPanel1.ChangeLedSize(300, 128);
                ledPanel1.Height = window.Height + 10;
                ledPanel1.Width = window.Width + 10;
                ledPanel1.TextAlign = (ContentAlignment)window.TextAlignment;
                ledPanel1.Font = new Font(window.FontFamily, window.FontSize);
                //判断下班按钮是否可见
                offworkPanel.Visible = _offworkButton != null;
                //加载其他按钮
                buttonContainer.Controls.Clear();
                foreach (var btn in buttons.Where(e => e.Type != ClientButtonType.下班))
                {
                    var control = new Button()
                    {
                        Text = btn.Type.ToString(),
                        BackColor = Color.SteelBlue,
                        ForeColor = Color.White,
                        FlatStyle = FlatStyle.Flat,
                        Width = 85,
                        Height = 32
                    };
                    switch (btn.Type)
                    {
                        case ClientButtonType.故障:
                            control.BackColor = Color.Red;
                            break;
                        case ClientButtonType.倒计数:
                            control.BackColor = Color.Peru;
                            break;
                    }
                    //按钮点击事件
                    control.Click += (sender, e) =>
                    {
                        if (btn.Type == ClientButtonType.倒计数)
                        {
                            btnCountDown_Click(sender, e);
                        }
                        else
                        {
                            SendMessage(btn.Message);
                        }
                    };
                    buttonContainer.Controls.Add(control);
                }
            }));
            client.Close();
        }