public XDocument GetCrlXDocument(string uniqueLabelForCheckRunSegment)
        {
            XDocument result      = null;
            string    truncatedId = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);

            try
            {
                lock (m_CheckRunLaunchLockObject)
                {
                    result = m_CRL_XDocuments[truncatedId];
                    m_CRL_XDocuments.Remove(truncatedId);
                }
            }
            catch (KeyNotFoundException ex)
            {
                string existingKeys = null;

                lock (m_CheckRunArtifactLockObject)
                {
                    existingKeys = this.ListCrlKeys();
                }

                string message = string.Format("GetCrlXDocument Failed to find a key. ID='{0}{1}{2}', truncated='{3}{4}{5}', existingkeys='{6}'", Environment.NewLine, uniqueLabelForCheckRunSegment, Environment.NewLine, Environment.NewLine, truncatedId, Environment.NewLine, this.ListCrlKeys());
                throw new CheckInfrastructureServiceException(message, ex);
            }

            return(result);
        }
Пример #2
0
        public string CompleteCheckRun(XDocument checkRunArtifact)
        {
            string uniqueLabelForCheckRunSegment = CrxDepot.Instance.SetCraXDocument(checkRunArtifact);

            Synchronization.ReleaseOne(CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment));
            return(uniqueLabelForCheckRunSegment);
        }
        public void SetMessage(string uniqueLabelForCheckRunSegment, string message)
        {
            string cleanedID = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);

            lock (m_CheckErrorsLockObject)
            {
                m_Errors.Add(cleanedID, message);
            }
        }
Пример #4
0
        public XDocument GetCrlXDocument(string uniqueLabelForCheckRunSegment)
        {
            XDocument result      = null;
            string    truncatedId = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);

            string crlFileName = CrlFilePrefix + this.FileNameFromTruncatedId(truncatedId);

            result = XDocument.Load(Path.Combine(this.m_CrlDirectory, crlFileName));

            return(result);
        }
        public string GetMessage(string uniqueLabelForCheckRunSegment)
        {
            string result    = null;
            string cleanedID = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);

            lock (m_CheckErrorsLockObject)
            {
                result = m_Errors[cleanedID];
            }

            return(result);
        }
Пример #6
0
        public string SetCraXDocument(XDocument xDocCra)
        {
            string uniqueLabelForCheckRunSegment = CheckRunDataHandles.CreateIdFromCrxXDocument(xDocCra);
            string truncatedId = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);

            string craFileName         = CraFilePrefix + this.FileNameFromTruncatedId(truncatedId);
            string fullFileNameAndPath = Path.Combine(this.m_CraDirectory, craFileName);

            xDocCra.Save(fullFileNameAndPath);

            return(uniqueLabelForCheckRunSegment);
        }
        public string SetCraXDocument(XDocument xDocCra)
        {
            string uniqueLabelForCheckRunSegment = CheckRunDataHandles.CreateIdFromCrxXDocument(xDocCra);
            string truncatedId = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);


            lock (m_CheckRunArtifactLockObject)
            {
                m_CRA_XDocuments.Add(truncatedId, xDocCra);
            }

            return(uniqueLabelForCheckRunSegment);
        }
Пример #8
0
        public static Semaphore CreateAndGetNamedSemaphore(string accessUserName, string semaphoreName)
        {
            Semaphore resultSemaphore = null;
            string    truncatedCreateSemaphoreName = string.Empty;

            try
            {
                bool createdNew = false;
                truncatedCreateSemaphoreName = CheckRunDataHandles.StripIdOfMachineNames(semaphoreName);

                // Create rights on the semaphore so the test user can signal it
                SemaphoreSecurity semaphoreSecurity = new SemaphoreSecurity();

                // Allow the user specified in the parameter to signal the semaphore. This user may be the identify specified with the distributed solution.
                SemaphoreAccessRule rule = new SemaphoreAccessRule(accessUserName, SemaphoreRights.Synchronize | SemaphoreRights.Modify, AccessControlType.Allow);
                semaphoreSecurity.AddAccessRule(rule);

                // Allow the current user to signal the semaphore. Note that a different format is required for a local user vs. a domain user
                string currentUserName = Environment.UserName;

                // Check if local user or domain user
                if (!string.IsNullOrEmpty(Environment.UserDomainName))
                {
                    currentUserName = Environment.UserDomainName + "\\" + currentUserName;
                }

                rule = new SemaphoreAccessRule(currentUserName, SemaphoreRights.Synchronize | SemaphoreRights.Modify, AccessControlType.Allow);
                semaphoreSecurity.AddAccessRule(rule);

                // Create the semaphore
                resultSemaphore = new Semaphore(0, 1, truncatedCreateSemaphoreName, out createdNew, semaphoreSecurity);

                if (!createdNew)
                {
                    throw new CheckInfrastructureClientException(string.Format("Semaphore with name='{0}' for user='******' was not created.", truncatedCreateSemaphoreName, accessUserName));
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                if (ex.Message.Contains("Access to the port"))
                {
                    throw new CheckInfrastructureClientException(string.Format("Semaphore with name='{0}' for user='******' was not created. Is there a duplicate named semaphore?", truncatedCreateSemaphoreName, accessUserName));
                }
                else
                {
                    throw;
                }
            }

            return(resultSemaphore);
        }
        public string SetCrlXDocument(XDocument crlXDoc)
        {
            string uniqueLabelForCheckRunSegment = CheckRunDataHandles.CreateIdFromCrxXDocument(crlXDoc);
            string truncatedId = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);


            lock (m_CheckRunLaunchLockObject)
            {
                m_CRL_XDocuments.Add(truncatedId, crlXDoc);
            }


            return(uniqueLabelForCheckRunSegment);
        }
        /// <summary>
        /// This method releases the client call that started the check or subcheck. If this method completes before the client calls WaitOne(), the client won't block at all.
        /// </summary>
        /// <param name="semaphoreName"></param>
        public static void ReleaseOne(string semaphoreName)
        {
            // signal the named semaphore
            Semaphore namedSemaphoreWaitingOnCheckRunResult = null;
            string    truncatedReleaseSemaphoreName         = CheckRunDataHandles.StripIdOfMachineNames(semaphoreName);

            bool semaphoreFindResult = Semaphore.TryOpenExisting(truncatedReleaseSemaphoreName, out namedSemaphoreWaitingOnCheckRunResult);

            if (!semaphoreFindResult)
            {
                throw new CheckInfrastructureServiceException(string.Format("The semaphore with name='{0}' was not found.", semaphoreName));
            }

            // Releases the thread in the process that created the named semaphore, so that thread can continue
            //  to call GetCheckRunArtifact
            namedSemaphoreWaitingOnCheckRunResult.Release(1);
        }
Пример #11
0
        public bool ClearCrlXDocumentById(string uniqueLabelForCheckRunSegment)
        {
            bool documentRemoved = false;

            try
            {
                string truncatedId = CheckRunDataHandles.StripIdOfMachineNames(uniqueLabelForCheckRunSegment);

                lock (m_CheckRunLaunchLockObject)
                {
                    documentRemoved = m_CRL_XDocuments.Remove(truncatedId);
                }
            }
            catch (KeyNotFoundException)
            {
                // do nothing
            }

            return(documentRemoved);
        }