Пример #1
0
        /// <summary>
        /// Creates a <see cref="SessionTicket"/> using the specififed scenario name.
        /// </summary>
        /// <param name="scenarioNames">List of the scenarios to execute.</param>
        /// <param name="sessionName">Name of the session to execute scenarios</param>
        /// <param name="durationHours">The session duration in hours.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">Scenario with specified name is not found in the database.</exception>
        public static SessionTicket Create(IEnumerable <string> scenarioNames, string sessionName, int durationHours = 2)
        {
            SessionTicket ticket = new SessionTicket()
            {
                ExpirationDate = DateTime.Now.AddHours(durationHours),
                DurationHours  = durationHours,
                SessionName    = sessionName
            };

            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                foreach (string scenarioName in scenarioNames)
                {
                    if (!string.IsNullOrEmpty(scenarioName))
                    {
                        var scenario = EnterpriseScenario.Select(context, scenarioName);
                        if (scenario == null)
                        {
                            throw new InvalidOperationException($"'{scenarioName}' is not found in the database.");
                        }
                        ((List <Guid>)ticket.ScenarioIds).Add(scenario.EnterpriseScenarioId);
                    }
                }
            }
            return(ticket);
        }
Пример #2
0
        /// <summary>
        /// Initiates a new session using the specified ticket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        public void InitiateSession(SessionTicket ticket)
        {
            if (_myCallbackService.State != CommunicationState.Opened)
            {
                StartCallbackService();
            }

            TraceFactory.Logger.Debug("SessionId: {0}".FormatWith(ticket.SessionId));
            CallDispatcher((c) => c.Initiate(ticket, _myCallbackEndpoint));
        }
Пример #3
0
        /// <summary>
        /// Initiates a new session based on the specified ticket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <param name="ownerCallback">The owner callback.</param>
        public void Initiate(SessionTicket ticket, Uri ownerCallback)
        {
            string sessionId = ticket.SessionId;

            SetTraceSessionContext(sessionId);

            TraceFactory.Logger.Debug("SessionId {0}".FormatWith(sessionId));

            if (_proxyControllers.Contains(sessionId))
            {
                StackTrace trace = new StackTrace(true);

                StringBuilder builder = new StringBuilder();
                foreach (StackFrame item in trace.GetFrames())
                {
                    builder.AppendLine("{0}::[{1}, {2}]::{3}"
                                       .FormatWith(item.GetFileName(), item.GetFileLineNumber(), item.GetFileColumnNumber(), item.GetMethod()));
                }
                TraceFactory.Logger.Error("A session proxy {0} already exists{1}{2}".FormatWith(sessionId, Environment.NewLine, builder));

                //string msg = "A session proxy {0} already exists".FormatWith(sessionId);
                //var exception = new ApplicationException(msg);
                //EventPublisher.PublishDispatcherException(exception);
                return;
            }

            TraceFactory.Logger.Debug("Starting proxy process");

            // Create a new entry for this session Id and start the associated Proxy Process
            _proxyControllers.StartProxyProcess(sessionId);

            if (GlobalSettings.IsDistributedSystem)
            {
                // Once the proxy service is started, give it a few more seconds to ensure it's fully initialized
                Thread.Sleep(3000);
            }

            // Make the initiate call but do it in the foreground to ensure it's completed before returning
            TraceFactory.Logger.Debug("CallProxy -> Initiate({0})".FormatWith(sessionId));
            CallSessionProxy(sessionId, (c) => c.Initiate(ticket, ownerCallback), useThread: false);

            // If we now have a new session proxy running, then make sure all subscribers are added to
            // this session proxy's subscriber list.
            foreach (var subscriber in EventPublisher.Subscribers)
            {
                TraceFactory.Logger.Debug("CallProxy -> Subscribe({0})".FormatWith(sessionId));
                CallSessionProxy(sessionId, (c) => c.Subscribe(subscriber), useThread: false);
                TraceFactory.Logger.Debug("Subscriber {0} added to session proxy {1}".FormatWith(subscriber.AbsoluteUri, sessionId));
            }
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemManifestAgent" /> class.
 /// </summary>
 /// <param name="ticket">The session configuration.</param>
 /// <param name="scenarioId">The scenarioId from which to build the manifest(s).</param>
 public SystemManifestAgent(SessionTicket ticket, Guid scenarioId)
 {
     Ticket      = ticket;
     ScenarioId  = scenarioId;
     Assets      = new List <AssetDetail>();
     DataCache   = new DataModelCache();
     Quantities  = new SessionResourceQuantity();
     ManifestSet = new SystemManifestCollection();
     _agents     = new List <IManifestComponentAgent>()
     {
         new ManifestAssetAgent(ScenarioId),
         new ManifestDocumentAgent(ScenarioId),
         new ManifestServerAgent(ScenarioId),
         new ManifestPrintQueueAgent(ScenarioId),
         new ManifestRetrySettingsAgent(ScenarioId),
         new ManifestSettingsAgent(),
         new ManifestPluginAssembliesAgent()
     };
     Initialize();
 }