Exemplo n.º 1
0
 public EntryNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Entry;
     file.Skip(0x2);
     mNextNode = file.ReadUInt16();
     file.Skip(0x6);
 }
Exemplo n.º 2
0
        public async Task <T> Open <T>(FileType fileType, string path)
            where T : FileBase
        {
            try
            {
                if (!path.EndsWith(fileType.Extension))
                {
                    path = path + "." + fileType.Extension;
                }

                if (path == null)
                {
                    return(null);
                }

                FileBase file = await Open(path, fileType);

                if (file is T tFile)
                {
                    return(tFile);
                }

                throw new Exception("file loaded was incorrect type");
            }
            catch (Exception ex)
            {
                Log.Write(new Exception("Failed to open file", ex), "Files", Log.Severity.Error);
            }

            return(null);
        }
Exemplo n.º 3
0
        private bool OpenFile(FileBase asset)
        {
            // cannot open files if this format is selected
            if ((asset as FileSDS) == null)
            {
                if (ToolkitSettings.UseSDSToolFormat)
                {
                    MessageBox.Show("These files are not supported with SDSTools format. Please navigate to the settings and de-select 'Use SDS Tool Format'", "Toolkit");
                    return(false);
                }
            }

            if (!asset.Open())
            {
                return(false);
            }

            if (asset is FileSDS)
            {
                OpenSDSDirectory(asset.GetUnderlyingFileInfo());
            }
            else
            {
                OpenDirectory(currentDirectory);
            }
            return(true);
        }
Exemplo n.º 4
0
        public Entry(ref FileBase file)
        {
            mTable   = new Dictionary <string, uint>();
            mEntries = new List <TableEntry>();

            int size = file.ReadInt32();

            file.Skip(0x8);
            int  loc   = file.Position();
            uint count = file.ReadUInt32();

            for (int i = 0; i < count; i++)
            {
                TableEntry e = new TableEntry();
                e.mIsValid = file.ReadUInt32();
                e.mPtr     = file.ReadInt32();

                mEntries.Add(e);

                if (e.mIsValid == 1)
                {
                    string str = file.ReadStringAt(loc + e.mPtr);
                    uint   val = file.ReadUInt32At(loc + e.mPtr + str.Length + 1);
                    mTable.Add(str, val);
                }
            }

            file.Seek(loc + size);

            while ((file.Position() % 0x10) != 0)
            {
                file.Skip(0x1);
            }
        }
Exemplo n.º 5
0
        private async void OnOpenClicked(object sender, RoutedEventArgs e)
        {
            IFileService fileService = Module.Services.Get <IFileService>();
            FileBase     file        = await fileService.OpenAny(EquipmentSetFile.FileType, LegacyEquipmentSetFile.FileType);

            if (file is LegacyEquipmentSetFile legacyFile)
            {
                file = legacyFile.Upgrade();
            }

            if (file is EquipmentSetFile eqFile)
            {
                eqFile.MainHand.Write(this.MainHand);
                eqFile.OffHand.Write(this.OffHand);
                eqFile.Head.Write(this.Head);
                eqFile.Body.Write(this.Body);
                eqFile.Hands.Write(this.Hands);
                eqFile.Legs.Write(this.Legs);
                eqFile.Feet.Write(this.Feet);
                eqFile.Ears.Write(this.Ears);
                eqFile.Neck.Write(this.Neck);
                eqFile.Wrists.Write(this.Wrists);
                eqFile.LeftRing.Write(this.LeftRing);
                eqFile.RightRing.Write(this.RightRing);
            }
        }
Exemplo n.º 6
0
 public ArchiveFileEntry(FileBase aFileBase, string aArchiveFileAndPath, bool aDataLoaded)
     : base(aFileBase.Name, aFileBase.GetFileType())
 {
     this.archivedFile       = aFileBase;
     this.dataLoaded         = aDataLoaded;
     this.archiveFileAndPath = aArchiveFileAndPath;
 }
        public void ConfigRepositoryRemoveSiteTest()
        {
            FileHelper.FileSystem = new MockFileSystem(new Dictionary <string, MockFileData>()
            {
                {
                    @"c:\site1.publishsettings",
                    new MockFileData(string.Format(ProfileTemplate, "site1"))
                },
                {
                    @"c:\site2.foo.publishsettings",
                    new MockFileData(string.Format(ProfileTemplate, "site2"))
                },
                { @"c:\foo.txt", new MockFileData("bar") },
                { @"c:\site1\", new MockDirectoryData() }
            });

            IConfigRepository repository = new ConfigRepository();

            repository.RemoveSite("site1");
            repository.RemoveSite("site2");

            FileBase      fileBase = FileHelper.FileSystem.File;
            DirectoryBase dirBase  = FileHelper.FileSystem.Directory;

            Assert.IsFalse(fileBase.Exists(@"c:\site1.publishSettings"), "site1 publishSettings still exists");
            Assert.IsFalse(dirBase.Exists(@"c:\site1"), "site1 folder still exists");
            Assert.IsFalse(fileBase.Exists(@"c:\site2.foo.publishsettings"), "sit2 publishSettings still exists");
        }
Exemplo n.º 8
0
        public MSBT(FileBase file)
        {
            if (file.ReadString(8) != "MsgStdBn")
            {
                throw new Exception("MSBT::MSBT() -- Invalid MSBT file!");
            }

            file.Skip(0x18);

            while (file.Position() != file.GetLength())
            {
                string magic = file.ReadString(4);

                switch (magic)
                {
                case "LBL1":
                    mLabels = new LBL1(ref file);
                    break;

                case "ATR1":
                    mAttributes = new ATR1(ref file);
                    break;

                case "TXT2":
                    mText = new TXT2(ref file);
                    break;
                }
            }
        }
Exemplo n.º 9
0
 public PictureGroup(ref FileBase file)
 {
     // idx + 0x30 done intentionally by Nintendo
     mCharIdx = Convert.ToUInt16(file.ReadUInt16() + 0x30);
     mFont    = file.ReadUInt16();
     mCharID  = file.ReadUInt16();
 }
Exemplo n.º 10
0
 private static void SetLoggerOptions(FileBase file)
 {
     file.Directory = ApplicationPath.Logs;
     file.MaxSizeMb = 1;
     file.FullFilePolicy = FullFilePolicy.Wrap;
     file.CircularStartSizeKb = 5;
 }
        public MockFileSystem(IDictionary <string, MockFileData> files, string currentDirectory = "")
        {
            if (string.IsNullOrEmpty(currentDirectory))
            {
                currentDirectory = IO.Path.GetTempPath();
            }

            pathVerifier = new PathVerifier(this);

            this.files           = new Dictionary <string, MockFileData>(StringComparer.OrdinalIgnoreCase);
            pathField            = new MockPath(this);
            file                 = new MockFile(this);
            directory            = new MockDirectory(this, file, currentDirectory);
            fileInfoFactory      = new MockFileInfoFactory(this);
            directoryInfoFactory = new MockDirectoryInfoFactory(this);
            driveInfoFactory     = new MockDriveInfoFactory(this);

            if (files != null)
            {
                foreach (var entry in files)
                {
                    AddFile(entry.Key, entry.Value);
                }
            }
        }
Exemplo n.º 12
0
 private static void SetLoggerOptions(FileBase file)
 {
     file.Directory           = ApplicationPath.Logs;
     file.MaxSizeMb           = 1;
     file.FullFilePolicy      = FullFilePolicy.Wrap;
     file.CircularStartSizeKb = 5;
 }
        public void Setup()
        {
            if (_referenceRepository is null)
            {
                _referenceRepository = new ReferenceRepository();
            }
            else
            {
                _referenceRepository.Reset();
            }

            _file = Substitute.For <FileBase>();
            _file.ReadAllText(_commitMessagePath, _encoding).Returns(_commitMessage);
            _file.ReadAllText(_mergeMessagePath, _encoding).Returns(_mergeMessage);
            _directory = Substitute.For <DirectoryBase>();

            var path = Substitute.For <PathBase>();

            path.Combine(Arg.Any <string>(), Arg.Any <string>()).Returns(x => Path.Combine((string)x[0], (string)x[1]));

            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(_file);
            _fileSystem.Directory.Returns(_directory);
            _fileSystem.Path.Returns(path);

            _manager = new CommitMessageManager(_workingDirGitDir, _encoding, _fileSystem, overriddenCommitMessage: null);
        }
Exemplo n.º 14
0
        static async Task <uint> CalcZipCrc32HandleAsync(FileBase src, CopyFileParams param, CancellationToken cancel)
        {
            ZipCrc32 srcCrc = new ZipCrc32();

            using (MemoryHelper.FastAllocMemoryWithUsing(param.BufferSize, out Memory <byte> buffer))
            {
                while (true)
                {
                    int readSize = await src.ReadAsync(buffer, cancel);

                    Debug.Assert(readSize <= buffer.Length);

                    if (readSize <= 0)
                    {
                        break;
                    }

                    ReadOnlyMemory <byte> sliced = buffer.Slice(0, readSize);

                    srcCrc.Append(sliced.Span);
                }
            }

            return(srcCrc.Value);
        }
Exemplo n.º 15
0
        protected GameObject Panel(GameObject parent, string name)
        {
            PanelContainerProfile profile   = Defaults.GetProfile(panelContainerProfile);
            FilePanelProfile      fpProfile = Defaults.GetProfile(filePanelProfile);
            PanelContainerFactory factory   = Undoable.AddComponent <PanelContainerFactory>(disposable);

            factory.parent                = parent;
            factory.containerName         = name;
            factory.panelContainerProfile = profile;
            GameObject panel = factory.Generate();

            filePanel                         = AddFilePanel(panel);
            filePanel.grabTarget              = filePanelContainerInstance.transform;
            filePanel.folderPrefab            = fpProfile.folderPrefab;
            filePanel.kineticScrollItemPrefab = kineticScrollerItem;
            filePanel.height                  = fpProfile.scrollerHeight;
            filePanel.searchPattern           = fpProfile.searchPattern;
            filePanel.panelProfile            = panelProfile;

#if VRTK
            CreateThis_VRTK_Interactable interactable = Undoable.AddComponent <CreateThis_VRTK_Interactable>(panel);
            CreateThis_VRTK_GrabAttach   grabAttach   = Undoable.AddComponent <CreateThis_VRTK_GrabAttach>(panel);
            interactable.isGrabbable = true;
            interactable.grabAttachMechanicScript = grabAttach;
#endif

            drives = Undoable.AddComponent <Drives>(panel);

            Rigidbody rigidbody = Undoable.AddComponent <Rigidbody>(panel);
            rigidbody.useGravity  = false;
            rigidbody.isKinematic = true;

            return(panel);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Loads all labels from a language file and hashes them.
        /// </summary>
        /// <param name="file">Language label file path.</param>
        /// <param name="game"><see cref="GameINT"/> of the file.</param>
        public static void LoadLangLabels(string file, GameINT game)
        {
            var      options = new Options(file);
            FileBase db      = game switch
            {
                GameINT.Carbon => new Support.Carbon.Datamap(),
                GameINT.MostWanted => new Support.MostWanted.Datamap(),
                GameINT.Underground2 => new Support.Underground2.Datamap(),
                GameINT.Prostreet => new Support.Prostreet.Datamap(),
                _ => null
            };

            if (db == null)
            {
                return;
            }
            db.Load(options);

            foreach (STRBlock str in db.GetManager("STRBlocks"))
            {
                foreach (var record in str.GetRecords())
                {
                    record.Text.BinHash();
                }
            }
        }
    }
Exemplo n.º 17
0
 public SystemSnapshotRecorder(DirectoryBase directory, FileBase file, string location)
 {
     this.directory             = directory;
     this.file                  = file;
     this.location              = location;
     this.pathToCurrentSnapshot = Path.Combine(this.location, TemporaryFilename);
 }
Exemplo n.º 18
0
        private async void OnLoadClicked(object sender, RoutedEventArgs e)
        {
            IFileService fileService = Services.Get <IFileService>();
            IViewService viewService = Services.Get <IViewService>();

            FileBase file = await fileService.OpenAny(
                LegacyEquipmentSetFile.FileType,
                LegacyAppearanceFile.AllFileType,
                AppearanceFile.FileType);

            if (file is LegacyAppearanceFile legacyAllFile)
            {
                file = legacyAllFile.Upgrade();
            }

            if (file is LegacyEquipmentSetFile legacyEquipmentFile)
            {
                file = legacyEquipmentFile.Upgrade();
            }

            if (file is AppearanceFile apFile)
            {
                AppearanceFile.SaveModes mode = await viewService.ShowDialog <AppearanceModeSelectorDialog, AppearanceFile.SaveModes>("Load Appearance...");

                if (mode == AppearanceFile.SaveModes.None)
                {
                    return;
                }

                apFile.Write(this.Appearance, this.Equipment, mode);
            }
        }
Exemplo n.º 19
0
        public VirtualFileSystem(IDictionary <string, VirtualFileData> files, string currentDirectory = "")
        {
            if (string.IsNullOrEmpty(currentDirectory))
            {
                currentDirectory = System.IO.Path.GetTempPath();
            }

            _pathVerifier = new PathVerifier(this);

            this._files           = new Dictionary <string, VirtualFileData>(StringComparer.OrdinalIgnoreCase);
            _pathField            = new VirtualPath(this);
            _file                 = new VirtualFile(this);
            _directory            = new VirtualDirectory(this, _file, currentDirectory);
            _fileInfoFactory      = new VirtualFileInfoFactory(this);
            _directoryInfoFactory = new VirtualDirectoryInfoFactory(this);
            _driveInfoFactory     = new VirtualDriveInfoFactory(this);

            if (files != null)
            {
                foreach (var entry in files)
                {
                    AddFile(entry.Key, entry.Value);
                }
            }
        }
Exemplo n.º 20
0
        public MSBF(FileBase file)
        {
            if (file.ReadString(0x8) != "MsgFlwBn")
            {
                throw new Exception("MSBF::MSBF() -- Not a valid MSBF file!");
            }

            file.Skip(0x18);

            while (file.Position() != file.GetLength())
            {
                string magic = file.ReadString(4);

                switch (magic)
                {
                case "FLW2":
                    mFlow = new Flow(ref file);
                    break;

                case "FEN1":
                    mEntries = new Entry(ref file);
                    break;

                case "REF1":
                    throw new Exception("MSBF::MSBF() -- REF1 section found, but this is not supported.");
                }
            }
        }
        public static void SafeAction(this FileBase fileBase, string file, Action <string> action)
        {
            if (fileBase == null)
            {
                throw new ArgumentNullException("fileBase");
            }
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException("file");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var tmp = String.Concat(file, ".tmp");

            action(tmp);
            if (!fileBase.Exists(tmp))
            {
                throw new InvalidOperationException("action must create a file");
            }

            //fileBase.Replace(tmp, file, null); write a TestHelper for Replace and make a pull request first
            fileBase.Delete(file);
            fileBase.Move(tmp, file);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 出库
        /// </summary>
        /// <param name="file">文件对象</param>
        /// <returns>存放容器Id</returns>
        public async Task <int> StockOut(FileBase file)
        {
            string errMessage;
            var    fileStoreInfo = await _fileStoreInfoRepository.FirstOrDefaultAsync(p => p.FileId == file.Id);

            if (fileStoreInfo != null)
            {
                switch (fileStoreInfo.StoreState)
                {
                case StoreState.在库:
                    fileStoreInfo.StoreState = StoreState.已出库;
                    return(fileStoreInfo.FileContainerId);

                case StoreState.已出库:
                    errMessage = $"档案编号[{file.DocumentSerialNumber}]的文件不在库中";
                    throw new UserFriendlyException(errMessage);

                case StoreState.已报废:
                    errMessage = $"档案编号[{file.DocumentSerialNumber}]的文件已报废";
                    throw new UserFriendlyException(errMessage);

                default:
                    errMessage = $"档案编号[{file.DocumentSerialNumber}]的状态异常";
                    throw new UserFriendlyException(errMessage);
                }
            }
            else
            {
                errMessage = $"档案编号[{file.DocumentSerialNumber}]的文件还未入库";
                throw new UserFriendlyException(errMessage);
            }
        }
Exemplo n.º 23
0
        public BMD(FileBase file)
        {
            mFile = file;
            byte[] data   = mFile.GetBuffer();
            Stream stream = new MemoryStream(data);

            mModel = Model.Load(stream);
        }
Exemplo n.º 24
0
 public SystemSnapshotLoader(DirectoryBase directory, FileBase file, Func <string, FileInfoBase> info, string path)
 {
     this.directory     = directory;
     this.file          = file;
     this.info          = info;
     this.path          = path;
     this.searchPattern = WildcardPattern;
 }
Exemplo n.º 25
0
        public Logger(string nameClass)
        {
            NameClass = nameClass;
            string fileFormat = GetSetting("Type") ?? ".txt";
            string fileName   = GetSetting("FileName") ?? "LogFile";

            File = new LoggerFileFactory().GetLoggerFileFactory(fileFormat, fileName);
        }
 public void Setup()
 {
     _file       = Substitute.For <FileBase>();
     _fileSystem = Substitute.For <IFileSystem>();
     _fileSystem.File.Returns(_file);
     _iconProvider = new FileAssociatedIconProvider(_fileSystem);
     _iconProvider.ResetCache();
 }
Exemplo n.º 27
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(FileBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_ReadAllBytes, serviceImpl.ReadAllBytes)
            .AddMethod(__Method_ReadAllLines, serviceImpl.ReadAllLines)
            .AddMethod(__Method_Exists, serviceImpl.Exists)
            .AddMethod(__Method_WriteAllBytes, serviceImpl.WriteAllBytes).Build());
 }
Exemplo n.º 28
0
 public BranchNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Branch;
     file.Skip(0x2);                       // Unk1
     mUnk2            = file.ReadUInt16(); // Unk2
     mCondition       = file.ReadUInt16(); // Unk3
     mYesNoBoxChoices = file.ReadUInt16(); // Unk4
     mLabelsToUse     = file.ReadUInt16(); // Unk5
 }
        public void Setup()
        {
            _file       = Substitute.For <FileBase>();
            _fileSystem = Substitute.For <IFileSystem>();
            _fileSystem.File.Returns(_file);

            _fullPathResolver = Substitute.For <IFullPathResolver>();
            _tester           = new GitRevisionTester(_fullPathResolver, _fileSystem);
        }
Exemplo n.º 30
0
 public EventNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Event;
     file.Skip(0x2);
     mEvent    = file.ReadUInt16();
     mJumpFlow = file.ReadUInt16();
     file.Skip(0x2);
     mFlowID = file.ReadUInt16();
 }
Exemplo n.º 31
0
 public MessageNode(ref FileBase file) : base()
 {
     mNodeType = NodeType.NodeType_Message;
     // skip 0x4 bytes because they are unused
     file.Skip(0x4);
     mMessageID = file.ReadUInt16();
     mNextNode  = file.ReadUInt16();
     file.Skip(0x2);
 }
        public MockFileSystem(IDictionary<string, MockFileData> files)
        {
            this.files = new Dictionary<string, MockFileData>(
                files,
                StringComparer.InvariantCultureIgnoreCase);

            file = new MockFile(this);
            directory = new MockDirectory(this, file);
            fileInfoFactory = new MockFileInfoFactory(this);
        }
        public MockDirectory(IMockFileDataAccessor mockFileDataAccessor, FileBase fileBase, string currentDirectory)
        {
            if (mockFileDataAccessor == null)
            {
                throw new ArgumentNullException("mockFileDataAccessor");
            }

            this.currentDirectory = currentDirectory;
            this.mockFileDataAccessor = mockFileDataAccessor;
            this.fileBase = fileBase;
        }
        public MockFileSystem(IDictionary<string, MockFileData> files, string currentDirectory = @"C:\Foo\Bar")
        {
            this.files = new Dictionary<string, MockFileData>(StringComparer.OrdinalIgnoreCase);
            pathField = new MockPath(this);
            file = new MockFile(this);
            directory = new MockDirectory(this, file, FixPath(currentDirectory));
            fileInfoFactory = new MockFileInfoFactory(this);
            directoryInfoFactory = new MockDirectoryInfoFactory(this);

            if (files == null) return;
            foreach (var entry in files)
                AddFile(entry.Key, entry.Value);
        }
Exemplo n.º 35
0
 public CreateServiceCommand(bool isServiceOffering, string title, string body, int categoryId,
     int clientId, double latitude, double longitude, DateTime? effectiveDate, IFileSystem fileSystem, FileBase imageFile)
 {
     IsServiceOffering = isServiceOffering;
     Title = title;
     Body = body;
     CategoryId = categoryId;
     ClientId = clientId;
     Latitude = latitude;
     Longitude = longitude;
     EffectiveDate = effectiveDate;
     ImageFile = imageFile;
     FileSystem = fileSystem;
 }
        public MockFileSystem(IDictionary<string, MockFileData> files, string currentDirectory = "")
        {
            if (String.IsNullOrEmpty(currentDirectory))
                currentDirectory = IO.Path.GetTempPath();

            this.files = new Dictionary<string, MockFileData>(StringComparer.OrdinalIgnoreCase);
            pathField = new MockPath(this);
            file = new MockFile(this);
            directory = new MockDirectory(this, file, currentDirectory);
            fileInfoFactory = new MockFileInfoFactory(this);
            directoryInfoFactory = new MockDirectoryInfoFactory(this);

            if (files == null) return;
            foreach (var entry in files)
                AddFileWithCreate(entry.Key, entry.Value);
        }
        public MockFileSystem(IDictionary<string, MockFileData> files)
        {
            file = new MockFile(this);
            directory = new MockDirectory(this, file);
            fileInfoFactory = new MockFileInfoFactory(this);
            path = new MockPath();
            directoryInfoFactory = new MockDirectoryInfoFactory(this);

            //For each mock file add a file to the files dictionary
            //Also add a file entry for all directories leading up to this file
            this.files = new Dictionary<string, MockFileData>(StringComparer.InvariantCultureIgnoreCase);
            foreach (var entry in files)
            {
                var directoryPath = Path.GetDirectoryName(entry.Key);
                if (!directory.Exists(directoryPath))
                    directory.CreateDirectory(directoryPath);

                if (!file.Exists(entry.Key))
                    this.files.Add(entry.Key, entry.Value);
            }
        }
Exemplo n.º 38
0
    private void ParseXMLtoList(XElement root)
    {
        foreach (XElement elem in root.Elements())
        {
            FileBase fb = new FileBase();

            string filename = elem.Element("FileName").Value;
            string filepath = elem.Element("FilePath").Value;
            string filereturn = elem.Element("FileReturn").Value;
            string timeout = elem.Element("Timeout").Value;

            fb.fileName = filename;
            fb.filePath = filepath;
            fb.fileReturn = filereturn;
            fb.startTimeOut = Int32.Parse(timeout);

            if (elem.Name == "Device")
                FileList.Add(fb);
            else if (elem.Name == "Switch")
                CiscoSwitchList.Add(fb);

        }
    }
 public MockDirectory(IMockFileDataAccessor mockFileDataAccessor, FileBase fileBase, string currentDirectory) 
 {
     this.currentDirectory = currentDirectory;
     this.mockFileDataAccessor = mockFileDataAccessor;
     this.fileBase = fileBase;
 }
Exemplo n.º 40
0
    private void ParseXMLtoList(XElement root)
    {
        foreach (XElement elem in root.Elements())
        {
            FileBase fb = new FileBase();

            string filename = elem.Element("FileName").Value;
            string filestop = elem.Element("FileStop").Value;

            fb.fileName = filename;
            fb.fileStop = filestop;

            if (elem.Name == "Device")
                FileList.Add(fb);
            else if (elem.Name == "Switch")
                CiscoSwitchList.Add(fb);

        }
    }
Exemplo n.º 41
0
 protected void AddFileToFileList(FileBase file)
 {
     FileList.Add(file);
 }
Exemplo n.º 42
0
        protected void AddStartCmdToList(FileBase file, XElement stlist)
        {
            XElement elem;
            if (file.deviceType == (int)Enum.DeviceType.DEVICE_TYPE_CISCOSWITCHER)
                elem = new XElement("Switch");
            else
                elem = new XElement("Device");

            switch (file.deviceType)
            {
                case (int)Enum.DeviceType.DEVICE_TYPE_HUAWEI:
                    {
                        string version = Util.SingletonGeneric<Data.SystemData>.GetInstance.HWversion;
                        if (!file.fileName.Contains(version))
                            return;
                    }
                    break;
                case (int)Enum.DeviceType.DEVICE_TYPE_WINDOWS:
                    {
                        AlertInformation += file.device.DP.Name + " 启动需要 2 分钟 " + System.Environment.NewLine;
                    }
                    break;
                case (int)Enum.DeviceType.DEVICE_TYPE_LINUX:
                    {
                        AlertInformation += file.device.DP.Name + " 启动需要 3 分钟 " + System.Environment.NewLine;
                    }
                    break;
                case (int)Enum.DeviceType.DEVICE_TYPE_JUNIPER:
                    {
                        AlertInformation += "Juniper 启动需要 15 分钟 " + System.Environment.NewLine;
                    }
                    break;
                default:
                    break;
            }

            XElement name = new XElement("FileName", file.fileName);
            XElement path = new XElement("FilePath", file.filePath);
            XElement ret = new XElement("FileReturn", file.fileReturn);
            XElement time = new XElement("Timeout", file.startTimeOut);

            elem.Add(name);
            elem.Add(path);
            elem.Add(ret);
            elem.Add(time);

            stlist.Add(elem);
        }
Exemplo n.º 43
0
        protected void AddStopCmdToList(FileBase file, XElement stlist)
        {
            XElement elem;
            if (file.deviceType == (int)Enum.DeviceType.DEVICE_TYPE_CISCOSWITCHER)
                elem = new XElement("Switch");
            else
                elem = new XElement("Device");

            XElement name = new XElement("FileName", file.fileName);
            XElement stop = new XElement("FileStop", file.fileStop);

            elem.Add(name);
            elem.Add(stop);
            stlist.Add(elem);
        }
Exemplo n.º 44
0
    private List<FileBase> ParseXMLtoList(XElement root)
    {
        List<FileBase> list = new List<FileBase>();
        foreach (XElement elem in root.Elements())
        {
            FileBase fb = new FileBase();

            string filename = elem.Element("FileName").Value;
            string filepath = elem.Element("FilePath").Value;
            string filecontent = elem.Element("FileContent").Value;
            string devicetype = elem.Element("DeviceType").Value;

            fb.fileName = filename;
            fb.filePath = filepath;
            fb.fileContent = Util.DealSpecialChar(filecontent);
            fb.deviceType = Int32.Parse(devicetype);
            list.Add(fb);
        }
        return list;
    }
Exemplo n.º 45
0
 public MockDirectory(IMockFileDataAccessor mockFileDataAccessor, FileBase fileBase)
 {
     this.mockFileDataAccessor = mockFileDataAccessor;
     this.fileBase = fileBase;
 }
Exemplo n.º 46
0
 public StopDevice(FileBase f, SshShell s, string n)
 {
     file = f;
     shell = s;
     sysname = n;
 }
Exemplo n.º 47
0
 public FileToServer(FileBase f, SshShell s, string n)
 {
     file = f;
     shell = s;
     sysname = n;
 }