internal string this[string key] { get { if (string.IsNullOrEmpty(key) || !ProjectsDict.ContainsKey(key)) { return(null); } return(ProjectsDict[key] ?? string.Empty); } set { if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) { return; } if (!ProjectsDict.ContainsKey(key)) { ProjectsDict.Add(key, value); Projects.Add(key); _modified = true; return; } ProjectsDict[key] = value; _modified = true; } }
internal void Add(string revitProject, string bimProject) { // input validation if (string.IsNullOrEmpty(revitProject)) { throw new IcnException("Parameter revitProject is not set to a value or reference", 20, "KnownProjects.Add"); } if (!File.Exists(revitProject)) { throw new IcnException($"Parameter revitProject '{revitProject}' does not exist", 20, "KnownProjects.Add"); } if (string.IsNullOrEmpty(bimProject)) { throw new IcnException("Parameter bimProject is not set to a value or reference", 20, "KnownProjects.Add"); } if (!ProjectsDict.ContainsKey(revitProject)) { ProjectsDict.Add(revitProject, bimProject); Projects.Add(revitProject); _modified = true; return; } ProjectsDict[revitProject] = bimProject; _modified = true; }
private void ReadProjects() { // get the path to the storage file string path = SavePath; if (!File.Exists(path)) { return; } // read the file and extract all revit project/bimserver project pairs try { XmlDocument xdoc = new XmlDocument(); xdoc.Load(path); XmlElement root = xdoc.DocumentElement; if (null == root || 0 != string.Compare(root.Name, RootElementXml, StringComparison.InvariantCultureIgnoreCase)) { return; } XmlNodeList nodes = root.SelectNodes(ElementXml); if (null == nodes || nodes.Count <= 0) { return; } foreach (XmlNode node in nodes) { XmlElement elem = node as XmlElement; if (null == elem) { continue; } string revitProject = elem.GetAttribute(RevitProjectXml); if (string.IsNullOrEmpty(revitProject) || ProjectsDict.ContainsKey(revitProject)) { continue; } string bimServerProject = elem.GetAttribute(BimServerXml); if (string.IsNullOrEmpty(bimServerProject)) { continue; } ProjectsDict.Add(revitProject, bimServerProject); } } catch (Exception ex) { throw new IcnException($"Error reading projects file '{path}' ({ex.Message})", 20, "KnownProjects"); } _modified = false; }
public bool Add(ProjectDescription desc) { if (ProjectsDict.ContainsKey(desc.ProjectID)) { ProjectsDict [desc.ProjectID] = desc; } else { ProjectsDict.Add(desc.ProjectID, desc); } return(Save()); }