예제 #1
0
        public static ScriptSettings InitInstance(IZeusInput input, MyMeta.dbRoot database, Dnp.Utils.Utils dnp, string version)
        {
            if (_instance == null)
            {
                if (input == null)
                {
                    throw new ApplicationException("InitInstance input");
                }

                if (database == null)
                {
                    throw new ApplicationException("InitInstance database");
                }

                if (dnp == null)
                {
                    throw new ApplicationException("InitInstance dnp");
                }

                if (string.IsNullOrEmpty(version))
                {
                    throw new ApplicationException("InitInstance version");
                }

                _instance = new ScriptSettings(input, database, dnp, version);
            }
            return(_instance);
        }
예제 #2
0
 public ScriptSettings(IZeusInput input, MyMeta.dbRoot database, Dnp.Utils.Utils dnp, string version)
 {
     this._input    = input;
     this._database = database;
     this._version  = version;
     this._dnpUtils = dnp;
 }
예제 #3
0
 public ScriptSettings(IZeusInput input, MyMeta.dbRoot database, Dnp.Utils.Utils dnp, string version)
 {
     this._input = input;
     this._database = database;
     this._version = version;
     this._dnpUtils = dnp;
 }
예제 #4
0
        /// <summary>
        /// Call this method first. This initializes everything that is
        /// necessary to run the application.
        /// </summary>
        /// <param name="MyMeta"></param>
        /// <param name="zeus"></param>
        public void Init(MyMeta.dbRoot MyMeta, Zeus.IZeusContext zeus, IZeusInput input, Dnp.Utils.Utils dnp, Dnp.Utils.ProgressDialog progressDialog)
        {
            // Initialize the ScriptSettings and save the input values from the MyGeneration form.
            try
            {
                _scriptSettings = ScriptSettings.InitInstance(input, MyMeta, dnp, _version);
                //_scriptSettings = new ScriptSettings(input, MyMeta, dnp, _version);
                _scriptSettings.SaveSettings();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    throw new Exception("Error Saving ScriptSettings (inner): " + ex.InnerException.Message);
                }
                throw new Exception("Error Saving ScriptSettings: " + ex.Message + " - " + ex.StackTrace.ToString());
            }


            // Populate the RequestContext class with all the values
            // needed to be passed to every code generating class.
            RequestContext context = new RequestContext();

            context.Zeus           = zeus;                                           // Pass along the MyGeneration output context for saving files
            context.MyMeta         = MyMeta;                                         // Pass along the Database meta properties
            context.FileList       = _fileList;                                      // Start the ArrayList for printing the generated files
            context.ScriptSettings = _scriptSettings;                                // Store the saved form values
            context.Dialog         = new ProgressDialogWrapper(progressDialog);      // Get instance of Dialog wrapper
            context.Database       = MyMeta.Databases[_scriptSettings.DatabaseName]; // Get the selected database
            context.Utility        = new CommonUtility();                            // Get instance of helper utility

            _context = context;
        }
예제 #5
0
//
        static public SQLiteConnection CreateConnection(MyMeta.dbRoot dbRoot)
        {
            SQLiteConnection cn = new SQLiteConnection(dbRoot.ConnectionString);

            cn.Open();
            //cn.ChangeDatabase(database);
            return(cn);
        }
예제 #6
0
//
//		static public NpgsqlConnection CreateConnection(MyMeta.dbRoot dbRoot, string database)
//		{
//			string cnstr = dbRoot.ConnectionString + "Database=" + database + ";";
//			NpgsqlConnection cn = new Npgsql.NpgsqlConnection(cnstr);
//			return cn;
//		}

        static public NpgsqlConnection CreateConnection(MyMeta.dbRoot dbRoot, string database)
        {
            NpgsqlConnection cn = new Npgsql.NpgsqlConnection(dbRoot.ConnectionString);

            cn.Open();
            cn.ChangeDatabase(database);
            return(cn);
        }
예제 #7
0
        public SchemaLoader(MyMeta.dbDriver dbDriver, string dbTarget, string language, string connectionString)
        {
            string settingFolder = Path.Combine(Environment.CurrentDirectory, @"Settings");

            if (!System.IO.Directory.Exists(settingFolder))
            {
                System.IO.Directory.CreateDirectory(settingFolder);
            }

            if (!System.IO.File.Exists(this._DbTargetMappingFileName))
            {
                using (Stream input = Assembly.GetAssembly(typeof(IDatabaseInfo)).GetManifestResourceStream("CKGen.Base.Res.DbTargets.xml"))
                using (Stream output = File.Create(this._DbTargetMappingFileName))
                {
                    byte[] buffer = new byte[8192];

                    int bytesRead;
                    while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        output.Write(buffer, 0, bytesRead);
                    }
                }
            }

            if (!System.IO.File.Exists(this._LanguageMappingFileName))
            {
                using (Stream input = Assembly.GetAssembly(typeof(IDatabaseInfo)).GetManifestResourceStream("CKGen.Base.Res.Languages.xml"))
                using (Stream output = File.Create(this._LanguageMappingFileName))
                {
                    byte[] buffer = new byte[8192];

                    int bytesRead;
                    while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        output.Write(buffer, 0, bytesRead);
                    }
                }
            }

            _DbTarget = dbTarget;
            _Language = language;
            _ConnectionString = connectionString;

            _root = new MyMeta.dbRoot();
            _root.DbTargetMappingFileName = this._DbTargetMappingFileName;
            _root.DbTarget = this._DbTarget;

            _root.LanguageMappingFileName = this._LanguageMappingFileName;
            _root.Language = this._Language;
            

            //_root.ShowSystemData = true;

            _dbDriver = dbDriver;

        }
예제 #8
0
 public DotNetScriptGui(IZeusContext context)
     : base(context)
 {
     this.ui = context.Objects["ui"] as Zeus.UserInterface.GuiController;
     this.MyMeta = context.Objects["MyMeta"] as MyMeta.dbRoot;
     this.DnpUtils = context.Objects["DnpUtils"] as Dnp.Utils.Utils;
 }