예제 #1
0
        /// <summary>
        /// Exports the scene to file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void SaveScene(object sender, EventArgs args)
        {
            if (viewportPanel.LoadedScene == null)
            {
                MessageBox.Show("No scene is selected");
                return;
            }

            string Filter         = "";
            string SceneExtension = "";

            foreach (var attr in viewportPanel.LoadedScene.GetType().GetCustomAttributes(false))
            {
                if (attr is SceneFileInformation info)
                {
                    SceneExtension = info.Extension;
                    Filter        += $"Scene|*{info.Extension}|";
                }
            }

            string FileName;

            if (Tools.FileTools.TrySaveFile(out FileName, Filter + IONET.IOManager.GetModelExportFileFilter()))
            {
                if (FileName.EndsWith(SceneExtension))
                {
                    viewportPanel.LoadedScene.ExportSceneToFile(FileName);
                }
                else
                {
                    var ioScene = viewportPanel.LoadedScene.GetIOModel();
                    IONET.IOManager.ExportScene(ioScene, FileName);
                }
            }
        }
예제 #2
0
        private void BrowseFirmware()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            if (PM)
            {
                dlg.Filter = "Binary files (*.bin)|*.bin|All files (*.*)|*.*";
            }
            else
            {
                dlg.Filter = "CEM Image|*.bin";
            }

            if (dlg.ShowDialog() == true)
            {
                FileName = dlg.FileName.Trim();
                if (FileName.EndsWith(".bin"))
                {
                    btnUpdate.IsEnabled = true;
                }
                MetromRailPage.fwUpdateData_ = File.ReadAllBytes(FileName);
                MetromRailPage.fwUpdateSize_ = (uint)MetromRailPage.fwUpdateData_.Length;
            }
            tbFWUpdate.Text = FileName;
        }
예제 #3
0
        /// <summary>
        /// Imports supported animation file into scene
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void ImportAnimationToScene(object sender, EventArgs args)
        {
            if (viewportPanel.LoadedScene == null)
            {
                MessageBox.Show("No scene is selected");
                return;
            }
            string Filter = "";

            //Create filter
            Dictionary <string, IImportableAnimation> extensionToImporter = new Dictionary <string, IImportableAnimation>();

            foreach (IImportableAnimation importer in AnimationImporters)
            {
                string Extension = importer.Extension;
                Filter += $"*{Extension};";
                extensionToImporter.Add(Extension, importer);
            }

            string FileName;

            if (Tools.FileTools.TryOpenFile(out FileName, "Supported Files|" + Filter))
            {
                foreach (var extension in extensionToImporter.Keys)
                {
                    if (FileName.EndsWith(extension))
                    {
                        OpenFile(FileName);
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Opens the file.
        /// </summary>
        public override void Open()
        {
            // Handle special cases for readers
            if (!PersistSettings || FileAccessMode == FileAccess.Read)
            {
                // Need to fall back on using old file format if a new one doesn't exist for historical reads
                if (!File.Exists(FileName) && !string.IsNullOrEmpty(m_baseFileName) && File.Exists(m_baseFileName))
                {
                    base.FileName = m_baseFileName;
                }

                // Use new file format if a newer one exists
                if (m_legacyMode != MetadataFileLegacyMode.Enabled && !FileName.EndsWith("2") && File.Exists(FileName + "2"))
                {
                    FileName += "2";
                }

                // Fall back on legacy mode if needed
                if (!FileName.EndsWith("2") && File.Exists(FileName))
                {
                    m_legacyMode = MetadataFileLegacyMode.Enabled;
                }
            }

            base.Open();
        }
예제 #5
0
    static void SearchDir(string SourcePath)
    {
        // 如果源目录不存在,则退出
        if (!Directory.Exists(SourcePath))
        {
            return;
        }


        if (Directory.Exists(SourcePath))
        {
            // 遍历源路径的文件夹,获取文件名(带路径的)
            foreach (string FileName in Directory.GetFiles(SourcePath))
            {
                if (FileName.EndsWith(".cs"))
                {
                    string content = File.ReadAllText(FileName);
                    string prefix  = "#if  UNITY_ANDROID || UNITY_EDITOR \n";
                    if (content.Contains(prefix) == false)
                    {
                        content = prefix + content + "\n #endif";
                        File.WriteAllText(FileName, content);
                    }
                }
            }

            // 子文件夹的遍历

            foreach (string SubPath in Directory.GetDirectories(SourcePath))
            {
                //复制文件
                SearchDir(SubPath);
            }
        }
    }
예제 #6
0
 private void button8_Click(object sender, EventArgs e)
 {
     try{
         CommonOpenFileDialog dialog = new CommonOpenFileDialog();
         dialog.IsFolderPicker   = true;
         dialog.Multiselect      = true;
         dialog.RestoreDirectory = true;
         Enabled = false;
         CommonFileDialogResult result = dialog.ShowDialog();
         Enabled = true;
         Focus();
         foreach (string FileName in dialog.FileNames)
         {
             bool Flag = !FileName.EndsWith(".d");
             for (int j = 0; j < FileList.Items.Count; j++)
             {
                 if (FileList.Items[j].ToString() == FileName)
                 {
                     Flag = true;
                     break;
                 }
             }
             if (!Flag)
             {
                 FileList.Items.Add(FileName);
             }
         }
     }catch (Exception) {}
 }
예제 #7
0
        /// <summary>
        /// Validade the properties.
        /// </summary>
        internal static bool Validade()
        {
            if (!(Exceptions.Any() || Warnings.Any() || Messages.Any() || Successes.Any()))
            {
                //throw new ArgumentException("At least one Exception/Warning/Message/Success expected.");
                return(false);
            }

            if (String.IsNullOrEmpty(ProjectName))
            {
                throw new ArgumentException("Project name must be declared.");
            }

            if (String.IsNullOrEmpty(Folder))
            {
                throw new ArgumentException("You must inform the Folder wich the Log will be writen.");
            }

            if (!Directory.Exists(Folder))
            {
                Directory.CreateDirectory(Folder);
            }

            if (!FileName.StartsWith("\\"))
            {
                FileName = "\\" + FileName;
            }

            if (!FileName.EndsWith(".htm"))
            {
                FileName += ".htm";
            }

            return(true);
        }
예제 #8
0
        /// <summary>
        /// Imports a model to scene
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void ImportToScene(object sender, EventArgs args)
        {
            if (Viewport.Scene == null)
            {
                MessageBox.Show("No scene is selected");
                return;
            }

            string Filter = "";

            //Create filter
            Dictionary <string, IImportableModelType> extensionToExporter = new Dictionary <string, IImportableModelType>();

            foreach (IImportableModelType exporter in ModelImporters)
            {
                string Extension = exporter.Extension;
                Filter += $"*{Extension};";
                extensionToExporter.Add(Extension, exporter);
            }

            string FileName;

            if (Tools.FileTools.TryOpenFile(out FileName, "Supported Files|" + Filter))
            {
                foreach (var extension in extensionToExporter.Keys)
                {
                    if (FileName.EndsWith(extension))
                    {
                        Viewport.Scene.FromIOModel(extensionToExporter[extension].ImportIOModel(FileName));
                        SetupScene(Viewport.Scene);
                    }
                }
            }
        }
예제 #9
0
        private void ExportAnimationToFile(object sender, EventArgs args)
        {
            if (Viewport.Scene == null)
            {
                MessageBox.Show("No scene is selected");
                return;
            }
            string Filter = "";

            //Create filter
            Dictionary <string, IExportableAnimation> extensionToExporter = new Dictionary <string, IExportableAnimation>();

            foreach (IExportableAnimation exporter in AnimationExporters)
            {
                string Extension = exporter.Extension;
                Filter += $"*{Extension};";
                extensionToExporter.Add(Extension, exporter);
            }

            string FileName;

            if (Tools.FileTools.TrySaveFile(out FileName, "Supported Files|" + Filter))
            {
                foreach (var extension in extensionToExporter.Keys)
                {
                    if (FileName.EndsWith(extension))
                    {
                        extensionToExporter[extension].ExportSBAnimation(FileName, Viewport.Animation, (SBSkeleton)Viewport.Scene.Skeleton);
                    }
                }
            }
        }
예제 #10
0
        internal override int IncludeInProject(bool includeChildren)
        {
            // Check if parent folder is designated as containing client-side code.
            var isContent  = false;
            var folderNode = this.Parent as NodejsFolderNode;

            if (folderNode != null)
            {
                var contentType = folderNode.ContentType;
                switch (contentType)
                {
                case FolderContentType.Browser:
                    isContent = true;
                    break;
                }
            }

            var includeInProject = base.IncludeInProject(includeChildren);

            if (isContent && FileName.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
            {
                this.ItemNode.ItemTypeName = ProjectFileConstants.Content;
            }

            ProjectMgr.Analyzer.AnalyzeFile(Url, ShouldAnalyze);

            UpdateParentContentType();
            ItemNode.ItemTypeChanged += ItemNode_ItemTypeChanged;

            return(includeInProject);
        }
예제 #11
0
 public LogFile(string path, IParserSelector parserSelector, IModuleClassifier moduleClassifier)
 {
     _path        = path;
     _entries     = new List <LogEntry>();
     FileName     = System.IO.Path.GetFileNameWithoutExtension(_path);
     Module       = moduleClassifier.GetModuleForFile(System.IO.Path.GetFileName(_path));
     IsErrorsFile = FileName.EndsWith(".Errors");
     _logParser   = parserSelector.GetParser(this);
 }
예제 #12
0
        // Called since the FileNode.ImageIndex returns -1 by default.
        //
        public override object GetIconHandle(bool open)
        {
            if (FileName.EndsWith(NemerleConstants.FileExtension, StringComparison.InvariantCultureIgnoreCase))
            {
                return(PackageUtilities.GetIntPointerFromImage(
                           NemerleProjectNode.NemerleImageList.Images[(int)NemerleConstants.ImageListIndex.NemerleSource]));
            }

            return(this.ProjectMgr.ImageHandler.GetIconHandle(this.ImageIndex));
        }
        // Called since the FileNode.ImageIndex returns -1 by default.
        //
        public override object GetIconHandle(bool open)
        {
            if (FileName.EndsWith(".prg", StringComparison.InvariantCultureIgnoreCase))
            {
                return(PackageUtilities.GetIntPointerFromImage(
                           XSharpProjectNode.ImageList.Images[(int)XSharpImageListIndex.Source]));
            }

            return(this.ProjectMgr.ImageHandler.GetIconHandle(this.ImageIndex));
        }
예제 #14
0
        //public async Task<IEnumerable<AnalogyLogMessage>> Process(string fileName, CancellationToken token)
        //{
        //    FileName = fileName;
        //    if (string.IsNullOrEmpty(FileName)) return new List<AnalogyLogMessage>();

        //    if (IsAuditLogFile())
        //    {
        //        LogWindow.SetAuditColumnVisibility(true);

        //        // This is to set the category column visibility to false since it remains same "AUDIT"
        //        LogWindow.SetCategoryColumnVisibility(false);
        //    }
        //    else
        //    {
        //        LogWindow.SetAuditColumnVisibility(false);
        //    }

        //    if (FileProcessingManager.Instance.AlreadyProcessed(FileName) && Settings.EnableFileCaching) //get it from the cache
        //    {
        //        var messagses = FileProcessingManager.Instance.GetMessages(FileName);
        //        DataWindow.AppendMessages(messagses, Utils.GetFileNameAsDataSource(FileName));
        //        return messagses;

        //    }

        //    if (FileProcessingManager.Instance.IsFileCurrentlyBeingProcessed(FileName))
        //    {
        //        while (FileProcessingManager.Instance.IsFileCurrentlyBeingProcessed(FileName))
        //        {
        //            await Task.Delay(1000);
        //        }
        //        var messagses = FileProcessingManager.Instance.GetMessages(FileName);
        //        DataWindow.AppendMessages(messagses, Utils.GetFileNameAsDataSource(FileName));
        //        return messagses;
        //    }
        //    //otherwise read file:
        //    FileProcessingManager.Instance.AddProcessingFile(FileName);
        //    Settings.AddToRecentFiles(Guid.Empty, FileName);
        //    try
        //    {
        //        if (FileName.EndsWith(".evtx", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            EventViewerLogLoader logLoader = new EventViewerLogLoader(token);
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;

        //        }
        //        if (FileName.EndsWith("XD.log", StringComparison.InvariantCultureIgnoreCase) ||
        //            FileName.EndsWith("XDDebug.log", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            MiradaXDLogLoader logLoader = new MiradaXDLogLoader();
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;
        //        }
        //        if (FileName.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            CTXmlLoader logLoader = new CTXmlLoader(token);
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;

        //        }
        //        if (FileName.EndsWith(".etl", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            ICAPLogLoader logLoader = new ICAPLogLoader();
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;

        //        }

        //        if (FileName.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            LogLoader logLoader = new LogXmlLoader();
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;
        //        }
        //        if (FileName.EndsWith(".nlog", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            LogLoader logLoader = new NLogLoader();
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;

        //        }
        //        if (FileName.EndsWith(".json", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            LogLoader logLoader = new JSonLoader();
        //            var messages = await logLoader.ReadFromFile(FileName, DataWindow).ConfigureAwait(false);
        //            FileProcessingManager.Instance.DoneProcessingFile(messages.ToList(), fileName);
        //            return messages;
        //        }
        //        else
        //        {
        //            AnalogyLogMessage m = new AnalogyLogMessage();
        //            m.Text = $"Incorrect file: {FileName}. Skipping file";
        //            m.Level = LogLevel.Critical;
        //            m.Source = "Analogy";
        //            m.Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
        //            m.ProcessID = System.Diagnostics.Process.GetCurrentProcess().Id;
        //            m.Class = LogClass.General;
        //            m.User = Environment.UserName;
        //            m.Date = DateTime.Now;
        //            FileProcessingManager.Instance.DoneProcessingFile(new List<AnalogyLogMessage>(0), FileName);
        //            DataWindow.AppendMessage(m, Environment.MachineName);
        //            return new List<AnalogyLogMessage>();
        //        }
        //    }

        //    catch (Exception ex)
        //    {
        //        MessageBox.Show("Error occured:" + ex);
        //    }
        //    return new List<AnalogyLogMessage>();
        //}

        private bool IsAuditLogFile()
        {
            bool isAuditLogFile = false;

            try
            {
                if (DataStream == null)
                {
                    return(false);
                }
                //audit log file is of the format .log. Hence return false if the file in question is an etl file
                if (FileName.EndsWith(".etl"))
                {
                    return(false);
                }

                XmlNodeType      ndType = XmlNodeType.Element;
                XmlParserContext xp     = new XmlParserContext(null, null, null, XmlSpace.Default);
                XmlTextReader    xr     = new XmlTextReader(DataStream, ndType, xp);

                if (xr.Read())
                {
                    if (xr.IsStartElement("Message"))
                    {
                        while (xr.Read())
                        {
                            if (xr.IsStartElement("Category"))
                            {
                                if (xr.ReadElementString() == "AUDIT")
                                {
                                    isAuditLogFile = true;
                                }
                                break;
                            }
                        }
                    }
                }

                DataStream.Position = 0;
                //or
                //dataStream.Seek(0, SeekOrigin.Begin);
            }
            catch (Exception)
            {
                //
            }
            finally
            {
                if (DataStream != null)
                {
                    DataStream.Position = 0;
                }
            }
            return(isAuditLogFile);
        }
예제 #15
0
 public override void SetXElement(XElement xEdit)
 {
     FileName = xEdit.Attribute("fileName").Value;
     if (FileName.EndsWith(".lightScript"))
     {
         if (xEdit.Attribute("stepName") != null)
         {
             StepName = xEdit.Attribute("stepName").Value;
         }
     }
 }
예제 #16
0
 public void ImportTheWholeExcel()
 {
     SyncFile.RegisterLicense();
     if (FileName.EndsWith("toThomsonReuters.xlsx"))
     {
         metals_smm_shanghai(1);
     }
     else if (FileName.EndsWith("路透.xlsx"))
     {
         metals_smm_shanghai(0);
     }
 }
예제 #17
0
파일: MapManager.cs 프로젝트: Pircs/Yi
        /// <summary>
        /// Load a GameMap.dat file with all the maps data.
        /// </summary>
        public MapManager(string gameMap, string conquerFolder)
        {
            _maps = new Dictionary <int, string>();
            _data = new Dictionary <string, GameMap>();

            using (var stream = new FileStream(gameMap, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                int amount;
                stream.Read(&amount, sizeof(int));
                for (var i = 0; i < amount; i++)
                {
                    int mapId, length, puzzleSize;
                    stream.Read(&mapId, sizeof(int));
                    stream.Read(&length, sizeof(int));

                    byte *pFileName = stackalloc byte[length + 1];
                    stream.Read(pFileName, length);
                    stream.Read(&puzzleSize, sizeof(int));

                    var fileName = conquerFolder + "\\" + new string((sbyte *)pFileName);
                    fileName = fileName.ToLower();

#if SEVENZIP
                    if (FileName.EndsWith(".7z"))
                    {
                        using (var SevenZip = new SevenZipExtractor(FileName))
                        {
                            for (Int32 k = 0; k < SevenZip.ArchiveFileData.Count; k++)
                            {
                                SevenZip.ExtractFiles(Path.GetDirectoryName(FileName) + "\\", SevenZip.ArchiveFileData[k].Index);
                            }
                        }
                        FileName  = FileName.Replace(".7z", ".dmap");
                        Extracted = true;
                    }
                    #endif

                    if (!_data.ContainsKey(fileName))
                    {
                        GameMap map;
                        try { map = new GameMap(fileName); }
                        catch { continue; }
                        _data.Add(fileName, map);
                    }

                    if (!_maps.ContainsKey(mapId))
                    {
                        _maps.Add(mapId, fileName);
                    }
                }
            }
        }
예제 #18
0
        // Called since the FileNode.ImageIndex returns -1 by default.
        //
        public override object GetIconHandle(bool open)
        {
            if (FileName.EndsWith(NemerleConstants.FileExtension, StringComparison.InvariantCultureIgnoreCase))
            {
                int imageIndex = HasDesigner ?
                                 NemerleConstants.ImageListIndex.NemerleForm :
                                 NemerleConstants.ImageListIndex.NemerleSource;
                return
                    (PackageUtilities.GetIntPointerFromImage(NemerleProjectNode.NemerleImageList.Images[imageIndex]));
            }

            return(base.GetIconHandle(open));
        }
예제 #19
0
 /// <summary>
 ///		Obtiene el texto asociado a un nodo arrastrado a la pantalla
 /// </summary>
 public override string TreatTextDropped(string content, bool shiftPressed)
 {
     // Obtiene el texto asociado a un nombre de archivo
     if (IsFileName(content))
     {
         if (FileName.EndsWith(".md", StringComparison.CurrentCultureIgnoreCase))
         {
             content = GetTextDroppedOnMarkdown(content);
         }
     }
     // Devuelve el contenido
     return(content);
 }
예제 #20
0
        /// <summary>
        /// Exports the scene to file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void SaveScene(object sender, EventArgs args)
        {
            if (viewportPanel.LoadedScene == null)
            {
                MessageBox.Show("No scene is selected");
                return;
            }

            string Filter         = "";
            string SceneExtension = "";

            foreach (var attr in viewportPanel.LoadedScene.GetType().GetCustomAttributes(false))
            {
                if (attr is SceneFileInformation info)
                {
                    SceneExtension = info.Extension;
                    Filter        += $"*{info.Extension};";
                }
            }

            //Create filter
            Dictionary <string, IExportableModelType> extensionToExporter = new Dictionary <string, IExportableModelType>();

            foreach (IExportableModelType exporter in ModelExporters)
            {
                string Extension = exporter.Extension;
                Filter += $"*{Extension};";
                extensionToExporter.Add(Extension, exporter);
            }


            string FileName;

            if (Tools.FileTools.TrySaveFile(out FileName, "Supported Files|" + Filter))
            {
                foreach (var extension in extensionToExporter.Keys)
                {
                    if (FileName.EndsWith(SceneExtension))
                    {
                        viewportPanel.LoadedScene.ExportSceneToFile(FileName);
                        break;
                    }
                    else
                    if (FileName.EndsWith(extension))
                    {
                        extensionToExporter[extension].ExportIOModel(FileName, viewportPanel.LoadedScene.GetIOModel());
                        break;
                    }
                }
            }
        }
예제 #21
0
        /// <summary>
        ///     Saves machine data code to .py file.
        /// </summary>
        public static string Export()
        {
            if (EmbeddedCode == null)
            {
                throw new Exception("This machine contains no code to be exported.");
            }

            var path = FileName.EndsWith(".py") ? FileName : FileName + ".py";

            path = string.Concat(Application.dataPath, "/Scripts/", path);
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            File.WriteAllText(path, EmbeddedCode);
            return(path);
        }
예제 #22
0
        /// <summary>
        /// Executes the POST method on the resource.
        /// </summary>
        /// <param name="Request">HTTP Request</param>
        /// <param name="Response">HTTP Response</param>
        /// <exception cref="HttpException">If an error occurred when processing the method.</exception>
        public Task POST(HttpRequest Request, HttpResponse Response)
        {
            Gateway.AssertUserAuthenticated(Request, "Admin.Data.Backup");

            if (!Request.HasData)
            {
                throw new BadRequestException();
            }

            if (!(Request.DecodeData() is string FileName))
            {
                throw new BadRequestException();
            }

            string Dir;

            if (FileName.EndsWith(".key", StringComparison.CurrentCultureIgnoreCase))
            {
                Dir = Export.FullKeyExportFolder;
            }
            else
            {
                Dir = Export.FullExportFolder;
            }

            if (!Directory.Exists(Dir))
            {
                throw new NotFoundException("Folder not found: " + Dir);
            }

            string FullFileName = Dir + Path.DirectorySeparatorChar + FileName;

            if (!File.Exists(FullFileName))
            {
                throw new NotFoundException("File not found: " + FullFileName);
            }

            File.Delete(FullFileName);

            Log.Informational("Export deleted.", FileName);

            Response.StatusCode  = 200;
            Response.ContentType = "text/plain";
            Response.Write("1");

            ExportFormat.UpdateClientsFileDeleted(FileName);

            return(Task.CompletedTask);
        }
예제 #23
0
 public Parsers.IParser CreateParser()
 {
     if (FileName.EndsWith(".csv"))
     {
         return(new Parsers.CsvParser(SourceContents));
     }
     else if (FileName.EndsWith(".xlsx"))
     {
         return(new XlsxParser(SourceContents));
     }
     else
     {
         return(null);
     }
 }
예제 #24
0
 private FileFormat GetFileFormat()
 {
     if (FileName.EndsWith(".xls"))
     {
         return(FileFormat.Version97to2003);
     }
     else if (FileName.EndsWith(".xlsx"))
     {
         return(FileFormat.Version2016);
     }
     else
     {
         return(FileFormat.Version2013);
     }
 }
예제 #25
0
        private bool VerifyFile( )
        {
            if (!FileName.EndsWith(".c"))
            {
                DotOutputs = null;
                LastError  = OptimizeResult.BadExtension;
                return(false);
            }
            if (!File.Exists(FileName))
            {
                LastError = OptimizeResult.FileNotFound;
                return(false);
            }

            return(true);
        }
예제 #26
0
        public JsonResult OnGetFileShare()
        {
            var rawQS = Uri.UnescapeDataString(Request.QueryString.ToString());
            var idx   = rawQS.IndexOf('{');

            if (idx == -1)
            {
                return(new JsonResult("ERROR~:No Parameters"));
            }
            var jsonQS = rawQS.Substring(idx);
            Dictionary <string, string> NVPairs = JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonQS);

            if (NVPairs.TryGetValue("Folder", out string FolderName) && NVPairs.TryGetValue("File", out string FileName))
            {
                if (FileName.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase) ||
                    FileName.EndsWith(".pdf", StringComparison.CurrentCultureIgnoreCase) ||
                    FileName.EndsWith(".docx", StringComparison.CurrentCultureIgnoreCase) ||
                    FileName.EndsWith(".doc", StringComparison.CurrentCultureIgnoreCase) ||
                    FileName.EndsWith(".htm", StringComparison.CurrentCultureIgnoreCase) ||
                    FileName.EndsWith(".html", StringComparison.CurrentCultureIgnoreCase))
                {
                    FileName = UnencodeQuotes(FileName);
                    string destFName = Path.Combine("tmpDBox", (FolderName + FileName).Replace('/', '~').Replace('\\', '~'));
                    string destFile  = Path.Combine(hostEnv.WebRootPath, destFName);

                    if (System.IO.File.Exists(destFile))
                    {
                        System.IO.File.Delete(destFile);
                    }
                    var task = dbox.DownloadToFile(FolderName, FileName, destFile);
                    task.Wait();
                    return(new JsonResult(destFName));
                }
                string url = dbox.GetSharedLink(Uri.UnescapeDataString(UnencodeQuotes(FolderName) + "/" + UnencodeQuotes(FileName)));

                if (url.Length > 0)
                {
                    return(new JsonResult(url));
                }
                else
                {
                    return(new JsonResult("ERROR~:No File Share"));
                }
            }
            return(new JsonResult("ERROR~:Incorrect Parameters"));
        }
예제 #27
0
        public void Save()
        {
            string fileName = FileName;

            if (!FileName.EndsWith(".txt"))
            {
                int extensionLocation = fileName.LastIndexOf('.');
                if (extensionLocation != -1)
                {
                    fileName = fileName.Remove(extensionLocation);
                }
                fileName = fileName + ".txt";
            }
            using (StreamWriter sw = new StreamWriter(fileName, false)) {
                sw.Write(ProgramText.Replace("\r", "").Replace("\n", Environment.NewLine));
            }
            Dirty = false;
        }
예제 #28
0
 public RNASeqFastqDataGrid(string filePath)
 {
     Use      = true;
     FilePath = filePath;
     FileName = Path.GetFileNameWithoutExtension(filePath);
     if (filePath.EndsWith("gz"))
     {
         FileName = Path.GetFileNameWithoutExtension(FileName);
     }
     if (FileName.EndsWith("_1"))
     {
         MatePair = "1";
     }
     if (FileName.EndsWith("_2"))
     {
         MatePair = "2";
     }
 }
예제 #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            OtherCultureExist = false;

            FileName = Request.QueryString["f"];

            CultureName = Request.QueryString["t"];

            if (CultureName != null)
            {
                OtherCultureExist = true;
                Save(null, null);
                var entityToken = new WebsiteFileElementProviderEntityToken("WebsiteFileElementProvider",
                                                                            Path.GetDirectoryName(FileName), Path.GetDirectoryName(PathUtil.BaseDirectory));
                ConsoleMessageQueueFacade.Enqueue(new RefreshTreeMessageQueueItem {
                    EntityToken = entityToken
                }, null);
            }

            if (!FileName.EndsWith(".resx", StringComparison.OrdinalIgnoreCase))
            {
                FileName = null;
                return;
            }

            var loc = CultureInfo.GetCultures(CultureTypes.AllCultures)
                      .LastOrDefault(f => f.Name != "" && FileName.EndsWith("." + f.Name + ".Resx", StringComparison.OrdinalIgnoreCase));

            if (loc != null)
            {
                FileName          = FileName.Replace(loc.Name + ".", "");
                OtherCultureExist = true;
            }

            if (loc != null)
            {
                CultureName = loc.Name;
            }

            this.BindGridView();
        }
    }
예제 #30
0
        public string BuildUri()
        {
            if (FileName.IsNullOrWhitespace())
            {
                return(string.Empty);
            }

            if (FileExtension.IsNullOrWhitespace())
            {
                return(FileName);
            }

            if (FileName.EndsWith(FileExtension))
            {
                return(FileName);
            }

            return($"{FileName.TrimEnd('.')}.{FileExtension.TrimStart('.')}");
        }