internal void BeginAsyncQuerySql(string sql, HubbleCommand command, ref int classId, bool priorMessage) { lock (this) { if (_TcpItem == null) { throw new System.IO.IOException("Hasn't connection"); } } if (classId < 0) { classId = _TcpItem.GetClassId(command); } lock (_AsyncQueryLock) { Hubble.Framework.Net.ASyncPackage package = new Hubble.Framework.Net.ASyncPackage( classId, sql); _TcpItem.TcpClient.SendASyncMessage((short)ConnectEvent.ExcuteSql, ref package, priorMessage); } }
/// <summary> /// Get synchronize progress /// </summary> /// <param name="insertRows">output current insert rows</param> /// <returns>progress</returns> /// <remarks>if synchronize finished, return 100</remarks> public double GetProgress(out int insertRows) { HubbleCommand cmd = new HubbleCommand("exec SP_GetTableSyncProgress {0}", _Conn, _TableName); System.Data.DataSet ds = cmd.Query(); double progress = double.Parse(ds.Tables[0].Rows[0]["Progress"].ToString()); insertRows = int.Parse(ds.Tables[0].Rows[0]["InsertRows"].ToString()); if (progress >= 100 || progress < 0) { return(100); } else { return(progress); } }
/// <summary> /// Do synchronize /// </summary> public bool Synchronize() { if (GetProgress() >= 100) { HubbleCommand cmd; if (_Flags == null) { cmd = new HubbleCommand("exec SP_SynchronizeTable {0}, {1}, {2}, {3}", _Conn, _TableName, _Step, (int)_Option, _FastestMode); } else { cmd = new HubbleCommand("exec SP_SynchronizeTable {0}, {1}, {2}, {3}, {4}", _Conn, _TableName, _Step, (int)_Option, _FastestMode, _Flags); } cmd.ExecuteNonQuery(); return(true); } else { return(false); } }
internal void BeginAsyncQuerySql(string sql, HubbleCommand command, ref int classId) { BeginAsyncQuerySql(sql, command, ref classId, false); }
/// <summary> /// Stop synchronize /// </summary> public void Stop() { HubbleCommand cmd = new HubbleCommand("exec SP_StopSynchronizeTable {0}", _Conn, _TableName); cmd.ExecuteNonQuery(); }