//create request to retrieve Webresource
QueryByAttribute requestWebResource = new QueryByAttribute
{
EntityName = WebResource.EntityLogicalName,
ColumnSet = new ColumnSet(true),
};
requestWebResource.Attributes.AddRange("name");
requestWebResource.Values.AddRange("url/XML/TestData.xml");
WebResource webResource = null;
EntityCollection webResourceCollection = organizationService.RetrieveMultiple(requestWebResource);
if (webResourceCollection.Entities.Count == 0)
throw new InvalidPluginExecutionException("Specified Webresource does not exist");
webResource = (WebResource)webResourceCollection.Entities[0];
byte[] binary = Convert.FromBase64String(webResource.Attributes["content"].ToString());
string resourceContent = UnicodeEncoding.UTF8.GetString(binary);
Tag Cloud
Pages
Tuesday, October 30, 2012
CRM 2011 CS: create request to retrieve Webresource
CRM 2011 CS: Query to get All Records
// Query to get All Records
protected EntityCollection getROBs(string EntityName)
{
CreatOrgSvcProx cosp = new CreatOrgSvcProx();
OrganizationServiceProxy prox = cosp.getServiceProxy();
ColumnSet _all = new ColumnSet(true);
QueryExpression _robQuery = new QueryExpression(EntityName);
_robQuery.ColumnSet = _all;
EntityCollection _allRec = prox.RetrieveMultiple(_robQuery);
return _allRec;
} //
C#: DATE-TIME FUNCTIONS
// DATE FUNCTIONS
// Get Current Year
protected int _currentYear()
{
DateTime dtn = DateTime.Now;
int ret= dtn.Year;
return ret;
}//**
// Get Current Month
protected int _currentMonth()
{
DateTime dtn = DateTime.Now;
int ret = dtn.Month;
return ret;
}//**
// Get current month in string
protected string _curMonthStr()
{
string thismonth = String.Format("{0:MMMM}", DateTime.Now).ToString();
return thismonth;
}
// Get Current Day
protected int _currentDay()
{
DateTime dtn = DateTime.Now;
int ret = dtn.Day;
return ret;
}//**
// Get Sundays for this month
protected int[] getSundays(int year, int month, DayOfWeek dayName)
{
int[] _sunday = new int[4];
CultureInfo ci = new CultureInfo("en-US");
int ai = 0;
for (int i = 1; i <= ci.Calendar.GetDaysInMonth(year, month); i++)
{
if (new DateTime(year, month, i).DayOfWeek == dayName)
{
//Response.Write(i.ToString());
_sunday[ai] = i; ai += 1;
}
}
return _sunday;
}//**