public TalkerSession(SessionTypeEnum sessionType, string busAddress) { topLevelTreeNode = null; bus = MQFactory.Instance.createMessagingBus(); if (sessionType == SessionTypeEnum.Server) { talkerConnection = bus.create(new Uri(busAddress)); ptpTalkerSession = talkerConnection.createPTPSession <T>("serverPTP", "ptpSimpleSession"); } else if (sessionType == SessionTypeEnum.Client) { talkerConnection = bus.connect(new Uri(busAddress)); ptpTalkerSession = talkerConnection.createPTPSession <T>("clientPTP", "ptpSimpleSession"); } else { throw new Exception("Session Type must be either Server or Client"); } this.sessionType = sessionType; talkerConnectionListener = new TalkerConnectionListener(); talkerConnection.addListener(talkerConnectionListener); ptpTalkerSession.addListener(this); talkerConnection.start(); }
public Session(string username, string connectionId, string deviceUuid) { this.Username = username; this.ConnectionId = connectionId; this.DeviceUuid = deviceUuid; this.LastTouchedDateTime = DateTime.UtcNow; this.SessionType = SessionTypeEnum.Active; }
private void CreateNewSession(SessionTypeEnum sessionType) { if (leftSource != null && rightSource != null) { Session session = new Session(); session.SessionUniqueId = Guid.NewGuid().ToString(); session.FriendlyName = string.Format(ModelResources.SessionFriendlyNameString, sessionType); session.LeftMigrationSourceUniqueId = leftSource.InternalUniqueId; session.RightMigrationSourceUniqueId = rightSource.InternalUniqueId; session.SessionType = sessionType; Microsoft.TeamFoundation.Migration.Shell.Tfs.Shell shell = DataContext as Microsoft.TeamFoundation.Migration.Shell.Tfs.Shell; shell.ViewModel.DataModel.Configuration.SessionGroup.Sessions.Session.Add(session); } }
private Session FindSession(Guid sessionGuid, SessionTypeEnum expectedSessionType) { using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { var sessionQuery = (from rts in context.RTSessionSet where rts.SessionUniqueId == sessionGuid select rts); if (sessionQuery.Count() == 0) { return(null); } RTSession rtSession = sessionQuery.First(); rtSession.SessionGroupReference.Load(); return(GetSessionFromSessionGroup(rtSession.SessionGroup.GroupUniqueId, expectedSessionType)); } }
private Session GetSessionFromSessionGroup(Guid sessionGroupId, SessionTypeEnum sessionType) { Configuration config; config = this.BusinessModelManager.LoadConfiguration(sessionGroupId); if (config == null) { throw new ArgumentException( String.Format(CultureInfo.InvariantCulture, ServerDiffResources.SessionGroupNotFound, sessionGroupId.ToString()), "sessionGroupId"); } foreach (var session in config.SessionGroup.Sessions.Session) { if (session.SessionType == sessionType) { Config = config; return(session); } } return(null); }
public static List <Guid> FindAllActiveSessionsOfType(SessionTypeEnum sessionType) { List <Guid> allActiveSessionsOfSelectedType = new List <Guid>(); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { // Query all of the session groups ordered by Id descending to get the most recent first var sessionGroupQuery = (from sg in context.RTSessionGroupSet orderby sg.Id select sg); // Iterate through the session groups until we find one that has the requested sessionType foreach (RTSessionGroup rtSessionGroup in sessionGroupQuery) { BusinessModelManager bmManager = new BusinessModelManager(); Configuration config = bmManager.LoadConfiguration(rtSessionGroup.GroupUniqueId); if (config == null) { continue; } HashSet <Guid> sessionGroupActiveSessions = new HashSet <Guid>(); rtSessionGroup.Sessions.Load(); foreach (RTSession rtSession in rtSessionGroup.Sessions) { if (rtSession.OrchestrationStatus != (int)PipelineState.Default && rtSession.OrchestrationStatus != (int)PipelineState.Stopped) { sessionGroupActiveSessions.Add(rtSession.SessionUniqueId); } } List <Guid> sessionGroupActiveSessionsOfSelectedType = FilterActiveSessionsByType(config, sessionGroupActiveSessions, sessionType); allActiveSessionsOfSelectedType.AddRange(sessionGroupActiveSessionsOfSelectedType); } } return(allActiveSessionsOfSelectedType); }
private Session FindMostRecentSessionOfType(SessionTypeEnum sessionType) { using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { // Query all of the session groups ordered by Id descending to get the most recent first var sessionGroupQuery = (from sg in context.RTSessionGroupSet orderby sg.Id descending select sg); // Iterate through the session groups until we find one that has the requested sessionType foreach (RTSessionGroup rtSessionGroup in sessionGroupQuery) { Session session = GetSessionFromSessionGroup(rtSessionGroup.GroupUniqueId, sessionType); if (session != null) { return(session); } } // No session groups had the requested session type, so return null return(null); } }
public static void ValidateCustomSettings(GenericSettingsElement customSettings, SessionTypeEnum sessionType) { string settingXml = BusinessModelManager.GenericSettingXmlToString(customSettings.SettingXml); if (!string.IsNullOrEmpty(settingXml)) { XmlDocument settingDoc = new XmlDocument(); settingDoc.LoadXml(settingXml); string pathToXsd = string.Empty; switch (sessionType) { case SessionTypeEnum.WorkItemTracking: pathToXsd = Constants.WITConfigXsdResourcePath; break; case SessionTypeEnum.VersionControl: pathToXsd = Constants.VCConfigXsdResourcePath; break; default: break; } if (!string.IsNullOrEmpty(pathToXsd)) { ConfigurationValidator configValidator = new ConfigurationValidator(); configValidator.ValidateXmlFragment(string.Empty, settingDoc.DocumentElement, pathToXsd); var sessionConfigValidateResult = configValidator.ValidationResult; if (!sessionConfigValidateResult.IsValid) { throw new ConfigurationSchemaViolationException(sessionConfigValidateResult); } } } }
private static List <Guid> FilterActiveSessionsByType(Configuration config, HashSet <Guid> activeSessionGuids, SessionTypeEnum sessionType) { List <Guid> sessionGuidOfSelectedType = new List <Guid>(); foreach (var session in config.SessionGroup.Sessions.Session) { if (activeSessionGuids.Contains(session.SessionUniqueIdGuid) && session.SessionType == sessionType) { sessionGuidOfSelectedType.Add(session.SessionUniqueIdGuid); } } return(sessionGuidOfSelectedType); }
/// <summary> /// VCServerDiff will verify the first VC session in the session group identified by the sessionGroupId /// </summary> /// <param name="sessionGuid">The Guid of the Session on which to perform the diff operation</param> /// <param name="noContentComparison">If true, don't compare the contents of each items, just the existence on both sides</param> /// <param name="verbose">Whether or not to include verbose messages in any tracing that is performed</param> /// <param name="useTraceManager">Whether or not to write messages using the TraceManager class</param> /// <param name="storeResultsInDB">Whether or not to store the results of the Diff operation in the Tfs_IntegrationPlatform database</param> public ServerDiffEngine( Guid sessionGuid, bool noContentComparison, bool verbose, SessionTypeEnum sessionType, bool useTraceManager, bool storeResultsInDB) { NoContentComparison = noContentComparison; Verbose = verbose; UseTraceManager = useTraceManager; StoreResultsInDB = storeResultsInDB; SessionGuidArgument = sessionGuid; if (sessionGuid.Equals(Guid.Empty)) { Session = FindMostRecentSessionOfType(sessionType); if (Session == null) { throw new MigrationSessionNotFoundException( String.Format(CultureInfo.InvariantCulture, ServerDiffResources.SessionWithTypeNotFound, sessionType)); } } else { Session = FindSession(sessionGuid, sessionType); if (Session == null) { throw new MigrationSessionNotFoundException( String.Format(CultureInfo.InvariantCulture, ServerDiffResources.SessionWithIdAndTypeNotFound, sessionType, sessionGuid.ToString())); } } ProviderManager providerManager = new ProviderManager(Config); Dictionary <Guid, ProviderHandler> providerHandlers = providerManager.LoadProvider(new DirectoryInfo(Constants.PluginsFolderName)); AddinManagementService = providerManager.AddinManagementService; TraceManager.TraceInformation("{0} Add-Ins loaded", AddinManagementService.Count); LeftDiffProviderGuid = new Guid(Session.LeftMigrationSourceUniqueId); LeftMigrationSource = Config.GetMigrationSource(LeftDiffProviderGuid); if (!providerHandlers.ContainsKey(LeftDiffProviderGuid)) { throw new ApplicationException( String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ServerDiffProviderNotLoaded, LeftMigrationSource.FriendlyName)); } LeftProvider = providerHandlers[LeftDiffProviderGuid].Provider; RightDiffProviderGuid = new Guid(Session.RightMigrationSourceUniqueId); RightMigrationSource = Config.GetMigrationSource(RightDiffProviderGuid); if (!providerHandlers.ContainsKey(RightDiffProviderGuid)) { throw new ApplicationException( String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ServerDiffProviderNotLoaded, RightMigrationSource.FriendlyName)); } RightProvider = providerHandlers[RightDiffProviderGuid].Provider; Session.MigrationSources.Add(LeftDiffProviderGuid, LeftMigrationSource); Session.MigrationSources.Add(RightDiffProviderGuid, RightMigrationSource); LogInfo(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.MigrationSourceName, LeftMigrationSource.FriendlyName)); LogInfo(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.MigrationTargetName, RightMigrationSource.FriendlyName)); SourceDiffProvider = GetDiffProviderForMigrationSource(LeftMigrationSource, providerHandlers); TargetDiffProvider = GetDiffProviderForMigrationSource(RightMigrationSource, providerHandlers); }
/// <summary> /// VCServerDiff will verify the first VC session in the session group identified by the sessionGroupId /// </summary> /// <param name="sessionGuid">The Guid of the Session group on which to perform the diff operation</param> /// <param name="noContentComparison">If true, don't compare the contents of each items, just the existence on both sides</param> /// <param name="verbose">Whether or not to include verbose messages in any tracing that is performed</param> public ServerDiffEngine(Guid sessionGuid, bool noContentComparison, bool verbose, SessionTypeEnum sessionType) : this(sessionGuid, noContentComparison, verbose, sessionType, false, false) { }
private void RegisterSessionSpecificConflicts(ConflictManager conflictManagementService, SessionTypeEnum sessionType) { switch (sessionType) { case SessionTypeEnum.VersionControl: RegisterVCContentConflicts(conflictManagementService); break; case SessionTypeEnum.WorkItemTracking: RegisterWITBasicConflicts(conflictManagementService); break; default: throw new InvalidOperationException(); } }
/// <summary> /// An operation that sets the session type to <see cref="SessionTypeEnum.Active"/>, /// and then updates the connectionId and deviceUuid. /// Usually called by an IUserHandler. /// </summary> /// <param name="connectionId">The new connecton id</param> /// <param name="deviceUuid">The new device uuid</param> public void Revive(string connectionId, string deviceUuid) { this.SessionType = SessionTypeEnum.Active; this.ConnectionId = connectionId; this.DeviceUuid = deviceUuid; }
/// <summary> /// An operation that sets the session type to <see cref="SessionTypeEnum.Expired"/>. /// Usually called by an IUserHandler. /// </summary> public void Expire() { this.SessionType = SessionTypeEnum.Expired; }
/// <summary> /// Constructor /// </summary> /// <param name="sessionType">Session type that the provider supports</param> /// <param name="endpointSystemName">The name of the endpoint system that the provider supports</param> public ProviderCapabilityAttribute( SessionTypeEnum sessionType, string endpointSystemName) { Initialize(sessionType, endpointSystemName); }
/// <summary> /// Allocate sessions to morning and afternoon slots based on session type /// </summary> /// <param name="sessionInput"></param> /// <param name="sessionType"></param> /// <returns>Returns list of sessions</returns> private List <Session> GetSessions(List <SessionInputViewModel> sessionInput, SessionTypeEnum sessionType) { var result = new List <Session>(); var uniqueDurationAvailable = _durationCountMap.Where(x => x.Value > 0).Select(x => x.Key).ToList(); // If no unique duration left (i.e. all sessions already assigned a slot), then return empty list if (uniqueDurationAvailable.Count == 0) { return(result); } var usedSessionStack = new Stack <int>(); var sessionsExplored = new Dictionary <int, HashSet <int> >(); minDuration = sessionType == SessionTypeEnum.Morning ? 180 : 240; var startTime = sessionType == SessionTypeEnum.Morning ? new DateTime(2020, 1, 1, 9, 0, 0) : new DateTime(2020, 1, 1, 13, 0, 0); var remainingDuration = ComputeRemainingDuration(minDuration, minDuration, usedSessionStack, sessionsExplored, uniqueDurationAvailable); if (remainingDuration == 0) { // Get all session duration from stack while (usedSessionStack.Count > 0) { var sessionDuration = usedSessionStack.Pop(); var session = sessionInput.FirstOrDefault(x => x.DurationMinutes == sessionDuration && !x.IsAllocated); if (session != null) { session.IsAllocated = true; result.Add(new Session { Duration = session.SessionDuration, SessionName = session.SessionName, StartTime = startTime.Hour, StartTimeText = startTime.ToString("hh:mm tt") }); // Calculate next slot adding minutes startTime = startTime.AddMinutes(session.DurationMinutes); } } } else { // Adjust extra time here foreach (var item in _minRemainingDurationSnapshot) { var session = sessionInput.FirstOrDefault(x => x.DurationMinutes == item && !x.IsAllocated); if (session != null) { session.IsAllocated = true; // Calculate next slot adding minutes result.Add(new Session { Duration = session.SessionDuration, SessionName = session.SessionName, StartTime = startTime.Hour, StartTimeText = startTime.ToString("hh:mm tt") }); startTime = startTime.AddMinutes(session.DurationMinutes); } } } // adding sharing session if (sessionType == SessionTypeEnum.Afternoon && result.Count > 0) { if (startTime.Hour < 16) { startTime = new DateTime(2020, 1, 1, 16, 0, 0); } result.Add(new Session { SessionName = "Sharing Session", StartTimeText = startTime.ToString("hh:mm tt"), Duration = string.Empty }); } else if (sessionType == SessionTypeEnum.Morning) { // adding a lunch session result.Add(new Session { SessionName = "Lunch", StartTimeText = "12:00 PM", Duration = string.Empty }); } return(result); }