Exemple #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);
            }
        }
        protected override void ImplementBusinessLogic()
        {
            AutoViewFactory factory = new AutoViewFactory();
            View            view    = factory.GetView(mViewId);

            MapViewToResult(view);
        }
Exemple #3
0
        protected override void ImplementBusinessLogic()
        {
            AutoViewFactory factory = new AutoViewFactory(Info.AppSqlCon, this);
            View            view    = factory.GetView(mViewId);

            var sql = this.GetViewSql(view);

            global::Soway.Model.SqlServer.dbContext context = new global::Soway.Model.SqlServer.dbContext(sql, this);
            IObjectProxy iObjectProxy  = context.GetDetail(view.Model, this.mObjectId);
            var          method        = view.Operations.FirstOrDefault(p => p.Operation.Operation.ID == this.mOperationId);
            var          methodContext = new Soway.Model.ModelMethodContext(sql, this);

            if (method != null)
            {
                try
                {
                    methodContext.ExcuteOperation(iObjectProxy, method.Operation.Operation);
                    Data.IsSuccess = true;
                    Data.ReturnMsg = method.Operation.SuccessMsg;
                }
                catch (Exception e)
                {
                    Data.Error     = new ErrorInfo(ErrorDescription.CODE_RUN_OPERATION_ERROR, ErrorDescription.MESSAGE_RUN_OPERATION_ERROR);
                    Data.IsSuccess = false;
                    Data.ReturnMsg = method.Operation.ErrorMsg + e.ToString();
                }
            }
        }
Exemple #4
0
        protected override void ImplementBusinessLogic()
        {
            Data.Token = this.PostData.Token;
            AutoViewFactory factory = new AutoViewFactory(Info.AppSqlCon, this);
            View            view    = factory.GetView(Option.ViewId);

            MapViewToResult(view);
        }
        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
                });
            }
        }
Exemple #6
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 = context.GetDetail(view.Model, this.Option.SaveObj.Id);

            DataFormator.ObjUpdateToProxy(this.Option.SaveObj, iObjectProxy);
            context.Save(iObjectProxy);
        }
        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;
        }
Exemple #8
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))
                });
            }
        }
        protected override void ImplementBusinessLogic()
        {
            AutoViewFactory      factory     = new AutoViewFactory(this.Info.AppSqlCon, this);
            View                 view        = factory.GetView(Option.ViewId);
            var                  sql         = GetViewSql(view);
            ListViewQueryContext context     = new ListViewQueryContext(sql, this);
            var                  orderby     = view.Items.OrderBy(p => p.ShowIndex).First();
            QueryResult          queryResult = context.Query(view, Option.PageIndex, Option.PageSize,
                                                             Option.QueryFilter, orderby, Model.OrderByType.DESC);

            Data.TotalItem = queryResult.TotalItemsCount;
            Data.TotalPage = queryResult.TotalPagesCount;
            Data.PageIndex = queryResult.CurrentPageIndex;
            List <QueryKeyValueResult> result    = new List <QueryKeyValueResult>();
            List <ObjectKeyValuePair>  valueList = new List <ObjectKeyValuePair>();

            Data.FreshTime = this.GetDateTime();
            Data.Cols      = view.Items.Where(p => p.EditType != ItemEditType.Format).Select(P => P.Name).ToList();

            Data.AutoFreshTime = view.AutoFreshInterval;
            foreach (ViewResultItem item in queryResult.CurrentResult)
            {
                QueryKeyValueResult data = new QueryKeyValueResult();
                data.RowIndex = item.RowIndex;
                data.Id       = item.ObjectProxy.ID;
                data.Items    = new DataFormator().IObjectProxyToValue(item.ObjectProxy,
                                                                       view.Items).ToList();

                var fmt = view.Items.FirstOrDefault(p => p.EditType == ItemEditType.Format);
                if (fmt != null)
                {
                    data.RowFmt = (item.ObjectProxy[fmt.Property.Name] ?? "").ToString();
                }
                result.Add(data);
            }

            Data.Data = result;
        }