Пример #1
0
        /// <summary>
        /// Save to <paramref name="fileName"/> the list of references
        /// </summary>
        /// <param name="fileName">output file name</param>
        /// <remarks>Do not write out the builtin references neither broken references. If you need to export a broken reference, first fix it</remarks>
        public override void Save(string fileName)
        {
            //Make sure the path exists
            MakePath(System.IO.Path.GetDirectoryName(fileName));

            using (StreamWriter sw = new StreamWriter(fileName)) {
                ExportObject export = new ExportObject(sw);

                export.WriteBegin(ClassName);
                foreach (Access.Reference reference in App.Application.References)
                {
                    if (!reference.BuiltIn && !reference.IsBroken)
                    {
                        export.WriteBegin("Reference", reference.Name);
                        export.WriteProperty("FullPath", reference.FullPath);
                        if (reference.Kind == Microsoft.Vbe.Interop.vbext_RefKind.vbext_rk_TypeLib)
                        {
                            export.WriteProperty("Guid", reference.Guid);
                            export.WriteProperty("Major", reference.Major);
                            export.WriteProperty("Minor", reference.Minor);
                            export.WriteEnd();
                        }
                    }
                }
                export.WriteEnd();
            }
        }
Пример #2
0
        public override void Save(string fileName)
        {
            //Make sure the path exists
            MakePath(System.IO.Path.GetDirectoryName(fileName));

            using (StreamWriter sw = new StreamWriter(fileName)) {
                ExportObject export = new ExportObject(sw);

                dao.Database db = App.Application.CurrentDb();

                export.WriteBegin(ClassName);
                foreach (dao.Relation relation in db.Relations)
                {
                    export.WriteBegin("Relation", relation.Name);
                    export.WriteProperty("Attributes", relation.Attributes);
                    export.WriteProperty("ForeignTable", relation.ForeignTable);
                    export.WriteProperty("Table", relation.Table);
                    //try { export.WriteProperty("PartialReplica", relation.PartialReplica); } catch { }      //Accessing this property causes an exception ¿?
                    export.WriteBegin("Fields");
                    foreach (dao.Field fld in relation.Fields)
                    {
                        export.WriteBegin("Field");
                        export.WriteProperty("Name", fld.Name);
                        export.WriteProperty("ForeignName", fld.ForeignName);
                        export.WriteEnd();
                    }
                    export.WriteEnd();
                    export.WriteEnd();
                }
                export.WriteEnd();
            }
        }
Пример #3
0
        /// <summary>
        /// Save table defintion to <paramref name="fileName"/>
        /// </summary>
        /// <param name="fileName">File name where save the table definition</param>
        public override void Save(string fileName)
        {
            MakePath(System.IO.Path.GetDirectoryName(fileName));

            dao.DBEngine dbEngine = new dao.DBEngine();
            dao.Database db       = dbEngine.OpenDatabase(App.FileName);
            dao.TableDef tbDef    = db.TableDefs[Name];

            using (StreamWriter sw = new StreamWriter(fileName)) {
                ExportObject export = new ExportObject(sw);
                //export.ListProperties(tbDef.Name, tbDef.Properties);
                export.WriteBegin(ClassName, TableName);
                export.WriteProperty("Attributes", tbDef.Attributes);
                export.WriteProperty("Connect", tbDef.Connect);
                export.WriteProperty("SourceTableName", tbDef.SourceTableName);
                export.WriteProperty("ValidationRule", tbDef.ValidationRule);
                export.WriteProperty("ValidationText", tbDef.ValidationText);

                PropertyCollectionDao propColl = new PropertyCollectionDao(tbDef, tbDef.Properties);
                propColl.TryWriteProperty(export, "Description");
                propColl.TryWriteProperty(export, "ConflictTable");
                propColl.TryWriteProperty(export, "ReplicaFilter");
                propColl.TryWriteProperty(export, "Orientation");
                propColl.TryWriteProperty(export, "OrderByOn");
                propColl.TryWriteProperty(export, "SubdatasheetName");
                propColl.TryWriteProperty(export, "LinkChildFields");
                propColl.TryWriteProperty(export, "LinkMasterFields");
                propColl.TryWriteProperty(export, "SubdatasheetHeight");
                propColl.TryWriteProperty(export, "SubdatasheetExpanded");
                propColl.TryWriteProperty(export, "DefaultView");
                propColl.TryWriteProperty(export, "OrderBy");

                export.WriteBegin("Fields");
                foreach (dao.Field field in tbDef.Fields)
                {
                    export.WriteObject(new Field(field));
                }
                export.WriteEnd();      //End Fields
                export.WriteBegin("Indexes");
                //TODO: Add new option menu to ignore linked tables errors if the linked document do not exist
                //      Check if the linked document exists before iterate the indexes collection
                foreach (dao.Index daoIndex in tbDef.Indexes)
                {
                    export.WriteObject(new Index(daoIndex));
                }
                export.WriteEnd();  //End Indexes
                export.WriteEnd();  //End Table
            }
            db.Close();
        }
Пример #4
0
 public override void SaveProperties(ExportObject export)
 {
     export.WriteProperty("Name", daoIndex.Name);
     export.WriteProperty("Primary", daoIndex.Primary);
     export.WriteProperty("Unique", daoIndex.Unique);
     export.WriteProperty("IgnoreNulls", daoIndex.IgnoreNulls);
     export.WriteProperty("Required", daoIndex.Required);
     export.WriteBegin("Fields");
     dao.IndexFields idxFiels = (dao.IndexFields)daoIndex.Fields;
     for (int i = 0; i < idxFiels.Count; i++)
     {
         dao.Field fld = (dao.Field)idxFiels[i];
         export.WriteBegin("Field");
         export.WriteProperty("Name", fld.Name);
         export.WriteProperty("Attributes", fld.Attributes); //Descending order (dao.FieldAttributeEnum.dbDescending)
         export.WriteEnd();
     }
     export.WriteEnd();
 }
Пример #5
0
        public override void Save(string fileName)
        {
            Dictionary <string, IPropertyTransform> propsToWrite = gatherProperties();

            //Make sure the path exists
            MakePath(System.IO.Path.GetDirectoryName(fileName));

            //Write the properties with help of an ExportObject
            using (StreamWriter sw = new StreamWriter(fileName)) {
                ExportObject export     = new ExportObject(sw);
                string       dbFileName = System.IO.Path.GetFileName(App.FileName);
                export.WriteBegin(ClassName, dbFileName);
                foreach (string item in propsToWrite.Keys)
                {
                    propsToWrite[item].WriteTransform(export, App.Application.CurrentProject.Properties[item]);
                }
                export.WriteEnd();
            }
        }