コード例 #1
0
        public void StartSession(StfSessionTicket sessionTicket)
        {
            _isSessionExecuting = true;
            try
            {
                var ticket = SessionTicket.Create(new[] { Guid.Parse(sessionTicket.ScenarioId) }, sessionTicket.SessionName, sessionTicket.Duration);
                ticket.ExpirationDate = DateTime.Now + TimeSpan.FromDays(180.0);
                if (GlobalSettings.IsDistributedSystem)
                {
                    ticket.SessionOwner = new UserCredential(GlobalSettings.Items.DomainAdminCredential.UserName, GlobalSettings.Items.DomainAdminCredential.Password, GlobalSettings.Items.DomainAdminCredential.Domain);
                }
                SessionClient.Instance.InitiateSession(ticket);
                var assetDetails = SessionClient.Instance.Reserve(ticket.SessionId);

                if (assetDetails.Any(x => x.Availability != AssetAvailability.Available))
                {
                    SessionClient.Instance.Close(ticket.SessionId);
                    TraceFactory.Logger.Error($"One or more assets are unavailable for session {ticket.SessionId}");
                    _isSessionExecuting = false;
                    return;
                }
                foreach (var printDeviceDetail in assetDetails.OfType <PrintDeviceDetail>())
                {
                    printDeviceDetail.UseCrc = false;
                }
                SessionClient.Instance.Stage(ticket.SessionId, assetDetails);
                lock (ticket.SessionId)
                {
                    SessionExecutionDictionary.TryAdd(ticket.SessionId, sessionTicket);
                }
            }
            catch (Exception e)
            {
                TraceFactory.Logger.Error(e.JoinAllErrorMessages());
                _isSessionExecuting = false;
            }
        }
コード例 #2
0
 public static int Enqueue(StfSessionTicket ticket)
 {
     SessionQueue.Enqueue(ticket);
     return(SessionQueue.Count);
 }