/// <summary> /// 获取不再指定范围里的型号,如果都在范围里面则返回null /// </summary> /// <param name="type1"></param> /// <param name="type2"></param> /// <param name="number">比较的次数,1是A和B比较,2是B和A比较。</param> /// <returns></returns> private bool CheckControllerCompatible(CentralController type1, CentralController type2, int number) { if (string.IsNullOrEmpty(type1.CompatibleModel)) { if (number == 1) { //type1没有明确兼容的控制器,需要第二次比较,如果type2不兼容type1,则最后结果是不兼容 return(CheckControllerCompatible(type2, type1, 2)); } else { return(true); } } else if (type1.CompatibleModel == "none") { //2.1 - Not compatible with other central controler JCMsg.ShowWarningOK(Msg.CONTROLLER_NOT_COMPATIBLE); return(false); } else { //2.2 - is combinable List <string> compatibleModels = new List <string>(); compatibleModels.AddRange(type1.CompatibleModel.Split(',')); //兼容性逻辑应该是所有类型适用的,所以下面的判断可以去掉 20160901 by Yunxiao Lin //if (type2.Type == ControllerType.CentralController || type2.Type == ControllerType.ONOFF) //{ if (!compatibleModels.Contains(type2.BrandCode == "H" ? type2.Model_Hitachi : type2.Model_York)) { //type1不兼容type2, 有3种情况 //1. 如果是第二次比较还是不兼容的话,则肯定是不兼容 //2. 如果是第一次比较,type1不兼容typ2,而type2没有指定兼容的型号,则判断为不兼容。 if (number == 2 || string.IsNullOrEmpty(type2.CompatibleModel)) { JCMsg.ShowWarningOK(Msg.CONTROLLER_NOT_COMPATIBLE_WITH(number == 1 ? type2.Model : type1.Model)); return(false); } //3.如果第一次比较下来type1不兼容typ2, 并且type2有明确兼容的型号,则要看type2是不是兼容type1。 else { return(CheckControllerCompatible(type2, type1, 2)); } } //} } return(true); }