public bool canPeriodicityModify(PeriodName periodicity) { try { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var request = new RestRequest(ResourcePath + "/modify", Method.POST); request.RequestFormat = DataFormat.Json; string json = serializer.Serialize(periodicity); request.AddParameter("application/json", json, ParameterType.RequestBody); RestResponse queryResult = (RestResponse)RestClient.Execute(request); try { bool canModify = RestSharp.SimpleJson.DeserializeObject <bool>(queryResult.Content); return(canModify); } catch (Exception e) { throw new BcephalException("Unable to verify periodicity change ", e); } } catch (Exception e) { throw new BcephalException("Unable to verify periodicity change ", e); } }
/// <summary> /// Cette méthode permet de désactiver un menuItem dans le cas /// où l'opération associée à ce menuItem n'est pas possible pour /// le noeud courant. /// </summary> /// <param name="e"></param> protected override void OnContextMenuOpening(ContextMenuEventArgs e) { GetSelectedPeriod(); PeriodName selectedItem = GetSelectedPeriod(); if (selectedPeriodNames.Count > 0 && selectedItem == null) { selectedItem = selectedPeriodNames.Keys.Last(); } if (Root != null) { this.tree.ContextMenu.Visibility = System.Windows.Visibility.Visible; this.newMenuItem.IsEnabled = this.Root != null && selectedItem != defaultValue && selectedPeriodNames.Count <= 1; this.cutMenuItem.IsEnabled = this.Root != null && selectedItem != null && selectedItem.parent != null && selectedItem != defaultValue && isContiguousList(); this.copyMenuItem.IsEnabled = this.Root != null && selectedItem != null && selectedItem.parent != null && selectedItem != defaultValue && isContiguousList(); this.pasteMenuItem.IsEnabled = this.Root != null && !Kernel.Util.ClipbordUtil.IsClipBoardEmptyPeriodName() && selectedItem != defaultValue && isContiguousList(); this.deleteMenuItem.IsEnabled = this.Root != null && selectedItem != null && selectedItem.parent != null && selectedItem != defaultValue && isContiguousList(); this.moveUpMenuItem.IsEnabled = this.Root != null && selectedItem != null && selectedItem != defaultValue && CanMoveUp; this.moveDownMenuItem.IsEnabled = this.Root != null && selectedItem != null && selectedItem != defaultValue && CanMoveDown; this.propertiesMenuItem.IsEnabled = selectedItem != null && selectedItem != defaultValue; } else { this.tree.ContextMenu.Visibility = System.Windows.Visibility.Collapsed; } }
private PeriodName AddPeriodName(string name, byte subPeriodCount, bool isLocal, out string error) { var calendar = new PeriodName { Name = MsgUtils.Instance.Trls("Accural Period") + " " + name, StartDate = DateTime.Today, EndDate = new DateTime(2999, 1, 1), IsLocal = isLocal, CompanyId = isLocal ? CompanyId : (int?)null, PeriodLength = 1, SubPeriodCount = subPeriodCount, CreatedUser = UserName, CreatedTime = DateTime.Now, SingleYear = true }; var periodNames = _hrUnitOfWork.Repository <PeriodName>().Where(p => p.Name.StartsWith(calendar.Name)).Select(p => p.Name).ToList(); string pname = null; if (periodNames.Count > 0) { pname = periodNames.Where(p => p == calendar.Name).FirstOrDefault(); while (pname != null) { calendar.Name += "1"; pname = periodNames.Where(p => p == calendar.Name).FirstOrDefault(); } } _hrUnitOfWork.BudgetRepository.Add(calendar); error = _hrUnitOfWork.BudgetRepository.GenerateAccuralPeriods(calendar, UserName, Language); return(calendar); }
/// <summary> /// Affiche le contenu de la PeriodName /// </summary> /// <param name="root"></param> public void DisplayRoot(PeriodName root) { this.Root = root; if (this.Root == null) { this.tree.ItemsSource = null; } else { RefreshParent(this.Root); if (this.Root.GetChildByName(defaultValue.name) == null) { this.Root.AddChild(defaultValue); } this.tree.ItemsSource = this.Root.GetItems(); if (this.Root.childrenListChangeHandler.Items.Count > 0) { this.Root.childrenListChangeHandler.Items[0].IsSelected = true; } else { SetSelectedPeriod(defaultValue); } } }
public void be_equatable() { var id1 = PeriodId.From(2, 2019); var id2 = PeriodId.From(PeriodName.From(2, 2019)); id1.Should().Be(id2); }
public void AddPeriod(PeriodName periodName) { if (!_allPeriods.ContainsKey(periodName)) { _allPeriods.Add(periodName, new PeriodBalance(0, "")); } }
protected virtual void onSelectPeriodNameFromSidebar(object sender) { if (sender == null) { return; } if (sender is PeriodName) { PeriodName periodName = (PeriodName)sender; ReconciliationFilterTemplateEditorItem page = (ReconciliationFilterTemplateEditorItem)getReconciliationFilterTemplateEditor().getActivePage(); if (page == null) { return; } page.getReconciliationFilterTemplateForm().setPeriodName(periodName); } else if (sender is PeriodInterval) { PeriodInterval periodInterval = (PeriodInterval)sender; ReconciliationFilterTemplateEditorItem page = (ReconciliationFilterTemplateEditorItem)getReconciliationFilterTemplateEditor().getActivePage(); if (page == null) { return; } page.getReconciliationFilterTemplateForm().setPeriodInterval(periodInterval); } }
/// <summary> /// Remove default nodes from root /// </summary> protected virtual void ForgetDefaultItems(Persistent parent) { if (parent != null) { if (parent is PeriodName) { PeriodName period = (PeriodName)parent; foreach (PeriodInterval interval in period.intervalListChangeHandler.Items.ToArray()) { if (interval.IsDefault) { period.intervalListChangeHandler.Items.Remove(interval); } } } else if (parent is PeriodInterval) { PeriodInterval interval = (PeriodInterval)parent; foreach (PeriodInterval child in interval.childrenListChangeHandler.Items.ToArray()) { if (child.IsDefault) { interval.childrenListChangeHandler.Items.Remove(child); } } } } }
/// <summary> /// Add default nodes /// </summary> /// <param name="parent"></param> protected virtual void AddDefaultItems(Persistent parent) { if (parent == null || parent.IsDefault) { return; } if (parent.isCompleted && parent.HasMoreElements()) { PeriodInterval showMore = new PeriodInterval(); showMore.IsShowMoreItem = true; showMore.name = SHOW_MORE_LABEL; if (parent is PeriodName) { PeriodName period = (PeriodName)parent; showMore.periodName = period; period.intervalListChangeHandler.Items.Add(showMore); } else if (parent is PeriodInterval) { PeriodInterval interval = (PeriodInterval)parent; showMore.parent = interval; interval.childrenListChangeHandler.Items.Add(showMore); } } }
public void return_an_incremnte_of_itself(int prevMonth, int prevYear, int nextMonth, int nextYear) { var periodName = PeriodName.From(prevMonth, prevYear); var next = periodName.GetIncrement(); next.Should().Be(PeriodName.From(nextMonth, nextYear)); }
/// <summary> /// Selectionne une mesure dans l'arbre /// </summary> /// <param name="attribute">La mesure à sélectionner</param> public void SetSelectedPeriod(PeriodName period) { if (period != null) { if (period.parent != null) { period.parent.IsExpanded = true; } period.IsSelected = true; } else { PeriodName selection = GetSelectedPeriod() == null?GetSelectedMultiPeriod() : GetSelectedPeriod(); if (selection != null) { selection.IsSelected = false; } } try { tree.Focus(); } catch (Exception) { } }
/// <summary> /// Cette méthode est appélée lorsque l'utilisateur clique sur le menu "New". /// Elle permet de créer un nouveau noeud dans l'abre. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnNewNode(object sender, RoutedEventArgs e) { PeriodName parent = null; PeriodName period = addDefaultNode(parent); removeCTRLSelection(); }
public static List <PeriodInterval> buildYearPeriods(PeriodName periodName) { List <PeriodInterval> periods = new List <PeriodInterval>(0); int fromYear = periodName.periodFromTime.Year; int toYear = periodName.periodToTime.Year; int position = 0; DateTime to = periodName.periodToTime; DateTime from = periodName.periodFromTime; while (from <= to) { position++; string name = "YEAR " + from.Year.ToString(); int months = from.Month; int monthToAdd = 12 * periodName.incrementationCount; DateTime localto = from.AddMonths(monthToAdd).AddDays(-1); if (localto > to) { localto = to; } periods.Add(new PeriodInterval(position, name, from, localto)); if (fromYear == toYear) { break; } from = localto.AddDays(1); } return(periods); }
public void be_created_from_periodName() { var periodName = PeriodName.From(1, 2018); var periodId = PeriodId.From(periodName); periodId.Value.Should().Be("2018-01"); }
/// <summary> /// Ajoute un nouveau noeud fils au noeud passé en paramètre. /// </summary> /// <param name="parent">Le noeud auquel il fau ajouter un fils</param> /// <param name="name">le nom du noeud</param> /// <returns>Le nouveau noed créé</returns> public virtual PeriodName AddNode(PeriodName parent, string name = "") { PeriodName child = GetNewTreeViewModel(); if (name != "") { child.name = name; } if (parent != null) { parent.AddChild(child); parent.UpdateParents(); } else { if (this.Root != null) { this.Root.AddChild(child); this.Root.SwichtPosition(defaultValue, child); } else { return(null); } } SetSelectedPeriod(defaultValue); if (Changed != null) { Changed(); } return(child); }
private void OnOkButtonClick(object sender, RoutedEventArgs e) { if (this.periodName == null) { this.periodName = new PeriodName(); } DateTime?from = this.fromDateBox.SelectedDate; DateTime?to = this.toDateBox.SelectedDate; if (from == null || to == null) { return; } if (!ValidateEdition()) { return; } PeriodName item = new PeriodName(); FillObject(item); BuildPeriods(item); this.periodName.Update(item); if (OnValidateChange != null) { OnValidateChange(this.periodName, true); } this.Close(); }
public void Create_new_period() { var periodCreator = new PeriodCreator(History.Empty); var period = periodCreator.Create(PeriodName.From(3, 2019)); period.PeriodName.Should().Be(PeriodName.From(3, 2019)); }
private void RefreshPeriodsGrid() { periodGrid.ItemsSource = null; if (this.periodName == null) { return; } PeriodName item = new PeriodName(); FillObject(item); if (!canBuildPeriodsGrid()) { noResultLabel.Visibility = System.Windows.Visibility.Visible; periodGrid.Visibility = System.Windows.Visibility.Collapsed; return; } if (!periodGridExpander.IsExpanded) { return; } noResultLabel.Visibility = System.Windows.Visibility.Collapsed; periodGrid.Visibility = System.Windows.Visibility.Visible; BuildPeriods(item); periodGrid.ItemsSource = item.GetRootPeriodInterval().Leafs; }
public void FillObject(PeriodName periodName) { periodName.name = this.periodNameTextBox.Text.Trim(); periodName.curentIntervalGroupName = this.standardPeriodNameTextBox.Text.Trim(); periodName.granularity = GetGranularity(); periodName.incrementationCount = GetPeriodIncrement(); periodName.showYear = this.showYear.IsChecked.Value; periodName.showMonth = this.showMonth.IsChecked.Value; periodName.showWeek = this.showWeek.IsChecked.Value; periodName.showDay = this.showDay.IsChecked.Value; if (this.fromDateBox.SelectedDate.HasValue) { periodName.periodFromTime = this.fromDateBox.SelectedDate.Value; } else { periodName.periodFrom = null; } if (this.toDateBox.SelectedDate.HasValue) { periodName.periodToTime = this.toDateBox.SelectedDate.Value; } else { periodName.periodTo = null; } periodName.incrementationCount = GetPeriodIncrement(); }
protected void onDoubleClickSelectPeriodNameFromSidebar(object sender) { if (sender != null) { if (sender is PeriodName) { PeriodName periodName = (PeriodName)sender; if (periodName.intervalListChangeHandler.Items.Count <= 0) { SetValue(sender); } else { SetValue(periodName.intervalListChangeHandler.Items); } } else if (sender is PeriodInterval) { PeriodInterval periodInterval = (PeriodInterval)sender; if (periodInterval.IsLeaf) { SetValue(sender); } else { SetValue(periodInterval.childrenListChangeHandler.Items); } } } }
private void BuildPeriods(PeriodName item) { if (item == null) { return; } item.GetRootPeriodInterval().childrenListChangeHandler.originalList = PeriodNameUtil.buildIntervals(item); }
public void Not_be_equatable_for_different_period_name(int month, int year) { var period1 = PeriodName.From(month, year); var period2 = PeriodName.From(month + 1, year + 1); period1.Should().NotBe(period2); (period1 != period2).Should().BeTrue(); }
private void OnEnterEditMode(object sender, EO.Wpf.EditItemEventArgs e) { if (e.Item is PeriodName) { PeriodName period = (PeriodName)e.Item; e.Text = period.name; } }
public void raise_period_created_when_create_period() { var period = Some.Period(); period.UncommittedEvents.GetStream() .Should().HaveCount(1).And .ContainEquivalentOf(new PeriodCreated(PeriodName.From(3, 2019)), e => e.Excluding(a => a.AggregateId)); }
public void Remove(PeriodName calendar) { if (Context.Entry(calendar).State == EntityState.Detached) { context.PeriodNames.Attach(calendar); } context.PeriodNames.Remove(calendar); }
public void setPeriodName(PeriodName periodName) { PeriodNameTextBox.Text = periodName.name; if (this.OnSetPeriod != null) { OnSetPeriod(periodName.name); } }
private void OnShowPeriodIntervalParams(object sender, RequestNavigateEventArgs e) { editedPeriodName = this.periodTree.GetSelectedValue(); if (!editedPeriodName.name.Equals(PeriodNameTreeView.Label_DEFAULT_PERIOD) && sender is Hyperlink) { showStandartPeriodEditor(); } }
public void Throw_error_if_create_period_that_already_exists() { var periodCreator = Some.PeriodCreator(e => e.WithEvent(Some.PeriodCreated(PeriodName.From(3, 2019)))); Action action = () => periodCreator.Create(PeriodName.From(3, 2019)); action.Should().Throw <PeriodAlreadyExistsException>(); }
/// <summary> /// /// </summary> /// <returns>La mesure sélectionnée dans le cas de multiselection mode</returns> public PeriodName GetSelectedMultiPeriod() { PeriodName period = null; period = this.tree.SelectedItem != null ? this.tree.SelectedItem as PeriodName : (this.tree.SelectedItem == null && this.tree.SelectedValue != null && this.tree.SelectedValue != defaultValue ? (this.tree.SelectedValue as PeriodName) : null); return(period); }
public void Throw_error_if_create_same_period_twice() { var periodCreator = Some.PeriodCreator(); periodCreator.Create(PeriodName.From(3, 2019)); Action action = () => periodCreator.Create(PeriodName.From(3, 2019)); action.Should().Throw <PeriodAlreadyExistsException>(); }