예제 #1
0
        /// <summary>
        /// 查询数据库
        /// </summary>
        /// <param name="date"></param>
        /// <param name="type"></param>
        /// <param name="itemName"></param>
        public void QueryDatabase(DateTime date, TYPE_COFFEE type, string itemName)
        {
            int countFailItem = 0;

            string[]     results   = MySQLTool.MySql.CheckResultSelect(date, type.ToString());
            List <float> listItems = MySQLTool.MySql.SelectItem(date, type.ToString(), itemName);
            int          i         = Int32.Parse(Regex.Replace(itemName, @"^[A-Za-z]+", string.Empty));

            Global.ChangeCoffeeType(type);
            foreach (var item in listItems)
            {
                if (item < Global.ListItemParameter[i - 1].UserMin || item > Global.ListItemParameter[i - 1].UserMax)
                {
                    countFailItem++;
                }
            }
            Global.ChangeCoffeeType((TYPE_COFFEE)Enum.Parse(typeof(TYPE_COFFEE), type.ToString()));
            string[] statistic = new string[results.Length + 1];
            for (int j = 0; j < results.Length; j++)
            {
                statistic[j] = results[j];
            }
            statistic[statistic.Length - 1] = countFailItem.ToString();
            if (UpdateMainViewRecords != null)
            {
                UpdateMainViewRecords(statistic);
            }
        }
예제 #2
0
        /// <summary>
        /// 保存检测项参数配置
        /// </summary>
        public static void Serialize(TYPE_COFFEE type)
        {
            //string currentDirectory = Directory.GetCurrentDirectory();
            string currentDirectory = @"E:\佐帕斯\Coffee\Zoppas\bin\Debug";

            File.Delete(currentDirectory + "\\" + type.ToString() + ".txt");
            FileStream    fs         = new FileStream(currentDirectory + "\\" + type.ToString() + ".txt", FileMode.Create);
            XmlSerializer serializer = new XmlSerializer(typeof(List <Parameter>));

            serializer.Serialize(fs, ListItemParameter);
            fs.Close();
        }
예제 #3
0
        /// <summary>
        /// 存储数据库
        /// </summary>
        void SaveDatabase()
        {
            if (_Products.Count == 0)
            {
                return;
            }
            List <insertRecordStr> list = new List <insertRecordStr>();
            string  id      = String.Empty;
            string  type    = _Type.ToString();
            string  result  = String.Empty;
            Product product = _Products[0];

            if (product.CurrentOP == 7)
            {
                id = product.ID;
                for (int i = 0; i < product.ListValue.Count; i++)
                {
                    list.Add(new insertRecordStr {
                        insertItemName = "Item" + (i + 1).ToString(), insertItemValue = product.ListValue[i].ToString()
                    });
                }
                if (product.Result.HasValue)
                {
                    result = (bool)product.Result ? "1" : "0";
                }
                MySQLTool.MySql.InsertRow(id, type, result, list);
            }
        }
예제 #4
0
        /// <summary>
        /// 导入检测项参数配置
        /// </summary>
        public static void Deserialize(TYPE_COFFEE type)
        {
            //string currentDirectory = Directory.GetCurrentDirectory();
            string     currentDirectory = @"E:\佐帕斯\Coffee\Zoppas\bin\Debug";
            FileStream fs = null;

            try
            {
                fs = new FileStream(currentDirectory + "\\" + type.ToString() + ".txt", FileMode.Open);
            }
            catch (Exception)
            {
                Logger.Fatal("Open file failed.");
                _ListItemParameter7319 = new List <Parameter>
                {
                    { new Parameter("mm")
                      {
                          Name = "平整度", FactoryMin = 0, FactoryMax = 0.5, UserMin = 0, UserMax = 0.5
                      } },
                    { new Parameter("mm")
                      {
                          Name = "NTC孔处加热丝位置", FactoryMin = 39, FactoryMax = 45, UserMin = 39, UserMax = 45
                      } },
                    { new Parameter("mm")
                      {
                          Name = "螺钉位置", FactoryMin = 52.5, FactoryMax = 53.5, UserMin = 52.5, UserMax = 53.5
                      } },
                    { new Parameter("度")
                      {
                          Name = "螺钉角度", FactoryMin = 88.5, FactoryMax = 91.5, UserMin = 88.5, UserMax = 91.5
                      } },
                    { new Parameter("mm")
                      {
                          Name = "左电极位置", FactoryMin = 98, FactoryMax = 104, UserMin = 98, UserMax = 104
                      } },
                    { new Parameter("mm")
                      {
                          Name = "水嘴位置", FactoryMin = 85, FactoryMax = 87, UserMin = 85, UserMax = 87
                      } },
                    { new Parameter("mm")
                      {
                          Name = "NTC孔直径", FactoryMin = 4.0, FactoryMax = 4.2, UserMin = 4.0, UserMax = 4.2
                      } },
                    { new Parameter("mm")
                      {
                          Name = "NTC位置", FactoryMin = 31.65, FactoryMax = 32.25, UserMin = 31.65, UserMax = 32.25
                      } },
                    { new Parameter("mm")
                      {
                          Name = "右电极位置", FactoryMin = 98, FactoryMax = 104, UserMin = 98, UserMax = 104
                      } },
                    { new Parameter("mm")
                      {
                          Name = "温控器到加热管间隙", FactoryMin = 0.5, FactoryMax = 2, UserMin = 0.5, UserMax = 2
                      } },
                    { new Parameter("mm")
                      {
                          Name = "热熔断器到加热管间隙", FactoryMin = 0.5, FactoryMax = 1.2, UserMin = 0.5, UserMax = 1.2
                      } },
                    { new Parameter("mm")
                      {
                          Name = "2加热丝间隙", FactoryMin = 1, FactoryMax = 999, UserMin = 1, UserMax = 999
                      } },
                };
                return;
            }
            XmlSerializer serializer = new XmlSerializer(typeof(List <Parameter>));

            _ListItemParameter7319 = (List <Parameter>)serializer.Deserialize(fs);
            _ListItemParameter     = _ListItemParameter7319;
            //ChangeCoffeeType(TYPE_COFFEE.T_7319);
            //NotifyView();
            fs.Close();
        }