Beispiel #1
0
        /// <summary>
        /// Конструктор 2.1
        /// </summary>
        /// <param name="name">Наименование департамента</param>
        /// <param name="workers">Работники департамента</param>
        public Department(string name, DepBoss localBoss, ObservableCollection <Department> departs, ObservableCollection <Worker> workers)
        {
            Id = ++countDep;

            Name         = name;
            LocalBoss    = localBoss;
            this.workers = workers;
            this.departs = departs;
        }
Beispiel #2
0
        /// <summary>
        /// Конструктор 1
        /// </summary>
        /// <param name="name">Наименование департамента</param>
        public Department(string name, DepBoss localBoss)
        {
            Id = ++countDep;

            Name      = name;
            LocalBoss = localBoss;

            workers = new ObservableCollection <Worker>();
            departs = new ObservableCollection <Department>();
        }
Beispiel #3
0
        /// <summary>
        /// Конструктор 5
        /// </summary>
        /// <param name="name"></param>
        /// <param name="workers"></param>
        public Department(string name, DepBoss localBoss, ObservableCollection <Worker> workers)
        {
            Id = ++countDep;

            Name             = name;
            LocalBoss        = localBoss;
            this.workers     = workers;
            this.departments = new ObservableCollection <Department>();
            Org = new Organization(this);
        }
Beispiel #4
0
        /// <summary>
        /// Конструктор 1
        /// </summary>
        /// <param name="name">Наименование департамента</param>
        /// <param name="org">Организация включающая департамент</param>
        public Department(string name, Organization org)
        {
            Id = ++countDep;

            Name        = name;
            LocalBoss   = new DepBoss();
            workers     = new ObservableCollection <Worker>();
            departments = new ObservableCollection <Department>();

            Org = org;
        }
        /// <summary>
        /// Вспомогательный рекурсивный метод для десереализации департамента и его поддепартаментов
        /// </summary>
        /// <param name="xeDep">XML-узел</param>
        /// <returns>Департамент с поддепартаментами</returns>
        private static Department deserializerSubDeps(XElement xeDep)
        {
            DepBoss depBoss = new DepBoss(xeDep.Attribute("depbossname").Value,
                                          xeDep.Attribute("depbosslastname").Value,
                                          DateTime.Parse(xeDep.Attribute("depbossbirth").Value));

            ObservableCollection <Worker> workers = new ObservableCollection <Worker>();

            // Перебираем сотрудников и добавляем их в коллекцию workers
            foreach (var itemEmpXml in xeDep.Element("EMPLOYEES").Elements())
            {
                workers.Add(new Employee(itemEmpXml.Attribute("empname").Value,
                                         itemEmpXml.Attribute("emplastname").Value,
                                         DateTime.Parse(itemEmpXml.Attribute("empbirth").Value),
                                         itemEmpXml.Attribute("empnamepost").Value,
                                         int.Parse(itemEmpXml.Attribute("empsalary").Value)));
            }

            // Перебираем интернов и добавляем их в коллекцию workers
            foreach (var itemEmpXml in xeDep.Element("INTERNS").Elements())
            {
                workers.Add(new Intern(itemEmpXml.Attribute("internname").Value,
                                       itemEmpXml.Attribute("internlastname").Value,
                                       DateTime.Parse(itemEmpXml.Attribute("internbirth").Value),
                                       int.Parse(itemEmpXml.Attribute("internsalary").Value)));
            }

            Department dep = new Department(xeDep.Attribute("depname").Value, depBoss, workers);

            if (xeDep.Element("DEPARTMENTS") != null)
            {
                foreach (var itemSubdepXml in xeDep.Element("DEPARTMENTS").Elements("DEPARTMENT").ToList())
                {
                    // ПОДДЕПАРТАМЕНТЫ ДЕПАРТАМЕНТА
                    dep.addDepartament(deserializerSubDeps(itemSubdepXml));                     // рекурсия
                }
            }

            return(dep);
        }
Beispiel #6
0
 /// <summary>
 /// Конструктор 2.3
 /// </summary>
 /// <param name="name"></param>
 /// <param name="workers"></param>
 public Department(string name, DepBoss localBoss, ObservableCollection <Worker> workers)
     : this(name, localBoss, new ObservableCollection <Department>(), workers)
 {
 }