Example #1
0
        public bool AddCountryTest(XML_CountryTest ct, ref string msg)
        {
            bool flag = true;

            try
            {
                if (AllCountryTest.Exists(c => c.StationUniqueId == ct.StationUniqueId && c.NodeId == ct.NodeId))
                {
                    msg  = ct.StationName + " 站点已经存在 " + ct.Remark + " 检测节点";
                    flag = false;
                }
                else if (AllCountryTest.Exists(c => c.StationUniqueId == ct.StationUniqueId && c.TestId == ct.TestId))
                {
                    msg  = ct.StationName + " 站点已经存在testid= " + ct.Remark + " 检测节点";
                    flag = false;
                }
                else
                {
                    lock (AllCountryTest)
                    {
                        int uniqueId = AllCountryTest.Max(c => c.UniqueId);
                        ct.UniqueId = uniqueId + 1;
                        AllCountryTest.Add(ct);
                        flag = AddCountryTestToXML(ct);
                    }
                }
            }
            catch (Exception ex)
            {
                flag = false;
                LogMg.AddError(ex);
            }
            return(flag);
        }
Example #2
0
        /// <summary>
        /// 删除countrytest
        /// </summary>
        /// <param name="uniqueId"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool DelCountryTest(int uniqueId, ref string msg)
        {
            XML_CountryTest _test = AllCountryTest.SingleOrDefault(c => c.UniqueId == uniqueId);

            if (_test != null)
            {
                lock (AllCountryTest)
                {
                    AllCountryTest.Remove(_test);
                    DelCountryTestFromXML(uniqueId);
                    return(true);
                }
            }
            else
            {
                msg = "不存在这个站点";
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 修改countrytest
        /// </summary>
        /// <param name="_test"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool EditCountryTest(XML_CountryTest _test, ref string msg)
        {
            bool flag = true;

            try
            {
                lock (AllCountryTest)
                {
                    XML_CountryTest s = AllCountryTest.SingleOrDefault(c => c.UniqueId == _test.UniqueId);
                    AllCountryTest.Remove(s);   //先把这个对象删了
                    AllCountryTest.Add(_test);  //再把新的对象添加进去
                    flag = EditCountryTestFromXML(_test);
                }
            }
            catch (Exception ex)
            {
                LogMg.AddError(ex);
                flag = false;
            }
            return(flag);
        }