int.ToString(System.IFormatProvider)

Here are the examples of the csharp api int.ToString(System.IFormatProvider) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1836 Examples 7

19 Source : PaginatedForumPostUrlProvider.cs
with MIT License
from Adoxio

public string GetPostUrl(IForumThread forumThread, int forumThreadPostCount, Guid forumPostId)
		{
			string forumThreadUrl = forumThread.Url;

			if (forumThreadUrl == null)
			{
				return null;
			}

			if (forumThreadPostCount < 1)
			{
				return "{0}#{1}".FormatWith(forumThread.Url, _anchorFormat.FormatWith(forumPostId));
			}

			var pageNumber = ((forumThreadPostCount - 1) / _pageSize) + 1;

			return "{0}#{1}".FormatWith(
				forumThread.Url.AppendQueryString(_pageQueryStringField, pageNumber.ToString(CultureInfo.InvariantCulture)),
				_anchorFormat.FormatWith(forumPostId));
		}

19 Source : AnnotationDataAdapter.cs
with MIT License
from Adoxio

private static void SetResponseParameters(HttpContextBase context,
			Enreplacedy annotation, Enreplacedy webfile, ICollection<byte> data)
		{
			context.Response.StatusCode = (int)HttpStatusCode.OK;
			context.Response.ContentType = annotation.GetAttributeValue<string>("mimetype");

			var contentDispositionText = "attachment";

			if (_allowDisplayInlineContentTypes.Any(contentType => contentType.Equals(context.Response.ContentType, StringComparison.OrdinalIgnoreCase)))
			{
				contentDispositionText = "inline";
			}

			var contentDisposition = new StringBuilder(contentDispositionText);

			AppendFilenameToContentDisposition(annotation, contentDisposition);

			context.Response.AppendHeader("Content-Disposition", contentDisposition.ToString());
			context.Response.AppendHeader("Content-Length", data.Count.ToString(CultureInfo.InvariantCulture));

			if (webfile?.Attributes != null && webfile.Attributes.ContainsKey("adx_alloworigin"))
			{
				var allowOrigin = webfile["adx_alloworigin"] as string;

				Web.Extensions.SetAccessControlAllowOriginHeader(context, allowOrigin);
			}
		}

19 Source : OrganizationServiceCache.cs
with MIT License
from Adoxio

private string GetCacheKey(object query, string selectorCacheKey, out string queryText)
		{
			if (query is CachedOrganizationRequest) return this.GetCacheKey((query as CachedOrganizationRequest).Request, selectorCacheKey, out queryText);
			if (query is RetrieveSingleRequest) return this.GetCacheKey((query as RetrieveSingleRequest).Request, selectorCacheKey, out queryText);
			if (query is FetchMultipleRequest) return this.GetCacheKey((query as FetchMultipleRequest).Request, selectorCacheKey, out queryText);

			var sb = new StringBuilder(128);

			var text = queryText = this.GetCacheKey(query) ?? Serialize(query);
			var connection = !string.IsNullOrWhiteSpace(ConnectionId)
				? ":ConnectionId={0}".FormatWith(QueryHashingEnabled ? ConnectionId.GetHashCode().ToString(CultureInfo.InvariantCulture) : ConnectionId)
				: null;
			var code = QueryHashingEnabled ? text.GetHashCode().ToString(CultureInfo.InvariantCulture) : text;
			var selector = !string.IsNullOrEmpty(selectorCacheKey)
				? ":Selector={0}".FormatWith(selectorCacheKey)
				: null;

			return sb.AppendFormat("{0}{1}:Query={2}{3}",
				GetType().FullName,
				connection,
				code,
				selector).ToString();
		}

19 Source : FileSize.cs
with MIT License
from Adoxio

public string ToString(int precision, IFormatProvider formatProvider = null)
		{
			var pow = Math.Floor((_value > 0 ? Math.Log(_value) : 0) / Math.Log(1024));

			pow = Math.Min(pow, _units.Length - 1);

			var value = _value / Math.Pow(1024, pow);

			var precisionString = formatProvider == null
				? precision.ToString(CultureInfo.CurrentCulture)
				: precision.ToString(formatProvider);

			return value.ToString(Math.Abs(pow - 0) < double.Epsilon ? "F0" : "F" + precisionString) + " " + _units[(int)pow];
		}

19 Source : AnnotationHandler.cs
with MIT License
from Adoxio

public void ProcessRequest(HttpContext context)
		{
			if (_annotation == null)
			{
				context.Response.StatusCode = (int)HttpStatusCode.NotFound;
				return;
			}

			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website,
				"Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies =
				new PortalConfigurationDataAdapterDependencies(requestContext: context.Request.RequestContext,
					portalName: portalName);
			var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);

			dataAdapter.Download(new HttpContextWrapper(context), _annotation, _webfile);
		}

19 Source : SalesAttachmentHandler.cs
with MIT License
from Adoxio

private static void SetResponseParameters(HttpResponse response, HttpCacheability defaultCacheability, Enreplacedy salesLiteratureItem, byte[] data)
		{
			response.StatusCode = (int)HttpStatusCode.OK;
			response.ContentType = salesLiteratureItem.GetAttributeValue<string>("mimetype");

			const string contentDispositionText = "inline";
			
			var contentDisposition = new StringBuilder(contentDispositionText);

			AppendFilenameToContentDisposition(salesLiteratureItem, contentDisposition);

			response.AppendHeader("Content-Disposition", contentDisposition.ToString());
			response.AppendHeader("Content-Length", data.Length.ToString(CultureInfo.InvariantCulture));

			Utility.SetResponseCachePolicy(new HttpCachePolicyElement(), new HttpResponseWrapper(response), defaultCacheability);
		}

19 Source : ODataQueryOptionExtensions.cs
with MIT License
from Adoxio

internal static Uri GetNextPageLink(Uri requestUri, IEnumerable<KeyValuePair<string, string>> queryParameters, int pageSize)
		{
			var stringBuilder = new StringBuilder();
			var num = pageSize;
			foreach (var keyValuePair in queryParameters)
			{
				var key = keyValuePair.Key;
				var str1 = keyValuePair.Value;
				switch (key)
				{
					case "$top":
						int result1;
						if (int.TryParse(str1, out result1))
						{
							str1 = (result1 - pageSize).ToString(CultureInfo.InvariantCulture);
						}
						break;
					case "$skip":
						int result2;
						if (int.TryParse(str1, out result2))
						{
							num += result2;
						}
						continue;
				}
				var str2 = key.Length <= 0 || (int)key[0] != 36 ? Uri.EscapeDataString(key) : string.Format("${0}", Uri.EscapeDataString(key.Substring(1)));
				var str3 = Uri.EscapeDataString(str1);
				stringBuilder.Append(str2);
				stringBuilder.Append('=');
				stringBuilder.Append(str3);
				stringBuilder.Append('&');
			}
			stringBuilder.AppendFormat("$skip={0}", num);
			return new UriBuilder(requestUri)
			{
				Query = stringBuilder.ToString()
			}.Uri;
		}

19 Source : ErrorNotifierModule.cs
with MIT License
from Adoxio

protected virtual IEnumerable<KeyValuePair<string, string>> GetHeaders(Exception error, HttpContext context, int dropped)
		{
			yield return CreateHeader("X-ADXSTUDIO-SERVER_NAME", context.Request.ServerVariables["SERVER_NAME"]);
			yield return CreateHeader("X-ADXSTUDIO-SCRIPT_NAME", context.Request.ServerVariables["SCRIPT_NAME"]);
			yield return CreateHeader("X-ADXSTUDIO-QUERY_STRING", context.Request.ServerVariables["QUERY_STRING"]);
			yield return CreateHeader("X-ADXSTUDIO-STATUS_CODE", context.Response.StatusCode.ToString());
			yield return CreateHeader("X-ADXSTUDIO-STATUS", context.Response.Status);
			yield return CreateHeader("X-ADXSTUDIO-CONTENT-TYPE", context.Response.ContentType);
			yield return CreateHeader("X-ADXSTUDIO-CONTENT-ENCODING", context.Response.ContentEncoding.EncodingName);
			yield return CreateHeader("X-ADXSTUDIO-EXCEPTION-TYPE", error.GetType().FullName);
			yield return CreateHeader("X-ADXSTUDIO-EXCEPTION-DROPPED", dropped.ToString(CultureInfo.InvariantCulture));
		}

19 Source : SharePointGridExtensions.cs
with MIT License
from Adoxio

public static IHtmlString SharePointGrid(this HtmlHelper html, EnreplacedyReference target, string serviceUrlGet, bool createEnabled = false, bool deleteEnabled = false,
			string serviceUrlAddFiles = null, string serviceUrlAddFolder = null, string serviceUrlDelete = null, int pageSize = 0,
			string replacedle = null, string fileNameColumnLabel = null, string modifiedColumnLabel = null, string parentFolderPrefix = null,
			string loadingMessage = null, string errorMessage = null, string accessDeniedMessage = null, string emptyMessage = null,
			string addFilesButtonLabel = null, string addFolderButtonLabel = null, string toolbarButtonLabel = null, string deleteButtonLabel = null,
			BootstrapExtensions.BootstrapModalSize modalAddFilesSize = BootstrapExtensions.BootstrapModalSize.Default,
			string modalAddFilesCssClreplaced = null, string modalAddFilesreplacedle = null, string modalAddFilesDismissButtonSrText = null,
			string modalAddFilesPrimaryButtonText = null, string modalAddFilesCancelButtonText = null, string modalAddFilesreplacedleCssClreplaced = null,
			string modalAddFilesPrimaryButtonCssClreplaced = null, string modalAddFilesCancelButtonCssClreplaced = null,
			string modalAddFilesAttachFileLabel = null, string modalAddFilesAttachFileAccept = null,
			bool modalAddFilesDisplayOverwriteField = true, string modalAddFilesOverwriteFieldLabel = null,
			bool modalAddFilesOverwriteFieldDefaultValue = true, string modalAddFilesDestinationFolderLabel = null,
			string modalAddFilesFormLeftColumnCssClreplaced = null, string modalAddFilesFormRightColumnCssClreplaced = null,
			IDictionary<string, string> modalAddFilesHtmlAttributes = null,
			BootstrapExtensions.BootstrapModalSize modalAddFolderSize = BootstrapExtensions.BootstrapModalSize.Default,
			string modalAddFolderCssClreplaced = null, string modalAddFolderreplacedle = null, string modalAddFolderDismissButtonSrText = null,
			string modalAddFolderPrimaryButtonText = null, string modalAddFolderCancelButtonText = null, string modalAddFolderreplacedleCssClreplaced = null,
			string modalAddFolderPrimaryButtonCssClreplaced = null, string modalAddFolderCancelButtonCssClreplaced = null,
			string modalAddFolderNameLabel = null, string modalAddFolderDestinationFolderLabel = null,
			string modalAddFolderFormLeftColumnCssClreplaced = null, string modalAddFolderFormRightColumnCssClreplaced = null,
			IDictionary<string, string> modalAddFolderHtmlAttributes = null,
			BootstrapExtensions.BootstrapModalSize modalDeleteFileSize = BootstrapExtensions.BootstrapModalSize.Default,
			string modalDeleteFileCssClreplaced = null, string modalDeleteFilereplacedle = null, string modalDeleteFileConfirmation = null, string modalDeleteFileDismissButtonSrText = null,
			string modalDeleteFilePrimaryButtonText = null, string modalDeleteFileCancelButtonText = null, string modalDeleteFilereplacedleCssClreplaced = null,
			string modalDeleteFilePrimaryButtonCssClreplaced = null, string modalDeleteFileCancelButtonCssClreplaced = null, IDictionary<string, string> modalDeleteFileHtmlAttributes = null,
			BootstrapExtensions.BootstrapModalSize modalDeleteFolderSize = BootstrapExtensions.BootstrapModalSize.Default,
			string modalDeleteFolderCssClreplaced = null, string modalDeleteFolderreplacedle = null, string modalDeleteFolderConfirmation = null, string modalDeleteFolderDismissButtonSrText = null,
			string modalDeleteFolderPrimaryButtonText = null, string modalDeleteFolderCancelButtonText = null, string modalDeleteFolderreplacedleCssClreplaced = null,
			string modalDeleteFolderPrimaryButtonCssClreplaced = null, string modalDeleteFolderCancelButtonCssClreplaced = null, IDictionary<string, string> modalDeleteFolderHtmlAttributes = null)
		{
			var container = new TagBuilder("div");
			container.AddCssClreplaced("sharepoint-grid");
			container.AddCssClreplaced("subgrid");
			container.MergeAttribute("data-url-get", serviceUrlGet);
			container.MergeAttribute("data-url-add-files", serviceUrlAddFiles);
			container.MergeAttribute("data-url-add-folder", serviceUrlAddFolder);
			container.MergeAttribute("data-url-delete", serviceUrlDelete);
			container.MergeAttribute("data-add-enabled", createEnabled.ToString());
			container.MergeAttribute("data-delete-enabled", deleteEnabled.ToString());
			container.MergeAttribute("data-target", JsonConvert.SerializeObject(target));
			container.MergeAttribute("data-pagesize", pageSize.ToString(CultureInfo.InvariantCulture));

			if (!string.IsNullOrWhiteSpace(replacedle))
			{
				var header = new TagBuilder("div");
				header.AddCssClreplaced("page-header");
				header.InnerHtml = (new TagBuilder("h3") { InnerHtml = replacedle.GetValueOrDefault(DefaultSharePointGridreplacedle) }).ToString();
				container.InnerHtml += header.ToString();
			}

			var template = new TagBuilder("script");
			template.MergeAttribute("id", "sharepoint-template");
			template.MergeAttribute("type", "text/x-handlebars-template");
			var grid = new TagBuilder("div");
			grid.AddCssClreplaced("view-grid");
			var table = new TagBuilder("table");
			table.AddCssClreplaced("table");
			table.AddCssClreplaced("table-striped");
			table.MergeAttribute("aria-live", "polite");
			table.MergeAttribute("aria-relevant", "additions");
			var thead = new TagBuilder("thead");
			var theadRow = new TagBuilder("tr");
			var fileNameColumnHeader = new TagBuilder("th");
			fileNameColumnHeader.MergeAttribute("data-sort-name", "FileLeafRef");
			fileNameColumnHeader.AddCssClreplaced("sort-enabled");
			var fileNameColumnLink = new TagBuilder("a");
			fileNameColumnLink.MergeAttribute("href", "#");
			fileNameColumnLink.InnerHtml = fileNameColumnLabel.GetValueOrDefault(DefaultFileNameColumnreplacedle);
			fileNameColumnHeader.InnerHtml = fileNameColumnLink.ToString();
			theadRow.InnerHtml += fileNameColumnHeader.ToString();
			var modifiedColumnHeader = new TagBuilder("th");
			modifiedColumnHeader.MergeAttribute("data-sort-name", "Modified");
			modifiedColumnHeader.AddCssClreplaced("sort-enabled");
			var modifiedColumnLink = new TagBuilder("a");
			modifiedColumnLink.MergeAttribute("href", "#");
			modifiedColumnLink.InnerHtml = modifiedColumnLabel.GetValueOrDefault(DefaultModifiedColumnreplacedle);
			modifiedColumnHeader.InnerHtml = modifiedColumnLink.ToString();
			theadRow.InnerHtml += modifiedColumnHeader.ToString();
			if (deleteEnabled)
			{
				var actionsHeader = new TagBuilder("th");
				actionsHeader.AddCssClreplaced("sort-disabled");
				actionsHeader.InnerHtml = "<span clreplaced='sr-only'>Actions</span>";
				theadRow.InnerHtml += actionsHeader.ToString();
			}
			thead.InnerHtml = theadRow.ToString();
			table.InnerHtml += thead.ToString();
			table.InnerHtml += "{{#each SharePoinreplacedems}}";
			table.InnerHtml += "{{#if IsFolder}}";
			var folderRow = new TagBuilder("tr");
			folderRow.AddCssClreplaced("sp-item");
			folderRow.MergeAttribute("data-id", "{{Id}}");
			folderRow.MergeAttribute("data-foldername", "{{Name}}");
			folderRow.MergeAttribute("data-folderpath", "{{FolderPath}}");
			var folderNameCell = new TagBuilder("td");
			folderNameCell.MergeAttribute("data-type", "System.String");
			folderNameCell.MergeAttribute("data-value", "{{Name}}");
			var folderLink = new TagBuilder("a");
			folderLink.AddCssClreplaced("folder-link");
			folderLink.MergeAttribute("data-folderpath", "{{FolderPath}}");
			folderLink.MergeAttribute("href", "#");
			folderLink.InnerHtml += "{{#if IsParent}}";
			folderLink.InnerHtml += "<span clreplaced='fa fa-level-up text-primary' aria-hidden='true'></span> ";
			folderLink.InnerHtml += parentFolderPrefix.GetValueOrDefault(DefaultParentFolderPrefix);
			folderLink.InnerHtml += "{{Name}}";
			folderLink.InnerHtml += "{{else}}";
			folderLink.InnerHtml += "<span clreplaced='fa fa-folder text-primary' aria-hidden='true'></span> {{Name}}";
			folderLink.InnerHtml += "{{/if}}";
			folderNameCell.InnerHtml += folderLink.ToString();
			folderRow.InnerHtml += folderNameCell.ToString();
			folderRow.InnerHtml += "{{#if IsParent}}";
			folderRow.InnerHtml += new TagBuilder("td").ToString();
			folderRow.InnerHtml += "{{else}}";
			var folderModifiedCell = new TagBuilder("td");
			folderModifiedCell.AddCssClreplaced("postedon");
			var folderModifiedAbbr = new TagBuilder("abbr");
			folderModifiedAbbr.AddCssClreplaced("timeago");
			folderModifiedAbbr.MergeAttribute("replacedle", "{{ModifiedOnDisplay}}");
			folderModifiedAbbr.MergeAttribute("data-datetime", "{{ModifiedOnDisplay}}");
			folderModifiedAbbr.InnerHtml = "{{ModifiedOnDisplay}}";
			folderModifiedCell.InnerHtml = folderModifiedAbbr.ToString();
			folderRow.InnerHtml += folderModifiedCell.ToString();
			folderRow.InnerHtml += "{{/if}}";
			if (deleteEnabled)
			{
				folderRow.InnerHtml += ActionCell(toolbarButtonLabel, deleteButtonLabel).ToString();
			}
			table.InnerHtml += folderRow.ToString();
			table.InnerHtml += "{{else}}";
			var fileRow = new TagBuilder("tr");
			fileRow.AddCssClreplaced("sp-item");
			fileRow.MergeAttribute("data-id", "{{Id}}");
			fileRow.MergeAttribute("data-filename", "{{Name}}");
			fileRow.MergeAttribute("data-url", "{{Url}}");
			var fileNameCell = new TagBuilder("td");
			fileNameCell.MergeAttribute("data-type", "System.String");
			fileNameCell.MergeAttribute("data-value", "{{Name}}");
			var fileLink = new TagBuilder("a");
			fileLink.MergeAttribute("target", "_blank");
			fileLink.MergeAttribute("href", "{{Url}}");
			fileLink.InnerHtml = "<span clreplaced='fa fa-file-o' aria-hidden='true'></span> {{Name}} <small>({{FileSizeDisplay}})</small>";
			fileNameCell.InnerHtml += fileLink.ToString();
			fileRow.InnerHtml += fileNameCell.ToString();
			var fileModifiedCell = new TagBuilder("td");
			fileModifiedCell.AddCssClreplaced("postedon");
			var fileModifiedAbbr = new TagBuilder("abbr");
			fileModifiedAbbr.AddCssClreplaced("timeago");
			fileModifiedAbbr.MergeAttribute("replacedle", "{{ModifiedOnDisplay}}");
			fileModifiedAbbr.MergeAttribute("data-datetime", "{{ModifiedOnDisplay}}");
			fileModifiedAbbr.InnerHtml = "{{ModifiedOnDisplay}}";
			fileModifiedCell.InnerHtml = fileModifiedAbbr.ToString();
			fileRow.InnerHtml += fileModifiedCell.ToString();
			if (deleteEnabled)
			{
				fileRow.InnerHtml += ActionCell(toolbarButtonLabel, deleteButtonLabel).ToString();
			}
			table.InnerHtml += fileRow.ToString();
			table.InnerHtml += "{{/if}}";
			table.InnerHtml += "{{/each}}";
			grid.InnerHtml += table.ToString();
			template.InnerHtml = grid.GetHTML();
			container.InnerHtml += template.ToString();

			var actionRow = new TagBuilder("div");
			actionRow.AddCssClreplaced("view-toolbar grid-actions clearfix");
			if (createEnabled)
			{
				if (!string.IsNullOrWhiteSpace(serviceUrlAddFolder))
				{
					var button = new TagBuilder("a");
					button.AddCssClreplaced("btn btn-info pull-right action");
					button.AddCssClreplaced("add-folder");
					button.MergeAttribute("replacedle", addFolderButtonLabel.GetValueOrDefault(DefaultAddFolderButtonLabel));
					button.InnerHtml = addFolderButtonLabel.GetValueOrDefault(DefaultAddFolderButtonLabel);
					actionRow.InnerHtml += button.ToString();
				}

				if (!string.IsNullOrWhiteSpace(serviceUrlAddFiles))
				{
					var button = new TagBuilder("a");
					button.AddCssClreplaced("btn btn-primary pull-right action");
					button.AddCssClreplaced("add-file");
					button.MergeAttribute("replacedle", addFilesButtonLabel.GetValueOrDefault(DefaultAddFilesButtonLabel));
					button.InnerHtml = addFilesButtonLabel.GetValueOrDefault(DefaultAddFilesButtonLabel);
					actionRow.InnerHtml += button.ToString();
				}
			}
			container.InnerHtml += actionRow.ToString();

			var sharePointBreadcrumbs = new TagBuilder("ol");
			sharePointBreadcrumbs.AddCssClreplaced("sharepoint-breadcrumbs");
			sharePointBreadcrumbs.AddCssClreplaced("breadcrumb");
			sharePointBreadcrumbs.MergeAttribute("style", "display: none;");
			container.InnerHtml += sharePointBreadcrumbs.ToString();

			var sharePointData = new TagBuilder("div");
			sharePointData.AddCssClreplaced("sharepoint-data");
			container.InnerHtml += sharePointData.ToString();

			var messageEmpty = new TagBuilder("div");
			messageEmpty.AddCssClreplaced("sharepoint-empty message");
			messageEmpty.MergeAttribute("style", "display: none;");
			if (!string.IsNullOrWhiteSpace(emptyMessage))
			{
				messageEmpty.InnerHtml = emptyMessage;
			}
			else
			{
				var message = new TagBuilder("div");
				message.AddCssClreplaced("alert alert-block alert-warning");
				message.InnerHtml = DefaultSharePointGridEmptyMessage;
				messageEmpty.InnerHtml = message.ToString();
			}
			container.InnerHtml += messageEmpty.ToString();

			var messageAccessDenied = new TagBuilder("div");
			messageAccessDenied.AddCssClreplaced("sharepoint-access-denied message");
			messageAccessDenied.MergeAttribute("style", "display: none;");
			if (!string.IsNullOrWhiteSpace(accessDeniedMessage))
			{
				messageAccessDenied.InnerHtml = accessDeniedMessage;
			}
			else
			{
				var message = new TagBuilder("div");
				message.AddCssClreplaced("alert alert-block alert-danger");
				message.InnerHtml = DefaultSharePointGridAccessDeniedMessage;
				messageAccessDenied.InnerHtml = message.ToString();
			}
			container.InnerHtml += messageAccessDenied.ToString();

			var messageError = new TagBuilder("div");
			messageError.AddCssClreplaced("sharepoint-error message");
			messageError.MergeAttribute("style", "display: none;");
			if (!string.IsNullOrWhiteSpace(errorMessage))
			{
				messageError.InnerHtml = errorMessage;
			}
			else
			{
				var message = new TagBuilder("div");
				message.AddCssClreplaced("alert alert-block alert-danger");
				message.InnerHtml = DefaultSharePointGridErrorMessage;
				messageError.InnerHtml = message.ToString();
			}
			container.InnerHtml += messageError.ToString();

			var messageLoading = new TagBuilder("div");
			messageLoading.AddCssClreplaced("sharepoint-loading message text-center");
			messageLoading.InnerHtml = !string.IsNullOrWhiteSpace(loadingMessage)
				? loadingMessage
				: DefaultSharePointGridLoadingMessage;
			container.InnerHtml += messageLoading.ToString();

			var pagination = new TagBuilder("div");
			pagination.AddCssClreplaced("sharepoint-pagination");
			pagination.MergeAttribute("data-pages", "1");
			pagination.MergeAttribute("data-pagesize", pageSize.ToString(CultureInfo.InvariantCulture));
			pagination.MergeAttribute("data-current-page", "1");
			container.InnerHtml += pagination;

			if (createEnabled)
			{
				if (!string.IsNullOrWhiteSpace(serviceUrlAddFiles))
				{
					var addFileModal = AddFilesModal(html, target, serviceUrlAddFiles, modalAddFilesSize, modalAddFilesCssClreplaced, modalAddFilesreplacedle,
						modalAddFilesDismissButtonSrText, modalAddFilesPrimaryButtonText, modalAddFilesCancelButtonText, modalAddFilesreplacedleCssClreplaced,
						modalAddFilesPrimaryButtonCssClreplaced, modalAddFilesCancelButtonCssClreplaced, modalAddFilesAttachFileLabel, modalAddFilesAttachFileAccept,
						modalAddFilesDisplayOverwriteField, modalAddFilesOverwriteFieldLabel, modalAddFilesOverwriteFieldDefaultValue, modalAddFilesDestinationFolderLabel,
						modalAddFilesFormLeftColumnCssClreplaced, modalAddFilesFormRightColumnCssClreplaced, modalAddFilesHtmlAttributes);

					container.InnerHtml += addFileModal;
				}

				if (!string.IsNullOrWhiteSpace(serviceUrlAddFolder))
				{
					var addFolderModal = AddFolderModal(html, target, serviceUrlAddFolder, modalAddFolderSize, modalAddFolderCssClreplaced, modalAddFolderreplacedle,
						modalAddFolderDismissButtonSrText, modalAddFolderPrimaryButtonText, modalAddFolderCancelButtonText, modalAddFolderreplacedleCssClreplaced,
						modalAddFolderPrimaryButtonCssClreplaced, modalAddFolderCancelButtonCssClreplaced, modalAddFolderNameLabel, modalAddFolderDestinationFolderLabel,
						modalAddFolderFormLeftColumnCssClreplaced, modalAddFolderFormRightColumnCssClreplaced, modalAddFolderHtmlAttributes);

					container.InnerHtml += addFolderModal;
				}
			}

			if (deleteEnabled && !string.IsNullOrWhiteSpace(serviceUrlDelete))
			{
				var deleteFileModal = html.DeleteModal(modalDeleteFileSize, string.Join(" ", new[] { "modal-delete-file", modalDeleteFileCssClreplaced }).TrimEnd(' '),
					modalDeleteFilereplacedle.GetValueOrDefault(DefaultDeleteFileModalreplacedle),
					modalDeleteFileConfirmation.GetValueOrDefault(DefaultDeleteFileModalConfirmation),
					modalDeleteFileDismissButtonSrText.GetValueOrDefault(DefaultModalDismissButtonSrText),
					modalDeleteFilePrimaryButtonText.GetValueOrDefault(DefaultDeleteModalPrimaryButtonText),
					modalDeleteFileCancelButtonText.GetValueOrDefault(DefaultDeleteModalCancelButtonText),
					modalDeleteFilereplacedleCssClreplaced, modalDeleteFilePrimaryButtonCssClreplaced, modalDeleteFileCancelButtonCssClreplaced,
					modalDeleteFileHtmlAttributes);

				container.InnerHtml += deleteFileModal;

				var deleteFolderModal = html.DeleteModal(modalDeleteFolderSize, string.Join(" ", new[] { "modal-delete-folder", modalDeleteFolderCssClreplaced }).TrimEnd(' '),
					modalDeleteFolderreplacedle.GetValueOrDefault(DefaultDeleteFolderModalreplacedle),
					modalDeleteFolderConfirmation.GetValueOrDefault(DefaultDeleteFolderModalConfirmation),
					modalDeleteFolderDismissButtonSrText.GetValueOrDefault(DefaultModalDismissButtonSrText),
					modalDeleteFolderPrimaryButtonText.GetValueOrDefault(DefaultDeleteModalPrimaryButtonText),
					modalDeleteFolderCancelButtonText.GetValueOrDefault(DefaultDeleteModalCancelButtonText),
					modalDeleteFolderreplacedleCssClreplaced, modalDeleteFolderPrimaryButtonCssClreplaced, modalDeleteFolderCancelButtonCssClreplaced,
					modalDeleteFolderHtmlAttributes);

				container.InnerHtml += deleteFolderModal;
			}

			return new HtmlString(container.ToString());
		}

19 Source : BooleanControlTemplate.cs
with MIT License
from Adoxio

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(Control container, ListControl dropDown)
		{
			dropDown.CssClreplaced = string.Join(" ", "readonly", dropDown.CssClreplaced);
			dropDown.Attributes["disabled"] = "disabled";

			var hiddenValue = new HiddenField
			{
				ID = "{0}_Value".FormatWith(ControlID),
				Value = dropDown.SelectedValue
			};
			container.Controls.Add(hiddenValue);

			var hiddenSelectedIndex = new HiddenField
			{
				ID = "{0}_SelectedIndex".FormatWith(ControlID),
				Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture)
			};
			container.Controls.Add(hiddenSelectedIndex);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					int value;
					return int.TryParse(hiddenValue.Value, out value) ? (object)(value == 1) : null;
				},
				Set = obj =>
				{
					var value = new OptionSetValue(Convert.ToInt32(obj)).Value;
					dropDown.SelectedValue = "{0}".FormatWith(value);
					hiddenValue.Value = dropDown.SelectedValue;
					hiddenSelectedIndex.Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture);
				}
			};
		}

19 Source : CustomerControlTemplate.cs
with MIT License
from Adoxio

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(Control container, OrganizationServiceContext context, DropDownList dropDown)
		{
			dropDown.CssClreplaced = "{0} readonly".FormatWith(CssClreplaced);
			dropDown.Attributes["disabled"] = "disabled";
			dropDown.Attributes["aria-disabled"] = "true";

			var hiddenValue = new HiddenField { ID = "{0}_Value".FormatWith(ControlID) };
			container.Controls.Add(hiddenValue);

			var hiddenSelectedIndex = new HiddenField { ID = "{0}_SelectedIndex".FormatWith(ControlID) };
			container.Controls.Add(hiddenSelectedIndex);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					Guid id;

					if (Guid.TryParse(hiddenValue.Value, out id))
					{
						foreach (var lookupTarget in Metadata.LookupTargets)
						{
							var lookupTargetId = GetEnreplacedyMetadata(context, lookupTarget).PrimaryIdAttribute;

							var foundEnreplacedy = context.CreateQuery(lookupTarget).FirstOrDefault(e => e.GetAttributeValue<Guid?>(lookupTargetId) == id);

							if (foundEnreplacedy != null)
							{
								return new EnreplacedyReference(lookupTarget, id);
							}
						}
					}

					return null;
				},
				Set = obj =>
				{
					var enreplacedyReference = (EnreplacedyReference)obj;
					dropDown.Items.Add(new Lisreplacedem
					{
						Value = enreplacedyReference.Id.ToString(),
						Text = enreplacedyReference.Name ?? string.Empty
					});
					dropDown.SelectedValue = "{0}".FormatWith(enreplacedyReference.Id);
					hiddenValue.Value = dropDown.SelectedValue;
					hiddenSelectedIndex.Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture);
				}
			};
		}

19 Source : DurationControlTemplate.cs
with MIT License
from Adoxio

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(Control container, DropDownList dropDown)
		{
			dropDown.CssClreplaced = "{0} readonly".FormatWith(CssClreplaced);
			dropDown.Attributes["disabled"] = "disabled";
			dropDown.Attributes["aria-disabled"] = "true";

			var hiddenValue = new HiddenField
			{
				ID = "{0}_Value".FormatWith(ControlID),
				Value = dropDown.SelectedValue
			};
			container.Controls.Add(hiddenValue);

			var hiddenSelectedIndex = new HiddenField
			{
				ID = "{0}_SelectedIndex".FormatWith(ControlID),
				Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture)
			};
			container.Controls.Add(hiddenSelectedIndex);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					int value;
					return int.TryParse(hiddenValue.Value, out value) ? new int?(value) : null;
				},
				Set = obj =>
				{
					var value = "{0}".FormatWith(obj);
					dropDown.SelectedValue = value;
					hiddenValue.Value = dropDown.SelectedValue;
					hiddenSelectedIndex.Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture);
				}
			};
		}

19 Source : ConstantSumControlTemplate.cs
with MIT License
from Adoxio

protected override void InstantiateControlIn(Control container)
		{
			var textbox = new TextBox { ID = ControlID, TextMode = TextBoxMode.SingleLine, CssClreplaced = string.Join(" ", "text integer", Metadata.GroupName, Metadata.CssClreplaced), ToolTip = Metadata.ToolTip, Width = 30 };

			if (Metadata.IsRequired || Metadata.WebFormForceFieldIsRequired)
			{
				textbox.Attributes.Add("required", string.Empty);
			}

			if (Metadata.ReadOnly)
			{
				textbox.CssClreplaced += " readonly";
				textbox.Attributes["readonly"] = "readonly";
			}

			textbox.Attributes["onchange"] = "setIsDirty(this.id);setPrecision(this.id);updateConstantSum('" + Metadata.GroupName + "');";

			container.Controls.Add(textbox);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					int value;

					return int.TryParse(textbox.Text, out value) ? new int?(value) : null;
				},
				Set = obj =>
				{
					textbox.Text = "{0}".FormatWith(obj);
				}
			};

			// Add a single hidden field to store the index of the constant sum fields processed
			var index = 0;
			HiddenField hiddenField;
			var hiddenFieldControl = container.Parent.Parent.Parent.FindControl(string.Format("ConstantSumIndex{0}", Metadata.GroupName));
			if (hiddenFieldControl == null)
			{
				hiddenField = new HiddenField { ID = string.Format("ConstantSumIndex{0}", Metadata.GroupName), ClientIDMode = ClientIDMode.Static, Value = "1" };
				container.Parent.Parent.Parent.Controls.Add(hiddenField);
			}
			else
			{
				hiddenField = (HiddenField)hiddenFieldControl;
				int.TryParse(hiddenField.Value, out index);
			}
			index++;
			hiddenField.Value = index.ToString(CultureInfo.InvariantCulture);
			// Add a single field to display the sum
			if (index == Metadata.ConstantSumAttributeNames.Length)
			{
				var totalField = new TextBox { ID = string.Format("ConstantSumTotalValue{0}", Metadata.GroupName), CssClreplaced = "total", Text = "0", Width = 30, ClientIDMode = ClientIDMode.Static };

				totalField.Attributes.Add("readonly", "readonly"); // Adding readonly attribute provides viewstate support and prevents user editing as opposed to setting the control's ReadOnly property which does not retain value in viewstate if value is modified by javascript.

				container.Controls.Add(totalField);

				var constantSumValidator = new CustomValidator
				{
					ID = string.Format("ConstantSumTotalValidator{0}", Metadata.GroupName),
					ControlToValidate = string.Format("ConstantSumTotalValue{0}", Metadata.GroupName),
					ValidationGroup = ValidationGroup,
					ErrorMessage = ValidationSummaryMarkup((string.IsNullOrWhiteSpace(Metadata.ConstantSumValidationErrorMessage) ? ResourceManager.GetString("Constant_Sum_Validation_Error_Message") : Metadata.ConstantSumValidationErrorMessage)),
					Text = "*",
					CssClreplaced = "validator-text"
				};

				constantSumValidator.ServerValidate += GetConstantSumValidationHandler(container.Parent.Parent.Parent, Metadata.GroupName, Metadata.ConstantSumMinimumTotal, Metadata.ConstantSumMaximumTotal);

				container.Controls.Add(constantSumValidator);
			}
		}

19 Source : PicklistControlTemplate.cs
with MIT License
from Adoxio

protected override void InstantiateControlIn(Control container)
		{
			ListControl listControl;

			switch (Metadata.ControlStyle)
			{
			case WebFormMetadata.ControlStyle.VerticalRadioButtonList:
				listControl = new RadioButtonList
				{
					ID = ControlID,
					CssClreplaced = string.Join(" ", "picklist", "vertical", Metadata.CssClreplaced),
					ToolTip = Metadata.ToolTip,
					RepeatDirection = RepeatDirection.Vertical,
					RepeatLayout = RepeatLayout.Flow
				};
				break;
			case WebFormMetadata.ControlStyle.HorizontalRadioButtonList:
				listControl = new RadioButtonList
				{
					ID = ControlID,
					CssClreplaced = string.Join(" ", "picklist", "horizontal", Metadata.CssClreplaced),
					ToolTip = Metadata.ToolTip,
					RepeatDirection = RepeatDirection.Horizontal,
					RepeatLayout = RepeatLayout.Flow
				};
				break;
			case WebFormMetadata.ControlStyle.MultipleChoiceMatrix:
				listControl = new RadioButtonList
				{
					ID = ControlID,
					CssClreplaced = string.Join(" ", "picklist", "horizontal", "labels-top", Metadata.CssClreplaced),
					ToolTip = Metadata.ToolTip,
					RepeatDirection = RepeatDirection.Horizontal,
					RepeatLayout = RepeatLayout.Table,
					TextAlign = TextAlign.Left
				};
				break;
			default:
				listControl = new DropDownList
				{
					ID = ControlID,
					CssClreplaced = string.Join(" ", "form-control", CssClreplaced, Metadata.CssClreplaced),
					ToolTip = Metadata.ToolTip
				};
				break;
			}

			if (listControl is RadioButtonList)
			{
				listControl.Attributes.Add("role", "presentation");
			}

			listControl.Attributes.Add("onchange", "setIsDirty(this.id);");

			container.Controls.Add(listControl);

			PopulateListControl(listControl);

			if (Metadata.IsRequired || Metadata.WebFormForceFieldIsRequired)
			{
				switch (Metadata.ControlStyle)
				{
				case WebFormMetadata.ControlStyle.VerticalRadioButtonList:
				case WebFormMetadata.ControlStyle.HorizontalRadioButtonList:
				case WebFormMetadata.ControlStyle.MultipleChoiceMatrix:
					listControl.Attributes.Add("data-required", "true");
					break;
				default:
					listControl.Attributes.Add("required", string.Empty);
					break;
				}
			}

			if (Metadata.ReadOnly)
			{
				AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(container, listControl);
			}
			else
			{
				Bindings[Metadata.DataFieldName] = new CellBinding
				{
					Get = () =>
					{
						int value;
						return int.TryParse(listControl.SelectedValue, out value) ? new int?(value) : null;
					},
					Set = obj =>
					{
						var value = ((OptionSetValue)obj).Value;
						var lisreplacedem = listControl.Items.FindByValue(value.ToString(CultureInfo.InvariantCulture));
						if (lisreplacedem != null)
						{
							listControl.ClearSelection();
							lisreplacedem.Selected = true;
						}
					}
				};
			}
		}

19 Source : PicklistControlTemplate.cs
with MIT License
from Adoxio

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(Control container, ListControl listControl)
		{
			listControl.CssClreplaced = string.Join(" ", "readonly", listControl.CssClreplaced);

			listControl.Attributes["disabled"] = "disabled";
			listControl.Attributes["aria-disabled"] = "true";

			var hiddenValue = new HiddenField
			{
				ID = "{0}_Value".FormatWith(ControlID),
				Value = listControl.SelectedValue
			};

			container.Controls.Add(hiddenValue);

			var hiddenSelectedIndex = new HiddenField
			{
				ID = "{0}_SelectedIndex".FormatWith(ControlID),
				Value = listControl.SelectedIndex.ToString(CultureInfo.InvariantCulture)
			};

			container.Controls.Add(hiddenSelectedIndex);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					int value;
					return int.TryParse(hiddenValue.Value, out value) ? new int?(value) : null;
				},
				Set = obj =>
				{
					var value = ((OptionSetValue)obj).Value;
					var lisreplacedem = listControl.Items.FindByValue(value.ToString(CultureInfo.InvariantCulture));
					if (lisreplacedem != null)
					{
						listControl.ClearSelection();
						lisreplacedem.Selected = true;
						hiddenValue.Value = lisreplacedem.Value;
						hiddenSelectedIndex.Value = listControl.SelectedIndex.ToString(CultureInfo.InvariantCulture);
					}
				}
			};
		}

19 Source : LookupControlTemplate.cs
with MIT License
from Adoxio

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(Control container, string lookupEnreplacedyName, DropDownList dropDown)
		{
			dropDown.CssClreplaced = "{0} readonly".FormatWith(CssClreplaced);
			dropDown.Attributes["disabled"] = "disabled";
			dropDown.Attributes["aria-disabled"] = "true";


			var hiddenValue = new HiddenField { ID = "{0}_Value".FormatWith(ControlID) };
			container.Controls.Add(hiddenValue);

			var hiddenSelectedIndex = new HiddenField { ID = "{0}_SelectedIndex".FormatWith(ControlID) };
			container.Controls.Add(hiddenSelectedIndex);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					Guid id;
					return !Guid.TryParse(hiddenValue.Value, out id) ? null : new EnreplacedyReference(lookupEnreplacedyName, id);
				},
				Set = obj =>
				{
					var enreplacedyReference = (EnreplacedyReference)obj;
					dropDown.Items.Add(new Lisreplacedem
					{
						Value = enreplacedyReference.Id.ToString(),
						Text = enreplacedyReference.Name ?? string.Empty
					});
					dropDown.SelectedValue = "{0}".FormatWith(enreplacedyReference.Id);
					hiddenValue.Value = dropDown.SelectedValue;
					hiddenSelectedIndex.Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture);
				}
			};
		}

19 Source : SubjectControlTemplate.cs
with MIT License
from Adoxio

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledSelect(Control container, DropDownList dropDown)
		{
			dropDown.CssClreplaced = string.Join(" ", dropDown.CssClreplaced, "readonly");
			dropDown.Attributes["disabled"] = "disabled";
			dropDown.Attributes["aria-disabled"] = "true";

			var hiddenValue = new HiddenField { ID = "{0}_Value".FormatWith(ControlID) };
			container.Controls.Add(hiddenValue);

			var hiddenSelectedIndex = new HiddenField { ID = "{0}_SelectedIndex".FormatWith(ControlID) };
			container.Controls.Add(hiddenSelectedIndex);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					Guid id;
					return !Guid.TryParse(hiddenValue.Value, out id) ? null : new EnreplacedyReference("subject", id);
				},
				Set = obj =>
				{
					var enreplacedyReference = (EnreplacedyReference)obj;
					dropDown.Items.Add(new Lisreplacedem
					{
						Value = enreplacedyReference.Id.ToString(),
						Text = enreplacedyReference.Name ?? string.Empty
					});
					dropDown.SelectedValue = "{0}".FormatWith(enreplacedyReference.Id);
					hiddenValue.Value = dropDown.SelectedValue;
					hiddenSelectedIndex.Value = dropDown.SelectedIndex.ToString(CultureInfo.InvariantCulture);
				}
			};
		}

19 Source : CrmDataSourceView.cs
with MIT License
from Adoxio

private string GetCacheKey(QueryBase query)
		{
			if (_cacheKey == null)
			{
				CacheParameters cacheParameters = Owner.GetCacheParameters();
				_cacheKey = cacheParameters.CacheKey.GetCacheKey(
					Context,
					Owner,
					Owner,
					delegate
					{
						string serializedQuery = Serialize(query);
						ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("QueryByAttribute : {0}", serializedQuery.GetHashCode().ToString(CultureInfo.InvariantCulture)));
						return "Adxstudio:Type={0}:ID={1}:Hash={2}".FormatWith(Owner.GetType().FullName, Owner.ID, serializedQuery.GetHashCode()).ToLower();
					});
			}

			return _cacheKey;
		}

19 Source : FilterOptionGroup.cs
with MIT License
from Adoxio

private static string ToLabel(EnumAttributeMetadata attributeMetadata, Condition condition, int languageCode)
		{
			if (condition == null) return null;
			if (attributeMetadata == null) return null;

			var value = Convert.ToInt32(condition.Value);

			var option = attributeMetadata.OptionSet.Options.FirstOrDefault(o => o.Value == value);

			if (option == null) return value.ToString(CultureInfo.InvariantCulture);

			var localizedLabel = option.Label.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == languageCode);

			return localizedLabel == null
				? option.Label.GetLocalizedLabelString()
				: localizedLabel.Label;
		}

19 Source : LiquidServerControl.cs
with MIT License
from Adoxio

private static void SetPortalName(EnreplacedyForm form, int languageCode)
		{
			var portalName = languageCode.ToString(CultureInfo.InvariantCulture);

			var portals = PortalCrmConfigurationManager.GetPortalCrmSection().Portals;

			if (portals.Count <= 0) return;

			var found = false;

			foreach (var portal in portals)
			{
				var portalContext = portal as PortalContextElement;
				if (portalContext != null && portalContext.Name == portalName)
				{
					found = true;
				}
			}

			if (found)
			{
				form.PortalName = portalName;
			}
		}

19 Source : LiquidServerControl.cs
with MIT License
from Adoxio

private static void SetPortalName(WebForm form, int languageCode)
		{
			var portalName = languageCode.ToString(CultureInfo.InvariantCulture);

			var portals = PortalCrmConfigurationManager.GetPortalCrmSection().Portals;

			if (portals.Count <= 0) return;

			var found = false;

			foreach (var portal in portals)
			{
				var portalContext = portal as PortalContextElement;
				if (portalContext != null && portalContext.Name == portalName)
				{
					found = true;
				}
			}

			if (found)
			{
				form.PortalName = portalName;
			}
		}

19 Source : CrmLanguage.cs
with MIT License
from Adoxio

override protected void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			if (Items.Count > 0)
			{
				return;
			}
			
			var empty = new Lisreplacedem(string.Empty, string.Empty);
			empty.Attributes["label"] = " ";
			Items.Add(empty);

			var context = CrmConfigurationManager.CreateContext(ContextName);
			var request = new RetrieveProvisionedLanguagesRequest();
			var response = (RetrieveProvisionedLanguagesResponse)context.Execute(request);
			var currentCultureInfo = System.Threading.Thread.CurrentThread.CurrentUICulture;

			if (LanguageCode > 0)
			{
				// Set the culture for the specified Language Code so the list of languages is displayed in the appropriate language.
				var tempCultureInfo = new CultureInfo(LanguageCode);
				System.Threading.Thread.CurrentThread.CurrentCulture = tempCultureInfo;
				System.Threading.Thread.CurrentThread.CurrentUICulture = tempCultureInfo;
			}
			foreach (var lcid in response.RetrieveProvisionedLanguages)
			{
				var culture = CultureInfo.GetCultureInfo(lcid);
				Items.Add(new Lisreplacedem(culture.DisplayName, culture.LCID.ToString(CultureInfo.InvariantCulture)));
			}
			if (LanguageCode > 0)
			{
				// Reset the culture back to the original culture.
				System.Threading.Thread.CurrentThread.CurrentCulture = currentCultureInfo;
				System.Threading.Thread.CurrentThread.CurrentUICulture = currentCultureInfo;
			}
			
		}

19 Source : CrmTimeZone.cs
with MIT License
from Adoxio

protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			if (Items.Count > 0)
			{
				return;
			}
			
			var empty = new Lisreplacedem(string.Empty, string.Empty);
			empty.Attributes["label"] = " ";
			Items.Add(empty);

			var context = CrmConfigurationManager.CreateContext(ContextName);

			if (LanguageCode == 0)
			{
				var organization = context.CreateQuery("organization").FirstOrDefault();

				if (organization == null)
				{
                    ADXTrace.Instance.TraceError(TraceCategory.Application, "Failed to retrieve organization.");
                }
				else
				{
					LanguageCode = organization.GetAttributeValue<int?>("languagecode") ?? 0;
				}
			}

			if (LanguageCode == 0)
			{
				LanguageCode = 1033;
			}
			
			var request = new GetAllTimeZonesWithDisplayNameRequest { LocaleId = LanguageCode };
			
			var response = (GetAllTimeZonesWithDisplayNameResponse)context.Execute(request);

			foreach (var timeZoneDefinition in response.EnreplacedyCollection.Enreplacedies.OrderBy(o => o.GetAttributeValue<string>("userinterfacename")))
			{
				Items.Add(new Lisreplacedem(timeZoneDefinition.GetAttributeValue<string>("userinterfacename"), timeZoneDefinition.GetAttributeValue<int>("timezonecode").ToString(CultureInfo.InvariantCulture)));
			}


		}

19 Source : EnhancedTextBox.cs
with MIT License
from Adoxio

override protected void OnPreRender(EventArgs e) 
		{ 
			// Ensure default work takes place
			base.OnPreRender(e);

			// Configure TextArea support
			if ((TextMode == TextBoxMode.MultiLine) && (MaxLength > 0))
			{
				// If we haven't already, include the supporting
				// script that limits the content of textareas.
				foreach (var script in ScriptIncludes)
				{
					var scriptManager = ScriptManager.GetCurrent(Page);

					if (scriptManager == null)
					{
						continue;
					}

					var absolutePath = VirtualPathUtility.ToAbsolute(script);

					scriptManager.Scripts.Add(new ScriptReference(absolutePath));
				}

				// Add an expando attribute to the rendered control which sets  its maximum length (using the MaxLength Attribute)

				/* Where there is a ScriptManager on the parent page, use it to register the attribute -
				 * to ensure the control works in partial updates (like an AJAX UpdatePanel)*/

				var current = ScriptManager.GetCurrent(Page);
				if (current != null && (current.GetRegisteredExpandoAttributes().All(rea => rea.ControlId != ClientID)))
				{
					ScriptManager.RegisterExpandoAttribute(this, ClientID, _maxLengthAttributeName,
						MaxLength.ToString(CultureInfo.InvariantCulture), true);
				}
				else
				{
					try
					{
						Page.ClientScript.RegisterExpandoAttribute(ClientID, _maxLengthAttributeName,
							MaxLength.ToString(CultureInfo.InvariantCulture));
					}
					catch (ArgumentException)
					{
						// This occurs if a script with this key has already been registered. The response should be to do nothing.
					}
				}

				// Now bind the onkeydown, oninput and onpaste events to script to inject in parent page.
				Attributes.Add("onkeydown", "javascript:return LimitInput(this, event);");
				Attributes.Add("oninput",  "javascript:return LimitInput(this, event);");
				Attributes.Add("onpaste",  "javascript:return LimitPaste(this, event);");
			}
		}

19 Source : OrganizationServiceCache.cs
with MIT License
from Adoxio

private string GetCacheKey(object query, string selectorCacheKey)
		{
			var text = InternalGetCacheKey(query) ?? Serialize(query);
			var connection = !string.IsNullOrWhiteSpace(ConnectionId)
				? ":ConnectionId={0}".FormatWith(QueryHashingEnabled ? ConnectionId.GetHashCode().ToString(CultureInfo.InvariantCulture) : ConnectionId)
				: null;
			var code = QueryHashingEnabled ? text.GetHashCode().ToString(CultureInfo.InvariantCulture) : text;
			var selector = !string.IsNullOrEmpty(selectorCacheKey)
				? ":Selector={0}".FormatWith(selectorCacheKey)
				: null;

			return "{0}{1}:Query={2}{3}".FormatWith(
				GetType().FullName,
				connection,
				code,
				selector);
		}

19 Source : CrmDataSourceView.cs
with MIT License
from Adoxio

private string GetCacheKey(QueryBase query)
		{
			if (_cacheKey == null)
			{
				CacheParameters cacheParameters = Owner.GetCacheParameters();
				_cacheKey = cacheParameters.CacheKey.GetCacheKey(
					Context,
					Owner,
					Owner,
					delegate
					{
						string serializedQuery = Serialize(query);
						Tracing.FrameworkInformation("CrmDataSourceView", "GetCacheKey: QueryByAttribute", serializedQuery.GetHashCode().ToString(CultureInfo.InvariantCulture));
						return "Adxstudio:Type={0}:ID={1}:Hash={2}".FormatWith(Owner.GetType().FullName, Owner.ID, serializedQuery.GetHashCode());
					});
			}

			return _cacheKey;
		}

19 Source : WebFormPayment.ascx.cs
with MIT License
from Adoxio

private Dictionary<string, string> GetPaypalArgs(decimal total, string accountEmail, bool itemizedData, string currencyCode, bool aggregateData, bool sendPaypalAddress, bool addressOverride)
		{
			if (Purchasable == null)
			{
				throw new InvalidOperationException("Unable to retrieve the purchase information.");
			}

			var args = new Dictionary<string, string>
			{
				{ "cmd", "_cart" },
				{ "upload", "1" },
				{ "business", accountEmail },
				{ "no_note", "1" },
				{ "invoice", Purchasable.Quote.Id.ToString() },
				{ "email", accountEmail }
			};

			if (addressOverride)
			{
				args.Add("address_override", "1");
				args.Add("first_name", Contact.GetAttributeValue<string>("firstname"));
				args.Add("last_name", Contact.GetAttributeValue<string>("lastname"));
				args.Add("address1", ShippingAddress);
				args.Add("city", ShippingCity);
				args.Add("state", ShippingProvince);
				args.Add("zip", ShippingPostalCode);
				args.Add("country", ShippingCountry);
			}

			if (!string.IsNullOrEmpty(currencyCode))
			{
				args.Add("currency_code", currencyCode);
			}

			if (aggregateData)
			{
				args.Add("item_name", "Aggregated Items");
				args.Add("amount", total.ToString("#.00"));
			}
			// Paypal Item Data for itemized data.
			else if (itemizedData)
			{
				var counter = 0;
				decimal itemDiscountsTotal = 0;

				foreach (var item in Purchasable.Items)
				{
					if (!item.IsSelected || item.Quanreplacedy < 0)
					{
						continue;
					}

					counter++;

					args.Add(string.Format("item_name_{0}", counter), item.Name);
					args.Add(string.Format("amount_{0}", counter), (item.PricePerUnit).ToString("#.00"));
					args.Add(string.Format("quanreplacedy_{0}", counter), Convert.ToInt32(item.Quanreplacedy).ToString(CultureInfo.InvariantCulture));
					args.Add(string.Format("discount_amount_{0}", counter), (item.TotalDiscountAmount).ToString("#.00"));
					itemDiscountsTotal = itemDiscountsTotal + item.TotalDiscountAmount;
					args.Add(string.Format("item_number_{0}", counter), item.QuoteProduct.Id.ToString());
				}

				if (Purchasable.ShippingAmount > 0)
				{
					args.Add("shipping", Purchasable.ShippingAmount.ToString("#.00"));
				}

				if (Purchasable.TotalTax > 0)
				{
					args.Add("tax_cart", Purchasable.TotalTax.ToString("#.00"));
				}

				if (Purchasable.TotalPreShippingAmount < Purchasable.TotalLineItemAmount)
				{
					// This variable overrides any individual item discount_amount_x values, if present therefore we must include the computed item discounts in the total.
					args.Add("discount_amount_cart", (Purchasable.TotalLineItemAmount - Purchasable.TotalPreShippingAmount + itemDiscountsTotal).ToString("#.00"));
				}
			}
			
			var cancelUrl = new UrlBuilder(Request.Url.PathAndQuery);

			cancelUrl.QueryString.Set("PayPal", "Cancel");

			var returnUrl = new UrlBuilder(Request.Url.PathAndQuery);

			returnUrl.QueryString.Set("sessionid", WebForm.CurrentSessionHistory.Id.ToString());
			returnUrl.QueryString.Set("quoteid", Purchasable.Quote.Id.ToString());
			
			var handlerPath = Url.RouteUrl("PaymentHandler", new
			{
				ReturnUrl = returnUrl.PathWithQueryString,
				area = "_services"
			});

			var baseUrl = GetBaseUrl();

			var successUrl = !string.IsNullOrWhiteSpace(baseUrl)
				? ((Request.IsSecureConnection) ? Uri.UriSchemeHttps : Uri.UriSchemeHttp) + Uri.SchemeDelimiter + baseUrl +
				  handlerPath
				: ((Request.IsSecureConnection) ? Uri.UriSchemeHttps : Uri.UriSchemeHttp) + Uri.SchemeDelimiter +
				  Request.Url.Authority + handlerPath;
			
			var cancelReturnUrl = !string.IsNullOrWhiteSpace(baseUrl)
				? ((Request.IsSecureConnection) ? Uri.UriSchemeHttps : Uri.UriSchemeHttp) + Uri.SchemeDelimiter + baseUrl + cancelUrl.PathWithQueryString
				: ((Request.IsSecureConnection) ? Uri.UriSchemeHttps : Uri.UriSchemeHttp) + Uri.SchemeDelimiter + Request.Url.Authority + cancelUrl.PathWithQueryString;
			
			args.Add("return", successUrl);
			args.Add("cancel_return", cancelReturnUrl);

			return args;
		}

19 Source : EntityGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult Delete(EnreplacedyReference enreplacedyReference)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var serviceContext = dataAdapterDependencies.GetServiceContext();
			var enreplacedyPermissionProvider = new CrmEnreplacedyPermissionProvider();

			if (!enreplacedyPermissionProvider.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			var enreplacedyMetadata = serviceContext.GetEnreplacedyMetadata(enreplacedyReference.LogicalName, EnreplacedyFilters.All);
			var primaryKeyName = enreplacedyMetadata.PrimaryIdAttribute;
			var enreplacedy =
				serviceContext.CreateQuery(enreplacedyReference.LogicalName)
					.First(e => e.GetAttributeValue<Guid>(primaryKeyName) == enreplacedyReference.Id);
			var test = enreplacedyPermissionProvider.Tryreplacedert(serviceContext, CrmEnreplacedyPermissionRight.Delete, enreplacedy);

			if (test)
			{
				using (PerformanceProfiler.Instance.StartMarker(PerformanceMarkerName.EnreplacedyGridController, PerformanceMarkerArea.Crm, PerformanceMarkerTagName.Delete))
				{
					serviceContext.DeleteObject(enreplacedy);
					serviceContext.SaveChanges();
				}
			}
			else
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("No_Permissions_To_Delete_This_Record"));
			}

			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : EntityGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult replacedociate(replacedociateRequest request)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var serviceContext = dataAdapterDependencies.GetServiceContext();
			var enreplacedyPermissionProvider = new CrmEnreplacedyPermissionProvider();

			if (!enreplacedyPermissionProvider.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			var relatedEnreplacedies = request.RelatedEnreplacedies
				.Where(e => enreplacedyPermissionProvider.Tryreplacedertreplacedociation(serviceContext, request.Target, request.Relationship, e))
				.ToArray();

			if (!relatedEnreplacedies.Any())
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Missing_Permissions_For_Operation_Exception"));
			}

			relatedEnreplacedies = FilterAlreadyreplacedociated(serviceContext, request.Relationship, request.Target, relatedEnreplacedies);

			var filtered = new replacedociateRequest
			{
				Target = request.Target,
				Relationship = request.Relationship,
				RelatedEnreplacedies = new EnreplacedyReferenceCollection(relatedEnreplacedies)
			};

			serviceContext.Execute(filtered);
			
			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : SharePointGridController.cs
with MIT License
from Adoxio

[AcceptVerbs(HttpVerbs.Post)]
		[AjaxValidateAntiForgeryToken]
		public ActionResult GetSharePointData(EnreplacedyReference regarding, string sortExpression, int page, int pageSize = DefaultPageSize, string pagingInfo = null, string folderPath = null)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new SharePointDataAdapter(dataAdapterDependencies);
			var data = dataAdapter.GetFoldersAndFiles(regarding, sortExpression, page, pageSize, pagingInfo, folderPath);

			var json = Json(new
			{
				data.SharePoinreplacedems,
				PageSize = pageSize,
				PageNumber = page,
				data.PagingInfo,
				data.TotalCount,
				data.AccessDenied
			});
			return json;
		}

19 Source : SharePointGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult AddSharePointFiles(string regardingEnreplacedyLogicalName, string regardingEnreplacedyId, IList<HttpPostedFileBase> files, bool overwrite, string folderPath = null)
		{
			Guid regardingId;
			Guid.TryParse(regardingEnreplacedyId, out regardingId);
			var regarding = new EnreplacedyReference(regardingEnreplacedyLogicalName, regardingId);
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new SharePointDataAdapter(dataAdapterDependencies);
			var result = dataAdapter.AddFiles(regarding, files, overwrite, folderPath);

			if (!result.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			if (!result.CanCreate)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "create SharePoint files"));
			}

			if (!result.CanAppendTo)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "append to record"));
			}

			if (!result.CanAppend)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "append SharePoint files"));
			}

			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : SharePointGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult DeleteSharePoinreplacedem(EnreplacedyReference regarding, string id)
		{
			int itemId;
			int.TryParse(id, out itemId);
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new SharePointDataAdapter(dataAdapterDependencies);

			var result = dataAdapter.DeleteItem(regarding, itemId);

			if (!result.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			if (!result.CanDelete)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "delete this record"));
			}

			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : EntityGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult ExecuteWorkflow(EnreplacedyReference workflow, EnreplacedyReference enreplacedy)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var serviceContext = dataAdapterDependencies.GetServiceContext();

			var request = new ExecuteWorkflowRequest
			{
				WorkflowId = workflow.Id,
				EnreplacedyId = enreplacedy.Id
			};

			serviceContext.Execute(request);

			serviceContext.TryRemoveFromCache(enreplacedy);

			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : EntityNotesController.cs
with MIT License
from Adoxio

[AcceptVerbs(HttpVerbs.Post)]
        [AjaxValidateAntiForgeryToken]
		public ActionResult GetNotes(EnreplacedyReference regarding, List<Order> orders, int page, int pageSize = DefaultPageSize)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
			var enreplacedyMetadata = portalContext.ServiceContext.GetEnreplacedyMetadata(regarding.LogicalName, EnreplacedyFilters.All);
			var result = dataAdapter.GetAnnotations(regarding, orders, page, pageSize, enreplacedyMetadata: enreplacedyMetadata);
			var totalRecordCount = result.TotalCount;
			var enreplacedyPermissionProvider = new CrmEnreplacedyPermissionProvider();
			var crmLcid = HttpContext.GetCrmLcid();
			var records = result.Select(r => new NoteRecord(r, dataAdapterDependencies, enreplacedyPermissionProvider, enreplacedyMetadata, true, crmLcid));
			var data = new PaginatedGridData(records, totalRecordCount, page, pageSize);

			return new JsonResult { Data = data, MaxJsonLength = int.MaxValue };
		}

19 Source : EntityNotesController.cs
with MIT License
from Adoxio

[HttpPost]
		[AjaxFormStatusResponse]
		[ValidateAntiForgeryToken]
		public ActionResult UpdateNote(string id, string text, string subject, bool isPrivate = false, HttpPostedFileBase file = null, string attachmentSettings = null)
		{
			if (string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(StringHelper.StripHtml(text)))
			{
				return new HttpStatusCodeResult(HttpStatusCode.ExpectationFailed, ResourceManager.GetString("Required_Field_Error").FormatWith(ResourceManager.GetString("Note_DefaultText")));
			}
			Guid annotationId;
			Guid.TryParse(id, out annotationId);
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
			var settings = GetAnnotationSettings(dataAdapterDependencies.GetServiceContext(), attachmentSettings);

			var annotation = dataAdapter.GetAnnotation(annotationId);

			annotation.AnnotationId = annotationId;

			annotation.NoteText = string.Format("{0}{1}", AnnotationHelper.WebAnnotationPrefix, text);

			if (!isPrivate && !string.IsNullOrWhiteSpace(subject) && subject.Contains(AnnotationHelper.PrivateAnnotationPrefix))
			{
				annotation.Subject = subject.Replace(AnnotationHelper.PrivateAnnotationPrefix, string.Empty);
			}

			if (isPrivate && !string.IsNullOrWhiteSpace(subject) && !subject.Contains(AnnotationHelper.PrivateAnnotationPrefix))
			{
				annotation.Subject = subject + AnnotationHelper.PrivateAnnotationPrefix;
			}

			if (file != null && file.ContentLength > 0)
			{
				annotation.FileAttachment = AnnotationDataAdapter.CreateFileAttachment(file, settings.StorageLocation);
			}

			try
			{
				var result = dataAdapter.UpdateAnnotation(annotation, settings);

				if (!result.PermissionsExist)
				{
					return new HttpStatusCodeResult(HttpStatusCode.Forbidden,
						ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
				}

				if (!result.PermissionGranted)
				{
					return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "update notes"));
				}

				return new HttpStatusCodeResult(HttpStatusCode.OK);
			}
			catch (AnnotationException ex)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ex.Message);
			}
		}

19 Source : Form.aspx.cs
with MIT License
from Adoxio

protected void Page_Init(object sender, EventArgs e)
		{
			IsLookupCreateForm = !string.IsNullOrEmpty(Request.QueryString["lookup"]);

			var languageCodeSetting = HttpContext.Current.Request["languagecode"];

			if (string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				return;
			}

			int languageCode;
			
			if (!int.TryParse(languageCodeSetting, out languageCode))
			{
				return;
			}

			EnreplacedyFormControl.LanguageCode = languageCode;

			var portalName = languageCode.ToString(CultureInfo.InvariantCulture);

			var portals = PortalCrmConfigurationManager.GetPortalCrmSection().Portals;
			
			if (portals.Count <= 0) return;

			var found = false;
			
			foreach (var portal in portals)
			{
				var portalContext = portal as PortalContextElement;
				if (portalContext != null && portalContext.Name == portalName)
				{
					found = true;
				}
			}

			if (found)
			{
				EnreplacedyFormControl.PortalName = portalName;
			}
		}

19 Source : QuickForm.aspx.cs
with MIT License
from Adoxio

protected void Page_Load(object sender, EventArgs e)
		{
			Guid enreplacedyId;
			var enreplacedyIdValue = HttpContext.Current.Request["enreplacedyid"];
			var enreplacedyName = HttpContext.Current.Request["enreplacedyname"];
			var enreplacedyPrimaryKeyName = HttpContext.Current.Request["enreplacedyprimarykeyname"];
			var formName = HttpContext.Current.Request["formname"];
			var controlId = HttpUtility.HtmlEncode(HttpContext.Current.Request["controlid"]);
			int languageCode;
			
			if (!Guid.TryParse(enreplacedyIdValue, out enreplacedyId) || string.IsNullOrWhiteSpace(enreplacedyName) ||
				string.IsNullOrWhiteSpace(formName) || string.IsNullOrWhiteSpace(controlId)) return;

			if (string.IsNullOrWhiteSpace(enreplacedyPrimaryKeyName))
			{
				enreplacedyPrimaryKeyName = MetadataHelper.GetEnreplacedyPrimaryKeyAttributeLogicalName(ServiceContext, enreplacedyName);
			}

			if (string.IsNullOrWhiteSpace(enreplacedyPrimaryKeyName)) return;

			var fetch = new Fetch
			{
				MappingType = MappingType.Logical,
				Enreplacedy = new FetchEnreplacedy(enreplacedyName)
				{
					Attributes = FetchAttribute.All,
					Filters = new List<Filter>
					{
						new Filter
						{
							Type = LogicalOperator.And,
							Conditions = new List<Condition> { new Condition(enreplacedyPrimaryKeyName, ConditionOperator.Equal, enreplacedyId) }
						}
					}
				}
			};

			var dataSource = new CrmDataSource
			{
				ID = string.Format("{0}_datasource", controlId),
				FetchXml = fetch.ToFetchExpression().Query,
				IsSingleSource = true
			};

			var formView = new CrmEnreplacedyFormView
			{
				ID = controlId,
				CssClreplaced = "crmEnreplacedyFormView",
				DataSourceID = dataSource.ID,
				DataBindOnPostBack = true,
				EnreplacedyName = enreplacedyName,
				FormName = formName,
				Mode = FormViewMode.ReadOnly,
				ClientIDMode = ClientIDMode.Static,
				IsQuickForm = true,
			};

			var languageCodeSetting = HttpContext.Current.Request["languagecode"];

			if (!string.IsNullOrWhiteSpace(languageCodeSetting) && int.TryParse(languageCodeSetting, out languageCode))
			{
				var found = false;
				var portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				var portals = Microsoft.Xrm.Portal.Configuration.PortalCrmConfigurationManager.GetPortalCrmSection().Portals;

				formView.LanguageCode = languageCode;

				if (portals.Count > 0)
				{
					foreach (var portal in portals)
					{
						var portalContext = portal as PortalContextElement;
						if (portalContext != null && portalContext.Name == portalName)
						{
							found = true;
						}
					}

					if (found)
					{
						formView.ContextName = portalName;
						dataSource.CrmDataContextName = portalName;
					}
				}
			}
			
			FormPanel.Controls.Add(dataSource);
			FormPanel.Controls.Add(formView);
		}

19 Source : ProductCollection.aspx.cs
with MIT License
from Adoxio

protected string GetRatingFilterUrl(int rating)
		{
			var urlBuilder = new UrlBuilder(Request.Url.PathAndQuery);

			urlBuilder.QueryString.Set("rating", rating.ToString(CultureInfo.InvariantCulture));
			urlBuilder.QueryString.Remove("page");

			return urlBuilder.PathWithQueryString;
		}

19 Source : PermitApplicationDetails.aspx.cs
with MIT License
from Adoxio

protected void Page_Load(object sender, EventArgs e)
		{
			var reference = Enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_enreplacedyform");

			var enreplacedyFormRecord = XrmContext.CreateQuery("adx_enreplacedyform").FirstOrDefault(ef => ef.GetAttributeValue<Guid>("adx_enreplacedyformid") == reference.Id);

			if (enreplacedyFormRecord != null)
			{
				var recordEnreplacedyLogicalName = enreplacedyFormRecord.GetAttributeValue<string>("adx_enreplacedyname");

				Guid recordId;

				if (Guid.TryParse(Request["id"], out recordId))
				{

					var metadataRequest = new RetrieveEnreplacedyRequest
					{
						LogicalName = recordEnreplacedyLogicalName,
						EnreplacedyFilters = EnreplacedyFilters.Attributes
					};

					var metadataResponse = (RetrieveEnreplacedyResponse)XrmContext.Execute(metadataRequest);

					var primaryFieldLogicalName = metadataResponse.EnreplacedyMetadata.PrimaryIdAttribute;

					var permitRecord = XrmContext.CreateQuery(recordEnreplacedyLogicalName).FirstOrDefault(r => r.GetAttributeValue<Guid>(primaryFieldLogicalName) == recordId);

					var permitTypeReference = permitRecord.GetAttributeValue<EnreplacedyReference>("adx_permittype");

					var permitType =
						XrmContext.CreateQuery("adx_permittype").FirstOrDefault(
							srt => srt.GetAttributeValue<Guid>("adx_permittypeid") == permitTypeReference.Id);

					var enreplacedyName = permitType.GetAttributeValue<string>("adx_enreplacedyname");

					RegardingContactFieldName = permitType.GetAttributeValue<string>("adx_regardingcontactfieldname");

					var trueMetadataRequest = new RetrieveEnreplacedyRequest
					{
						LogicalName = enreplacedyName,
						EnreplacedyFilters = EnreplacedyFilters.Attributes
					};

					var trueMetadataResponse = (RetrieveEnreplacedyResponse)XrmContext.Execute(trueMetadataRequest);

					var primaryFieldName = trueMetadataResponse.EnreplacedyMetadata.PrimaryIdAttribute;

					var enreplacedyId = permitRecord.GetAttributeValue<string>("adx_enreplacedyid");

					var trueRecordId = Guid.Parse(enreplacedyId);

					var trueRecord = XrmContext.CreateQuery(enreplacedyName).FirstOrDefault(r => r.GetAttributeValue<Guid>(primaryFieldName) == trueRecordId);

					Permit = trueRecord;

					var permitDataSource = CreateDataSource("PermitDataSource", enreplacedyName, primaryFieldName, trueRecordId);

					var permitFormView = new CrmEnreplacedyFormView() { FormName = "Details Form", Mode = FormViewMode.Edit, EnreplacedyName = enreplacedyName, CssClreplaced = "crmEnreplacedyFormView", AutoGenerateSteps = false };

					var languageCodeSetting = OrganizationServiceContextExtensions.GetSiteSettingValueByName(ServiceContext, Portal.Website, "Language Code");
					if (!string.IsNullOrWhiteSpace(languageCodeSetting))
					{
						int languageCode;
						if (int.TryParse(languageCodeSetting, out languageCode))
						{
							permitFormView.LanguageCode = languageCode;
							permitFormView.ContextName = languageCode.ToString(CultureInfo.InvariantCulture);
							permitDataSource.CrmDataContextName = languageCode.ToString(CultureInfo.InvariantCulture);
						}
					}

					CrmEnreplacedyFormViewPanel.Controls.Add(permitFormView);

					permitFormView.DataSourceID = permitDataSource.ID;

					var regardingContact = Permit.GetAttributeValue<EnreplacedyReference>(RegardingContactFieldName);

					if (regardingContact == null || Contact == null || regardingContact.Id != Contact.Id)
					{
						PermitControls.Enabled = false;
						PermitControls.Visible = false;
						AddNoteInline.Visible = false;
						AddNoteInline.Enabled = false;
					}
					else
					{
						var dataAdapterDependencies =
							new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: PortalName);
						var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
						var annotations = dataAdapter.GetAnnotations(Permit.ToEnreplacedyReference(),
							new List<Order> { new Order("createdon") }, respectPermissions: false);

						NotesList.DataSource = annotations;
						NotesList.DataBind();
					}
				}
			}
		}

19 Source : EntityGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult Disreplacedociate(DisreplacedociateRequest request)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var serviceContext = dataAdapterDependencies.GetServiceContext();
			var enreplacedyPermissionProvider = new CrmEnreplacedyPermissionProvider();

			if (!enreplacedyPermissionProvider.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			var relatedEnreplacedies =
				request.RelatedEnreplacedies.Where(
					related => enreplacedyPermissionProvider.Tryreplacedertreplacedociation(serviceContext, request.Target, request.Relationship, related)).ToList();

			if (relatedEnreplacedies.Any())
			{
				var filtered = new DisreplacedociateRequest { Target = request.Target, Relationship = request.Relationship, RelatedEnreplacedies = new EnreplacedyReferenceCollection(relatedEnreplacedies) };

				serviceContext.Execute(filtered);
			}
			else
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Missing_Permissions_For_Operation_Exception"));
			}

			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : EntityNotesController.cs
with MIT License
from Adoxio

[HttpPost]
		[AjaxFormStatusResponse]
		[ValidateAntiForgeryToken]
		public ActionResult AddNote(string regardingEnreplacedyLogicalName, string regardingEnreplacedyId, string text, bool isPrivate = false, HttpPostedFileBase file = null, string attachmentSettings = null)
		{
			if (string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(StringHelper.StripHtml(text)))
			{
				return new HttpStatusCodeResult(HttpStatusCode.ExpectationFailed, ResourceManager.GetString("Required_Field_Error").FormatWith(ResourceManager.GetString("Note_DefaultText")));
			}

			Guid regardingId;
			Guid.TryParse(regardingEnreplacedyId, out regardingId);
			var regarding = new EnreplacedyReference(regardingEnreplacedyLogicalName, regardingId);
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var serviceContext = dataAdapterDependencies.GetServiceContext();
			var user = Request.GetOwinContext().GetUser();

			var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
			var settings = GetAnnotationSettings(serviceContext, attachmentSettings);

			var annotation = new Annotation
			{
				NoteText = string.Format("{0}{1}", AnnotationHelper.WebAnnotationPrefix, text),
				Subject = AnnotationHelper.BuildNoteSubject(serviceContext, user.ContactId, isPrivate),
				Regarding = regarding
			};
			if (file != null && file.ContentLength > 0)
			{
				annotation.FileAttachment = AnnotationDataAdapter.CreateFileAttachment(file, settings.StorageLocation);
			}

			var result = (AnnotationCreateResult)dataAdapter.CreateAnnotation(annotation, settings);
			
			if (!result.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			if (!result.CanCreate)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "create notes"));
			}

			if (!result.CanAppendTo)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "append to record"));
			}

			if (!result.CanAppend)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "append notes"));
			}

			return new HttpStatusCodeResult(HttpStatusCode.Created);
		}

19 Source : EntityNotesController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult DeleteNote(string id)
		{
			Guid annotationId;
			Guid.TryParse(id, out annotationId);
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
			var annotation = dataAdapter.GetAnnotation(annotationId);

			var result = dataAdapter.DeleteAnnotation(annotation, new AnnotationSettings(dataAdapterDependencies.GetServiceContext(), true));
			
			if (!result.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			if (!result.PermissionGranted)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "delete this record"));
			}
			
			return new HttpStatusCodeResult(HttpStatusCode.OK);
		}

19 Source : SharePointGridController.cs
with MIT License
from Adoxio

[HttpPost]
		[JsonHandlerError]
		[AjaxValidateAntiForgeryToken]
		public ActionResult AddSharePointFolder(EnreplacedyReference regarding, string name, string folderPath = null)
		{
			string portalName = null;
			var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
			var languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

			if (!string.IsNullOrWhiteSpace(languageCodeSetting))
			{
				int languageCode;
				if (int.TryParse(languageCodeSetting, out languageCode))
				{
					portalName = languageCode.ToString(CultureInfo.InvariantCulture);
				}
			}

			var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
			var dataAdapter = new SharePointDataAdapter(dataAdapterDependencies);
			var result = dataAdapter.AddFolder(regarding, name, folderPath);

			if (!result.PermissionsExist)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Enreplacedy_Permissions_Have_Not_Been_Defined_Message"));
			}

			if (!result.CanCreate)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "create SharePoint files"));
			}

			if (!result.CanAppendTo)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "append to record"));
			}

			if (!result.CanAppend)
			{
				return new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Enreplacedy_Permissions"), "append SharePoint files"));
			}

			return new HttpStatusCodeResult(HttpStatusCode.NoContent);
		}

19 Source : ServiceRequestDetails.aspx.cs
with MIT License
from Adoxio

private void RenderCrmEnreplacedyFormView(string enreplacedyName, string primaryFieldName, Enreplacedy serviceRequestType, Guid trueRecordId, FormViewMode formMode)
		{
			var serviceRequestDataSource = CreateDataSource("SeriveRequestDataSource", enreplacedyName, primaryFieldName, trueRecordId);

			Enreplacedy enreplacedyForm = null;

			enreplacedyForm = (serviceRequestType.GetAttributeValue<EnreplacedyReference>("adx_enreplacedyformid") != null)
				? XrmContext.CreateQuery("adx_enreplacedyform").FirstOrDefault(e => e.GetAttributeValue<Guid>("adx_enreplacedyformid") ==
				serviceRequestType.GetAttributeValue<EnreplacedyReference>("adx_enreplacedyformid").Id) :
				XrmContext.CreateQuery("adx_enreplacedyform").FirstOrDefault(ef => ef.GetAttributeValue<string>("adx_name")
				== "Web Service Request Details" && ef.GetAttributeValue<string>("adx_enreplacedyname") == enreplacedyName);

			if (enreplacedyForm != null)
			{
				var formRecordSourceDefinition = new FormEnreplacedySourceDefinition(enreplacedyName, primaryFieldName, trueRecordId);

				var enreplacedyFormControl = new EnreplacedyForm(enreplacedyForm.ToEnreplacedyReference(), formRecordSourceDefinition)
										{
											ID = "CustomEnreplacedyFormControl",
											FormCssClreplaced = "crmEnreplacedyFormView",
											PreviousButtonCssClreplaced = "btn btn-default",
											NextButtonCssClreplaced = "btn btn-primary",
											SubmitButtonCssClreplaced = "btn btn-primary",
											ClientIDMode = ClientIDMode.Static/*,
											EnreplacedyFormReference	= enreplacedyForm.ToEnreplacedyReference(),
											EnreplacedySourceDefinition = formRecordSourceDefinition*/
										};

				var languageCodeSetting = ServiceContext.GetSiteSettingValueByName(Portal.Website, "Language Code");
				if (!string.IsNullOrWhiteSpace(languageCodeSetting))
				{
					int languageCode;
					if (int.TryParse(languageCodeSetting, out languageCode)) enreplacedyFormControl.LanguageCode = languageCode;
					
				}

				CrmEnreplacedyFormViewPanel.Controls.Add(enreplacedyFormControl);
			}
			else
			{
				var mappingFieldCollection = new MappingFieldMetadataCollection()
				{
					FormattedLocationFieldName = serviceRequestType.GetAttributeValue<string>("adx_locationfieldname"),
					LareplacedudeFieldName = serviceRequestType.GetAttributeValue<string>("adx_lareplacedudefieldname"),
					LongitudeFieldName = serviceRequestType.GetAttributeValue<string>("adx_longitudefieldname")
				};

				var serviceRequestFormView = new CrmEnreplacedyFormView()
				{
					FormName = "Web Details",
					Mode = formMode,
					EnreplacedyName = enreplacedyName,
					CssClreplaced = "crmEnreplacedyFormView",
					SubmitButtonCssClreplaced = "btn btn-primary",
					AutoGenerateSteps = false,
					ClientIDMode = ClientIDMode.Static,
					MappingFieldCollection = mappingFieldCollection
				};

				var languageCodeSetting = ServiceContext.GetSiteSettingValueByName(Portal.Website, "Language Code");
				if (!string.IsNullOrWhiteSpace(languageCodeSetting))
				{
					int languageCode;
					if (int.TryParse(languageCodeSetting, out languageCode))
					{
						serviceRequestFormView.LanguageCode = languageCode;
						serviceRequestFormView.ContextName = languageCode.ToString(CultureInfo.InvariantCulture);
						serviceRequestDataSource.CrmDataContextName = languageCode.ToString(CultureInfo.InvariantCulture);
					}
				}

				CrmEnreplacedyFormViewPanel.Controls.Add(serviceRequestFormView);

				serviceRequestFormView.DataSourceID = serviceRequestDataSource.ID;
			}

		}

19 Source : ServiceRequestsMap.aspx.cs
with MIT License
from Adoxio

public void CreateServiceRequestPriorityList()
		{
			// Create the Service Request Priority List Items

			var retrieveOptionSetRequest = new RetrieveOptionSetRequest { Name = "adx_servicerequestpriority" };

			var retrieveOptionSetResponse = (RetrieveOptionSetResponse)ServiceContext.Execute(retrieveOptionSetRequest);

			if (retrieveOptionSetResponse == null)
			{
				throw new ApplicationException("Error retrieving adx_servicerequestpriority OptionSet");
			}
			
			var retrievedOptionSetMetadata = (OptionSetMetadata)retrieveOptionSetResponse.OptionSetMetadata;

			var priorityOptions = retrievedOptionSetMetadata.Options;

			if (priorityOptions == null)
			{
				throw new ApplicationException("Error retrieving adx_servicerequestpriority OptionSetMetadata");
			}

			var priorityLisreplacedems = priorityOptions.Select(o => new SearchLisreplacedem { Id = o.Value.GetValueOrDefault().ToString(CultureInfo.InvariantCulture), Name = o.Label.GetLocalizedLabelString() }).ToList();

			var defaultPriorityLisreplacedems = new List<SearchLisreplacedem> { new SearchLisreplacedem { Id = "0", Name = "Any" } };

			ServiceRequestPriorityList.DataSource = defaultPriorityLisreplacedems.Union(priorityLisreplacedems);

			ServiceRequestPriorityList.DataBind();
		}

19 Source : ServiceRequestsMap.aspx.cs
with MIT License
from Adoxio

public void CreateServiceRequestStatusList()
		{
			// Create the Service Request Status List Items

			var retrieveOptionSetRequest = new RetrieveOptionSetRequest { Name = "adx_servicestatus" };

			var retrieveOptionSetResponse = (RetrieveOptionSetResponse)ServiceContext.Execute(retrieveOptionSetRequest);

			if (retrieveOptionSetResponse == null)
			{
				throw new ApplicationException("Error retrieving adx_servicestatus OptionSet");
			}

			var retrievedOptionSetMetadata = (OptionSetMetadata)retrieveOptionSetResponse.OptionSetMetadata;

			var status = retrievedOptionSetMetadata.Options;

			if (status == null)
			{
				throw new ApplicationException("Error retrieving adx_servicestatus OptionSetMetadata");
			}

			var statusLisreplacedems = status.Select(o => new SearchLisreplacedem { Id = o.Value.GetValueOrDefault().ToString(CultureInfo.InvariantCulture), Name = o.Label.GetLocalizedLabelString() }).ToList();

			var defaultStatusLisreplacedems = new List<SearchLisreplacedem> { new SearchLisreplacedem { Id = "0", Name = "Any" } };

			ServiceRequestStatusList.DataSource = defaultStatusLisreplacedems.Union(statusLisreplacedems);

			ServiceRequestStatusList.DataBind();
		}

19 Source : ContentLocator.cs
with Apache License 2.0
from advanced-cms

private IEnumerable<PageData> FindPagesByPageTypeRecursively(PageReference pageLink, int pageTypeId)
        {
            var criteria = new PropertyCriteriaCollection
                                {
                                    new PropertyCriteria
                                    {
                                        Name = "PageTypeID",
                                        Type = PropertyDataType.PageType,
                                        Condition = CompareCondition.Equal,
                                        Value = pageTypeId.ToString(CultureInfo.InvariantCulture)
                                    }
                                };

            // Include content providers serving content beneath the page link specified for the search
            if (_providerManager.ProviderMap.CustomProvidersExist)
            {
                var contentProvider = _providerManager.ProviderMap.GetProvider(pageLink);

                if (contentProvider.HasCapability(ContentProviderCapabilities.Search))
                {
                    criteria.Add(new PropertyCriteria
                    {
                        Name = "EPI:MultipleSearch",
                        Value = contentProvider.ProviderKey
                    });
                }
            }

            return _pageCriteriaQueryService.FindPagesWithCriteria(pageLink, criteria);
        }

19 Source : MeshBoundingBoxTree.cs
with The Unlicense
from aeroson

public override string ToString()
            {
                return LeafIndex.ToString(CultureInfo.InvariantCulture);
            }

19 Source : PlatformManager.cs
with GNU General Public License v3.0
from affederaffe

private async Task LoadPlatformsAsync()
        {
            Stopwatch sw = Stopwatch.StartNew();
            CancellationToken cancellationToken = _cancellationTokenSource.Token;

            if (File.Exists(_cacheFilePath))
            {
                foreach (CustomPlatform platform in EnumeratePlatformDescriptorsFromFile())
                    AllPlatforms.AddSorted(1, AllPlatforms.Count - 1, platform);
            }

            // Load all remaining platforms, or all if no cache file is found
            foreach (string path in Directory.EnumerateFiles(DirectoryPath, "*.plat").Where(x => AllPlatforms.All(y => y.fullPath != x)))
            {
                if (cancellationToken.IsCancellationRequested) return;
                CustomPlatform? platform = await CreatePlatformAsync(path);
                if (platform is null) continue;
                AllPlatforms.AddSorted(1, AllPlatforms.Count - 1, platform);
            }

            sw.Stop();
            _siraLog.Info($"Loaded {AllPlatforms.Count.ToString(NumberFormatInfo.InvariantInfo)} platforms in {sw.ElapsedMilliseconds.ToString(NumberFormatInfo.InvariantInfo)}ms");
        }

19 Source : StringHelper.cs
with Mozilla Public License 2.0
from agebullhu

public static string ToFixLenString(this int d, int len)
        {
            var s = d.ToString(CultureInfo.InvariantCulture);
            var sb = new StringBuilder();
            var l = len - s.Length;
            if (l > 0)
                sb.Append(' ', l);
            sb.Append(s);
            return sb.ToString();
        }

See More Examples