public void TestDoQuerySkip()
        {
            var executor          = new MockArchiveExecutor();
            var dateTimeConverter = new Mock <IDateTimeConverter>();
            var man = new ArchiveManager <PropertyHelperTestCompany>(executor, dateTimeConverter.Object, new ArchiveExecutionContextProvider());

            var result = man.DoQuery(new LinqRestrictionBuilder <PropertyHelperTestCompany>(), noItems: 0, skip: 13);

            Assert.Equal(1, executor.Page);
            Assert.Equal(0, executor.MaxItems);
            Assert.Equal(13, executor.Parameters.PageSize);
        }
Ejemplo n.º 2
0
        private GameOnPc RetrieveGameInArchive(string compressedFilePath)
        {
            GameOnPc game = null;

            WriteInfo($"Checking archive {compressedFilePath}...");
            IArchive archive;

            try
            {
                archive = ArchiveFactory.Open(new FileInfo(compressedFilePath));
            }
            catch (Exception ex)
            {
                WriteError($"Could not open archive {compressedFilePath}. Error: {ex.Message}");
                CopyProgressBar.Value += 10;
                CopyProgressBar.Refresh();
                return(null);
            }

            if (ArchiveManager.RetreiveUniqueFileFromArchiveEndingWith(archive, ".gdi") == null)
            {
                WriteWarning($"Could not find GDI in archive {compressedFilePath} (CDI are ignored in archives)");
                CopyProgressBar.Value += 10;
                CopyProgressBar.Refresh();
                return(null);
            }
            else
            {
                try
                {
                    if (archive.Type == SharpCompress.Common.ArchiveType.SevenZip && !viewModel.MustScanSevenZip)
                    {
                        WriteWarning($"Archive {compressedFilePath} ignored as it's a 7z file and the option isn't ticked.");
                        CopyProgressBar.Value += 10;
                        CopyProgressBar.Refresh();
                        return(null);
                    }

                    game = GameManager.ExtractPcGameDataFromArchive(compressedFilePath, archive);
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message);
                    CopyProgressBar.Value += 10;
                    CopyProgressBar.Refresh();
                    return(null);
                }
            }
            CopyProgressBar.Value += 10;
            CopyProgressBar.Refresh();

            return(game);
        }
        protected override void ProcessRecord()
        {
            if (!ID.IsNullOrEmpty(ItemId))
            {
                var archivalId = Archive.GetArchivalId(ItemId);
                if (!ShouldProcess(ItemId.ToString(), "Restore items by Item Id"))
                {
                    return;
                }

                WriteVerbose($"Restoring item {ItemId} from the archive {Archive.Name}");
                Archive.RestoreItem(archivalId);
            }
            else if (Identity != null)
            {
                var user = User.FromName(Identity.Name, false);
                if (user == null)
                {
                    return;
                }
                if (!ShouldProcess(Identity.ToString(), "Restore items by User"))
                {
                    return;
                }

                var entryCount = Archive.GetEntryCountForUser(user);
                var entries    = Archive.GetEntriesForUser(user, 0, entryCount);
                foreach (var entry in entries)
                {
                    WriteVerbose($"Restoring item {entry.ItemId} from the archive {entry.ArchiveName} in database {entry.Database.Name}");
                    Archive.RestoreItem(entry.ArchivalId);
                }
            }
            else if (ArchiveItem != null)
            {
                foreach (var entry in ArchiveItem)
                {
                    var archivalId = entry.ArchivalId;
                    if (!ShouldProcess(entry.ItemId.ToString(), "Restore items by ArchiveItem"))
                    {
                        return;
                    }

                    var archive = ArchiveManager.GetArchive(entry.ArchiveName, entry.Database);
                    if (archive == null)
                    {
                        return;
                    }
                    WriteVerbose($"Restoring item {entry.ItemId} from the archive {entry.ArchiveName} in database {entry.Database.Name}");
                    archive.RestoreItem(archivalId);
                }
            }
        }
Ejemplo n.º 4
0
        private static void StepLoadAnimGroups()
        {
            foreach (var path in Config.GetPaths("anim_groups_paths"))
            {
                AnimationGroup.Load(ArchiveManager.PathToCaseSensitivePath(path));
            }

            // load custom anim groups from resources
            TextAsset textAsset = Resources.Load <TextAsset>("Data/auxanimgrp");

            AnimationGroup.LoadFromStreamReader(new StreamReader(new MemoryStream(textAsset.bytes)));
        }
Ejemplo n.º 5
0
        private static void StepLoadCollision()
        {
            int numCollisionFiles = 0;

            foreach (var colFile in ArchiveManager.GetFileNamesWithExtension(".col"))
            {
                CollisionFile.Load(colFile);
                numCollisionFiles++;
            }

            Debug.Log("Number of collision files " + numCollisionFiles);
        }
Ejemplo n.º 6
0
    private void buttonUninstallSelected_Click(object sender, EventArgs e)
    {
        ModInfo selMod = GetSelectedMod();

        if (!selMod)
        {
            return;
        }

        ArchiveManager.UninstallSelected(selMod);
        ArchiveManager.DeleteEmptyDirs(Serializer.GetGameModFolder());
    }
Ejemplo n.º 7
0
        public OpenKhGame(string[] args)
        {
            var contentPath = args.FirstOrDefault() ?? Config.DataPath;

            _dataContent = CreateDataContent(contentPath, Config.IdxFilePath, Config.ImgFilePath);
            if (Kernel.IsReMixFileHasHdAssetHeader(_dataContent, "fm"))
            {
                Log.Info("ReMIX files with HD asset header detected");
                _dataContent = new HdAssetContent(_dataContent);
            }

            _dataContent = new SafeDataContent(_dataContent);

            _kernel = new Kernel(_dataContent);
            var resolutionWidth  = GetResolutionWidth();
            var resolutionHeight = GetResolutionHeight();

            Log.Info($"Internal game resolution set to {resolutionWidth}x{resolutionHeight}");

            graphics = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = (int)Math.Round(resolutionWidth * Config.ResolutionBoost),
                PreferredBackBufferHeight = (int)Math.Round(resolutionHeight * Config.ResolutionBoost),
                IsFullScreen = Config.IsFullScreen,
            };

            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            archiveManager = new ArchiveManager(_dataContent);
            inputManager   = new InputManager();
            _debugOverlay  = new DebugOverlay(this);

            Config.OnConfigurationChange += () =>
            {
                var resolutionWidth  = GetResolutionWidth();
                var resolutionHeight = GetResolutionHeight();

                var backBufferWidth  = (int)Math.Round(resolutionWidth * Config.ResolutionBoost);
                var backBufferHeight = (int)Math.Round(resolutionHeight * Config.ResolutionBoost);

                if (graphics.PreferredBackBufferWidth != backBufferWidth ||
                    graphics.PreferredBackBufferHeight != backBufferHeight ||
                    graphics.IsFullScreen != Config.IsFullScreen)
                {
                    graphics.PreferredBackBufferWidth  = backBufferWidth;
                    graphics.PreferredBackBufferHeight = backBufferHeight;
                    graphics.IsFullScreen = Config.IsFullScreen;
                    _isResolutionChanged  = true;
                    Log.Info($"Internal game resolution set to {resolutionWidth}x{resolutionHeight}");
                }
            };
        }
Ejemplo n.º 8
0
        public static bool GenerateProcuratoryFile(IDataManager dataManager, ArchiveManager archiveManager, List <Procuratory> procuratories, string saveTo, bool autoCounting = false)
        {
            var procuratory = procuratories.First();

            if (procuratory == null)
            {
                return(false);
            }

            var auction = dataManager.GetAuction((int)procuratory.auctionId);

            if (auction == null)
            {
                return(false);
            }

            var supplierOrder = dataManager.GetSupplierOrder(auction.Id, procuratory.SupplierId);

            if (supplierOrder == null)
            {
                return(false);
            }

            var supplierJournal = dataManager.GetSupplierJournal(supplierOrder.brokerid, procuratory.SupplierId);

            if (supplierJournal == null)
            {
                return(false);
            }

            var templateRequisite = archiveManager.GetTemplateRequisite((MarketPlaceEnum)auction.SiteId, DocumentTemplateEnum.Procuratory);

            if (templateRequisite == null)
            {
                return(false);
            }

            archiveManager.GetDocument(templateRequisite, saveTo);

            supplierOrder.Code = supplierJournal.code;
            var order = new Order();

            order.Auction = auction;
            order.Auction.SupplierOrders.Clear();
            order.Auction.SupplierOrders.Add(supplierOrder);
            order.Auction.Procuratories.Clear();
            procuratories.ForEach(p => order.Auction.Procuratories.Add(p));

            DocumentFormation.ProcuratoriesService.FormateProcuratory(saveTo, order, autoCounting: autoCounting);

            return(true);
        }
Ejemplo n.º 9
0
        public BaseGame ExtractGameDataFromArchive(string archivePath, IArchive archive)
        {
            var archiveFileInfo = new FileInfo(archivePath);
            var game            = new BaseGame
            {
                FullPath      = archivePath,
                Path          = archivePath.Split(Path.DirectorySeparatorChar).Last(),
                Size          = archiveFileInfo.Length,
                FormattedSize = FileManager.FormatSize(archiveFileInfo.Length)
            };

            IArchiveEntry gdiEntry = ArchiveManager.RetreiveUniqueFileFromArchiveEndingWith(archive, ".gdi");

            if (gdiEntry != null)
            {
                string gdiContentInSingleLine;
                using (var ms = new MemoryStream())
                {
                    gdiEntry.WriteTo(ms);
                    gdiContentInSingleLine = Encoding.UTF8.GetString(ms.ToArray());
                }

                var gdiContent = new List <string>(
                    gdiContentInSingleLine.Split(new string[] { "\r\n", "\n" },
                                                 StringSplitOptions.RemoveEmptyEntries));

                game.GdiInfo = GetGdiFromStringContent(gdiContent);
                game.IsGdi   = true;
                var track3 = game.GdiInfo.Tracks.Single(t => t.TrackNumber == 3);
                if (track3.Lba != 45000)
                {
                    throw new Exception("Bad track03.bin LBA");
                }

                bool isRawMode = track3.SectorSize == 2352; // 2352/RAW mode or 2048

                var track3Entry = ArchiveManager.RetreiveUniqueFileFromArchiveEndingWith(archive, track3.FileName);
                using (var track3Stream = track3Entry.OpenEntryStream())
                {
                    if (isRawMode)
                    {
                        // We ignore the first line
                        byte[] dummyBuffer = new byte[16];
                        track3Stream.Read(dummyBuffer, 0, 16);
                    }

                    ReadGameInfoFromBinaryData(game, track3Stream);
                }
            }

            return(game);
        }
Ejemplo n.º 10
0
        public void RegisterGamefiles()
        {
            FileInfo[]    archiveFiles = null;
            DirectoryInfo archiveDir   = new DirectoryInfo(Path.Combine(this.gamePath.FullName, "../../archive/pc/content"));

            archiveFiles = archiveDir.GetFiles("*.archive");

            foreach (FileInfo fi in archiveFiles)
            {
                Console.WriteLine(String.Format("Adding archive ({0})...", fi.Name));
                ArchiveManager.AddArchive(fi);
            }
        }
        public List <DocumentRequisite> GetDocuments(int auctionId)
        {
            var auction = DataManager.GetAuction(auctionId);

            if (auction == null || auction.CustomerId != CurrentUser.CustomerId)
            {
                throw new AltaHttpResponseException(System.Net.HttpStatusCode.Forbidden, "Not found auction");
            }

            var documents = ArchiveManager.GetFilesFromList(auction.FilesListId);

            return(documents);
        }
Ejemplo n.º 12
0
    private void installAllFilesToolStripMenuItem_Click(object sender, EventArgs e)
    {
        ModInfo selMod = GetSelectedMod();

        if (!selMod)
        {
            return;
        }

        buttonCheckAll_Click(null, null);
        ArchiveManager.InstallSelected(selMod);
        ArchiveManager.DeleteEmptyDirs(Serializer.GetGameModFolder());
    }
Ejemplo n.º 13
0
        private void DefaultParametrs()
        {
            archiveManager = new ArchiveManager(dataManager);

            SuppliersListStorage = dataManager.GetSuppliersWithContract();
            BrokersList          = DataBaseClient.ReadBrokers();
            SelectedBroker       = BrokersList[0];
            FromDate             = DateTime.Now.AddDays(-14);
            ToDate         = DateTime.Now;
            StatusesList   = DataBaseClient.ReadStatuses().Where(s => s.id > 8).ToList();
            SelectedStatus = StatusesList[0];

            FormateDate = DateTime.Now;
        }
Ejemplo n.º 14
0
        public static TextureDictionary Load(string name)
        {
            name = name.ToLower();
            if (_sLoaded.ContainsKey(name))
            {
                return(_sLoaded[name]);
            }

            var txd = new TextureDictionary(ArchiveManager.ReadFile <RenderWareStream.TextureDictionary>(name + ".txd"));

            _sLoaded.Add(name, txd);

            return(txd);
        }
Ejemplo n.º 15
0
        private void RemoveVersion(Item item)
        {
            var itemSig = $"{item.Database}:{item.ID}/{item.Language}#{item.Version}";

            if (ProcessedList.Contains(itemSig))
            {
                return;
            }

            ProcessedList.Add(itemSig);
            if (!ShouldProcess(item.GetProviderPath() + ", Lang:" + item.Language.Name + ", Ver:" + item.Version.Number, confirmMessage))
            {
                return;
            }

            var hasArchive     = IsParameterSpecified(nameof(Archive));
            var hasPermanently = IsParameterSpecified(nameof(Permanently));

            if (hasArchive && hasPermanently)
            {
                WriteError(typeof(ParameterBindingException), "Parameter set cannot be resolved using the specified named parameters. Detected Archive and Permanently parameters provided.", ErrorIds.AmbiguousParameterSet, ErrorCategory.InvalidOperation, null);
                return;
            }

            if (IsParameterSpecified("Archive"))
            {
                var archive = ArchiveManager.GetArchive("archive", item.Database);
                if (archive == null)
                {
                    return;
                }
                WriteVerbose($"Removing item {itemSig} and moving to the archive {archive.Name} in database {item.Database}");
                archive.ArchiveVersion(item);
            }
            else if (IsParameterSpecified("Permanently"))
            {
                WriteVerbose($"Removing item {itemSig} permanently.");
                item.Versions.RemoveVersion();
            }
            else
            {
                var archive = ArchiveManager.GetArchive("recyclebin", item.Database);
                if (archive == null)
                {
                    return;
                }
                WriteVerbose($"Removing item {itemSig} and moving to the archive {archive.Name} in database {item.Database}");
                archive.ArchiveVersion(item);
            }
        }
        public async Task ArchiveLogFiles_ArchiveSuccess_ReturnTrue(string startTime, string endTime)
        {
            // Arrange
            mockArchiveService.Setup(x => x.ArchiveLogFiles(new List <string>())).Returns(Task.FromResult(true));

            IArchiveManager archiveManager = new ArchiveManager(mockArchiveService.Object, mockFolderHandlerService.Object);

            // Act
            var archiveResult = await archiveManager.ArchiveLogFiles(DateTimeOffset.Parse(startTime),
                                                                     DateTimeOffset.Parse(endTime));

            // Assert
            Assert.IsTrue(archiveResult.WasSuccessful);
        }
        public async Task ArchiveLogFiles_IOException_ReturnFalse(string startTime, string endTime, ErrorMessage error)
        {
            // Arrange
            mockArchiveService.Setup(x => x.ArchiveLogFiles(new List <string>())).Throws(new IOException());

            IArchiveManager archiveManager = new ArchiveManager(mockArchiveService.Object, mockFolderHandlerService.Object);

            // Act
            var archiveResult = await archiveManager.ArchiveLogFiles(DateTimeOffset.Parse(startTime), DateTimeOffset.Parse(endTime));

            // Assert
            Assert.IsFalse(archiveResult.WasSuccessful);
            Assert.IsTrue(archiveResult.ErrorMessage == error);
        }
        public async Task DeleteArchivedFiles_DeleteFailure_ReturnFalse(string startTime, string endTime)
        {
            // Arrange
            mockArchiveService.Setup(x => x.DeleteArchivedFiles(new List <string>())).Returns(Task.FromResult(false));

            IArchiveManager archiveManager = new ArchiveManager(mockArchiveService.Object, mockFolderHandlerService.Object);

            // Act
            var deleteResult = await archiveManager.DeleteArchivedFiles(DateTimeOffset.Parse(startTime),
                                                                        DateTimeOffset.Parse(endTime));

            // Assert
            Assert.IsFalse(deleteResult.WasSuccessful);
        }
Ejemplo n.º 19
0
        public List <DocumentRequisite> GetCommerticals(int companyId)
        {
            var company = DataManager.GetCompany(companyId);

            if (company == null)
            {
                throw new AltaHttpResponseException(HttpStatusCode.NotFound, "Not found \"company\".");
            }

            return(ArchiveManager.GetFilesInfo(company.filesListId, new List <int>()
            {
                (int)DocumentTypeEnum.CommercialOffer
            }));
        }
Ejemplo n.º 20
0
 private static void LoadAsync(string collFileName, CollisionFileInfo collFileInfo, System.Action <CollisionFile> onFinish)
 {
     ArchiveManager.ReadFileAsync(collFileName, (stream) => {
         CollisionFile cf = null;
         try {
             using (stream)
             {
                 cf = new CollisionFile(collFileInfo, stream);
             }
         } finally {
             onFinish(cf);
         }
     });
 }
Ejemplo n.º 21
0
        private void ArchiveItem(Database db, string itemID)
        {
            Item jobItem = db.GetItem(new ID(itemID));

            if (jobItem != null)
            {
                using (new Sitecore.SecurityModel.SecurityDisabler())
                {
                    Archive archive = ArchiveManager.GetArchive("archive", jobItem.Database);
                    archive.ArchiveItem(jobItem);
                    Log.Info(string.Format("Sitecron - Item Archived. (ItemID: {0} Archive:{1} DB: {2})", itemID, db.Name), this);
                }
            }
        }
        public List <DocumentRequisite> getOtherDocumentsForCompany(int supplierId)
        {
            var company = DataManager.GetCompanySupplier(supplierId);

            if (company == null)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(ArchiveManager.GetFilesInfo(company.filesListId, new List <int>()
            {
                (int)DocumentTypeEnum.Other
            }));
        }
        public List <DocumentRequisite> getContractsDocuments()
        {
            var company = DataManager.GetCompany(CurrentUser.CompanyId);

            if (company == null)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(ArchiveManager.GetFilesInfo(company.filesListId, new List <int>()
            {
                (int)DocumentTypeEnum.Contract
            }));
        }
Ejemplo n.º 24
0
        static void Main()
        {
            CR2WLib.Types.CR2WValue.RegisterTypes();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            String gamePath = Properties.Settings.Default["CPGamePath"].ToString();

            try
            {
                DirectoryInfo dirInfo = new DirectoryInfo(gamePath);
                if (!dirInfo.Exists)
                {
                    gamePath = "";
                }
            } catch (Exception e)
            {
                Console.Error.Write(e);
                gamePath = "";
            }

            if (gamePath == "")
            {
                OpenFileDialog searchCPDialog = new OpenFileDialog();
                searchCPDialog.FileName         = "Cyberpunk2077.exe";
                searchCPDialog.Title            = "Select cyberpunk 2077 executable...";
                searchCPDialog.Filter           = "Cyberpunk 2077|Cyberpunk2077.exe";
                searchCPDialog.RestoreDirectory = false;
                searchCPDialog.CheckFileExists  = true;

                if (searchCPDialog.ShowDialog() == DialogResult.OK)
                {
                    Properties.Settings.Default["CPGamePath"] = Path.GetDirectoryName(searchCPDialog.FileName);
                    Properties.Settings.Default.Save();

                    gamePath = Properties.Settings.Default["CPGamePath"].ToString();
                }
            }

            CyberpunkGame game = new CyberpunkGame(gamePath);

            game.RegisterGamefiles();

            OodleCompression.LoadLibrary(game.GamePath);
            ArchiveManager.Initialize();

            Application.Run(new Browser());
        }
        public async Task ArchiveLogFiles_NoValidLogs_ReturnFalse(string startTime, string endTime, string message, LogLevel logLevel,
                                                                  LogTarget logTarget)
        {
            // Arrange
            logService.Log(message, logTarget, logLevel, this.ToString(), "Test_Logs");
            logService.Log(message, logTarget, logLevel, this.ToString(), "User_Logging");

            IArchiveManager archiveManager = new ArchiveManager(archiveService, folderHandlerService);

            // Act
            var result = await archiveManager.ArchiveLogFiles(DateTimeOffset.Parse(startTime), DateTimeOffset.Parse(endTime));

            // Assert
            Assert.IsFalse(result.WasSuccessful);
        }
Ejemplo n.º 26
0
        public void Initialize(StateInitDesc initDesc)
        {
            _kernel         = initDesc.Kernel;
            _dataContent    = initDesc.DataContent;
            _archiveManager = initDesc.ArchiveManager;
            _graphics       = initDesc.GraphicsDevice;
            _input          = initDesc.InputManager;
            _shader         = new KingdomShader(initDesc.ContentManager);
            _camera         = new Camera()
            {
                CameraPosition             = new Vector3(0, 100, 200),
                CameraRotationYawPitchRoll = new Vector3(90, 0, 10),
            };

            BasicallyForceToReloadEverything();
        }
Ejemplo n.º 27
0
        private void byPathToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileNameSearch searchInput = new FileNameSearch();

            if (searchInput.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    ArchiveManager.SearchFile(searchInput.FileName);
                    Console.WriteLine($"File {searchInput.FileName} found!");
                } catch (FileNotFoundException)
                {
                    Console.Error.WriteLine($"File {searchInput.FileName} not found!");
                }
            }
        }
Ejemplo n.º 28
0
        public MangaPage(bool addNewOnly, Uri uri, string title, string tempTitleWithNo = null)
            : base(addNewOnly, DaruUriParser.Manga.FixUri(uri), title)
        {
            this.TitleWithNo = tempTitleWithNo;

            var entry = ArchiveManager.GetManga(this.ArchiveCode);

            if (entry != null)
            {
                this.TitleWithNo = entry.TitleWithNo;
                this.ZipPath     = entry.ZipPath;
                this.State       = MaruComicState.Complete_2_Archived;

                MainWindow.Instance.WakeThread();
            }
        }
Ejemplo n.º 29
0
    public ModInfo(string modPath_)
    {
        modPath = modPath_;
        modName = Path.GetFileName(modPath);

        category = Path.GetFileName(Path.GetDirectoryName(modPath));

        sevZip = Path.GetExtension(modPath).ToLower() == ".7z";

        archiveFiles = ArchiveManager.GetArchiveFiles(this);

        if (File.Exists(modPath))
        {
            date = File.GetCreationTime(modPath);
        }
    }
        public List <DocumentRequisite> getDocuments(int auctionId)
        {
            var supplierOrder = DataManager.GetSupplierOrder(auctionId, CurrentUser.SupplierId);

            if (supplierOrder == null)
            {
                return(new List <DocumentRequisite>());
            }

            if (ArchiveManager == null)
            {
                throw new AltaHttpResponseException(HttpStatusCode.InternalServerError, "Not connection to archive manager.");
            }

            return(ArchiveManager.GetFilesFromList((int)supplierOrder.fileListId));
        }