Exemplo n.º 1
0
        // Donem Players
        public override async Task PPRDFill(QryProxy request, IServerStreamWriter <PPRDProxy> responseStream, ServerCallContext context)
        {
            PPRDProxy        proxy     = new PPRDProxy();
            List <PPRDProxy> proxyList = new List <PPRDProxy>();

            Type proxyType = typeof(PPRDProxy);

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

            await Scheduling.RunTask(() =>
            {
                IEnumerable <PPRD> rows = null;
                if (request.Query == "DD")
                {
                    rows = Db.SQL <PPRD>("select r from PPRD r where r.Dnm = ?", int.Parse(request.Param));
                }
                else
                {
                    rows = Db.SQL <PPRD>("select r from PPRD r");
                }

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

            foreach (var p in proxyList)
            {
                await responseStream.WriteAsync(p);
            }
        }
Exemplo n.º 2
0
        public override Task <PPRDProxy> PPRDUpdate(PPRDProxy request, ServerCallContext context)
        {
            Scheduling.RunTask(() =>
            {
                // RowSte: Added, Modified, Deletede, Unchanged
                Db.Transact(() =>
                {
                    if (request.RowSte == "A")
                    {
                        PPRD row = CRUDsHelper.FromProxy <PPRDProxy, PPRD>(request);
                        request  = CRUDsHelper.ToProxy <PPRDProxy, PPRD>(row);
                    }
                    else if (request.RowSte == "M")
                    {
                        // Sadece IsFerdi degisebilir
                        if (request.RowErr == string.Empty)
                        {
                            PPRD row = CRUDsHelper.FromProxy <PPRDProxy, PPRD>(request);
                            request  = CRUDsHelper.ToProxy <PPRDProxy, PPRD>(row);
                        }
                    }
                    else if (request.RowSte == "D")
                    {
                        request.RowErr = "Silemezsiniz";
                    }
                });
            }).Wait();

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

            return(Task.FromResult(request));
        }
Exemplo n.º 3
0
        public string PPRDUpdate()
        {
            StringBuilder sb      = new StringBuilder();
            var           dt      = PPRD;
            var           request = new PPRDProxy();
            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.PPRDUpdate(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());
        }