Example #1
0
        protected override void ImplementBusinessLogic()
        {
            AutoViewFactory factory = new AutoViewFactory(this.Info.AppSqlCon, this);
            View            view    = factory.GetView(Option.ViewName);



            var sql = GetViewSql(view);


            var item = view.Items.FirstOrDefault(p => p.Name == this.Option.ViewItemId);

            if (item.SelectedView != null)
            {
                sql = GetViewSql(item.SelectedView);
            }
            var context = new Soway.Model.Context.InputContext(sql);

            List <Soway.Model.Context.InputQueryResult> list = null;

            Soway.Model.ModelBindingList source = null;
            var sourceExp = "";

            sourceExp = item.ItemSourceExp;
            if (String.IsNullOrEmpty(sourceExp))
            {
                sourceExp = item.Property.Source;
            }

            if (String.IsNullOrEmpty(sourceExp) == false)
            {
                if (Option.IsAdded && String.IsNullOrEmpty(Option.OwnerId) == false && view.Model.Owner != null)
                {
                    var parentObj = new Soway.Model.SqlServer.dbContext(sql, this).GetDetail(view.Model.Owner, Option.OwnerId);
                    var addedItem = new Soway.Model.ObjectProxy(item.Property.Model, this);
                    addedItem.Owner = parentObj;
                    source          = addedItem[sourceExp] as Soway.Model.ModelBindingList;
                }
                else if (String.IsNullOrEmpty(this.Option.ObjID) == false)
                {
                    var obj = new Soway.Model.SqlServer.dbContext(sql, this).GetDetail(view.Model,
                                                                                       this.Option.ObjID);

                    source = new Soway.Model.SqlServer.dbContext(sql, this).GetDetail(view.Model,
                                                                                      this.Option.ObjID)[item.Property.Source] as Soway.Model.ModelBindingList;
                }
            }
            list = context.Query(item.Property.Model, Option.Text, source, null, 5);
            this.QueryResult.Items = new List <QueryItem>();
            foreach (var dataitem in list)
            {
                this.QueryResult.Items.Add(new QueryItem()
                {
                    Id   = dataitem.id.ToString(),
                    Text = dataitem.Text
                });
            }
        }
Example #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);

            Data.AutoFreshTime = view.AutoFreshInterval;

            var objid = this.Option.objId;

            if (string.IsNullOrEmpty((objid ?? "").ToString().Trim()))

            {
                if (string.IsNullOrEmpty((this.Option.IdExp ?? "").Trim()) == false)
                {
                    objid = new Soway.Model.Expressions.GetValueExpression(this).GetValue(null, null, this.Option.IdExp);
                }
                else
                {
                    var getidcontext = new Soway.Model.Context.InputContext(sql).Query(view.Model, "", null, "", 10);
                    objid = getidcontext.First().id;
                }
            }
            global::Soway.Model.SqlServer.dbContext context = new global::Soway.Model.SqlServer.dbContext(sql, this);
            IObjectProxy iObjectProxy = context.GetDetail(view.Model, objid);

            Data.CanEdit    = view.CanEdit;
            Data.Data       = DataFormator.IObjectProxyToDetail(iObjectProxy, view);
            Data.Operations = new List <ViewOperation>();


            foreach (var op in view.Operations)
            {
                Data.Operations.Add(new ViewOperation()
                {
                    Name   = op.Name,
                    ViewID = (op.Operation == null?(op.ResultView == null?0: op.ResultView.ID):(op.Operation.ResultView == null ?0:(op.Operation.ResultView.ID))),
                    ID     = (op.Operation == null ?0: (op.Operation.Operation == null ? 0 : op.Operation.Operation.ID))
                });
            }
        }