예제 #1
0
 private void CallSendScript(List <string> script, DataSynOperation operation)
 {
     if (m_syn.m_outBuffer != null)
     {
         SaveScript(script);
     }
     else
     {
         m_syn.m_target.Connection.Invoke2(DoSendScript, script, operation);
     }
 }
예제 #2
0
        private void DoSendScript(List <string> script, DataSynOperation operation)
        {
            var begin = CreateHolderDumper();
            var end   = CreateHolderDumper();

            if (m_options.DisableConstraints == true)
            {
                begin.Dumper.EnableConstraints(m_item.Target.Table, false);
                end.Dumper.EnableConstraints(m_item.Target.Table, true);
            }
            m_syn.m_dstSada.SendScript(m_syn.m_target.Connection, script, begin.Scripts, end.Scripts, operation, m_syn.m_reportEnv);
        }
예제 #3
0
        public LogReportMode GetModeForOperation(DataSynOperation operation)
        {
            switch (operation)
            {
            case DataSynOperation.Insert:
                return(LogInserts);

            case DataSynOperation.Delete:
                return(LogDeletes);

            case DataSynOperation.Update:
                return(LogUpdates);
            }
            return(LogReportMode.None);
        }
예제 #4
0
        public virtual void SendScript(IPhysicalConnection conn, List <string> script, List <string> batchBegin, List <string> batchEnd, DataSynOperation operation, IDataSynReportEnv repenv)
        {
            var fullcmd = new List <string>();

            if (batchBegin != null)
            {
                fullcmd.AddRange(batchBegin);
            }
            fullcmd.AddRange(script);
            if (batchEnd != null)
            {
                fullcmd.AddRange(batchEnd);
            }
            repenv.SendScriptWrapper(new DataSynScriptWrapper_ExecuteNonQuery(fullcmd.CreateDelimitedText(";\n"), operation, conn.SystemConnection));
        }
예제 #5
0
 public DataSynScriptWrapper_ExecuteNonQuery(string script, DataSynOperation operation, DbConnection conn)
 {
     Operation = operation;
     Script    = script;
     m_conn    = conn;
 }
예제 #6
0
        public override void SendScript(IPhysicalConnection conn, List <string> script, List <string> batchBegin, List <string> batchEnd, DataSynOperation operation, IDataSynReportEnv repenv)
        {
            int maxpacket = Int32.Parse(conn.SystemConnection.ExecuteScalar("select @@max_allowed_packet").ToString());

            string oldmode = conn.SystemConnection.ExecuteScalar("SELECT @@SQL_MODE").ToString();

            string begin = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';\n";

            foreach (string s in batchBegin)
            {
                begin += s + ";\n";
            }
            string end = "SET SQL_MODE='" + oldmode + "';\n";

            foreach (string s in batchEnd)
            {
                end += s + ";\n";
            }

            //try
            //{
            //    conn.SystemConnection.ExecuteNonQuery("SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
            var sb = new StringBuilder();

            foreach (string sql in script)
            {
                if (sb.Length + sql.Length + begin.Length + end.Length > maxpacket / 4)
                {
                    repenv.SendScriptWrapper(new DataSynScriptWrapper_ExecuteNonQuery(begin + sb.ToString() + end, operation, conn.SystemConnection));
                    sb = new StringBuilder();
                }
                sb.Append(sql);
                sb.Append(";");
            }
            if (sb.Length > 0)
            {
                conn.SystemConnection.ExecuteNonQuery(begin + sb.ToString() + end);
            }
            //}
            //finally
            //{
            //    conn.SystemConnection.ExecuteNonQuery("SET SQL_MODE='" + oldmode + "'");
            //}
        }