Exemplo n.º 1
0
        public static StackHashEventCollection GetEventsApi(ref Login login, ApplicationFile file, out List <Event> rawEvents, DateTime startTime)
        {
            EventPageReader          eventPageReader    = file.GetEvents(startTime); // Get all events.
            StackHashEventCollection apiStackHashEvents = new StackHashEventCollection();

            rawEvents = new List <Event>();

            // Read each page of new events.
            while (eventPageReader.Read(ref login) == true)
            {
                // Get the events for the page.
                EventReader events = eventPageReader.Events;

                while (events.Read() == true)
                {
                    // Get the event
                    Event dpEvent = events.Event;
                    rawEvents.Add(dpEvent);
                    StackHashEvent stackHashEvent = ObjectConversion.ConvertEvent(dpEvent, file.ID);


                    apiStackHashEvents.Add(stackHashEvent);
                }
            }
            return(apiStackHashEvents);
        }
        public ActionResult <Application> PostApplication([FromForm] ApplicationFile appFile, [FromForm] Application app)
        {
            //appending date with filename to make dbo.Application.File_Name unique

            string            tempFileName = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") + "/" + app.FileName;
            DatabaseOperation db           = new DatabaseOperation();

            db.AddApplication(app.ProjectName, app.CategoryName, tempFileName);

            Application       application = new Application();
            DatabaseOperation db1         = new DatabaseOperation();

            application = db1.GetSingleApplication(app.ProjectName, app.CategoryName, tempFileName);


            DatabaseOperation db2     = new DatabaseOperation();
            Project           project = db2.GetSingleProject(app.ProjectName)[0];


            FileHierarchyCreation file = new FileHierarchyCreation();
            bool uploadCheck           = file.CreateApplicationFolder(application.AppId, app.CategoryName, app.ProjectName, tempFileName, project.BundleIdentifier, appFile);

            if (uploadCheck)
            {
                return(StatusCode(200, new { title = "Applicaton uploaded successfully.", status = 200 }));
            }
            else
            {
                return(StatusCode(500, new { title = "Applicaton upload error.", status = 500, message = "This app version already exists" }));
            }
        }
 public RecompensateApplicationProcessCommand(
     string id,
     ApplicationFile photo,
     ApplicationFile cv)
 {
     Id    = id;
     Photo = photo;
     Cv    = cv;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of <see cref="Packager"/>.
        /// </summary>
        /// <param name="applicationData">The data to base the packaging process on.</param>
        /// <param name="outputFolder">The location where the application must be packaged to.</param>
        public Packager(ApplicationData applicationData, string outputFolder)
        {
            var workingDirectory = new ApplicationFile(outputFolder);

            if (workingDirectory.Type != FileType.Directory)
            {
                throw new ArgumentException("The value specified for the outputFolder is invalid.", "outputFolder");
            }
            _startInfo  = new VirtualProcessStartInfo(applicationData, workingDirectory);
            _waitHandle = new AutoResetEvent(false);
        }
Exemplo n.º 5
0
 private void downloadFile(ApplicationFile file)
 {
     Response.Clear();
     Response.Buffer  = true;
     Response.Charset = "";
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     Response.ContentType = file.ContentType;
     Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.FileName);
     //Response.BinaryWrite(file.data);
     Response.Flush();
     Response.End();
 }
 public static string getFilePath(ApplicationFile f)
 {
     switch (f)
     {
         case ApplicationFile.EmptyDB:
             return string.Format(@"{0}\{1}", getFolderPath(ApplicationFolder.Defaults), MOBILEDB_FILE);
         case ApplicationFile.EmptyTaxonDB:
             return string.Format(@"{0}\{1}", getFolderPath(ApplicationFolder.Defaults), TAXONDB_FILE);
         case ApplicationFile.ConnectionProfiles:
             return string.Format(@"{0}\{1}", getFolderPath(ApplicationFolder.Defaults), CONNECTIONPROFILES_FILE);
         default:
             throw new ArgumentException("Unkown FileType");
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Extract zip release file to application directory.
        /// </summary>
        /// <param name="releaseFile">A zip release file.</param>
        protected void ExtractRelease(FileInfo releaseFile)
        {
            try
            {
                GRoggle.Write("Try to extract a release zip", RoggleLogLevel.Debug);

                ZipFile.ExtractToDirectory(releaseFile.FullName, ApplicationDirectory.FullName);
                File.Delete(releaseFile.FullName);
                ApplicationFile.Refresh();
            }
            catch (Exception e)
            {
                GRoggle.Write("Something goes wrong while extracting release", e);
            }
        }
        public static string getFilePath(ApplicationFile f)
        {
            switch (f)
            {
            case ApplicationFile.EmptyDB:
                return(string.Format(@"{0}\{1}", getFolderPath(ApplicationFolder.Defaults), MOBILEDB_FILE));

            case ApplicationFile.EmptyTaxonDB:
                return(string.Format(@"{0}\{1}", getFolderPath(ApplicationFolder.Defaults), TAXONDB_FILE));

            case ApplicationFile.ConnectionProfiles:
                return(string.Format(@"{0}\{1}", getFolderPath(ApplicationFolder.Defaults), CONNECTIONPROFILES_FILE));

            default:
                throw new ArgumentException("Unkown FileType");
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Converts a WinQual ApplicationFile into a StackHashFile.
        /// </summary>
        /// <param name="file">WinQual application file to convert.</param>
        /// <returns>Converted file.</returns>
        public static StackHashFile ConvertFile(ApplicationFile file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            StackHashFile newFile = new StackHashFile(
                file.DateCreatedLocal.ToUniversalTime(),
                file.DateModifiedLocal.ToUniversalTime(),
                file.ID,
                file.LinkDateLocal.ToUniversalTime(),
                file.Name,
                file.Version);

            return(newFile);
        }
Exemplo n.º 10
0
        public ImageVM GetImage(int id)
        {
            ApplicationFile file = new ApplicationFile();

            file = ApplicationFileRepository.GetImage(id);
            if (file == null)
            {
                throw new BussinesException(502, ErrorResource.NoData);
            }
            ImageVM result = new ImageVM
            {
                Content = file.Content,
                Type    = file.ContentType
            };

            return(result);
        }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="FileNotFoundException"></exception>
 /// <exception cref="GacException"></exception>
 /// <param name="otherAppExe"></param>
 /// <param name="sharedAssemblies"></param>
 public GacManager(string otherAppExe, IEnumerable <string> sharedAssemblies)
 {
     _gacSyncRoot = new object();
     _otherAppExe = new ApplicationFile(otherAppExe);
     if (_otherAppExe.Type != FileType.Executable)
     {
         throw new GacException("\"" + _otherAppExe.FileName + "\" is no valid executable.");
     }
     _sharedAssemblies = new List <ApplicationFile>();
     foreach (var sharedAssembly in sharedAssemblies)
     {
         var file = new ApplicationFile(sharedAssembly);
         if (file.Type == FileType.Library)
         {
             _sharedAssemblies.Add(file);
         }
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of <see cref="ProcessSynchronizer"/>.
 /// The constructor will create default databases from the specified files.
 /// </summary>
 /// <param name="fileSystemRoot">The directory to use as root of the file system.</param>
 /// <param name="fileSystemRuleCollection">The collection of engine rules to apply on the file system virtualization engine.</param>
 /// <param name="registryDatabaseFile">The file to use with a default <see cref="RegistryDatabase"/>.</param>
 /// <param name="registryRuleCollection">The collection of engine rules to apply on the registry virtualization engine.</param>
 public ProcessSynchronizer(ApplicationFile fileSystemRoot, FileSystemRuleCollection fileSystemRuleCollection,
                            ApplicationFile registryDatabaseFile, RegistryRuleCollection registryRuleCollection)
 {
     if (fileSystemRoot.Type != FileType.Directory)
     {
         throw new ArgumentException("The root location specified for the file system is not valid.", "fileSystemRoot");
     }
     if (registryDatabaseFile.Type != FileType.Database)
     {
         throw new ArgumentException("The filename specified for the registry database is not valid.", "registryDatabaseFile");
     }
     _connectionStrings = new Dictionary <ConfigurationDataType, string>(2)
     {
         { ConfigurationDataType.RegistryDatabaseFile, registryDatabaseFile.FileName },
         { ConfigurationDataType.FileSystemRoot, fileSystemRoot.FileName }
     };
     _fsRuleCollection  = fileSystemRuleCollection;
     _regRuleCollection = registryRuleCollection;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of <see cref="VirtualProcessStartInfo"/>
 ///  based on the <see cref="ApplicationData"/> specified.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// An <see cref="ArgumentNullException"/> is thrown if <paramref name="data"/> of one of its properties is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// An <see cref="ArgumentException"/> is thrown if any of the properties of <paramref name="data"/> is of the wrong type.
 /// </exception>
 /// <param name="data">The data to base the process on.</param>
 /// <param name="workingDirectory">The working directory of the process to start.</param>
 public VirtualProcessStartInfo(ApplicationData data, ApplicationFile workingDirectory)
 {
     if (data == null ||
         data.Files.RegistryDatabase == null ||
         data.Files.Executable == null ||
         data.Files.RootDirectory == null)
     {
         throw new ArgumentNullException("data", "The data argument or one of its properties is null.");
     }
     if (workingDirectory == null)
     {
         throw new ArgumentNullException("workingDirectory", "The workingDirectory argument is null.");
     }
     if (data.Files.Executable.Type != FileType.Executable)
     {
         throw new ArgumentException("The ApplicationData specified contains an illegal value for the main executable.",
                                     "data");
     }
     if (data.Files.RegistryDatabase.Type != FileType.Database)
     {
         throw new ArgumentException(
                   "The ApplicationData specified contains an illegal value for the registry database.",
                   "data");
     }
     if (workingDirectory.Type != FileType.Directory)
     {
         throw new ArgumentException("The working directory specified is not a directory.",
                                     "workingDirectory");
     }
     _files = new ApplicationFiles
     {
         RegistryDatabase
             = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.RegistryDatabase.FileName)),
         Executable
             = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.Executable.FileName)),
         RootDirectory
             = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.RootDirectory.FileName))
     };
     _arguments                = "";
     _workingDirectory         = workingDirectory;
     _fileSystemRuleCollection = data.Settings.FileSystemEngineRuleCollection ?? FileSystemRuleCollection.GetDefaultRuleCollection();
     _registryRuleCollection   = data.Settings.RegistryEngineRuleCollection ?? RegistryRuleCollection.GetDefaultRuleCollection();
 }
Exemplo n.º 14
0
        /// <summary>
        /// Starts a process from the <see cref="ApplicationData"/> loaded from the filename specified.
        /// </summary>
        /// <exception cref="FileNotFoundException">
        /// A <see cref="FileNotFoundException"/> is thrown if the <paramref name="applicationDataFile"/> can not be found.
        /// </exception>
        /// <exception cref="HostException">
        /// A <see cref="HostException"/> is thrown if the process can't be started.
        /// </exception>
        /// <param name="applicationDataFile">
        /// The file to load the <see cref="ApplicationData"/> from,
        /// representing the application to start.
        /// </param>
        public static void StartProcess(string applicationDataFile)
        {
            if (!File.Exists(applicationDataFile))
            {
                throw new FileNotFoundException("Unable to locate the virtual application's datafile.", applicationDataFile);
            }
            var data = ApplicationData.Load(applicationDataFile);

            if (data == null)
            {
                throw new HostException("\"" + applicationDataFile + "\""
                                        + " could not be found or contains invalid data while trying"
                                        + " to start a new process based on this file.");
            }
            var workingDirectory = new ApplicationFile(Path.GetDirectoryName(applicationDataFile));
            var startInfo        = new VirtualProcessStartInfo(data, workingDirectory);

            _process = VirtualizedProcess.Start(startInfo);
        }
 public bool UploadApplicationFile(string route, ApplicationFile appFile)
 {
     if (appFile.File.Length > 0)
     {
         try
         {
             using (FileStream filestream = System.IO.File.Create(route + "/" + appFile.File.FileName))
             {
                 appFile.File.CopyTo(filestream);
                 filestream.Flush();
                 return(true);
             }
         }
         catch (Exception e)
         {
             Console.WriteLine("Upload Application File catch" + e);
         }
     }
     return(false);
 }
Exemplo n.º 16
0
        public IHttpActionResult AddApplicationFile(ApplicationFile value)
        {
            var result = objApplicationFileRepository.Save(value);

            return(Ok(result));
        }
Exemplo n.º 17
0
        private ApplicationDefinition CreateApplicationDefinition(List <Reference> references, IEnumerable <PackageFile> files)
        {
            var defaultEnvironments = DefaultEnvironments.Select(
                e => ( TargetEnvironment )Enum.Parse(typeof(TargetEnvironment), e));

            var scripts = files.Where(f => f.Environment != TargetEnvironment.None);
            var specifiedEnvironments = scripts.Where(f => f.Environment != TargetEnvironment.All).Select(f => f.Environment).Distinct();

            specifiedEnvironments = specifiedEnvironments.Union(defaultEnvironments);

            Guid = Guid.Replace("{", "").Replace("}", "");
            ApplicationDefinition appdef = new ApplicationDefinition
            {
                Name                  = ApplicationName,
                Guid                  = Guid,
                Version               = ApplicationVersion,
                Description           = Description,
                Publisher             = Publisher,
                Copyright             = Copyright,
                RequiredMFilesVersion = MFilesVersion,
                EnabledByDefault      = EnabledByDefault,
                Optional              = Optional,
                MasterApplicationGuid = MasterApplicationGuid,
                Platforms             = Platforms.Select(platformName => new Platform(platformName)).ToList()
            };

            // Create the module elements.
            foreach (var env in specifiedEnvironments)
            {
                var module = new ApplicationModule {
                    Environment = env.ToString().ToLower()
                };
                appdef.Modules.Add(module);

                // Add the bootstrap scripts.
                module.Files.Add(new ApplicationFile {
                    Name = "_package_start.js"
                });

                // Add javascript files from the references.
                foreach (var r in references)
                {
                    var referencedScripts = r.GetScriptsForEnvironment(env);
                    foreach (var script in referencedScripts)
                    {
                        var file = new ApplicationFile {
                            Name = r.PackageName + "/" + script
                        };
                        module.Files.Add(file);
                    }
                }

                // Add the application's own javascript files.
                var environmentScripts = scripts.Where(s => s.Environment == TargetEnvironment.All || s.Environment == env);
                foreach (var script in environmentScripts)
                {
                    var file = new ApplicationFile {
                        Name = script.PathInProject
                    };
                    module.Files.Add(file);
                }

                module.Files.Add(new ApplicationFile {
                    Name = "_package_end.js"
                });
            }

            foreach (var db in files.Where(f => f.IsDashboard))
            {
                var dashboard = new ApplicationDashboard
                {
                    Id      = Path.GetFileNameWithoutExtension(db.PathInProject),
                    Content = db.PathInProject
                };
                appdef.Dashboards.Add(dashboard);
            }

            foreach (var r in references)
            {
                foreach (var db in r.GetDashboards())
                {
                    var dashboard = new ApplicationDashboard
                    {
                        Id      = db.Key,
                        Content = r.PackageName + "/" + db.Value
                    };
                    appdef.Dashboards.Add(dashboard);
                }
            }

            return(appdef);
        }
        public bool CreateApplicationFolder(int appId, string categoryName, string projectName, string fileName, string bundleIdentifier, ApplicationFile appFile)
        {
            string applicationPath = rootPath + "/" + projectName + "/" + categoryName + "/" + Convert.ToString(appId);
            string ipaPath         = ipaRootPath + "/" + projectName + "/" + categoryName + "/" + Convert.ToString(appId);

            // Console.WriteLine(applicationPath);
            CreateCategoryFolder(projectName, categoryName);
            if (FileExists(applicationPath) == false)
            {
                System.IO.Directory.CreateDirectory(applicationPath);
                if (UploadApplicationFile(applicationPath, appFile))
                {
                    FileOperationLibrary.ManifestPlist manifest = new FileOperationLibrary.ManifestPlist();
                    manifest.CreateManifest(applicationPath, ipaPath + "/" + appFile.File.FileName, bundleIdentifier, Convert.ToString(appId), projectName);
                }
                else
                {
                    // Console.WriteLine("file upload error");
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Method to loads the mapped files associated with the mapped product.
        /// </summary>
        /// <param name="loginObject">Object containing the login credentials.</param>
        /// <returns>Collection of MappedFile objects.</returns>
        public MappedFileCollection GetMappedFiles(ref Login loginObject)
        {
            //
            // get the feed response string
            //
            string responseFromServer = ApplicationFile.GetFeedResponse(new Uri(BASE_URL + "mappedproductfiles.aspx?mappedproductid=" + this.ID.ToString()), ref loginObject);

            XmlNamespaceManager namespaceMgr;

            //
            // get the entry nodes from the XML
            //
            XmlNodeList entryNodes = ApplicationFile.GetEntryNodes(responseFromServer, out namespaceMgr);

            //
            // create an empty mapped file collection object.
            //
            MappedFileCollection mappedFileCollection = new MappedFileCollection(entryNodes.Count);

            //
            // parse the entry elements and load the product objects
            //
            foreach (XmlNode entryNode in entryNodes)
            {
                MappedFile mappedFile = new MappedFile();

                //title - file name
                mappedFile.Name = entryNode.SelectSingleNode("atom:title", namespaceMgr).InnerText;

                //id - file id
                mappedFile.ID = int.Parse(entryNode.SelectSingleNode("atom:id", namespaceMgr).InnerText);

                // updated - file date modified
                mappedFile.DateModifiedLocal = DateTime.Parse(entryNode.SelectSingleNode("atom:updated", namespaceMgr).InnerText).ToLocalTime();

                // published - file date created
                mappedFile.DateCreatedLocal = DateTime.Parse(entryNode.SelectSingleNode("atom:published", namespaceMgr).InnerText).ToLocalTime();

                // link - href - events link
                //mappedFile.EventsLink = new Uri(entryNode.SelectSingleNode("atom:link", namespaceMgr).Attributes["href"].Value);

                // file version
                mappedFile.Version = entryNode.SelectSingleNode("wer:fileVersion", namespaceMgr).InnerText;

                // file link date
                mappedFile.LinkDateLocal = DateTime.Parse(entryNode.SelectSingleNode("wer:fileLinkDate", namespaceMgr).InnerText).ToLocalTime();

                // mapped by
                mappedFile.MappedBy = entryNode.SelectSingleNode("wer:mappedBy", namespaceMgr).InnerText;

                // mapped by e-mail
                mappedFile.MappedByEmail = entryNode.SelectSingleNode("wer:mappedByEmail", namespaceMgr).InnerText;

                // status
                mappedFile.Status = entryNode.SelectSingleNode("wer:status", namespaceMgr).InnerText;

                //
                // add the file to the file collection
                //
                mappedFileCollection.Add(mappedFile);
            }

            //
            // return the file collection
            //
            return(mappedFileCollection);
        }
Exemplo n.º 20
0
        public ActionResult SaveResume(HttpPostedFileBase file, Guid id = new Guid())
        {
            try {
                JobBoardDataContext db = new JobBoardDataContext();
                Application app = db.Applications.Where(x => x.id.Equals(id)).FirstOrDefault<Application>();

                if (file != null && file.ContentLength > 0) {
                    string fileName = Path.GetFileName(file.FileName);
                    string name = (Request.Form["name"] != null && Request.Form["name"].Length > 0) ? Request.Form["name"] : "";

                    Stream uploadedFile = file.InputStream;
                    int slength = Convert.ToInt32(uploadedFile.Length);
                    byte[] fileData = new byte[slength];
                    uploadedFile.Read(fileData, 0, slength);
                    uploadedFile.Close();

                    ApplicationFile afile = new ApplicationFile {
                        id = Guid.NewGuid(),
                        app_id = app.id,
                        fileName = fileName,
                        name = name,
                        size = fileData.Length,
                        fileContent = fileData
                    };

                    if (afile.isTypeAllowed() && afile.isSizeAllowed()) {
                        db.ApplicationFiles.InsertOnSubmit(afile);
                        db.SubmitChanges();
                    } else {
                        if (!afile.isSizeAllowed()) {
                            throw new Exception("File is too large!");
                        }
                        if (!afile.isTypeAllowed()) {
                            throw new Exception("File type not allowed!");
                        }
                    }
                }

                return Redirect("/Job/Resume/" + id);
            } catch (Exception e) {
                TempData["error"] = e.Message;
                return Redirect("/Job/Resume/" + id);
            }
        }
Exemplo n.º 21
0
        private void UpdateEvents(DateTime lastPullDate, IErrorIndex errorIndex,
                                  StackHashProduct stackHashProduct, bool getCabs, ApplicationFile file, StackHashFile stackHashFile)
        {
            // Get the events for the file with the start date as last pull date + 1.
            // Only stores the last 90 days worth - this will exception if you specify a date
            // before that time. In the case of the last pulldown date being close to 90 days ago
            // just get ALL the events.
            DateTime        startTime = lastPullDate; // This is a local time.
            EventPageReader eventPageReader;
            TimeSpan        timeSinceLastSync = (DateTime.UtcNow - lastPullDate.ToUniversalTime());

            if (timeSinceLastSync.Days >= 89)
            {
                StackHashUtilities.DiagnosticsHelper.LogMessage(DiagSeverity.Information,
                                                                String.Format(CultureInfo.InvariantCulture, "Updating Events for {0} {1} ALL",
                                                                              stackHashProduct.Name, stackHashFile.Name));

                eventPageReader = file.GetEvents(); // Get all events.
            }
            else
            {
                StackHashUtilities.DiagnosticsHelper.LogMessage(DiagSeverity.Information,
                                                                String.Format(CultureInfo.InvariantCulture, "Updating Events for {0} {1} since {2} {3}",
                                                                              stackHashProduct.Name, stackHashFile.Name, startTime, startTime.Kind));
                eventPageReader = file.GetEvents(startTime);
            }

            // Read each page of new events.
            while (eventPageReader.Read(ref m_Login) == true)
            {
                if (m_AbortRequested)
                {
                    throw new OperationCanceledException("Abort requested during Win Qual synchronize");
                }

                // Get the events for the page.
                EventReader events = eventPageReader.Events;

                while (events.Read() == true)
                {
                    if (m_AbortRequested)
                    {
                        throw new OperationCanceledException("Abort requested during Win Qual synchronize");
                    }

                    // Get the event
                    Event dpEvent = events.Event;

                    StackHashEvent stackHashEvent = ObjectConversion.ConvertEvent(dpEvent, stackHashFile.Id);

                    m_SyncProgress.EventId       = stackHashEvent.Id;
                    m_SyncProgress.EventTypeName = stackHashEvent.EventTypeName;

                    // Check the date created. If it is greater than the last
                    // pull date then this is a new event and hence insert.
                    if (dpEvent.DateCreatedLocal > lastPullDate)
                    {
                        errorIndex.AddEvent(stackHashProduct, stackHashFile, stackHashEvent);
                    }
                    else if (dpEvent.DateModifiedLocal > lastPullDate)
                    {
                        // update the event information if event modified
                        // date is greater than the last pull date
                        errorIndex.AddEvent(stackHashProduct, stackHashFile, stackHashEvent);
                    }
                    else
                    {
                        // Check if the event exists. If not then add it.
                        if (!errorIndex.EventExists(stackHashProduct, stackHashFile, stackHashEvent))
                        {
                            errorIndex.AddEvent(stackHashProduct, stackHashFile, stackHashEvent);
                        }
                    }

                    // Get the details for the event.
                    EventInfoCollection infoCollection = dpEvent.GetEventDetails(ref m_Login);

                    // Loop through the event info.
                    StackHashEventInfo           stackHashEventInfo           = null;
                    StackHashEventInfoCollection stackHashEventInfoCollection = new StackHashEventInfoCollection();
                    foreach (EventInfo info in infoCollection)
                    {
                        if (m_AbortRequested)
                        {
                            throw new OperationCanceledException("Abort requested during Win Qual synchronize");
                        }

                        stackHashEventInfo = ObjectConversion.ConvertEventInfo(info);
                        stackHashEventInfoCollection.Add(stackHashEventInfo);
                    }

                    errorIndex.MergeEventInfoCollection(stackHashProduct, stackHashFile, stackHashEvent, stackHashEventInfoCollection);

                    // Now get the total hits.
                    StackHashEventInfoCollection newEventInfos = errorIndex.LoadEventInfoList(stackHashProduct, stackHashFile, stackHashEvent);

                    int hits = 0;
                    foreach (StackHashEventInfo theEvent in newEventInfos)
                    {
                        hits += theEvent.TotalHits;
                    }

                    // Update the hits count.
                    stackHashEvent.TotalHits = hits;
                    errorIndex.AddEvent(stackHashProduct, stackHashFile, stackHashEvent);

                    if (getCabs)
                    {
                        UpdateCabs(lastPullDate, errorIndex, stackHashProduct, dpEvent, stackHashFile, stackHashEvent);
                    }
                }
            }
        }
Exemplo n.º 22
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);
        }