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;
        }
Esempio n. 4
0
 public bool Delete(Guid uuid)
 {
     if (ProjectsDict.ContainsKey(uuid))
     {
         ProjectsDict.Remove(uuid);
         return(Save());
     }
     return(false);
 }
        internal bool ContainsKey(string revitProject)
        {
            if (string.IsNullOrEmpty(revitProject))
            {
                return(false);
            }

            return(ProjectsDict.ContainsKey(revitProject));
        }
Esempio n. 6
0
 public bool Add(ProjectDescription desc)
 {
     if (ProjectsDict.ContainsKey(desc.ProjectID))
     {
         ProjectsDict [desc.ProjectID] = desc;
     }
     else
     {
         ProjectsDict.Add(desc.ProjectID, desc);
     }
     return(Save());
 }
        private void logChanges(Tasks t, Guid userID)
        {
            string log           = string.Empty;
            string Delimiterline = string.Empty;

            if (t.ChangeTracker.State == ObjectState.Modified)
            {
                if (t.ChangeTracker.ChangedProperties.Count > 0)
                {
                    DateTime?dateClosed = t.dateClosed;
                    Delimiterline = getLogDelimiterLine(logDelimiterMode.Modified, userID, t.taskName);
                    foreach (string changedProperty in t.ChangeTracker.ChangedProperties)
                    {
                        PropertyInfo piInstance =
                            typeof(Tasks).GetProperty(changedProperty);
                        var    val          = piInstance.GetValue(t, null);
                        string currentValue = string.Empty;
                        if (val != null)
                        {
                            currentValue = val.ToString();
                        }

                        switch (changedProperty.ToLower())
                        {
                        case "taskstatusid":
                            if (currentValue.Length == 0)
                            {
                                log += string.Format("Status Cleared{0}", Environment.NewLine);
                            }
                            else
                            {
                                if (Int32.Parse(currentValue) == 4)     //finished
                                {
                                    dateClosed = DateTime.Now;
                                }
                                log += string.Format("Status changed to '{0}'{1}", StatusDict[Int32.Parse(currentValue)], Environment.NewLine);
                            }

                            break;

                        case "requesterid":
                            if (currentValue.Length == 0)
                            {
                                log += string.Format("Requested by Cleared{0}", Environment.NewLine);
                            }
                            else
                            {
                                log += string.Format("Requester changed to '{0}'{1}", UsersDict[Guid.Parse(currentValue)].userName, Environment.NewLine);
                            }
                            break;

                        case "projectid":
                            if (currentValue.Length == 0)
                            {
                                log += string.Format("Project Cleared{0}", Environment.NewLine);
                            }
                            else
                            {
                                if (ProjectsDict.ContainsKey(Guid.Parse(currentValue)))
                                {
                                    log += string.Format("Project changed to '{0}'{1}", ProjectsDict[Guid.Parse(currentValue)], Environment.NewLine);
                                }
                            }
                            break;

                        case "remarks":
                            log += string.Format("Remarks Change{0}", Environment.NewLine);
                            break;

                        case "priority":
                            //skip logging changes in priority
                            break;

                        case "userid":
                            log += string.Format("Task was assigned to: '{0}'{1}", UsersDict[Guid.Parse(currentValue)].userName, Environment.NewLine);
                            break;

                        default:
                            if (changedProperty.ToLower() != "updateslog")
                            {
                                log += string.Format("'{0}' changed to : '{1}'{2}", changedProperty, currentValue, Environment.NewLine);
                            }
                            break;
                        }
                    }
                    t.dateClosed = dateClosed;
                }
            }
            else if (t.ChangeTracker.State == ObjectState.Added)
            {
                t.dateEntered = DateTime.Now;
                log           = getLogDelimiterLine(logDelimiterMode.Added, userID, t.taskName); //string.Format("{0}{1}{2} - Added by '{3}':{4}{5}{6}", LINE_DELIMITER, Environment.NewLine, DateTime.Now, friendlyUserName, Environment.NewLine, LINE_DELIMITER, Environment.NewLine);
            }
            if (log.Length > 0)
            {
                t.UpdatesLog = Delimiterline + log + t.UpdatesLog;
            }
        }