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); } }
void TaskPane_Click(object sender, Xceed.SmartUI.SmartItemClickEventArgs e) { Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem; TaskInfo info = item.Tag as TaskInfo; IArchiveMasterForm seeForm = ServiceProvider.GetService <IApplication>().ExecuteAction(info.Action.Name) as IArchiveMasterForm; ArchiveOperationForm operForm = seeForm as ArchiveOperationForm; if (seeForm == null) { MessageForm.ShowError("未能创建目标窗体!"); return; } switch (info.TaskType) { case TaskType.Add: operForm.DoAdd(); break; case TaskType.Edit: ISearchManager smSrc; if (m_sms.ContainsKey(info.Name)) { smSrc = m_sms[info.Name]; } else { smSrc = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(info.SearchManagerClassName, info.SearchManagerClassParams); } ISearchManager smDest = seeForm.DisplayManager.SearchManager; if (smSrc.GetType() == smDest.GetType()) { smDest.LoadData(SearchExpression.Parse(EntityHelper.ReplaceExpression(info.SearchExpression)), null); } else { smSrc.EnablePage = false; object dataSource = smSrc.GetData(SearchExpression.Parse(EntityHelper.ReplaceExpression(info.SearchExpression)), null); IDisplayManager dm = seeForm.DisplayManager; dm.SetDataBinding(dataSource, string.Empty); dm.SearchManager.OnDataLoaded(new DataLoadedEventArgs(dataSource, 0)); } break; default: throw new NotSupportedException("Invalide TaskType"); } }