Ejemplo n.º 1
0
        private string SQLServer_InsertMessageScript()
        {
            DatabaseQueue queue     = Settings.DatabaseSettings.DatabaseQueue;
            string        tableName = queue.TableName;
            string        field1    = queue.Fields.Where(f => f.Property == "МоментВремени").FirstOrDefault()?.Name;
            string        field2    = queue.Fields.Where(f => f.Property == "Идентификатор").FirstOrDefault()?.Name;
            string        field3    = queue.Fields.Where(f => f.Property == "ДатаВремя").FirstOrDefault()?.Name;
            string        field4    = queue.Fields.Where(f => f.Property == "Отправитель").FirstOrDefault()?.Name;
            string        field5    = queue.Fields.Where(f => f.Property == "ТипОперации").FirstOrDefault()?.Name;
            string        field6    = queue.Fields.Where(f => f.Property == "ТипСообщения").FirstOrDefault()?.Name;
            string        field7    = queue.Fields.Where(f => f.Property == "ТелоСообщения").FirstOrDefault()?.Name;
            string        field8    = queue.Fields.Where(f => f.Property == "КоличествоОшибок").FirstOrDefault()?.Name;
            string        field9    = queue.Fields.Where(f => f.Property == "ОписаниеОшибки").FirstOrDefault()?.Name;

            StringBuilder script = new StringBuilder();

            script.AppendLine($"INSERT [{tableName}]");
            script.AppendLine($"([{field1}], [{field2}], [{field3}], [{field4}], [{field5}], [{field6}], [{field7}], [{field8}], [{field9}])");
            script.AppendLine("VALUES (@p1, CAST(@p2 AS binary(16)), @p3, @p4, @p5, @p6, @p7, @p8, @p9);");
            return(script.ToString());
        }
Ejemplo n.º 2
0
        private string PostgreSQL_InsertMessageScript()
        {
            DatabaseQueue queue     = Settings.DatabaseSettings.DatabaseQueue;
            string        tableName = queue.TableName;
            string        field1    = queue.Fields.Where(f => f.Property == "МоментВремени").FirstOrDefault()?.Name;
            string        field2    = queue.Fields.Where(f => f.Property == "Идентификатор").FirstOrDefault()?.Name;
            string        field3    = queue.Fields.Where(f => f.Property == "ДатаВремя").FirstOrDefault()?.Name;
            string        field4    = queue.Fields.Where(f => f.Property == "Отправитель").FirstOrDefault()?.Name;
            string        field5    = queue.Fields.Where(f => f.Property == "ТипОперации").FirstOrDefault()?.Name;
            string        field6    = queue.Fields.Where(f => f.Property == "ТипСообщения").FirstOrDefault()?.Name;
            string        field7    = queue.Fields.Where(f => f.Property == "ТелоСообщения").FirstOrDefault()?.Name;
            string        field8    = queue.Fields.Where(f => f.Property == "КоличествоОшибок").FirstOrDefault()?.Name;
            string        field9    = queue.Fields.Where(f => f.Property == "ОписаниеОшибки").FirstOrDefault()?.Name;

            StringBuilder script = new StringBuilder();

            script.AppendLine($"INSERT INTO {tableName}");
            script.AppendLine($"({field1}, {field2}, {field3}, {field4}, {field5}, {field6}, {field7}, {field8}, {field9})");
            script.AppendLine("VALUES (@p1, @p2, @p3, CAST(@p4 AS mvarchar), CAST(@p5 AS mvarchar), ");
            script.AppendLine("CAST(@p6 AS mvarchar), CAST(@p7 AS mvarchar), @p8, CAST(@p9 AS mvarchar));");
            return(script.ToString());
        }