コード例 #1
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _script       = "";
     _scriptObject = null;
     if (Values.Count > 0)
     {
         _script = Values[0];
     }
     if (!string.IsNullOrEmpty(_script))
     {
         var scr = Settings.Settings.Default.GetScriptItem(_script);
         if (scr != null)
         {
             _scriptObject = Script.Manager.Instance.LoadFilterScript(scr.Code);
             if (_scriptObject != null)
             {
                 _scriptInterface = _scriptObject.AlignToInterface <IFilterScript>();
                 if (Values.Count > 1)
                 {
                     var props = GetPropertyValues();
                     Script.Manager.Instance.SetProprtyValues(_scriptObject, props);
                 }
                 _scriptInterface.PrepareRun(this, db, tableName);
             }
         }
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #2
0
        public void RunFlow(ActionFlow flow, Database.DBCon db)
        {
            List <ActionImplementation> orderedActions = null;

            try
            {
                ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("StartingFlow"), flow.Name);
                orderedActions = flow.Actions.OrderByDescending(x => x.Priority).ToList();
                int id = 0;
                foreach (ActionImplementation ai in orderedActions)
                {
                    id++;
                    ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("PreparingAction"), Localization.TranslationManager.Instance.Translate(ai.Name));
                    ai.PrepareRun(db, string.Format("gskwrp{0}", id));
                }

                //find start and run
                ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart;

                startAction.Run(null);
            }
            finally
            {
                foreach (ActionImplementation ai in orderedActions)
                {
                    ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("FinishingAction"), Localization.TranslationManager.Instance.Translate(ai.Name));
                    ai.FinalizeRun();
                }
            }
            ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("FinishedFlow"), flow.Name);
        }
コード例 #3
0
 public void Dispose()
 {
     if (_dbcon != null)
     {
         _dbcon.Dispose();
         _dbcon = null;
     }
 }
コード例 #4
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = "";
     if (Values.Count > 0)
     {
         _value = string.Format("'{0}'", string.Join("','", Values.ToArray()));
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #5
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = "T";
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #6
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _option = Option.Yes;
     if (Values.Count > 0)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[0]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #7
0
ファイル: ActionExport.cs プロジェクト: JensFF/GSAKWrapper
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     if (Values.Count == 0)
     {
         Values.Add("");
     }
     _settings = PrepareSettings(Values[0]);
     return(base.PrepareRun(db, tableName));
 }
コード例 #8
0
        private List <string> AvailableCustomFields(Database.DBCon db)
        {
            var result = new List <string>();
            var dr     = db.ExecuteReader("select fname from CustomLocal");

            while (dr.Read())
            {
                result.Add(dr.GetString(0));
            }
            return(result);
        }
コード例 #9
0
 public virtual bool PrepareRun(Database.DBCon db, string tableName)
 {
     DatabaseConnection = db;
     AssignedTableName  = tableName;
     CreateTableInDatabase(ActionInputTableName);
     foreach (OutputConnectionInfo oci in _outputConnectionInfo)
     {
         oci.PassCounter = 0;
     }
     TotalProcessTime.Reset();
     return(true);
 }
コード例 #10
0
        protected List <string> AvailableCustomFields(Database.DBCon db)
        {
            var result = new List <string>();
            var dr     = db.ExecuteReader("select fname from CustomLocal");

            while (dr.Read())
            {
                result.Add(dr.GetString(0));
            }
            result.AddRange((from a in ApplicationData.Instance.GSAKCustomGlobals select a.fname).ToArray());
            return(result);
        }
コード例 #11
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     if (Values.Count > 0)
     {
         _dateField1 = (DateFields)Enum.Parse(typeof(DateFields), Values[0]);
     }
     if (Values.Count > 1)
     {
         _dateField2 = (DateFields)Enum.Parse(typeof(DateFields), Values[1]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #12
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = true.ToString();
     if (Values.Count > 0)
     {
         bool flag;
         if (bool.TryParse(Values[0], out flag))
         {
             _value = flag ? "1" : "0";
         }
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #13
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     if (Values.Count > 0)
     {
         _all = bool.Parse(Values[0]);
         _ids.Clear();
         for (int i = 1; i < Values.Count; i++)
         {
             _ids.Add(int.Parse(Values[i]));
         }
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #14
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = "Parking Area";
     _count = 0;
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (Values.Count > 1)
     {
         _count = Utils.Conversion.StringToDouble(Values[1]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #15
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value  = DateTime.Now.Date;
     _option = Option.Value;
     if (Values.Count > 0)
     {
         _value = DateTime.ParseExact(Values[0], "yyyy-MM-dd", CultureInfo.InvariantCulture).Date;
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #16
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _option   = Shapefiles.AreaType.State;
     _areaname = "";
     if (Values.Count > 0)
     {
         _option = (Shapefiles.AreaType)Enum.Parse(typeof(Shapefiles.AreaType), Values[0]);
     }
     if (Values.Count > 1)
     {
         _areaname = Values[1];
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #17
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     if (Values.Count > 0)
     {
         try
         {
             _value = Utils.Conversion.StringToDouble(Values[0]);
         }
         catch
         {
         }
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #18
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = DateTime.Now.Date;
     _user  = "******";
     if (Values.Count > 0)
     {
         _value = DateTime.ParseExact(Values[0], "yyyy-MM-dd", CultureInfo.InvariantCulture).Date;
     }
     if (Values.Count > 1)
     {
         _user = Values[1];
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #19
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value  = 0.0;
     _option = Option.Value;
     if (Values.Count > 0)
     {
         _value = Utils.Conversion.StringToDouble(Values[0]);
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #20
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = "";
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (!string.IsNullOrEmpty(_value))
     {
         var opts = Utils.GSAK.AvailableDatabases.ToArray();
         _value = (from a in opts where a == _value select a).FirstOrDefault() ?? "";
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #21
0
        public SqliteSettingsStorage()
        {
            _availableKeys = new Hashtable();
            try
            {
                var sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper");
                RootSettingsFolder = sf;
                if (!Directory.Exists(sf))
                {
                    Directory.CreateDirectory(sf);
                }

                sf = Path.Combine(sf, "settings.db3");
                if (ApplicationRunning)
                {
                    _dbcon = new Database.DBConSqlite(sf);

                    if (!_dbcon.TableExists("settings"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)");
                        _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)");
                    }
                    else
                    {
                        DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings");
                        while (dr.Read())
                        {
                            _availableKeys[dr[0] as string] = dr[1] as string;
                        }
                    }

                    object o = _dbcon.ExecuteScalar("PRAGMA integrity_check");
                    if (o as string == "ok")
                    {
                        //what is expected
                    }
                    else
                    {
                        //oeps?
                        _dbcon.Dispose();
                        _dbcon = null;
                    }
                }
            }
            catch//(Exception e)
            {
                _dbcon = null;
            }
        }
コード例 #22
0
        public SqliteSettingsStorage()
        {
            _availableKeys = new Hashtable();
            try
            {
                var sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper");
                RootSettingsFolder = sf;
                if (!Directory.Exists(sf))
                {
                    Directory.CreateDirectory(sf);
                }

                sf = Path.Combine(sf, "settings.db3");
                if (ApplicationRunning)
                {
                    _dbcon = new Database.DBConSqlite(sf);

                    if (!_dbcon.TableExists("settings"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)");
                        _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)");
                    }
                    else
                    {
                        DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings");
                        while (dr.Read())
                        {
                            _availableKeys[dr[0] as string] = dr[1] as string;
                        }
                    }

                    object o = _dbcon.ExecuteScalar("PRAGMA integrity_check");
                    if (o as string == "ok")
                    {
                        //what is expected
                    }
                    else
                    {
                        //oeps?
                        _dbcon.Dispose();
                        _dbcon = null;
                    }
                }
            }
            catch//(Exception e)
            {
                _dbcon = null;
            }
        }
コード例 #23
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _option     = Option.Yes;
     _collection = "";
     if (Values.Count > 0)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[0]);
     }
     if (Values.Count > 1)
     {
         _collection = Values[1];
     }
     if (!string.IsNullOrEmpty(_collection))
     {
         var opts = (from a in Settings.Settings.Default.GetGeocacheCollections() select a.Name).ToArray();
         _collection = (from a in opts where string.Compare(a, _collection, true) == 0 select a).FirstOrDefault() ?? "";
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #24
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value         = "";
     _option        = Option.Contains;
     _userDataField = UserDataField.UserData;
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = (UserDataField)Enum.Parse(typeof(UserDataField), Values[2]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #25
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value       = 2000;
     _sortoption  = SortOption.Ascending;
     _fieldoption = FieldOption.DistanceFromCenter;
     if (Values.Count > 0)
     {
         int.TryParse(Values[0], out _value);
     }
     if (Values.Count > 1)
     {
         _sortoption = (SortOption)Enum.Parse(typeof(SortOption), Values[1]);
     }
     if (Values.Count > 2)
     {
         _fieldoption = (FieldOption)Enum.Parse(typeof(FieldOption), Values[2]);
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #26
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _option   = Option.Yes;
     _database = "";
     if (Values.Count > 0)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[0]);
     }
     if (Values.Count > 1)
     {
         _database = Values[1];
     }
     if (!string.IsNullOrEmpty(_database))
     {
         var opts = Utils.GSAK.AvailableDatabases.ToArray();
         _database = (from a in opts where a == _database select a).FirstOrDefault() ?? "";
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #27
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value = "Found it";
     _count = 0;
     _user  = "******";
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (Values.Count > 1)
     {
         _count = Utils.Conversion.StringToDouble(Values[1]);
     }
     if (Values.Count > 2)
     {
         _user = Values[2];
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #28
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _level  = AreaType.State;
     _prefix = "";
     _field  = "";
     if (Values.Count > 0)
     {
         _level = (AreaType)Enum.Parse(typeof(AreaType), Values[0]);
     }
     if (Values.Count > 1)
     {
         _prefix = Values[1];
     }
     if (Values.Count > 2)
     {
         _field = Values[2];
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #29
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value         = DateTime.Now.Date;
     _option        = Option.Value;
     _userDataField = "";
     if (Values.Count > 0)
     {
         _value = DateTime.ParseExact(Values[0], "yyyy-MM-dd", CultureInfo.InvariantCulture).Date;
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = Values[2];
         var cf = AvailableCustomFields(db);
         _userDataField = (from a in cf where string.Compare(a, _userDataField, true) == 0 select a).FirstOrDefault() ?? "";
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #30
0
 public override bool PrepareRun(Database.DBCon db, string tableName)
 {
     _value         = "";
     _option        = Option.Contains;
     _userDataField = "";
     if (Values.Count > 0)
     {
         _value = Values[0];
     }
     if (Values.Count > 1)
     {
         _option = (Option)Enum.Parse(typeof(Option), Values[1]);
     }
     if (Values.Count > 2)
     {
         _userDataField = Values[2];
         var cf = AvailableCustomFields(db);
         _userDataField = (from a in cf where string.Compare(a, _userDataField, true) == 0 select a).FirstOrDefault() ?? "";
     }
     return(base.PrepareRun(db, tableName));
 }
コード例 #31
0
 public void Dispose()
 {
     if (_dbcon!=null)
     {
         _dbcon.Dispose();
         _dbcon = null;
     }
 }
コード例 #32
0
        public SqliteSettingsStorage()
        {
            _availableKeys = new Hashtable();
            try
            {
                var sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper");
                RootSettingsFolder = sf;
                if (!Directory.Exists(sf))
                {
                    Directory.CreateDirectory(sf);
                }

                sf = Path.Combine(sf, "settings.db3");
                if (ApplicationRunning)
                {
                    _dbcon = new Database.DBConSqlite(sf);

                    if (!_dbcon.TableExists("settings"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)");
                        _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)");
                    }
                    else
                    {
                        DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings");
                        while (dr.Read())
                        {
                            _availableKeys[dr[0] as string] = dr[1] as string;
                        }
                    }

                    if (!_dbcon.TableExists("formulasolv"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'formulasolv' (gccode text, formula text)");
                        _dbcon.ExecuteNonQuery("create index idx_form on formulasolv (gccode)");
                    }

                    if (!_dbcon.TableExists("GeocacheCollection"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'GeocacheCollection' (CollectionID integer not null, Name text not null)");
                        _dbcon.ExecuteNonQuery("create index idx_gckey on GeocacheCollection (CollectionID)");
                        _dbcon.ExecuteNonQuery("create index idx_gcname on GeocacheCollection (Name)");
                    }
                    if (!_dbcon.TableExists("GeocacheCollectionItem"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'GeocacheCollectionItem' (CollectionID integer not null, GeocacheCode text not null, Name text not null)");
                        _dbcon.ExecuteNonQuery("create unique index idx_gcikey on GeocacheCollectionItem (CollectionID, GeocacheCode)");

                        _dbcon.ExecuteNonQuery("CREATE TRIGGER Delete_GeocacheCollection Delete ON GeocacheCollection BEGIN delete from GeocacheCollectionItem where CollectionID = old.CollectionID; END");
                    }
                    if (!_dbcon.TableExists("ShapeFileItemV2"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'ShapeFileItemV2' (FileName text, TableName text not null, CoordType text not null, AreaType text not null, NamePrefix text, Encoding text not null, Enabled integer not null)");
                    }
                    if (!_dbcon.TableExists("Scripts"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'Scripts' (Name text not null, ScriptType integer not null, Code text not null)");
                        _dbcon.ExecuteNonQuery("create unique index idx_scname on Scripts (Name)");
                    }

                    object o = _dbcon.ExecuteScalar("PRAGMA integrity_check");
                    if (o as string == "ok")
                    {
                        //what is expected
                    }
                    else
                    {
                        //oeps?
                        _dbcon.Dispose();
                        _dbcon = null;
                    }
                }
            }
            catch//(Exception e)
            {
                _dbcon = null;
            }
        }
コード例 #33
0
 public virtual bool PrepareRun(Database.DBCon db, string tableName)
 {
     DatabaseConnection = db;
     AssignedTableName = tableName;
     CreateTableInDatabase(ActionInputTableName);
     foreach (OutputConnectionInfo oci in _outputConnectionInfo)
     {
         oci.PassCounter = 0;
     }
     TotalProcessTime.Reset();
     return true;
 }