예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserUtil.GotoLoginIfNoSuperadmin();

            var logicID = DataConverter.ToNullableGuid(Request["LogicID"]);
            var tableID = DataConverter.ToNullableGuid(Request["TableID"]);

            var logic = DataContext.LP_Logics.FirstOrDefault(n => n.ID == logicID);

            if (logic == null)
            {
                return;
            }

            var table = DataContext.LP_Tables.FirstOrDefault(n => n.ID == tableID);

            if (table == null)
            {
                return;
            }

            var logicConverter = new LogicEntityModelConverter(DataContext);
            var tableConverter = new TableEntityModelConverter(DataContext);

            var logicModel = logicConverter.Convert(logic);
            var tableModel = tableConverter.Convert(table);

            var tableDataModel = new TableDataModel
            {
                Table = tableModel,
                Logic = logicModel,
            };

            tableDataControl.Model = tableDataModel;
        }
예제 #2
0
        protected IList <String> GetLogicOutputColumns(Guid logicID)
        {
            var logic = DataContext.LP_Logics.Single(n => n.ID == logicID);

            var converter = new LogicEntityModelConverter(DataContext);
            var model     = converter.Convert(logic);

            if (model.Type == "Query")
            {
                return(GetQueryOutputColumns(model.Query));
            }

            var queryGen = new QueryGenerator(DataContext, model);
            var columns  = queryGen.OutputColumns.ToList();

            return(columns);
        }
예제 #3
0
        private void FillLogicsGrid()
        {
            var entities = (from n in DataContext.LP_Logics
                            where n.DateDeleted == null
                            orderby n.DateCreated descending
                            select n).ToList();

            var converter = new LogicEntityModelConverter(DataContext);

            var models = (from n in entities
                          let m = converter.Convert(n)
                                  select m).ToList();

            var model = new LogicsModel();

            model.List = models;

            logicsControl.Model = model;
        }
예제 #4
0
        protected override void OnGetModel(object model, Type type)
        {
            var reportLogicModel = model as ReportLogicModel;

            if (reportLogicModel == null)
            {
                return;
            }

            if (reportLogicModel.Type != "Grid")
            {
                reportLogicModel.Type = cbxType.TryGetStringValue();
            }

            var logicID = cbxLogic.TryGetGuidValue();

            if (logicID != null)
            {
                var logicEntity = DataContext.LP_Logics.Single(n => n.ID == logicID);

                var converter  = new LogicEntityModelConverter(DataContext);
                var logicModel = converter.Convert(logicEntity);

                reportLogicModel.Logic = logicModel;
            }

            var bindingsModel = reportLogicModel.Bindings;

            if (bindingsModel == null)
            {
                bindingsModel             = new BindingInfosModel();
                reportLogicModel.Bindings = bindingsModel;
            }

            bindingsModel.List = Bindings;
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserUtil.GotoLoginIfNoSuperadmin();

            if (!IsPostBack)
            {
                var logicID = DataConverter.ToNullableGuid(Request["LogicID"]);
                if (logicID == null)
                {
                    return;
                }

                var entity = DataContext.LP_Logics.FirstOrDefault(n => n.ID == logicID);
                if (entity == null)
                {
                    return;
                }

                var converter = new LogicEntityModelConverter(DataContext);
                var model     = converter.Convert(entity);

                logicControl.Model = model;
            }
        }
예제 #6
0
        public QueryGenerator(PortalDataContext dbContext, LogicModel logicModel)
        {
            _dbContext             = dbContext;
            _logicModel            = logicModel;
            _sourceType            = _logicModel.SourceType;
            _expressionsLogicModel = logicModel.ExpressionsLogic;

            if (_logicModel.SourceType == "Table")
            {
                var table = dbContext.LP_Tables.First(n => n.ID == _logicModel.SourceID);

                var converter = new TableEntityModelConverter(_dbContext);
                var model     = converter.Convert(table);

                var columns = model.Columns;
                _querySource = GetCorrectName(model.Name);

                var allColumnsQuery = (from n in columns
                                       let m = GetCorrectName(n.Name)
                                               select new KeyValuePair <String, String>(n.Name, m));

                _allColumns = allColumnsQuery.ToDictionary();

                var primaryColumnsQuery = (from n in columns
                                           where n.IsPrimary
                                           let m = GetCorrectName(n.Name)
                                                   select new KeyValuePair <String, String>(n.Name, m));

                _primaryColumns = primaryColumnsQuery.ToDictionary();

                var dbTypesQuery = (from n in columns
                                    let t = GetDataType(n.Type)
                                            let m = GetCorrectName(n.Name)
                                                    select new KeyValuePair <String, SqlDbType>(m, t));

                _dbTypes = dbTypesQuery.ToDictionary();

                _outputColumns = GetOutputs().ToHashSet();
            }
            else if (_logicModel.SourceType == "Logic")
            {
                var logic = dbContext.LP_Logics.First(n => n.ID == _logicModel.SourceID);

                var converter = new LogicEntityModelConverter(_dbContext);
                var model     = converter.Convert(logic);

                var queryGen = new QueryGenerator(_dbContext, model);

                var selectQuery = queryGen.SelectQuery(true);

                _querySource = String.Format("({0})", selectQuery);

                var allColumnsQuery = (from n in queryGen.OutputColumns
                                       let m = GetCorrectName(n)
                                               select new KeyValuePair <String, String>(n, m));

                _allColumns = allColumnsQuery.ToDictionary();

                var dbTypesQuery = (from n in queryGen.OutputColumns
                                    let m = GetCorrectName(n)
                                            let t = queryGen.DbTypes[m]
                                                    select new KeyValuePair <String, SqlDbType>(m, t));

                _dbTypes = dbTypesQuery.ToDictionary();

                _outputColumns = GetOutputs().ToHashSet();
            }

            if (_primaryColumns == null || _primaryColumns.Count == 0)
            {
                _primaryColumns = _allColumns;
            }

            var allParamsQuery = (from n in _allColumns
                                  let p = String.Format("@v{0}", n.Key.ComputeCrc16())
                                          select new KeyValuePair <String, String>(n.Value, p));

            _allColumnsParams = allParamsQuery.ToDictionary();

            var primaryParamsQuery = (from n in _primaryColumns
                                      let p = String.Format("@p{0}", n.Key.ComputeCrc16())
                                              select new KeyValuePair <String, String>(n.Value, p));

            _primaryColumnsParams = primaryParamsQuery.ToDictionary();
        }