/// <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; string gridId = cp.CommandArguments["GridId"]; EcfListView ecfLV = ManagementHelper.GetControlFromCollection <EcfListView>(((Control)sender).Page.Controls, gridId); if (ecfLV != null) { int error = 0; string errorMessage = String.Empty; try { ProcessUpdateCommand(ecfLV.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 update item(s). Error: ", errorMessage), true); } } } }
/// <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> /// 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; string logType = cp.CommandArguments["LogType"]; string variant = cp.CommandArguments["Variant"]; string dataSourceId = cp.CommandArguments["DataSourceId"]; ApplicationLogDataSource applicationLogDataSource = ManagementHelper.GetControlFromCollection <ApplicationLogDataSource>(((Control)sender).Page.Controls, dataSourceId); if (applicationLogDataSource != null) { string exportPageUrl = "~/Apps/Core/StoreLogs/LogExport.aspx"; int error = 0; string errorMessage = String.Empty; try { exportPageUrl += String.Concat("?type=", applicationLogDataSource.DataMode.ToString()); if (variant.Equals("View") || variant.Equals("CurrentPage")) { exportPageUrl += GetApplicationLogDataSourceUrlParamaters(applicationLogDataSource); if (variant.Equals("CurrentPage")) { exportPageUrl += String.Concat("&RecordsToRetrieve=", applicationLogDataSource.Options.RecordsToRetrieve); exportPageUrl += String.Concat("&StartingRecord=", applicationLogDataSource.Options.StartingRecord); } } ((Control)sender).Page.Response.Redirect(exportPageUrl, true); } 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> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lbSaveFiles_Click(object sender, EventArgs e) { FileStreamInfo[] fsi = FileUpCtrl.Files; if (fsi != null && fsi.Length > 0) { try { string filePath = Path.Combine(HttpContext.Current.Server.MapPath(ManagementHelper.GetImportExportFolderPath("csv\\data")), fsi[0].FileName); if (File.Exists(filePath)) { File.Delete(filePath); } FileUpCtrl.SaveAs(fsi[0], filePath); FileUpCtrl.ReleaseAll(); // update upload status lblUploadResult.Text = String.Empty; //"File saved successfully."; UploadResultPanel.Update(); } catch (Exception ex) { lblUploadResult.Text = ex.Message; UploadResultPanel.Update(); } finally { FilesControl.DataBind(); FilesPanel.Update(); DropDownList ddlDataFiles = ManagementHelper.GetControlFromCollection <DropDownList>(this.Parent.Parent.Controls, "ddlDataFiles"); if (ddlDataFiles != null) { BindDataFiles(this.SourcePath, String.Empty, ddlDataFiles); } } } }
public string GetClientId(string serverId) { return(ManagementHelper.GetControlFromCollection <Label>(fuProgress.Controls, serverId).ClientID); }