Exemple #1
0
        // Players
        public override async Task PPFill(QryProxy request, IServerStreamWriter <PPProxy> responseStream, ServerCallContext context)
        {
            PPProxy        proxy     = new PPProxy();
            List <PPProxy> proxyList = new List <PPProxy>();

            Type proxyType = typeof(PPProxy);

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

            await Scheduling.RunTask(() =>
            {
                foreach (var row in Db.SQL <PP>("select r from PP r"))
                {
                    //proxy = ReflectionExample.ToProxy<AHPproxy, AHP>(row);
                    proxy = CRUDsHelper.ToProxy <PPProxy, PP>(row);

                    /*
                     * proxy = new PPProxy
                     * {
                     *  RowKey = row.GetObjectNo(),
                     *  Ad = row.Ad,
                     *  Sex = row.Sex ?? "",
                     *  Tel = row.Tel ?? "",
                     *  Info = row.Info ?? "",
                     *  IsRun = row.IsRun,
                     *
                     *  RnkIlk = row.RnkBaz,
                     *  RnkBaz = row.RnkBaz,
                     *  RnkSon = row.RnkSon,
                     *  RnkIdx = row.RnkIdx,
                     *
                     *  SST = row.SST,
                     *  SSW = row.SSW,
                     *  SSL = row.SSL,
                     *  SMT = row.SMT,
                     *  SMW = row.SMW,
                     *  SML = row.SML,
                     *  DST = row.DST,
                     *  DSW = row.DSW,
                     *  DSL = row.DSL,
                     *  DMT = row.DMT,
                     *  DMW = row.DMW,
                     *  DML = row.DML,
                     *
                     * };
                     */
                    proxyList.Add(proxy);
                }
            });

            foreach (var p in proxyList)
            {
                await responseStream.WriteAsync(p);
            }
        }
Exemple #2
0
        public string PPUpdate()
        {
            StringBuilder sb      = new StringBuilder();
            var           dt      = PP;
            var           request = new PPProxy();
            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.PPUpdate(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 <PPProxy> PPUpdate(PPProxy request, ServerCallContext context)
        {
            Scheduling.RunTask(() =>
            {
                // RowSte: Added, Modified, Deletede, Unchanged
                Db.Transact(() =>
                {
                    if (request.RowSte == "A" || request.RowSte == "M")
                    {
                        if (request.RowErr == string.Empty)
                        {
                            PP row = CRUDsHelper.FromProxy <PPProxy, PP>(request);
                            //XUT.Append(request.RowUsr, row, request.RowSte);
                            request = CRUDsHelper.ToProxy <PPProxy, PP>(row);
                        }
                    }
                    else if (request.RowSte == "D")
                    {
                        var row = (PP)Db.FromId(request.RowKey);
                        if (row == null)
                        {
                            request.RowErr = "PP Rec not found";
                        }
                        else
                        {
                            // CTP, CF ve MAC da ara varsa sildirme
                            string err = "";
                            var ctp    = Db.SQL <CTP>("select r from CTP r where r.PP = ?", row).FirstOrDefault();
                            if (ctp != null)
                            {
                                err = "CTP kaydı var";
                            }
                            else
                            {
                                var cf = Db.SQL <CF>("select r from CF r where r.PP = ?", row).FirstOrDefault();
                                if (cf != null)
                                {
                                    err = "CF kaydı var";
                                }
                                else
                                {
                                    var mac = Db.SQL <MAC>("select r from MAC r where r.HPP1 = ? or r.HPP2 = ? or r.GPP1 = ? or r.GPP2 = ?", row, row, row, row).FirstOrDefault();
                                    if (mac != null)
                                    {
                                        err = "MAC kaydı var";
                                    }
                                }
                            }
                            if (err == "")
                            {
                                row.Delete();
                            }
                            else
                            {
                                request.RowErr = $"Silemezsiniz! {err}";
                            }
                        }
                    }
                });
            }).Wait();

            return(Task.FromResult(request));
        }