コード例 #1
0
        /// <summary>
        /// Сериализует департамент вместе с вложенными департаментами
        /// </summary>
        public static JObject SerializeDepartamentWithSub(AbsDepartment department)
        {
            JObject finished = new JObject();

            finished["Id"]          = department.Id;
            finished["Class"]       = department.GetType().Name;
            finished["InheritedID"] = department.inheritedID;
            finished["Title"]       = department.Title;


            JArray employees = new JArray();

            foreach (var e in department.Employees)
            {
                employees.Add(GetJObjectPerson(e));
            }
            finished["Employees"] = employees;
            JArray departments = new JArray();

            if (department.Departments.Count > 0)
            {
                foreach (var d in department.Departments)
                {
                    departments.Add(SerializeDepartamentWithSub(d));
                }
            }
            finished["Departments"] = departments;
            return(finished);
        }
コード例 #2
0
        /// <summary>
        /// Возвращает наибольший ID сотрудника депратамента
        /// </summary>
        /// <param name="dep">Департамент</param>
        /// <returns></returns>
        static int BiggerEmplId(AbsDepartment dep)
        {
            int result = 0;

            foreach (var e in dep.Employees)
            {
                if (e.Id > result)
                {
                    result = e.Id;
                }
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Присваивает глобальным статическим переменным последние ID (потребуется для создания новых экземпляров)
        /// </summary>
        /// <param name="md">Департамент самого высокого уровня</param>
        static void GetLastIds(AbsDepartment md)
        {
            if (md.Id >= AbsDepartment.countID)
            {
                AbsDepartment.countID = md.Id;
            }
            var eid = BiggerEmplId(md);

            if (eid > Person.countID)
            {
                Person.countID = eid;
            }
            foreach (var i in md.Departments)
            {
                GetLastIds(i);
            }
        }
コード例 #4
0
ファイル: 1 Person.cs プロジェクト: VolkovaVG/OrgStructure
        public Person(string name, string lastName, string position, AbsDepartment department, int id = -1)
            : base()
        {
            if (id == -1)
            {
                this.id = NewID();
            }
            else
            {
                this.Id = id;
            }
            this.Name     = name;
            this.LastName = lastName;
            this.Position = position;

            this.Department = department;
            //EmpTypes.Add("hhh", typeof(Intern))
        }
コード例 #5
0
        /// <summary>
        /// Просчитывает ЗП товарищей трудящихся
        /// </summary>
        /// <param name="start">Начальная ЗП</param>
        /// <param name="dep">Департамент для подсчета</param>
        protected double GetAllSalaries(AbsDepartment dep, double start)
        {
            double sal = start;

            foreach (var e in dep.Employees)
            {
                if (e is Intern)
                {
                    sal += e.Salary * CoefSalary;
                }
                if (e is Employee)
                {
                    sal += e.Salary * CoefSalary;
                }
            }
            foreach (var d in dep.Departments)
            {
                sal = GetAllSalaries(d, sal);
            }
            return(sal);
        }
コード例 #6
0
        /// <summary>
        /// Преобразует экземпляр калсса AbsDepartament в JObject
        /// </summary>
        /// <param name="department">Сериализуемый департамент</param>
        public static JObject GetJObjectDepartament(AbsDepartment department)
        {
            JObject result = new JObject();

            result["Id"]          = department.Id;
            result["inheritedId"] = department.inheritedID;
            result["Title"]       = department.Title;
            //Заполняем различающиеся поля
            if (department is Department)
            {
                result["Class"] = "Department";
            }

            JArray employees = new JArray();

            foreach (var e in department.Employees)
            {
                employees.Add(GetJObjectPerson(e));
            }
            result["Employees"] = employees;
            return(result);
        }
コード例 #7
0
 public TopManager(string name, string surname, string position, AbsDepartment departament)
     : base(name, surname, position, departament)
 {
 }
コード例 #8
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="name"></param>
 /// <param name="surname"></param>
 /// <param name="position"></param>
 /// <param name="department"></param>
 public LocalManager(string name, string surname, string position, AbsDepartment department)
     : base(name, surname, position, department)
 {
     error = "";
 }
コード例 #9
0
 public Intern(string name, string lastName, string position, AbsDepartment departament)
     : base(name, lastName, position, departament)
 {
 }
コード例 #10
0
 public BranchOfficeManager(string name, string surname, string position, AbsDepartment departament)
     : base(name, surname, position, departament)
 {
 }