예제 #1
0
        public override ISearchManager GenerateSearchManager(WindowTabInfo tabInfo, IDisplayManager dmParent)
        {
            ISearchManager sm = base.GenerateSearchManager(tabInfo, dmParent);

            AddEvent(tabInfo, sm, WindowTabEventManagerType.SearchManager);
            return(sm);
        }
        private void Initialize(WindowTabInfo windowTabInfo, IControlManager cmParent)
        {
            ISearchManager        smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(windowTabInfo, cmParent == null ? null : cmParent.DisplayManager);
            IWindowControlManager cmMaster = ServiceProvider.GetService <IManagerFactory>().GenerateControlManager(windowTabInfo, smMaster) as IWindowControlManager;

            if (cmParent != null && cmParent.Dao is IRelationalDao)
            {
                ManagerFactory.GenerateBusinessLayer(cmParent.Dao as IRelationalDao, windowTabInfo);
            }
            else
            {
                IBaseDao daoMaster = ServiceProvider.GetService <IManagerFactory>().GenerateBusinessLayer(windowTabInfo);
                cmMaster.Dao = daoMaster;
            }

            this.SetControlManager(cmMaster, windowTabInfo.GridName);

            //ArchiveSearchForm searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
            //this.SearchPanel = searchForm;
            //cmMaster.StateControls.Add(searchForm);

            // daoParent's subDao is inserted in detailForm
            if (this is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids(this as IBoundGridWithDetailGridLoadOnDemand, windowTabInfo);
            }
        }
        internal static IList <Dictionary <string, object> > InternalGetItems(string winTabName, NameValueCollection nvc)
        {
            if (!Utils.AuthHelper.CheckAuthentication())
            {
                return(null);
            }

            ISearchManager sm       = Feng.Server.Utils.ServiceHelper.GetSearchManagerFromWindowTab(winTabName);
            var            smParams = Utils.WebHelper.GetSearchManagerParameters(sm, nvc);
            var            se       = smParams.Item1;
            var            so       = smParams.Item2;

            sm.FillSearchAdditionals(ref se, ref so);
            IEnumerable list = sm.GetData(se, so);

            WindowTabInfo tabInfo       = ADInfoBll.Instance.GetWindowTabInfo(winTabName);
            bool          includeDetail = false;

            if (!string.IsNullOrEmpty(nvc["detail"]))
            {
                includeDetail = Feng.Utils.ConvertHelper.ToBoolean(nvc["detail"]).Value;
            }
            using (GridDataConvert dp = new GridDataConvert(!includeDetail))
            {
                IList <Dictionary <string, object> > r = dp.Process(list, tabInfo.GridName);

                return(r);
            }
        }
        /// <summary>
        /// 生成主Dao(不生成subDao)
        /// </summary>
        /// <param name="tabInfo"></param>
        public virtual IBaseDao GenerateBusinessLayer(WindowTabInfo tabInfo)
        {
            if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's BusinessLayerClassName must not be null!");
            }
            IBaseDao daoParent;

            if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassParams))
            {
                daoParent = Feng.Utils.ReflectionHelper.CreateInstanceFromName(tabInfo.BusinessLayerClassName) as IBaseDao;
            }
            else
            {
                string[] s    = Feng.Utils.StringHelper.Split(tabInfo.BusinessLayerClassParams, ',');
                object[] args = new object[s.Length];
                for (int i = 0; i < s.Length; ++i)
                {
                    args[i] = s[i];
                }
                daoParent = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.BusinessLayerClassName), args) as IBaseDao;
            }
            if (daoParent is IRepositoryConsumer)
            {
                (daoParent as IRepositoryConsumer).RepositoryCfgName = tabInfo.RepositoryConfigName;
            }
            return(daoParent);
        }
        private void CreateDataSearchSeriveHost(string tabName, string restAddress, string soapAddress)
        {
            WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(tabName);

            if (tabInfo == null)
            {
                return;
            }

            ISearchManager sm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfo, null);

            Type entityType = Utils.ReflectionHelper.GetGenericUnderlyingType(sm.GetType());

            if (entityType == null)
            {
                throw new ArgumentException("SearchManager should be Generic type!", "entityType");
            }
            entityType = Feng.Server.Utils.TypeHelper.AddDataContractAttributeToType(entityType);

            Type serviceServiceType = Feng.Utils.ReflectionHelper.CreateGenericType(typeof(DataSearchService <,>), new Type[] { entityType, entityType });

            if (!string.IsNullOrEmpty(restAddress))
            {
                Type serviceContractType = Feng.Utils.ReflectionHelper.CreateGenericType(typeof(IDataSearchRestService <>), new Type[] { entityType });

                CreateRestService(serviceContractType, serviceServiceType, restAddress, tabName);
            }

            if (!string.IsNullOrEmpty(soapAddress))
            {
                Type serviceContractType = Feng.Utils.ReflectionHelper.CreateGenericType(typeof(IDataSearchSoapService <>), new Type[] { entityType });

                CreateSoapService(serviceContractType, serviceServiceType, soapAddress, tabName);
            }
        }
        private void CreateDataSearchViewSeriveHost(string tabName, string restAddress, string soapAddress)
        {
            WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(tabName);

            if (tabInfo == null)
            {
                return;
            }

            ISearchManager sm                 = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfo, null);
            Type           entityType         = Feng.Server.Utils.TypeHelper.GenerateTypeFromGridColumn(tabInfo.GridName);
            Type           serviceServiceType = Feng.Utils.ReflectionHelper.CreateGenericType(typeof(DataSearchViewService <>), new Type[] { entityType });

            if (!string.IsNullOrEmpty(restAddress))
            {
                Type serviceContractType = Feng.Utils.ReflectionHelper.CreateGenericType(typeof(IDataSearchViewRestService <>), new Type[] { entityType });

                CreateRestService(serviceContractType, serviceServiceType, restAddress, tabName);
            }

            if (!string.IsNullOrEmpty(soapAddress))
            {
                Type serviceContractType = Feng.Utils.ReflectionHelper.CreateGenericType(typeof(IDataSearchViewSoapService <>), new Type[] { entityType });

                CreateSoapService(serviceContractType, serviceServiceType, soapAddress, tabName);
            }
        }
예제 #7
0
        public override IControlManager GenerateControlManager(WindowTabInfo tabInfo, ISearchManager sm)
        {
            IControlManager cm = base.GenerateControlManager(tabInfo, sm);
            IDisplayManager dm = cm.DisplayManager;

            if (tabInfo.SelectedDataValueChanged != null)
            {
                dm.SelectedDataValueChanged += new EventHandler <SelectedDataValueChangedEventArgs>(delegate(object sender, SelectedDataValueChangedEventArgs e)
                {
                    EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(tabInfo.SelectedDataValueChanged), sender, e);
                });
            }
            if (tabInfo.PositionChanged != null)
            {
                dm.PositionChanged += new EventHandler(delegate(object sender, EventArgs e)
                {
                    EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(tabInfo.PositionChanged), sender, e);
                });
            }

            AddEvent(tabInfo, cm, WindowTabEventManagerType.ControlManager);
            AddEvent(tabInfo, cm.DisplayManager, WindowTabEventManagerType.DisplayManager);

            return(cm);
        }
        /// <summary>
        /// 生成子Dao(继续生成subsubDao)
        /// </summary>
        /// <param name="daoParent"></param>
        /// <param name="tabInfo"></param>
        public static void GenerateBusinessLayer(IRelationalDao daoParent, WindowTabInfo tabInfo)
        {
            if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Name + " 's BusinessLayerClassName must not be null!");
            }

            if (!string.IsNullOrEmpty(tabInfo.BusinessLayerClassParams))
            {
                IRelationalDao subDao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(tabInfo.BusinessLayerClassParams) as IRelationalDao;

                IEventDao subRelationDao = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.BusinessLayerClassName), subDao) as IEventDao;
                daoParent.AddRelationalDao(subRelationDao);

                foreach (WindowTabInfo childTab in tabInfo.ChildTabs)
                {
                    GenerateBusinessLayer(subDao, childTab);
                }
            }
            else
            {
                IEventDao subDao = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.BusinessLayerClassName)) as IEventDao;
                daoParent.AddRelationalDao(subDao);

                foreach (WindowTabInfo childTab in tabInfo.ChildTabs)
                {
                    GenerateBusinessLayer(subDao, childTab);
                }
            }
        }
        /// <summary>
        /// 生成子Dao(继续生成subsubDao)
        /// </summary>
        /// <param name="daoParent"></param>
        /// <param name="tabInfo"></param>
        public static void GenerateBusinessLayer(IRelationalDao daoParent, WindowTabInfo tabInfo)
        {
            if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Name + " 's BusinessLayerClassName must not be null!");
            }

            if (!string.IsNullOrEmpty(tabInfo.BusinessLayerClassParams))
            {
                IRelationalDao subDao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(tabInfo.BusinessLayerClassParams) as IRelationalDao;

                IEventDao subRelationDao = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.BusinessLayerClassName), subDao) as IEventDao;
                daoParent.AddRelationalDao(subRelationDao);

                foreach (WindowTabInfo childTab in tabInfo.ChildTabs)
                {
                    GenerateBusinessLayer(subDao, childTab);
                }
            }
            else
            {
                IEventDao subDao = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.BusinessLayerClassName)) as IEventDao;
                daoParent.AddRelationalDao(subDao);

                foreach (WindowTabInfo childTab in tabInfo.ChildTabs)
                {
                    GenerateBusinessLayer(subDao, childTab);
                }
            }
        }
예제 #10
0
        public override IBaseDao GenerateBusinessLayer(WindowTabInfo tabInfo)
        {
            IBaseDao dao = base.GenerateBusinessLayer(tabInfo);

            AddEvent(tabInfo, dao, WindowTabEventManagerType.BusinessLayer);
            return(dao);
        }
        public override IControlManager GenerateControlManager(WindowTabInfo tabInfo, ISearchManager sm)
        {
            IControlManager cm = base.GenerateControlManager(tabInfo, sm);
            IDisplayManager dm = cm.DisplayManager;

            if (tabInfo.SelectedDataValueChanged != null)
            {
                dm.SelectedDataValueChanged += new EventHandler<SelectedDataValueChangedEventArgs>(delegate(object sender, SelectedDataValueChangedEventArgs e)
                {
                    EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(tabInfo.SelectedDataValueChanged), sender, e);
                });
            }
            if (tabInfo.PositionChanged != null)
            {
                dm.PositionChanged += new EventHandler(delegate(object sender, EventArgs e)
                {
                    EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(tabInfo.PositionChanged), sender, e);
                });
            }

            AddEvent(tabInfo, cm, WindowTabEventManagerType.ControlManager);
            AddEvent(tabInfo, cm.DisplayManager, WindowTabEventManagerType.DisplayManager);

            return cm;
        }
        public GeneratedDataUnboundGrid(WindowTabInfo windowTabInfo)
            : base()
        {
            this.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow());

            this.Name = windowTabInfo.Name;
            this.Text = windowTabInfo.Text;

            Initialize(windowTabInfo, null);
        }
        internal GeneratedDataUnboundGrid(WindowTabInfo windowTabInfo, IDisplayManager dmParent)
            : base()
        {
            this.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow());

            this.Name = windowTabInfo.Name;
            this.Text = windowTabInfo.Text;

            Initialize(windowTabInfo, dmParent);
        }
        internal GeneratedArchiveUnboundGrid(WindowTabInfo windowTabInfo, IControlManager cmParent)
            : base()
        {
            this.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow());

            this.Name = windowTabInfo.Name;
            this.Text = windowTabInfo.Text;

            Initialize(windowTabInfo, cmParent);
        }
예제 #15
0
        public GeneratedDataUnboundGrid(WindowTabInfo windowTabInfo)
            : base()
        {
            this.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow());

            this.Name = windowTabInfo.Name;
            this.Text = windowTabInfo.Text;

            Initialize(windowTabInfo, null);
        }
예제 #16
0
        internal GeneratedDataUnboundGrid(WindowTabInfo windowTabInfo, IDisplayManager dmParent)
            : base()
        {
            this.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow());

            this.Name = windowTabInfo.Name;
            this.Text = windowTabInfo.Text;

            Initialize(windowTabInfo, dmParent);
        }
예제 #17
0
        /// <summary>
        /// 按照WindowTabInfo配置Grid
        /// </summary>
        /// <param name="masterGrid"></param>
        /// <param name="masterTabInfo"></param>
        public static void SetupDataUnboundGrid(DataUnboundGrid masterGrid, WindowTabInfo masterTabInfo)
        {
            ISearchManager sm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(masterTabInfo, null);

            masterGrid.SetDisplayManager(ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(masterTabInfo, sm),
                                         masterTabInfo.GridName);

            if (masterTabInfo.ChildTabs.Count > 0)
            {
                GenerateDetailGrids(masterGrid, masterTabInfo);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="dmParent"></param>
        /// <returns></returns>
        public virtual ISearchManager GenerateSearchManager(WindowTabInfo tabInfo, IDisplayManager dmParent)
        {
            if (string.IsNullOrEmpty(tabInfo.SearchManagerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's SearchManagerClassName must not be null!");
            }

            ISearchManager sm = null;

            if (dmParent != null)
            {
                if (string.IsNullOrEmpty(tabInfo.SearchManagerClassParams))
                {
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), dmParent) as ISearchManager;
                }
                else
                {
                    string[] s    = Feng.Utils.StringHelper.Split(tabInfo.SearchManagerClassParams, ',');
                    object[] args = new object[s.Length + 1];
                    args[0] = dmParent;
                    for (int i = 0; i < s.Length; ++i)
                    {
                        args[i + 1] = s[i];
                    }
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), args) as ISearchManager;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(tabInfo.SearchManagerClassParams))
                {
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo)) as ISearchManager;
                }
                else
                {
                    string[] s = Feng.Utils.StringHelper.Split(tabInfo.SearchManagerClassParams, ',');
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), s) as ISearchManager;
                }
            }


            sm.Name = tabInfo.Identity;

            if (sm is IRepositoryConsumer)
            {
                (sm as IRepositoryConsumer).RepositoryCfgName = tabInfo.RepositoryConfigName;
            }

            sm.AdditionalSearchExpression = (string)ParamCreatorHelper.TryGetParam(tabInfo.WhereClause);
            sm.AdditionalSearchOrder      = (string)ParamCreatorHelper.TryGetParam(tabInfo.OrderByClause);

            return(sm);
        }
        public static string GenerateXsl(string windowTabName)
        {
            WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(windowTabName);

            if (tabInfo == null)
            {
                return(null);
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(@"<?xml version=""1.0""?>
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
<xsl:output method=""html"" encoding=""UTF-8""/>
<xsl:template match=""/"">
<html>");
            sb.Append("<head><title>" + tabInfo.Name + "</title>");
            sb.Append(@"</head>
<body>
<table width=""100%"" border=""1"">
  <THEAD>
	<TR>"    );
            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(tabInfo.GridName))
            {
                if (info.GridColumnType != GridColumnType.Normal)
                {
                    continue;
                }
                sb.Append("<TD><B>" + info.Caption + "</B></TD>");
            }
            sb.Append(@"</TR>
  </THEAD>");
            sb.Append("<TBODY>" +
                      "<xsl:for-each select=\"" + "ItemList" + "/" + tabInfo.GridName + "\">" +
                      "<TR>");
            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(tabInfo.GridName))
            {
                if (info.GridColumnType != GridColumnType.Normal)
                {
                    continue;
                }
                sb.Append("<TD><xsl:value-of select=\"" + info.GridColumnName + "\" /></TD>");
            }
            sb.Append(@"</TR>
	</xsl:for-each>
  </TBODY>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>");
            return(sb.ToString());
        }
예제 #20
0
        private void CreateColumns(int level, WindowTabInfo tabInfo)
        {
            string gridName = tabInfo.GridName; //"网页查询_客户委托情况_进口";

            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(gridName))
            {
                if (info.GridColumnType == GridColumnType.Normal)
                {
                    if (!Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    if (this.Grid1.Levels.Count <= level)
                    {
                        this.Grid1.Levels.Add(new ComponentArt.Web.UI.GridLevel());
                    }

                    ComponentArt.Web.UI.GridColumn column = GetColumn(info);
                    if (!this.Grid1.Levels[level].Columns.Contains(column))
                    {
                        this.Grid1.Levels[level].Columns.Add(GetColumn(info));
                    }
                }
            }

            //m_levelTabInfos[level] = tabInfo;
            //if (tabInfo.Childs.Count > 1)
            //{
            //    //throw new NotSupportedException("only one child is supported!");
            //}

            //for (int i = 0; i < Math.Min(1, tabInfo.Childs.Count); i++)
            //{
            //    WindowTabInfo subTabInfo = tabInfo.Childs[i];
            //    CreateColumns(level + 1, subTabInfo);

            //    if (!m_isHierarchicalEventCreated)
            //    {
            //        this.Grid1.NeedChildDataSource += new ComponentArt.Web.UI.Grid.NeedChildDataSourceEventHandler(Grid1_NeedChildDataSource);
            //        m_isHierarchicalEventCreated = true;
            //    }
            //}

            for (int i = 0; i < tabInfo.ChildTabs.Count; i++)
            {
                this.Grid1.Levels[level].Columns[i].DataCellCssClass = "DetailTemplate";
            }
        }
예제 #21
0
        public static ISearchManager GetSearchManagerFromWindowTab(string tabName)
        {
            if (s_searchManagers.ContainsKey(tabName))
            {
                return(s_searchManagers[tabName]);
            }

            WindowTabInfo  tabInfo = ADInfoBll.Instance.GetWindowTabInfo(tabName);
            ISearchManager sm      = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfo, null);

            Feng.Windows.Utils.ManagerFactory.CreateSearchManagerEagerFetchs(sm, tabInfo.GridName);

            s_searchManagers[tabName] = sm;
            return(s_searchManagers[tabName]);
        }
예제 #22
0
        private void Initialize(WindowTabInfo windowTabInfo, IDisplayManager dmParent)
        {
            ISearchManager smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(windowTabInfo, dmParent);

            IDisplayManager dmMaster = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(windowTabInfo, smMaster);

            this.SetDisplayManager(dmMaster, windowTabInfo.GridName);

            //ArchiveSearchForm searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
            //this.SearchPanel = searchForm;

            if (this is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids((IBoundGridWithDetailGridLoadOnDemand)this, windowTabInfo);
            }
        }
예제 #23
0
        /// <summary>
        /// 按照WindowTabInfo生成Grid
        /// </summary>
        /// <param name="masterTabInfo"></param>
        /// <returns></returns>
        public static DataUnboundGrid GenerateDataUnboundGrid(WindowTabInfo masterTabInfo)
        {
            DataUnboundGrid ret;

            if (masterTabInfo.ChildTabs.Count == 0)
            {
                ret = new DataUnboundGrid();
            }
            else
            {
                ret = new DataUnboundWithDetailGridLoadOnDemand();
            }
            SetupDataUnboundGrid(ret, masterTabInfo);

            return(ret);
        }
        private void Initialize(WindowTabInfo windowTabInfo, IDisplayManager dmParent)
        {
            ISearchManager smMaster = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(windowTabInfo, dmParent);

            IDisplayManager dmMaster = ServiceProvider.GetService<IManagerFactory>().GenerateDisplayManager(windowTabInfo, smMaster);

            this.SetDisplayManager(dmMaster, windowTabInfo.GridName);

            //ArchiveSearchForm searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
            //this.SearchPanel = searchForm;

            if (this is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids((IBoundGridWithDetailGridLoadOnDemand)this, windowTabInfo);
            }
        }
        private Type GenerateSearchManagerType(WindowTabInfo tabInfo)
        {
            Type sm;

            switch (tabInfo.SearchManagerClassName.ToUpper())
            {
            case "TYPED":
                sm = Feng.Utils.ReflectionHelper.CreateGenericType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManager`1, Feng.Windows.Controller"),
                                                                   new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) });
                break;

            case "TYPEDDETAIL":
                sm = Feng.Utils.ReflectionHelper.CreateGenericType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManagerProxyDetail`1, Feng.Windows.Controller"),
                                                                   new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) });
                break;

            case "TYPEDONETOSAME":
                sm = Feng.Utils.ReflectionHelper.CreateGenericType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManagerProxyOneToSame`1, Feng.Windows.Controller"),
                                                                   new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) });
                break;

            case "UNTYPED":
                sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManager, Feng.Windows.Controller");
                break;

            case "UNTYPEDPROCEDURE":
                sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerProcedure, Feng.Windows.Controller");
                break;

            case "UNTYPEDFUNCTION":
                sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerFunction, Feng.Windows.Controller");
                break;

            case "UNTYPEDGROUPBYDETAIL":
                sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerGroupByDetail, Feng.Windows.Controller");
                break;

            case "UNTYPEDDETAILINMASTER":
                sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerProxyDetailInMaster, Feng.Windows.Controller");
                break;

            default:
                sm = Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.SearchManagerClassName);
                break;
            }
            return(sm);
        }
        private static void SetGridPermissions(WindowTabInfo tabInfo, IControlManager cm)
        {
            GridInfo info = ADInfoBll.Instance.GetGridInfo(tabInfo.GridName);

            if (!string.IsNullOrEmpty(info.AllowInsert))
            {
                cm.AllowInsert = Authority.AuthorizeByRule(info.AllowInsert);
            }
            if (!string.IsNullOrEmpty(info.AllowEdit))
            {
                cm.AllowEdit = Authority.AuthorizeByRule(info.AllowEdit);
            }
            if (!string.IsNullOrEmpty(info.AllowDelete))
            {
                cm.AllowDelete = Authority.AuthorizeByRule(info.AllowDelete);
            }
        }
예제 #27
0
        public static IArchiveGrid AssociateArchiveDetailGrid(Control container, string windowTabName, IControlManager cmParent, IRelationalDao daoParent)
        {
            WindowTabInfo windowTabInfo = ADInfoBll.Instance.GetWindowTabInfo(windowTabName);

            if (windowTabName == null)
            {
                return(null);
            }

            GeneratedArchiveUnboundGrid grid = new GeneratedArchiveUnboundGrid(windowTabInfo, cmParent);

            IWindowControlManager subCm = grid.ControlManager as IWindowControlManager;
            //ISearchManager subSm = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(windowTabInfo, cmParent.DisplayManager);
            //IWindowControlManager subCm = ServiceProvider.GetService<IManagerFactory>().GenerateControlManager(windowTabInfo, subSm) as IWindowControlManager;
            //subCm.Name = windowTabInfo.Name;
            //grid.SetControlManager(subCm, windowTabInfo.GridName);
            //ManagerFactory.GenerateBusinessLayer(daoParent, windowTabInfo);

            int      i      = 0;
            IBaseDao subDao = daoParent.GetRelationalDao(i);

            if (subDao is IMemoriedRelationalDao)
            {
                IMemoryDao subMemoryDao = ((IMemoriedRelationalDao)daoParent.GetRelationalDao(i)).DetailMemoryDao;
                subCm.Dao = subMemoryDao;

                //subMemoryDao.AddSubDao(new MasterDetailMemoryDao<>(cmParent));
                ((IMemoriedRelationalDao)daoParent.GetRelationalDao(i)).AddRelationToMemoryDao(cmParent.DisplayManager);
            }
            else
            {
                subCm.Dao = subDao;
            }

            AddControl(container, grid);
            grid.LoadLayout();

            grid.IsInDetailMode = true;
            cmParent.StateControls.Add(grid);
            cmParent.CheckControls.Add(grid);

            return(grid);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="sm"></param>
        /// <returns></returns>
        public virtual IControlManager GenerateControlManager(WindowTabInfo tabInfo, ISearchManager sm)
        {
            // maybe null, saved in outer space
            //if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassName))
            //{
            //    throw new ArgumentException("WindowTabInfo of " + tabInfo.Name + " 's BusinessLayerClassName must not be null!");
            //}
            if (string.IsNullOrEmpty(tabInfo.ControlManagerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's ControlManagerClassName must not be null!");
            }
            IControlManager cm = null;

            switch (tabInfo.ControlManagerClassName.ToUpper())
            {
            case "TYPED":
                cm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.CreateGenericType(
                                                                            Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.ControlManager`1, Feng.Windows.Controller"), new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) }),
                                                                        sm) as IControlManager;
                break;

            case "UNTYPED":
                cm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.ControlManager, Feng.Windows.Controller"),
                                                                        sm) as IControlManager;
                break;

            default:
                cm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ControlManagerClassName), sm) as IControlManager;
                break;
            }
            if (cm == null)
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's ControlManagerClassName is wrong!");
            }
            //cm.Name = windowInfo == null ? tabInfo.Name : windowInfo.Name;
            cm.Name = tabInfo.Identity;
            cm.DisplayManager.Name = tabInfo.Identity;

            SetGridPermissions(tabInfo, cm);

            return(cm);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="sm"></param>
        /// <returns></returns>
        public virtual IDisplayManager GenerateDisplayManager(WindowTabInfo tabInfo, ISearchManager sm)
        {
            IDisplayManager dm;

            if (!string.IsNullOrEmpty(tabInfo.DisplayManagerClassName))
            {
                switch (tabInfo.DisplayManagerClassName.ToUpper())
                {
                case "TYPED":
                    dm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.CreateGenericType(
                                                                                Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.DisplayManager`1, Feng.Windows.Controller"), new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) }),
                                                                            sm) as IDisplayManager;
                    break;

                case "UNTYPED":
                    dm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.DisplayManager, Feng.Windows.Controller"),
                                                                            sm) as IDisplayManager;
                    break;

                default:
                    dm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.DisplayManagerClassName), sm) as IDisplayManager;
                    break;
                }
                if (dm == null)
                {
                    throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's DisplayManagerClassName is wrong!");
                }
            }
            else if (!string.IsNullOrEmpty(tabInfo.ControlManagerClassName))
            {
                dm = GenerateControlManager(tabInfo, sm).DisplayManager;
            }
            else
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's DisplayManagerClassName or ControlManagerClassName must not be null!");
            }
            // Why?
            //dm.Name = windowInfo == null ? tabInfo.Name : windowInfo.Name;
            dm.Name = tabInfo.Identity;

            return(dm);
        }
예제 #30
0
        public static IBoundGrid AssociateDataDetailGrid(Control container, string windowTabName, IDisplayManager dmParent)
        {
            WindowTabInfo windowTabInfo = ADInfoBll.Instance.GetWindowTabInfo(windowTabName);

            if (windowTabName == null)
            {
                return(null);
            }

            GeneratedDataUnboundGrid grid = new GeneratedDataUnboundGrid(windowTabInfo, dmParent);

            //ISearchManager subSm = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(windowTabInfo, dmParent);
            //IDisplayManager subDm = ServiceProvider.GetService<IManagerFactory>().GenerateDisplayManager(windowTabInfo, subSm);
            //subDm.Name = windowTabInfo.Name;
            //grid.SetDisplayManager(subDm, windowTabInfo.GridName);

            AddControl(container, grid);
            grid.LoadLayout();
            return(grid);
        }
예제 #31
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="archiveSeeForm"></param>
        /// <param name="sm"></param>
        /// <param name="winTabInfo"></param>
        public ArchiveSearchForm(Form parentForm, ISearchManager sm, WindowTabInfo winTabInfo)
            : this()
        {
            m_parentForm = parentForm;

            m_sm         = sm;
            m_winTabInfo = winTabInfo;

            m_sm.DataLoaded  += new EventHandler <DataLoadedEventArgs>(searchManager_DataLoaded);
            m_sm.DataLoading += new EventHandler <DataLoadingEventArgs>(searchManager_DataLoading);

            searchControlContainer1.SetSearchManager(sm);
            searchControlContainer1.LoadSearchControls(winTabInfo.GridName, this.flowLayoutPanelSearchControlNormal, this.flowLayoutPanelSearchControlHidden);

            //tabControl1.SetTabPageBackColor();

            LoadCustomSearch(winTabInfo.GridName);

            LoadLayout();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="archiveSeeForm"></param>
        /// <param name="sm"></param>
        /// <param name="winTabInfo"></param>
        public ArchiveSearchForm(Form parentForm, ISearchManager sm, WindowTabInfo winTabInfo)
            : this()
        {
            m_parentForm = parentForm;

            m_sm = sm;
            m_winTabInfo = winTabInfo;

            m_sm.DataLoaded += new EventHandler<DataLoadedEventArgs>(searchManager_DataLoaded);
            m_sm.DataLoading += new EventHandler<DataLoadingEventArgs>(searchManager_DataLoading);

            searchControlContainer1.SetSearchManager(sm);
            searchControlContainer1.LoadSearchControls(winTabInfo.GridName, this.flowLayoutPanelSearchControlNormal, this.flowLayoutPanelSearchControlHidden);

            //tabControl1.SetTabPageBackColor();

            LoadCustomSearch(winTabInfo.GridName);

            LoadLayout();
        }
예제 #33
0
        // 必定是DisplayManager接管,不可编辑
        internal static void GenerateDetailGrids(IBoundGrid masterGrid, WindowTabInfo masterTabInfo)
        {
            if (masterTabInfo.ChildTabs.Count == 0)
            {
                return;
            }

            if (!(masterGrid is IBoundGridWithDetailGridLoadOnDemand))
            {
                throw new ArgumentException("Grid With DetailGrid must be IBoundGridWithDetailGridLoadOnDemand");
            }

            IDisplayManager masterDm = masterGrid.DisplayManager;

            foreach (WindowTabInfo subTabInfo in masterTabInfo.ChildTabs)
            {
                if (subTabInfo.IsInGrid)
                {
                    ISearchManager subSm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(subTabInfo, masterDm);

                    IDisplayManager subDm;
                    if (!string.IsNullOrEmpty(subTabInfo.DisplayManagerClassName))
                    {
                        subDm = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(subTabInfo, subSm);
                    }
                    else
                    {
                        subDm = (ServiceProvider.GetService <IManagerFactory>().GenerateControlManager(subTabInfo, subSm)).DisplayManager;
                    }
                    subDm.Name = subTabInfo.Name;

                    // IBoundGridWithDetailGridLoadOnDemand
                    DataUnboundDetailGrid detailGrid = new DataUnboundDetailGrid();
                    detailGrid.SetDisplayManager(subDm, subTabInfo.GridName);
                    ((IBoundGridWithDetailGridLoadOnDemand)masterGrid).AddDetailGrid(detailGrid);

                    GenerateDetailGrids(detailGrid, subTabInfo);
                }
            }
        }
        public override SoaDataGridSelectResponse Select(SoaDataGridSelectRequest request)
        {
            SoaDataGridSelectResponse response = new SoaDataGridSelectResponse();

            if (request.Tag == null || string.IsNullOrEmpty(request.Tag.ToString()))
            {
                return(response);
            }

            try
            {
                //WindowInfo windowInfo = ADInfoBll.Instance.GetWindowInfo(request.Tag.ToString());
                //IList<WindowTabInfo> tabInfos = null;
                //if (windowInfo != null)
                //{
                //    tabInfos = ADInfoBll.Instance.GetWindowTabInfo(windowInfo.Id);
                //}

                Dictionary <string, string> dict = StringToDictionary(request.Tag.ToString());

                if (!dict.ContainsKey("winTab") || string.IsNullOrEmpty(dict["winTab"]))
                {
                    return(response);
                }

                WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(dict["winTab"]);

                if (tabInfo != null)
                {
                    ISearchManager sm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfo, null);
                    ManagerFactory.CreateSearchManagerEagerFetchs(sm, tabInfo.GridName);

                    ISearchExpression exp = null;
                    if (dict.ContainsKey("se") && !string.IsNullOrEmpty(dict["se"]))
                    {
                        //exp = HttpUtility.UrlDecode(exp, System.Text.Encoding.GetEncoding("gb2312"));
                        //exp = HttpContext.Current.Server.UrlDecode(exp);
                        exp = SearchExpression.Parse(dict["se"]);
                    }

                    //if (request.Filters != null)
                    //{
                    //    //searchs.Add(SearchExpression.Parse(request.Tag.ToString()));
                    //    foreach (SoaDataGridDataCondition i in request.Filters)
                    //    {
                    //        switch (i.Operand)
                    //        {
                    //            case SoaDataGridDataConditionOperand.Contains:
                    //                searchExps.Add(SearchExpression.Like(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.Equals:
                    //                searchExps.Add(SearchExpression.Eq(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.GreaterThan:
                    //                searchExps.Add(SearchExpression.Gt(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.GreaterThanOrEqual:
                    //                searchExps.Add(SearchExpression.Ge(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.In:
                    //                searchExps.Add(SearchExpression.InG(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.LessThan:
                    //                searchExps.Add(SearchExpression.Lt(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.LessThanOrEqual:
                    //                searchExps.Add(SearchExpression.Le(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.NotEqualTo:
                    //                searchExps.Add(SearchExpression.NotEq(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.NotIn:
                    //                searchExps.Add(SearchExpression.NotInG(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //            case SoaDataGridDataConditionOperand.StartsWith:
                    //                searchExps.Add(SearchExpression.Like(i.DataFieldName, i.DataFieldValue));
                    //                break;
                    //        }
                    //    }
                    //}

                    IList <ISearchOrder> searchOrders = new List <ISearchOrder>();
                    if (request.Sortings != null)
                    {
                        foreach (SoaDataGridSorting i in request.Sortings)
                        {
                            searchOrders.Add(i.Direction == SoaSortDirection.Ascending ? SearchOrder.Asc(i.Column.Name) : SearchOrder.Desc(i.Column.Name));
                        }
                    }

                    sm.FirstResult = request.Offset;
                    sm.MaxResult   = request.Count;

                    List <List <object> > arMessages;

                    arMessages = GenerateData(sm.GetData(exp, searchOrders), tabInfo.GridName, request.Columns);

                    //IList<Dictionary<string, object>> values = null;
                    //

                    //using (DataProcess dp = new DataProcess())
                    //{
                    //    if (dt == null)
                    //    {
                    //        // should be IEnumerable because IList<T> not support IList
                    //        IEnumerable data = ret as IEnumerable;
                    //        values = dp.Process(data, tabInfo.GridName);
                    //    }
                    //    else
                    //    {
                    //        values = dp.Process(dt.Rows, tabInfo.GridName);
                    //    }
                    //}

                    //foreach (Dictionary<string, object> obj in values)
                    //{
                    //    List<object> msg = new List<object>();

                    //    foreach (SoaDataGridColumn oColumn in request.Columns)
                    //    {
                    //        if (!obj.ContainsKey(oColumn.Name))
                    //        {
                    //            msg.Add(null);
                    //        }
                    //        else
                    //        {
                    //            msg.Add(obj[oColumn.Name]);
                    //        }
                    //    }

                    //    arMessages.Add(msg);
                    //}
                    response.Data = arMessages;

                    if (sm.EnablePage)
                    {
                        response.ItemCount = sm.GetCount(exp);
                    }
                    else
                    {
                        response.ItemCount = arMessages.Count;
                    }
                }
                else
                {
                    throw new ArgumentException("Invalide tabName of " + dict["winTab"]);
                }
            }
            catch (Exception)
            {
#if DEBUG
                throw;
#endif
            }

            return(response);
        }
예제 #35
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Dictionary <string, object> dict = new Dictionary <string, object>();

                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["window"]))
                {
                    string windowId = this.Context.Request.QueryString["window"];

                    WindowInfo            windowInfo = ADInfoBll.Instance.GetWindowInfo(windowId);
                    IList <WindowTabInfo> tabInfos   = null;
                    if (windowInfo != null)
                    {
                        this.Title = windowInfo.Text;
                        tabInfos   = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Id);
                    }
                    if (tabInfos != null && tabInfos.Count > 0)
                    {
                        //CreateColumns(0, tabInfos[0]);

                        dict["winTab"] = tabInfos[0].Id;
                    }
                }
                else if (!string.IsNullOrEmpty(this.Context.Request.QueryString["winTab"]))
                {
                    string        winTabId = this.Context.Request.QueryString["winTab"];
                    WindowTabInfo tabInfo  = ADInfoBll.Instance.GetWindowTabInfo(winTabId);
                    if (tabInfo != null)
                    {
                        this.Title = tabInfo.Text;
                        //CreateColumns(0, tabInfo);

                        dict["winTab"] = tabInfo.Id.ToString();
                    }
                }
                else
                {
                    return;
                }

                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["se"]))
                {
                    //this.Grid1.Filter = this.Context.Request.QueryString["se"];
                    dict["se"] = this.Context.Request.QueryString["se"];
                }
                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["so"]))
                {
                    this.Grid1.Sort = this.Context.Request.QueryString["so"];
                }
                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["ro"]))
                {
                    this.Grid1.RecordOffset = ConvertHelper.ToInt(this.Context.Request.QueryString["ro"]).Value;
                }
                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["ps"]))
                {
                    this.Grid1.PageSize = ConvertHelper.ToInt(this.Context.Request.QueryString["ps"]).Value;
                }
                //// 按照当前登录用户,附加查询条件
                //ISearchExpression se = Helper.GetConstraitByRole(Helper.人员类型.委托人, Helper.业务类型.进口);
                //if (se != null)
                //{
                //    if (dict.ContainsKey("se"))
                //    {
                //        dict["se"] = "(" + dict["se"] + ") AND " + se.ToString();
                //    }
                //    else
                //    {
                //        dict["se"] = se.ToString();
                //    }
                //}
                this.Grid1.WebServiceCustomParameter = Helper.DictionaryToString(dict);
                this.Grid1.PageSize = 100;

                //显示上次查询条件
                foreach (string key in Session.Keys)
                {
                    if (key != null)
                    {
                        TextBox tb = (TextBox)this.FindControl(key);
                        tb.Text = Session[key].ToString();
                    }
                }
            }
        }
        /// <summary>
        /// 按照WindowTabInfo生成Grid
        /// </summary>
        /// <param name="masterTabInfo"></param>
        /// <returns></returns>
        public static DataUnboundGrid GenerateDataUnboundGrid(WindowTabInfo masterTabInfo)
        {
            DataUnboundGrid ret;
            if (masterTabInfo.ChildTabs.Count == 0)
            {
                ret = new DataUnboundGrid();
            }
            else
            {
                ret = new DataUnboundWithDetailGridLoadOnDemand();
            }
            SetupDataUnboundGrid(ret, masterTabInfo);

            return ret;
        }
        /// <summary>
        /// 按照WindowTabInfo配置Grid
        /// </summary>
        /// <param name="masterGrid"></param>
        /// <param name="masterTabInfo"></param>
        public static void SetupDataUnboundGrid(DataUnboundGrid masterGrid, WindowTabInfo masterTabInfo)
        {
            ISearchManager sm = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(masterTabInfo, null);
            masterGrid.SetDisplayManager(ServiceProvider.GetService<IManagerFactory>().GenerateDisplayManager(masterTabInfo, sm),
                masterTabInfo.GridName);

            if (masterTabInfo.ChildTabs.Count > 0)
            {
                GenerateDetailGrids(masterGrid, masterTabInfo);
            }
        }
        // 必定是DisplayManager接管,不可编辑
        internal static void GenerateDetailGrids(IBoundGrid masterGrid, WindowTabInfo masterTabInfo)
        {
            if (masterTabInfo.ChildTabs.Count == 0)
                return;

            if (!(masterGrid is IBoundGridWithDetailGridLoadOnDemand))
            {
                throw new ArgumentException("Grid With DetailGrid must be IBoundGridWithDetailGridLoadOnDemand");
            }

            IDisplayManager masterDm = masterGrid.DisplayManager;
            foreach (WindowTabInfo subTabInfo in masterTabInfo.ChildTabs)
            {
                if (subTabInfo.IsInGrid)
                {
                    ISearchManager subSm = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(subTabInfo, masterDm);

                    IDisplayManager subDm;
                    if (!string.IsNullOrEmpty(subTabInfo.DisplayManagerClassName))
                    {
                        subDm = ServiceProvider.GetService<IManagerFactory>().GenerateDisplayManager(subTabInfo, subSm);
                    }
                    else
                    {
                        subDm = (ServiceProvider.GetService<IManagerFactory>().GenerateControlManager(subTabInfo, subSm)).DisplayManager;
                    }
                    subDm.Name = subTabInfo.Name;

                    // IBoundGridWithDetailGridLoadOnDemand
                    DataUnboundDetailGrid detailGrid = new DataUnboundDetailGrid();
                    detailGrid.SetDisplayManager(subDm, subTabInfo.GridName);
                    ((IBoundGridWithDetailGridLoadOnDemand)masterGrid).AddDetailGrid(detailGrid);

                    GenerateDetailGrids(detailGrid, subTabInfo);
                }
            }
        }
 public override ISearchManager GenerateSearchManager(WindowTabInfo tabInfo, IDisplayManager dmParent)
 {
     ISearchManager sm = base.GenerateSearchManager(tabInfo, dmParent);
     AddEvent(tabInfo, sm, WindowTabEventManagerType.SearchManager);
     return sm;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="dmParent"></param>
        /// <returns></returns>
        public virtual ISearchManager GenerateSearchManager(WindowTabInfo tabInfo, IDisplayManager dmParent)
        {
            if (string.IsNullOrEmpty(tabInfo.SearchManagerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's SearchManagerClassName must not be null!");
            }

            ISearchManager sm = null;
            if (dmParent != null)
            {
                if (string.IsNullOrEmpty(tabInfo.SearchManagerClassParams))
                {
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), dmParent) as ISearchManager;
                }
                else
                {
                    string[] s = Feng.Utils.StringHelper.Split(tabInfo.SearchManagerClassParams, ',');
                    object[] args = new object[s.Length + 1];
                    args[0] = dmParent;
                    for (int i = 0; i < s.Length; ++i)
                    {
                        args[i + 1] = s[i];
                    }
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), args) as ISearchManager;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(tabInfo.SearchManagerClassParams))
                {
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo)) as ISearchManager;
                }
                else
                {
                    string[] s = Feng.Utils.StringHelper.Split(tabInfo.SearchManagerClassParams, ',');
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), s) as ISearchManager;
                }
            }

            sm.Name = tabInfo.Identity;

            if (sm is IRepositoryConsumer)
            {
                (sm as IRepositoryConsumer).RepositoryCfgName = tabInfo.RepositoryConfigName;
            }

            sm.AdditionalSearchExpression = (string)ParamCreatorHelper.TryGetParam(tabInfo.WhereClause);
            sm.AdditionalSearchOrder = (string)ParamCreatorHelper.TryGetParam(tabInfo.OrderByClause);

            return sm;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="sm"></param>
        /// <returns></returns>
        public virtual IDisplayManager GenerateDisplayManager(WindowTabInfo tabInfo, ISearchManager sm)
        {
            IDisplayManager dm;
            if (!string.IsNullOrEmpty(tabInfo.DisplayManagerClassName))
            {
                switch (tabInfo.DisplayManagerClassName.ToUpper())
                {
                    case "TYPED":
                        dm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.CreateGenericType(
                            Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.DisplayManager`1, Feng.Windows.Controller"), new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) }),
                            sm) as IDisplayManager;
                        break;
                    case "UNTYPED":
                        dm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.DisplayManager, Feng.Windows.Controller"),
                            sm) as IDisplayManager;
                        break;
                    default:
                        dm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.DisplayManagerClassName), sm) as IDisplayManager;
                        break;
                }
                if (dm == null)
                {
                    throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's DisplayManagerClassName is wrong!");
                }
            }
            else if (!string.IsNullOrEmpty(tabInfo.ControlManagerClassName))
            {
                dm = GenerateControlManager(tabInfo, sm).DisplayManager;
            }
            else
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's DisplayManagerClassName or ControlManagerClassName must not be null!");
            }
            // Why?
            //dm.Name = windowInfo == null ? tabInfo.Name : windowInfo.Name;
            dm.Name = tabInfo.Identity;

            return dm;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="sm"></param>
        /// <returns></returns>
        public virtual IControlManager GenerateControlManager(WindowTabInfo tabInfo, ISearchManager sm)
        {
            // maybe null, saved in outer space
            //if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassName))
            //{
            //    throw new ArgumentException("WindowTabInfo of " + tabInfo.Name + " 's BusinessLayerClassName must not be null!");
            //}
            if (string.IsNullOrEmpty(tabInfo.ControlManagerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's ControlManagerClassName must not be null!");
            }
            IControlManager cm = null;
            switch (tabInfo.ControlManagerClassName.ToUpper())
            {
                case "TYPED":
                    cm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.CreateGenericType(
                        Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.ControlManager`1, Feng.Windows.Controller"), new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) }),
                        sm) as IControlManager;
                    break;
                case "UNTYPED":
                    cm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Windows.Forms.ControlManager, Feng.Windows.Controller"),
                        sm) as IControlManager;
                    break;
                default:
                    cm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ControlManagerClassName), sm) as IControlManager;
                    break;
            }
            if (cm == null)
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's ControlManagerClassName is wrong!");
            }
            //cm.Name = windowInfo == null ? tabInfo.Name : windowInfo.Name;
            cm.Name = tabInfo.Identity;
            cm.DisplayManager.Name = tabInfo.Identity;

            SetGridPermissions(tabInfo, cm);

            return cm;
        }
        private static void SetGridPermissions(WindowTabInfo tabInfo, IControlManager cm)
        {
            GridInfo info = ADInfoBll.Instance.GetGridInfo(tabInfo.GridName);

            if (!string.IsNullOrEmpty(info.AllowInsert))
            {
                cm.AllowInsert = Authority.AuthorizeByRule(info.AllowInsert);
            }
            if (!string.IsNullOrEmpty(info.AllowEdit))
            {
                cm.AllowEdit = Authority.AuthorizeByRule(info.AllowEdit);
            }
            if (!string.IsNullOrEmpty(info.AllowDelete))
            {
                cm.AllowDelete = Authority.AuthorizeByRule(info.AllowDelete);
            }
        }
 public override IBaseDao GenerateBusinessLayer(WindowTabInfo tabInfo)
 {
     IBaseDao dao = base.GenerateBusinessLayer(tabInfo);
     AddEvent(tabInfo, dao, WindowTabEventManagerType.BusinessLayer);
     return dao;
 }
 /// <summary>
 /// 生成主Dao(不生成subDao)
 /// </summary>
 /// <param name="tabInfo"></param>
 public virtual IBaseDao GenerateBusinessLayer(WindowTabInfo tabInfo)
 {
     if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassName))
     {
         throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's BusinessLayerClassName must not be null!");
     }
     IBaseDao daoParent;
     if (string.IsNullOrEmpty(tabInfo.BusinessLayerClassParams))
     {
         daoParent = Feng.Utils.ReflectionHelper.CreateInstanceFromName(tabInfo.BusinessLayerClassName) as IBaseDao;
     }
     else
     {
         string[] s = Feng.Utils.StringHelper.Split(tabInfo.BusinessLayerClassParams, ',');
         object[] args = new object[s.Length];
         for (int i = 0; i < s.Length; ++i)
         {
             args[i] = s[i];
         }
         daoParent = Feng.Utils.ReflectionHelper.CreateInstanceFromType(Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.BusinessLayerClassName), args) as IBaseDao;
     }
     if (daoParent is IRepositoryConsumer)
     {
         (daoParent as IRepositoryConsumer).RepositoryCfgName = tabInfo.RepositoryConfigName;
     }
     return daoParent;
 }
예제 #46
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Label1.Text = System.Threading.Thread.CurrentPrincipal.Identity.Name;

                Dictionary <string, object> dict = new Dictionary <string, object>();

                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["window"]))
                {
                    string windowId = this.Context.Request.QueryString["window"];

                    WindowInfo            windowInfo = ADInfoBll.Instance.GetWindowInfo(windowId);
                    IList <WindowTabInfo> tabInfos   = null;
                    if (windowInfo != null)
                    {
                        this.Title = windowInfo.Text;
                        tabInfos   = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Id);
                    }
                    if (tabInfos != null && tabInfos.Count > 0)
                    {
                        CreateColumns(0, tabInfos[0]);

                        dict["winTab"] = tabInfos[0].Id;
                    }
                }
                else if (!string.IsNullOrEmpty(this.Context.Request.QueryString["wintab"]))
                {
                    string        winTabId = this.Context.Request.QueryString["wintab"];
                    WindowTabInfo tabInfo  = ADInfoBll.Instance.GetWindowTabInfo(winTabId);
                    if (tabInfo != null)
                    {
                        this.Title = tabInfo.Text;
                        CreateColumns(0, tabInfo);

                        dict["winTab"] = tabInfo.Id.ToString();
                    }
                }
                else
                {
                    return;
                }

                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["se"]))
                {
                    //this.Grid1.Filter = this.Context.Request.QueryString["se"];
                    dict["se"] = this.Context.Request.QueryString["se"];
                }
                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["so"]))
                {
                    this.Grid1.Sort = this.Context.Request.QueryString["so"];
                }
                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["ro"]))
                {
                    this.Grid1.RecordOffset = ConvertHelper.ToInt(this.Context.Request.QueryString["ro"]).Value;
                }
                if (!string.IsNullOrEmpty(this.Context.Request.QueryString["ps"]))
                {
                    this.Grid1.PageSize = ConvertHelper.ToInt(this.Context.Request.QueryString["ps"]).Value;
                }

                this.Grid1.WebServiceCustomParameter = Helper.DictionaryToString(dict);
            }
        }
 private Type GenerateSearchManagerType(WindowTabInfo tabInfo)
 {
     Type sm;
     switch (tabInfo.SearchManagerClassName.ToUpper())
     {
         case "TYPED":
             sm = Feng.Utils.ReflectionHelper.CreateGenericType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManager`1, Feng.Windows.Controller"),
                 new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) });
             break;
         case "TYPEDDETAIL":
             sm = Feng.Utils.ReflectionHelper.CreateGenericType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManagerProxyDetail`1, Feng.Windows.Controller"),
                 new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) });
             break;
         case "TYPEDONETOSAME":
             sm = Feng.Utils.ReflectionHelper.CreateGenericType(Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.NH.SearchManagerProxyOneToSame`1, Feng.Windows.Controller"),
                 new Type[] { Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.ModelClassName) });
             break;
         case "UNTYPED":
             sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManager, Feng.Windows.Controller");
             break;
         case "UNTYPEDPROCEDURE":
             sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerProcedure, Feng.Windows.Controller");
             break;
         case "UNTYPEDFUNCTION":
             sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerFunction, Feng.Windows.Controller");
             break;
         case "UNTYPEDGROUPBYDETAIL":
             sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerGroupByDetail, Feng.Windows.Controller");
             break;
         case "UNTYPEDDETAILINMASTER":
             sm = Feng.Utils.ReflectionHelper.GetTypeFromName("Feng.Data.SearchManagerProxyDetailInMaster, Feng.Windows.Controller");
             break;
         default:
             sm = Feng.Utils.ReflectionHelper.GetTypeFromName(tabInfo.SearchManagerClassName);
             break;
     }
     return sm;
 }
        private void AddEvent(WindowTabInfo tabInfo, object manager, WindowTabEventManagerType type)
        {
            var list = ADInfoBll.Instance.GetWindowTabEventInfos(tabInfo.Name, type);
            foreach (var info in list)
            {
                System.Reflection.EventInfo eventInfo = manager.GetType().GetEvent(info.EventName);

                Type handlerType = eventInfo.EventHandlerType;
                //MethodInfo invokeMethod = handlerType.GetMethod("Invoke");
                //ParameterInfo[] parms = invokeMethod.GetParameters();
                //Type[] parmTypes = new Type[parms.Length];
                //for (int i = 0; i < parms.Length; i++)
                //{
                //    parmTypes[i] = parms[i].ParameterType;
                //}
                //Type dType = Expression.GetActionType(parmTypes);
                Delegate d = null;
                switch (type)
                {
                    case WindowTabEventManagerType.SearchManager:
                        switch (info.EventName)
                        {
                            case "DataLoaded":
                                {
                                    EventHandler<DataLoadedEventArgs> d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            case "DataLoading":
                                {
                                    EventHandler<DataLoadingEventArgs> d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            default:
                                throw new ArgumentException("invalid EventName of " + info.EventName);
                        }
                        break;
                    case WindowTabEventManagerType.DisplayManager:
                        switch (info.EventName)
                        {
                            case "PositionChanging":
                                {
                                    EventHandler<System.ComponentModel.CancelEventArgs> d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            case "PositionChanged":
                                {
                                    EventHandler d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            case "SelectedDataValueChanged":
                                {
                                    EventHandler<SelectedDataValueChangedEventArgs> d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            default:
                                throw new ArgumentException("invalid EventName of " + info.EventName);
                        }
                        break;
                    case WindowTabEventManagerType.ControlManager:
                        switch (info.EventName)
                        {
                            case "BeginningEdit":
                            case "EditBegun":
                            case "EndingEdit":
                            case "EditEnded":
                            case "EditCanceled":
                            case "StateChanged":
                                {
                                    EventHandler d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            case "CancellingEdit":
                                {
                                    EventHandler<System.ComponentModel.CancelEventArgs> d1 = (sender, e) =>
                                    {
                                        EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info.EventProcessName), sender, e);
                                    };
                                    d = Delegate.CreateDelegate(handlerType, d1.Target, d1.Method);
                                }
                                break;
                            default:
                                throw new ArgumentException("invalid EventName of " + info.EventName);
                        }

                        break;
                    case WindowTabEventManagerType.BusinessLayer:
                        break;
                    default:
                        throw new ArgumentException("invalid WindowTabEventManagerType of " + type);
                }
                if (d != null)
                {
                    eventInfo.AddEventHandler(manager, d);
                }
            }
        }