/// <summary>Gets HTML code for customers row list</summary> /// <param name="dictionary">Dictionary for fixed labels</param> /// <param name="grants">Grants of users</param> /// <returns>HTML code for customers row list</returns> public string ListRow(Dictionary <string, string> dictionary, ReadOnlyCollection <UserGrant> grants) { if (grants == null) { return(string.Empty); } if (dictionary == null) { dictionary = HttpContext.Current.Session["Dictionary"] as Dictionary <string, string>; } var grantWrite = UserGrant.HasWriteGrant(grants, ApplicationGrant.Customer); var grantDelete = UserGrant.HasDeleteGrant(grants, ApplicationGrant.Customer); var iconDelete = string.Empty; if (grantDelete) { var deleteFunction = string.Format(CultureInfo.InvariantCulture, "CustomerDelete({0},'{1}');", this.Id, this.Description); if (!this.CanBeDeleted) { deleteFunction = string.Format(CultureInfo.InvariantCulture, "warningInfoUI('{0}', null, 400);", dictionary["Common_Warning_Undelete"]); } iconDelete = string.Format( CultureInfo.InvariantCulture, @"<span title=""{2} {1}"" class=""btn btn-xs btn-danger"" onclick=""{0}""><i class=""icon-trash bigger-120""></i></span>", deleteFunction, Tools.LiteralQuote(Tools.JsonCompliant(this.Description)), Tools.JsonCompliant(dictionary["Common_Delete"])); } var iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='CustomersView.aspx?id={0}';""><i class=""icon-eye-open bigger-120""></i></span>", this.Id, dictionary["Common_View"], this.Description); if (grantWrite) { iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='CustomersView.aspx?id={0}';""><i class=""icon-edit bigger-120""></i></span>", this.Id, dictionary["Common_Edit"], this.Description); } string pattern = @"<tr><td>{0}</td><td style=""width:90px;"">{1} {2}</td></tr>"; return(string.Format( CultureInfo.InvariantCulture, pattern, this.Link, iconEdit, iconDelete)); }
public string ListRow(Dictionary <string, string> dictionary, ReadOnlyCollection <UserGrant> grants) { if (grants == null) { return(string.Empty); } if (dictionary == null) { dictionary = HttpContext.Current.Session["Dictionary"] as Dictionary <string, string>; } bool grantWrite = UserGrant.HasWriteGrant(grants, ApplicationGrant.Rule); bool grantDelete = UserGrant.HasDeleteGrant(grants, ApplicationGrant.Rule); string iconDelete = string.Empty; if (grantDelete) { string deleteFunction = string.Format(CultureInfo.GetCultureInfo("en-us"), "RuleDelete({0},'{1}');", this.Id, this.Description); if (!this.CanBeDeleted) { deleteFunction = string.Format(CultureInfo.GetCultureInfo("en-us"), "warningInfoUI('{0}', null, 400);", dictionary["Common_Warning_Undelete"]); } iconDelete = string.Format( CultureInfo.InvariantCulture, @"<span title=""{2} {1}"" class=""btn btn-xs btn-danger"" onclick=""{0}""><i class=""icon-trash bigger-120""></i></span>", deleteFunction, Tools.LiteralQuote(Tools.JsonCompliant(this.Description)), Tools.JsonCompliant(dictionary["Common_Delete"])); } string iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='RulesView.aspx?id={0}';""><i class=""icon-eye-open bigger-120""></i></span>", this.Id, dictionary["Common_View"], this.Description); if (grantWrite) { iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='RulesView.aspx?id={0}';""><i class=""icon-edit bigger-120""></i></span>", this.Id, dictionary["Common_Edit"], this.Description); } /*if (grantWrite) * { * string validDescription = Tools.LiteralQuote(Tools.JsonCompliant(this.Description)); * string deleteFunction = string.Format(CultureInfo.GetCultureInfo("en-us"), "RuleDelete({0},'{1}');", this.Id, this.Description); * if (!this.CanBeDeleted) * { * deleteFunction = string.Format(CultureInfo.GetCultureInfo("en-us"), "warningInfoUI('{0}', null, 400);", dictionary["Common_Warning_Undelete"]); * } * * iconEdit = string.Format(CultureInfo.GetCultureInfo("en-us"), @"<span title=""{2} {1}"" class=""btn btn-xs btn-info"" onclick=""document.location='RulesView.aspx?id={0}';""><i class=""icon-edit bigger-120""></i></span>", this.Id, validDescription, Tools.JsonCompliant(dictionary["Common_Edit"])); * iconDelete = string.Format(CultureInfo.GetCultureInfo("en-us"), @"<span title=""{2} {1}"" class=""btn btn-xs btn-danger"" onclick=""{0}""><i class=""icon-trash bigger-120""></i></span>", deleteFunction, validDescription, Tools.JsonCompliant(dictionary["Common_Delete"])); * }*/ return(string.Format( CultureInfo.GetCultureInfo("en-us"), @"<tr><td>{0}</td><td align=""right"" style=""width:100px;"">{1}</td><td style=""width:90px;"">{2} {3}</td></tr>", this.Link, this.Limit, iconEdit, iconDelete)); }
/// <summary>Render HTML code for process list content</summary> private void RenderProcesosData() { var procesos = ProcessType.ObtainByCompany(this.company.Id, this.Dictionary); var res = new StringBuilder(); var processList = Process.ByCompany(((Company)Session["Company"]).Id); var searchedItem = new List <string>(); bool first = true; this.ProcesosDataTotal.Text = processList.Count.ToString(); bool grantWrite = UserGrant.HasWriteGrant(this.user.Grants, ApplicationGrant.Process); bool grantDelete = UserGrant.HasDeleteGrant(this.user.Grants, ApplicationGrant.Process); foreach (Process process in processList) { string resposableDescription = string.Empty; string processTypeName = string.Empty; foreach (ProcessType processType in procesos) { if (processType.Id == process.ProcessType) { processTypeName = processType.Description; break; } } if (process.JobPosition != null) { resposableDescription = process.JobPosition.Link; if (!searchedItem.Contains(process.JobPosition.Description)) { searchedItem.Add(process.JobPosition.Description); } } else { resposableDescription = string.Format(CultureInfo.InvariantCulture, @"<span style=""color:#f00;"">{0}</span>", this.Dictionary["Item_Process_Status_WhitoutResponsible"]); } string iconDelete = string.Empty; if (grantDelete) { if (process.CanBeDeleted) { iconDelete = string.Format( CultureInfo.InvariantCulture, @"<span title=""{0} '{1}'"" class=""btn btn-xs btn-danger"" onclick=""ProcessDelete(this);""><i class=""icon-trash bigger-120""></i></span>", this.Dictionary["Common_Delete"], process.Description); } else { iconDelete = string.Format( CultureInfo.InvariantCulture, @"<span title=""{0} '{1}'"" class=""btn btn-xs btn-danger"" onclick=""ProcessNoDelete(this);""><i class=""icon-trash bigger-120""></i></span>", this.Dictionary["Common_Delete"], process.Description); } } string iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='ProcesosView.aspx?id={0}';""><i class=""icon-eye-open bigger-120""></i></span>", process.Id, this.Dictionary["Common_View"], process.Description); if (grantWrite) { iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='ProcesosView.aspx?id={0}';""><i class=""icon-edit bigger-120""></i></span>", process.Id, this.Dictionary["Common_Edit"], process.Description); } string pattern = @"<tr id=""{0}"" class=""process{7}""><td vertical-align=""middle""><a href=""ProcesosView.aspx?id={0}"">{1}</a></td><td style=""width:300px;padding-left:4px;""><div title='{6}' style=""width:165px;"" class=""truncate"">{2}</div></td><td style=""width:200px;text-align:center;""><div title='{3}' style=""width:165px;"" class=""truncate"">{3}</td><td style=""width:90px;"">{4} {5}</td></tr>"; res.Append(string.Format( CultureInfo.InvariantCulture, pattern, process.Id, process.Description, resposableDescription, processTypeName, iconEdit, iconDelete, process.JobPosition.Description, process.DisabledOn.HasValue ? "Inactive" : "Active")); searchedItem.Add(process.Description); } searchedItem.Sort(); first = true; var sea = new StringBuilder(); foreach (string item in searchedItem) { if (!string.IsNullOrEmpty(item)) { if (first) { first = false; } else { sea.Append(","); } if (item.IndexOf("\"") != -1) { sea.Append(string.Format(@"'{0}'", item)); } else { sea.Append(string.Format(@"""{0}""", item)); } } } this.ProcesosData.Text = res.ToString(); this.master.SearcheableItems = sea.ToString(); }
private void RenderUserData() { var active = new StringBuilder(); var sea = new StringBuilder(); var searchedItem = new List <string>(); bool first = true; var users = ApplicationUser.CompanyUsers(this.company.Id); int contData = 0; foreach (var userItem in users.Where(u => u.PrimaryUser == true)) { var row = string.Empty; if (dictionary == null) { dictionary = Session["Dictionary"] as Dictionary <string, string>; } bool grantWrite = UserGrant.HasWriteGrant(this.user.Grants, ApplicationGrant.User); bool grantDelete = UserGrant.HasDeleteGrant(this.user.Grants, ApplicationGrant.User); string employeeLink = userItem.Employee != null ? userItem.Employee.Link : string.Empty; string iconDelete = string.Empty; string iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""UserUpdate({0},'{2}');""><i class=""icon-eye-open bigger-120""></i></span>", userItem.Id, dictionary["Common_View"], userItem.Description); if (grantWrite) { iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""UserUpdate({0},'{2}');""><i class=""icon-edit bigger-120""></i></span>", userItem.Id, dictionary["Common_Edit"], userItem.Description); } string iconAdmin = iconAdmin = "<i class=\"icon-star\" style=\"color:#428bca;\" title=" + dictionary["User_PrimaryUser"] + "></i>"; string pattern = @"<tr><td style=""width:40px;"">{5}</td><td>{0}</td><td style=""width:300px;"">{1}</td><td style=""width:300px;"">{2}</td><td style=""width:90px;"">{3} {4}</td></tr>"; row = string.Format( CultureInfo.GetCultureInfo("en-us"), pattern, userItem.Link, employeeLink, userItem.Email, iconEdit, string.Empty, iconAdmin); active.Append(row); if (!searchedItem.Contains(userItem.UserName)) { searchedItem.Add(userItem.UserName); } if (!searchedItem.Contains(userItem.Email)) { searchedItem.Add(userItem.Email); } if (!searchedItem.Contains(userItem.Employee.FullName)) { searchedItem.Add(userItem.Employee.FullName); } contData++; } foreach (var userItem in users.Where(u => u.PrimaryUser == false)) { active.Append(userItem.ListRow(this.dictionary, this.user.Grants)); if (!searchedItem.Contains(userItem.UserName)) { searchedItem.Add(userItem.UserName); } if (!searchedItem.Contains(userItem.Email)) { searchedItem.Add(userItem.Email); } if (!searchedItem.Contains(userItem.Employee.FullName)) { searchedItem.Add(userItem.Employee.FullName); } contData++; } searchedItem.Sort(); foreach (string s1 in searchedItem) { if (!string.IsNullOrEmpty(s1)) { if (first) { first = false; } else { sea.Append(","); } sea.AppendFormat(CultureInfo.InvariantCulture, @"""{0}""", s1); } } this.UsersData.Text = active.ToString(); this.UsersDataTotal.Text = contData.ToString(); this.master.SearcheableItems = sea.ToString(); }
public string ListRow(Dictionary <string, string> dictionary, ReadOnlyCollection <UserGrant> grants) { if (grants == null) { return(string.Empty); } if (dictionary == null) { dictionary = HttpContext.Current.Session["Dictionary"] as Dictionary <string, string>; } bool grantWrite = UserGrant.HasWriteGrant(grants, ApplicationGrant.Indicador); bool grantDelete = UserGrant.HasDeleteGrant(grants, ApplicationGrant.Indicador); string iconDelete = string.Empty; if (grantDelete) { string deleteFunction = string.Format(CultureInfo.GetCultureInfo("en-us"), "IndicadorDelete({0},'{1}');", this.Id, this.Description); if (!this.CanBeDeleted) { deleteFunction = string.Format(CultureInfo.GetCultureInfo("en-us"), "warningInfoUI('{0}', null, 400);", dictionary["Common_Warning_Undelete"]); } iconDelete = string.Format( CultureInfo.InvariantCulture, @"<span title=""{2} {1}"" class=""btn btn-xs btn-danger"" onclick=""{0}""><i class=""icon-trash bigger-120""></i></span>", deleteFunction, Tools.LiteralQuote(Tools.JsonCompliant(this.Description)), Tools.JsonCompliant(dictionary["Common_Delete"])); } string iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""recordEdit({0});""><i class=""icon-eye-open bigger-120""></i></span>", this.Id, dictionary["Common_View"], this.Description); if (grantWrite) { iconEdit = string.Format( CultureInfo.InvariantCulture, @"<span title=""{1} '{2}'"" class=""btn btn-xs btn-info"" onclick=""document.location='IndicadorView.aspx?id={0}';""><i class=""icon-edit bigger-120""></i></span>", this.Id, dictionary["Common_Edit"], this.Description); } string alarmaText = string.Empty; if (this.Alarma.HasValue) { alarmaText = string.Format( CultureInfo.InvariantCulture, "@{0:#0.00}", this.Alarma.Value); } string pattenr = @"<tr><td align=""right"" style=""width:90px;"">{1}</td><td align=""center"" style=""width:90px;"">{2:dd/MM/yyyy}</td><td>{3}</td><td align=""right"" style=""width:90px;"">{4}</td><td align=""right"" style=""width:90px;"">{5}</td><td style=""width:150px;"">{6}</td><td style=""width:90px;"">{7} {8}</td></tr>"; return(string.Format( CultureInfo.InvariantCulture, pattenr, this.Indicador.Link, this.Value, this.Date, this.Comments, this.Meta, alarmaText, this.Responsible.FullName, iconEdit, iconDelete)); }
/// <summary>Gets a row of list departament</summary> /// <param name="dictionary">Dictionary for fixed labels</param> /// <param name="grants">List of user's grants</param> /// <returns>Code HTML for department row</returns> public string ListRow(Dictionary <string, string> dictionary, ReadOnlyCollection <UserGrant> grants) { if (dictionary == null) { return(string.Empty); } bool grantDepartment = UserGrant.HasWriteGrant(grants, ApplicationGrant.Department); bool grantDepartmentDelete = UserGrant.HasDeleteGrant(grants, ApplicationGrant.Department); bool grantJobPosition = UserGrant.HasWriteGrant(grants, ApplicationGrant.JobPosition); bool grantEmployee = UserGrant.HasWriteGrant(grants, ApplicationGrant.Employee); string employeesList = string.Empty; bool first = true; foreach (var employee in this.employees) { if (first) { first = false; } else { employeesList += ", "; } if (grantEmployee) { employeesList += employee.Link; } else { employeesList += employee.FullName; } } string jobPositionsList = string.Empty; first = true; foreach (var jobPosition in this.jobPositions) { if (first) { first = false; } else { jobPositionsList += ", "; } if (grantJobPosition) { jobPositionsList += jobPosition.Link; } else { jobPositionsList += jobPosition.Description; } } string iconRenameSymbol = grantDepartment ? "icon-edit" : "icon-eye-open"; string iconRename = string.Format(CultureInfo.InvariantCulture, @"<span title=""{2} '{1}'"" class=""btn btn-xs btn-info"" onclick=""DepartmentUpdate({0},'{1}');""> <i class=""{3} bigger-120""></i></span>", this.Id, Tools.SetTooltip(this.Description), Tools.JsonCompliant(dictionary["Common_Edit"]), iconRenameSymbol); string iconDelete = string.Empty; if (grantDepartmentDelete) { string deleteAction = string.Empty; if (this.employees.Count == 0 && this.jobPositions.Count == 0) { deleteAction = string.Format(CultureInfo.InvariantCulture, "DepartmentDelete({0},'{1}');", this.Id, this.Description); } else if (this.jobPositions.Count == 0) { deleteAction = string.Format(CultureInfo.InvariantCulture, "alertUI('{0}');", Tools.JsonCompliant(dictionary["Item_Departmennt_ErrorMessage_HasEmployees"])); } else if (this.employees.Count > 0) { deleteAction = string.Format(CultureInfo.InvariantCulture, "alertUI('{0}');", Tools.JsonCompliant(dictionary["Item_Departmennt_ErrorMessage_HasEmployees"])); } else { deleteAction = string.Format(CultureInfo.InvariantCulture, "alertUI('{0}');", Tools.JsonCompliant(dictionary["Item_JobPosition_ErrorMessage_HasJobPositionLinked"])); } iconDelete = string.Format(CultureInfo.InvariantCulture, @"<span title=""{1} {2}"" class=""btn btn-xs btn-danger"" onclick=""{0}""><i class=""icon-trash bigger-120""></i></span>", deleteAction, Tools.JsonCompliant(dictionary["Common_Delete"]), Tools.SetTooltip(this.Description)); } return(string.Format( CultureInfo.InvariantCulture, @"<tr id=""{5}""><td style=""width:300px;padding-left:4px;"">{0}</td><td style=""width:400px;padding-left:4px;""class=""hidden-480"">({6}) {7}</td><td class=""hidden-480"">({1}) {2}</td><td style=""width:90px;"">{3} {4}</td></tr>", this.Link, this.employees.Count, employeesList, iconRename, iconDelete, this.Id, this.jobPositions.Count, jobPositionsList)); }
/// <summary>Begin page running after session validations</summary> private void Go() { this.Dictionary = Session["Dictionary"] as Dictionary <string, string>; this.company = this.Session["Company"] as Company; this.master = this.Master as Giso; this.master.AdminPage = true; string serverPath = this.Request.Url.AbsoluteUri.Replace(this.Request.RawUrl.Substring(1), string.Empty); this.master.AddBreadCrumb("Item_Equipments"); this.master.Titulo = "Item_Equipments"; if (this.user.HasGrantToWrite(ApplicationGrant.Equipment)) { this.master.ButtonNewItem = UIButton.NewItemButton("Item_Equipment_Button_New", "EquipmentView.aspx"); } this.DataHeader = new UIDataHeader { Id = "ListDataHeader", ActionsItem = 2 }; this.DataHeader.AddItem(new UIDataHeaderItem { Id = "th0", HeaderId = "ListDataHeader", DataId = "ListDataTable", Text = this.Dictionary["Item_Equipment_Header_Code"], Sortable = true, Filterable = true, HiddenMobile = true }); this.DataHeader.AddItem(new UIDataHeaderItem { Id = "th1", HeaderId = "ListDataHeader", DataId = "ListDataTable", Text = this.Dictionary["Item_Equipment_Header_Description"], Sortable = true, Filterable = true }); this.DataHeader.AddItem(new UIDataHeaderItem { Id = "th2", HeaderId = "ListDataHeader", DataId = "ListDataTable", Text = this.Dictionary["Item_Equipment_Header_Location"], Sortable = true, HiddenMobile = true }); this.DataHeader.AddItem(new UIDataHeaderItem { Id = "th3", HeaderId = "ListDataHeader", DataId = "ListDataTable", Text = this.Dictionary["Item_Equipment_Header_Responsible"], Sortable = true, HiddenMobile = true }); bool grantWrite = UserGrant.HasWriteGrant(this.user.Grants, ApplicationGrant.Equipment); bool grantDelete = UserGrant.HasDeleteGrant(this.user.Grants, ApplicationGrant.Equipment); bool grantEmployee = UserGrant.HasReadGrant(this.user.Grants, ApplicationGrant.Employee); bool first = true; var equipments = Equipment.ByCompany(this.company); var searchList = new List <string>(); foreach (var equipment in equipments) { if (!searchList.Contains(equipment.Code)) { searchList.Add(equipment.Code); } if (!searchList.Contains(equipment.Description)) { searchList.Contains(equipment.Description); } } searchList.Sort(); var sea = new StringBuilder(); foreach (string item in searchList) { if (first) { first = false; } else { sea.Append(","); } if (item.IndexOf("\"") != -1) { sea.Append(string.Format(@"'{0}'", item)); } else { sea.Append(string.Format(@"""{0}""", item)); } } this.master.SearcheableItems = sea.ToString(); this.RenderCosts(); }