コード例 #1
0
        private bool Update_pvoutput_v_1836(DDL ddl, GenConnection con)
        {
            try
            {
                GenCommand cmd = new GenCommand("drop view pvoutput_v", con);
                int res = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                GlobalSettings.LogMessage("VersionManager", "Update_pvoutput_v_1500: exception dropping pvoutput_v: " + e.Message, LogEntryType.ErrorMessage);
            }

            try
            {
                GenCommand cmd = new GenCommand("drop view pvoutput5min_v", con);
                int res = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                GlobalSettings.LogMessage("VersionManager", "Update_pvoutput_v_1500: exception dropping pvoutput5min_v: " + e.Message, LogEntryType.ErrorMessage);
            }

            try
            {
                GenCommand cmd = new GenCommand("drop view pvoutput_sub_v", con);
                int res = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                GlobalSettings.LogMessage("VersionManager", "Update_pvoutput_v_1500: exception dropping pvoutput_sub_v: " + e.Message, LogEntryType.ErrorMessage);
            }

            try
            {
                if (CreateRelation(ddl.View_pvoutput_sub_v_1836, con))
                    if (CreateRelation(ddl.View_pvoutput_v_1836, con))
                        if (CreateRelation(ddl.View_pvoutput5min_v_1836, con))
                            return true;
            }
            catch (Exception e)
            {
                GlobalSettings.LogMessage("VersionManager", "Update_pvoutput_v_1836: exception creating views: " + e.Message, LogEntryType.ErrorMessage);
            }

            return false;
        }
コード例 #2
0
        private bool Update_meterreading_1700(String databaseType, DDL ddl, GenConnection con)
        {
            bool ok = true;
            if (databaseType == "SQLite")
            {
                try
                {
                    GenCommand cmd = new GenCommand("alter table meterreading rename to meterreading_old ", con);
                    int res = cmd.ExecuteNonQuery();
                    ok = res >= 0;
                }
                catch (Exception e)
                {
                    ok = false;
                    GlobalSettings.LogMessage("VersionManager", "Update_meterreading_1700: exception renaming existing: " + e.Message, LogEntryType.ErrorMessage);
                }

                if (!ok)
                    return false;

                if (!CreateRelation(((SQLite_DDL)ddl).Table_meterreading_1700, con))
                    return false;

                List<String> columns = new List<String>();
                columns.Add("Meter_Id");
                columns.Add("ReadingTime");
                columns.Add("Appliance");
                columns.Add("Duration");
                columns.Add("Energy");
                columns.Add("Temperature");
                columns.Add("Calculated");
                columns.Add("MinPower");
                columns.Add("MaxPower");

                if (!CopyToTable("meterreading_old", "meterreading", columns, con))
                    return false;

                try
                {
                    GenCommand cmd = new GenCommand("drop table meterreading_old ", con);
                    int res = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    GlobalSettings.LogMessage("VersionManager", "Update_meterreading_1700: exception dropping old: " + e.Message, LogEntryType.ErrorMessage);
                }
            }
            else
            {
                if (!AlterRelation(ddl.Alter_meterreading_dropPK_1700, con))
                    return false;

                if (!AlterRelation(ddl.Alter_meterreading_createPK_1700, con))
                    return false;
                return true;
            }

            return false;
        }