示例#1
0
        // Teams
        public override async Task CTFill(QryProxy request, IServerStreamWriter <CTProxy> responseStream, ServerCallContext context)
        {
            CTProxy        proxy     = new CTProxy();
            List <CTProxy> proxyList = new List <CTProxy>();

            Type proxyType = typeof(CTProxy);

            PropertyInfo[] proxyProperties = proxyType.GetProperties().Where(x => x.CanRead && x.CanWrite).ToArray();

            await Scheduling.RunTask(() =>
            {
                IEnumerable <CT> rows = null;
                if (request.Query == "CC")
                {
                    rows = Db.SQL <CT>("select r from CT r where r.CC.ObjectNo = ?", ulong.Parse(request.Param));
                }
                else
                {
                    rows = Db.SQL <CT>("select r from CT r");
                }

                foreach (var row in rows)
                {
                    proxy = CRUDsHelper.ToProxy <CTProxy, CT>(row);
                    proxyList.Add(proxy);
                }
            });

            foreach (var p in proxyList)
            {
                await responseStream.WriteAsync(p);
            }
        }
示例#2
0
        public override Task <CTProxy> CTUpdate(CTProxy request, ServerCallContext context)
        {
            Scheduling.RunTask(() =>
            {
                // RowSte: Added, Modified, Deletede, Unchanged
                Db.Transact(() =>
                {
                    if (request.RowSte == "A" || request.RowSte == "M")
                    {
                        if (request.RowErr == string.Empty)
                        {
                            CT row = CRUDsHelper.FromProxy <CTProxy, CT>(request);
                            //XUT.Append(request.RowUsr, row, request.RowSte);
                            request = CRUDsHelper.ToProxy <CTProxy, CT>(row);
                        }
                    }
                    else if (request.RowSte == "D")
                    {
                        var row = Db.FromId(request.RowKey) as CT;
                        if (row == null)
                        {
                            request.RowErr = "CT Rec not found";
                        }
                        else
                        {
                            // CTP ve CET detaylari yoksa sil.
                            var ctp = Db.SQL("select r from CTP r where r.CT = ?", row).FirstOrDefault();
                            if (ctp == null)
                            {
                                var cet = Db.SQL("select r from CET r where r.HCT = ? or r.GCT = ?", row, row).FirstOrDefault();
                                if (cet == null)
                                {
                                    row.Delete();
                                }
                                else
                                {
                                    request.RowErr = $"Event var, Silemezsiniz";
                                }
                            }
                            else
                            {
                                request.RowErr = $"Oyuncuları var, Silemezsiniz";
                            }
                        }
                    }
                });
            }).Wait();

            Session.RunTaskForAll((s, id) =>
            {
                s.CalculatePatchAndPushOnWebSocket();
            });

            return(Task.FromResult(request));
        }
示例#3
0
        public string CTUpdate()
        {
            StringBuilder sb      = new StringBuilder();
            var           dt      = CT;
            var           request = new CTProxy();
            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.CTUpdate(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());
        }