Exemplo n.º 1
0
            public ByNumber()
            {
                var files   = CheckPath(".ts");
                var outFile = Path.ChangeExtension(InputPath.Trim('.'), ".ts");

                FileHelper.FileMerge(files.ToArray(), outFile);
            }
Exemplo n.º 2
0
 private void btn_Select_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(InputPath))
     {
         MessageBox.Show(this, "您未有选定文件夹,请选择目录或手动输入目录", "", MessageBoxButtons.OK, DialogResult.OK, 12);
         return;
     }
     if (!IO.PathHelper.IsPath(InputPath))
     {
         MessageBox.Show(this, "您输入的路径不合法,请检查", "", MessageBoxButtons.OK, DialogResult.OK, 12);
         pathTBox.Focus();
         return;
     }
     InputPath = InputPath.Trim();
     if (CheckPathExists && !Directory.Exists(InputPath))
     {
         if (MessageBox.Show(this, "您指定的文件夹不存在,是否继续?", "", MessageBoxButtons.YesNo, DialogResult.Yes, 12) == DialogResult.No)
         {
             pathTBox.Focus();
             return;
         }
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Exemplo n.º 3
0
            public ByName()
            {
                var ex      = SystemConsole.GetInputStr("请输入文件后缀(如\"cs,cpp\":");
                var files   = CheckPath("*.*").Where(p => p.EndsWith(ex)).ToArray();
                var outFile = Path.ChangeExtension(InputPath.Trim('.'), ex);

                FileHelper.FileMerge(files.ToArray(), outFile);
            }
Exemplo n.º 4
0
        private void DoProcessing()
        {
            string inputPath = InputPath.Trim();

            if (string.IsNullOrEmpty(inputPath))
            {
                string error = string.Format("Input file path is empty.  Processing ignored. File: {0}", inputPath);
                AddLogEntry(error, LogEntryTarget.Database);
                m_Logger.Error(error);
                throw new FileNotFoundException("File not found. Input path is empty");
            }

            if (!File.Exists(inputPath))
            {
                string error = string.Format("Input file not found.  Processing ignored. File: {0}", inputPath);
                AddLogEntry(error, LogEntryTarget.Database);
                m_Logger.Error(error);
                throw new FileNotFoundException("File not found", inputPath);
            }

            try
            {
                // Plugin to be used for processing
                PluginInfo pluginInfo = PluginManager.Instance.GetPluginInfo(PluginName, PathUtils.GetExtension(inputPath));

                // Get the actual plugin to do the processing
                PluginBase plugin = pluginInfo.GetAssetProcessingPlugin();

                // Do any setup stuff
                plugin.Setup();

                // Set the plugin actually used for processing
                PluginUsed = pluginInfo.Name;

                AddLogEntry("Plugin to be used for processing: " + PluginUsed);

                // Set required properties
                plugin.InputPath     = inputPath;
                plugin.WatermarkPath = WatermarkPath;
                plugin.ThumbnailSize = (OverrideWidth > 0 && OverrideHeight > 0) ? new Size(OverrideWidth, OverrideHeight) : new Size(100, 100);
                plugin.PreviewSize   = (OverrideWidth > 0 && OverrideHeight > 0) ? new Size(OverrideWidth, OverrideHeight) : new Size(320, 300);

                m_Logger.DebugFormat("Dimensions to be used - thumbnail: {0}(w)x{1}h, preview: {2}(w)x{3}h", plugin.ThumbnailSize.Width, plugin.ThumbnailSize.Height, plugin.PreviewSize.Width, plugin.PreviewSize.Height);

                try
                {
                    plugin.BeforeProcessing();

                    m_Logger.InfoFormat("Processing {0}.  Preview: {1} (Watermark: {2}).  Thumbnail: {3}", inputPath, CreatePreview, (!String.IsNullOrEmpty(WatermarkPath)).ToString().ToLower(), CreateThumbnail);

                    if (CreatePreview)
                    {
                        if (plugin.CanGeneratePreview)
                        {
                            PreviewPath = plugin.GeneratePreview();

                            if (!String.IsNullOrEmpty(PreviewPath) && !File.Exists(PreviewPath))
                            {
                                m_Logger.WarnFormat("Plugin reports that the preview file has been created, but file does not exist: {0}", PreviewPath);
                            }

                            AddLogEntry("Generated preview: " + PreviewPath);
                        }
                        else
                        {
                            const string message = "Preview generation requested, but plugin cannot generate preview";

                            AddLogEntry(message, LogEntryTarget.Database);

                            m_Logger.Warn(message);
                        }
                    }
                }
                catch (NotImplementedException)
                {
                    const string error = "Preview not created: plugin does not support this feature";

                    AddLogEntry(error, LogEntryTarget.Database);

                    m_Logger.Error(error);
                }
                catch (Exception e)
                {
                    LogError("Error creating preview", e);
                }

                try
                {
                    if (CreateThumbnail)
                    {
                        if (plugin.CanGenerateThumbnail)
                        {
                            ThumbnailPath = plugin.GenerateThumbnail();

                            if (!String.IsNullOrEmpty(ThumbnailPath) && !File.Exists(ThumbnailPath))
                            {
                                m_Logger.WarnFormat("Plugin reports thumbnail has been created, but file does not exist: {0}", ThumbnailPath);
                            }

                            AddLogEntry("Generated thumbnail: " + ThumbnailPath);
                        }
                        else
                        {
                            const string message = "Thumbnail generation requested, but plugin cannot generate thumbnail";

                            AddLogEntry(message, LogEntryTarget.Database);

                            m_Logger.Warn(message);
                        }
                    }
                }
                catch (NotImplementedException)
                {
                    const string error = "Thumbnail not created: plugin does not support this feature";

                    AddLogEntry(error, LogEntryTarget.Database);

                    m_Logger.Error(error);
                }
                catch (Exception e)
                {
                    LogError("Error creating thumbnail", e);
                }

                // Add any other data to be posted back by plugin
                foreach (var item in plugin.FileDataItems)
                {
                    FileDataItems[item.Key] = item.Value;
                }

                // Do any cleanup stuff
                plugin.Cleanup();
            }
            catch (PluginNotFoundException ex)
            {
                LogError("Plugin not found or not available", ex);
            }

            try
            {
                MetadataExtractor mex = new MetadataExtractor(inputPath);
                MetadataXml = mex.GetXml();
                AddLogEntry("Got file metadata XML");
            }
            catch (Exception ex)
            {
                LogError("Error getting metadata XML", ex);
            }
        }