private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            if (this.openFileDialog.ShowDialog() == true)
            {
                string filename = this.openFileDialog.FileName;
                string ext      = System.IO.Path.GetExtension(filename);
                if (ext.ToLower() != ".exe")
                {
                    MessageBox.Show(this, "请选择一个可执行文件!");
                }

                DeviceSettingInfo dsi = new DeviceSettingInfo();
                dsi.ReadFromDevice(this.currentDevice);

                SettingInfo si = new SettingInfo()
                {
                    Name           = System.IO.Path.GetFileNameWithoutExtension(filename),
                    TargetFilePath = this.openFileDialog.FileName,
                    Setting        = dsi
                };

                settingList.Add(si);
            }

            this.SaveConfig();
        }
Esempio n. 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            int           nItemCount = this.listView1.Items.Count;
            StringBuilder sqlList    = new StringBuilder();
            StringBuilder sqlLIst2   = new StringBuilder();

            for (int i = 0; i < nItemCount; ++i)
            {
                DeviceSettingInfo dsInfo = new DeviceSettingInfo()
                {
                    DeviceNum   = this.listView1.Items[i].SubItems[0].Text,
                    StudentNum  = this.listView1.Items[i].SubItems[1].Text,
                    StudentName = this.listView1.Items[i].SubItems[6].Text,
                };
                deviceSettingInfos.Add(dsInfo);

                string sql1 = string.Format(@"insert into device_tb(device_mac,device_state)values('{0}',0);
", dsInfo.DeviceNum);
                string sql2 = string.Format(@"
insert into stu_tb(stu_name,stu_sex,stu_num,class_id,device_id)
select '学生'+device_id,0,001,14,device_id from device_tb
where device_mac = '{0}';
", dsInfo.DeviceNum);
                sqlList.Append(sql1);
                sqlLIst2.Append(sql2);
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = @"CSV文件|*.csv";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string     file = sfd.FileName;
                FileHelper fh   = new FileHelper();
                fh.FileWriteForDeviceInfo(file, deviceSettingInfos);
            }
            SaveFileDialog sfd2 = new SaveFileDialog();

            sfd2.Filter = @"TXT文件|*.TXT";
            if (sfd2.ShowDialog() == DialogResult.OK)
            {
                string     file = sfd2.FileName;
                FileHelper fh   = new FileHelper();
                fh.FileWriteStr(file, sqlList.ToString());
            }
            SaveFileDialog sfd3 = new SaveFileDialog();

            sfd3.Filter = @"TXT文件|*.TXT";
            if (sfd3.ShowDialog() == DialogResult.OK)
            {
                string     file = sfd3.FileName;
                FileHelper fh   = new FileHelper();
                fh.FileWriteStr(file, sqlLIst2.ToString());
            }
            deviceSettingInfos = new List <DeviceSettingInfo>();
        }
Esempio n. 3
0
        public async Task <bool> SaveDeviceSettingInfoAsync()
        {
            using (var proxy = new MogamiApiServiceClient())
            {
                await proxy.LoadDeviceSettingAsync();

                if (this.DeviceSettingInfo == null)
                {
                    this._DeviceSettingInfo = new DeviceSettingInfo();
                }

                var req  = new REQUEST_SAVEDEVICRSETTING();
                var json = JsonConvert.SerializeObject(this.DeviceSettingInfo, Formatting.None);
                req.Data = json;
                var rsp = await proxy.SaveDeviceSettingAsync(req);

                return(rsp.Success);
            }
        }
Esempio n. 4
0
        public async Task <bool> LoadDeviceSettingInfoAsync()
        {
            if (this.DeviceSettingInfo == null)
            {
                this._DeviceSettingInfo = new DeviceSettingInfo();
            }

            using (var proxy = new MogamiApiServiceClient())
            {
                await proxy.LoginAsync();

                var rsp = await proxy.LoadDeviceSettingAsync();

                if (rsp.Data != null)
                {
                    JsonConvert.PopulateObject(rsp.Data, this.DeviceSettingInfo);
                }

                LoadedDeviceSetting();
            }

            return(true);
        }