/// <summary> /// 试乘试驾路线 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > QueryDriveRouteList(DriveRouteRequest request) { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.mcs_dealerid)) { // request.DealerId = Guid.Parse(userInfo.mcs_dealerid); } #region 查询结果集 var fetchString = _driveRecordRepository.QueryDriveRouteList(request); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_driveroute", FetchXml = fetchXdoc, ProxyUserId = userInfo?.systemuserid }; fetchRequest.Headers.Add(dicHeadKey, dicHead[dicHeadKey]); var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = request.PageIndex; queryResult.TotalCount = 0; return(queryResult); #endregion }
/// <summary> /// 我的试乘试驾查询 /// </summary> /// <param name="GetDriveRecordList"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > GetDriveRecordList(TestDriveRequest Request) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var ProxyUserId = userInfo != null ? userInfo.systemuserid : null; var fetchString = _Repository.GetDriveRecordList(Request); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_driverecord", FetchXml = fetchXdoc, ProxyUserId = ProxyUserId }; var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = Request.PageIndex; queryResult.TotalCount = 0; return(queryResult); } catch (Exception ex) { throw ex; } }
/// <summary> /// 根据Fetch查询字符串获取所有记录 /// </summary> /// <param name="strFetch">Fetch查询字符串</param> /// <param name="callBack"></param> public static void RetriveAll(string strFetch, Action <Entity> callBack) { int page = 1, count = 500; var doc = XDocument.Parse(strFetch); var orgService = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService); while (true) { doc.Root.SetAttributeValue("page", page.ToString()); doc.Root.SetAttributeValue("count", count.ToString()); FetchExpression fetchExpression = new FetchExpression(doc.ToString()); var queryResponse = orgService.RetrieveMultiple(fetchExpression); foreach (var entityItem in queryResponse.Entities.ToList()) { callBack(entityItem); } if (!queryResponse.MoreRecords) { break; } page++; } }
public bool HasRole(PAUser user, Guid roleId) { var orgService = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService); var strFetch = string.Format(@"<fetch distinct=""false"" mapping=""logical"" output-format=""xml - platform"" version=""1.0""> <entity name = ""role""> <attribute name = ""name"" /> <attribute name = ""roleid"" /> <filter type = ""and"" > <condition attribute=""roleid"" operator=""eq"" uitype=""role"" value=""{0}"" /> </filter > <link-entity name = ""systemuserroles"" intersect = ""true"" visible = ""false"" to = ""roleid"" from = ""roleid"" > <link-entity name = ""systemuser"" to = ""systemuserid"" from = ""systemuserid"" alias = ""aa"" > <filter type = ""and"" > <condition attribute = ""systemuserid"" value = ""{1}"" operator= ""eq"" uitype = ""systemuser"" /> </filter > </link-entity> </link-entity> </entity> </fetch> ", roleId.ToString(), user.EntityRecord.Id.ToString()); var collection = orgService.RetrieveMultiple(new FetchExpression(strFetch)); if (collection.Entities.Count == 0) { return(false); } return(true); }
public void SetBusinessUnit(PAUser user, Guid buId) { var currentUser = ContextContainer.GetValue <ICurrentUserInfoContext>(ContextTypes.CurrentUser); Entity updateUser = new Entity("systemuser"); updateUser.Id = user.EntityRecord.Id; updateUser["businessunitid"] = new EntityReference("businessunit", buId); var orgService = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService); try { orgService.Update(updateUser); } catch { SetBusinessSystemUserRequest request = new SetBusinessSystemUserRequest(); request.UserId = user.EntityRecord.Id; request.BusinessId = buId; //var administrator = _configurationService.GetAdministratorID(); request.ReassignPrincipal = currentUser.GetUserID(); orgService.Execute(request); } }
public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { if (cki.Key != ConsoleKey.Enter) { return; } var current = ctx.Get <InputBuffer>().GetInput(); if (current.Length == 0) { return; } var inputHistory = ctx.Get <InputHistory>(); inputHistory.Last(); if (inputHistory.Pre() == current) { inputHistory.Next(); return; } inputHistory.Next(); inputHistory.Update(current); inputHistory.Enqueue(string.Empty); }
public override void OnRegist(ContextContainer ctx) { if (ctx.Get <InputHistory>() == null) { ctx.Set(new InputHistory(100)); } }
public OptionMetadata[] GetOptionSet(string entityName, string fieldName) { OptionMetadata[] optionMetadatas; IOrganizationService orgService = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService); RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest { EntityLogicalName = entityName, LogicalName = fieldName, RetrieveAsIfPublished = false }; RetrieveAttributeResponse attributeResponse = (RetrieveAttributeResponse)orgService.Execute(attributeRequest); if (attributeResponse.AttributeMetadata.AttributeType == Microsoft.Xrm.Sdk.Metadata.AttributeTypeCode.Boolean) { BooleanAttributeMetadata boolenAttributeMetadata = (BooleanAttributeMetadata)attributeResponse.AttributeMetadata; BooleanOptionSetMetadata boolenOptionSetMetadata = boolenAttributeMetadata.OptionSet; OptionMetadata[] options = new OptionMetadata[2]; options[0] = boolenOptionSetMetadata.TrueOption; options[1] = boolenOptionSetMetadata.FalseOption; optionMetadatas = options; } else { EnumAttributeMetadata picklistAttributeMetadata = (EnumAttributeMetadata)attributeResponse.AttributeMetadata; OptionSetMetadata optionSetMetadata = picklistAttributeMetadata.OptionSet; OptionMetadata[] optionList = optionSetMetadata.Options.ToArray(); optionMetadatas = optionList; } return(optionMetadatas); }
public async Task <ValidateResult> Validate(BusinessAction action, Dictionary <string, object> originalParameters) { //获取参数信息过滤器 var filter = _originalParametersFilterServiceSelector.Choose(action.OriginalParametersFilterType); Dictionary <string, object> parameters = null; if (filter != null) { //获取过滤后的参数信息 parameters = await filter.Execute(originalParameters); } //获取规则信息,转成xml var doc = XDocument.Parse(action.Rule); var result = await _conditionService.Validate(doc, parameters); //如果需要替换 if (!result.Result && !string.IsNullOrEmpty(action.ErrorReplaceText)) { LoggerHelper.LogInformation(_informationCategory, $"BusinessAction {action.Name} validate fail,detail:{result.Description}"); var lcId = ContextContainer.GetValue <int>(ContextTypes.CurrentUserLcid); TemplateContext templateContext = new TemplateContext(lcId, parameters); result.Description = await _templateService.Convert(action.ErrorReplaceText, templateContext); } return(result); }
public static dPackedStocks EagerPackedStockById(this ContextContainer _context, int argId) { return(_context.dPackedStocks .Include(p => p.Mix) .Include(p => p.Package) .FirstOrDefault(c => c.Id == argId)); }
public EntityMetadata GetEntityMetadata(int typeCode) { EntityMetadata entityMetadatas; IOrganizationService orgService = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService); MetadataFilterExpression EntityFilter = new MetadataFilterExpression(LogicalOperator.And); EntityFilter.Conditions.Add(new MetadataConditionExpression("ObjectTypeCode", MetadataConditionOperator.Equals, 9800)); EntityQueryExpression entityQueryExpression = new EntityQueryExpression(); entityQueryExpression.Criteria = EntityFilter; //entityQueryExpression.AttributeQuery=new AttributeQueryExpression() RetrieveMetadataChangesRequest request = new RetrieveMetadataChangesRequest() { Query = entityQueryExpression, //ClientVersionStamp = clientVersionStamp, //DeletedMetadataFilters = deletedMetadataFilter }; var response = (RetrieveEntityResponse)orgService.Execute(request); entityMetadatas = response.EntityMetadata; return(entityMetadatas); }
/// <summary> /// Creates a new instance of the <see cref="TestBase{TToValidate}"/> class. /// </summary> protected TestBase() { var container = new ContextContainer(); _configureContainer = container as IConfigureContainer; _resolveInstances = container as IResolveInstance; }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <ValidateResult> Add(UsermessageRequest model) { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var validateResult = new ValidateResult(); try { Guid id = Guid.NewGuid(); var entity = new CrmExecuteEntity(entityName, id); if (!string.IsNullOrEmpty(model.phone)) { entity.Attributes.Add("mcs_phone", model.phone); } if (!string.IsNullOrEmpty(model.valcode)) { entity.Attributes.Add("mcs_name", model.valcode); } entity.Attributes.Add("mcs_type", model.type); await _crmService.Create(entity, userInfo?.systemuserid); #region 组装数据返回 validateResult.Result = true; validateResult.Description = "操作成功"; #endregion } catch (Exception e) { validateResult.Result = false; validateResult.Description = e.Message; } return(validateResult); }
/// <summary> /// 查询试乘试驾附件 /// </summary> /// <param name="driverecordid"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > QueryAttachment(string driverecordid) { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); #region 查询结果集 var fetchString = _driveRecordRepository.QueryAttachment(driverecordid); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_attachment", FetchXml = fetchXdoc, ProxyUserId = userInfo?.systemuserid }; fetchRequest.Headers.Add(dicHeadKey, dicHead[dicHeadKey]); var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = 1; queryResult.TotalCount = 0; return(queryResult); #endregion }
public override void OnAuthorization(AuthorizationContext filterContext) { var Authorized = false; if (!filterContext.HttpContext.User.Identity.IsAuthenticated) { Authorized = false; } else if (!String.IsNullOrWhiteSpace(Roles)) { ContextContainer Context = new ContextContainer(); var UserRoles = (from a in Context.RoleService.GetUserInRoles(null) select a.ToLower()).ToList(); var RequestRoles = (from a in Roles.Split(',') where a.Trim().Length > 0 select a.Trim().ToLower()).ToList(); Authorized = (from a in RequestRoles where UserRoles.Contains(a) select a).Count() == RequestRoles.Count; } else { Authorized = true; } if (!Authorized) { filterContext.Result = new HttpUnauthorizedResult(); } }
/// <summary> /// 多语言转换 /// 如果多语言文件中可以找到对饮文本编号和当前用户语言编号的文本 /// 则返回找到的文本,否则返回默认文本 /// </summary> /// <param name="code">文本编号</param> /// <param name="strDefault">默认文本</param> /// <returns></returns> public static string Translate(string code, string strDefault) { //从上下文中获取当前用户语言编码 var lcid = ContextContainer.GetValue <int>(ContextTypes.CurrentUserLcid); return(Translate(code, lcid, strDefault)); }
protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext) { var Authorized = base.AuthorizeCore(httpContext); AccessDenied = false; if (Authorized) { HttpContext.Current.Session[session.MenuId] = MenuId; ContextContainer Context = new ContextContainer(); MenuService menuService = new MenuService(Context); Authorized = menuService.IsUserInMenu(MenuId); //foreach (var menuId in MenuId) //{ // Authorized = menuService.IsMenuInRole(Context.CompanyId ?? 0, menuId); // if (Authorized) // break; //} AccessDenied = !Authorized; } return(Authorized); }
/// <summary> /// 新增或编辑 logcall /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <ValidateResult <CrmEntity> > AddOrEditEntity(LogCallRequest request) { var validateResult = new ValidateResult <CrmEntity>(); var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); try { Guid guid = string.IsNullOrEmpty(request.mcs_logcallid) ? Guid.NewGuid() : Guid.Parse(request.mcs_logcallid); CrmExecuteEntity Entity = new CrmExecuteEntity("mcs_logcall", guid); if (!string.IsNullOrEmpty(request.mcs_onlyleadid)) { Entity.Attributes.Add("mcs_onlyleadid", new CrmEntityReference("mcs_onlylead", Guid.Parse(request.mcs_onlyleadid))); } if (!string.IsNullOrEmpty(request.accountid)) { Entity.Attributes.Add("mcs_accountid", new CrmEntityReference("account", Guid.Parse(request.accountid))); } if (!string.IsNullOrEmpty(request.mcs_content)) { Entity.Attributes.Add("mcs_content", request.mcs_content); } if (!string.IsNullOrEmpty(request.mcs_fullname)) { Entity.Attributes.Add("mcs_fullname", request.mcs_fullname); } if (!string.IsNullOrEmpty(request.mcs_mobilephone)) { Entity.Attributes.Add("mcs_mobilephone", request.mcs_mobilephone); } if (!string.IsNullOrEmpty(request.mcs_results)) { Entity.Attributes.Add("mcs_results", request.mcs_results); } if (request.mcs_visittime.HasValue) { Entity.Attributes.Add("mcs_visittime", request.mcs_visittime.Value); } if (!string.IsNullOrEmpty(request.mcs_logcallid)) { await _crmService.Update(Entity, userInfo?.systemuserid); } else { guid = await _crmService.Create(Entity, userInfo?.systemuserid); } validateResult.Result = true; validateResult.Description = "操作成功"; } catch (Exception ex) { validateResult.Result = false; validateResult.Description = "操作失败,原因:" + ex.Message; throw ex; } return(validateResult); }
/// <summary> /// 多语言转换 /// 如果多语言文件中可以找到对饮文本编号和当前用户语言编号的文本 /// 则返回找到的文本,否则返回默认文本 /// </summary> /// <param name="code">文本编号</param> /// <param name="strDefault">默认文本</param> /// <returns></returns> public static string Translate(string code, string strDefault) { //从上下文中获取当前用户信息 var currentUserInfo = ContextContainer.GetValue <ICurrentUserInfoContext>(ContextTypes.CurrentUser); return(Translate(code, currentUserInfo.GetLcid(), strDefault)); }
/// <summary> /// 唯一线索列表查询 /// </summary> /// <param name="onlyLeadRequest"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > QueryList(OnlyLeadRequest onlyLeadRequest) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var fetchString = _onlyLeadRepository.QueryList(onlyLeadRequest); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_onlylead", FetchXml = fetchXdoc, ProxyUserId = userInfo?.systemuserid }; fetchRequest.Headers.Add(dicHeadKey, dicHead[dicHeadKey]); var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = onlyLeadRequest.PageIndex; queryResult.TotalCount = 0; return(queryResult); } catch (Exception ex) { throw ex; } }
public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { if (cki.Key != ConsoleKey.DownArrow) { return; } var inputBuffer = ctx.Get <InputBuffer>(); var inputHistory = ctx.Get <InputHistory>(); var current = inputBuffer.GetInput(); if (current.Length != 0) { inputHistory.Update(current); } current = inputHistory.Next(); if (current == null) { return; } inputBuffer.ForceSetInput(current); inputBuffer.ForceSetCursorPos(current.Length); }
/// <summary> /// 安装单列表查询 /// </summary> /// <param name="_request"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > GetInstallationorderList(InstallationorderRequest _request) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); if (userInfo != null) { _request.mcs_dealerid = userInfo.mcs_dealerid; } var fetchString = _InstallationRepository.GetInstallationorderList(_request); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_installationorder", FetchXml = fetchXdoc, ProxyUserId = userInfo != null ? userInfo.systemuserid : null }; var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = _request.PageIndex; queryResult.TotalCount = 0; return(queryResult); } catch (Exception ex) { throw ex; } }
public void RemoveRole(PAUser user, EntityReferenceCollection roleIdList) { var orgService = ContextContainer.GetValue <IOrganizationService>(ContextTypes.OrgService); Relationship roleRelationShip = new Relationship("systemuserroles_association"); orgService.Disassociate("systemuser", user.EntityRecord.Id, roleRelationShip, roleIdList); }
/// <summary> /// 获取安装单详情 /// </summary> /// <param name="guid"></param> /// <returns></returns> public async Task <CrmEntity> GetInstallationorderDetail(string guid) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var fetchString = _InstallationRepository.GetInstallationorderDetail(Guid.Parse(guid)); var fetchXdoc = XDocument.Parse(fetchString); var fetchResponse = await helper.ExecuteAsync(_crmService, "mcs_installationorder", fetchXdoc); if (fetchResponse != null && fetchResponse.Results.Count > 0) { var item = fetchResponse.Results[0]; var crmEntity = new CrmEntity(item.EntityName, item.Id); crmEntity.Attributes = item.Attributes; crmEntity.IsActivity = item.IsActivity; crmEntity.Version = item.Version; return(crmEntity); } else { return(null); } } catch (Exception ex) { throw ex; } }
public async Task <CrmEntityCollection> ExecuteAsync(ICrmService crmService, string entityName, XDocument document, Guid?userId = null) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var dicHead = new Dictionary <string, IEnumerable <string> >(); dicHead.Add("Prefer", new List <string>() { "odata.include-annotations=\"*\"" }); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = entityName, FetchXml = document, ProxyUserId = userInfo?.systemuserid }; fetchRequest.Headers.Add("Prefer", dicHead["Prefer"]); var crmResponseMessage = await crmService.Execute(fetchRequest); var resultsList = crmResponseMessage as CrmRetrieveMultipleFetchResponseMessage; return(resultsList.Value); } catch (Exception ex) { return(new CrmEntityCollection()); } }
/// <summary> /// 获取安装单用户反馈列表 /// </summary> /// <param name="guid"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > GetInstallationUser(InstallationorderDetailRequest _request) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); var fetchString = _InstallationRepository.GetInstallationUser(Guid.Parse(_request.Guid)); var fetchXdoc = XDocument.Parse(fetchString); var fetchResponse = await helper.ExecuteAsync(_crmService, "mcs_surveysatisfaction", fetchXdoc); if (fetchResponse != null && fetchResponse.Results.Count > 0) { var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponse.Results; return(queryResult); } else { return(null); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取预约时段配置记录 /// </summary> /// <param name="appointmentConfiggRequest"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > GetConfig(AppointmentConfigRequest appointmentConfiggRequest) { try { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.mcs_dealerid)) { appointmentConfiggRequest.mcs_dealerid = Guid.Parse(userInfo.mcs_dealerid); } var fetchString = _appointmentInfoRepository.GetConfig(appointmentConfiggRequest); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_appointmentconfig", FetchXml = fetchXdoc }; var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = appointmentConfiggRequest.page; queryResult.TotalCount = 0; return(queryResult); } catch (Exception ex) { throw ex; } }
public object Get(Type serviceType, object[] arguments, Type[] argumentTypes) { var factory = ActivatorUtilities.CreateFactory(serviceType, argumentTypes); var serviceProvider = ContextContainer.GetValue <IServiceProvider>(ContextTypes.ServiceProvider); return(factory(serviceProvider, arguments)); }
/// <summary> /// 初始化Crm服务 /// </summary> /// <returns></returns> public static CrmService CreateCrmService() { var coreConfiguration = ConfigurationContainer.Get <UserCenterAssConfiguration>(ConfigurationNames.Application); var crmService = DIContainerContainer.Get <CrmService>(); if (coreConfiguration.DyCRMSetting != null) { var dyCRMSetting = coreConfiguration.DyCRMSetting; if (crmService != null) { crmService.CrmApiMaxRetry = dyCRMSetting.CrmApiMaxRetry; crmService.CrmApiVersion = dyCRMSetting.CrmApiVersion; crmService.CrmUrl = dyCRMSetting.CrmUrl; crmService.TokenServiceType = dyCRMSetting.TokenServiceType; crmService.TokenServiceParameters.Add("Domain", dyCRMSetting.Domain); crmService.TokenServiceParameters.Add("AdfsUrl", dyCRMSetting.AdfsUrl); crmService.TokenServiceParameters.Add("CrmUrl", dyCRMSetting.CrmUrl); crmService.TokenServiceParameters.Add("ClientId", dyCRMSetting.ClientId); crmService.TokenServiceParameters.Add("ClientSecret", dyCRMSetting.ClientSecret); crmService.TokenServiceParameters.Add("UserName", dyCRMSetting.UserName); crmService.TokenServiceParameters.Add("Password", dyCRMSetting.Password); crmService.TokenServiceParameters.Add("RedirectUri", dyCRMSetting.RedirectUri); ContextContainer.SetValue <Guid>(ContextExtensionTypes.MemberInstanceId, dyCRMSetting.MemberInstanceId); } } return(crmService); }
/// <summary> /// 列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <QueryResult <CrmEntity> > getlist(ActivityRequest request) { var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo); try { var fetchXdoc = _Repository.GetListFetchXml(request); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_activity", FetchXml = fetchXdoc.Result, ProxyUserId = userInfo?.systemuserid }; var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = request.PageSize; queryResult.TotalCount = 0; return(queryResult); } catch (Exception ex) { throw ex; } }