Exemplo n.º 1
0
        protected override void ImplementBusinessLogic()
        {
            AutoViewFactory factory = new AutoViewFactory(this.Info.AppSqlCon, this);
            View            view    = factory.GetView(this.Option.SaveObj.ViewID);
            var             sql     = GetViewSql(view);

            global::Soway.Model.SqlServer.dbContext context = new global::Soway.Model.SqlServer.dbContext(sql, this);
            IObjectProxy iObjectProxy = new Soway.Model.ObjectProxy(view.Model, this);

            if (String.IsNullOrEmpty(this.Option.OwnerViewId) == false)
            {
                var ownerModel = factory.GetView(this.Option.OwnerViewId).Model;
                var owner      = context.GetDetail(ownerModel, this.Option.OwnerId);
                Soway.Model.ModelBindingList array = owner[this.Option.Property] as Soway.Model.ModelBindingList;
                iObjectProxy = array.AddNew();
                DataFormator.ObjUpdateToProxy(this.Option.SaveObj, iObjectProxy);
                context.Save(owner);
                //iObjectProxy.Owner = new ObjectProxy(ownerModel) { ID = this.Option.OwnerId ,SaveInDB=true,IsLoad= LoadType.Complete};
            }
            else
            {
                DataFormator.ObjUpdateToProxy(this.Option.SaveObj, iObjectProxy);
                context.Create(iObjectProxy);
            }
        }
Exemplo n.º 2
0
        protected override void ImplementBusinessLogic()
        {
            AutoViewFactory factory = new AutoViewFactory(this.Info.AppSqlCon, this);
            View            view    = factory.GetView(this.Option.ViewId);
            var             sql     = GetViewSql(view);

            global::Soway.Model.SqlServer.dbContext context = new global::Soway.Model.SqlServer.dbContext(sql, this);
            IObjectProxy iObjectProxy = new Soway.Model.ObjectProxy(view.Model, this);

            Data.Data = DataFormator.IObjectProxyToDetail(iObjectProxy, view);
            if (String.IsNullOrEmpty((this.Option.ParentObjId ?? "").ToString()) == false)
            {
                Data.Data.ParentId = this.Option.ParentObjId;
            }

            this.Result = Data;
        }
Exemplo n.º 3
0
        private void setProxy(ref IObjectProxy proxy, object ob, Dictionary <object, IObjectProxy> ProxyDic)
        {
            if (ProxyDic.ContainsKey(ob))
            {
                proxy = ProxyDic[ob];
            }
            else
            {
                ProxyDic.Add(ob, proxy);
            }

            foreach (var proerty in proxy.Model.Properties)
            {
                var op =
                    new ReflectionPropertyOperation(proerty, proxy.Model);
                if (proerty.IsArray == false)
                {
                    if (proerty.PropertyType != PropertyType.BusinessObject)
                    {
                        proxy[proerty] = op.Get(ob);
                    }
                    else
                    {
                        var propertyValue = op.Get(ob);
                        if (propertyValue != null)
                        {
                            if (ProxyDic.ContainsKey(propertyValue))
                            {
                                proxy[proerty] = ProxyDic[propertyValue];
                            }
                            else
                            {
                                if (proerty.Model != null)
                                {
                                    IObjectProxy pob = new ObjectProxy(proerty.Model, this.ConFac);

                                    ProxyDic.Add(propertyValue, pob);
                                    this.setProxy(ref pob, propertyValue, ProxyDic);
                                    proxy[proerty] = pob;
                                }
                            }
                        }
                    }
                }
                else
                {
                    dynamic items = op.Get(ob);
                    if (items != null)
                    {
                        dynamic addItem = proxy[proerty];
                        addItem.Clear();
                        foreach (var i in items)
                        {
                            ;
                            if (proerty.PropertyType != PropertyType.BusinessObject)
                            {
                                addItem.Add(i);
                            }
                            else
                            {
                                if (ProxyDic.ContainsKey(i))
                                {
                                    addItem.Add(ProxyDic[i]);
                                }
                                else
                                {
                                    IObjectProxy itemProxy = new ObjectProxy(proerty.Model, this.ConFac);
                                    this.setProxy(ref itemProxy, i, ProxyDic);
                                    addItem.Add(itemProxy);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 internal void SetProxy <T>(ref ObjectProxy proxy, T obj)
 {
 }