private void delete_Click(object sender, EventArgs e)
        {
            try
            {
                TreeNode node     = this.treeView1.SelectedNode;
                string   typename = node.Tag.ToString();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].typename == typename)
                    {
                        list.RemoveAt(i);
                    }
                }
                string path = Application.StartupPath + "\\TestInfo";
                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "TypeList.json", json);

                InitTree();
                ExpandTree();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// 根据SQL序号删除SQLXML文件
        /// </summary>
        /// <param name="parameters">页面传递的参数</param>
        /// <returns>true:成功,false:失败</returns>
        public object DeleteSql(Dictionary <String, String> parameters)
        {
            try
            {
                JsonOperate _JsonOperate = new JsonOperate();
                //获取SQL序号
                string _SqlNum = parameters.ContainsKey("SqlNum") ? _JsonOperate.FromJsonString <string>(parameters["SqlNum"]) : "";

                //SQL语句所在xml文件路径
                string xmlPath = Path.Combine(SQLPath, _SqlNum + ".xml");
                //判断是否存在文件
                if (!File.Exists(xmlPath))
                {
                    return(new { Methods = false });
                }
                //判断配置文件是否只读
                FileInfo fi = new FileInfo(xmlPath);
                //如果只读则修改为普通
                //if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                //{
                fi.Attributes = FileAttributes.Normal;
                //}

                //删除SQLXML文件
                File.Delete(xmlPath);

                return(new { Methods = true });
            }
            catch
            {
                return(new { Methods = false });
            }
        }
Пример #3
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                string path = Application.StartupPath + "\\TestInfo";
                var    item = list.Where(x => x.InstrumentCluster == combEquipment.Text && x.TypeName == combtypename.Text).FirstOrDefault();
                if (item != null)
                {
                    item.InstrumentCluster = combEquipment.Text;
                    item.TypeName          = combtypename.Text;
                }
                else
                {
                    EquipmentTestInfo testInfo = new EquipmentTestInfo();
                    testInfo.InstrumentCluster = combEquipment.Text;
                    testInfo.TypeName          = combtypename.Text;
                    list.Add(testInfo);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "InstrumentClusterTestInfo.json", json);
                LoadEquipmentTestInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
Пример #4
0
        private void LoadStepInfo()
        {
            string path = Application.StartupPath + "\\TestInfo";
            string json = JsonOperate.GetJson(path, "TestStep.json");

            testInfo = JsonConvert.DeserializeObject <List <TestStep> >(json);
        }
        private void LoadValue(string type)
        {
            this.combValue.DataSource = null;
            switch (type)
            {
            case "CAN":
                string     path = Application.StartupPath + "\\SysConfig";
                string     json = JsonOperate.GetJson(path, "CAN.json");
                List <CAN> temp = JsonConvert.DeserializeObject <List <CAN> >(json);
                this.combValue.DataSource    = temp;
                this.combValue.DisplayMember = "channel";
                break;

            case "COM":
                string     path2 = Application.StartupPath + "\\SysConfig";
                string     json2 = JsonOperate.GetJson(path2, "COM.json");
                List <COM> temp2 = JsonConvert.DeserializeObject <List <COM> >(json2);
                this.combValue.DataSource    = temp2;
                this.combValue.DisplayMember = "portName";
                break;

            default:
                break;
            }
        }
Пример #6
0
        private List <TypeList> LoadTypeList()
        {
            List <TypeList> temp = new List <TypeList>();
            string          path = Application.StartupPath + "\\TestInfo";;
            string          json = JsonOperate.GetJson(path, "TypeList.json");

            temp = JsonConvert.DeserializeObject <List <TypeList> >(json);
            return(temp);
        }
Пример #7
0
        private List <CAN> LoadCANInfo()
        {
            List <CAN> listCAN = new List <CAN>();
            string     path    = Application.StartupPath + "\\SysConfig";
            string     json    = JsonOperate.GetJson(path, "CAN.json");

            listCAN = JsonConvert.DeserializeObject <List <CAN> >(json);
            return(listCAN);
        }
Пример #8
0
        private List <InstrumentClusterConfiguration> LoadICInfo()
        {
            List <InstrumentClusterConfiguration> temp = new List <InstrumentClusterConfiguration>();
            string path = Application.StartupPath + "\\SysConfig";
            string json = JsonOperate.GetJson(path, "InstrumentClusterConfiguration.json");

            temp = JsonConvert.DeserializeObject <List <InstrumentClusterConfiguration> >(json);
            return(temp);
        }
Пример #9
0
        private List <PowerMeter> LoadPowerInfo()
        {
            List <PowerMeter> temp = new List <PowerMeter>();
            string            path = Application.StartupPath + "\\SysConfig";
            string            json = JsonOperate.GetJson(path, "PowerMeter.json");

            temp = JsonConvert.DeserializeObject <List <PowerMeter> >(json);
            return(temp);
        }
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtstepname.Text.Trim()))
                {
                    MessageBox.Show("Stepname can't be empty!");
                    return;
                }
                if (!txtstepname.Text.Trim().Contains("Step"))
                {
                    MessageBox.Show("Stepname should be like 'Step1'!");
                    return;
                }
                if (String.IsNullOrEmpty(combtypename.Text))
                {
                    MessageBox.Show("Typename can't be empty!");
                    return;
                }
                #endregion
                double result = -1;

                string path = Application.StartupPath + "\\TestInfo";
                var    item = stepList.Where(c => c.stepname == txtstepname.Text.Trim() && c.typename == combtypename.Text).FirstOrDefault();
                if (item != null)
                {
                    item.modelname = txtmodename.Text.Trim();
                    item.voltage   = double.TryParse(txtvoltage.Text.Trim(), out result) ? double.Parse(txtvoltage.Text.Trim()):0;
                    item.cycletime = double.TryParse(txtcycletime.Text.Trim(), out result) ? double.Parse(txtcycletime.Text.Trim()) : 0;
                    int msg = -1;
                    item.repeat = int.TryParse(txtrepeat.Text.Trim(), out msg) ? int.Parse(txtrepeat.Text.Trim()) : 1;
                }
                else
                {
                    TestStep step = new TestStep();
                    step.typename  = combtypename.Text;
                    step.stepname  = txtstepname.Text.Trim();
                    step.modelname = txtmodename.Text.Trim();
                    step.voltage   = double.TryParse(txtvoltage.Text.Trim(), out result) ? double.Parse(txtvoltage.Text.Trim()) : 0;
                    step.cycletime = double.TryParse(txtcycletime.Text.Trim(), out result) ? double.Parse(txtcycletime.Text.Trim()) : 0;
                    int msg = -1;
                    step.repeat = int.TryParse(txtrepeat.Text.Trim(), out msg) ? int.Parse(txtrepeat.Text.Trim()) : 1;
                    stepList.Add(step);
                }

                string json = JsonConvert.SerializeObject(stepList, Formatting.Indented);
                JsonOperate.SaveJson(path, "TestStep.json", json);
                LoadStepInfo(combtypename.Text);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
Пример #11
0
 /// <summary>
 /// 添加请求数据
 /// </summary>
 /// <param name="parameterName">请求方法的参数关键字</param>
 /// <param name="parameterValue">与参数关键对应数据</param>
 public void AddRequestData(String parameterName, Object parameterValue)
 {
     try
     {
         JsonOperate _JsonOperate = new JsonOperate();
         requestData.Add(parameterName, _JsonOperate.ToJsonString(parameterValue));
     }
     catch
     {
     }
 }
        private void LoadInfo()
        {
            string     path = Application.StartupPath + "\\SysConfig";
            string     json = JsonOperate.GetJson(path, "CAN.json");
            List <CAN> temp = JsonConvert.DeserializeObject <List <CAN> >(json);

            if (temp != null)
            {
                list = temp;
                this.dataGridView1.DataSource = list;
            }
        }
        private void LoadInfo()
        {
            string path = Application.StartupPath + "\\SysConfig";
            string json = JsonOperate.GetJson(path, "InstrumentClusterConfiguration.json");
            List <AutoTestDLL.Model.InstrumentClusterConfiguration> temp = JsonConvert.DeserializeObject <List <AutoTestDLL.Model.InstrumentClusterConfiguration> >(json);

            if (temp != null)
            {
                list = temp;
                this.dataGridView1.DataSource = list;
            }
        }
Пример #14
0
        private void LoadEquipmentTestInfo()
        {
            string path = Application.StartupPath + "\\TestInfo";
            string json = JsonOperate.GetJson(path, "InstrumentClusterTestInfo.json");
            List <EquipmentTestInfo> temp = JsonConvert.DeserializeObject <List <EquipmentTestInfo> >(json);

            if (temp != null)
            {
                list = temp;
                this.dataGridView1.DataSource = list;
            }
        }
Пример #15
0
        private void LoadTypeInfo()
        {
            string          path = Application.StartupPath + "\\TestInfo";
            string          json = JsonOperate.GetJson(path, "TypeList.json");
            List <TypeList> temp = JsonConvert.DeserializeObject <List <TypeList> >(json);

            if (temp != null)
            {
                this.combtypename.DataSource    = temp.Where(t => t.parentname == "").ToList();
                this.combtypename.DisplayMember = "typename";
            }
        }
        private void LoadStepInfo(string typename)
        {
            string          path = Application.StartupPath + "\\TestInfo";
            string          json = JsonOperate.GetJson(path, "TestStep.json");
            List <TestStep> temp = JsonConvert.DeserializeObject <List <TestStep> >(json);
            List <TestStep> list = temp.Where(x => x.typename == typename).ToList();

            if (temp != null)
            {
                stepList = temp;
                this.dataGridView1.DataSource = list.OrderBy(x => Convert.ToInt32(x.stepname.Replace("Step", ""))).ToList();
            }
        }
Пример #17
0
        /// <summary>
        /// 添加SQLXML文件
        /// </summary>
        /// <param name="parameters">页面传递的参数</param>
        /// <returns>true:成功,false:失败</returns>
        public object AddSql(Dictionary <String, String> parameters)
        {
            try
            {
                ////XML存储路径
                //string _XmlOutPath = Path.Combine(WorkDir, SQLPath);
                //if (!Directory.Exists(_XmlOutPath))//如果路径不存在
                //{
                //    //创建路径
                //    Directory.CreateDirectory(_XmlOutPath);
                //}

                //检查SQLXML路径是否存在
                CheckPath();
                JsonOperate _JsonOperate = new JsonOperate();
                //获取SQL序号
                string _SqlNum = parameters.ContainsKey("SqlNum") ? _JsonOperate.FromJsonString <string>(parameters["SqlNum"]) : "";
                //获取SQL说明
                string _SqlDescription = parameters.ContainsKey("SqlDescription") ? _JsonOperate.FromJsonString <string>(parameters["SqlDescription"]) : "";
                //获取SQL语句
                string _SQLString = parameters.ContainsKey("SQLString") ? _JsonOperate.FromJsonString <string>(parameters["SQLString"]) : "";

                //SQL语句所在xml文件路径
                string xmlPath = Path.Combine(SQLPath, _SqlNum + ".xml");
                if (File.Exists(xmlPath))//如果存在文件,返回false
                {
                    return(new { Methods = false });
                }
                if (string.IsNullOrEmpty(_SqlNum) || string.IsNullOrEmpty(_SqlDescription) || string.IsNullOrEmpty(_SQLString))
                {
                    return(new { Methods = false });
                }
                //实例化XML文件操作类
                XmlOperate _XmlOperate = new XmlOperate();
                //实例化SQL实体类
                SQLCodeEntity _SQLCodeEntity = new SQLCodeEntity();
                _SQLCodeEntity.SqlNum         = _SqlNum;
                _SQLCodeEntity.SqlDescription = _SqlDescription;
                _SQLCodeEntity.SQLString      = _SQLString;

                //转换成xml字符串
                string _XmlString = _XmlOperate.ObjectToSimpleXml(_SQLCodeEntity);
                //生成SQLXML文件
                File.WriteAllText(xmlPath, _XmlString);
                return(new { Methods = true });
            }
            catch
            {
                return(new { Methods = false });
            }
        }
Пример #18
0
        /// <summary>
        /// 根据SQL序号获得SQL信息
        /// </summary>
        /// <param name="parameters">页面传递的参数</param>
        /// <returns>SQL信息</returns>
        public object GetSqlByNum(Dictionary <String, String> parameters)
        {
            try
            {
                JsonOperate _JsonOperate = new JsonOperate();
                //获取SQL序号
                string _SqlNum = parameters.ContainsKey("SqlNum") ? _JsonOperate.FromJsonString <string>(parameters["SqlNum"]) : "";

                //SQLCodeEntity _SQLCodeEntity;
                if (_SQLCodeEntityList != null && SQLCodeManager._SQLCodeEntityList.FirstOrDefault(S => S.SqlNum == _SqlNum) != null)
                {
                    //从缓存中获得SQL实体
                    SQLCodeEntity _SQLCodeEntity = SQLCodeManager._SQLCodeEntityList.FirstOrDefault(S => S.SqlNum == _SqlNum);

                    return(new { Methods = _SQLCodeEntity });
                }
                else
                {
                    //SQL语句所在xml文件路径
                    string xmlPath = Path.Combine(SQLPath, _SqlNum + ".xml");
                    //判断是否存在文件
                    if (!File.Exists(xmlPath))
                    {
                        return(new { Methods = "" });
                    }
                    //实例化XML文件操作类
                    //XmlOperate _XmlOperate = new XmlOperate();
                    //判断配置文件是否只读
                    //FileInfo fi = new FileInfo(xmlPath);
                    ////如果只读则修改为普通
                    //if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                    //{
                    //    fi.Attributes = FileAttributes.Normal;
                    //}
                    ////实例化文件操作类
                    //DirectoryFileOperate _DirectoryFileOperate = new DirectoryFileOperate();
                    ////根据指定路径读取文件
                    //string _XmlContent = _DirectoryFileOperate.ShareReadFile(xmlPath);
                    ////把xml转换成对象
                    //SQLCodeEntity _SQLCodeEntity = _XmlOperate.SimpleXmlToObject<SQLCodeEntity>(_XmlContent);
                    SQLCodeEntity _SQLCodeEntity = SQLCodeHelp.GetSQLCodeEntityByPath(xmlPath);

                    return(new { Methods = _SQLCodeEntity });
                }
            }
            catch
            {
                return(new { Methods = "" });
            }
        }
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txttype.Text.Trim()))
                {
                    MessageBox.Show("type can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtid.Text.Trim()))
                {
                    MessageBox.Show("id can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtdata.Text.Trim()))
                {
                    MessageBox.Show("data can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.id == txtid.Text).FirstOrDefault();
                if (item != null)
                {
                    item.type      = txttype.Text.Trim();
                    item.dlc       = Convert.ToInt32(txtdlc.Text.Trim());
                    item.data      = txtdata.Text.Trim();
                    item.cycletime = Convert.ToInt32(txtct.Text.Trim());
                }
                else
                {
                    ManualInstruction Ins = new ManualInstruction();
                    Ins.type      = txttype.Text.Trim();
                    Ins.id        = txtid.Text.Trim();
                    Ins.dlc       = Convert.ToInt32(txtdlc.Text.Trim());
                    Ins.data      = txtdata.Text.Trim();
                    Ins.cycletime = Convert.ToInt32(txtct.Text.Trim());
                    list.Add(Ins);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "ManualInstrustion.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
Пример #20
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtPortName.Text.Trim()))
                {
                    MessageBox.Show("AmmeterName can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtPortName.Text))
                {
                    MessageBox.Show("PortName can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.ammeterName == txtAmmeterName.Text.Trim() && c.portName == txtPortName.Text).FirstOrDefault();
                if (item != null)
                {
                    item.baudrate  = String.IsNullOrEmpty(txtBaudRate.Text.Trim())?0:Convert.ToInt32(txtBaudRate.Text.Trim());
                    item.parity    = (Parity)Enum.Parse(typeof(Parity), label11.Text);
                    item.dataBits  = String.IsNullOrEmpty(txtDataBits.Text.Trim()) ? 0 : Convert.ToInt32(txtDataBits.Text.Trim());
                    item.stopBits  = (StopBits)Enum.Parse(typeof(StopBits), txtStopBits.Text);
                    item.handshake = (Handshake)Enum.Parse(typeof(Handshake), txtHandshake.Text);
                }
                else
                {
                    AmmeterConfiguration ammeter = new AmmeterConfiguration();
                    ammeter.ammeterName = txtAmmeterName.Text.Trim();
                    ammeter.portName    = txtPortName.Text.Trim();
                    ammeter.baudrate    = String.IsNullOrEmpty(txtBaudRate.Text.Trim()) ? 0 : Convert.ToInt32(txtBaudRate.Text.Trim());
                    ammeter.parity      = (Parity)Enum.Parse(typeof(Parity), txtParity.Text, true);
                    ammeter.dataBits    = String.IsNullOrEmpty(txtDataBits.Text.Trim()) ? 0 : Convert.ToInt32(txtDataBits.Text.Trim());
                    ammeter.stopBits    = (StopBits)Enum.Parse(typeof(StopBits), txtStopBits.Text, true);
                    ammeter.handshake   = (Handshake)Enum.Parse(typeof(Handshake), txtHandshake.Text, true);
                    list.Add(ammeter);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "AmmeterConfiguration.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
Пример #21
0
        private void LoadInfo()
        {
            string path = Application.StartupPath + "\\SysConfig";
            string json = JsonOperate.GetJson(path, "InstrumentClusterConfiguration.json");
            List <InstrumentClusterConfiguration> temp = JsonConvert.DeserializeObject <List <InstrumentClusterConfiguration> >(json);

            if (temp != null)
            {
                foreach (InstrumentClusterConfiguration equipment in temp)
                {
                    if (!this.listBox1.Items.Contains(equipment.InstrumentCluster))
                    {
                        this.listBox1.Items.Add(equipment.InstrumentCluster);
                    }
                }
            }
        }
Пример #22
0
 private void frmSelectTestType_Load(object sender, EventArgs e)
 {
     try
     {
         string          path = Application.StartupPath + "\\TestInfo";;
         string          json = JsonOperate.GetJson(path, "TypeList.json");
         List <TypeList> temp = JsonConvert.DeserializeObject <List <TypeList> >(json);
         if (temp != null)
         {
             list = temp;
             InitTree();
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, ex.Message);
     }
 }
Пример #23
0
        public void ReadConfig(string fileName, Label status)
        {
            //读取数据库配置
            if (File.Exists(fileName))
            {
                JsonOperate        jsonOperate = new JsonOperate();
                ConnectStringModel m           = new ConnectStringModel();

                ConnectStringModel connectModel = jsonOperate.JsonToModel <ConnectStringModel>(fileName, m);

                status.Text = connectModel.DataSource + "-" + connectModel.DataBase;

                status.ForeColor = Color.Green;
            }
            else
            {
                status.Text      = "未配置";
                status.ForeColor = Color.Red;
            }
        }
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtEquipment.Text.Trim()))
                {
                    MessageBox.Show("Equipment can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(combParamter.Text))
                {
                    MessageBox.Show("Paramter can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.InstrumentCluster == txtEquipment.Text.Trim() && c.CommunicationType == combParamter.Text).FirstOrDefault();
                if (item != null)
                {
                    item.CommunicationType = combParamter.Text;
                    item.Value             = combValue.Text;
                }
                else
                {
                    AutoTestDLL.Model.InstrumentClusterConfiguration equipment = new AutoTestDLL.Model.InstrumentClusterConfiguration();
                    equipment.InstrumentCluster = txtEquipment.Text.Trim();
                    equipment.CommunicationType = combParamter.Text;
                    equipment.Value             = combValue.Text;
                    list.Add(equipment);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "InstrumentClusterConfiguration.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
Пример #25
0
        private void InitAmmeterConfigurationInfo()
        {
            System.Timers.Timer ammeterTimer = new System.Timers.Timer();
            ammeterTimer.Interval = 1000;
            ammeterTimer.Elapsed += ammeter_Tick;

            string path = Application.StartupPath + "\\SysConfig";
            string json = JsonOperate.GetJson(path, "AmmeterConfiguration.json");

            ammeterList = JsonConvert.DeserializeObject <List <AmmeterConfiguration> >(json);
            if (ammeterList != null)
            {
                this.panel1.Controls.Clear();
                foreach (AmmeterConfiguration ammeter in ammeterList)
                {
                    string ammeterName = ammeter.ammeterName;
                    LoadAmmeterConfigurationInfo(ammeterName);
                }
            }
            ammeterTimer.Start();
        }
        private void Init()
        {
            string          path = Application.StartupPath + "\\TestInfo";
            string          json = JsonOperate.GetJson(path, "TypeList.json");
            List <TypeList> temp = JsonConvert.DeserializeObject <List <TypeList> >(json);

            if (temp != null)
            {
                //filter parentname is empty
                for (int i = 0; i < temp.Count; i++)
                {
                    string parentname = temp[i].parentname;
                    if (parentname == "")
                    {
                        temp.RemoveAt(i);
                    }
                }
                List <TypeList> list = temp.Where(x => x.parentname == temp[0].parentname).ToList();
                FitComboAndLabel(list, 0);
            }
        }
Пример #27
0
        private void LoadEquipmentInfo()
        {
            string path = Application.StartupPath + "\\SysConfig";
            string json = JsonOperate.GetJson(path, "InstrumentClusterConfiguration.json");
            List <InstrumentClusterConfiguration> temp = JsonConvert.DeserializeObject <List <InstrumentClusterConfiguration> >(json);

            if (temp != null)
            {
                foreach (InstrumentClusterConfiguration equipment in temp)
                {
                    string   eq       = equipment.InstrumentCluster;
                    TestUnit testUnit = new TestUnit();
                    testUnit.Name = eq;
                    testUnit.Tag  = eq;
                    if (!DicEquipmentInfo.ContainsKey(eq))
                    {
                        DicEquipmentInfo.Add(eq, testUnit);
                    }
                }
            }
        }
Пример #28
0
        private void LoadTemperatureInfo()
        {
            string path = Application.StartupPath + "\\SysConfig";
            string json = JsonOperate.GetJson(path, "TempSensorConfiguration.json");
            List <TempSensorConfiguration> temp = JsonConvert.DeserializeObject <List <TempSensorConfiguration> >(json);

            if (temp != null)
            {
                foreach (TempSensorConfiguration t in temp)
                {
                    string             sensorName  = t.SensorName;
                    TemperatureControl temperature = new TemperatureControl();
                    temperature.Name = sensorName;
                    temperature.Tag  = sensorName;
                    if (!DicTemperatureInfo.ContainsKey(sensorName))
                    {
                        DicTemperatureInfo.Add(sensorName, temperature);
                    }
                }
            }
        }
Пример #29
0
        private List <TypeList> LoadEquipmentTestInfo()
        {
            List <TypeList> result = new List <TypeList>();

            string path = Application.StartupPath + "\\TestInfo";
            string json = JsonOperate.GetJson(path, "InstrumentClusterTestInfo.json");
            List <EquipmentTestInfo> temp = JsonConvert.DeserializeObject <List <EquipmentTestInfo> >(json);

            string          json2 = JsonOperate.GetJson(path, "TypeList.json");
            List <TypeList> temp2 = JsonConvert.DeserializeObject <List <TypeList> >(json2);

            if (temp != null && temp2 != null)
            {
                List <EquipmentTestInfo> list = temp.Where(t => t.InstrumentCluster == this.Tag.ToString()).ToList();

                foreach (EquipmentTestInfo info in list)
                {
                    result.AddRange(temp2.Where(t => t.typename == info.TypeName || t.parentname == info.TypeName).ToList());
                }
            }
            return(result);
        }
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(combChannel.Text.Trim()))
                {
                    MessageBox.Show("Channel can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(combBaudRate.Text))
                {
                    MessageBox.Show("PortName can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.Channel == combChannel.Text).FirstOrDefault();
                if (item != null)
                {
                    item.Baudrate = combBaudRate.Text.Trim();
                }
                else
                {
                    CAN can = new CAN();
                    can.Channel  = String.IsNullOrEmpty(combChannel.Text.Trim()) ? "" : combChannel.Text.Trim();
                    can.Baudrate = combBaudRate.Text.Trim();
                    list.Add(can);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "CAN.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }