Ejemplo n.º 1
0
        public async Task SetConfiguration(int startDepartment, int endDepartment, int departmentsCount,
                                           IEnumerable <IDepartmentRule> orderedRulesList)
        {
            var departmentRules = orderedRulesList.ToList();

            if (departmentRules.Count != departmentsCount)
            {
                throw new ArgumentException("Count of rules not equal count of departments!");
            }

            if (startDepartment > departmentsCount || endDepartment > departmentsCount)
            {
                throw new ArgumentException("Entered department id not included in available identifiers!");
            }

            var departments = departmentRules
                              .Select((rule, index) => new Department(index + 1, rule))
                              .ToList();

            var configuration = new OrganizationConfiguration(startDepartment, endDepartment, departments);

            await FillBypassSheet(configuration).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
        private async Task FillBypassSheet(OrganizationConfiguration configuration)
        {
            var bypassSheet = new BypassSheet();
            var oldId       = 0;

            for (var departmentId = configuration.StartDepartmentId; oldId != configuration.EndDepartmentId;)
            {
                var department = configuration.Departments.FirstOrDefault(d => d.Id == departmentId);
                if (department == null)
                {
                    throw new InvalidDataException("Entered department id not included in available identifiers!");
                }

                if (department.IsCycle)
                {
                    break;
                }

                oldId        = departmentId;
                departmentId = await department.ExecuteDepartmentRuleAsync(bypassSheet);
            }

            Configuration = configuration;
        }
Ejemplo n.º 3
0
 public OrganizationManager()
 {
     Configuration = null;
 }
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="source">The soruce data from a data model</param>
 public OrganizationConfigurationDTO(OrganizationConfiguration source)
 {
     Name           = source.Name;
     Value          = source.Value;
     OrganizationID = source.OrganizationID;
 }