Esempio n. 1
0
        private int syncThreshold()
        {
            int result;

            try
            {
                System.Collections.Generic.List <DeviceInfo>    allDevice = DeviceOperation.GetAllDevice();
                System.Collections.Generic.List <DevSnmpConfig> list      = new System.Collections.Generic.List <DevSnmpConfig>();
                new System.Collections.Generic.List <System.Collections.Hashtable>();
                foreach (DeviceInfo current in allDevice)
                {
                    if (ClientAPI.IsDeviceOnline(current.DeviceID))
                    {
                        DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current);
                        list.Add(sNMPpara);
                    }
                }
                DevMonitorAPI devMonitorAPI = new DevMonitorAPI();
                System.Collections.Generic.List <ThresholdMessage> monitorThresholds = devMonitorAPI.GetMonitorThresholds(list);
                this.UpdateAllThresholds(monitorThresholds);
                result = 1;
            }
            catch (System.Exception)
            {
                result = -1;
            }
            return(result);
        }
        public void ClearMemory()
        {
            int id     = dgAccountManagement.SelectedIndex;
            int number = 3;

            Task.Run(() =>
            {
                AdminsBLL objAdminBLL      = new AdminsBLL();
                SystemConfigBLL bLL        = new SystemConfigBLL();
                SystemConfigBLL objConfigs = new SystemConfigBLL();
                objAdminBLL.DelAdmins();        //删除账号
                objConfigs.DelSystemConfig(id); //删除配置信息
                foreach (string deviceIP in DeviceConnectionManager.Instance.Devices)
                {
                    string connectDeviceCmd         = string.Format("{0}/adb -s {1} shell", ProcessUtils.LDPath, deviceIP);
                    string cmdClear                 = string.Format("pm clear com.facebook.katana");
                    string cmdExit                  = string.Format("exit");
                    DeviceOperation deviceOperation = new DeviceOperation();
                    deviceOperation
                    .SetCmd(connectDeviceCmd)
                    .SetCmd(cmdClear)
                    .SetCmd(cmdExit)
                    .Run2(id, out number);
                }
            });
            MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Eliminate_Success", SystemLanguageManager.Instance.CultureInfo));
        }
Esempio n. 3
0
        public bool WriteDevice(DeviceOperation op)
        {
            var device = Config.Device;

            var flashBlocks  = FlashHexBoard.SplitBlocks(device.Flash.PageSize);
            var eepromBlocks = EepromHexBoard.SplitBlocks(device.Eeprom.PageSize, EEPROM_MAX_SUPERPAGE);

            op.FlashSize  += flashBlocks.TotalBytes;
            op.EepromSize += eepromBlocks.TotalBytes;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    foreach (var block in flashBlocks.Blocks)
                    {
                        programmer.WritePage(block.Address, AvrMemoryType.Flash, block.Data, 0, block.Data.Length);
                    }

                    foreach (var block in eepromBlocks.Blocks)
                    {
                        programmer.WritePage(block.Address, AvrMemoryType.Eeprom, block.Data, 0, block.Data.Length);
                    }
                }
            }
            op.CurrentState = "Everything is done";

            return(true);
        }
Esempio n. 4
0
        private void DevtreeInit()
        {
            this.tvDev.Nodes.Clear();
            System.GC.Collect();
            TreeNode treeNode = new TreeNode();

            treeNode.Text               = EcoLanguage.getMsg(LangRes.DevRoot, new string[0]);
            treeNode.Name               = "DevRoot";
            treeNode.Tag                = "DevRoot";
            treeNode.ImageIndex         = 0;
            treeNode.SelectedImageIndex = 0;
            this.tvDev.Nodes.Add(treeNode);
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            for (int i = 0; i < allDevice.Count; i++)
            {
                DeviceInfo deviceInfo = allDevice[i];
                string     deviceName = deviceInfo.DeviceName;
                TreeNode   treeNode2  = new TreeNode();
                treeNode2.Text = deviceName;
                treeNode2.Name = deviceInfo.DeviceID.ToString();
                treeNode2.Tag  = deviceInfo.Mac;
                if (!ClientAPI.IsDeviceOnline(deviceInfo.DeviceID))
                {
                    treeNode2.ImageIndex         = 2;
                    treeNode2.SelectedImageIndex = 2;
                }
                else
                {
                    treeNode2.ImageIndex         = 3;
                    treeNode2.SelectedImageIndex = 3;
                }
                treeNode.Nodes.Add(treeNode2);
            }
        }
        internal static string ToSerializedValue(this DeviceOperation value)
        {
            switch (value)
            {
            case DeviceOperation.None:
                return("None");

            case DeviceOperation.Delete:
                return("Delete");

            case DeviceOperation.DeleteWithWarning:
                return("DeleteWithWarning");

            case DeviceOperation.DRSource:
                return("DRSource");

            case DeviceOperation.DRTarget:
                return("DRTarget");

            case DeviceOperation.Browsable:
                return("Browsable");

            case DeviceOperation.ReadOnlyForDR:
                return("ReadOnlyForDR");

            case DeviceOperation.Deactivate:
                return("Deactivate");
            }
            return(null);
        }
Esempio n. 6
0
        public int refreshTree()
        {
            int      result      = 0;
            TreeNode treeNode    = this.tvDev.Nodes[0];
            int      refreshFlag = DeviceInfo.GetRefreshFlag();

            foreach (TreeNode treeNode2 in treeNode.Nodes)
            {
                string name     = treeNode2.Name;
                string arg_50_0 = (string)treeNode2.Tag;
                if (!ClientAPI.IsDeviceOnline(System.Convert.ToInt32(name)))
                {
                    treeNode2.ImageIndex         = 2;
                    treeNode2.SelectedImageIndex = 2;
                }
                else
                {
                    treeNode2.ImageIndex         = 3;
                    treeNode2.SelectedImageIndex = 3;
                }
                if (refreshFlag == 1)
                {
                    result = 1;
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(name));
                    string     text       = treeNode2.Text;
                    if (!text.Equals(deviceByID.DeviceName))
                    {
                        treeNode2.Text = deviceByID.DeviceName;
                    }
                }
            }
            DeviceInfo.SetRefreshFlag(2);
            return(result);
        }
Esempio n. 7
0
        public bool ReadDevice(DeviceOperation op)
        {
            var device     = Config.Device;
            var flashSize  = device.Flash.Size;
            var eepromSize = device.Eeprom.Size;
            var fusesSize  = device.FuseBits.Size;
            var locksSize  = device.LockBits.Size;

            op.FlashSize  += flashSize;
            op.EepromSize += eepromSize;
            op.FusesSize  += fusesSize;
            op.LocksSize  += locksSize;

            var flashData = new byte[flashSize];
            var eepData   = new byte[eepromSize];
            var fusesData = new byte[fusesSize];
            var locksData = new byte[locksSize];

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    programmer.ReadPage(0, AvrMemoryType.Flash, flashData, 0, flashSize);
                    programmer.ReadPage(0, AvrMemoryType.Eeprom, eepData, 0, eepromSize);
                    programmer.ReadPage(device.FuseBits.StartAddress, device.FuseBits.Location ?? AvrMemoryType.FuseBits, fusesData, 0, fusesSize);
                    programmer.ReadPage(device.LockBits.StartAddress, device.LockBits.Location ?? AvrMemoryType.LockBits, locksData, 0, locksSize);
                }
            }
            op.CurrentState = "Everything is done";

            EepromHexBoard = HexBoard.From(eepData);
            FlashHexBoard  = HexBoard.From(flashData);
            FusesHexBoard  = HexBoard.From(fusesData, device.FuseBits.StartAddress);
            LocksHexBoard  = HexBoard.From(locksData, device.LockBits.StartAddress);

            return(true);
        }
Esempio n. 8
0
        public bool VerifyDevice(DeviceOperation op)
        {
            var device = Config.Device;

            var flashBlocks  = FlashHexBoard.SplitBlocks(device.Flash.PageSize);
            var eepromBlocks = EepromHexBoard.SplitBlocks(device.Eeprom.PageSize);

            op.FlashSize  += flashBlocks.TotalBytes;
            op.EepromSize += eepromBlocks.TotalBytes;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    if (!VerifyBlocks(programmer, flashBlocks, AvrMemoryType.Flash, op))
                    {
                        return(false);
                    }

                    if (!VerifyBlocks(programmer, eepromBlocks, AvrMemoryType.Eeprom, op))
                    {
                        return(false);
                    }
                }
            }
            op.Complete();
            op.CurrentState = "Everything is done";

            return(true);
        }
Esempio n. 9
0
        private void handleTheResult(FirmwareUpgrade.Upgrading upgrading, int status)
        {
            switch (status)
            {
            case 0:
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;

            case 2:
                upgrading(UpgradeStatus.Upgrading, this.m_devID, "");
                return;

            case 3:
                upgrading(UpgradeStatus.NoNeedToUpgrade, this.m_devID, "");
                return;

            case 4:
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;

            case 5:
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;
            }
            string text = string.Empty;
            DefaultSnmpExecutor defaultSnmpExecutor = null;

            try
            {
                DeviceInfo    deviceByID = DeviceOperation.getDeviceByID(this.m_devID);
                DevSnmpConfig sNMPpara   = commUtil.getSNMPpara(deviceByID);
                SnmpConfig    snmpConfig = DevAccessCfg.GetInstance().getSnmpConfig(sNMPpara);
                defaultSnmpExecutor = new DefaultSnmpExecutor(new SnmpConfiger(snmpConfig, 1));
            }
            catch (System.Exception)
            {
            }
            int num = 0;

            while (num++ < 20)
            {
                try
                {
                    PropertiesMessage properties_ATEN = defaultSnmpExecutor.GetProperties_ATEN();
                    text = properties_ATEN.FirwWareVersion;
                    break;
                }
                catch (System.Exception)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            if (text.Equals(string.Empty))
            {
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;
            }
            upgrading(UpgradeStatus.UpgradeSucceed, this.m_devID, text);
        }
Esempio n. 10
0
        private IProgrammer CreateProgrammer(DeviceOperation deviceOperation)
        {
            var settings   = Config;
            var inner      = CreateProgrammerFromConfig(settings);
            var programmer = new ProgressTrackerProgrammer(inner, deviceOperation);

            return(programmer);
        }
Esempio n. 11
0
 private void InstalldeviceRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (installRadioButton.Checked)
     {
         configuration_GroupBox.Enabled = false;
         selectedOperation = DeviceOperation.InstallHPAgent;
     }
 }
Esempio n. 12
0
 private void ConfiguredeviceRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (configureRadioButton.Checked)
     {
         configuration_GroupBox.Enabled = true;
         selectedOperation = DeviceOperation.Configure;
     }
 }
Esempio n. 13
0
 private void AdddeviceRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (addDeviceRadioButton.Checked)
     {
         configuration_GroupBox.Enabled = false;
         selectedOperation = DeviceOperation.Add;
     }
 }
Esempio n. 14
0
        private object backupcfgPro(object param)
        {
            string str_folder = (string)param;

            this.syncThreshold();
            DeviceOperation.RefreshDBCache(false);
            EcoGlobalVar.setDashBoardFlg(2uL, "", 0);
            int num = Backuptask.BackupConfig4UI(str_folder);

            return(num);
        }
 private void Loop(Dispatcher disp, DeviceOperation op)
 {
     while (!_source.IsCancellationRequested)
     {
         Thread.Sleep(50);
         var delta = DateTime.Now - _start;
         disp.Invoke(() => {
             op.ExecutionTime = delta;
         });
     }
 }
Esempio n. 16
0
        public void pageInit(DevManDevice pParent, int devID, string devName, bool onlinest)
        {
            this.m_ininit   = true;
            this.m_cleartab = true;
            this.tcDev.Controls.Clear();
            this.m_cleartab = false;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            if (deviceByID == null)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[]
                {
                    devName
                }));
                return;
            }
            this.m_onlinest = onlinest;
            this.m_curdevID = devID.ToString();
            this.tcDev.Controls.Add(this.tbDevice);
            this.propDev1.pageInit(pParent, devID, onlinest);
            if (deviceByID.GetPortInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbOutlet);
                this.propOutlet1.pageInit(devID, 0, onlinest);
            }
            if (deviceByID.GetBankInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbBank);
                this.propBank1.pageInit(devID, 0, onlinest);
            }
            if (deviceByID.GetLineInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbLine);
                this.propLine1.pageInit(devID, 0, onlinest);
            }
            if (deviceByID.GetSensorInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbSensor);
                this.propSensor1.pageInit(devID, onlinest);
            }
            if (DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion).popReading == 2)
            {
                this.tcDev.Controls.Add(this.tbPop);
                this.propPOP1.pageInit(devID, onlinest);
            }
            if (this.m_selectedTab == null || !this.tcDev.Contains(this.m_selectedTab))
            {
                this.m_selectedTab = this.tbDevice;
            }
            this.tcDev.SelectTab(this.m_selectedTab);
            this.m_ininit = false;
        }
Esempio n. 17
0
        private void setBankConfigData(DeviceInfo pCurDev, int bankID)
        {
            string         text              = this.labDevModel.Text;
            string         value             = bankID.ToString();
            BankInfo       bankInfoByID      = DeviceOperation.GetBankInfoByID(bankID);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, pCurDev.FWVersion);
            int            selNo             = System.Convert.ToInt32(bankInfoByID.PortLists);

            this.labBankNo.Text = selNo.ToString();
            System.Collections.Generic.List <BankInfo> bankInfo = pCurDev.GetBankInfo();
            for (int i = 1; i <= bankInfo.Count; i++)
            {
                Control[] array = this.gbBankConfig.Controls.Find("butBank" + i, false);
                if (array.Length > 0)
                {
                    string text2 = ((Button)array[0]).Tag.ToString();
                    if (!text2.Equals(value))
                    {
                        ((Button)array[0]).BackColor = Color.PaleTurquoise;
                    }
                    else
                    {
                        ((Button)array[0]).BackColor = Color.DarkCyan;
                    }
                }
            }
            this.tbBankNm.Text = bankInfoByID.BankName;
            int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "bank");

            if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU)
            {
                this.labMaxPortCurrentBound.Text = ((!this.tbOMinCurrent.ReadOnly || !this.tbOMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "bank", selNo, "F0") : "");
                ThresholdUtil.SetUIEdit(this.tbOMinCurrent, (num & 1) == 0, bankInfoByID.Min_current, 0, "F0");
                ThresholdUtil.SetUIEdit(this.tbOMaxCurrent, (num & 2) == 0, bankInfoByID.Max_current, 0, "F0");
            }
            else
            {
                this.labMaxPortCurrentBound.Text = ((!this.tbOMinCurrent.ReadOnly || !this.tbOMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "bank", selNo, "F1") : "");
                ThresholdUtil.SetUIEdit(this.tbOMinCurrent, (num & 1) == 0, bankInfoByID.Min_current, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbOMaxCurrent, (num & 2) == 0, bankInfoByID.Max_current, 0, "F1");
            }
            ThresholdUtil.SetUIEdit(this.tbOMinVoltage, (num & 4) == 0, bankInfoByID.Min_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMaxVoltage, (num & 8) == 0, bankInfoByID.Max_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMinPower, (num & 16) == 0, bankInfoByID.Min_power, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMaxPower, (num & 32) == 0, bankInfoByID.Max_power, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMinPowerDiss, (num & 64) == 0, bankInfoByID.Min_power_diss, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMaxPowerDiss, (num & 128) == 0, bankInfoByID.Max_power_diss, 0, "F1");
            this.labMaxVoltageBound.Text  = ((!this.tbOMinVoltage.ReadOnly || !this.tbOMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "bank", selNo) : "");
            this.labMaxPowerBound.Text    = ((!this.tbOMinPower.ReadOnly || !this.tbOMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "bank", selNo, 1.0) : "");
            this.labMaxPowerDisBound.Text = ((!this.tbOMinPowerDiss.ReadOnly || !this.tbOMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "bank", selNo) : "");
            this.tbBankNm.BackColor       = Color.White;
        }
Esempio n. 18
0
        /// <summary>
        /// 传到指定模拟器编号启动登录
        /// </summary>
        private void AutomaticLogin(object login)
        {
            LoginInfo li = (LoginInfo)login;

            Task.Run(() =>
            {
                //获取所有设备连接信息
                List <string> devicesList = ProcessUtils.AdbDevices();
                gridLListSimulators.Clear();
                string txt = "";
                if (this.dgAccountManagement.Items[li.index] != null)
                {
                    if (((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_pwd != null && ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_user != null)
                    {
                        if (((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_pwd.Trim() != "" && ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_user.Trim() != "")
                        {
                            gridLListSimulators.Add(this.dgAccountManagement.Items[li.index] as Xzy.EmbeddedApp.Model.admins);
                        }
                        txt += ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_user.Trim() + "\r\n" +
                               ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_pwd + "\r\n";
                    }
                }

                if (((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[0]).login_user != null)
                {
                    string connectDeviceCmd = string.Format("{0}/adb -s {1} shell", ProcessUtils.LDPath, devicesList[li.index].ToString());
                    if (devicesList[li.index].IndexOf(li.port) > 0)
                    {
                        string cmdInputText = string.Format("input text {0}", gridLListSimulators[0].login_user);
                        string cmdInputTap  = string.Format("input tap {0} {1}", 100, 200);
                        string cmdTab       = "input keyevent 61";
                        string cmdPwd       = string.Format("input text {0}", gridLListSimulators[0].login_pwd);
                        string cmdLogin     = string.Format("input tap {0} {1}", 100, 300);
                        string cmdConfirm   = string.Format("input tap {0} {1}", 245, 465);

                        StreamWriter sw = new StreamWriter(@"D:\" + li.index.ToString() + ".txt");
                        sw.WriteLine(cmdInputTap);
                        sw.WriteLine(cmdInputText);
                        sw.WriteLine(cmdInputTap);
                        sw.WriteLine(cmdTab);
                        sw.WriteLine(cmdPwd);
                        sw.WriteLine(cmdLogin);
                        sw.WriteLine(cmdConfirm);
                        sw.Close();

                        DeviceOperation deviceOperation = new DeviceOperation();
                        deviceOperation.RunText(connectDeviceCmd, @"D:\" + li.index.ToString() + ".txt");
                    }
                }
            });
        }
Esempio n. 19
0
        private void butBank_Click(object sender, System.EventArgs e)
        {
            string         text              = this.labDevModel.Text;
            string         value             = this.labDevModel.Tag.ToString();
            int            l_id              = System.Convert.ToInt32(value);
            DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(l_id);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion);

            this.bankConfigPageControlInit(deviceModelConfig);
            string value2 = ((Button)sender).Tag.ToString();

            ((Button)sender).BackColor = Color.DarkCyan;
            this.setBankConfigData(deviceByID, System.Convert.ToInt32(value2));
        }
Esempio n. 20
0
        private void btbrowsedev_Click(object sender, System.EventArgs e)
        {
            int          devID        = System.Convert.ToInt32(this.lbECDevNm.Tag);
            FindDevDlg   findDevDlg   = new FindDevDlg(devID);
            DialogResult dialogResult = findDevDlg.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                int        devID2     = findDevDlg.DevID;
                DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID2);
                this.lbECDevNm.Text = deviceByID.DeviceName + " (IP:" + deviceByID.DeviceIP + ")";
                this.lbECDevNm.Tag  = devID2;
            }
        }
Esempio n. 21
0
        private JavaScriptObject ClosePumpCmd(HttpRequest request)
        {
            string DeviceNo = request["DeviceNo"] ?? "";
            string SendTime = request["SendTime"] ?? "";

            JavaScriptObject result = new JavaScriptObject();

            result.Add("Result", false);
            result.Add("Message", "");
            try
            {
                DateTime OperationTime = DateTime.Parse(SendTime);

                CmdToDtuClosePump cmd = new CmdToDtuClosePump();
                cmd.AddressField = DeviceNo.Substring(0, 12) + Convert.ToInt32(DeviceNo.Substring(12, 3)).ToString("X").PadLeft(2, '0');
                byte[] bs  = cmd.WriteMsg(OperationTime);
                string str = HexStringUtility.ByteArrayToHexString(bs);

                Device device = DeviceModule.GetDeviceByFullDeviceNo(DeviceNo);
                if (device == null)
                {
                    result["Message"] = "设备长编号" + DeviceNo + "不存在!";
                }
                else
                {
                    DeviceOperation op = new DeviceOperation();

                    op.DeviceNo      = DeviceNo;
                    op.DeviceName    = device.DeviceName;
                    op.OperationTime = OperationTime;
                    op.OperationType = "远程关泵";
                    op.RawData       = str;
                    op.Remark        = "";
                    op.UserId        = 0;
                    op.UserName      = "******";
                    op.State         = "发送成功";

                    DeviceOperationModule.AddDeviceOperation(op);

                    result["Result"] = true;
                }
            }
            catch (Exception ex)
            {
                result["Message"] = "关泵命令保存出错!";
                myLogger.Error(ex.Message);
            }
            return(result);
        }
Esempio n. 22
0
        private void initPage(string rackNm, string devIDs)
        {
            Program.m_IdleCounter = 0;
            int num = 212;

            this.labrackNm.Text = rackNm;
            using (Graphics graphics = base.CreateGraphics())
            {
                SizeF sizeF = graphics.MeasureString(rackNm, this.labrackNm.Font);
                int   num2  = (int)System.Math.Ceiling((double)sizeF.Width);
                if (num2 > 135)
                {
                    this.labrackNm.Width = (int)System.Math.Ceiling((double)(sizeF.Width + 5f));
                }
                else
                {
                    this.labrackNm.Width = 135;
                }
                if (num2 + 77 > num)
                {
                    num = num2 + 77;
                }
            }
            string[] array = devIDs.Split(new char[]
            {
                ','
            });
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                if (!text.Equals(string.Empty))
                {
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(text));
                    string     text2      = deviceByID.DeviceName + ":" + deviceByID.DeviceIP;
                    using (Graphics graphics2 = base.CreateGraphics())
                    {
                        int num2 = (int)System.Math.Ceiling((double)graphics2.MeasureString(text2, this.lbDevice.Font).Width);
                        if (num2 + 8 > num)
                        {
                            num = num2 + 8;
                        }
                    }
                    this.lbDevice.Items.Add(text2);
                }
            }
            this.lbDevice.Width = num - 8;
            base.Width          = num;
        }
        private async Task <bool> WatchAndExecute(DeviceOperation op)
        {
            _start = DateTime.Now;
            var  disp      = Dispatcher;
            var  watchTask = Task.Run(() => Loop(disp, op));
            bool res;

            try {
                res = await Execute(op);
            } finally {
                _source.Cancel();
            }
            await watchTask;

            return(res);
        }
Esempio n. 24
0
        private object delDevicePro(object param)
        {
            int num = 1;

            System.Collections.ArrayList arrayList = param as System.Collections.ArrayList;
            DBConn connection = DBConnPool.getConnection();

            for (int i = 0; i < arrayList.Count; i++)
            {
                string     value      = (string)arrayList[i];
                DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(value));
                int        num2       = DeviceOperation.DeleteDeviceByID(connection, System.Convert.ToInt32(value));
                if (num2 < 0)
                {
                    num = num2;
                }
                else
                {
                    string valuePair = ValuePairs.getValuePair("Username");
                    if (!string.IsNullOrEmpty(valuePair))
                    {
                        LogAPI.writeEventLog("0430001", new string[]
                        {
                            deviceByID.ModelNm,
                            deviceByID.Mac,
                            deviceByID.DeviceIP,
                            deviceByID.DeviceName,
                            valuePair
                        });
                    }
                    else
                    {
                        LogAPI.writeEventLog("0430001", new string[]
                        {
                            deviceByID.ModelNm,
                            deviceByID.Mac,
                            deviceByID.DeviceIP,
                            deviceByID.DeviceName
                        });
                    }
                }
            }
            connection.Close();
            DeviceOperation.RefreshDBCache(false);
            DeviceOperation.StartDBCleanupThread();
            return(num);
        }
Esempio n. 25
0
 private void tvUserDeviceInit()
 {
     this.dgvAllDevices.Rows.Clear();
     string[] source = this.m_deviceIds.Split(new char[]
     {
         ','
     });
     System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
     for (int i = 0; i < allDevice.Count; i++)
     {
         DeviceInfo deviceInfo      = allDevice[i];
         string     deviceIP        = deviceInfo.DeviceIP;
         string     mac             = deviceInfo.Mac;
         string     deviceName      = deviceInfo.DeviceName;
         string     modelNm         = deviceInfo.ModelNm;
         RackInfo   rackByID        = RackInfo.getRackByID(deviceInfo.RackID);
         string     displayRackName = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
         string     text            = deviceInfo.DeviceID.ToString();
         if (source.Contains(text))
         {
             this.dgvAllDevices.Rows.Add(new object[]
             {
                 true,
                 deviceName,
                 mac,
                 deviceIP,
                 modelNm,
                 displayRackName,
                 text
             });
         }
         else
         {
             this.dgvAllDevices.Rows.Add(new object[]
             {
                 false,
                 deviceName,
                 mac,
                 deviceIP,
                 modelNm,
                 displayRackName,
                 text
             });
         }
     }
 }
        public static string GetOperationString(DeviceOperation oper)
        {
            var ret = "?";

            switch (oper)
            {
            case DeviceOperation.Issue:
                ret = "выдано";
                break;

            case DeviceOperation.Surrender:
                ret = "возвращено";
                break;
            }

            return(ret);
        }
Esempio n. 27
0
        public bool EraseDevice(DeviceOperation op)
        {
            var device = Config.Device;

            op.FlashSize  += device.Flash.Size;
            op.EepromSize += device.Eeprom.Size;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    programmer.EraseDevice();
                }
            }

            op.Complete();
            op.CurrentState = "Everything is done";

            return(true);
        }
Esempio n. 28
0
        public bool ReadFlash(DeviceOperation op)
        {
            var device    = Config.Device;
            var flashSize = device.Flash.Size;

            op.FlashSize += flashSize;

            var flashData = new byte[flashSize];

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    programmer.ReadPage(0, AvrMemoryType.Flash, flashData, 0, flashSize);
                }
            }
            op.CurrentState = "Everything is done";

            FlashHexBoard = HexBoard.From(flashData);

            return(true);
        }
Esempio n. 29
0
        public bool ReadEeprom(DeviceOperation op)
        {
            var device     = Config.Device;
            var eepromSize = device.Eeprom.Size;

            op.EepromSize += eepromSize;

            var eepData = new byte[eepromSize];

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    programmer.ReadPage(0, AvrMemoryType.Eeprom, eepData, 0, eepromSize);
                }
            }
            op.CurrentState = "Everything is done";

            EepromHexBoard = HexBoard.From(eepData);

            return(true);
        }
Esempio n. 30
0
        public bool WriteLocks(DeviceOperation op)
        {
            var device = Config.Device;

            var locksBlocks = LocksHexBoard.SplitBlocks(device.LockBits.PageSize);

            op.LocksSize += locksBlocks.TotalBytes;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    foreach (var block in locksBlocks.Blocks)
                    {
                        programmer.WritePage(block.Address, device.LockBits.Location ?? AvrMemoryType.LockBits, block.Data, 0, block.Data.Length);
                    }
                }
            }
            op.CurrentState = "Everything is done";

            return(true);
        }