public void Invoke(object sender, object element) { //first check permissions if (!ProfileContext.Current.CheckPermission("profile:roles:mng:delete")) { //permissions not present, deny throw new UnauthorizedAccessException("Current user does not have enough rights to access the requested operation."); } if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; int error = 0; string errorMessage = String.Empty; try { string[] items = null; if (cp.CommandArguments.ContainsKey(EcfListView.GridCommandParameterName) && Boolean.Parse(cp.CommandArguments[EcfListView.GridCommandParameterName])) { // process command from grid (delete only one item) string primaryKeyId = cp.CommandArguments["primaryKeyId"]; items = new string[] { primaryKeyId }; } else { // get checked items and process batch delete command (from toolbar) string gridId = cp.CommandArguments["GridId"]; items = EcfListView.GetCheckedCollection(((Control)sender).Page, gridId); ManagementHelper.SetBindGridFlag(gridId); } if (items != null) { ProcessDeleteCommand(items); } } catch (Exception ex) { error++; errorMessage = ex.Message; } if (error > 0) { errorMessage = errorMessage.Replace("'", "\\'").Replace(Environment.NewLine, "\\n"); ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("alert('{0}{1}');", "Failed to delete item(s). Error: ", errorMessage), true); } } }
/// <summary> /// Processes the language command. /// </summary> /// <param name="items">The items.</param> void ProcessLanguageCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int folderId = Int32.Parse(keys[0]); PopulateLanguagesRecursive(folderId); } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("VersionId"); DataTable dtPV; dtPV = PageVersion.GetWorkVersionByUserId(Page.User.Identity.Name); if (dtPV != null && dtPV.Rows.Count > 0) { DataView dv = dtPV.DefaultView; //APPLY FILTER int DefaultWorkflowId = -1; using (IDataReader reader = Mediachase.Cms.Workflow.LoadDefault()) { if (reader.Read()) { DefaultWorkflowId = (int)reader["WorkflowId"]; } reader.Close(); } int PublishId = WorkflowStatus.GetLastByWorkflowId(DefaultWorkflowId); int DraftId = WorkflowStatus.DraftId; string filter = Parameters["filter"]; if (!String.IsNullOrEmpty(filter)) { if (filter.Equals("draft")) { dv.RowFilter = String.Format("StateId = 1 AND StatusId = {0}", DraftId); } else if (filter.Equals("approve")) { dv.RowFilter = String.Format("StateId = 1 AND StatusId NOT IN (-1, {0}, {1})", PublishId, DraftId); } else if (filter.Equals("reject")) { dv.RowFilter = String.Format("StateId = 2 AND StatusId NOT IN (-1, {0})", PublishId); } } else { dv.RowFilter = String.Format("StateId = 1 AND StatusId NOT IN (-1, {0}, {1})", PublishId, DraftId);; } //END:APPLY FILTER dv.Sort = sortExpression; MyListView.DataSource = dv; } MyListView.DataBind(); }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int id = Int32.Parse(keys[0]); DeleteEntryRecursive(id, 0); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack || String.Compare(Request.Form["__EVENTTARGET"], CommandManager.GetCurrent(this.Page).ID, false) == 0) { if (!IsPostBack) { MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("ProviderUserKey"); } InitDataSource(_StartRowIndex, GetMaximumRows(), true, String.Empty); DataBind(); } }
void ProcessApproveCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int versionId = Int32.Parse(keys[0]); using (IDataReader reader = PageVersion.GetVersionById(versionId)) { if (reader.Read()) { int templateId = (int)reader["TemplateId"]; int statusId = (int)reader["StatusId"]; int stateId = (int)reader["StateId"]; int langId = (int)reader["LangId"]; int newStatus = WorkflowAccess.GetNextStatusId(statusId); if (newStatus > 0) { PageVersion.UpdatePageVersion(versionId, templateId, langId, statusId, newStatus, ProfileContext.Current.UserId, 1, ""); } //PageVersion.UpdatePageVersion(CMSContext.Current.VersionId, templateId, langId, statusId, WorkflowAccess.GetMaxStatus(Roles.GetRolesForUser(), WorkflowStatus.GetLast(statusId)), (Guid)Membership.GetUser(Page.User.Identity.Name).ProviderUserKey, 1, string.Empty); // if we publish version if (newStatus == WorkflowStatus.GetLast(statusId)) { //find old publishd and put to archive using (IDataReader reader2 = PageVersion.GetVersionByStatusId((int)reader["PageId"], newStatus)) { while (reader2.Read()) { if ((int)reader2["LangId"] == langId) { if (versionId != (int)reader2["VersionId"]) { PageVersion.UpdatePageVersion((int)reader2["VersionId"], (int)reader2["TemplateId"], (int)reader2["LangId"], (int)reader2["StatusId"], WorkflowStatus.GetArcStatus((int)reader2["StatusId"]), ProfileContext.Current.UserId, 2, "sent to archieve"); } } } reader2.Close(); } } } reader.Close(); } } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { ExpressionDto dto = ExpressionManager.GetExpressionDto(ExpressionCategory); if (dto.Expression != null) { DataView view = dto.Expression.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("ExpressionId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { WarehouseDto dto = WarehouseManager.GetWarehouseDto(); if (dto.Warehouse != null) { DataView view = dto.Warehouse.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("WarehouseId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { CatalogTaxDto dto = CatalogTaxManager.GetTaxCategories(); if (dto.TaxCategory != null) { DataView view = dto.TaxCategory.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("TaxCategoryId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { CountryDto dto = CountryManager.GetCountries(true); if (dto.Country != null) { DataView view = dto.Country.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("CountryId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { ShippingMethodDto dto = ShippingManager.GetShippingPackages(); if (dto.Package != null) { DataView view = dto.Package.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("PackageId"); MyListView.DataBind(); }
void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int id = Int32.Parse(keys[0]); // delete selected sites NavigationManager.DeleteCommand(id); } } }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { string id = keys[0]; // delete selected sites ProfileContext.Current.DeleteAccount(id); } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { int totalRecords = 0; DataTable table = GetDataSource(out totalRecords); DataView view = table.DefaultView; view.Sort = sortExpression; MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("ID", "Type", "OutlineNumber"); MyListView.DataSource = view; MyListView.DataBind(); m_TotalRecords = totalRecords; //MyListView.Grid.RecordCount = totalRecords; }
void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int versionId = Int32.Parse(keys[0]); // delete selected version PageVersion.DeletePageVersion(versionId); } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { CampaignDto dto = CampaignManager.GetCampaignDto(); if (dto.Campaign != null) { DataView view = dto.Campaign.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("CampaignId"); MyListView.DataBind(); }
void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int id = Int32.Parse(keys[0]); // delete selected sites Mediachase.Cms.Workflow.DeleteWorkflow(id); } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { TemplateDto templates = DictionaryManager.GetTemplateDto(0); DataView templateView = templates.main_Templates.DefaultView; templateView.Sort = sortExpression; templateView.RowFilter = String.Format("LanguageCode LIKE '{0}'", LanguageCode); MyListView.DataSource = templateView; MyListView.CurrentListView.SetSortProperties(sortExpression); MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("TemplateId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { SegmentDto dto = SegmentManager.GetSegmentDto(); if (dto.Segment != null) { DataView view = dto.Segment.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("SegmentId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { ShippingMethodDto dto = ShippingManager.GetShippingMethods(LanguageCode, true); if (dto.ShippingMethod != null) { DataView view = dto.ShippingMethod.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("ShippingMethodId", "LanguageId"); MyListView.DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { DataTable table = mc.Workflow.LoadAllDT(); if (table != null) { DataView view = table.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("WorkflowId"); MyListView.DataBind(); }
public void Invoke(object sender, object element) { if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; string gridId = cp.CommandArguments["GridId"]; string[] items = EcfListView.GetCheckedCollection(((Control)sender).Page, gridId); if (items != null) { int error = 0; string errorMessage = String.Empty; try { ProcessDeleteCommand(items); ManagementHelper.SetBindGridFlag(gridId); } catch (SqlException sqlEx) { error++; if (sqlEx.Number == 547) { errorMessage = Resources.ContentStrings.Site_Template_Delete_ReferenceException; } else { errorMessage = String.Concat(Resources.ContentStrings.Site_Template_Delete_TitleException, sqlEx.Message); } } catch (Exception ex) { error++; errorMessage = String.Concat(Resources.ContentStrings.Site_Template_Delete_TitleException, ex.Message); } if (error > 0) { errorMessage = errorMessage.Replace("'", "\\'").Replace(Environment.NewLine, "\\n"); ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("alert('{0}');", errorMessage), true); } } else { return; } } }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int id = Int32.Parse(keys[0]); string name = keys[1]; CatalogContext.Current.DeleteCatalog(id); } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { CatalogDto dto = CatalogContext.Current.GetCatalogDto(); if (dto.Catalog != null) { DataView view = dto.Catalog.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("CatalogId", "Name"); DataBind(); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { JurisdictionDto dto = JurisdictionManager.GetJurisdictionGroups(JurisdictionType); if (dto.Jurisdiction != null) { DataView view = dto.JurisdictionGroup.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("JurisdictionGroupId", "JurisdictionType"); MyListView.DataBind(); }
/// <summary> /// Returns true, if grid is not empty. /// </summary> /// <param name="sender"></param> /// <param name="element"></param> /// <returns></returns> public bool IsEnable(object sender, object element) { bool enable = false; if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; string gridId = cp.CommandArguments["GridId"]; // find grid EcfListView grid = ManagementHelper.GetControlFromCollection <EcfListView>(((Control)sender).Page.Controls, gridId); // get EcfListViewControl which contains the specified grid EcfListViewControl lv = ManagementHelper.GetParentControl <EcfListViewControl>(grid); if (lv != null) { enable = lv.CurrentListView.Items.Count > 0; } else { enable = false; } // Check permissions too if (enable) { if (ProfileConfiguration.Instance.EnablePermissions) { string permissions = cp.CommandArguments["permissions"]; if (permissions != string.Empty) { string[] permissionsArray = permissions.Split(new char[] { ',' }); foreach (string permission in permissionsArray) { if (!ProfileContext.Current.CheckPermission(permission)) { return(false); } } } } } } return(enable); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack || String.Compare(Request.Form["__EVENTTARGET"], CommandManager.GetCurrent(this.Page).ID, false) == 0) { if (!IsPostBack) { MyListView2.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("ID", "Type"); } //MyListView2.CurrentListView.CurrentPageSize = GetMaximumRows(); InitDataSource(_StartRowIndex, GetMaximumRows(), true, "" /*EcfListView.MakeSortExpression(EcfListView.GetSavedSorting(this.Page, MyListView2.ViewId, * new SortViewState("Type", SortDirection.Ascending)))*/); DataBind(); } }
/// <summary> /// Handles the SelectedIndexChanged event of the ddPaging control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ddPaging_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddPaging = (DropDownList)sender; if (Convert.ToInt32(ddPaging.SelectedValue) != -1) { MainListView.CurrentPageSize = Convert.ToInt32(ddPaging.SelectedValue); } else MainListView.CurrentPageSize = Int32.MaxValue; // save new pageSize EcfListView.SavePageSize(this.Page, this.ViewId, MainListView.CurrentPageSize); ResetPageNumber(true); }
/// <summary> /// Invokes the specified sender. /// </summary> /// <param name="sender">The sender.</param> /// <param name="element">The element.</param> public void Invoke(object sender, object element) { if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; int error = 0; string errorMessage = String.Empty; try { string[] items = null; if (cp.CommandArguments.ContainsKey(EcfListView.GridCommandParameterName) && Boolean.Parse(cp.CommandArguments[EcfListView.GridCommandParameterName])) { // process command from grid (delete only one item) string primaryKeyId = cp.CommandArguments["primaryKeyId"]; items = new string[] { primaryKeyId }; } else { // get checked items and process batch delete command (from toolbar) string gridId = cp.CommandArguments["GridId"]; items = EcfListView.GetCheckedCollection(((Control)sender).Page, gridId); ManagementHelper.SetBindGridFlag(gridId); } if (items != null) { ProcessLanguageCommand(items); } } catch (Exception ex) { error++; errorMessage = ex.Message; } if (error > 0) { errorMessage = errorMessage.Replace("'", "\\'").Replace(Environment.NewLine, "\\n"); ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("alert('{0}{1}');", "Failed to copy item(s). Error: ", errorMessage), true); } } }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { PolicyDto dto = PolicyManager.GetPolicyDto(); if (dto.Policy != null && dto.Policy.Count > 0) { DataView view = null; if (String.IsNullOrEmpty(Group)) { view = dto.Policy.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } else { // filter dto by specified group PolicyDto.GroupPolicyRow[] gpRows = (PolicyDto.GroupPolicyRow[])dto.GroupPolicy.Select(String.Format("GroupName = '{0}'", Group)); string query = ""; foreach (PolicyDto.GroupPolicyRow gpRow in gpRows) { query = String.Concat(query, String.Format("OR PolicyId={0}", gpRow.PolicyId)); } if (query.StartsWith("OR ")) { query = query.Substring(3); } else { query = "1 = 0"; } dto.Policy.DefaultView.Sort = sortExpression; PolicyDto.PolicyRow[] policyRows = (PolicyDto.PolicyRow[])dto.Policy.Select(query); MyListView.DataSource = policyRows; } } else { MyListView.DataSource = null; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("PolicyId"); MyListView.DataBind(); }