// [OperationContract] public PackageData GetDataForGet(Int64 ClientId, Int64 SessionId, DataForGet DataForGet) { PackageData pd = new PackageData(); using (var cnn = SqlExtension.NewSqlConnection) { using (var cmd = cnn.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = String.Format("a2repl.get_{0}_for_client", DataForGet.TableName); cmd.Parameters.AddWithValue("@clientid", ClientId); // 0 cmd.Parameters.AddWithValue("@sessionid", SessionId); // 1 cmd.Parameters.AddWithValue("@id", DataForGet.Id); // 2 using (var rdr = cmd.ExecuteReader()) { do { var di = new DataTable(rdr); while (rdr.Read()) { ReadData(di, rdr); } if (pd.Tables == null) { pd.Tables = new List <DataTable>(); } pd.Tables.Add(di); } while (rdr.NextResult()); } } } pd.SetHasContent(); return(pd); }
// [OperationContract] public PackageData LoadPackage(Int64 ClientId, Int64 SessionId, Int64 PackageId) { var pd = new PackageData(); using (var cnn = SqlExtension.NewSqlConnection) { using (var cmd = cnn.CreateCommandSP("a2repl.package_content_load")) { cmd.Parameters.AddWithValue(String.Empty, (Int32)0).Direction = ParameterDirection.ReturnValue; cmd.Parameters.AddWithValue("@clientid", ClientId); cmd.Parameters.AddWithValue("@sessionid", SessionId); cmd.Parameters.AddWithValue("@pkgid", PackageId); cmd.Parameters.AddWithValue("@nextpkg", (Int64)0).Direction = ParameterDirection.Output; using (var rdr = cmd.ExecuteReader()) { do { var di = new DataTable(rdr); while (rdr.Read()) { di.Read(rdr); } if (di.HasContent) { if (pd.Tables == null) { pd.Tables = new List <DataTable>(); } pd.Tables.Add(di); } } while (rdr.NextResult()); } pd.HasMoreData = (Int32)cmd.Parameters[0].Value != 0; if (pd.HasMoreData) { pd.NextPackageId = (Int64)cmd.Parameters[4].Value; } pd.SetHasContent(); } } return(pd); }