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);
        }