コード例 #1
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
        private async Task CheckNewCommand()
        {
            if (services == null)
            {
                services = new mServices();
            }
            int    i      = 0;
            string hash   = utils.Truncate(utils.GetHashString(utils.GetMacAdres() + Environment.UserName + Environment.MachineName), 49);
            var    device = new DeviceModel
            {
                AndroidIDmacHash = hash,
                TypeDeviceID     = (int)TypeDevicePW.WindowsPCslave,
                codeA            = 0,
                codeB            = 0,
                Name             = string.Format("{0}({1})", Environment.UserName, Environment.MachineName),
                Token            = "token"
            };
            var commands = await services.SyncCommandWithRest(device);

            label_command_result.Text = DateTime.Now.ToLongTimeString();
            if (commands != null && commands.Count > 0)
            {
                await CommandOperate(commands);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
        private async Task GetListMasters()
        {
            if (services == null)
            {
                services = new mServices();
            }

            try
            {
                string hash = utils.Truncate(utils.GetHashString(utils.GetMacAdres() + Environment.UserName + Environment.MachineName), 49);
                await services.GetListMasters(new DeviceModel
                {
                    AndroidIDmacHash = hash,
                    TypeDeviceID     = (int)TypeDevicePW.WindowsPCslave,
                    codeA            = 0,
                    codeB            = 0,
                    Name             = string.Format("{0}({1})", Environment.UserName, Environment.MachineName),
                    Token            = "token"
                }, listBox_masters);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
 private async Task SaveScreenShot(long queueCommandID = 0)
 {
     if (services == null)
     {
         services = new mServices();
     }
     await services.SaveAndGetListScreenShotFromLocalSql(listBox_screenshots, dateTimePicker_from.Value, dateTimePicker_to.Value, queueCommandID);
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
 private async Task GetListMastersFromLocalSaved()
 {
     if (services == null)
     {
         services = new mServices();
     }
     await services.GetListMastersLocalSql(listBox_masters);
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
 //test2
 private async void button1_Click(object sender, EventArgs e)
 {
     //MessageBox.Show(utils.Truncate(
     //    utils.GetHashString(utils.GetMacAdres() + Environment.UserName + Environment.MachineName), 49));
     //MessageBox.Show(ConverterHelper.ConvertDateWithoutTimeToMillisec(DateTime.Now).ToString());
     // SaveTimeToSql();
     if (services == null)
     {
         services = new mServices();
     }
     await services.testttttt(dateTimePicker_from.Value);
 }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
        private async Task RefreshPowerTime()
        {
            if (string.IsNullOrEmpty(GUID))
            {
                MessageBox.Show("GUID is EMTPY!!!");
                return;
            }
            if (services == null)
            {
                services = new mServices();
            }
            await services.SaveAndGetListPowerTimeFromLocalSql(listBox_powertime, dateTimePicker_from.Value, dateTimePicker_to.Value, GUID);

            label_savepowertime_result.Text = DateTime.Now.ToLongTimeString();
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
        private async void SaveTimeToSql()
        {
            if (!string.IsNullOrEmpty(GUID))
            {
                if (services == null)
                {
                    services = new mServices();
                }
                int result = await services.UpdateOrCreatePowerPCtoSql(GUID);

                switch (result)
                {
                case 0:
                {
                    label_savepowertime_result.Text = "not saved";
                    break;
                }

                case 1:
                {
                    label_savepowertime_result.Text = DateTime.Now.ToLongTimeString();
                    await services.GetListPowerTimeTODAYFromLocalSql(listBox_powertime);

                    break;
                }

                case -1:
                {
                    label_savepowertime_result.Text = "error!";
                    break;
                }

                default:
                {
                    label_savepowertime_result.Text = result.ToString();
                    break;
                }
                }
            }
        }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: 5509850/pwlenasite
        private async Task Synchro(bool silentmode)
        {
            if (services == null)
            {
                services = new mServices();
            }
            int    i      = 0;
            string hash   = utils.Truncate(utils.GetHashString(utils.GetMacAdres() + Environment.UserName + Environment.MachineName), 49);
            var    device = new DeviceModel
            {
                AndroidIDmacHash = hash,
                TypeDeviceID     = (int)TypeDevicePW.WindowsPCslave,
                codeA            = 0,
                codeB            = 0,
                Name             = string.Format("{0}({1})", Environment.UserName, Environment.MachineName),
                Token            = "token"
            };

            i = await services.SyncSqlWithRest(device, DateTime.Now);

            if (!silentmode)
            {
                if (i >= 0)
                {
                    MessageBox.Show(string.Format("synchronized {0} records", i));
                    label_synch_result.Text = DateTime.Now.ToLongTimeString();
                }
                else
                {
                    switch (i)
                    {
                    case -1:
                    {
                        MessageBox.Show("error inside PowerPcService");
                        break;
                    }

                    case -2:
                    {
                        MessageBox.Show("Device not found in Rest");
                        break;
                    }

                    case -3:
                    {
                        MessageBox.Show("SQL error in Rest");
                        break;
                    }

                    case -777:
                    {
                        MessageBox.Show("not active device - no paired masters?");
                        break;
                    }

                    default:
                    {
                        MessageBox.Show("not expected error");
                        break;
                    }
                    }
                }
            }
            else
            {
                if (i > 0)
                {
                    label_synch_result.Text = DateTime.Now.ToLongTimeString();
                }
                if (i < 0)
                {
                    label_synch_result.Text = "error";
                }
                if (i == 0)
                {
                    label_synch_result.Text = "no data";
                }
            }
            await ShowPowertimeList();
        }