Exemple #1
0
        // Ferdi Events
        public override async Task CEFFill(QryProxy request, IServerStreamWriter <CEFProxy> responseStream, ServerCallContext context)
        {
            CEFProxy        proxy     = new CEFProxy();
            List <CEFProxy> proxyList = new List <CEFProxy>();

            Type proxyType = typeof(CEFProxy);

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

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

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

            foreach (var p in proxyList)
            {
                await responseStream.WriteAsync(p);
            }
        }
Exemple #2
0
        public string CEFUpdate()
        {
            StringBuilder sb      = new StringBuilder();
            var           dt      = CEF;
            var           request = new CEFProxy();
            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.CEFUpdate(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());
        }
Exemple #3
0
        public override Task <CEFProxy> CEFUpdate(CEFProxy request, ServerCallContext context)
        {
            Scheduling.RunTask(() =>
            {
                // RowSte: Added, Modified, Deletede, Unchanged
                Db.Transact(() =>
                {
                    if (request.RowSte == "A" || request.RowSte == "M")
                    {
                        if (request.RowErr == string.Empty)
                        {
                            CEF row = CRUDsHelper.FromProxy <CEFProxy, CEF>(request);
                            //XUT.Append(request.RowUsr, row, request.RowSte);
                            request = CRUDsHelper.ToProxy <CEFProxy, CEF>(row);
                        }
                    }
                    else if (request.RowSte == "D")
                    {
                        var row = (CEF)Db.FromId(request.RowKey);
                        if (row == null)
                        {
                            request.RowErr = "CEF Rec not found";
                        }
                        else
                        {
                            var mac = Db.SQL <MAC>("select r from MAC r where r.CEB.ObjectNo = ?", request.RowKey).FirstOrDefault();
                            if (mac != null)
                            {
                                request.RowErr = $"Maçı var, Silemezsiniz";
                            }
                            else
                            {
                                row.Delete();
                            }
                        }
                    }
                });
            }).Wait();

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

            return(Task.FromResult(request));
        }