예제 #1
0
 //Закрывает историю
 public void Close()
 {
     try
     {
         if (_subHistory != null)
         {
             _subHistory.Dispose();
         }
         if (_history != null)
         {
             _history.Dispose();
         }
         if (_superHistory != null)
         {
             _superHistory.Dispose();
         }
         if (_errorsRec != null)
         {
             _errorsRec.Dispose();
         }
         if (HistoryDb != null)
         {
             HistoryDb.Dispose();
         }
         _subHistory   = null;
         _history      = null;
         _superHistory = null;
         _errorsRec    = null;
         HistoryDb     = null;
     }
     catch { }
 }
예제 #2
0
        //Получение Tag параметра из SysTabl
        public static string TagS(string file, string param)
        {
            string stSql = "SELECT SysTabl.ParamTag FROM SysTabl WHERE (SysTabl.ParamName='" + param + "')";

            using (var rec = new DaoRec(file, stSql, RecordsetTypeEnum.dbOpenSnapshot, RecordsetOptionEnum.dbReadOnly))
                return(rec.GetString("ParamTag"));
        }
예제 #3
0
        //Получение Tag подпараметра из SysSubTabl
        public static string SubTagS(string file, string param, string subparam)
        {
            string stSql = "SELECT SysSubTabl.SubParamTag FROM SysTabl INNER JOIN SysSubTabl ON SysTabl.ParamId = SysSubTabl.ParamId " +
                           " WHERE (SysTabl.ParamName='" + param + "') AND (SysSubTabl.SubParamName='" + subparam + "')";

            using (var rec = new DaoRec(file, stSql, RecordsetTypeEnum.dbOpenSnapshot, RecordsetOptionEnum.dbReadOnly))
                return(rec.GetString("SubParamTag"));
        }
예제 #4
0
 private void OpenTables(bool useSubTabl)
 {
     _tabl = new DaoRec(_db, "SELECT * FROM SysTabl");
     if (useSubTabl)
     {
         _sub = new DaoRec(_db, "SELECT SysSubTabl.*, SysTabl.ParamName FROM SysTabl INNER JOIN SysSubTabl ON SysTabl.ParamId = SysSubTabl.ParamId");
     }
 }
예제 #5
0
파일: DaoDb.cs 프로젝트: martugin/InfoTask2
 //Добавление параметров в SysTabl
 public void AddSysParam(string templatePath, //Файл с шаблонным SysTabl
                         string paramName)    //Имя параметра
 {
     using (var rec = new DaoRec(File, "SELECT ParamId, ParamName FROM SysTabl WHERE ParamName='" + paramName + "'"))
         if (rec.HasRows)
         {
             return;
         }
     Execute("INSERT INTO SysTabl SELECT ParamName, ParamType, ParamValue, ParamDescription, ParamTag " +
             "FROM [" + templatePath + "].SysTabl t1 WHERE t1.ParamName='" + paramName + "';");
 }
예제 #6
0
파일: DaoDb.cs 프로젝트: martugin/InfoTask2
        //Добавление подпараметров в SysTabl
        public void AddSysSubParam(string templatePath, //Файл с шаблонным SysTabl
                                   string paramName,    //Имя параметра
                                   string subParamName) //Имя подпараметра
        {
            int paramId;

            using (var sysTablRs = new DaoRec(templatePath, "SELECT ParamId,ParamName FROM SysTabl WHERE ParamName='" + paramName + "'"))
                paramId = sysTablRs.GetInt("ParamId");
            Execute("INSERT INTO SysSubTabl " +
                    "SELECT ParamId, SubParamNum, SubParamName,SubParamType, SubParamValue, SubParamDescription, SubParamTag, SubParamRowSource " +
                    "FROM [" + templatePath + "].SysSubTabl t1 WHERE t1.ParamId=" + paramId + " AND t1.SubParamName='" + subParamName +
                    "' AND NOT EXISTS(SELECT * FROM SysSubTabl t2 WHERE t1.SubParamName = t2.SubParamName)");
        }
예제 #7
0
        //Запись Tag параметра в SysTabl
        public static void PutTagS(string file, string param, string tag, string value = null)
        {
            string stSql = "SELECT SysTabl.ParamValue, SysTabl.ParamTag FROM SysTabl WHERE (SysTabl.ParamName='" + param + "')";

            using (var rec = new DaoRec(file, stSql))
            {
                rec.Put("ParamTag", tag);
                if (value != null)
                {
                    rec.Put("ParamValue", value);
                }
                rec.Update();
            }
        }
예제 #8
0
        //Запись Tag подпараметра в SysSubTabl
        public static void PutSubTagS(string file, string param, string subparam, string tag, string value = null)
        {
            string stSql = "SELECT SysSubTabl.SubParamValue, SysSubTabl.SubParamTag FROM SysTabl INNER JOIN SysSubTabl ON SysTabl.ParamId = SysSubTabl.ParamId " +
                           " WHERE (SysTabl.ParamName='" + param + "') AND (SysSubTabl.SubParamName='" + subparam + "')";

            using (var rec = new DaoRec(file, stSql, RecordsetTypeEnum.dbOpenDynaset))
            {
                rec.Put("SubParamTag", tag);
                if (value != null)
                {
                    rec.Put("SubParamValue", value);
                }
                rec.Update();
            }
        }
예제 #9
0
 //Обрамление для операций с таблицами истории
 internal void RunHistoryOperation(DaoRec rec, Action fun)
 {
     if (rec != null)
     {
         try
         {
             fun();
             rec.Update();
         }
         catch (Exception ex)
         {
             AddErrorAboutHistory(ex);
         }
     }
 }
예제 #10
0
        //То же самое, но база данных не задается
        public void SaveDicToTable <T>(DicS <T> dic, string tabl, string keyField = "Code", string keyField2 = "", string delField = "Del") where T : ISaveToRecDao
        {
            var old = new SetS();
            var add = new SetS();

            using (var rec = new DaoRec(this, tabl, RecordsetTypeEnum.dbOpenTable))
                while (rec.Read())
                {
                    var code = rec.GetString(keyField);
                    if (!keyField2.IsEmpty())
                    {
                        code += "." + rec.GetString(keyField2);
                    }
                    if (dic.ContainsKey(code))
                    {
                        old.Add(code);
                    }
                    else
                    {
                        rec.Put(delField, true);
                    }
                }
            Execute("DELETE * FROM " + tabl + " WHERE " + delField + "=True");

            foreach (var ap in dic.Keys)
            {
                if (!old.Contains(ap))
                {
                    add.Add(ap);
                }
            }
            using (var rec = new DaoRec(this, tabl, RecordsetTypeEnum.dbOpenTable))
            {
                while (rec.Read())
                {
                    dic[rec.GetString(keyField) + (keyField2.IsEmpty() ? "" : ("." + rec.GetString(keyField2)))].ToRecordset(rec, false);
                }
                foreach (var p in add.Keys)
                {
                    dic[p].ToRecordset(rec, true);
                }
            }
        }
예제 #11
0
 //Открытие рекордсетов истории и добавление в историю первой записи после создания
 private void OpenHistoryRecs()
 {
     HistoryDb     = new DaoDb(_historyFile);
     _subHistory   = new DaoRec(HistoryDb, "SubHistory");
     _history      = new DaoRec(HistoryDb, "History");
     _superHistory = new DaoRec(HistoryDb, "SuperHistory");
     _errorsRec    = new DaoRec(HistoryDb, "ErrorsList");
     if (_updateReason != null)
     {
         try
         {
             Logger.StartLog(0, 0, "Создание нового файла истории", _updateReason).Finish();
             _updateReason = null;
         }
         catch (OutOfMemoryException) { }
         catch (Exception ex)
         {
             AddErrorAboutHistory(ex);
         }
         _historyId = 0;
     }
 }