/// <summary> /// Initializes inner controls to its default state. /// </summary> private void InitializeControls() { chkPostAfterDocumentPublish.Checked = false; string content = String.Empty; if (!String.IsNullOrWhiteSpace(mDefaultValue)) { // Default content given as control's string Value content = mDefaultValue; } else if ((FieldInfo != null) && !String.IsNullOrWhiteSpace(FieldInfo.DefaultValue)) { // Default content from field info content = FieldInfo.DefaultValue; } txtPost.Text = content; txtPost.MaxLength = (int)LinkedInHelper.COMPANY_SHARE_COMMENT_MAX_LENGTH; if (!chkPostAfterDocumentPublish.Checked) { publishDateTime.Value = DateTime.Now; } companySelector.ObjectSiteName = SiteIdentifier; LinkedInAccountInfo defaultAccountInfo = LinkedInAccountInfoProvider.GetDefaultLinkedInAccount(SiteIdentifier); if (defaultAccountInfo != null) { companySelector.Value = defaultAccountInfo.LinkedInAccountID; } ClearPostState(); urlShortenerSelector.SiteID = SiteIdentifier; urlShortenerSelector.Value = URLShortenerHelper.GetDefaultURLShortenerForSocialNetwork(SocialNetworkTypeEnum.LinkedIn, SiteIdentifier); chkPostAfterDocumentPublish.Visible = (Document != null); campaingSelector.Value = null; campaingSelector.ObjectSiteName = SiteIdentifier; if ((FieldInfo != null) && !FieldInfo.AllowEmpty) { // Post must be created because field doesn't allow an empty value chkPostToLinkedIn.Enabled = false; DisplayForm = true; } }
/// <summary> /// OnBeforeDataLoad event - Ensures default account is pre-selected. /// </summary> private void Control_OnBeforeDataLoad(object sender, EventArgs e) { var post = Control.EditedObject as LinkedInPostInfo; if (post == null) { return; } // if the post is newly created fill in default page if (post.LinkedInPostID == 0) { LinkedInAccountInfo defaultAccountInfo = LinkedInAccountInfoProvider.GetDefaultLinkedInAccount(Control.ObjectSiteID); if (defaultAccountInfo != null) { post.LinkedInPostLinkedInAccountID = defaultAccountInfo.LinkedInAccountID; } } }
/// <summary> /// Creates an object that represents information required by this page to display LinkedIn insights, and returns it. /// </summary> /// <param name="accountId">The LinkedIn account identifier.</param> /// <returns>An object that represents information required by this page to display LinkedIn insights.</returns> private PageContext GetPageContextForLinkedIn(int accountId) { LinkedInAccountInfo account = LinkedInAccountInfoProvider.GetLinkedInAccountInfo(accountId); if (account == null || account.LinkedInAccountSiteID != SiteContext.CurrentSiteID) { throw new Exception("[CMSModules_SocialMarketing_Pages_InsightsMenu.GetPageContextForLinkedIn]: LinkedIn account with the specified identifier does not exist."); } if (!account.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { RedirectToAccessDenied(ModuleName.SOCIALMARKETING, PermissionsEnum.Read.ToString()); } return(new PageContext { ExternalId = account.LinkedInAccountProfileID, ReportNamePrefix = "LinkedIn.", ReportNameFormat = "LinkedIn.{0}.{1}.{2}report", DisplayNameResourceNameFormat = "sm.ins.linkedin.{0}" }); }