コード例 #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);
        }
コード例 #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;
        }
コード例 #3
0
 public OrganizationManager()
 {
     Configuration = null;
 }
コード例 #4
0
 /// <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;
 }