// Team Players public override async Task CTPFill(QryProxy request, IServerStreamWriter <CTPProxy> responseStream, ServerCallContext context) { CTPProxy proxy = new CTPProxy(); List <CTPProxy> proxyList = new List <CTPProxy>(); Type proxyType = typeof(CTPProxy); PropertyInfo[] proxyProperties = proxyType.GetProperties().Where(x => x.CanRead && x.CanWrite).ToArray(); await Scheduling.RunTask(() => { IEnumerable <CTP> rows = null; if (request.Query == "CT") { rows = Db.SQL <CTP>("select r from CTP r where r.CT.ObjectNo = ?", ulong.Parse(request.Param)); } else { rows = Db.SQL <CTP>("select r from CTP r "); } foreach (var row in rows) { proxy = CRUDsHelper.ToProxy <CTPProxy, CTP>(row); /* * proxy = new CTProxy * { * RowKey = row.GetObjectNo(), * CC = row.CC == null ? 0 : row.CC.GetObjectNo(), * K1 = row.K1 == null ? 0 : row.K1.GetObjectNo(), * K2 = row.K2 == null ? 0 : row.K1.GetObjectNo(), * * Ad = row.Ad, * Adres = row.Adres ?? "", * Info = row.Info ?? "", * NG = row.NG, * NM = row.NM, * NB = row.NB, * NT = row.NT, * NX = row.NX, * KA = row.KA, * KV = row.KV, * KF = row.KF, * PW = row.PW, * * IsRun = row.IsRun, * }; */ proxyList.Add(proxy); } }); foreach (var p in proxyList) { await responseStream.WriteAsync(p); } }
public string CTPUpdate() { StringBuilder sb = new StringBuilder(); var dt = CTP; var request = new CTPProxy(); string rs = ""; // Unchanged disindakileri gonder, deleted disindakileri reply ile guncelle, hata yoksa her rec icin AcceptChanges for (int i = 0; i < dt.Rows.Count; i++) { // States: Added, Modified, Deletede, Unchanged rs = dt.Rows[i].RowState.ToString().Substring(0, 1); if (rs == "A" || rs == "M" || rs == "D") { dt.Rows[i].ClearErrors(); request.RowSte = rs; //request.RowUsr = Program.ObjUsr; if (rs == "D") { request.RowKey = (ulong)dt.Rows[i]["RowKey", DataRowVersion.Original]; } else { ProxyHelper.RowToProxy(dt, dt.Rows[i], request); } var reply = grpcService.ClientCRUDs.CTPUpdate(request); // ---------> if (string.IsNullOrEmpty(reply.RowErr)) { if (rs != "D") { ProxyHelper.ProxyToRow(dt, dt.Rows[i], reply); } dt.Rows[i].AcceptChanges(); } else { dt.Rows[i].RowError = reply.RowErr; sb.AppendLine(reply.RowErr); dt.Rows[i].RejectChanges(); } } } return(sb.ToString()); }
public override Task <CTPProxy> CTPUpdate(CTPProxy request, ServerCallContext context) { Scheduling.RunTask(() => { // RowSte: Added, Modified, Deletede, Unchanged Db.Transact(() => { if (request.RowSte == "A") { CTP row = CRUDsHelper.FromProxy <CTPProxy, CTP>(request); H.PPRD_TryInsert(row.PP, row.CC.Dnm); request = CRUDsHelper.ToProxy <CTPProxy, CTP>(row); } else if (request.RowSte == "M") { // CC ve PP degistirilemez var oRow = (CTP)Db.FromId(request.RowKey); if (oRow.PP.GetObjectNo() != request.PP) { request.RowErr = "Oyuncu değiştiremezsiniz. Silip yenisini girin."; } else if (oRow.CC.GetObjectNo() != request.CC) { request.RowErr = "Turnuva değiştiremezsiniz. Silip yenisini girin."; } if (request.RowErr == string.Empty) { CTP row = CRUDsHelper.FromProxy <CTPProxy, CTP>(request); H.PPRD_TryInsert(row.PP, row.CC.Dnm); request = CRUDsHelper.ToProxy <CTPProxy, CTP>(row); } } else if (request.RowSte == "D") { var row = Db.FromId(request.RowKey) as CTP; if (row == null) { request.RowErr = "CTP Rec not found"; } else // Silinmesinde sakinca yok { PP pp = row.PP; int dnm = row.CC.Dnm; row.Delete(); H.PPRD_TryDelete(pp, dnm); /* * var mac = Db.SQL<MAC>("select r from MAC r where r.CC = ? and (r.HPP1 = ? or r.HPP2 = ? or r.GPP1 = ? or r.GPP2 = ?)", row.CC, row.PP, row.PP, row.PP, row.PP).FirstOrDefault(); * if (mac != null) * request.RowErr = "MAC kaydı var. Silemezsiniz"; * else * { * PP pp = row.PP; * int dnm = row.CC.Dnm; * row.Delete(); * H.PPRD_TryDelete(pp, dnm); * }*/ } } }); }).Wait(); Session.RunTaskForAll((s, id) => { s.CalculatePatchAndPushOnWebSocket(); }); return(Task.FromResult(request)); }