protected override void OnLoad(EventArgs e) { if (!Page.IsPostBack) { IResource res = Provider.Scheduler.Resource.GetResource(ResourceID); if (res != null) { string helpdeskEmail = res.HelpdeskEmail; hidAjaxUrl.Value = "/ostclient/ajax.aspx"; hidHelpdeskQueue.Value = helpdeskEmail; hidHelpdeskResource.Value = Provider.Utility.Serialization.Json.SerializeObject(new { id = res.ResourceID, name = res.ResourceName }); hidHelpdeskFromEmail.Value = CurrentUser.Email; hidHelpdeskFromName.Value = string.Format("{0} {1}", CurrentUser.FName, CurrentUser.LName); LoadReservations(); if (string.IsNullOrEmpty(helpdeskEmail)) { litErrMsg.Text = WebUtility.BootstrapAlert("danger", "A ticket cannot be created because a helpdesk email is not configured for this resource."); } } else { phNoResource.Visible = true; phHelpdesk.Visible = false; } } }
protected void btnCreateTicket_Click(object sender, EventArgs e) { var res = Helper.GetResourceTreeItemCollection().GetResource(ResourceID); litErrMsg.Text = string.Empty; string helpdeskEmail = GetHelpdeskEmail(res); bool load = true; if (string.IsNullOrEmpty(txtSubject.Text)) { litErrMsg.Text = WebUtility.BootstrapAlert("danger", "Please enter a subject.", true); } else if (string.IsNullOrEmpty(txtMessage.Text)) { litErrMsg.Text = WebUtility.BootstrapAlert("danger", "Please enter a message.", true); } else if (string.IsNullOrEmpty(helpdeskEmail)) { litErrMsg.Text = WebUtility.BootstrapAlert("danger", "An error occurred while creating the ticket. A helpdesk email is not configured for this resource.", true); } else { IReservation rsv = null; if (ddlReservations.SelectedValue != "None") { rsv = Provider.Scheduler.Reservation.GetReservation(int.Parse(ddlReservations.SelectedValue)); } string subjectText = "[" + res.ResourceID.ToString() + ":" + res.ResourceName + "] " + txtSubject.Text; CreateTicketResult addTicketResult = HelpdeskUtility.CreateTicket(CurrentUser, res, rsv, CurrentUser.ClientID, ddlReservations.SelectedItem.Text, subjectText, txtMessage.Text, ddlTicketType.SelectedItem.Text, Request.Url); if (addTicketResult.Success) { litErrMsg.Text = WebUtility.BootstrapAlert("success", string.Format("Your ticket has been created. A confirmation email has been sent to {0}.", CurrentUser.Email)); load = false; } else { StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("Create ticket failed. User: {0} ({1}). Resource: {2} ({3})", CurrentUser.DisplayName, CurrentUser.ClientID, res.ResourceName, res.ResourceID)); sb.AppendLine(string.Format("----------{0}{1}", Environment.NewLine, addTicketResult.Exception.Message)); SendEmail.SendDeveloperEmail("LNF.Web.Scheduler.Controls.Helpdesk.btnCreateTicket_Click", "Create Ticket Error", sb.ToString()); litErrMsg.Text = WebUtility.BootstrapAlert("danger", "Sorry, an error occurred and your ticket was not created. A notification has been sent to LNF staff."); } } if (load) { //LoadOpenTickets(); } LoadReservations(); }
protected void ResourceStatus_Command(object sender, CommandEventArgs e) { try { litErrMsg.Text = string.Empty; IResource res = GetCurrentResource(); IResourceTree treeItem = Helper.GetResourceTreeItemCollection().GetResourceTree(res.ResourceID); IReservation repair; var util = new RepairUtility(treeItem, CurrentUser, Provider); DateTime repairActualBeginDateTime, repairActualEndDateTime; string notes = txtNotes.Text; switch (e.CommandName) { case "start": var state = GetSelectedState(); repairActualBeginDateTime = GetRepairActualBeginDateTime(state); repairActualEndDateTime = GetRepairActualEndDateTime(state); repair = util.StartRepair(ContextBase, state, repairActualBeginDateTime, repairActualEndDateTime, notes); break; case "update": repairActualBeginDateTime = GetRepairActualBeginDateTime(res.State); repairActualEndDateTime = GetRepairActualEndDateTime(res.State); repair = util.UpdateRepair(repairActualEndDateTime, notes); break; case "end": repair = util.EndRepair(DateTime.Now); break; default: throw new InvalidOperationException($"Unknown command: {e.CommandName}"); } RefreshAndRedirect(res); } catch (Exception ex) { litErrMsg.Text = WebUtility.BootstrapAlert("danger", ex.Message, true); } }
private void LoadResourceStatus(IResource res) { if (res.HasState(ResourceState.Online)) { // Tool state is online ClearRepairBeginDateTime(); divRepairStart.Visible = true; divRepairTime.Visible = true; divRepairDuration.Visible = true; divStatusOptions.Visible = true; divStatusText.Visible = false; txtRepairStart.Text = "0"; txtRepairTime.Text = "0"; btnStartRepair.Visible = true; btnUpdateRepair.Visible = false; btnEndRepair.Visible = false; btnReset.Visible = true; } else if (res.HasState(ResourceState.Offline)) { // Tool state is offline var resource = Helper.GetResourceTreeItemCollection().GetResourceTree(res.ResourceID); var rip = Reservations.GetRepairInProgress(resource); IReservation rsv = null; if (rip != null) { rsv = Provider.Scheduler.Reservation.GetReservation(rip.ReservationID); } if (rsv != null) { //We found a repair offline reservation SetRepairBeginDateTime(rsv); divRepairStart.Visible = false; divRepairTime.Visible = true; divRepairDuration.Visible = false; divStatusOptions.Visible = false; divStatusText.Visible = true; litStatus.Text = "Offline"; txtRepairTime.Text = GetDuration(rsv).TotalHours.ToString("#0.00"); txtNotes.Text = rsv.Notes; btnStartRepair.Visible = false; btnUpdateRepair.Visible = true; btnEndRepair.Visible = true; btnReset.Visible = false; } else { //Something is wrong, the resource state is different from the reservation table btnReset.Visible = false; btnStartRepair.Visible = false; btnUpdateRepair.Visible = true; btnUpdateRepair.Enabled = false; btnEndRepair.Visible = true; litErrMsg.Text = WebUtility.BootstrapAlert("danger", @"A problem has occurred: This resource is currenlty offline but there is no active repair reservation to modify. Please click the ""End Repair"" button to put the resource back online - then you will be able to create a new repair reservation."); } } else if (res.HasState(ResourceState.Limited)) { //Tool state is limited ClearRepairBeginDateTime(); divRepairStart.Visible = false; divRepairTime.Visible = false; divRepairDuration.Visible = false; divStatusOptions.Visible = false; divStatusText.Visible = true; litStatus.Text = "Limited"; btnStartRepair.Visible = false; btnUpdateRepair.Visible = true; txtNotes.Text = res.StateNotes; btnReset.Visible = false; btnEndRepair.Visible = true; } else { //The state of tool is unknown, something is wrong Response.Redirect("~", false); } }