/// <summary> /// Tests the connection. /// </summary> /// <param name="message">The message.</param> /// <returns></returns> public bool TestConnection(out String message) { try { message = String.Empty; SyncSoap sync = new SyncSoapClient(); return(sync.TestConnection()); } catch (Exception ex) { message = ex.Message; return(false); } }
/// <summary> /// Does the sync master. /// </summary> public void DoSyncMaster() { try { messageBuilder.Clear(); messageBuilder.AppendLine("Start sync at " + DateTime.Now); Update(0, "Kiểm tra kết nối tới server..."); SyncSoap sync = new SyncSoapClient(); String message; if (!TestConnection(out message)) { Update(0, "Không kết nối được tới máy chủ. Kiểm tra lại đường truyền (" + message + ")"); return; } Update(2, "Tải về dữ liệu"); var dataset = sync.GetMasterData(); var connection = new SqlConnection(GetConnectionString()); Update(5, "Cập nhập dữ liệu "); var adapter = new DefineAdapter(connection); adapter.Sync(dataset.Tables[0]); Update(10, "Cập nhập dữ liệu thuốc "); var medicineAdater = new MedicineAdapter(connection); medicineAdater.Sync(dataset.Tables[1]); Update(15, "Cập nhập dữ liệu phác đồ "); var figureAdapter = new FigureAdapter(connection); figureAdapter.Sync(dataset.Tables[2]); Update(18, "Cập nhập dữ liệu phác đồ "); var figureDetailAdapter = new FigureDetailAdapter(connection); figureDetailAdapter.Sync(dataset.Tables[3]); Update(20, "Cập nhập dữ liệu dự trù "); var medicinePlanAdapter = new MedicinePlanAdapter(connection); medicinePlanAdapter.Sync(dataset.Tables[4]); } catch (Exception ex) { Update(100, "Error: " + ex.Message); throw; } }
/// <summary> /// Gets the sync table. /// </summary> /// <param name="key">The key.</param> /// <param name="clinicId">The clinic id.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> private void DoSync(String key, int clinicId) { ClientAdapterBase clientAdapter = CreateAdapter(key); SyncSoap syncObject = new SyncSoapClient(); int counting = 0; string message; var ds = new DataSet(); var table = clientAdapter.GetData(key, 500, out counting); ds.Tables.Add(table); var result = syncObject.SyncTable(out message, clinicId, ds); if (result) { clientAdapter.Update(table); } else { throw new Exception(message); } }
/// <summary> /// Does the remove. /// </summary> /// <param name="key">The key.</param> /// <param name="clinicId">The clinic id.</param> /// <exception cref="System.Exception"></exception> private void DoRemove(String key, int clinicId) { SqlConnection connection = new SqlConnection(GetConnectionString()); TableChangeClientAdapter clientAdapter = new TableChangeClientAdapter(connection, key); SyncSoap syncObject = new SyncSoapClient(); int counting = 0; string message; var ds = new DataSet(); var table = clientAdapter.GetData(key, 500, out counting); ds.Tables.Add(table); var result = syncObject.Remove(out message, clinicId, ds); if (result) { clientAdapter.Update(table); } else { throw new Exception(message); } }
/// <summary> /// Gets the sync table. /// </summary> /// <param name="key">The key.</param> /// <param name="clinicId">The clinic id.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> private void DoSync(String key, int clinicId) { ClientAdapterBase clientAdapter = CreateAdapter(key); SyncSoap syncObject = new SyncSoapClient(); int counting = 0; string message; var ds = new DataSet(); var table = clientAdapter.GetData(key, 500, out counting); ds.Tables.Add(table); var result = syncObject.SyncTable(out message, clinicId, ds); if (result) clientAdapter.Update(table); else throw new Exception(message); }
/// <summary> /// Does the remove. /// </summary> /// <param name="key">The key.</param> /// <param name="clinicId">The clinic id.</param> /// <exception cref="System.Exception"></exception> private void DoRemove(String key, int clinicId) { SqlConnection connection = new SqlConnection(GetConnectionString()); TableChangeClientAdapter clientAdapter = new TableChangeClientAdapter(connection, key); SyncSoap syncObject = new SyncSoapClient(); int counting = 0; string message; var ds = new DataSet(); var table = clientAdapter.GetData(key, 500, out counting); ds.Tables.Add(table); var result = syncObject.Remove(out message, clinicId, ds); if (result) clientAdapter.Update(table); else throw new Exception(message); }
/// <summary> /// Tests the connection. /// </summary> /// <param name="message">The message.</param> /// <returns></returns> public bool TestConnection(out String message) { try { message = String.Empty; SyncSoap sync = new SyncSoapClient(); return sync.TestConnection(); } catch (Exception ex) { message = ex.Message; return false; } }