/// <summary> /// Loads options for combo box from SharePoint. /// Fills the options directly in the combo box. /// </summary> private void LoadListsFromSharePoint() { drpSharePointLists.DropDownList.Items.Clear(); int connectionID = SharePointConnectionID; var connectionInfo = SharePointConnectionInfoProvider.GetSharePointConnectionInfo(connectionID); if (connectionInfo == null) { return; } DataSet lists = null; try { ISharePointListService service = SharePointServices.GetService <ISharePointListService>(connectionInfo.ToSharePointConnectionData()); lists = service.GetLists(SharePointListType); } catch (Exception ex) { mShowConnectionWarning = true; EventLogProvider.LogWarning("SharePoint", "GETSHAREPOINTLISTS", ex, SiteContext.CurrentSiteID, String.Empty); } DataHelper.ForEachRow(lists, AddOptionToComboBoxFromRow); }
/// <summary> /// OnAfterSave event. /// </summary> private void ControlOnAfterSave(object sender, EventArgs eventArgs) { TwitterPostInfo twitterPost = Control.EditedObject as TwitterPostInfo; if (twitterPost == null) { return; } if (!twitterPost.TwitterPostPostAfterDocumentPublish) { try { TwitterPostInfoProvider.PublishTwitterPost(twitterPost.TwitterPostID); } catch (Exception ex) { EventLogProvider.LogWarning("Social marketing - Twitter post", "PUBLISHPOST", ex, SiteContext.CurrentSiteID, String.Format("An error occurred while publishing the Twitter post with ID {0}.", twitterPost.TwitterPostID)); Control.ShowError(Control.GetString("sm.twitter.posts.msg.unknownerror")); } } // Invoke event to set the form's state properly ControlOnAfterDataLoad(sender, eventArgs); }
protected virtual IOptimizerResult LogResult(IOptimizerResult result, string name, string extension, int imageWidth, int imageHeight, long ms) { if (result.Success) { if (result.SizeAfter < result.SizeBefore) { EventLogProvider.LogInformation("Dianoga.Kentico", "IMAGE_OPTIMIZED", String.Format("Dianoga: optimized '{0}{1}' [{2}x{3}] (final size: {4} bytes) - saved {5} bytes / {6:p}. Optimized in {7}ms.", name, extension, imageWidth, imageHeight, result.SizeAfter, result.SizeBefore - result.SizeAfter, 1 - ((result.SizeAfter / (float)result.SizeBefore)), ms)); } else { EventLogProvider.LogInformation("Dianoga.Kentico", "IMAGE_OPTIMIZED", String.Format("Dianoga: '{0}{1}' already optimized", name, extension)); } return(result); } EventLogProvider.LogWarning("Dianoga.Kentico", "IMAGE_OPT_ERR", new Exception(String.Format("Dianoga: unable to optimize {0} because {1}", name, result.ErrorMessage)), SiteContext.CurrentSiteID, "Dianoga Error"); return(null); }
/// <summary> /// OnAction for LinkedIn post object type. /// </summary> private void OnAction_LinkedIn(string actionName, object actionArgument) { switch (actionName) { case "delete": try { int postId = ValidationHelper.GetInteger(actionArgument, 0); var postInfo = LinkedInPostInfoProvider.GetLinkedInPostInfo(postId); if (VerifyPermissionsAndObjectAvailability(postInfo)) { LinkedInPostInfoProvider.DeleteLinkedInPostInfo(postInfo); } Control.ShowConfirmation(Control.GetString("sm.linkedin.posts.msg.completedelete")); } catch (LinkedInPartialDeleteException) { Control.ShowWarning(Control.GetString("sm.linkedin.posts.msg.partialdelete")); } catch (Exception ex) { EventLogProvider.LogWarning("Social marketing - LinkedIn post", "DELETEPOST", ex, SiteContext.CurrentSiteID, "LinkedIn post could not be deleted."); Control.ShowError(Control.GetString("sm.linkedin.posts.msg.deleteerror")); } break; } }
private void PopulateErrors(IEnumerable <MailingAddressDto> badAddresses) { var errorsDictionary = CustomTableItemProvider .GetItems("KDA.AddressErrors") .ToDictionary(i => i["ErrorCode"].ToString(), i => i["ErrorDescription"].ToString()); var missingCodes = new HashSet <string>(); foreach (var address in badAddresses) { string errorDescription; if (errorsDictionary.TryGetValue(address.ErrorMessage, out errorDescription)) { address.ErrorMessage = errorDescription; } else { if (!missingCodes.Contains(address.ErrorMessage)) { missingCodes.Add(address.ErrorMessage); } } } if (missingCodes.Any()) { var exc = new KeyNotFoundException($"The error description is not found for following key(s): {string.Join(", ", missingCodes)}"); EventLogProvider.LogWarning("Mailing Addresses Load", "WARNING", exc, CurrentSite.SiteID, string.Empty); } }
// TODO Finish implementing Resolve // TODO Add caching // /// <inheritdoc /> public IRichTextData Resolve(string richText, UnknownWidgetBehaviour unknownWidgetBehaviour = UnknownWidgetBehaviour.WriteErrorInline) { var rt = new RichTextData(); var lastStartIndex = 0; var match = Regex.Match(richText, WIDGET_REGEX); while (match.Success) { var widgetText = match.Groups[1].Value; var widgetObj = ParseWidgetText(widgetText); // Get any text prior to the widget var rawHtml = richText.Substring(lastStartIndex, richText.IndexOf(match.Value, StringComparison.Ordinal) - lastStartIndex); rt.Add(new RichTextHtml(rawHtml)); var codename = widgetObj.Property("name").Value.ToString(); var type = WidgetRegistry.GetWidgetType(codename); if (!unknownWidgetBehaviour.HasFlag(UnknownWidgetBehaviour.Ignore)) { if (unknownWidgetBehaviour.HasFlag(UnknownWidgetBehaviour.WriteErrorInline) && type == null) { rt.Add(new RichTextHtml( $"<div style=\"border: 1px solid #f00; padding: 5px; margin: 5px; background: #fff; color: #f00\"><p>Widget of type '{codename}' is not a valid and registered MVC widget.</p></div>")); } if (unknownWidgetBehaviour.HasFlag(UnknownWidgetBehaviour.WriteErrorToLog) && type == null) { EventLogProvider.LogWarning("RichTextResolver::Resolve", "UNKNOWN_WIDGET", null, SiteContext.CurrentSiteID, $"Widget of type '{codename}' is not a valid and registered MVC widget."); } if (unknownWidgetBehaviour.HasFlag(UnknownWidgetBehaviour.ThrowException) && type == null) { throw new Exception($"Widget of type '{codename}' is not a valid and registered MVC widget."); } } if (type != null) { rt.Add(WidgetResolver.Resolve(widgetObj, type)); } lastStartIndex = lastStartIndex + rawHtml.Length + match.Value.Length; match = match.NextMatch(); } var lastRawHtml = richText.Substring(lastStartIndex); rt.Add(new RichTextHtml(lastRawHtml)); return(rt); }
/// <summary> /// Publishes Twitter post with given identifier. /// </summary> /// <param name="postId">Twitter post identifier.</param> private void PublishPost(int postId) { try { TwitterPostInfoProvider.TryCancelScheduledPublishTwitterPost(postId); TwitterPostInfoProvider.PublishTwitterPost(postId); } catch (Exception ex) { EventLogProvider.LogWarning("Social marketing - Twitter post", "PUBLISHPOST", ex, SiteContext.CurrentSiteID, String.Format("An error occurred while publishing the Twitter post with ID {0}.", postId)); } }
private void UpdateLastWriteTime(string fileName, string origFileName, FileInfo fi) { try { if (fileName == origFileName) { fi.LastWriteTime = FileInfo.FileModifiedWhen; } } catch (IOExceptions.IOException exception) { EventLogProvider.LogWarning("Media File Edit", "UPDATEFILE", exception, CurrentSite.SiteID, "Cannot update the 'Modified' time stamp, because the file is currently being used by another process."); ShowWarning(ResHelper.GetString("mediafile.cantupdatelockedfile")); } }
/// <summary> /// OnAction for Twitter post object type. /// </summary> /// <param name="actionName"></param> /// <param name="actionArgument">Integer ID as a string.</param> private void OnAction_Twitter(string actionName, object actionArgument) { switch (actionName) { case "delete": try { TwitterPostInfoProvider.DeleteTwitterPostInfo(ValidationHelper.GetInteger(actionArgument, 0)); } catch (Exception ex) { EventLogProvider.LogWarning("Social marketing - Twitter post", "DELETEPOST", ex, SiteContext.CurrentSiteID, "Twitter post could not be deleted."); Control.ShowError(Control.GetString("sm.twitter.posts.msg.deleteerror")); } break; } }
// Retrieves data to be displayed in the selector protected override IEnumerable <SelectListItem> GetItems() { // Perform data retrieval operations here // The following example retrieves all pages of the 'DancingGoatMvc.Article' page type // located under the 'Articles' section of the Dancing Goat sample website return(CacheHelper.Cache <IEnumerable <SelectListItem> >(cs => { if (cs.Cached) { cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.pagebuildercontainer|all", "cms.pagebuildercontainersite|all" }); } try { var Containers = PageBuilderContainerInfoProvider.GetPageBuilderContainers() .WhereIn("PageBuilderContainerID", PageBuilderContainerSiteInfoProvider.GetPageBuilderContainerSites().WhereEquals("SiteID", SiteContext.CurrentSiteID).Select(x => x.PageBuilderContainerID).ToArray()) .OrderBy("ContainerDisplayName") .Select(x => new SelectListItem() { Value = x.ContainerName, Text = x.ContainerDisplayName } ).ToList(); Containers.Insert(0, new SelectListItem() { Value = "", Text = "(No Container)" }); return Containers; } catch (Exception ex) { // Module not installed EventLogProvider.LogWarning("PageBuilderContainer", "PageBuilderContainer Module Missing", ex, SiteContext.CurrentSite != null ? SiteContext.CurrentSite.SiteID : 0, additionalMessage: "Could not get Page Builder Containers, make sure you have installed the PageBuilderContainers.Kentico nuget package on your admin kentico instance."); return new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "(No Container)" } }; } }, new CacheSettings(1440, "GetContainerSelectors", SiteContext.CurrentSiteID))); }
public static string GetResizedSrcSet(this HtmlHelper htmlHelper, string mediaUrl, IEnumerable <int> widths = null) { if (string.IsNullOrWhiteSpace(mediaUrl)) { EventLogProvider.LogWarning("HtmlHelperExtensions", "RENDERIMAGE", new ArgumentNullException(nameof(mediaUrl), "Empty media URL"), SiteContext.CurrentSiteID, String.Empty); return(mediaUrl); } if (widths == null) { widths = new[] { 320, 360, 640, 720, 960, 1280, 1440 }; } var result = new StringBuilder(); try { var absoluteMediaUrl = URLHelper.GetAbsoluteUrl(mediaUrl); var uri = new UriBuilder(absoluteMediaUrl); var query = HttpUtility.ParseQueryString(uri.Query); query.Remove("height"); foreach (var width in widths) { query["width"] = width.ToString(); uri.Query = query.ToString(); result.AppendFormat("{0} {1}w,", uri.Uri.PathAndQuery, width); } result.Length--; return(result.ToString()); } catch (Exception exception) { EventLogProvider.LogException("HtmlHelperExtensions", "RENDERIMAGE", exception); return(mediaUrl); } }
//Returns bool value for Username and Password Validation private bool validateUserNamePassword(string Username, string Password) { bool flag = false; try { if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)) { flag = false; } else { var x = _wsSso.SSOCustomerAuthenticate( _personifySsoVendorName, _personifySsoVendorPassword, Username, Password); if (x != null) { if (x.Result == false) { flag = false; EventLogProvider.LogWarning("Login", "Login", new Exception(x.Errors.Join(" | ")), SiteContext.CurrentSiteID, Username); } else { flag = true; } } } } catch (Exception ex) { //log exception into eventlog EventLogProvider.LogException(ex.Source, ex.Message, ex); flag = false; } return(flag); }
/// <summary> /// OnAction for Facebook post object type. /// </summary> private void OnAction_Facebook(string actionName, object actionArgument) { switch (actionName) { case "delete": try { int postId = ValidationHelper.GetInteger(actionArgument, 0); var postInfo = FacebookPostInfoProvider.GetFacebookPostInfo(postId); if (VerifyPermissionsAndObjectAvailability(postInfo)) { FacebookPostInfoProvider.DeleteFacebookPostInfo(postInfo); } } catch (Exception ex) { EventLogProvider.LogWarning("Social marketing - Facebook post", "DELETEPOST", ex, SiteContext.CurrentSiteID, "Facebook post could not be deleted."); Control.ShowError(Control.GetString("sm.facebook.posts.msg.deleteerror")); } break; } }