Exemplo n.º 1
0
        /// <summary>
        /// Marks a non-syncworkflow session to be completed
        /// and the parent session group to be completed if all its child
        /// sessions are in "completed (3)" status
        /// </summary>
        private void MigrationSessionCompleted()
        {
            // update the session state to Completed
            //
            // NOTE:
            // The sproc called here through EDM sets the Session *Group* to
            // be completed if all the sibling sessions of the current session (inclusively)
            // are completed.
            var updatedRTSessions = m_context.UpdateMigrationSessionStatusToCompleted(SessionId);

            if (updatedRTSessions.Count() > 0 &&
                WorkFlowType.Frequency == Frequency.OneTime)
            {
                // mark Session Group to be OneTimeCompleted (value: 4)

                // Note: updatedRTSessions has already been enumerated in the EDM imported function UpdateMigrationSessionStatusToCompleted
                // We have to ask the Context for a new instance of the RTSession, rather than enumerating on updatedRTSessions
                RTSession rtSession = m_context.RTSessionSet.Where(s => s.SessionUniqueId.Equals(SessionId)).First();
                rtSession.SessionGroupReference.Load();
                if (rtSession.SessionGroup.State == (int)BusinessModelManager.SessionStateEnum.Completed)
                {
                    rtSession.SessionGroup.State = (int)BusinessModelManager.SessionStateEnum.OneTimeCompleted;
                    m_context.TrySaveChanges();
                }
            }

            // update the session sync orchestration state
            if (m_syncStateMachine.TryTransit(PipelineSyncCommand.STOP))
            {
                m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.STOP);
            }

            var rtSessionRun = m_context.RTSessionRunSet.Where(r => r.Id == m_sessionRunId).FirstOrDefault();

            if (null != rtSessionRun)
            {
                rtSessionRun.State = (int)BusinessModelManager.SessionStateEnum.Completed;
                m_context.TrySaveChanges();
            }
        }