public double Calculate(IBudget budget) { IDiscount d1 = new DiscountForFiveItems(); IDiscount d2 = new DiscountForAValueGreaterThan500(); IDiscount d3 = new NoDiscount(); d1.Next = d2; d2.Next = d3; return(d1.Discount(budget)); }
private BudgetWeek BindDataOf(IBudget budget) { var dataSource = new SortedDictionary <PEOrderKey, PEBudgetRow>(); var currentWeekMarker = CurrentWeekMarker(budget); BudgetWeek currentWeek = null; var lastWeekMonth = 0; foreach (var week in budget.Weeks) { if (week.Contains(currentWeekMarker)) { currentWeek = week; } if (week.Month != lastWeekMonth) { dataSource.Add( new PEOrderKey(week.FirstDay.MonthFirstDay(), WeekRowRank.MonthTitle), new PEBudgetRow { Date = week.FirstDay.ToString("MMMM") }); } dataSource.Add( new PEOrderKey(week.FirstDay, WeekRowRank.WeekTitle), new PEBudgetRow { Date = string.Format("Неделя {0:d} - {1:d}", week.FirstDay, week.LastDay), Amount = string.Format("Свободные {0}", budget.GetFreeMoney(week.FirstDay).ToString("D")), }); // todo : performance var monthlyCashStatements = budget.MonthlyCashMovements.Within(week).ToList(); AddExpenses(week, dataSource, DayRowRank.MonthlyIncome, monthlyCashStatements.Where(_ => _.Amount > 0), currentWeek, PEBudgetRow.CurrentWeekMonthlyIncome); AddExpenses(week, dataSource, DayRowRank.MonthlyExpense, monthlyCashStatements.Where(_ => _.Amount <= 0), currentWeek, PEBudgetRow.CurrentWeekMonthlyOutcome); AddTransfers(week, dataSource, DayRowRank.Income, budget.Investments.Within(week), deletionService.DeleteCashMovement, OnEditCashMovement, currentWeek, PEBudgetRow.CurrentWeekIncome); AddTransfers(week, dataSource, DayRowRank.Expense, budget.Expenses.Within(week), deletionService.DeleteCashMovement, OnEditCashMovement, currentWeek, PEBudgetRow.CurrentWeekOutcome); AddReminders(week, dataSource, DayRowRank.Remainer, budget.Remainders.Within(week), budget, deletionService.DeleteRemainder, OnEditRemainder, currentWeek, PEBudgetRow.Default); lastWeekMonth = week.Month; } view.CalculationResults.DataSource = new List <PEBudgetRow>(dataSource.Values); var monthToBalance = budget.Remainders.LastOrDefault()?.Date ?? DateTimeService.Now(); var balance = budget.MonthlyActualBalances.GetFor(monthToBalance); var nextMonth = monthToBalance.AddMonths(1); var nextMonthBalance = budget.MonthlyActualBalances.GetFor(nextMonth); view.MonthlyBalance = $"{monthToBalance:MMM}: {balance:+#;-#}, {nextMonth:MMM}: {nextMonthBalance:+#;-#}"; return(currentWeek); }
protected override void AddToQueryList(UserResultMapping userResultMapping, IBudget budget) { OrganizationId organizationId; if (base.TryGetOrganizationId(userResultMapping, out organizationId)) { base.AddToADQueryList(userResultMapping, organizationId, null, budget); return; } this.AddToMServeQueryList(userResultMapping); }
internal static string GetPolicyDataForUser(ADUser user, IBudget budget) { PolicyData policyData = MobilePolicySettingsHelper.GetPolicyData(user, budget); if (policyData != null) { bool flag; return(ProvisionCommandPhaseOne.BuildEASProvisionDoc(121, out flag, policyData)); } ExTraceGlobals.FrameworkTracer.TraceDebug <string>(0L, "[MobilePolicySettingsHelper.GetPolicyDataForUser()] No explicit or default policy found for user {0}", user.Alias); return(null); }
protected override void AddToQueryList(UserResultMapping userResultMapping, IBudget budget) { FaultInjection.GenerateFault((FaultInjection.LIDs) 2745576765U); OrganizationId organizationId; if (base.TryGetOrganizationId(userResultMapping, out organizationId)) { base.AddToADQueryList(userResultMapping, organizationId, null, budget); return; } this.AddToMServeQueryList(userResultMapping); }
private LocalizedString GenerateDelayInfoLogString(IBudget budget, DelayEnforcementResults info) { LocalizedString result = LocalizedString.Empty; if (!string.Equals(info.NotEnforcedReason, "No Delay Necessary", StringComparison.OrdinalIgnoreCase)) { CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "DelayInfo.Type", info.DelayInfo.GetType().Name); if (info.NotEnforcedReason != null) { CmdletLogger.SafeAppendGenericInfo(this.context.UniqueId, "NotEnforcedReason", info.NotEnforcedReason); } if (string.Equals(info.NotEnforcedReason, "Max Delayed Threads Exceeded", StringComparison.OrdinalIgnoreCase)) { BudgetTypeSetting budgetTypeSetting = BudgetTypeSettings.Get(budget.Owner.BudgetType); if (info.DelayInfo is UserQuotaDelayInfo) { UserQuotaDelayInfo userQuotaDelayInfo = info.DelayInfo as UserQuotaDelayInfo; result = Strings.UserQuotaDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, userQuotaDelayInfo.OverBudgetException.PolicyPart, budgetTypeSetting.MaxDelayedThreads); } else if (info.DelayInfo is ResourceLoadDelayInfo) { ResourceLoadDelayInfo resourceLoadDelayInfo = info.DelayInfo as ResourceLoadDelayInfo; result = Strings.ResourceLoadDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, resourceLoadDelayInfo.ResourceKey.ToString(), resourceLoadDelayInfo.ResourceLoad.ToString(), budgetTypeSetting.MaxDelayedThreads); } else { result = Strings.MicroDelayNotEnforcedMaxThreadsExceeded((int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, budgetTypeSetting.MaxDelayedThreads); } } else { CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.ThrottlingDelay, info.DelayedAmount.TotalMilliseconds); if (info.DelayInfo is UserQuotaDelayInfo) { UserQuotaDelayInfo userQuotaDelayInfo2 = info.DelayInfo as UserQuotaDelayInfo; result = Strings.UserQuotaDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, userQuotaDelayInfo2.OverBudgetException.PolicyPart, info.NotEnforcedReason); } else if (info.DelayInfo is ResourceLoadDelayInfo) { ResourceLoadDelayInfo resourceLoadDelayInfo2 = info.DelayInfo as ResourceLoadDelayInfo; result = Strings.ResourceLoadDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, resourceLoadDelayInfo2.ResourceKey.ToString(), resourceLoadDelayInfo2.ResourceLoad.ToString(), info.NotEnforcedReason); } else { result = Strings.MicroDelayInfo((int)info.DelayedAmount.TotalMilliseconds, info.Enforced, (int)info.DelayInfo.Delay.TotalMilliseconds, info.DelayInfo.Required, info.NotEnforcedReason); } } } return(result); }
private static PolicyData GetDefaultPolicySetting(ADUser user, IBudget budget) { PolicyData result = null; try { result = MobilePolicySettingsHelper.LoadDefaultPolicySetting(MobilePolicySettingsHelper.CreateScopedADSession(user, budget), user); } catch (ADTransientException arg) { ExTraceGlobals.FrameworkTracer.TraceError <string, ADTransientException>(0L, "MobilePolicySettingsHelper.GetDefaultPolicySetting -- AD lookup returned transient error for user \"{0}\": {1}", user.Alias, arg); } return(result); }
private static PolicyData GetPolicyData(ADUser user, IBudget budget) { PolicyData policyData = null; if (user.ActiveSyncMailboxPolicy != null) { policyData = MobilePolicySettingsHelper.GetPolicySetting(user, budget); } if (policyData == null) { policyData = MobilePolicySettingsHelper.GetDefaultPolicySetting(user, budget); } return(policyData); }
private void ProcessXsoEventAvailable(NotificationManager.AsyncEvent evt, IBudget budget) { Interlocked.Increment(ref this.totalXsoEvents); this.EnqueueDiagOperation(NotificationManager.DiagnosticEvent.XsoEvent, new EventType?(evt.Event.EventType), new EventObjectType?(evt.Event.ObjectType), null); if (this.command == null) { AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ThreadingTracer, this, "XSO event available for {0}, but command is not available. Calling Kill", this.uniqueId); this.Kill(); return; } budget.CheckOverBudget(); this.command.Consume(evt.Event); AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ThreadingTracer, this, "XSO event available for {0}. calling Command.Consume", this.uniqueId); }
public static void TraceMicroDelays(IBudget budget, TimeSpan workAccomplished, TimeSpan microDelay) { StandardBudgetWrapper standardBudgetWrapper = budget as StandardBudgetWrapper; if (standardBudgetWrapper != null) { int num = (int)standardBudgetWrapper.GetInnerBudget().CasTokenBucket.GetBalance(); ExTraceGlobals.BudgetDelayTracer.TraceDebug(0L, "Budget: '{0}', Balance: {1}, Work Done: {2}, MicroDelay: {3}", new object[] { budget.Owner, num, workAccomplished, microDelay }); } }
// Token: 0x06000372 RID: 882 RVA: 0x00015B9C File Offset: 0x00013D9C internal override UserResponse CreateResponse(IBudget budget) { UserResponse result; if (!string.IsNullOrEmpty(this.RedirectServer)) { ExTraceGlobals.FrameworkTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Creating response using redirect url {0} for {1}.", this.RedirectServer, this.userResultMapping.Mailbox); result = this.CreateRedirectResponse(); } else { ExTraceGlobals.FrameworkTracer.TraceDebug <string>((long)this.GetHashCode(), "MServer didn't find {0}. Creating invalid user response.", this.userResultMapping.Mailbox); result = base.CreateInvalidUserResponse(); } return(result); }
private void SelectLastRemainderOf(IBudget budget, BudgetWeek currentWeek) { if (view.CalculationResults.IsScrolledDown) { return; } var lastRemainder = budget.Remainders .OrderBy(r => r.Date) .LastOrDefault(); if (lastRemainder != null) { view.CalculationResults.SelectedItem = CreatePEBudgetRow(lastRemainder, "Остаток", r => { }, r => { }, ExplainReminder(budget, currentWeek), currentWeek, PEBudgetRow.Default); } }
internal static string GetElcRootUrl(IBudget budget) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.FullyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 362, "GetElcRootUrl", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdFolderReader.cs"); if (budget != null) { tenantOrTopologyConfigurationSession.SessionSettings.AccountingObject = budget; } Organization organization = tenantOrTopologyConfigurationSession.FindSingletonConfigurationObject <Organization>(); if (!string.IsNullOrEmpty(organization.ManagedFolderHomepage)) { return(organization.ManagedFolderHomepage); } return(null); }
private void ProcessTimeout(IBudget budget) { Interlocked.Increment(ref this.totalTimeouts); this.EnqueueDiagOperation(NotificationManager.DiagnosticEvent.HBTimeout); if (ExDateTime.UtcNow.CompareTo(this.lastTargetTime) >= 0) { if (this.command != null) { AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ThreadingTracer, this, "Timed out for {0}. calling command.HeartbeatCallback", this.uniqueId); budget.CheckOverBudget(); this.command.HeartbeatCallback(); return; } this.Kill(); AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ThreadingTracer, this, "Timed out and killing {0}", this.uniqueId); } }
// Token: 0x0600035F RID: 863 RVA: 0x0001573C File Offset: 0x0001393C protected override void AddToQueryList(UserResultMapping userResultMapping, IBudget budget) { OrganizationId organizationId; if (!base.TryGetOrganizationId(userResultMapping, out organizationId)) { ExTraceGlobals.FrameworkTracer.TraceDebug <string>((long)this.GetHashCode(), "Mailbox '{0}' org Id was not found, possibly in other forest.", userResultMapping.Mailbox); base.SetInvalidSmtpAddressResult(userResultMapping); return; } if (organizationId.Equals(this.partnerUser.OrganizationId)) { base.AddToADQueryList(userResultMapping, this.partnerUser.OrganizationId, null, budget); return; } ExTraceGlobals.FrameworkTracer.TraceDebug <string, OrganizationId, string>((long)this.GetHashCode(), "Mailbox '{0}' has different org id {1}. The identity is {1}.", userResultMapping.Mailbox, organizationId, this.partnerUser.Name); base.SetInvalidSmtpAddressResult(userResultMapping); }
internal void Run() { ConsoleHelper.WriteSpacedLine("Enter Budget FilePath (including filename)"); IBudget budget = JsonBudget.LoadBudget(Console.ReadLine()); TimePeriodEnum summaryPeriod = ConsoleHelper.GetEnumValueFromConsoleInput <TimePeriodEnum>("Select Summary TimePeriod: "); DateTime endDate; if (ConsoleHelper.GetBooleanInput("From Current Date?")) { endDate = DateTime.Today; } else { endDate = ConsoleHelper.GetDateInput("Enter the last date of the period to summarise"); } BudgetSummariser summariser = new BudgetSummariser(budget, summaryPeriod, endDate); OutputSummary(summariser.BuildSummary()); }
internal static List <ELCFolder> GetAllFolders(bool orgFoldersOnly, IBudget budget) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 123, "GetAllFolders", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdFolderReader.cs"); if (budget != null) { tenantOrTopologyConfigurationSession.SessionSettings.AccountingObject = budget; } QueryFilter filter = null; if (orgFoldersOnly) { filter = new ComparisonFilter(ComparisonOperator.Equal, ELCFolderSchema.FolderType, ElcFolderType.ManagedCustomFolder); } ADPagedReader <ELCFolder> elcFolders = tenantOrTopologyConfigurationSession.FindPaged <ELCFolder>(tenantOrTopologyConfigurationSession.GetOrgContainerId(), QueryScope.SubTree, filter, null, 0); AdReader.Tracer.TraceDebug(0L, "Found ELCFolders in the AD."); List <ELCFolder> list = new List <ELCFolder>(); AdFolderReader.ExtractTheGoodFolders(elcFolders, list); return(list); }
public void addToCurrent(IBudget b) { iterator.CurrentBudget.addSub(b); iterator.ChildCount++; iterator.CurrentBudget.Amount += b.Amount; Stack <int> sequence = new Stack <int> { }; sequence.Push(iterator.ChildCount - 1); while (iterator.goToParent()) { sequence.Push(iterator.CurrentBudget.PositionInParent); iterator.CurrentBudget.Amount += b.Amount; } for (int i = 0; i < sequence.Count; i++) { iterator.goToChild(sequence.Pop()); } }
internal MailTipsLocalQuery(ClientContext clientContext, DateTime deadline, IBudget callerBudget) : base(clientContext, deadline) { this.callerBudget = callerBudget; }
public virtual ISearchPolicy GetSearchPolicy(IRecipientSession recipientSession, CallerInfo callerInfo, ExchangeRunspaceConfiguration runspaceConfiguration, IBudget budget = null) { Recorder.Trace(2L, TraceType.InfoTrace, "SearchFactory.GetSearchPolicy"); return(new SearchPolicy(recipientSession, callerInfo, runspaceConfiguration, budget)); }
internal OptInFolders(ExchangePrincipal mailboxToAccess, string accessingUser, ClientSecurityContext clientSecurityContext, IBudget ewsBudget) { if (clientSecurityContext == null) { throw new ArgumentNullException("clientSecurityContext"); } if (accessingUser == null) { throw new ArgumentNullException("accessingUser"); } if (mailboxToAccess == null) { throw new ArgumentNullException("mailboxToAccess"); } this.clientSecurityContext = clientSecurityContext; this.accessingUser = accessingUser; this.mailboxToAccess = mailboxToAccess; this.budget = ewsBudget; }
internal OptInFolders(ExchangePrincipal mailboxToAccess, string accessingUser, WindowsPrincipal accessingPrincipal, IBudget ewsBudget) { if (accessingPrincipal == null) { throw new ArgumentNullException("accessingPrincipal"); } if (accessingUser == null) { throw new ArgumentNullException("accessingUser"); } if (mailboxToAccess == null) { throw new ArgumentNullException("mailboxToAccess"); } this.accessingPrincipal = accessingPrincipal; this.accessingUser = accessingUser; this.mailboxToAccess = mailboxToAccess; this.budget = ewsBudget; }
public TransactionService(ApplicationDbContext context, IBudget budgetSevice, IHttpContextAccessor httpContextAccessor) { this.context = context; this.budgetSevice = budgetSevice; this.httpContextAccessor = httpContextAccessor; }
public Budget(IBudget budget) { }
public BudgetSummariser(IBudget budget, TimePeriodEnum period, DateTime endDate) { Budget = budget; Period = period; EndDate = endDate; }
// Token: 0x06000368 RID: 872 RVA: 0x00015A14 File Offset: 0x00013C14 protected override void AddToQueryList(UserResultMapping userResultMapping, IBudget budget) { base.AddToADQueryList(userResultMapping, OrganizationId.ForestWideOrgId, null, budget); }
// Token: 0x06000325 RID: 805 internal abstract UserResponse CreateResponse(IBudget budget);
public SubscriptionLoader(ADUser adUser, IBudget requesterBudget) { this.adUser = adUser; this.requesterBudget = requesterBudget; }
public TeamMailboxSyncResourceMonitor(ResourceKey[] resourcesToAccess, IBudget ibudget) { this.resourcesToAccess = resourcesToAccess; this.ibudget = ibudget; }
protected override void InternalValidate() { MailboxIdParameter mailboxIdParameter = null; try { base.InternalValidate(); } catch (ManagementObjectNotFoundException) { if (this.Identity == null || !this.TryGetMailboxIdFromIdentity(this.Identity.ToString(), out mailboxIdParameter)) { throw; } this.deviceExistsinAD = false; } if (base.HasErrors) { return; } if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings)) { ADObjectId adobjectId; if (!base.TryGetExecutingUserId(out adobjectId)) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } if (!base.DataObject.Id.Parent.Parent.Equals(adobjectId) || (mailboxIdParameter != null && !mailboxIdParameter.Equals(adobjectId))) { base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null); } } Exception ex = null; if (mailboxIdParameter == null) { mailboxIdParameter = this.Identity.GetMailboxId(); } if (mailboxIdParameter == null && base.DataObject != null) { this.Identity = new MobileDeviceIdParameter(base.DataObject); mailboxIdParameter = this.Identity.GetMailboxId(); } if (mailboxIdParameter == null) { base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null); } this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, this.CreateTenantGlobalCatalogSession(base.SessionSettings), mailboxIdParameter, "Remove-MobileDevice", out ex); if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidArgument, null); } if (DeviceInfo.IsThrottlingLimitsExceeded((IConfigurationSession)base.DataSession, this.principal, out this.activeSyncDevices)) { uint maxDeviceDeleteCount = 0U; using (IBudget budget = StandardBudget.Acquire(this.principal.Sid, BudgetType.Eas, this.principal.MailboxInfo.OrganizationId.ToADSessionSettings())) { IThrottlingPolicy throttlingPolicy = budget.ThrottlingPolicy; maxDeviceDeleteCount = throttlingPolicy.EasMaxDeviceDeletesPerMonth.Value; } base.WriteError(new LocalizedException(Strings.MaxDeviceDeletesPerMonthReached(this.activeSyncDevices.ObjectsDeletedThisPeriod, maxDeviceDeleteCount)), ErrorCategory.WriteError, null); } }
public BudgetController(IBudget b) { budget = b; }