public void AddMissingMateriale(MaterialeProcessState state, Func <string, string> getResourcePath) { List <MaterialePakke> pakker = GetMaterialePakker(); pakker = pakker.OrderBy(pakke => pakke.new_stoerrelse).ToList(); List <Account> accounts = GetAccountsToAddMaterialeBehov(BehovDefinitioner, state, getResourcePath); foreach (Account account in accounts) { Dictionary <MaterialePakke, int> materialePakkerOnAccount = new Dictionary <MaterialePakke, int>(); decimal materialeNeededCount = GetMaterialeNeededCount(BehovDefinitioner, account) * new_antalfaktor.GetValueOrDefault(1); int currentSize = 0; currentSize = account.CountMaterialeBehov(Id, getResourcePath); FindMaterialeNeed(pakker, materialePakkerOnAccount, materialeNeededCount, currentSize); CreateMaterialeBehov(account, materialePakkerOnAccount); } state.AccountsProcessed = accounts.Count; }
private List <Account> GetAccountsToAddMaterialeBehov(List <MaterialeBehovDefinition> behovDefinitioner, MaterialeProcessState state, Func <string, string> getResourcePath) { List <Account> accounts = new List <Account>(); switch (state.BehovType) { case MaterialeBehovDefinition.behovtypeEnum.Indsamlingssted: GetAccountsIndsamlingssted(behovDefinitioner, accounts, state.owningbusinessunit, getResourcePath, state.pagingInformation); if (accounts.Count == 0) { state.BehovType = MaterialeBehovDefinition.behovtypeEnum.ForventetAntalIndsamlere2016; return(GetAccountsToAddMaterialeBehov(behovDefinitioner, state, getResourcePath)); } break; case MaterialeBehovDefinition.behovtypeEnum.ForventetAntalIndsamlere2016: GetAccountsForventetAntalIndsamlere2016(behovDefinitioner, accounts, state.owningbusinessunit, getResourcePath, state.pagingInformation); if (accounts.Count == 0) { state.BehovType = MaterialeBehovDefinition.behovtypeEnum.Indsamlingshjaelper; return(GetAccountsToAddMaterialeBehov(behovDefinitioner, state, getResourcePath)); } break; case MaterialeBehovDefinition.behovtypeEnum.Indsamlingshjaelper: GetAccountsIndsamlingshjaelper(behovDefinitioner, accounts, state.owningbusinessunit, getResourcePath, state.pagingInformation); if (accounts.Count == 0) { state.pagingInformation.Reset(); } break; default: break; } return(accounts); }