Пример #1
0
 public void RaisePendingChangesEvent()
 {
     PendingChanges?.Invoke(this, new PendingChangesEventArgs()
     {
         Changes = NumberOfPendingChanges
     });
 }
        protected override void ExcludeItems(string projectFile, string[] itemNames)
        {
            List <string> changed = null;

            foreach (string item in itemNames)
            {
                if (!IsSafeSccPath(item))
                {
                    continue;
                }

                string path = SvnTools.GetNormalizedFullPath(item);

                if (!ProjectMap.IsSccExcluded(path))
                {
                    ProjectMap.SccExclude(path);

                    if (changed == null)
                    {
                        changed = new List <string>();
                    }
                    changed.Add(path);

                    StatusCache.SetSolutionContained(path, ProjectMap.ContainsFile(path), true);
                }
            }

            if (changed != null)
            {
                PendingChanges.Refresh(changed);
            }
        }
Пример #3
0
        public void the_result_is_fifteen()
        {
            var addedEvent = (NumberAddedEvent)PendingChanges.Single();

            Assert.That(addedEvent.Id, Is.EqualTo(this.id));
            Assert.That(addedEvent.NewValue, Is.EqualTo(15));
        }
Пример #4
0
        public void SubmitInputChange(int frame, string button, bool value)
        {
            if (Engaged())
            {
                if (frame >= 0)
                {
                    PendingChanges newChange = default;

                    if (frame < Tastudio.CurrentTasMovie.InputLogLength)
                    {
                        if (Tastudio.CurrentTasMovie.BoolIsPressed(frame, button) != value)                         //Check if the button state is not already in the state the user set in the lua script
                        {
                            newChange.Type      = LuaChangeTypes.InputChange;
                            newChange.InputType = InputChangeTypes.Bool;
                            newChange.Frame     = frame;
                            newChange.Button    = button;
                            newChange.ValueBool = value;

                            _changeList.Add(newChange);
                        }
                    }
                    else
                    {
                        newChange.Type      = LuaChangeTypes.InputChange;
                        newChange.InputType = InputChangeTypes.Bool;
                        newChange.Frame     = frame;
                        newChange.Button    = button;
                        newChange.ValueBool = value;

                        _changeList.Add(newChange);
                    }
                }
            }
        }
        protected override void UndoExcludeItems(string projectFile, string[] itemNames)
        {
            List <string> changed = null;

            foreach (string item in itemNames)
            {
                if (!IsSafeSccPath(item))
                {
                    continue;
                }

                string path = SvnTools.GetNormalizedFullPath(item);

                if (ProjectMap.SccRemoveExcluded(path))
                {
                    if (changed == null)
                    {
                        changed = new List <string>();
                    }
                    changed.Add(path);
                }
            }

            if (changed != null)
            {
                PendingChanges.Refresh(changed);
            }
        }
Пример #6
0
        private void OnlineModBuildAction(PendingChangeBase.PendingAction pendingAction)
        {
            if (_selectedOnlineMod == null)
            {
                MessageBox.Show("Please select a mod beforehand");
                return;
            }
            if (_selectedOnlineModReleaseIdx == -1)
            {
                MessageBox.Show("Please specify a release version.");
                return;
            }
            switch (pendingAction)
            {
            case PendingChangeBase.PendingAction.Download:
                PendingChanges.AddDownload(_selectedOnlineMod, _selectedOnlineModReleaseIdx, _localModManager.GetDownloadPath(_selectedOnlineMod, _selectedOnlineModReleaseIdx));
                break;

            case PendingChangeBase.PendingAction.Install:

                PendingChanges.AddDownload(_selectedOnlineMod, _selectedOnlineModReleaseIdx, _localModManager.GetDownloadPath(_selectedOnlineMod, _selectedOnlineModReleaseIdx));
                PendingChanges.AddInstall(_selectedOnlineMod, _localModManager.GetDownloadPath(_selectedOnlineMod, _selectedOnlineModReleaseIdx));
                break;

            case PendingChangeBase.PendingAction.Uninstall:
                PendingChanges.AddUninstall(_selectedOnlineMod);
                break;

            case PendingChangeBase.PendingAction.Update:
                PendingChanges.AddDownload(_selectedOnlineMod, _selectedOnlineModReleaseIdx, _localModManager.GetDownloadPath(_selectedOnlineMod, _selectedOnlineModReleaseIdx));
                PendingChanges.AddUninstall(_selectedOnlineMod);
                PendingChanges.AddInstall(_selectedOnlineMod, _localModManager.GetDownloadPath(_selectedOnlineMod, _selectedOnlineModReleaseIdx));
                break;
            }
        }
Пример #7
0
        private static void GetPendingChanges()
        {
            if (!PendingChanges.Any())
            {
                return;
            }

            var changeSet = PendingChanges.Peek();

            if (changeSet != null)
            {
                var doc = SyncVersion.GetDocumentTypeByCod(changeSet);

                // show Progress
                var percent = Convert.ToInt32(((double)index++ / (double)changesetsCount) * 100);

                ShowProgress(string.Format("{0}% {1}", percent, doc.DocumentName));

                if (doc != null)
                {
                    DoSync(doc, changeSet);
                    PendingChanges.Pop();
                }
                else
                {
                    //TODO handle null Documents locally.
                    PendingChanges.Pop();
                }
            }

            if (PendingChanges.Any())
            {
                GetPendingChanges();
            }
        }
Пример #8
0
        public void SubmitAnalogChange(int frame, string button, float value)
        {
            if (Engaged())
            {
                if (frame >= 0)
                {
                    PendingChanges newChange = new PendingChanges();

                    if (frame < Tastudio.CurrentTasMovie.InputLogLength)
                    {
                        if (Tastudio.CurrentTasMovie.GetFloatState(frame, button) != value)                         // Check if the button state is not already in the state the user set in the lua script
                        {
                            newChange.Type       = LuaChangeTypes.InputChange;
                            newChange.InputType  = InputChangeTypes.Float;
                            newChange.Frame      = frame;
                            newChange.Button     = button;
                            newChange.ValueFloat = value;

                            _changeList.Add(newChange);
                        }
                    }
                    else
                    {
                        newChange.Type       = LuaChangeTypes.InputChange;
                        newChange.InputType  = InputChangeTypes.Float;
                        newChange.Frame      = frame;
                        newChange.Button     = button;
                        newChange.ValueFloat = value;

                        _changeList.Add(newChange);
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Handles the Elapsed event of the PendingChangesTimer control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Timers.ElapsedEventArgs"/> instance containing the event data.</param>
        public void PendingChangesTimerElapsed(object sender, ElapsedEventArgs e)
        {
            if (PendingChanges.Count == 0)
            {
                return;
            }

            var changes = PendingChanges.ToList();

            PendingChanges.Clear();

            if (File.Exists(_pendingDataPath))
            {
                try { File.Delete(_pendingDataPath); }
                catch { }
            }

            var req = Remote.API.SendDatabaseChanges(changes, _user, _pass);

            if (!req.Success || !req.OK)
            {
                PendingChanges.AddRange(changes);
                PendingChangesTimer.Start();
                SavePendingChanges();
            }
        }
Пример #10
0
        private void PopulateSelectedPendingChangesSummary()
        {
            if (_backgroundFunctionPreventDataUpdate)
            {
                return;
            }

            this.Logger().Trace("PopulateSelectedPendingChangesSummary");

            if (PendingChanges.Count == 0)
            {
                PendingChangesSummary = CollectionSelectionSummaryEnum.None;
                return;
            }

            var includedCount = PendingChanges.Count(model => model.IncludeChange);

            if (includedCount == 0)
            {
                PendingChangesSummary = CollectionSelectionSummaryEnum.None;
                return;
            }

            PendingChangesSummary = PendingChanges.Count == includedCount
                                        ? CollectionSelectionSummaryEnum.All
                                        : CollectionSelectionSummaryEnum.Some;
        }
Пример #11
0
        public void SubmitAnalogChange(int frame, [LuaASCIIStringParam] string button, float value)
        {
            if (Engaged())
            {
                if (frame >= 0)
                {
                    PendingChanges newChange = default;

                    if (frame < Tastudio.CurrentTasMovie.InputLogLength)
                    {
                        if (Tastudio.CurrentTasMovie.GetAxisState(frame, button) != (int)value)                          // Check if the button state is not already in the state the user set in the lua script
                        {
                            newChange.Type      = LuaChangeTypes.InputChange;
                            newChange.InputType = InputChangeTypes.Axis;
                            newChange.Frame     = frame;
                            newChange.Button    = button;
                            newChange.ValueAxis = (int)value;

                            _changeList.Add(newChange);
                        }
                    }
                    else
                    {
                        newChange.Type      = LuaChangeTypes.InputChange;
                        newChange.InputType = InputChangeTypes.Axis;
                        newChange.Frame     = frame;
                        newChange.Button    = button;
                        newChange.ValueAxis = (int)value;

                        _changeList.Add(newChange);
                    }
                }
            }
        }
Пример #12
0
        private async Task applyProjectionsAsync(CancellationToken token)
        {
            var projections = _schema.Events.As <IProjections>();

            foreach (var projection in projections.Inlines)
            {
                await projection.ApplyAsync(this, PendingChanges.Streams().ToArray(), token).ConfigureAwait(false);
            }
        }
Пример #13
0
        private void applyProjections()
        {
            var eventPage = new EventPage(PendingChanges.Streams().ToArray());

            foreach (var projection in _store.Events.InlineProjections)
            {
                projection.Apply(this, eventPage);
            }
        }
Пример #14
0
        private void applyProjections()
        {
            var streams = PendingChanges.Streams().ToArray();

            foreach (var projection in _schema.Events.InlineProjections)
            {
                projection.Apply(this, streams);
            }
        }
Пример #15
0
        private async Task applyProjectionsAsync(CancellationToken token)
        {
            var eventPage = new EventPage(PendingChanges.Streams().ToArray());

            foreach (var projection in _store.Events.InlineProjections)
            {
                await projection.ApplyAsync(this, eventPage, token).ConfigureAwait(false);
            }
        }
Пример #16
0
        private async Task applyProjectionsAsync(CancellationToken token)
        {
            var streams = PendingChanges.Streams().ToArray();

            foreach (var projection in _schema.Events.InlineProjections)
            {
                await projection.ApplyAsync(this, streams, token);
            }
        }
Пример #17
0
 /// <summary>
 /// Sends the specified change to the remote database.
 /// </summary>
 /// <param name="change">The object containing the changed information.</param>
 public void SendChange(ShowInfoChange change)
 {
     new Thread(() =>
     {
         var req = Remote.API.SendDatabaseChange(change, _user, _pass);
         if (!req.Success || !req.OK)
         {
             PendingChanges.Add(change);
             PendingChangesTimer.Start();
         }
     }).Start();
 }
Пример #18
0
        /// <inheritdoc />
        public IDisposable BeginChangeScope(Action afterSaveCallback = null)
        {
            if (afterSaveCallback != null)
            {
                _afterSaveCallbacks.Add(afterSaveCallback);
            }

            IDisposable scope;

            _pendingChanges.Push(scope = new PendingChanges(EndChangeScope));
            return(scope);
        }
Пример #19
0
        private void applyProjections()
        {
            var streams = PendingChanges.Streams().ToArray();

            if (streams.Length > 0)
            {
                var eventPage = new EventPage(streams);
                foreach (var projection in DocumentStore.Events.InlineProjections)
                {
                    projection.Apply(this, eventPage);
                }
            }
        }
Пример #20
0
        public void SubmitDeleteFrames(int frame, int number)
        {
            if (Engaged())
            {
                if (frame >= 0 && frame < Tastudio.CurrentTasMovie.InputLogLength && number > 0)
                {
                    PendingChanges newChange = new PendingChanges();

                    newChange.type   = LuaChangeTypes.DeleteFrames;
                    newChange.frame  = frame;
                    newChange.number = number;

                    changeList.Add(newChange);
                }
            }
        }
Пример #21
0
        //private static void SyncPoolingLoop()
        //{
        //    // Wait for Start Db Contxt
        //    Thread.Sleep(new TimeSpan(0,0,10));

        //    Thread.CurrentThread.Priority = ThreadPriority.Lowest;
        //    while (true)
        //    {
        //        // 5 min
        //        Thread.Sleep(TimeSpan.FromSeconds(5));

        //        CheckForUpdates();
        //    }
        //}



        //public static bool IsRunningSync { get; set; }


        #endregion

        //Procedimiento principal de sincronización
        public static void CheckForUpdates()
        {
            try
            {
                //lock (Extensions.SyncLock)
                //{
                //    PendingChanges.Clear();

                //    if (!WebApiClient.IsAvailableConnection) return;
                //    if (OnBeginSync != null) OnBeginSync();
                //    //Buscar los cambios pendientes en SAP
                //    var version = SyncVersion.GetLatestVersionByType();

                //    var changesets = WebApiClient.GetNewChangesets(version.Item1, version.Item2, Config.WhsCode).Result;

                //    // ORder By Version CHanges

                //    changesets = changesets.OrderByDescending(o => o.version).ToList();

                //    //Llenar pila con cambios
                //    changesets
                //    .Where(p=> PendingChanges.All(c => c.version != p.version))
                //    .ToList().ForEach(c => PendingChanges.Push(c));

                //    changesetsCount = PendingChanges.Count();
                //    index = 0;

                //    //Sincronizar
                //    GetPendingChanges();

                //    //UploadPendingChanges();

                //    if (onSyncComplete != null) onSyncComplete();
                //  }
            }
            catch (Exception ex)
            {
                if (onSyncComplete != null)
                {
                    onSyncComplete();
                }
                PendingChanges.Clear();
                throw ex;
            }
        }
        public void Unshelve()
        {
            Shelveset shelveset;
            bool      result;

            if (PendingChanges.All(model => model.IncludeChange))
            {
                result = teamPilgrimServiceModelProvider.TryWorkspaceUnshelve(WorkspaceServiceModel.Workspace, out shelveset, Shelveset.Name, Shelveset.OwnerName);
            }
            else
            {
                var itemSpecs = PendingChanges
                                .Where(model => model.IncludeChange)
                                .Select(model => new ItemSpec(model.Change))
                                .ToArray();

                result = teamPilgrimServiceModelProvider.TryWorkspaceUnshelve(WorkspaceServiceModel.Workspace, out shelveset,
                                                                              Shelveset.Name, Shelveset.OwnerName, itemSpecs);
            }

            if (result)
            {
                if (RestoreWorkItemsAndCheckinNotes)
                {
                    foreach (var workItemCheckinInfo in Shelveset.WorkItemInfo)
                    {
                        WorkspaceServiceModel.SelectWorkItemById(workItemCheckinInfo.WorkItem.Id);
                    }

                    foreach (var checkinNoteFieldValue in this.Shelveset.CheckinNote.Values)
                    {
                        WorkspaceServiceModel.RestoreCheckinNoteFieldValue(checkinNoteFieldValue);
                    }
                }

                if (!PreserveShelveset)
                {
                    teamPilgrimServiceModelProvider.TryDeleteShelveset(ProjectCollectionServiceModel.TfsTeamProjectCollection, shelveset.Name, shelveset.OwnerName);
                }
            }

            OnDismiss(result, true);
        }
        public void ThenTheExpectedChangeToApprenticeshipBannersShouldBeShown(
            PendingChanges pendingChanges,
            bool hasPendingChangeOfProviderRequest,
            Party pendingChangeOfProviderRequestWithParty,
            ChangeToApprenticeshipBanner expected)
        {
            //Arrange
            var viewModel = new ApprenticeshipDetailsRequestViewModel
            {
                PendingChanges = pendingChanges,
                HasPendingChangeOfProviderRequest       = hasPendingChangeOfProviderRequest,
                PendingChangeOfProviderRequestWithParty = pendingChangeOfProviderRequestWithParty
            };

            //Act
            var changeToApprenticeshipBanners = viewModel.GetChangeToApprenticeshipBanners();

            //Assert
            Assert.IsTrue(changeToApprenticeshipBanners.HasFlag(expected));
        }
        public void ThenTheExpectedActionRequiredBannersShouldBeShown(
            PendingChanges pendingChanges,
            bool hasPendingChangeOfProviderRequest,
            Party pendingChangeOfProviderRequestWithParty,
            bool pendingDataLockChange,
            bool pendingDataLockRestart,
            ActionRequiredBanner expected)
        {
            //Arrange
            var viewModel = new ApprenticeshipDetailsRequestViewModel
            {
                PendingChanges = pendingChanges,
                HasPendingChangeOfProviderRequest       = hasPendingChangeOfProviderRequest,
                PendingChangeOfProviderRequestWithParty = pendingChangeOfProviderRequestWithParty,
                PendingDataLockChange  = pendingDataLockChange,
                PendingDataLockRestart = pendingDataLockRestart
            };

            //Act
            var actionBanners = viewModel.GetActionRequiredBanners();

            //Assert
            Assert.IsTrue(actionBanners.HasFlag(expected));
        }
Пример #25
0
        /// <summary>
        /// Updates the conflicts.
        /// </summary>
        /// <remarks>Documented by CFI, 2011-01-08</remarks>
        private void UpdateConflicts()
        {
            objectListViewConflicts.SetObjects(null);

            if (PendingChanges.Count <= 0 || GetSelectedChanges().Count <= 0)
            {
                return;
            }

            CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Conflicts, PendingChanges.ToArray(),
                                                                                      GetSelectedChanges().ToArray(), textBoxComment.Text, GetCurrentCheckinNotes(), GetSelectedWorkItems());

            if (result.Conflicts.Length == 0)
            {
                labelConflicts.Text = "No Conflicts found";
            }
            else
            {
                labelConflicts.Text = result.Conflicts.Length < 2 ? "1 Conflict found" : result.Conflicts.Length + " Conflicts found";
                objectListViewConflicts.SetObjects(result.Conflicts);
            }
        }
Пример #26
0
        /// <summary>
        /// Updates the policy warnings.
        /// </summary>
        /// <remarks>Documented by CFI, 2011-01-08</remarks>
        private void UpdatePolicyWarnings()
        {
            List <object>        items   = new List <object>();
            List <PendingChange> changes = GetSelectedChanges();

            if (pendingChanges.Count > 0 && changes.Count > 0)
            {
                CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Policies,
                                                                                          PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, GetCurrentCheckinNotes(), GetSelectedWorkItems());
                if (result.PolicyEvaluationException != null || result.PolicyFailures.Length > 0)
                {
                    labelPolicyWarning.Text   = "The following check-in policies have not been satisfied";
                    pictureBoxWarning.Visible = true;

                    foreach (PolicyFailure failure in result.PolicyFailures)
                    {
                        if (failure.Message.Contains("CheckForComments.cs"))
                        {
                            if (string.IsNullOrEmpty(textBoxComment.Text))
                            {
                                items.Add("Please provide some comments about your check-in.");
                            }
                        }
                        else
                        {
                            items.Add(failure);
                        }
                    }
                    if (result.PolicyEvaluationException != null)
                    {
                        items.Add(result.PolicyEvaluationException);
                    }

                    objectListViewPolicyWarnings.SetObjects(items);
                }
                else
                {
                    labelPolicyWarning.Text   = "All check-in policies are satisfied";
                    pictureBoxWarning.Visible = false;
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Checks the in.
        /// </summary>
        /// <remarks>Documented by CFI, 2010-06-27</remarks>
        public void CheckIn()
        {
            foreach (ITabbedDocument document in PluginBase.MainForm.Documents)
            {
                if (document.IsModified)
                {
                    document.Save();
                }
            }

            List <PendingChange> changes = GetSelectedChanges();

            if (pendingChanges.Count <= 0 || changes.Count <= 0)
            {
                MessageBox.Show("Nothing to Check In!", "Nothing to Check In", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            CheckinNote note = GetCurrentCheckinNotes();

            WorkItemCheckinInfo[] workItemsArray = GetSelectedWorkItems();

            PolicyOverrideInfo policyInfo = null;

            CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Conflicts, PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, note, workItemsArray);

            if (result.Conflicts.Length > 0)
            {
                MessageBox.Show("Checkin cannot proceed because there are some conflicts.", "Conflict Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ShowConfilcts();

                return;
            }

            result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Notes, PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, note, workItemsArray);
            if (result.NoteFailures.Length > 0)
            {
                MessageBox.Show("Checkin cannot proceed because there are errors in the Check-in Notes.", "Check-in Notes Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ShowCheckInNotes();

                return;
            }

            result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Policies, PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, note, workItemsArray);
            if (result.PolicyEvaluationException != null || result.PolicyFailures.Length > 0)
            {
                string errors = string.Empty;
                foreach (PolicyFailure failure in result.PolicyFailures)
                {
                    if (failure.Message.Contains("CheckForComments.cs"))
                    {
                        if (string.IsNullOrEmpty(textBoxComment.Text))
                        {
                            errors += Environment.NewLine + " - " + "Please provide comments for your check-in.";
                        }
                    }
                    else
                    {
                        errors += Environment.NewLine + " - " + failure.Message;
                    }
                }
                if (result.PolicyEvaluationException != null)
                {
                    errors += Environment.NewLine + " - " + result.PolicyEvaluationException.Message;
                }

                if (errors != string.Empty)
                {
                    DialogResult boxResult = MessageBox.Show("Checkin cannot proceed because the policy requirements have not been satisfied." + Environment.NewLine + errors, "Policy Failure", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
                    if (boxResult == DialogResult.Abort)
                    {
                        ShowPolicyWarnings();
                        return;
                    }
                    else if (boxResult == DialogResult.Retry)
                    {
                        CheckIn();
                        return;
                    }
                }
            }

            Manager.CurrentWorkspace.CheckIn(changes.ToArray(), textBoxComment.Text, note, workItemsArray, policyInfo);
            CheckedInChanges = changes;

            textBoxComment.Text             = string.Empty;
            textBoxCodeReviewer.Text        = string.Empty;
            textBoxSecurityReviewer.Text    = string.Empty;
            textBoxPerformanceReviewer.Text = string.Empty;

            foreach (ITabbedDocument document in PluginBase.MainForm.Documents)
            {
                if (changes.FirstOrDefault(c => c.LocalItem == document.FileName) != null)
                {
                    document.Reload(false);
                }
            }

            UpdatePendingChanges();

            OnCheckedIn(EventArgs.Empty);
        }
Пример #28
0
        public async Task <ApprenticeshipDetailsRequestViewModel> Map(ApprenticeshipDetailsRequest source)
        {
            try
            {
                var apprenticeshipId = _encodingService.Decode(source.ApprenticeshipHashedId, EncodingType.ApprenticeshipId);

                var apprenticeshipTask        = _commitmentsApiClient.GetApprenticeship(apprenticeshipId, CancellationToken.None);
                var priceEpisodesTask         = _commitmentsApiClient.GetPriceEpisodes(apprenticeshipId, CancellationToken.None);
                var apprenticeshipUpdatesTask = _commitmentsApiClient.GetApprenticeshipUpdates(apprenticeshipId, new GetApprenticeshipUpdatesRequest()
                {
                    Status = ApprenticeshipUpdateStatus.Pending
                }, CancellationToken.None);
                var apprenticeshipDataLocksStatusTask = _commitmentsApiClient.GetApprenticeshipDatalocksStatus(apprenticeshipId, CancellationToken.None);
                var changeofPartyRequestsTask         = _commitmentsApiClient.GetChangeOfPartyRequests(apprenticeshipId, CancellationToken.None);
                var changeOfProviderChainTask         = _commitmentsApiClient.GetChangeOfProviderChain(apprenticeshipId, CancellationToken.None);

                await Task.WhenAll(apprenticeshipTask, priceEpisodesTask, apprenticeshipUpdatesTask, apprenticeshipDataLocksStatusTask, changeofPartyRequestsTask, changeOfProviderChainTask);

                var apprenticeship                = apprenticeshipTask.Result;
                var priceEpisodes                 = priceEpisodesTask.Result;
                var apprenticeshipUpdates         = apprenticeshipUpdatesTask.Result;
                var apprenticeshipDataLocksStatus = apprenticeshipDataLocksStatusTask.Result;
                var changeofPartyRequests         = changeofPartyRequestsTask.Result;
                var changeOfProviderChain         = changeOfProviderChainTask.Result;

                var currentTrainingProgramme = await GetTrainingProgramme(apprenticeship.CourseCode, apprenticeship.StandardUId);

                PendingChanges pendingChange = GetPendingChanges(apprenticeshipUpdates);

                bool dataLockCourseTriaged        = apprenticeshipDataLocksStatus.DataLocks.HasDataLockCourseTriaged();
                bool dataLockCourseChangedTraiged = apprenticeshipDataLocksStatus.DataLocks.HasDataLockCourseChangeTriaged();
                bool dataLockPriceTriaged         = apprenticeshipDataLocksStatus.DataLocks.HasDataLockPriceTriaged();

                bool enableEdit = EnableEdit(apprenticeship, pendingChange, dataLockCourseTriaged, dataLockCourseChangedTraiged, dataLockPriceTriaged);

                var pendingChangeOfProviderRequest = changeofPartyRequests.ChangeOfPartyRequests?
                                                     .Where(x => x.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeProvider && x.Status == ChangeOfPartyRequestStatus.Pending).FirstOrDefault();

                var result = new ApprenticeshipDetailsRequestViewModel
                {
                    HashedApprenticeshipId = source.ApprenticeshipHashedId,
                    AccountHashedId        = source.AccountHashedId,
                    ApprenticeName         = $"{apprenticeship.FirstName} {apprenticeship.LastName}",
                    ULN                  = apprenticeship.Uln,
                    DateOfBirth          = apprenticeship.DateOfBirth,
                    StartDate            = apprenticeship.StartDate,
                    EndDate              = apprenticeship.EndDate,
                    StopDate             = apprenticeship.StopDate,
                    PauseDate            = apprenticeship.PauseDate,
                    CompletionDate       = apprenticeship.CompletionDate,
                    TrainingName         = currentTrainingProgramme.Name,
                    Version              = apprenticeship.Version,
                    TrainingType         = currentTrainingProgramme.ProgrammeType,
                    Cost                 = priceEpisodes.PriceEpisodes.GetPrice(),
                    ApprenticeshipStatus = apprenticeship.Status,
                    ProviderName         = apprenticeship.ProviderName,
                    PendingChanges       = pendingChange,
                    EmployerReference    = apprenticeship.EmployerReference,
                    CohortReference      = _encodingService.Encode(apprenticeship.CohortId, EncodingType.CohortReference),
                    EnableEdit           = enableEdit,
                    EndpointAssessorName = apprenticeship.EndpointAssessorName,
                    MadeRedundant        = apprenticeship.MadeRedundant,
                    HasPendingChangeOfProviderRequest       = pendingChangeOfProviderRequest != null,
                    PendingChangeOfProviderRequestWithParty = pendingChangeOfProviderRequest?.WithParty,
                    HasContinuation         = apprenticeship.HasContinuation,
                    TrainingProviderHistory = changeOfProviderChain?.ChangeOfProviderChain
                                              .Select(copc => new TrainingProviderHistory
                    {
                        ProviderName           = copc.ProviderName,
                        FromDate               = copc.StartDate.Value,
                        ToDate                 = copc.StopDate.HasValue ? copc.StopDate.Value : copc.EndDate.Value,
                        HashedApprenticeshipId = _encodingService.Encode(copc.ApprenticeshipId, EncodingType.ApprenticeshipId),
                        ShowLink               = apprenticeship.Id != copc.ApprenticeshipId
                    })
                                              .ToList(),

                    PendingDataLockChange  = dataLockPriceTriaged || dataLockCourseChangedTraiged,
                    PendingDataLockRestart = dataLockCourseTriaged,
                    ConfirmationStatus     = apprenticeship.ConfirmationStatus,
                    Email = apprenticeship.Email,
                    EmailShouldBePresent = apprenticeship.EmailShouldBePresent,
                    HasNewerVersions     = await HasNewerVersions(currentTrainingProgramme),
                    Option         = apprenticeship.Option,
                    VersionOptions = currentTrainingProgramme.Options
                };

                return(result);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Error mapping for accountId {source.AccountHashedId}  and apprenticeship {source.ApprenticeshipHashedId} to ApprenticeshipDetailsRequestViewModel");
                throw;
            }
        }
Пример #29
0
 private static bool EnableEdit(CommitmentsV2.Api.Types.Responses.GetApprenticeshipResponse apprenticeship, PendingChanges pendingChange,
                                bool dataLockCourseTriaged, bool dataLockCourseChangedTraiged, bool dataLockPriceTriaged)
 {
     return(pendingChange == PendingChanges.None &&
            !dataLockCourseTriaged &&
            !dataLockCourseChangedTraiged &&
            !dataLockPriceTriaged &&
            new[] { ApprenticeshipStatus.WaitingToStart, ApprenticeshipStatus.Live, ApprenticeshipStatus.Paused }.Contains(apprenticeship.Status));
 }
 private void InitializePendingChanges()
 {
     pendingChanges       = new PendingChanges();
     listView.DataContext = pendingChanges;
 }
 private void InitializePendingChanges()
 {
     pendingChanges = new PendingChanges();
     listView.DataContext = pendingChanges;
 }