public void CheckAccountLookup() { List <dynamic> sites = ReadCSV.GetSites("Cases/CheckAccountLookup/CheckAccountLookupTestData.csv"); IWebDriver driver = StartUp(); try { for (int j = 0; j < sites.Count; j++) { try { AccountLookup.Execute(sites[j], driver); } catch (System.Exception ex) { throw ex; } finally { TestContext.WriteLine("CheckAccountLookup"); foreach (KeyValuePair <string, object> entry in sites[j]) { TestContext.WriteLine(entry.Key + ": " + entry.Value); } } } } catch (System.Exception ex) { throw ex; } finally { driver.Close(); driver.Dispose(); } }
protected override void Execute(CodeActivityContext executionContext) { //ITracingService tracingService = executionContext.GetExtension<ITracingService>(); IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); if (InspectionLookup.Get <EntityReference>(executionContext) != null) { recordId = InspectionLookup.Get <EntityReference>(executionContext).Id; queryAttribute = "blu_inspectiondetailid"; isInspection = true; } if (OrderLookup.Get <EntityReference>(executionContext) != null) { recordId = OrderLookup.Get <EntityReference>(executionContext).Id; queryAttribute = "blu_order"; isOrder = true; } if (isInspection == false && isOrder == false) { return; } strName = WFHelpers.GetFirstPortalQuestionAsnwerByNumberAndLookupRecord(executionContext , NameQuestion.Get <string>(executionContext) , queryAttribute , recordId , service); strAddress = WFHelpers.GetFirstPortalQuestionAsnwerByNumberAndLookupRecord(executionContext , AddressQuestion.Get <string>(executionContext) , queryAttribute , recordId , service); strEmailAddress = WFHelpers.GetFirstPortalQuestionAsnwerByNumberAndLookupRecord(executionContext , EmailAddressQuestion.Get <string>(executionContext) , queryAttribute , recordId , service); strMainPhone = WFHelpers.GetFirstPortalQuestionAsnwerByNumberAndLookupRecord(executionContext , TelephoneNumberQuestion.Get <string>(executionContext) , queryAttribute , recordId , service); if (strName != String.Empty && strAddress != String.Empty && strEmailAddress != String.Empty && strMainPhone != String.Empty) { Entity enAccount = new Entity("account") { ["name"] = strName, ["address1_composite"] = strAddress, ["emailaddress1"] = strEmailAddress, ["telephone1"] = strMainPhone }; Guid accountId = Guid.Empty; //Check if Account record already exists otherwise create new #region query Account var fetchXmlAccount = string.Empty; fetchXmlAccount += "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"; fetchXmlAccount += " <entity name='account'>"; fetchXmlAccount += " <attribute name='accountid'/>"; fetchXmlAccount += " <filter type='and'>"; fetchXmlAccount += " <condition attribute='name' operator='eq' value='" + enAccount["name"].ToString() + "'/>"; //fetchXmlAccount += " <condition attribute='address1_composite' operator='eq' value='" + enAccount["address1_composite"].ToString() + "'/>"; fetchXmlAccount += " <condition attribute='emailaddress1' operator='eq' value='" + enAccount["emailaddress1"].ToString() + "'/>"; fetchXmlAccount += " <condition attribute='telephone1' operator='eq' value='" + enAccount["telephone1"].ToString() + "'/>"; fetchXmlAccount += " <condition attribute='statecode' operator='eq' value='0'/>"; fetchXmlAccount += " </filter>"; fetchXmlAccount += " </entity>"; fetchXmlAccount += "</fetch>"; #endregion EntityCollection ecAccount = service.RetrieveMultiple(new FetchExpression(fetchXmlAccount)); if (ecAccount.Entities.Count > 0) { foreach (var enAccountResult in ecAccount.Entities) { accountId = enAccountResult.Id; } } else { accountId = service.Create(enAccount); } AccountLookup.Set(executionContext, new EntityReference("account", accountId)); } }