Exemplo n.º 1
0
        //---------------------------------------------------------------------------------------------------------------------

        public ServiceItem(AdminTool tool, string identifier, string baseDir) : base(tool, identifier, baseDir)
        {
            try {
                IDataReader reader = Tool.GetQueryResult(String.Format("SELECT id, version, c_version FROM $MAIN$.service WHERE identifier={0};", StringUtils.EscapeSql(Identifier)));
                if (reader.Read())
                {
                    this.Id                 = reader.GetInt32(0);
                    this.Version            = (reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1));
                    this.CleanupVersion     = (reader.GetValue(2) == DBNull.Value ? this.Version : reader.GetString(2));
                    this.PreviousVersion    = Version;
                    this.WasInstalledBefore = this.IsInstalled;
                }
                reader.Close();
                if (!this.Exists)
                {
                    tool.Execute(String.Format("INSERT INTO $MAIN$.service (id_type, available, identifier, name, description, version) VALUES ({0}, true, {1}, {1}, {1}, {2});", ScriptBasedServiceTypeId, StringUtils.EscapeSql(Identifier), StringUtils.EscapeSql(Version)));
                    SetId();
                    tool.Execute(String.Format("INSERT INTO $MAIN$.scriptservice (id, root) VALUES ({0}, {1});", Id, StringUtils.EscapeSql("$(SERVICEROOT)/" + Identifier)));
                }
            } catch (Exception e) {
                if (Tool.Interactive)
                {
                    Console.Error.WriteLine("ERROR: Could not add service: {0}", e.Message);
                }
            }
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------------------------------------------------------

        public Module(AdminTool tool, string identifier, string baseDir) : base(tool, identifier, baseDir)
        {
            Dependencies = new List <Module>();
            distance     = -1;
            Load();
            if (!Exists)
            {
                tool.Execute(String.Format("INSERT INTO $MAIN$.module (name) VALUES ({0});", StringUtils.EscapeSql(Identifier)));
                SetId();
            }
        }