");
//heading
formBuilder.AppendLine("
");
//end of heading
//toggle panel
if (firstNote)
{
formBuilder.AppendLine("
");
firstNote = false;
}
else
{
formBuilder.AppendLine("
");
}
//build body of
formBuilder.AppendLine("
");
//build horizontal form
formBuilder.AppendLine("
");
formBuilder.AppendLine("
");
formBuilder.AppendLine("
");
formBuilder.AppendLine("
");
formBuilder.AppendLine("
");
formBuilder.AppendLine("
");
//end of body
formBuilder.AppendLine("
");
//end toggle panel
formBuilder.AppendLine("
");
//end of group
}
parentControl.InnerHtml = formBuilder.ToString();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
private string GetNextTaskNumber(string prefix)
{
string taskNumber = "";
try
{
oTaskNumber tskNum = new oTaskNumber();
foreach (oTaskNumber tNum in xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskNumber), "custCode,projCode,prefix", ddFilterCustomer.SelectedValue + "," + ddTaskProject.SelectedValue + "," + prefix, "prefix", "pal_", true))
{
tskNum = tNum;
break;
}
tskNum.prefix = prefix.ToUpper();
tskNum.lastNumberUsed += 1;
tskNum.custCode = ddFilterCustomer.SelectedValue;
tskNum.projCode = ddTaskProject.SelectedValue;
taskNumber = prefix + "-" + tskNum.lastNumberUsed;
if (tskNum.recId > 0)
{ xData.UpdateTyped("recId", tskNum.recId.ToString(), typeof(oTaskNumber), tskNum, "pal_", true); }
else
{ tskNum.recId = xData.SaveTyped("recId", typeof(oTaskNumber), tskNum, "pal_", true); }
return taskNumber;
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
return taskNumber;
}
}
private void PopulateTaskForm(oTask task)
{
try
{
divfTaskAttachments.Controls.Clear();
divfTaskAttachments.InnerHtml = "";
divfTaskNotes.Controls.Clear();
divfTaskNotes.InnerHtml = "";
if (task == null) //adding new task
{
//divNotes.Visible = false;
//btnAttachments.Visible = false;
divfLogCanvas.Visible = false;
divfFiles.Visible = false;
divfNotes.Visible = false;
oUser usr = new oUser();
if (utils.verifySession("user"))
{ usr = (oUser)Session["user"]; }
ddTaskInitiator.ClearSelection();
if (ddTaskInitiator.Items.FindByValue(usr.recId.ToString()) != null)
ddTaskInitiator.Items.FindByValue(usr.recId.ToString()).Selected = true;
ddTaskAssignee.ClearSelection();
if (ddTaskAssignee.Items.FindByValue(usr.recId.ToString()) != null)
ddTaskAssignee.Items.FindByValue(usr.recId.ToString()).Selected = true;
txtTaskCreatedDate.Text = System.DateTime.Now.ToString("dd/MM/yyyy");
ddTaskCategory.ClearSelection();
if (ddTaskCategory.Items.FindByValue(((int)pNums.TaskCategory.Scoping).ToString()) != null)
ddTaskCategory.Items.FindByValue(((int)pNums.TaskCategory.Scoping).ToString()).Selected = true;
//clear values
BindTaskType();
ddTaskType.ClearSelection();
if (ddTaskType.Items.FindByValue(((int)pNums.TaskType.ScopingNewFeature).ToString()) != null)
ddTaskType.Items.FindByValue(((int)pNums.TaskType.ScopingNewFeature).ToString()).Selected = true;
txtTaskName.Text = "";
txtTaskUpdatedDate.Text = "";
ddTaskStatus.ClearSelection(); ;
if (ddTaskStatus.Items.FindByValue(((int)pNums.TaskStatus.ToDo).ToString()) != null)
ddTaskStatus.Items.FindByValue(((int)pNums.TaskStatus.ToDo).ToString()).Selected = true;
txtTaskDueDate.Text = "";
txtTaskDescription.Text = "";
txtTaskNumber.Text = "";
ddTaskPriority.ClearSelection();
if (ddTaskPriority.Items.FindByValue(((int)pNums.TaskPriority.Major).ToString()) != null)
ddTaskPriority.Items.FindByValue(((int)pNums.TaskPriority.Major).ToString()).Selected = true;
divDates.Visible = false;
}
else //editing existing task
{
//divNotes.Visible = true;
//btnAttachments.Visible = true;
divfFiles.Visible = true;
divfNotes.Visible = true;
//if (this.Parent.Page.ToString().ToLower().Contains("canvas_aspx"))
if (handler.GetRoutedData("canvas-title") == "overlay")
{
divfLogCanvas.Visible = true;
divfTaskSnapshot.Visible = false;
}
else
{
if (task.canvasId == 0 || task.taskSnapshotId == 0)
{
divfLogCanvas.Visible = true;
divfTaskSnapshot.Visible = false;
}
else
{
divfLogCanvas.Visible = true;
divfTaskSnapshot.Visible = true;
}
}
ddTaskCategory.ClearSelection();
if (ddTaskCategory.Items.FindByValue(task.taskCategoryId.ToString()) != null)
{
ddTaskCategory.Items.FindByValue(task.taskCategoryId.ToString()).Selected = true;
BindTaskType();
}
ddTaskType.ClearSelection();
if (ddTaskType.Items.FindByValue(task.taskTypeId.ToString()) != null)
ddTaskType.Items.FindByValue(task.taskTypeId.ToString()).Selected = true;
txtTaskName.Text = task.name;
ddTaskProject.SelectedValue = task.projectCode;
ddTaskProject.Enabled = false; //project cannot be changed after task has been saved.
txtTaskCreatedDate.Text = task.createdDate.ToString("dd/MM/yyyy");
if (task.updatedDate != null && task.updatedDate.Year != 1900)
txtTaskUpdatedDate.Text = task.updatedDate.ToString("dd/MM/yyyy");
ddTaskInitiator.ClearSelection();
if (ddTaskInitiator.Items.FindByValue(task.initiatorUserId.ToString()) != null)
ddTaskInitiator.Items.FindByValue(task.initiatorUserId.ToString()).Selected = true;
ddTaskAssignee.ClearSelection();
if (ddTaskAssignee.Items.FindByValue(task.assigneeUserId.ToString()) != null)
ddTaskAssignee.Items.FindByValue(task.assigneeUserId.ToString()).Selected = true;
ddTaskStatus.ClearSelection();
if (ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()) != null)
ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()).Selected = true;
if (task.dueDate != null && task.dueDate.Year != 1900 && task.dueDate.Year != 1)
txtTaskDueDate.Text = task.dueDate.ToString("dd/MM/yyyy");
else
txtTaskDueDate.Text = "";
txtTaskDescription.Text = task.description;
txtTaskNumber.Text = task.taskNumber;
ddTaskPriority.ClearSelection();
if (task.taskPriorityId != 0)
{
if (ddTaskPriority.Items.FindByValue(task.taskPriorityId.ToString()) != null)
ddTaskPriority.Items.FindByValue(task.taskPriorityId.ToString()).Selected = true;
}
else
{
if (ddTaskPriority.Items.FindByValue(((int)pNums.TaskPriority.Major).ToString()) != null)
ddTaskPriority.Items.FindByValue(((int)pNums.TaskPriority.Major).ToString()).Selected = true;
}
divDates.Visible = true;
BindAttachments(task.recId, divfTaskAttachments);
BindNotes(task.recId, divfTaskNotes);
}
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
private void PopulateTaskView(oTask task)
{
try
{
//if (this.Parent.Page.ToString().ToLower().Contains("canvas_aspx"))
if (handler.GetRoutedData("canvas-title") == "overlay")
divvTaskSnapsnot.Visible = false;
else if (task.taskSnapshotId == 0 || task.canvasId == 0)
divvTaskSnapsnot.Visible = false;
else
divvTaskSnapsnot.Visible = true;
divfTaskAttachments.Controls.Clear();
divfTaskAttachments.InnerHtml = "";
divfTaskNotes.Controls.Clear();
divfTaskNotes.InnerHtml = "";
divfFiles.Visible = true;
divfNotes.Visible = true;
if (ddTaskCategory.Items.FindByValue(task.taskCategoryId.ToString()) != null)
lblvTaskCategory.Text = ddTaskCategory.Items.FindByValue(task.taskCategoryId.ToString()).Text;
if (ddTaskType.Items.FindByValue(task.taskTypeId.ToString()) != null)
lblvTaskType.Text = ddTaskType.Items.FindByValue(task.taskTypeId.ToString()).Text;
lblvTaskName.Text = task.name;
if (ddTaskProject.Items.FindByValue(task.projectCode.ToString()) != null)
lblvTaskProject.Text = ddTaskProject.Items.FindByValue(task.projectCode.ToString()).Text;
lblvTaskCreatedDate.Text = task.createdDate.ToString("dd/MM/yyyy");
if (task.updatedDate != null && task.updatedDate.Year != 1900)
lblvTaskUpdatedDate.Text = task.updatedDate.ToString("dd/MM/yyyy");
if (ddTaskInitiator.Items.FindByValue(task.initiatorUserId.ToString()) != null)
lblvTaskInitiator.Text = ddTaskInitiator.Items.FindByValue(task.initiatorUserId.ToString()).Text;
if (ddTaskAssignee.Items.FindByValue(task.assigneeUserId.ToString()) != null)
lblvTaskAssignee.Text = ddTaskAssignee.Items.FindByValue(task.assigneeUserId.ToString()).Text;
if (ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()) != null)
lblvTaskStatus.Text = ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()).Text;
if (task.dueDate != null && task.dueDate.Year != 1900 && task.dueDate.Year != 1)
lblvTaskDueDate.Text = task.dueDate.ToString("dd/MM/yyyy");
else
lblvTaskDueDate.Text = "";
lblvTaskDescription.Text = task.description;
lblvTaskNumber.Text = task.taskNumber;
if (ddTaskPriority.Items.FindByValue(task.taskPriorityId.ToString()) != null)
lblvTaskPriority.Text = ddTaskPriority.Items.FindByValue(task.taskPriorityId.ToString()).Text;
BindAttachments(task.recId, divvTaskAttachments);
BindNotes(task.recId, divvTaskNotes);
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
private void SaveFormValues(out oTask task, out oTaskHistory history, oUser usr)
{
task = new oTask();
history = new oTaskHistory();
try
{
task = new oTask();
task.customerCode = ddFilterCustomer.SelectedValue;
task.assigneeUserId = int.Parse(ddTaskAssignee.SelectedItem.Value);
task.canvasId = this.CanvasId;
task.createdDate = utils.formatStringToDate(txtTaskCreatedDate.Text);
task.description = txtTaskDescription.Text;
if (txtTaskDueDate.Text != "")
task.dueDate = utils.formatStringToDate(txtTaskDueDate.Text);
task.initiatorUserId = int.Parse(ddTaskInitiator.SelectedItem.Value);
task.name = txtTaskName.Text;
task.projectCode = ddTaskProject.SelectedItem.Value;
task.taskCategoryId = int.Parse(ddTaskCategory.SelectedItem.Value);
task.taskSnapshotId = this.SnapshotId;
task.taskSnapshotPosX = this.SnapshotX;
task.taskSnapshotPosY = this.SnapshotY;
task.taskStatusId = int.Parse(ddTaskStatus.SelectedItem.Value);
task.taskTypeId = int.Parse(ddTaskType.SelectedItem.Value);
if (this.Task != null)
task.updatedDate = System.DateTime.Now;
task.taskPriorityId = int.Parse(ddTaskPriority.SelectedItem.Value);
if (this.Task != null && this.Task.taskNumber != "")
{
//task number cannot be changed.
task.taskNumber = this.Task.taskNumber;
}
else
{
//GR TO DO:
//Add customer code and project code and task number
//get next task number for project prefix
string prefix = ddFilterCustomer.SelectedItem.Text.Substring(0, 3) + "-" + ddTaskProject.SelectedItem.Text.Substring(0, 3);
task.taskNumber = GetNextTaskNumber(prefix);
}
history = new oTaskHistory();
//if item is being updated, get current task as history, otherwise use new values as history add record
if (this.Task == null)
{
history.assigneeUserId = task.assigneeUserId;
history.canvasId = task.canvasId;
history.changeDate = System.DateTime.Now;
history.changeNum = 0; //new item
history.changeType = "ADD";
history.createdDate = task.createdDate;
history.description = task.description;
history.dueDate = task.dueDate;
history.initiatorUserId = task.initiatorUserId;
history.name = task.name;
history.customerCode = task.customerCode;
history.projectCode = task.projectCode;
history.taskCategoryId = task.taskCategoryId;
history.taskSnapshotId = task.taskSnapshotId;
history.taskSnapshotPosX = task.taskSnapshotPosX;
history.taskSnapshotPosY = task.taskSnapshotPosY;
history.taskStatusId = task.taskStatusId;
history.taskTypeId = task.taskTypeId;
history.updatedDate = task.updatedDate;
history.userId = usr.recId;
history.taskPriorityId = task.taskPriorityId;
history.taskNumber = task.taskNumber;
}
else
{
history.assigneeUserId = this.Task.assigneeUserId;
history.canvasId = this.Task.canvasId;
history.changeDate = System.DateTime.Now;
int changeNum = 1; //will be at least 1, add is 0
ArrayList maxChangeNumList = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "taskId", this.Task.recId.ToString(), "changeNum DESC", "pal_", true);
if (maxChangeNumList != null && maxChangeNumList.Count > 0)
{
oTaskHistory max = (oTaskHistory)maxChangeNumList[0];
changeNum = max.changeNum + 1;
}
history.changeNum = changeNum;
history.changeType = "CHANGE";
history.createdDate = this.Task.createdDate;
history.description = this.Task.description;
history.dueDate = this.Task.dueDate;
history.initiatorUserId = this.Task.initiatorUserId;
history.name = this.Task.name;
history.customerCode = this.Task.customerCode;
history.projectCode = this.Task.projectCode;
history.taskCategoryId = this.Task.taskCategoryId;
history.taskId = this.Task.recId;
history.taskSnapshotId = this.Task.taskSnapshotId;
history.taskSnapshotPosX = this.Task.taskSnapshotPosX;
history.taskSnapshotPosY = this.Task.taskSnapshotPosY;
history.taskStatusId = this.Task.taskStatusId;
history.taskTypeId = this.Task.taskTypeId;
history.updatedDate = this.Task.updatedDate;
history.userId = usr.recId;
history.taskPriorityId = this.Task.taskPriorityId;
history.taskNumber = this.Task.taskNumber;
}
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
private void TogglePanels(string panel)
{
switch (panel)
{
case "Grid":
pnlTaskGrid.Visible = true;
pnlTaskForm.Visible = false;
pnlTaskView.Visible = false;
//pnlTaskAttachments.Visible = false;
//pnlTaskNotes.Visible = false;
pnlTaskHistory.Visible = false;
break;
case "Form":
pnlTaskGrid.Visible = false;
pnlTaskForm.Visible = true;
pnlTaskView.Visible = false;
//pnlTaskAttachments.Visible = false;
//pnlTaskNotes.Visible = false;
pnlTaskHistory.Visible = false;
break;
case "View":
pnlTaskView.Visible = true;
pnlTaskGrid.Visible = false;
pnlTaskForm.Visible = false;
//pnlTaskAttachments.Visible = false;
//pnlTaskNotes.Visible = false;
pnlTaskHistory.Visible = false;
break;
//case "Attachments":
// pnlTaskView.Visible = false;
// pnlTaskGrid.Visible = false;
// pnlTaskForm.Visible = false;
// pnlTaskAttachments.Visible = true;
// pnlTaskNotes.Visible = false;
// pnlTaskHistory.Visible = false;
// break;
//case "Notes":
// pnlTaskView.Visible = false;
// pnlTaskGrid.Visible = false;
// pnlTaskForm.Visible = false;
// pnlTaskAttachments.Visible = false;
// pnlTaskNotes.Visible = true;
// pnlTaskHistory.Visible = false;
// break;
case "History":
pnlTaskView.Visible = false;
pnlTaskGrid.Visible = false;
pnlTaskForm.Visible = false;
//pnlTaskAttachments.Visible = false;
//pnlTaskNotes.Visible = false;
pnlTaskHistory.Visible = true;
break;
}
}
private void LoadPage()
{
try
{
string panel = this.ActivePanel;
if (panel == "Form")
PopulateTaskForm(this.Task);
else if (panel == "View")
PopulateTaskView(this.Task);
else if (panel == "Grid")
BindGrid();
else if (panel == "History")
BindHistoryGrid(this.Task);
TogglePanels(panel);
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
private void SendEmail(oTask task)
{
try
{
oEmail email = new oEmail();
string Subject = String.Empty;
string body = String.Empty;
foreach (oTemplate taskTemplate in xData.GetTypedByCriteriaSpecific("recId", typeof(oTemplate), "templateTypeId", pNums.TemplateType.OutboundResponse.GetHashCode().ToString()))
{
if (taskTemplate.templateName.ToLower().Contains("task"))
{
body = taskTemplate.templateContent;
Subject = taskTemplate.templateName;
break;
}
}
string project = "";
oUser initiator = new oUser();
oUser assignee = new oUser();
string status = "";
if (ddTaskProject.Items.FindByValue(task.projectCode.ToString()) != null)
project = ddTaskProject.Items.FindByValue(task.projectCode.ToString()).Text;
foreach (oUser assigUsr in xData.GetTypedByCriteriaSpecific("recId", typeof(oUser), "recId", task.assigneeUserId.ToString(), "surname", "pal_", true))
{
assignee = assigUsr;
break;
}
foreach (oUser initUsr in xData.GetTypedByCriteriaSpecific("recId", typeof(oUser), "recId", task.initiatorUserId.ToString(), "surname", "pal_", true))
{
initiator = initUsr;
break;
}
if (ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()) != null)
status = ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()).Text;
//merge internal body with values
body = body.Replace("src=\"/images", "src=\"" + ConfigurationManager.AppSettings["WebAddy"] + "/images");
body = body.Replace("{WebAddress}", ConfigurationManager.AppSettings["WebAddy"]);
body = body.Replace("{TaskNumber}", task.taskNumber);
body = body.Replace("{Project}", project);
body = body.Replace("{Subject}", task.name);
body = body.Replace("{Initiator}", initiator.name);
body = body.Replace("{Assignee}", assignee.name);
body = body.Replace("{Status}", status);
string toAddress = initiator.email;
if (toAddress == "")
toAddress = assignee.email;
else if (assignee.email != "")
toAddress += ";" + assignee.email;
if (toAddress == "")
throw new Exception("To address cannot be blank.");
email.fromAddress = ConfigurationManager.AppSettings["from"];
email.toAddress = toAddress;
email.Body = body;
email.Subject = ConfigurationManager.AppSettings["subject"].Replace("{content}", Subject);
communication.SendAnEmail(email);
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
}
}
private void LoadTaskOverlayPopup()
{
if (this.Task == null)
{
Response.Redirect("/home", false);
return;
}
//throw new Exception("Current task could not be determined.");
ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskSnapshot), "recId", this.Task.taskSnapshotId.ToString(), "", "pal_", true);
if (list == null || list.Count <= 0)
throw new Exception("Task snapshot could not be determined.");
oTaskSnapshot snap = (oTaskSnapshot)list[0];
if (snap.sourcePath != String.Empty)//get image from live stream
{
imgOverlay.ImageUrl = snap.sourcePath + "/upload/tasks/" + snap.fileName;
WebClient wc = new WebClient();
byte[] bytes = wc.DownloadData(snap.sourcePath + "/upload/tasks/" + snap.fileName);
MemoryStream ms = new MemoryStream(bytes);
using (System.Drawing.Image img = System.Drawing.Image.FromStream(ms))
{
divOverlayColour.Style.Add("Height", (img.Height + 20) + "px");
divOverlayColour.Style.Add("Width", (img.Width + 20) + "px");
divOverlayWrapper.Style.Add("Height", (img.Height + 20) + "px");
divOverlayWrapper.Style.Add("Width", (img.Width + 20) + "px");
divOverlayImg.Style.Add("Height", img.Height + "px");
divOverlayImg.Style.Add("Width", img.Width + "px");
imgOverlay.Height = img.Height;
imgOverlay.Width = img.Width;
}
ms.Close();
}
else
{
imgOverlay.ImageUrl = taskImagePath + snap.fileName;
using (System.Drawing.Image img = System.Drawing.Image.FromFile(System.Web.Hosting.HostingEnvironment.MapPath(taskImagePath) + snap.fileName))
{
divOverlayColour.Style.Add("Height", (img.Height + 20) + "px");
divOverlayColour.Style.Add("Width", (img.Width + 20) + "px");
divOverlayWrapper.Style.Add("Height", (img.Height + 20) + "px");
divOverlayWrapper.Style.Add("Width", (img.Width + 20) + "px");
divOverlayImg.Style.Add("Height", img.Height + "px");
divOverlayImg.Style.Add("Width", img.Width + "px");
imgOverlay.Height = img.Height;
imgOverlay.Width = img.Width;
}
}
//load image
//load tasks
int taskSeq = 0;
foreach (oTask task in xData.GetTypedByCriteriaSpecific("recId", typeof(oTask), "canvasId,taskSnapshotId", snap.canvasId + "," + snap.recId, "", "pal_", true))
{
int adjust = taskSeq * 85; //width of the div point
taskSeq++;
//get task assignee name
string assignee = "";
if (ddTaskAssignee.Items.FindByValue(task.assigneeUserId.ToString()) != null)
assignee = ddTaskAssignee.Items.FindByValue(task.assigneeUserId.ToString()).Text;
//get task status name
string statusDesc = "";
if (ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()) != null)
statusDesc = ddTaskStatus.Items.FindByValue(task.taskStatusId.ToString()).Text;
//divs are moving about 15 points for each one added (think to do with div position relative).
int left = task.taskSnapshotPosX - 35 - adjust;
int top = task.taskSnapshotPosY - 5;
HtmlGenericControl divPoint = new HtmlGenericControl();
divPoint.ID = "divTask" + task.recId;
if (task.recId == this.Task.recId)
divPoint.Attributes.Add("class", "taskPoint task-tooltip");
else
divPoint.Attributes.Add("class", "taskPointGray task-tooltip");
divPoint.Attributes.Add("style", "left:" + left + "px;top:" + top + "px");
//divPoint.Attributes.Add("title", task.name);
divPoint.Attributes.Add("data-toggle", "tooltip");
divPoint.Attributes.Add("data-html", "true");
divPoint.Attributes.Add("data-container", "#" + divOverlayWrapper.ClientID);
divPoint.Attributes.Add("data-placement", "auto top");
divPoint.Attributes.Add("title", "
Subject: " + task.name + "
Assignee: " + assignee + "
Status: " + statusDesc);
divPoint.InnerHtml = task.taskNumber == "" ? "NONE" : task.taskNumber;
divOverlayWrapper.Controls.Add(divPoint);
}
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myOverlayModal", "$('#modOverlay').modal();", true);
}
///
Dirk Strauss, 20 June 2016.
/// Functionality: Service Desk - Add functionality to toggle between Service Desk and Task
///
private void SetUserControlState()
{
if (this.Page.AppRelativeVirtualPath.Equals("~/Admin_Support.aspx"))
UserControlState = (int)ucState.ServiceDesk;
else
UserControlState = (int)ucState.Task;
}
///
Dirk Strauss, 20 June 2016.
/// Functionality: Service Desk - This method logic was originally in the Form_Load(). It sets up the user control as a Task.
/// It has been left unmodified.
///
private void PopulateTaskState(string panel)
{
lblTaskResult.Text = "";
lblTaskResult.Visible = false;
BindCustomers();
BindTaskCategory();
BindTaskType();
BindFilterTaskType();
BindProject();
BindUser();
BindTaskStatus();
BindTaskPriority();
if (panel == "Form")
PopulateTaskForm(this.Task);
else if (panel == "View")
PopulateTaskView(this.Task);
else if (panel == "Grid")
BindGrid();
if (utils.verifySession("user"))
{
oUser admin = (oUser)Session["user"];
if (admin.isSetup)
lnkProjects.Visible = true;
else
lnkProjects.Visible = false;
}
else
lnkProjects.Visible = false;
}
///
Dirk Strauss, 20 June 2016.
/// Functionality: Service Desk - Set up the user control as a Service Desk.
/// This code has been modified from the original which can be found in PopulateTaskState().
///
private void PopulateServiceDeskState(string panel)
{
lblTaskResult.Text = "";
lblTaskResult.Visible = false;
BindCustomers();
BindTaskCategory();
BindTaskType();
BindFilterTaskType();
BindProject();
BindUser();
BindTaskStatus();
BindTaskPriority();
if (panel == "Form")
PopulateTaskForm(this.Task);
else if (panel == "View")
PopulateTaskView(this.Task);
else if (panel == "Grid")
BindGrid();
if (utils.verifySession("user"))
{
oUser admin = (oUser)Session["user"];
if (admin.isSetup)
lnkProjects.Visible = true;
else
lnkProjects.Visible = false;
}
else
lnkProjects.Visible = false;
}
#endregion
#region events
///
/// Page Load Event
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!utils.verifySession("user") && !utils.verifySession("user"))
{
Response.Redirect("/home", false);
}
else
{
string panel = this.ActivePanel;
if (!IsPostBack)
{
if (UserControlState == (int)ucState.Undefined) // Service Desk - Dirk Strauss - 20 June 2016 - (Comment: Determine if the user control state has been set)
SetUserControlState();
if (UserControlState == (int)ucState.Task)
{// Service Desk - Dirk Strauss - 20 June 2016 - (Comment: Load the original Task State functionality)
PopulateTaskState(panel);
}
if (UserControlState == (int)ucState.ServiceDesk)
{// Service Desk - Dirk Strauss - 20 June 2016 - (Comment: Load the Service Desk State)
PopulateServiceDeskState(panel);
}
}
//LoadPage();
TogglePanels(panel);
}
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void lnkProjects_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("Admin_Projects.aspx", false);
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void ddTaskCategory_SelectedIndexChanged(object sender, EventArgs e)
{
BindTaskType();
}
protected void btnSaveTask_Click(object sender, EventArgs e)
{
try
{
oUser usr = new oUser();
if (utils.verifySession("user"))
{
usr = (oUser)Session["user"];
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "userAlert", "alert('No login detected. Operation aborted.');", true);
return;
}
oTask task = null;
oTaskHistory history = null;
SaveFormValues(out task, out history, usr);
if (this.Task == null)
{
task.recId = xData.SaveTyped("recId", typeof(oTask), task, "pal_", true);
history.taskId = task.recId;
history.recId = xData.SaveTyped("recId", typeof(oTaskHistory), history, "pal_", true);
}
else
{
task.recId = this.Task.recId;
xData.UpdateTyped("recId", task.recId.ToString(), typeof(oTask), task, "pal_", true);
history.recId = xData.SaveTyped("recId", typeof(oTaskHistory), history, "pal_", true);
}
txtTaskNumber.Text = task.taskNumber;
lblTaskResult.Text = "The task has been saved.";
lblTaskResult.Visible = true;
this.Task = task;
//btnAttachments.Visible = true;
divfTaskAttachments.Controls.Clear();
divfTaskAttachments.InnerHtml = "";
BindAttachments(task.recId, divfTaskAttachments);
divfFiles.Visible = true;
SendEmail(task);
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
//protected void btnAttachments_Click(object sender, EventArgs e)
//{
// try
// {
// if (this.Task == null)
// throw new Exception("Current task could not be determined.");
// //get last history item to link attachments to
// ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "taskId", this.Task.recId.ToString(), "changeNum DESC");
// if (list == null || list.Count <= 0)
// throw new Exception("No history records have been logged for task " + this.Task.recId + ".");
// int itemId = ((oTaskHistory)list[0]).recId;
// Session["moduleId"] = pNums.Module.Task.GetHashCode();
// Session["entityId"] = itemId;
// dynamic attachments = this.FindControl("attachments");
// attachments.ReloadControl();
// this.ActivePanel = "Attachments";
// TogglePanels("Attachments");
// }
// catch (Exception ex)
// {
// exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
// Response.Redirect("/error", false);
// }
//}
//protected void btnNotes_Click(object sender, EventArgs e)
//{
// try
// {
// if (this.Task == null)
// throw new Exception("Current task could not be determined.");
// //get last history item to link attachments to
// ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "taskId", this.Task.recId.ToString(), "changeNum DESC");
// if (list == null || list.Count <= 0)
// throw new Exception("No history records have been logged for task " + this.Task.recId + ".");
// int itemId = ((oTaskHistory)list[0]).recId;
// Session["noteModuleId"] = pNums.Module.Task.GetHashCode();
// Session["noteEntityId"] = itemId;
// dynamic notes = this.FindControl("notes");
// notes.ReloadControl();
// this.ActivePanel = "Notes";
// TogglePanels("Notes");
// }
// catch (Exception ex)
// {
// exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
// Response.Redirect("/error", false);
// }
//}
protected void btnCancelTask_Click(object sender, EventArgs e)
{
//if (this.Parent.Page.ToString().ToLower().Contains("canvas_aspx"))
if (handler.GetRoutedData("canvas-title") == "overlay")
{
Session["overlayCanvasId"] = this.CanvasId;
Response.Redirect("/pages/overlay", false);
}
else
{
lblTaskResult.Text = "";
lblTaskResult.Visible = false;
this.ActivePanel = "Grid";
LoadPage();
}
}
protected void btnEditTaskView_Click(object sender, EventArgs e)
{
try
{
lblTaskResult.Text = "";
lblTaskResult.Visible = false;
this.ActivePanel = "Form";
LoadPage();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void btnCloseTaskView_Click(object sender, EventArgs e)
{
//if (this.Parent.Page.ToString().ToLower().Contains("canvas_aspx"))
if (handler.GetRoutedData("canvas-title") == "overlay")
{
Session["overlayCanvasId"] = this.CanvasId;
Response.Redirect("/pages/overlay", false);
}
else
{
lblTaskResult.Text = "";
lblTaskResult.Visible = false;
this.ActivePanel = "Grid";
LoadPage();
}
}
//protected void btnCloseAttachments_Click(object sender, EventArgs e)
//{
// try
// {
// this.ActivePanel = "View";
// LoadPage();
// }
// catch (Exception ex)
// {
// exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
// Response.Redirect("/error", false);
// }
//}
//protected void btnCloseNotes_Click(object sender, EventArgs e)
//{
// try
// {
// this.ActivePanel = "View";
// LoadPage();
// }
// catch (Exception ex)
// {
// exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
// Response.Redirect("/error", false);
// }
//}
protected void lnkView_Click(object sender, EventArgs e)
{
try
{
if (sender.GetType() == typeof(LinkButton))
{
LinkButton lnkButton = (LinkButton)sender;
int taskId = int.Parse(((LinkButton)sender).CommandArgument);
ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTask), "recId", taskId.ToString(), "", "pal_", true);
oTask task = (oTask)list[0];
this.Task = task;
this.CanvasId = task.canvasId;
this.SnapshotId = task.taskSnapshotId;
this.SnapshotX = task.taskSnapshotPosX;
this.SnapshotY = task.taskSnapshotPosY;
this.ActivePanel = "View";
LoadPage();
}
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void btnNew_Click(object sender, EventArgs e)
{
try
{
this.Task = null;
this.CanvasId = 0;
this.SnapshotId = 0;
this.SnapshotX = 0;
this.SnapshotY = 0;
this.ActivePanel = "Form";
LoadPage();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void btnTaskHistoryBack_Click(object sender, EventArgs e)
{
try
{
this.ActivePanel = "View";
LoadPage();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void btnTaskLog_Click(object sender, EventArgs e)
{
try
{
this.ActivePanel = "History";
LoadPage();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void ddFilterAssignee_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindGrid();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void btnfAddFile_Click(object sender, EventArgs e)
{
if (handler.GetRoutedData("canvas-title") == "overlay")
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfFileModal", "$('#modAddFile').modal(); ResetTaskModalScrollPosition(); ", true);
else
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfFileModal", "$('#modAddFile').modal(); ", true);
}
protected void btnCloseFileModal_Click(object sender, EventArgs e)
{
if (this.Task == null)
{
Response.Redirect("/home", false);
return;
}
//throw new Exception("Current task could not be determined.");
BindAttachments(this.Task.recId, this.ActivePanel == "View" ? divvTaskAttachments : divfTaskAttachments);
BindNotes(this.Task.recId, this.ActivePanel == "View" ? divvTaskNotes : divfTaskNotes);
if (handler.GetRoutedData("canvas-title") == "overlay")
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfFileModalClose", "$('#modAddFile').modal('hide');", true);
else
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfFileModalClose", "$('.modal-backdrop').remove(); $('body').removeClass('modal-open');", true);
//ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfFileModalClose", "$('#modAddFile').modal('hide'); $('.modal-backdrop').remove(); $('body').removeClass('modal-open');", true);
if (ViewState["AttachmentAdded"] != null && ViewState["AttachmentAdded"].ToString() == "SendMail")
{
SendEmail(this.Task);
ViewState["AttachmentAdded"] = null;
}
}
protected void radUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
oAttachment Attachment = new oAttachment();
try
{
oUser usr = new oUser();
if (utils.verifySession("user"))
usr = (oUser)Session["user"];
else
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "userAlert", "alert('No user login detected. Operation aborted.');", true);
return;
}
if (this.Task == null)
{
Response.Redirect("/home", false);
return;
}
//throw new Exception("Current task could not be determined.");
//get last history item to link attachments to
ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "taskId", this.Task.recId.ToString(), "changeNum DESC", "pal_", true);
if (list == null || list.Count <= 0)
throw new Exception("No history records have been logged for task " + this.Task.recId + ".");
int itemId = ((oTaskHistory)list[0]).recId;
Attachment.entityId = itemId;
Attachment.moduleId = (int)pNums.Module.Task;
Attachment.typeId = e.File.ContentType.StartsWith("image") ? (int)pNums.AttachmentType.Image : (int)pNums.AttachmentType.Document;
string taskFolderName = "task/";
taskFolderName += this.Task.recId.ToString();
Attachment.folderName = taskFolderName;
/* CVH 2016-04-15 Add date and user */
int userId = usr.recId;
if (Attachment.recId > 0)
{
Attachment.userIdUpdated = userId;
Attachment.dateUpdated = System.DateTime.Now;
}
else
{
Attachment.userIdSaved = userId;
Attachment.dateSaved = System.DateTime.Now;
}
Attachment.display = e.File.FileName.Remove(e.File.FileName.LastIndexOf("."));
Attachment.fileName = Attachment.entityId + "_" + utils.RandomString(9, true) + e.File.FileName.Substring(e.File.FileName.LastIndexOf("."));
string imagePath = Server.MapPath("~/upload/" + Attachment.folderName + "/image/");
string thumbPath = Server.MapPath("~/upload/" + Attachment.folderName + "/thumb/");
string tempPath = Server.MapPath("~/upload/" + Attachment.folderName + "/temp/");
utils.validateFolder(imagePath);
utils.validateFolder(thumbPath);
utils.validateFolder(tempPath);
//upload file
e.File.SaveAs(tempPath + Attachment.fileName);
Attachment.sourcePath = ConfigurationManager.AppSettings["WebAddy"];
//resize and compress
utils.ResizeImage(tempPath + Attachment.fileName, imagePath, Attachment.fileName, 400, true);
//resize and crop
utils.ResizeCropImagePrecise(imagePath + Attachment.fileName, thumbPath, Attachment.fileName, 383, 264, false);
if (Attachment.recId > 0)
{
xData.UpdateTyped("recId", Attachment.recId.ToString(), typeof(oAttachment), Attachment, "pal_", true);
utils.disposeSession("Attachment");
}
else
{
Attachment.recId = xData.SaveTyped("recId", typeof(oAttachment), Attachment, "pal_", true);
if (Attachment.recId > 0)
{ }
}
//if attachment has been added, set ViewState so that email can be sent when close modal
ViewState["AttachmentAdded"] = "SendMail";
}
catch (Exception ex)
{
exception.HandleException("Attachments:", MethodBase.GetCurrentMethod().Name, ex, Session["attachment"]);
Response.Redirect("/error", false);
}
}
protected void btnfAddNotes_Click(object sender, EventArgs e)
{
txtNewNote.Text = "";
if (handler.GetRoutedData("canvas-title") == "overlay")
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfNoteModal", "$('#modAddNote').modal(); ResetTaskModalScrollPosition(); ", true);
else
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfNoteModal", "$('#modAddNote').modal();", true);
}
protected void radUploadNotes_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
oAttachment Attachment = new oAttachment();
try
{
if (this.Task == null)
{
Response.Redirect("/home", false);
return;
}
//throw new Exception("Current task could not be determined.");
oUser user = new oUser();
if (utils.verifySession("user"))
user = (oUser)Session["user"];
else
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "userAlert", "alert('No user login detected. Operation aborted.');", true);
return;
}
oNote note = new oNote();
if (ViewState["newNote"] == null)
{
//get last history item to link attachments to
ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "taskId", this.Task.recId.ToString(), "changeNum DESC", "pal_", true);
if (list == null || list.Count <= 0)
throw new Exception("No history records have been logged for task " + this.Task.recId + ".");
int itemId = ((oTaskHistory)list[0]).recId;
//save new note to link attachment to
note.caption = txtNewNote.Text;
note.dateSaved = System.DateTime.Now;
note.entityId = itemId;
note.isActive = true;
note.moduleId = (int)pNums.Module.Task;
note.title = user.name + " (" + utils.fixDate(System.DateTime.Now) + ")";
note.typeId = (int)pNums.NoteType.Task;
note.userIdSaved = user.recId;
note.recId = xData.SaveTyped("recId", typeof(oNote), note, "pal_", true);
ViewState["newNote"] = note;
}
else
{
note = (oNote)ViewState["newNote"];
}
Attachment.entityId = note.recId;
Attachment.moduleId = (int)pNums.Module.Notes;
Attachment.typeId = e.File.ContentType.StartsWith("image") ? (int)pNums.AttachmentType.Image : (int)pNums.AttachmentType.Document;
string taskFolderName = "note/";
taskFolderName += this.Task.recId.ToString();
Attachment.folderName = taskFolderName;
/* CVH 2016-04-15 Add date and user */
int userId = user.recId;
if (Attachment.recId > 0)
{
Attachment.userIdUpdated = userId;
Attachment.dateUpdated = System.DateTime.Now;
}
else
{
Attachment.userIdSaved = userId;
Attachment.dateSaved = System.DateTime.Now;
}
Attachment.display = e.File.FileName.Remove(e.File.FileName.LastIndexOf("."));
Attachment.fileName = Attachment.entityId + "_" + utils.RandomString(9, true) + e.File.FileName.Substring(e.File.FileName.LastIndexOf("."));
string imagePath = Server.MapPath("~/upload/" + Attachment.folderName + "/image/");
string thumbPath = Server.MapPath("~/upload/" + Attachment.folderName + "/thumb/");
string tempPath = Server.MapPath("~/upload/" + Attachment.folderName + "/temp/");
utils.validateFolder(imagePath);
utils.validateFolder(thumbPath);
utils.validateFolder(tempPath);
//upload file
e.File.SaveAs(tempPath + Attachment.fileName);
//resize and compress
utils.ResizeImage(tempPath + Attachment.fileName, imagePath, Attachment.fileName, 400, true);
//resize and crop
utils.ResizeCropImagePrecise(imagePath + Attachment.fileName, thumbPath, Attachment.fileName, 383, 264, false);
if (Attachment.recId > 0)
{
xData.UpdateTyped("recId", Attachment.recId.ToString(), typeof(oAttachment), Attachment, "pal_", true);
utils.disposeSession("Attachment");
}
else
{
Attachment.recId = xData.SaveTyped("recId", typeof(oAttachment), Attachment, "pal_", true);
if (Attachment.recId > 0)
{ }
}
}
catch (Exception ex)
{
exception.HandleException("Attachments:", MethodBase.GetCurrentMethod().Name, ex, Session["attachment"]);
Response.Redirect("/error", false);
}
}
protected void btnSaveNote_Click(object sender, EventArgs e)
{
try
{
oUser user = new oUser();
if (this.Task == null)
{
Response.Redirect("/home", false);
return;
//throw new Exception("Current task could not be determined.");
}
if (utils.verifySession("user"))
{
user = (oUser)Session["user"];
}
else
{
Response.Redirect("/home", false);
return;
//throw new Exception("Logged on user could not be determined.");
}
//if viewstate is null, no attachment has been linked to this note, and the note hasn't been saved yet, save it now
if (ViewState["newNote"] == null)
{
//get last history item to link attachments to
ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oTaskHistory), "taskId", this.Task.recId.ToString(), "changeNum DESC", "pal_", true);
if (list == null || list.Count <= 0)
throw new Exception("No history records have been logged for task " + this.Task.recId + ".");
int itemId = ((oTaskHistory)list[0]).recId;
oNote note = new oNote();
note.caption = txtNewNote.Text;
note.dateSaved = System.DateTime.Now;
note.entityId = itemId;
note.isActive = true;
note.moduleId = (int)pNums.Module.Task;
note.title = user.name + " (" + utils.fixDate(System.DateTime.Now) + ")";
note.typeId = (int)pNums.NoteType.Task;
note.userIdSaved = user.recId;
note.recId = xData.SaveTyped("recId", typeof(oNote), note, "pal_", true);
}
else
ViewState["newNote"] = null;
BindAttachments(this.Task.recId, this.ActivePanel == "View" ? divvTaskAttachments : divfTaskAttachments);
BindNotes(this.Task.recId, this.ActivePanel == "View" ? divvTaskNotes : divfTaskNotes);
SendEmail(this.Task);
if (handler.GetRoutedData("canvas-title") != "overlay")
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfNoteModalSave", "$('.modal-backdrop').remove(); $('body').removeClass('modal-open');", true);
}
catch (Exception ex)
{
exception.HandleException("Attachments:", MethodBase.GetCurrentMethod().Name, ex, Session["attachment"]);
Response.Redirect("/error", false);
}
}
protected void btnCancelNote_Click(object sender, EventArgs e)
{
if (this.Task == null)
{
Response.Redirect("/home", false);
return;
//throw new Exception("Current task could not be determined.");
}
BindAttachments(this.Task.recId, this.ActivePanel == "View" ? divvTaskAttachments : divfTaskAttachments);
BindNotes(this.Task.recId, this.ActivePanel == "View" ? divvTaskNotes : divfTaskNotes);
if (handler.GetRoutedData("canvas-title") != "overlay")
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myfNoteModalClose", "$('.modal-backdrop').remove();$('body').removeClass('modal-open');", true);
}
protected void ddFilterInitiator_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindGrid();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void ddFilterCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindProject();
BindGrid();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void ddFilterProject_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindGrid();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void ddFilterType_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindGrid();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void ddFilterStatus_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindGrid();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
protected void btnvTaskSnapshot_Click(object sender, EventArgs e)
{
try
{
LoadTaskOverlayPopup();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Click event to take snapshot
///
///
///
protected void btnfTaskSnapshot_Click(object sender, EventArgs e)
{
try
{
LoadTaskOverlayPopup();
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Iteam Data bound
///
///
///
protected void rptTasks_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
try
{
if (e.Item.ItemIndex != -1)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
/* CVH 2016-04-15 Set background of Status cell */
/*
1 To do - Pink
2 In progress - Yellow
3 To be tested - Orange
4 Release ready - Green
5 Reopened - Pink
6 Closed - Gray
7 On hold - Blue
*/
HtmlTableCell td = (HtmlTableCell)e.Item.FindControl("tdStatus");
if (td != null)
{
Label lblStatus = (Label)td.FindControl("lblStatus");
if (lblStatus != null)
{
string status = lblStatus.Text.ToUpper().Replace(" ", "");
if (status == pNums.TaskStatus.ToDo.ToString().ToUpper() || status == pNums.TaskStatus.Reopened.ToString().ToUpper())
td.BgColor = "#FC8D8D"; //pink
else if (status == pNums.TaskStatus.InProgress.ToString().ToUpper())
td.BgColor = "#FFFF73"; //yellow
else if (status == pNums.TaskStatus.ToBeTested.ToString().ToUpper())
td.BgColor = "#FFBC03"; //orange
else if (status == pNums.TaskStatus.ReleaseReady.ToString().ToUpper())
td.BgColor = "#8AD173"; //green
else if (status == pNums.TaskStatus.Closed.ToString().ToUpper())
td.BgColor = "#D1D1D1"; //gray
else if (status == pNums.TaskStatus.OnHold.ToString().ToUpper())
td.BgColor = "#5BC0DE"; //blue
}
}
}
}
}
catch (Exception ex)
{
exception.HandleException("Task:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
#endregion
}