/// <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)); }
/// <summary>Gets the html code for row of document's version table</summary> public string Render(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.Customer); string iconView = string.Empty; string iconDelete = string.Empty; if (grantWrite && this.DocumentId > 0) { string validDescription = Tools.LiteralQuote(Tools.JsonCompliant(this.Attach)); string deleteFunction = string.Format(CultureInfo.InvariantCulture, "DocumentAttachDelete({0},'{1}');", this.DocumentId, this.Attach); iconView = string.Format(CultureInfo.InvariantCulture, @"<span class=""btn btn-xs btn-success"" onclick=""window.open('/DOCS/{0}/Document_{1}_v{2}_{3}.{4}');""><i class=""icon-eye-open bigger-120""></i></span>", this.CompanyId, this.Id, this.Version, this.DocumentId, this.Extension); 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, validDescription, Tools.JsonCompliant(dictionary["Common_Delete"])); } string pattern = @" <tr> <td style=""width:80px;"">{0}</td> <td style=""width:90px;"">{1:dd/MM/yyyy}</td> <td>{2}</td> <td style=""width:120px;"" id=""DOC{0}"">{3}</td> <td style=""width:80px;"">{4}</td> <td style=""width:150px;"" id=""Icons{0}"">{5} {6}</td> </tr>"; return(string.Format( CultureInfo.InvariantCulture, pattern, this.Version, this.Date, this.Reason, this.Attach, this.AprovedBy, iconView, 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 grantCostDefinition = UserGrant.HasWriteGrant(grants, ApplicationGrant.CostDefinition); string iconRename = string.Format(CultureInfo.GetCultureInfo("en-us"), @"<span title=""{2} {1}"" class=""btn btn-xs btn-info"" onclick=""CostDefinitionUpdate({0});""><i class=""icon-edit bigger-120""></i></span>", this.Id, Tools.SetTooltip(this.Description), Tools.JsonCompliant(dictionary["Common_Edit"])); string iconDelete = string.Empty; if (grantCostDefinition) { string deleteAction = string.Format(CultureInfo.GetCultureInfo("en-us"), "CostDefinitionDelete('{0}', {1});", Tools.JsonCompliant(this.Description), this.Id); iconDelete = string.Format(CultureInfo.GetCultureInfo("en-us"), @"<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)); } string import = string.Format(CultureInfo.InvariantCulture, "{0:#,##0.00}", this.Amount).Replace(".", ","); return(string.Format(CultureInfo.GetCultureInfo("en-us"), @"<tr id=""{0}""><td>{1}</td><td class=""hidden-480"" align=""right"" style=""padding-right:8px;width:200px;"">{2}</td><td style=""width:90px"">{3} {4}</td></tr>", this.Id, this.Link, import, iconRename, 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(); }
/// <summary>Begin page running after session validations</summary> private void Go() { if (this.Request.QueryString["id"] != null) { this.employeeId = Convert.ToInt32(this.Request.QueryString["id"].ToString()); } if (this.Request.QueryString["New"] != null) { this.returnScript = "document.location = 'EmployeesList.aspx';"; } else { this.returnScript = "document.location = referrer;"; } this.formFooter = new FormFooter(); this.formFooterLearning = new FormFooter(); this.formFooterInternalLearning = new FormFooter(); this.user = (ApplicationUser)Session["User"]; this.company = (Company)Session["company"]; this.Dictionary = Session["Dictionary"] as Dictionary <string, string>; string label = this.employeeId == -1 ? "Item_Employee_Button_New" : "Item_Employee_Title_EmployeeData"; 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_Employees", "EmployeesList.aspx", false); this.master.AddBreadCrumb("Item_Employee_Title_EmployeeData"); this.master.TitleInvariant = true; this.master.Titulo = this.Dictionary["Item_Employee_Title_EmployeeData"]; if (employeeId > 0) { bool grantDelete = UserGrant.HasWriteGrant(this.user.Grants, ApplicationGrant.Employee); bool grantJobPositionView = UserGrant.HasReadGrant(this.user.Grants, ApplicationGrant.JobPosition); bool grantDepartmentsView = UserGrant.HasReadGrant(this.user.Grants, ApplicationGrant.Department); this.Employee = new Employee(this.employeeId, true); if (this.Employee.CompanyId != this.company.Id) { this.Response.Redirect("NoAccesible.aspx", false); Context.ApplicationInstance.CompleteRequest(); this.Employee = Employee.Empty; } if (this.Employee.DisabledDate.HasValue) { this.Active = false; } label = string.Format(CultureInfo.InvariantCulture, "{0}: <strong>{1}</strong>", this.Dictionary["Item_Employee"], Employee.FullName); this.master.Titulo = label; this.departmentsEmployeeJson = new StringBuilder("[").Append(Environment.NewLine); this.departmentsEmployeeJson.Append(Environment.NewLine).Append("\t]"); this.jobPositionAcademic = new StringBuilder(); this.jobPositionSpecific = new StringBuilder(); this.jobPositionWorkExperience = new StringBuilder(); this.jobPositionHability = new StringBuilder(); var tableJobAsignements = new StringBuilder(); this.jobpositionEmployeeJson = new StringBuilder("["); bool firstJobPosition = true; this.Employee.ObtainJobPositionsHistoric(); var JobPositionAdded = new List <long>(); foreach (var jobAsignement in this.Employee.JobPositionAssignment) { if (!JobPositionAdded.Contains(jobAsignement.JobPosition.Id) || true) { JobPositionAdded.Add(jobAsignement.JobPosition.Id); var actualJobPosition = new JobPosition(jobAsignement.JobPosition.Id, this.company.Id); if (firstJobPosition) { firstJobPosition = false; } else { this.jobpositionEmployeeJson.Append(","); } this.jobpositionEmployeeJson.Append(jobAsignement.Json); if (!string.IsNullOrEmpty(actualJobPosition.AcademicSkills)) { if (this.jobPositionAcademic.ToString().IndexOf(actualJobPosition.AcademicSkills) == -1) { this.jobPositionAcademic.Append(actualJobPosition.AcademicSkills); this.jobPositionAcademic.Append(Environment.NewLine); } } if (!string.IsNullOrEmpty(actualJobPosition.SpecificSkills)) { if (this.jobPositionSpecific.ToString().IndexOf(actualJobPosition.SpecificSkills) == -1) { this.jobPositionSpecific.Append(actualJobPosition.SpecificSkills); this.jobPositionSpecific.Append(Environment.NewLine); } } if (!string.IsNullOrEmpty(actualJobPosition.WorkExperience)) { if (this.jobPositionWorkExperience.ToString().IndexOf(actualJobPosition.WorkExperience) == -1) { this.jobPositionWorkExperience.Append(actualJobPosition.WorkExperience); this.jobPositionWorkExperience.Append(Environment.NewLine); } } if (!string.IsNullOrEmpty(actualJobPosition.Habilities)) { if (this.jobPositionHability.ToString().IndexOf(actualJobPosition.Habilities) == -1) { this.jobPositionHability.Append(actualJobPosition.Habilities); this.jobPositionHability.Append(Environment.NewLine); } } tableJobAsignements.Append(jobAsignement.TableRow(this.Dictionary, grantDelete, grantJobPositionView, grantDepartmentsView)); } } this.jobpositionEmployeeJson.Append("]"); this.TableExperiencia.Text = tableJobAsignements.ToString(); this.companyUserNames = new StringBuilder(); bool firstUserName = true; foreach (var userName in ApplicationUser.CompanyUserNames(this.company.Id)) { if (firstUserName) { firstUserName = false; } else { this.companyUserNames.Append(","); } this.companyUserNames.Append(string.Format(@"{{""UserName"":""{0}"",""EmployeeId"":{1}}}", userName.Key, userName.Value)); } var tableAssistance = new StringBuilder(); this.Employee.ObtainLearningAssistance(); foreach (LearningAssistance assistance in this.Employee.LearningAssistance) { tableAssistance.Append(assistance.TableRowProfile(this.Dictionary)); } this.TableLearningAssistance.Text = tableAssistance.ToString(); this.LtTrazas.Text = ActivityTrace.RenderTraceTableForItem(this.employeeId, TargetType.Employee); this.Employee.ObtainEmployeeSkills(); this.formFooter.ModifiedBy = this.Employee.ModifiedBy.Description; this.formFooter.ModifiedOn = this.Employee.ModifiedOn; if (this.Employee.EmployeeSkills != null && this.Employee.EmployeeSkills.ModifiedBy != null) { this.formFooterLearning.ModifiedBy = this.Employee.EmployeeSkills.ModifiedBy.Description; this.formFooterLearning.ModifiedOn = this.Employee.EmployeeSkills.ModifiedOn; } if (this.Employee.User == null) { this.Employee.User = ApplicationUser.GetByEmployee(this.Employee.Id, this.Employee.CompanyId); this.employeeUserId = this.Employee.User.Id; this.userName = this.Employee.User.UserName; } this.RenderDocuments(); } else { this.Employee = Employee.Empty; this.departmentsEmployeeJson = new StringBuilder(Constant.EmptyJsonList); this.jobpositionEmployeeJson = new StringBuilder(Constant.EmptyJsonList); this.employeeUserId = -1; this.userName = string.Empty; this.companyUserNames = new StringBuilder(); this.Employee.Address = EmployeeAddress.Empty; } this.RenderCountries(); if (this.Active) { if (employeeId > 0) { this.formFooter.AddButton(new UIButton { Id = "BtnAnular", Icon = "icon-ban-circle", Text = this.Dictionary["Item_Employee_Btn_Inactive"], Action = "danger" }); } this.formFooter.AddButton(new UIButton { Id = "BtnSave", Icon = "icon-ok", Text = this.Dictionary["Common_Accept"], Action = "success" }); } else { this.formFooter.AddButton(new UIButton { Id = "BtnRestore", Icon = "icon-undo", Text = this.Dictionary["Item_Employee_Button_Restore"], Action = "primary" }); //this.formFooter.AddButton(new UIButton { Id = "BtnRestore", Icon = "icon-ok", Text = this.Dictionary["Item_Employee_Button_Restore"], Action = "success" }); } this.formFooter.AddButton(new UIButton { Id = "BtnCancel", Icon = "icon-undo", Text = this.Dictionary["Common_Cancel"] }); if (this.Active) { this.formFooterInternalLearning.ModifiedBy = this.formFooter.ModifiedBy; this.formFooterInternalLearning.ModifiedOn = this.formFooter.ModifiedOn; this.formFooterLearning.AddButton(new UIButton { Id = "BtnSaveFormacion", Icon = "icon-ok", Text = this.Dictionary["Common_Accept"], Action = "success" }); this.formFooterLearning.AddButton(new UIButton { Id = "BtnCancelFormacion", Icon = "icon-undo", Text = this.Dictionary["Common_Cancel"] }); this.formFooterInternalLearning.AddButton(new UIButton { Id = "BtnSaveInternalLearning", Icon = "icon-ok", Text = this.Dictionary["Common_Accept"], Action = "success" }); this.formFooterInternalLearning.AddButton(new UIButton { Id = "BtnCancelInternalLearning", Icon = "icon-undo", Text = this.Dictionary["Common_Cancel"] }); } this.SelectedTab = "home"; if (this.Request.QueryString["Tab"] != null) { SelectedTab = this.Request.QueryString["Tab"].ToString().Trim().ToLowerInvariant(); } this.tabBar.AddTab(new Tab { Id = "home", Selected = SelectedTab == "home", Active = true, Label = this.Dictionary["Item_Employee_Tab_Principal"], Available = true }); this.tabBar.AddTab(new Tab { Id = "formacion", Available = true, Active = this.employeeId > 0, Hidden = this.employeeId < 1, Label = this.Dictionary["Item_Employee_Tab_Learning"] }); this.tabBar.AddTab(new Tab { Id = "formacionInterna", Selected = SelectedTab == "formacioninterna", Available = true, Active = this.employeeId > 0, Hidden = this.employeeId < 1, Label = this.Dictionary["Item_Employee_Tab_InternalLearning"] }); this.tabBar.AddTab(new Tab { Id = "uploadFiles", Selected = SelectedTab == "uploadfiles", Available = true, Active = this.employeeId > 0, Hidden = this.employeeId < 1, Label = this.Dictionary["Item_Employee_Tab_UploadFiles"] }); //// this.tabBar.AddTab(new Tab { Id = "trazas", Available = this.user.HasTraceGrant() && this.employeeId > 0, Active = this.employeeId > 0, Label = this.dictionary["Item_Employee_Tab_Traces"] }); }
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 Row(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 grantIncident = UserGrant.HasWriteGrant(grants, ApplicationGrant.Incident); bool grantAction = UserGrant.HasWriteGrant(grants, ApplicationGrant.IncidentActions); string itemName = string.Empty; string status = string.Empty; string description = string.Empty; string associated = string.Empty; switch (this.Status) { case 1: status = dictionary["Item_Incident_Status1"]; break; case 2: status = dictionary["Item_Incident_Status2"]; break; case 3: status = dictionary["Item_Incident_Status3"]; break; case 4: status = dictionary["Item_Incident_Status4"]; break; default: status = "undefined"; break; } if (this.Incident != null && this.Relation == 0 || this.Relation == 1) { itemName = dictionary["Item_Incident"]; description = grantIncident ? this.Incident.Link : this.Incident.Description; if (this.Relation == 1) { associated = dictionary["Item_IncidentAction"] + ": " + (grantAction ? this.Action.Link : this.Action.Description); } } else { itemName = dictionary["Item_IncidentAction"]; description = grantAction ? this.Action.Link : this.Action.Description; if (this.Relation == 2) { associated = dictionary["Item_Incident"] + ": " + (grantIncident ? this.Incident.Link : this.Incident.Description); } } return(string.Format( CultureInfo.GetCultureInfo("en-us"), @"<tr> <td>{0}</td> <td>{1}</td> <td>{2}</td> <td>{3}</td> </tr>", itemName, description, status, associated)); }
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(); }
public string Row(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 grantEquipment = UserGrant.HasWriteGrant(grants, ApplicationGrant.Equipment); bool grantEmployee = UserGrant.HasWriteGrant(grants, ApplicationGrant.Employee); string itemName = string.Empty; string employee = string.Empty; DateTime date = new DateTime(); decimal? amount = 0; string operation = string.Empty; if (this.Calibration != null) { itemName = dictionary["Item_EquipmentCalibration"]; employee = grantEmployee ? this.Calibration.Responsible.Link : this.Calibration.Responsible.FullName; date = this.Calibration.Date; amount = this.Calibration.Cost; operation = this.Calibration.Description; } else if (this.Verification != null) { itemName = dictionary["Item_EquipmentVerification"]; employee = grantEmployee ? this.Verification.Responsible.Link : this.Verification.Responsible.FullName; date = this.Verification.Date; amount = this.Verification.Cost; operation = this.Verification.Description; } else if (this.Maintenance != null) { itemName = dictionary["Item_EquipmentMaintenance"]; employee = grantEmployee ? this.Maintenance.Responsible.Link : this.Maintenance.Responsible.FullName; date = this.Maintenance.Date; amount = this.Maintenance.Cost; operation = this.Maintenance.Description; } else if (this.Repair != null) { itemName = dictionary["Item_EquipmentRepair"]; employee = grantEmployee ? this.Repair.Responsible.Link : this.Repair.Responsible.FullName; date = this.Repair.Date; amount = this.Repair.Cost; operation = this.Repair.Description; } string cost = string.Empty; if (amount.HasValue) { cost = string.Format(CultureInfo.GetCultureInfo("en-us"), "{0:#,##0.00}", amount).Replace(".", ","); } return(string.Format( CultureInfo.GetCultureInfo("en-us"), @"<tr> <td>{5}</td> <td>{0}</td> <td>{1}</td> <td align=""center"">{2:dd/MM/yyyy}</td> <td>{3}</td> <td align=""right"">{4}</td> </tr>", itemName, operation, date, employee, cost, grantEquipment ? this.Equipment.Link : this.Equipment.Description)); }