Exemplo n.º 1
0
        private void btnInstall_ClickAsync(object sender, EventArgs e)
        {
            var dot = installDtoBindingSource.Current as InstallDto;

            if (dot != null)
            {
                btnInstall.Enabled = false;
                Task.Run(async() =>
                {
                    try
                    {
                        var Client = SdkClient.Create <InstallerClient>();
                        var result = await Client.InstallAsync(dot);
                        Invoke((MethodInvoker) delegate
                        {
                            btnInstall.Enabled = true;
                            if (result.Installed)
                            {
                                DialogResult = DialogResult.OK;
                            }
                        });
                    }
                    catch (SwaggerException se)
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            libinfo.Text       = se.ToResult().Msg;
                            btnInstall.Enabled = true;
                        });
                    }
                });
            }
        }
Exemplo n.º 2
0
        private async void btnAttTest_ItemClick(object sender, ItemClickEventArgs e)
        {
            var dev = SdkClient.Create <DevicesClient>();
            var dis = new Dictionary <string, object>();

            dis.Add("boolvalue", true);
            dis.Add("jsonvalue", new { a = 1, b = "sss", c = false, e = DateTime.Now });
            dis.Add("longvalue", 2342343L);
            dis.Add("Doublevalue", 2332.322);
            await dev.Attributes2Async(txtToken.EditValue.ToString(), dis);

            await ReloadLatest();
        }
Exemplo n.º 3
0
        private async Task ReloadLatest()
        {
            try
            {
                Device row = null;
                this.Invoke((MethodInvoker) delegate
                {
                    row = FocusedRow;
                    if (row != null)
                    {
                        rpgModBus.Enabled = row.DeviceType == DeviceType.Gateway;
                        if (row.DeviceType == DeviceType.Gateway)
                        {
                            modBusConfigBindingSource.DataSource = new ModBusConfig()
                            {
                                Address         = "100",
                                KeyNameOrPrefix = "ModBus",
                                ModBusUri       = new Uri("modbus://127.0.0.1:502/1"),
                                Lenght          = 1,
                                ValueType       = "UInt32",
                                DataType        = "Telemetry"
                            };;
                        }
                    }
                });

                if (row != null)
                {
                    var dev = SdkClient.Create <DevicesClient>();
                    var al  = await dev.GetTelemetryLatestAllAsync(row.Id);

                    var tl = await dev.GetAttributeLatestAllAsync(row.Id);

                    var ddds = from d in tl select new DeviceDataDto(d);
                    this.Invoke((MethodInvoker) delegate
                    {
                        attributeLatestBindingSource.DataSource = al;
                        deviceDataDtoBindingSource.DataSource   = ddds;
                        telemetryLatestBindingSource.DataSource = tl;
                    });
                }
            }
            catch (Exception ex)
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lblInfo.Caption = ex.Message;
                });
            }
        }
Exemplo n.º 4
0
        private async void btnLogin_ClickAsync(object sender, EventArgs e)
        {
            var    Client   = SdkClient.Create <IoTSharp.Sdk.Http.AccountClient>();
            string username = txtUserName.Text;
            string password = txtPassword.Text;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                lblInfo.Text = "密码或用户名为空";
            }
            else
            {
                try
                {
                    var result = await Client.LoginAsync(username, password);

                    if (result.IsLogin)
                    {
                        DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        lblInfo.Text = "密码错误";
                    }
                }
                catch (SwaggerException sex)
                {
                    var result = sex.ToResult();
                    if (result != null)
                    {
                        lblInfo.Text = $"错误代码:{result.Code},错误:{result.Msg}";
                    }
                    else
                    {
                        lblInfo.Text = sex.Message;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemplo n.º 5
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            lblVersion.Text  = "V" + AppUtils.AssemblyVersion;
            btnLogin.Enabled = false;
            lblInfo.Text     = "正在检查服务器...";

            cts.Token.Register(() => Console.WriteLine(DateTime.Now.ToString() + "取消"));
            Task.Run(async() =>
            {
                try
                {
                    var Client = SdkClient.Create <IoTSharp.Sdk.Http.InstallerClient>();
                    var fr     = await Client.InstanceAsync();
                    this.Invoke((MethodInvoker) delegate
                    {
                        if (fr.Installed)
                        {
                            btnLogin.Enabled = true;
                            lblInfo.Text     = "服务器就绪";
                            lblVersion.Text  = fr.Version;
                        }
                        else
                        {
                            DialogResult = DialogResult.No;
                        }
                    });
                }
                catch (SwaggerException se)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        lblInfo.Text = se.ToResult().ToString();
                    });
                }
                catch (Exception ex)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        lblInfo.Text = ex.Message;
                    });
                }
            }, cts.Token);
        }
Exemplo n.º 6
0
        private async void  BtnConfigBus_ItemClickAsync(object sender, ItemClickEventArgs e)
        {
            ModBusConfig modBus = new ModBusConfig()
            {
                Address         = txtAddress.EditValue.ToString(),
                DataType        = cbxDataType.EditValue.ToString(),
                KeyNameOrPrefix = txtExtModbus.EditValue.ToString(),
                Lenght          = int.Parse(txtLenght.EditValue.ToString()),
                ModBusUri       = new Uri(txtModBusUri.EditValue.ToString()),
                ValueType       = cbxValueType.EditValue.ToString()
            };
            var dev = SdkClient.Create <DevicesClient>();
            var dis = new Dictionary <string, object>();

            dis.Add("ModBusConfig", modBus);
            await dev.Attributes2Async(txtToken.EditValue.ToString(), dis);

            await ReloadLatest();
        }
Exemplo n.º 7
0
        private async void btnGetToken_ItemClickAsync(object sender, ItemClickEventArgs e)
        {
            try
            {
                var row = FocusedRow;
                if (row != null)
                {
                    var dev = SdkClient.Create <DevicesClient>();
                    var ids = await dev.GetIdentityAsync(row.Id);

                    txtToken.EditValue = ids.IdentityId;
                    //XtraMessageBox.Show(ids.ToJson());
                    lblInfo.Caption = "已经获取到该设备Token";
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 8
0
        private async Task ReloadLatest()
        {
            try
            {
                var row = FocusedRow;
                if (row != null)
                {
                    var dev = SdkClient.Create <DevicesClient>();
                    var al  = await dev.GetAttributeLatestAsync(row.Id);

                    var tl = await dev.GetTelemetryLatestAsync(row.Id);

                    attributeLatestBindingSource.DataSource = al;
                    telemetryLatestBindingSource.DataSource = tl;
                }
            }
            catch (Exception ex)
            {
                lblInfo.Caption = ex.Message;
            }
        }
Exemplo n.º 9
0
        private async Task ReloadLatest()
        {
            try
            {
                Device row = null;
                this.Invoke((MethodInvoker)async delegate
                {
                    var dev            = SdkClient.Create <DevicesClient>();
                    var ids            = await dev.GetIdentityAsync(Device.Id);
                    txtToken.EditValue = ids.IdentityId;
                    //XtraMessageBox.Show(ids.ToJson());
                    lblInfo.Caption = "已经获取到该设备Token";
                });

                if (row != null)
                {
                    var dev = SdkClient.Create <DevicesClient>();
                    var al  = await dev.GetAttributeLatestAllAsync(row.Id);

                    var tl = await dev.GetTelemetryLatestAllAsync(row.Id);

                    this.Invoke((MethodInvoker) delegate
                    {
                        attributeLatestBindingSource.DataSource = al;
                        telemetryLatestBindingSource.DataSource = tl;
                    });
                }
            }
            catch (Exception ex)
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lblInfo.Caption = ex.Message;
                });
            }
        }
Exemplo n.º 10
0
 private void frmCustomerAdmin_Load(object sender, EventArgs e)
 {
     InitializeGridView(gridView, colId);
     Client = SdkClient.Create <CustomersClient>();
 }
Exemplo n.º 11
0
 private void frmCustomerAdmin_Load(object sender, EventArgs e)
 {
     InitializeGridView(gridView1, colId);
     Client = SdkClient.Create <DevicesClient>();
     enumKeyValueBindingSource.BindingEnum <DeviceType>();
 }
Exemplo n.º 12
0
 public frmTenantAdmin()
 {
     InitializeComponent();
     InitializeGridView(gridView, colId);
     Client = SdkClient.Create <TenantsClient>();
 }
Exemplo n.º 13
0
 private void frmDevData_Load(object sender, EventArgs e)
 {
     Client = SdkClient.Create <DevicesClient>();
     enumKeyValueBindingSource.BindingEnum <DeviceType>();
 }
Exemplo n.º 14
0
 private void FrmUserAdmin_Load(object sender, EventArgs e)
 {
     Client = SdkClient.Create <AccountClient>();
     Task.Run(Reload);
 }