/// <summary> /// Handles the ItemDataBound event for the repeater control responsible for rendering /// a relationship's profile data on the page. /// </summary> /// <remarks> /// The default profile for a relationship is intentionally hidden. /// </remarks> /// <param name="source">Repeater</param> /// <param name="e">Repeater arguments</param> protected void HandleProfileListItemDataBound(object source, RepeaterItemEventArgs e) { try { Profile profile = e.Item.DataItem as Profile; if (profile != null) { ProfilePresentationServices profileServices = new ProfilePresentationServices(profile); if (profileServices.DisplayProfile) { // Render the link to access profile details. HtmlAnchor linkProfileName = e.Item.FindControl("linkProfileName") as HtmlAnchor; if (linkProfileName != null) { string profileLinkHRef = ""; if (profile.Parent.RemoteSite.Address.Contains("|")) { profileLinkHRef = string.Format(CloudProfileUrlFormat, ProfileViewAction, profile.Id); } else { profileLinkHRef = string.Format(ProfileUrlFormat, ProfileViewAction, profile.Id); } linkProfileName.HRef = profileLinkHRef; linkProfileName.InnerText = profile.Name; string itemsList = string.Empty; if (profile.SynchronizeDatabase) { itemsList = itemsList + "Database, "; } if (profile.SynchronizeTemplates) { itemsList = itemsList + "Templates, "; } if (profile.SynchronizeWorkarea) { itemsList = itemsList + "Workarea, "; } if (profile.SynchronizeBinaries) { itemsList = itemsList + "Bin, "; } if (itemsList.Length > 0) { itemsList = itemsList.Substring(0, itemsList.Length - 2); } PopulateTextControl(e.Item.FindControl("litCurrentStatus"), _siteApi.EkMsgRef.GetMessage("txt quickdeploy idle")); string a = e.Item.FindControl("litCurrentStatus").ToString(); // Get Current Status of Profiles if (IsSyncRunning(Convert.ToInt64(profile.Id))) { PopulateTextControl(e.Item.FindControl("litCurrentStatus"), _siteApi.EkMsgRef.GetMessage("lbl running")); } linkProfileName.Title = String.Format(_siteApi.EkMsgRef.GetMessage("lbl Direction")+" {0}. "+_siteApi.EkMsgRef.GetMessage("lbl Including Items")+ " {1}", profile.Direction.ToString(), itemsList); } PopulateTextControl( e.Item.FindControl("litProfileId"), profile.Id.ToString()); // Populate the schedule and run time fields. PopulateTextControl( e.Item.FindControl("litSchedule"), GetResourceText(PresentationHelper.GetScheduleIntervalString(profile.Schedule.Recurrence))); // Don't display the next run time when nothing has been // scheduled. if (profile.Schedule.Recurrence != ScheduleInterval.None) { PopulateTextControl( e.Item.FindControl("litNextRunTime"), _siteApi.EkMsgRef.GetMessage("lbl Next Sync Time")+" " + FormatDateTime(profile.Schedule.NextRunTime)); } if (profile.LastRunResult != SyncResult.None) { if (profile.LastRunResult == SyncResult.Success) { PopulateTextControl( e.Item.FindControl("litLastRunResult"), _siteApi.EkMsgRef.GetMessage("generic succsess")); } else { EwsExceptionParser exceptionParser = new EwsExceptionParser(); PopulateTextControl( e.Item.FindControl("litLastRunResult"), exceptionParser.Translate(profile.LastRunMessage, SyncHandlerAction.GetStatus)); } } // Don't display the last run time if the profile // has not yet been executed. if (profile.LastFullSync > DateTime.MinValue) { PopulateTextControl( e.Item.FindControl("litLastRunTime"), FormatDateTime(profile.LastFullSync)); } // Render the action buttons for the profile. HtmlGenericControl divProfileButtons = e.Item.FindControl("divProfileButtons") as HtmlGenericControl; if (divProfileButtons != null) { // Add 'Sync' button. if (profileServices.AllowSync) { HtmlAnchor linkSyncButton = new HtmlAnchor(); linkSyncButton.HRef = "#"; linkSyncButton.Title = _siteApi.EkMsgRef.GetMessage("generic Sync"); linkSyncButton.Attributes.Add(AttributeClass, "syncButton"); linkSyncButton.Attributes.Add(AttributeRel, profile.Id.ToString()); linkSyncButton.Attributes.Add(AttributeOnClick, "Ektron.Workarea.Sync.Relationships.Synchronize(this, true);"); divProfileButtons.Controls.Add(linkSyncButton); } // Add 'Get Status' button. if (profileServices.AllowStatusRetrieval) { HtmlAnchor linkStatusButton = new HtmlAnchor(); linkStatusButton.HRef = "#"; linkStatusButton.Title = _siteApi.EkMsgRef.GetMessage("lbl Get Status"); linkStatusButton.Attributes.Add(AttributeClass, "statusButton"); linkStatusButton.Attributes.Add(AttributeRel, profile.Id.ToString()); linkStatusButton.Attributes.Add(AttributeOnClick, "Ektron.Workarea.Sync.Relationships.ShowSyncStatus(this);"); divProfileButtons.Controls.Add(linkStatusButton); } // Add 'Sync Preview' button. if (profileServices.AllowSyncPreview) { HtmlAnchor linkPreviewButton = new HtmlAnchor(); linkPreviewButton.HRef = "SyncPreview.aspx?id=" + profile.Id.ToString(); linkPreviewButton.Title = _siteApi.EkMsgRef.GetMessage("btn preview status"); linkPreviewButton.Attributes.Add(AttributeClass, "previewButton"); linkPreviewButton.Attributes.Add(AttributeRel, profile.Id.ToString()); divProfileButtons.Controls.Add(linkPreviewButton); } // Add 'Pause/Resume' button. if (profileServices.AllowToggleSchedule && _siteApi.IsARoleMember(EkEnumeration.CmsRoleIds.SyncAdmin)) { HtmlAnchor linkToggleScheduleButton = new HtmlAnchor(); linkToggleScheduleButton.HRef = "#"; linkToggleScheduleButton.Title = _siteApi.EkMsgRef.GetMessage("lbl PauseResume"); linkToggleScheduleButton.Attributes.Add(AttributeRel, profile.Id.ToString()); linkToggleScheduleButton.Attributes.Add(AttributeOnClick, "Ektron.Workarea.Sync.Relationships.ToggleScheduleStatus(this);"); // Display the appropriate button (play/pause) according // to the current status of the profile. if (profile.Status == ProfileStatus.Active) { linkToggleScheduleButton.Attributes.Add(AttributeClass, "toggleScheduleButton pause"); } else { linkToggleScheduleButton.Attributes.Add(AttributeClass, "toggleScheduleButton resume"); } divProfileButtons.Controls.Add(linkToggleScheduleButton); } // Add 'Delete' button. if (profileServices.AllowDelete && _siteApi.IsARoleMember(EkEnumeration.CmsRoleIds.SyncAdmin)) { HtmlAnchor linkDeleteButton = new HtmlAnchor(); linkDeleteButton.HRef = "#"; linkDeleteButton.Title = _siteApi.EkMsgRef.GetMessage("generic delete title"); linkDeleteButton.Attributes.Add(AttributeClass, "deleteButton"); linkDeleteButton.Attributes.Add(AttributeRel, profile.Id.ToString()); linkDeleteButton.Attributes.Add(AttributeOnClick, "Ektron.Workarea.Sync.Relationships.DeleteProfile(this);"); divProfileButtons.Controls.Add(linkDeleteButton); } } } else { // Do not render the default profile or deleted // profile entries. e.Item.Visible = false; } } } catch (EndpointNotFoundException) { Utilities.ShowError(SiteAPI.Current.EkMsgRef.GetMessage("windows service not running")); } }
/// <summary> /// Binds this page's profile data to the UI. /// </summary> public void Bind() { if (Data != null) { RenderHeader(Data); if (!IsPostBack) { ProfilePresentationServices _presentationServices = new ProfilePresentationServices(Data); txtLocalSite.Enabled = false; txtRemoteSite.Enabled = false; txtMultiSiteFolder.Enabled = false; txtScheduleName.Text = Data.Name; txtLocalSite.Text = Data.Parent.LocalSite.Connection.DatabaseName; txtRemoteSite.Text = Data.Parent.RemoteSite.Connection.DatabaseName; tbSQLServer.Text = Data.Parent.RemoteSite.ConnectionString; string[] azureData = Data.Parent.RemoteSite.Address.Split('|'); tbAccountName.Text = azureData[1]; tbContainerName.Text = azureData[0]; tbAccountKey.Text = azureData[2]; if (Data.Parent.MultiSite.IsMultiSite) { trMultiSiteRow.Visible = true; txtMultiSiteFolder.Text = Data.Parent.MultiSite.FolderId.ToString(); } else { trMultiSiteRow.Visible = false; } // Determine if database sync is allowed, if so // display option and populate according to the // current profile. Otherwise, hide and deselect. if (_presentationServices.AllowDatabaseSync) { chkDatabase.Checked = Data.SynchronizeDatabase; chkDatabase.Visible = true; cbScope.Visible = true; // Populate Scope list if (Data.SynchronizeDatabase) { if (Data.Scope != null && Data.Scope.Count > 0) { foreach (SyncDBScope scope in Data.Scope) { cbScope.Items.FindByValue(scope.ToString()).Selected = true; } } else { cbScope.Items.FindByValue("ektron").Selected = true; } // Show Tables lists in a tool tip if (this.ScopeConfigs != null) { bool showCustomScope = false; foreach (ScopeConfiguration scopeConfig in this.ScopeConfigs) { try { cbScope.Items.FindByValue(scopeConfig.Name).Attributes["class"] = "addtooltip"; StringBuilder tableListSB = new StringBuilder(); if (scopeConfig.Tables != null && scopeConfig.Tables.Count > 0) { foreach (string tablename in scopeConfig.Tables) { tableListSB.Append(tablename + ", "); } } if (tableListSB.Length == 0) { tableListSB.Append("Table list not currently available for this scope."); } ListItem lbItem = cbScope.Items.FindByValue(scopeConfig.Name); lbItem.Attributes["title"] = String.Format("Tables currently defined in scope : {0} | {1}", lbItem.Text , tableListSB.ToString()); } catch { } if (scopeConfig.Name == "custom" ) { showCustomScope = true; } } // If there are no custom tables don't show the custom scope if (!showCustomScope) { cbScope.Items.Remove(cbScope.Items.FindByValue("custom")); } } } // Package sync should be disabled until it // is completely implemented. chkPackage.Visible = false; } else { chkDatabase.Checked = false; chkDatabase.Visible = false; chkPackage.Visible = false; cbScope.Visible = false; } chkWorkarea.Checked = Data.SynchronizeWorkarea; chkTemplates.Checked = Data.SynchronizeTemplates; chkBinaries.Checked = Data.SynchronizeBinaries; rdoConflictResolution.SelectedValue = Data.ConflictResolution.ToString(); rdoDirection.SelectedValue = Data.Direction.ToString(); rdoFilters.SelectedValue = Data.Filters.Type.ToString(); if (Data.Filters.Files != null) { foreach (string fileFilter in Data.Filters.Files) { if (txtFileFilters.Text.Length > 0) { txtFileFilters.Text += ", "; } txtFileFilters.Text += fileFilter; } } if (Data.Filters.Directories != null) { foreach (string directoryFilter in Data.Filters.Directories) { if (txtDirectoryFilters.Text.Length > 0) { txtDirectoryFilters.Text += ", "; } txtDirectoryFilters.Text += directoryFilter; } } chkRestoration.Checked = Data.AllowRestoration; chkRestoration.Enabled = false; ssScheduleOptions.Interval = Data.Schedule.Recurrence; ssScheduleOptions.StartTime = Data.Schedule.StartTime; if (PackageContent != null) { PopulateTree(); } StripeRows(); } } }
/// <summary> /// Binds this page's profile data to the UI. /// </summary> public void Bind() { if (Data != null) { RenderHeader(Data); ProfilePresentationServices _presentationServices = new ProfilePresentationServices(Data); if (_presentationServices.AllowDatabaseSync) { chkDatabase.Visible = true; cbScope.Visible = true; } else { chkDatabase.Checked = false; chkDatabase.Visible = false; cbScope.Visible = false; } if (!IsPostBack) { txtLocalSite.Enabled = false; txtRemoteSite.Enabled = false; txtMultiSiteFolder.Enabled = false; txtScheduleName.Text = Data.Name; txtLocalSite.Text = Data.Parent.LocalSite.Connection.DatabaseName; txtRemoteSite.Text = Data.Parent.RemoteSite.Connection.DatabaseName; if (Data.Parent.MultiSite.IsMultiSite) { trMultiSiteRow.Visible = true; txtMultiSiteFolder.Text = Data.Parent.MultiSite.FolderId.ToString(); } else { trMultiSiteRow.Visible = false; } // Determine if database sync is allowed, if so // display option and populate according to the // current profile. Otherwise, hide and deselect. if (_presentationServices.AllowDatabaseSync) { chkDatabase.Checked = Data.SynchronizeDatabase; // Populate Scope list if (Data.SynchronizeDatabase) { if (Data.Scope != null && Data.Scope.Count > 0) { foreach (SyncDBScope scope in Data.Scope) { cbScope.Items.FindByValue(scope.ToString()).Selected = true; } } else { cbScope.Items.FindByValue("ektron").Selected = true; } } } chkWorkarea.Checked = Data.SynchronizeWorkarea; chkTemplates.Checked = Data.SynchronizeTemplates; chkBinaries.Checked = Data.SynchronizeBinaries; if (Data.ConflictResolution.ToString() != "ApplicationDefined") { rdoConflictResolution.SelectedValue = Data.ConflictResolution.ToString(); } rdoDirection.SelectedValue = Data.Direction.ToString(); rdoFilters.SelectedValue = Data.Filters.Type.ToString(); if (Data.Filters.Files != null) { foreach (string fileFilter in Data.Filters.Files) { if (txtFileFilters.Text.Length > 0) { txtFileFilters.Text += ", "; } txtFileFilters.Text += fileFilter; } } if (Data.Filters.Directories != null) { foreach (string directoryFilter in Data.Filters.Directories) { if (txtDirectoryFilters.Text.Length > 0) { txtDirectoryFilters.Text += ", "; } txtDirectoryFilters.Text += directoryFilter; } } chkRestoration.Checked = Data.AllowRestoration; chkRestoration.Enabled = false; ssScheduleOptions.Interval = Data.Schedule.Recurrence; ssScheduleOptions.StartTime = Data.Schedule.StartTime; StripeRows(); } // Show Tables lists in a tool tip if (this.ScopeConfigs != null) { bool showCustomScope = false; foreach (ScopeConfiguration scopeConfig in this.ScopeConfigs) { try { cbScope.Items.FindByValue(scopeConfig.Name).Attributes["class"] = "addtooltip"; StringBuilder tableListSB = new StringBuilder(); if (scopeConfig.Tables != null && scopeConfig.Tables.Count > 0) { foreach (string tablename in scopeConfig.Tables) { tableListSB.Append(tablename + ", "); } } if (tableListSB.Length == 0) { tableListSB.Append(_siteApi.EkMsgRef.GetMessage("lbl table empty")); } ListItem lbItem = cbScope.Items.FindByValue(scopeConfig.Name); //lbItem.Attributes["title"] = tableListSB.ToString(); lbItem.Attributes["title"] = String.Format(_siteApi.EkMsgRef.GetMessage("lbl Tables currently") + " {0} | {1}", lbItem.Text, tableListSB.ToString()); } catch { } if (scopeConfig.Name == "custom") { showCustomScope = true; } } // If there are no custom tables don't show the custom scope if (!showCustomScope) { cbScope.Items.Remove(cbScope.Items.FindByValue("custom")); } } } }