コード例 #1
0
 public Event GetEvent(string pr,
                       string fi,
                       int eventId,
                       ref Login login)
 {
     foreach (Product p in Product.GetProducts(ref login))
     {
         if (p.Name == pr)
         {
             ApplicationFileCollection ac =
                 p.GetApplicationFiles(ref login);
             foreach (ApplicationFile file in ac)
             {
                 if (file.Name == fi)
                 {
                     EventPageReader epr = file.GetEvents();
                     while (epr.Read(ref login) == true)
                     {
                         EventReader er = epr.Events;
                         while (er.Read() == true)
                         {
                             Event e = er.Event;
                             return(e);
                         }
                     }
                 }
             }
         }
     }
     throw new Exception("Event Not Found");
 }
コード例 #2
0
 public static ApplicationFile FindFile(ApplicationFileCollection files, int id)
 {
     foreach (ApplicationFile file in files)
     {
         if (file.ID == id)
         {
             return(file);
         }
     }
     return(null);
 }
コード例 #3
0
        public static StackHashFileCollection GetFilesApi(ref Login login, Product product)
        {
            ApplicationFileCollection apiFiles = product.GetApplicationFiles(ref login);

            StackHashFileCollection apiStackHashFiles = new StackHashFileCollection();

            foreach (ApplicationFile file in apiFiles)
            {
                StackHashFile stackHashFile = ObjectConversion.ConvertFile(file);
                apiStackHashFiles.Add(stackHashFile);
            }
            return(apiStackHashFiles);
        }
コード例 #4
0
        /// <summary>
        /// Syncs up with the files/events on winqual.
        /// </summary>
        /// <param name="lastPullDate">Last time the data was synced.</param>
        /// <param name="errorIndex">Index to add to.</param>
        /// <param name="product">Product to sync.</param>
        /// <param name="stackHashProduct">StackHash version of the product data.</param>
        /// <param name="getCabs">True - get the cabs associated with the events, false - just get the events.</param>
        private void UpdateFiles(DateTime lastPullDate, IErrorIndex errorIndex, Product product, StackHashProduct stackHashProduct, bool getCabs)
        {
            // Get the files associated with the product.
            ApplicationFileCollection files = product.GetApplicationFiles(ref m_Login);

            foreach (ApplicationFile file in files)
            {
                if (m_AbortRequested)
                {
                    throw new OperationCanceledException("Abort requested during Win Qual synchronize");
                }

                StackHashFile stackHashFile = ObjectConversion.ConvertFile(file);

                m_SyncProgress.FileId = stackHashFile.Id;

                // Check the date the file record was created. If the date created is
                // greater than the last pull date then this is a new file and so add a file
                // record.
                if (file.DateCreatedLocal > lastPullDate)
                {
                    errorIndex.AddFile(stackHashProduct, stackHashFile);
                }
                else if (file.DateModifiedLocal > lastPullDate)
                {
                    // Update the product information if product last modified date is greater than
                    // the last pull date.
                    errorIndex.AddFile(stackHashProduct, stackHashFile);
                }
                else
                {
                    // Check if the file exists. If not then add it.
                    if (!errorIndex.FileExists(stackHashProduct, stackHashFile))
                    {
                        errorIndex.AddFile(stackHashProduct, stackHashFile);
                    }
                }

                UpdateEvents(lastPullDate, errorIndex, stackHashProduct, getCabs, file, stackHashFile);
            }
        }
コード例 #5
0
        public void GetEventsStartDate()
        {
            DateTime startTime = DateTime.Now.AddMonths(-1);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, false, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            // ATOM GetProducts.
            AtomProductCollection atomProducts = atomFeed.GetProducts();


            // WERAPI Login.
            Login login = new Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword);

            login.Validate();

            // WERAPI GetProducts.
            ProductCollection apiProducts = Product.GetProducts(ref login);

            Assert.AreEqual(atomProducts.Count, apiProducts.Count);

            bool eventListsDifferent = false;

            foreach (AtomProduct atomProduct in atomProducts)
            {
                // ATOM GetFiles.
                AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                // API GetFiles
                Product apiProduct = Utils.FindProduct(apiProducts, atomProduct.Product.Id);
                ApplicationFileCollection apiFiles = apiProduct.GetApplicationFiles(ref login);

                Assert.AreEqual(atomFiles.Count, apiFiles.Count);

                foreach (AtomFile atomFile in atomFiles)
                {
                    ApplicationFile apiFile = Utils.FindFile(apiFiles, atomFile.File.Id);

                    // ATOM GetEvents.
                    StackHashEventCollection atomStackHashEvents       = Utils.GetEventsAtom(atomFeed, atomFile, startTime);
                    StackHashEventCollection atomStackHashEventsNoTime = Utils.GetEventsAtom(atomFeed, atomFile);

                    if (atomStackHashEvents.Count != atomStackHashEventsNoTime.Count)
                    {
                        eventListsDifferent = true;
                    }

                    // WERAPI GetEvents.
                    List <Event>             rawApiEvents;
                    StackHashEventCollection apiStackHashEvents = Utils.GetEventsApi(ref login, apiFile, out rawApiEvents, startTime);

                    Assert.AreEqual(apiStackHashEvents.Count, atomStackHashEvents.Count);

                    foreach (StackHashEvent stackHashEvent in atomStackHashEvents)
                    {
                        // Find the equivalent event in the api file list.
                        StackHashEvent apiEvent = apiStackHashEvents.FindEvent(stackHashEvent.Id, stackHashEvent.EventTypeName);

                        Assert.AreNotEqual(null, apiEvent);

                        Assert.AreEqual(true, stackHashEvent.CompareTo(apiEvent) == 0);
                    }
                }
            }

            Assert.AreEqual(true, eventListsDifferent);
        }