コード例 #1
0
ファイル: ImportUtil.cs プロジェクト: seud0nym/jackcess-net
        /// <summary>Copy a delimited text file into a new table in this database.</summary>
        /// <remarks>
        /// Copy a delimited text file into a new table in this database.
        /// <p>
        /// Equivalent to:
        /// <code>importReader(new BufferedReader(new FileReader(f)), db, name, delim, "'", filter, false);
        ///     </code>
        /// </remarks>
        /// <param name="name">Name of the new table to create</param>
        /// <param name="f">Source file to import</param>
        /// <param name="delim">Regular expression representing the delimiter string.</param>
        /// <param name="quote">the quote character</param>
        /// <param name="filter">valid import filter</param>
        /// <param name="useExistingTable">
        /// if
        /// <code>true</code>
        /// use current table if it already
        /// exists, otherwise, create new table with unique
        /// name
        /// </param>
        /// <returns>the name of the imported table</returns>
        /// <seealso cref="ImportReader(System.IO.BufferedReader, Database, string, string, ImportFilter)
        ///     ">ImportReader(System.IO.BufferedReader, Database, string, string, ImportFilter)
        ///     </seealso>
        /// <exception cref="System.IO.IOException"></exception>
        public static string ImportFile(FilePath f, Database db, string name, string delim
                                        , char quote, ImportFilter filter, bool useExistingTable)
        {
            BufferedReader @in = null;

            try
            {
                @in = new BufferedReader(new FileReader(f));
                return(ImportReader(@in, db, name, delim, quote, filter, useExistingTable));
            }
            finally
            {
                if (@in != null)
                {
                    try
                    {
                        @in.Close();
                    }
                    catch (IOException ex)
                    {
                        System.Console.Error.WriteLine("Could not close file " + f.GetAbsolutePath());
                        Sharpen.Runtime.PrintStackTrace(ex, System.Console.Error);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Docker.xaml.cs プロジェクト: H1410646/QrCodeDocker
        private void CreateBitmapLocal(int strSize = 221)
        {
            Layers layers = this.app.ActiveDocument.ActivePage.Layers;

            foreach (Layer l in layers)
            {
                if (l.Shapes.Count == 0 && !l.IsSpecialLayer)
                {
                    l.Delete();
                }
            }

            Layer tempLayer = this.app.ActiveDocument.ActivePage.CreateLayer("temp_qrcode");

            tempLayer.Activate();
            BitmapSource imageSource = (BitmapSource)img_render.Source;

            imageRender.SaveTempQrCodeFile(txt_content.Text, this.app.ActivePage.Resolution, strSize);
            StructImportOptions sio = new StructImportOptions();

            sio.MaintainLayers = true;

            ImportFilter importFilter = this.app.ActiveLayer.ImportEx(imageRender.QrCodeFilePath);

            importFilter.Finish();

            //Corel.Interop.VGCore.Clipboard cp = new Corel.Interop.VGCore.Clipboard();

            //System.Windows.Clipboard.SetImage(imageSource);
        }
        protected override void InternalHandleImport(ComponentsModel packageModel, ImportFilter importFilter, out int importedCount)
        {
            importedCount = 0;
            if (!Directory.Exists(this.ComponentsFolder))
            {
                return;
            }
            var resultLocalizationStrings = this.GetComponentModelList(packageModel);
            var groupFolders = Directory.EnumerateDirectories(this.ComponentsFolder);

            foreach (var groupFolder in groupFolders)
            {
                if (importFilter.NeedImport(groupFolder, this.DevelopmentPath))
                {
                    var groupCode           = new DirectoryInfo(groupFolder).Name;
                    var localizationStrings = this.LoadLocalizationStringsByGroup(groupCode);
                    foreach (var localizationString in localizationStrings)
                    {
                        this.PrepareForImport(groupFolder, localizationString);
                        resultLocalizationStrings.Add(localizationString);
                        importedCount++;
                    }
                }
            }
        }
コード例 #4
0
ファイル: ImportUtil.cs プロジェクト: seud0nym/jackcess-net
        /// <summary>Returns a new table with a unique name and the given table definition.</summary>
        /// <remarks>Returns a new table with a unique name and the given table definition.</remarks>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="Sharpen.SQLException"></exception>
        private static Table CreateUniqueTable(Database db, string name, IList <Column> columns
                                               , ResultSetMetaData md, ImportFilter filter)
        {
            // otherwise, find unique name and create new table
            string baseName = name;
            int    counter  = 2;

            while (db.GetTable(name) != null)
            {
                name = baseName + (counter++);
            }
            db.CreateTable(name, filter.FilterColumns(columns, md));
            return(db.GetTable(name));
        }
コード例 #5
0
        public void HandleImport(ComponentsModel packageModel, ImportFilter importFilter)
        {
            const string ImportStageName = "Импорт";

            try
            {
                int importedCount;
                this.InternalHandleImport(packageModel, importFilter, out importedCount);
                Log.Info(string.Format("  {0} {1}: завершен (импортировано {2})", ImportStageName, this.ElementNameInGenitive, importedCount));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("  {0} {1}: ошибка. Подробнее: {2}", ImportStageName, this.ElementNameInGenitive, ex.Message));
                throw;
            }
        }
コード例 #6
0
ファイル: ImportUtil.cs プロジェクト: seud0nym/jackcess-net
        /// <summary>
        /// Copy a delimited text file into a new (or optionally exixsting) table in
        /// this database.
        /// </summary>
        /// <remarks>
        /// Copy a delimited text file into a new (or optionally exixsting) table in
        /// this database.
        /// </remarks>
        /// <param name="name">Name of the new table to create</param>
        /// <param name="in">Source reader to import</param>
        /// <param name="delim">Regular expression representing the delimiter string.</param>
        /// <param name="quote">the quote character</param>
        /// <param name="filter">valid import filter</param>
        /// <param name="useExistingTable">
        /// if
        /// <code>true</code>
        /// use current table if it already
        /// exists, otherwise, create new table with unique
        /// name
        /// </param>
        /// <returns>the name of the imported table</returns>
        /// <exception cref="System.IO.IOException"></exception>
        public static string ImportReader(BufferedReader @in, Database db, string name, string
                                          delim, char quote, ImportFilter filter, bool useExistingTable)
        {
            string line = @in.ReadLine();

            if (line == null || line.Trim().Length == 0)
            {
                return(null);
            }
            Sharpen.Pattern delimPat = Sharpen.Pattern.Compile(delim);
            name = Database.EscapeIdentifier(name);
            Table table = null;

            if (!useExistingTable || ((table = db.GetTable(name)) == null))
            {
                IList <Column> columns     = new List <Column>();
                string[]       columnNames = SplitLine(line, delimPat, quote, @in, 0);
                for (int i = 0; i < columnNames.Length; i++)
                {
                    columns.AddItem(new ColumnBuilder(columnNames[i], DataType.TEXT).EscapeName().SetLength
                                        (DataTypeProperties.TEXT.maxSize.Value).ToColumn());
                }
                table = CreateUniqueTable(db, name, columns, null, filter);
            }
            IList <object[]> rows = new AList <object[]>(COPY_TABLE_BATCH_SIZE);
            int numColumns        = table.GetColumnCount();

            while ((line = @in.ReadLine()) != null)
            {
                object[] data = SplitLine(line, delimPat, quote, @in, numColumns);
                rows.AddItem(filter.FilterRow(data));
                if (rows.Count == COPY_TABLE_BATCH_SIZE)
                {
                    table.AddRows(rows);
                    rows.Clear();
                }
            }
            if (rows.Count > 0)
            {
                table.AddRows(rows);
            }
            return(table.GetName());
        }
コード例 #7
0
        // ImportBackgrounds - Imports Backgrounds from Install Folder.

        private VGCore.Shape ImportBackground(String fileName)
        {
            String prefix = fileName.Substring(0, 3);

            StructImportOptions impOpt = this.appDraw.CreateStructImportOptions();

            if (prefix == "FMR")
            {
                ImportFilter impFil = this.appDraw.ActiveLayer.ImportEx("C:\\CorelDrawPreviewExport\\CorelDrawPreviewExport\\assets\\bg\\fmr\\" + fileName, cdrFilter.cdrCDR, impOpt);
                impFil.Finish();
            }
            else
            {
                ImportFilter impFil = this.appDraw.ActiveLayer.ImportEx("C:\\CorelDrawPreviewExport\\CorelDrawPreviewExport\\assets\\bg\\msmx\\" + fileName, cdrFilter.cdrCDR, impOpt);
                impFil.Finish();
            }

            return(this.appDraw.ActiveShape);
        }
コード例 #8
0
        /// <summary>
        /// Обработать импорт моделей (внутренний метод).
        /// </summary>
        /// <param name="packageModel">Модель пакета разработки.</param>
        /// <param name="importFilter">Фильтр импорта.</param>
        /// <param name="importedCount">Количество импортированных элементов.</param>
        protected virtual void InternalHandleImport(ComponentsModel packageModel, ImportFilter importFilter, out int importedCount)
        {
            importedCount = 0;
            var serializer = this.CreateSerializer();
            var models     = this.GetComponentModelList(packageModel);

            if (!Directory.Exists(this.ComponentsFolder))
            {
                return;
            }

            foreach (var componentFolder in Directory.EnumerateDirectories(this.ComponentsFolder))
            {
                if (importFilter.NeedImport(componentFolder, this.DevelopmentPath))
                {
                    models.Add(this.HandleImportModel(componentFolder, serializer));
                    importedCount++;
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Обработать импорт моделей (внутренний метод).
        /// </summary>
        /// <param name="rootModel">Модель пакета разработки.</param>
        /// <param name="importFilter">Фильтр импорта.</param>
        /// <param name="importedCount">Количество импортированных элементов.</param>
        protected override void InternalHandleImport(RootModel rootModel, ImportFilter importFilter, out int importedCount)
        {
            importedCount = 0;
            var serializer = this.CreateSerializer();
            var models     = rootModel.Records;

            if (!Directory.Exists(this.ComponentsFolder))
            {
                return;
            }

            foreach (var componentFolder in Directory.EnumerateDirectories(this.ComponentsFolder))
            {
                if (importFilter.NeedImport(componentFolder, this.DevelopmentPath))
                {
                    models.Add(this.HandleImportModel(componentFolder, serializer));
                    importedCount++;
                }
            }
        }
コード例 #10
0
 public LabeledInclude(ImportFilter importFilter, BuildObject buildObject)
 {
     this.importFilter = importFilter;
     this.buildObject  = buildObject;
 }
コード例 #11
0
ファイル: ImportUtil.cs プロジェクト: seud0nym/jackcess-net
 /// <summary>Copy a delimited text file into a new table in this database.</summary>
 /// <remarks>
 /// Copy a delimited text file into a new table in this database.
 /// <p>
 /// Equivalent to:
 /// <code>importFile(f, name, db, delim, "'", filter, false);</code>
 /// </remarks>
 /// <param name="name">Name of the new table to create</param>
 /// <param name="f">Source file to import</param>
 /// <param name="delim">Regular expression representing the delimiter string.</param>
 /// <param name="filter">valid import filter</param>
 /// <returns>the name of the imported table</returns>
 /// <seealso cref="ImportReader(System.IO.BufferedReader, Database, string, string, ImportFilter)
 ///     ">ImportReader(System.IO.BufferedReader, Database, string, string, ImportFilter)
 ///     </seealso>
 /// <exception cref="System.IO.IOException"></exception>
 public static string ImportFile(FilePath f, Database db, string name, string delim
                                 , ImportFilter filter)
 {
     return(ImportFile(f, db, name, delim, ExportUtil.DEFAULT_QUOTE_CHAR, filter, false
                       ));
 }
コード例 #12
0
ファイル: ImportUtil.cs プロジェクト: seud0nym/jackcess-net
 /// <summary>
 /// Copy a delimited text file into a new (or optionally exixsting) table in
 /// this database.
 /// </summary>
 /// <remarks>
 /// Copy a delimited text file into a new (or optionally exixsting) table in
 /// this database.
 /// <p>
 /// Equivalent to:
 /// <code>importReader(in, db, name, delim, '"', filter, false);</code>
 /// </remarks>
 /// <param name="name">Name of the new table to create</param>
 /// <param name="in">Source reader to import</param>
 /// <param name="delim">Regular expression representing the delimiter string.</param>
 /// <param name="filter">valid import filter</param>
 /// <param name="useExistingTable">
 /// if
 /// <code>true</code>
 /// use current table if it already
 /// exists, otherwise, create new table with unique
 /// name
 /// </param>
 /// <returns>the name of the imported table</returns>
 /// <exception cref="System.IO.IOException"></exception>
 public static string ImportReader(BufferedReader @in, Database db, string name, string
                                   delim, ImportFilter filter, bool useExistingTable)
 {
     return(ImportReader(@in, db, name, delim, ExportUtil.DEFAULT_QUOTE_CHAR, filter,
                         useExistingTable));
 }
コード例 #13
0
ファイル: ImportUtil.cs プロジェクト: seud0nym/jackcess-net
 /// <summary>Copy a delimited text file into a new table in this database.</summary>
 /// <remarks>
 /// Copy a delimited text file into a new table in this database.
 /// <p>
 /// Equivalent to:
 /// <code>importReader(in, db, name, delim, filter, false);</code>
 /// </remarks>
 /// <param name="name">Name of the new table to create</param>
 /// <param name="in">Source reader to import</param>
 /// <param name="delim">Regular expression representing the delimiter string.</param>
 /// <param name="filter">valid import filter</param>
 /// <returns>the name of the imported table</returns>
 /// <seealso cref="ImportReader(System.IO.BufferedReader, Database, string, string, ImportFilter, bool)
 ///     ">ImportReader(System.IO.BufferedReader, Database, string, string, ImportFilter, bool)
 ///     </seealso>
 /// <exception cref="System.IO.IOException"></exception>
 public static string ImportReader(BufferedReader @in, Database db, string name, string
                                   delim, ImportFilter filter)
 {
     return(ImportReader(@in, db, name, delim, filter, false));
 }
コード例 #14
0
ファイル: BeatIncludes.cs プロジェクト: jango2015/Ironclad
 public LabeledInclude(ImportFilter importFilter, BuildObject buildObject)
 {
     this.importFilter = importFilter;
     this.buildObject = buildObject;
 }