SearchByKeywordsKbArticleRequest in CRM 4.0 SDK C# - c#

I am using CRM 4.0 SDK to query kbarticles by keyword entered from a textbox on an asp.net webpage. I am using the SearchByKeywordsKbArticleRequest message to do this. Single keywords work fine, but if more than one word is entered a server error occurs. Here is my code:
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "omitted";
CrmService service = new CrmService();
service.Url = "omitted"
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
//RetrieveMultipleResponse allArticlesResponse = getAllArticles();
SearchByKeywordsKbArticleRequest kb = new SearchByKeywordsKbArticleRequest();
String rawSearchText = keyword;
ColumnSet col = new ColumnSet();
col.Attributes = new string[] { "title", "kbarticleid" };
kb.ColumnSet = col;
kb.SearchText = rawSearchText.Trim();
kb.ReturnDynamicEntities = false;
SearchByKeywordsKbArticleResponse response =
(SearchByKeywordsKbArticleResponse)service.Execute(kb);
return response.BusinessEntityCollection;
Any clues?

That method uses the SQL Full-Text indexing service, so you would need to have full-text indexing setup in your database. You should be able to get more information about what's going wrong by enabling tracing in CRM. See:
http://social.microsoft.com/forums/en-us/crmdevelopment/thread/6A4CE7A3-29F3-4E5A-9A89-8E35D6FD05B9

Related

CSOM Search limit to single site

How would I update the following CSOM search code to limit search scope to a single site in the SharePoint tenant:
KeywordQuery keywordQuery = new KeywordQuery(spClientContext);
keywordQuery.QueryText = term;
keywordQuery.StartRow = page;
keywordQuery.RowLimit = pageSize;
keywordQuery.EnableStemming = true;
keywordQuery.TrimDuplicates = false;
SearchExecutor searchExecutor = new SearchExecutor(spClientContext);
ClientResult<ResultTableCollection> resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
spClientContext.ExecuteQuery();
Currently it brings back results from all sites. Using CSOM MS SP Client v4.0.30319. Thanks for the help!
You could add path managed property in QueryText to search in a specific site. For example:
keywordQuery.QueryText = "test path:https://tenant.sharepoint.com/sites/test";

Microsoft.Web.Deployment: How to take the target offline before syncing the new version?

I have a problem with the Microsoft.Web.Deployment package. someone here could tell me, how i must write / configure the sync-process, that the target will be shutdown, before updating it with the new version?
here is my snippet:
var publishSettings = GetPublishSettings(subscriptionId, resourcegroupName, websiteName);
var sourceBaseOptions = new DeploymentBaseOptions();
var targetBaseOptions = new DeploymentBaseOptions
{
ComputerName = publishSettings.ComputerName,
UserName = publishSettings.Username,
Password = publishSettings.Password,
AuthenticationType = "basic",
TraceLevel = Verbose
};
targetBaseOptions.Trace += TargetBaseOptions_Trace;
var syncOptions = new DeploymentSyncOptions
{
DoNotDelete = false,
WhatIf = false,
UseChecksum = true
};
using (var deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.ContentPath, Path.GetFullPath(websitePath), sourceBaseOptions))
{
var summary = deploymentObject.SyncTo(DeploymentWellKnownProvider.ContentPath, publishSettings.SiteName, targetBaseOptions, syncOptions);
if (summary.Errors > 0) throw new Exception("Website Deployment failed");
if (summary.Errors == 0)
{
Console.WriteLine($"{publishSettings.SiteName}: erfolgreich");
}
}
i could imagine that it is something in the DeploymentSyncOptions
thank you guys
From Microsoft.Web.Deployment, I could not find it provides method or option to manage (stop, restart etc) Azure web site. If you’d like to stop your Azure web site before you do deployment, you could try to use Microsoft.Azure.Management.WebSites that provides website management capabilities for Microsoft Azure.
WebSiteManagementClient websiteManagementClient = new WebSiteManagementClient(cred);
websiteManagementClient.SubscriptionId = "your subscription id here";
websiteManagementClient.Sites.StopSite(AzureResourceGroup, siteName);
and you could use websiteManagementClient.Sites.GetSite(AzureResourceGroup, siteName).State to check the site state.

Is it possible to call Dynamics CRM 2011 late-bound WCF Organization service without the SDK - straight customized binding?

I'm trying to implement a pure WCF scenario where I want to call Dynamics CRM WCF service without relying on the SDK helper classes. Basically, I would like to implement federated authentication against Dynamics CRM 2011 using only native WCF support from the .net framework.
The reason I'm doing this is that I would like to port this scenario later-on to BizTalk.
I've successfully generated proxy classes with SvcUtil, but the part of the policies and security assertions are not compatible with the configuration schema. SvcUtil suggests to build the binding from code instead, which is what I'm trying to do.
The resulting code is here:
private static void CallWcf()
{
OrganizationServiceClient client = null;
try
{
// Login Live.com Issuer Binding
var wsHttpBinding = new WSHttpBinding();
wsHttpBinding.Security = new WSHttpSecurity();
wsHttpBinding.Security.Mode = SecurityMode.Transport;
// Endpoint Binding Elements
var securityElement = new TransportSecurityBindingElement();
securityElement.DefaultAlgorithmSuite = SecurityAlgorithmSuite.TripleDes;
securityElement.IncludeTimestamp = true;
securityElement.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
securityElement.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
securityElement.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
var securityTokenParameters = new IssuedSecurityTokenParameters();
securityTokenParameters.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient;
securityTokenParameters.ReferenceStyle = SecurityTokenReferenceStyle.Internal;
securityTokenParameters.RequireDerivedKeys = false;
securityTokenParameters.TokenType = null;
securityTokenParameters.KeyType = SecurityKeyType.SymmetricKey;
securityTokenParameters.KeySize = 192;
securityTokenParameters.IssuerAddress = new EndpointAddress("https://login.live.com/extSTS.srf");
securityTokenParameters.IssuerMetadataAddress = null;
securityTokenParameters.DefaultMessageSecurityVersion = null;
securityTokenParameters.IssuerBinding = wsHttpBinding;
securityElement.EndpointSupportingTokenParameters.Signed.Add(securityTokenParameters);
var textMessageEncodingElement = new TextMessageEncodingBindingElement();
textMessageEncodingElement.MaxReadPoolSize = 64;
textMessageEncodingElement.MaxWritePoolSize = 16;
textMessageEncodingElement.MessageVersion = MessageVersion.Default;
textMessageEncodingElement.WriteEncoding = System.Text.Encoding.UTF8;
textMessageEncodingElement.ReaderQuotas.MaxStringContentLength = 8192;
textMessageEncodingElement.ReaderQuotas.MaxArrayLength = 16384;
textMessageEncodingElement.ReaderQuotas.MaxBytesPerRead = 4096;
textMessageEncodingElement.ReaderQuotas.MaxNameTableCharCount = 16384;
var httpsTransportElement = new HttpsTransportBindingElement();
httpsTransportElement.ManualAddressing = false;
httpsTransportElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
CustomBinding binding = new CustomBinding();
binding.Elements.Add(securityElement);
binding.Elements.Add(textMessageEncodingElement);
binding.Elements.Add(httpsTransportElement);
client = new OrganizationServiceClient(binding, new EndpointAddress(EndpointUri));
client.ClientCredentials.UserName.UserName = Username;
client.ClientCredentials.UserName.Password = Password;
client.Open();
var columnSet = new schemas.microsoft.com.xrm._2011.Contracts.ColumnSet();
var identifier = new Guid("fbf8240e-2c85-e011-ad55-1cc1de0878eb");
columnSet.Columns = new string[] { "name" };
var entity = client.Retrieve("account", identifier, columnSet);
}
finally
{
if (client != null)
client.Close();
}
}
I'm new to federated authentication and am having a hard time figuring out the potential differences between the many available bindings, so I would be grateful for any help in this regard.
It is probably possible, but hugely complicated. We had a project using Dynamics which moved to ADFS, and required adding lots of extra code around refreshing tokens (code form autorefreshsecuritytoken.cs, deviceidmanager.cs and toolserviceproxies.cs from the SDK) and that was still using the SDK for everything.
Bare in mind you also need windows.identification installed in the OS which is another load of functionality to copy.
In the end you can always just use JustDecompile or similar to see what the SDK is doing.

How to publish a post with multiple attachments to a user's facebook profile?

My facebook app uses the Facebook C# SDK to publish to a user's Facebook profile. I'm currently publishing multiple posts with one attachment, but I'd much rather publish one summary post with multiple attachments. I've done this with the JavaScript API, but is it possible with the C# SDK?
This is my current publish code:
FacebookApp app = new FacebookApp(user.AccessToken);
string userFeedPath = String.Format("/{0}/feed/", user.FacebookUserId);
string message = String.Format("{0} earned an achievement in {1}",
user.SteamUserId, achievement.Game.Name);
dynamic parameters = new ExpandoObject();
parameters.link = achievement.Game.StatsUrl;
parameters.message = message;
parameters.name = achievement.Name;
parameters.description = achievement.Description;
parameters.picture = achievement.ImageUrl;
app.Api(userFeedPath, parameters, HttpMethod.Post);
We currently don't support multiple attachments. As far as I know you can't publish multiple attachments with either the graph or rest api. If you have a sample that shows how to do it, I will get it implemented in the SDK.
i have the same code as yours but it doesent work for me. I am trying this:
public void plesni()
{
try
{
dynamic parameters = new ExpandoObject();
parameters.message = "xxxxxxx";
parameters.link = "xxxxxxxx";
// parameters.picture=""
parameters.name = "xxxxxx";
parameters.caption = "xxxxxxx";
parameters.description = "xxxxxxxxxx";
parameters.actions = new
{
name = "xxxxxxx",
link = "http://www.xxxxxxxxxxxxxx.com",
};
parameters.privacy = new
{
value = "ALL_FRIENDS",
};
parameters.targeting = new
{
countries = "US",
regions = "6,53",
locales = "6",
};
dynamic result = app.Api("/uid/feed/", parameters, HttpMethod.Post);
// app.Api("/uid/feed", parameters);
Response.Write("Sucess");
}
catch (FacebookOAuthException)
{
Response.Write("...... <br/>");
}
}
if instead of uid I put me it works fine.
I am hoping for your help.
Have a good day.

Adding a new permission for google document content

I use google docs API(.net, c#) to share my document for other google user (ex: abc#gmail.com). Here's my code:
AclEntry entry = new AclEntry();
entry.Scope = new AclScope();
entry.Scope.Type = AclScope.SCOPE_USER;
entry.Scope.Value = "abc#gmail.com";
entry.Role = new AclRole();
entry.Role = AclRole.ACL_CALENDAR_READ;
Service service = createService(szUserName, szPassword);
string szAclUrl = ((DocumentEntry)contentEntry).AccessControlList;
Uri AclUri = new Uri(szAclUrl);
AtomEntry newAcl = service.Insert(AclUri, entry);
Note: service and contentEntry was created successfully.
But i get an error: (400) Bad Request when execute service.Insert(AclUri, entry) function.
What's i doing wrong? How can i add a new permission using google docs API(.net, c#)?
I think edit
entry.Role = new AclRole();
entry.Role = AclRole.ACL_CALENDAR_READ;
to :
entry.Role = new AclRole("reader"); or entry.Role = new AclRole("writer");

Categories

Resources