コード例 #1
0
 public void AddOrUpdateUnit(Guid unitId, Guid agencyId, string unitName)
 {
     if (string.IsNullOrWhiteSpace(unitName))
         return;
     if (unitId == Guid.Empty)
         unitId = Guid.NewGuid();
     if (_units.ContainsKey(unitId))
     {
         _units[unitId].AgencyKeyId = agencyId;
         _units[unitId].UnitName = unitName;
     }
     else
     {
         _units[unitId] = new UnitInfo(unitId, agencyId, unitName);
     }
     MarkChangesMade();
 }
コード例 #2
0
 internal bool LoadInfoFromNode(System.Xml.XmlNode xNode)
 {
     bool bChangesMade = false;
     switch (xNode.Name.ToLower())
     {
         case "agencies":
             {
                 foreach (XmlNode xAgency in xNode.ChildNodes)
                 {
                     Guid agencyId = GetGuidAttribute(xAgency.Attributes["AgencyId"]);
                     if (agencyId == Guid.Empty)
                     {
                         agencyId = Guid.NewGuid();
                         bChangesMade = true;
                     }
                     string agencyName = GetAttributeText(xAgency.Attributes["AgencyName"]);
                     _agencies[agencyId] = new AgencyInfo(agencyId, agencyName);
                 }
                 break;
             }
         case "units":
             {
                 foreach (XmlNode xUnit in xNode.ChildNodes)
                 {
                     Guid unitKeyId = GetGuidAttribute(xUnit.Attributes["UnitKeyId"]);
                     if (unitKeyId == Guid.Empty)
                     {
                         unitKeyId = Guid.NewGuid();
                         bChangesMade = true;
                     }
                     Guid agencyId = GetGuidAttribute(xUnit.Attributes["AgencyId"]);
                     string unitName = GetAttributeText(xUnit.Attributes["UnitName"]);
                     _units[unitKeyId] = new UnitInfo(unitKeyId, agencyId, unitName);
                 }
                 break;
             }
         case "radios":
             {
                 foreach (XmlNode xRadio in xNode.ChildNodes)
                 {
                     Guid agencyId = GetGuidAttribute(xRadio.Attributes["AgencyId"]);
                     Guid unitKeyId = GetGuidAttribute(xRadio.Attributes["UnitKeyId"]);
                     string signalingFormat = GetAttributeText(xRadio.Attributes["SignalingFormat"]);
                     string signalingUnitId = GetAttributeText(xRadio.Attributes["SignalingUnitId"]);
                     string radioName = GetAttributeText(xRadio.Attributes["RadioName"]);
                     string roleName = GetAttributeText(xRadio.Attributes["RoleName"]);
                     string personnelName = GetAttributeText(xRadio.Attributes["PersonnelName"]);
                     RadioTypeCode radioType = GetEnumAttribute<RadioTypeCode>(xRadio.Attributes["RadioType"], RadioTypeCode.Unknown);
                     string firstHeardSource = GetAttributeText(xRadio.Attributes["FirstHeardSource"]);
                     bool excludeFromRollcall = GetBoolAttribute(xRadio.Attributes["ExcludeFromRollcall"]);
                     RadioInfo radioInfo = new RadioInfo(unitKeyId, agencyId, signalingFormat, signalingUnitId, radioName, roleName, personnelName, radioType, firstHeardSource, excludeFromRollcall);
                     _radios[radioInfo.SignalingLookupKey] = radioInfo;
                 }
                 break;
             }
     }
     return bChangesMade;
 }