1781 lines
83 KiB
C#
1781 lines
83 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using SafeMobileLib;
|
|
using Telerik.WinControls.UI;
|
|
using Telerik.WinControls;
|
|
using Telerik.WinControls.UI.Docking;
|
|
using Dispatcher.maptab.UIClasses;
|
|
using Telerik.WinControls.Enumerations;
|
|
using Telerik.WinControls.Data;
|
|
using Telerik.WinControls.Export;
|
|
using System.IO;
|
|
|
|
namespace Safedispatch_4_0
|
|
{
|
|
public partial class TicketingUserControl : UserControl
|
|
{
|
|
private bool showCellBorders = false;
|
|
public MainForm2 parent;
|
|
//public static ConvertDT convDT;
|
|
private DBTicketingManager DBT = new DBTicketingManager(MainForm2.cfg.DB_IP, MainForm2.cfg.DB_schema, MainForm2.cfg.DB_user, MainForm2.cfg.DB_passwd, MainForm2.cfg.DB_port);
|
|
private DBuserManager DBU = new DBuserManager(MainForm2.cfg.DB_IP, MainForm2.cfg.DB_schema, MainForm2.cfg.DB_user, MainForm2.cfg.DB_passwd, MainForm2.cfg.DB_port);
|
|
|
|
private GridViewTemplate template;
|
|
public static Dictionary<Int32, User> dispatchersList = new Dictionary<Int32,User>();
|
|
public static Boolean isFilterLoaded = false;
|
|
|
|
public TicketingUserControl(MainForm2 mf2)
|
|
{
|
|
InitializeComponent();
|
|
|
|
// set theme for the Message Box
|
|
RadMessageBox.SetThemeName("TelerikMetroBlue");
|
|
|
|
#region THEMING
|
|
parent = mf2;
|
|
rgbFilters.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
|
|
rgbFilters.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
|
|
rgbFilters.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
|
|
/*
|
|
rgbFilters.GroupBoxElement.Header.ImagePrimitive.Image =
|
|
Utils.ChangeColor((Bitmap)Utils.ScaleImage(Dispatcher.Properties.Resources.h_filter, 24, 24), MainForm2.ButtonColor);*/
|
|
rgbColumns.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
|
|
rgbColumns.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
|
|
rgbColumns.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
|
|
|
|
rbNewTicket.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
|
|
|
|
labelReportName.ForeColor = MainForm2.DefaultForeColor;
|
|
pbReportType.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_tickets, MainForm2.ButtonColor);
|
|
|
|
pbClearStartTime.Image = pbClearEndTime.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.b_clear, MainForm2.ButtonColor);
|
|
|
|
btExportReport.ButtonElement.ButtonFillElement.BackColor = Color.White;
|
|
btExportReport.ButtonElement.TextElement.ForeColor = MainForm2.ButtonColor;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
rtbarTicketNumbers.Ranges.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
float min = rtbarTicketNumbers.Ranges[0].Start;
|
|
float max = rtbarTicketNumbers.Ranges[0].End;
|
|
|
|
// remove file descriptor for ticket number
|
|
ticketingGridView.FilterDescriptors.Remove("Ticket_id");
|
|
|
|
CompositeFilterDescriptor ticketNumberDescriptor = new CompositeFilterDescriptor();
|
|
ticketNumberDescriptor.FilterDescriptors.Add(new FilterDescriptor("Ticket_id", FilterOperator.IsGreaterThanOrEqualTo, min));
|
|
ticketNumberDescriptor.FilterDescriptors.Add(new FilterDescriptor("Ticket_id", FilterOperator.IsLessThanOrEqualTo, max));
|
|
ticketNumberDescriptor.LogicalOperator = FilterLogicalOperator.And;
|
|
|
|
// add the descriptor
|
|
ticketingGridView.FilterDescriptors.Add(ticketNumberDescriptor);
|
|
};
|
|
|
|
// remove all context menu options for the left panels
|
|
ContextMenuService menuService2 = this.radDock1.GetService<ContextMenuService>();
|
|
menuService2.ContextMenuDisplaying += delegate(object sender, ContextMenuDisplayingEventArgs e)
|
|
{
|
|
if (e.MenuType == ContextMenuType.DockWindow &&
|
|
e.DockWindow.DockTabStrip is DocumentTabStrip)
|
|
{
|
|
//remove the "Close" menu items
|
|
for (int i = 0; i < e.MenuItems.Count; i++)
|
|
e.MenuItems[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
|
}
|
|
};
|
|
|
|
// clear values for start and end dateTime pickers
|
|
rdpStartTime.SetToNullValue();
|
|
rdpEndTime.SetToNullValue();
|
|
|
|
// set different properties for the grid rows
|
|
this.ticketingGridView.TableElement.RowHeight = 43;
|
|
this.ticketingGridView.TableElement.GroupHeaderHeight = 38;
|
|
this.ticketingGridView.EnableAlternatingRowColor = true;
|
|
this.ticketingGridView.TableElement.GridViewElement.TableElement.AlternatingRowColor = Color.LightYellow;
|
|
this.ticketingGridView.MasterTemplate.AutoExpandGroups = true;
|
|
ticketingGridView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
|
|
this.ticketingGridView.EnableCustomSorting = true;
|
|
|
|
// remove border for grid
|
|
this.ticketingGridView.GridViewElement.DrawBorder = false;
|
|
this.ticketingGridView.GridViewElement.GroupPanelElement.DrawBorder = false;
|
|
|
|
|
|
CustomTicketColumn ctc = new CustomTicketColumn("MyTicket");
|
|
ctc.AllowResize = true;
|
|
ctc.Name = "MyTicket";
|
|
ctc.FieldName = "MyTicket";
|
|
ctc.MinWidth = 270;
|
|
ctc.MaxWidth = 700;
|
|
ctc.Width = 500;
|
|
ctc.HeaderText = MainForm2.returnLNGString("t_ticket");
|
|
ctc.HeaderTextAlignment = ContentAlignment.MiddleLeft;
|
|
ctc.SortOrder = RadSortOrder.Ascending;
|
|
|
|
this.ticketingGridView.Columns.Add(ctc);
|
|
this.ticketingGridView.Columns.Move(ctc.Index, 0);
|
|
|
|
//ticketingGridView.Columns["lastUpdate"].SortOrder = RadSortOrder.Descending;
|
|
//
|
|
/*
|
|
SortDescriptor descriptor = new SortDescriptor();
|
|
descriptor.PropertyName = "lastUpdate";
|
|
descriptor.Direction = ListSortDirection.Descending;
|
|
this.ticketingGridView.MasterTemplate.SortDescriptors.Add(descriptor);
|
|
*/
|
|
#region CELL CONDITIONAL FORMATING
|
|
GridViewColumn column = ticketingGridView.Columns["priority"];
|
|
ConditionalFormattingObject obj = new ConditionalFormattingObject("priority", ConditionTypes.Equal, MainForm2.returnLNGString("High"), "", false);
|
|
//obj.CellBackColor = Color.Red;
|
|
obj.CellForeColor = Color.Red;
|
|
obj.TextAlignment = ContentAlignment.MiddleCenter;
|
|
|
|
|
|
ConditionalFormattingObject obj2 = new ConditionalFormattingObject("priority", ConditionTypes.Equal, MainForm2.returnLNGString("Normal"), "", false);
|
|
//obj2.CellBackColor = Color.Yellow;
|
|
obj2.CellForeColor = Color.Green;
|
|
obj2.TextAlignment = ContentAlignment.MiddleCenter;
|
|
|
|
ConditionalFormattingObject obj3 = new ConditionalFormattingObject("priority", ConditionTypes.Equal, MainForm2.returnLNGString("Low"), "", false);
|
|
//obj3.CellBackColor = Color.Green;
|
|
obj3.CellForeColor = Color.Gray;
|
|
obj3.TextAlignment = ContentAlignment.MiddleCenter;
|
|
|
|
ConditionalFormattingObject obj4 = new ConditionalFormattingObject("priority", ConditionTypes.Equal, MainForm2.returnLNGString("Critical"), "", false);
|
|
obj4.CellFont = new Font(
|
|
new FontFamily("Segoe UI"),
|
|
12,
|
|
FontStyle.Bold,
|
|
GraphicsUnit.Pixel);
|
|
obj4.CellForeColor = Color.Red;
|
|
obj4.TextAlignment = ContentAlignment.MiddleCenter;
|
|
|
|
column.ConditionalFormattingObjectList.Add(obj);
|
|
column.ConditionalFormattingObjectList.Add(obj2);
|
|
column.ConditionalFormattingObjectList.Add(obj3);
|
|
column.ConditionalFormattingObjectList.Add(obj4);
|
|
#endregion
|
|
|
|
|
|
RadCheckedListDataItem radCheckedListDataItem7 = new RadCheckedListDataItem("Assigned" /*MainForm2.returnLNGString("t_Assigned")*/, true);
|
|
RadCheckedListDataItem radCheckedListDataItem8 = new RadCheckedListDataItem("Accepted" /*MainForm2.returnLNGString("t_Accepted")*/, true);
|
|
RadCheckedListDataItem radCheckedListDataItem9 = new RadCheckedListDataItem("In progress" /*MainForm2.returnLNGString("t_InProgress")*/, true);
|
|
RadCheckedListDataItem radCheckedListDataItem10 = new RadCheckedListDataItem("Completed"/*MainForm2.returnLNGString("t_Completed")*/, true);
|
|
RadCheckedListDataItem radCheckedListDataItem11 = new RadCheckedListDataItem("Rejected"/*MainForm2.returnLNGString("t_Rejected")*/, true);
|
|
RadCheckedListDataItem radCheckedListDataItem12 = new RadCheckedListDataItem("Overdue"/*MainForm2.returnLNGString("t_Overdue")*/, true);
|
|
|
|
this.rcbDropDownTicketStatus.Items.Add(radCheckedListDataItem7);
|
|
this.rcbDropDownTicketStatus.Items.Add(radCheckedListDataItem8);
|
|
this.rcbDropDownTicketStatus.Items.Add(radCheckedListDataItem9);
|
|
this.rcbDropDownTicketStatus.Items.Add(radCheckedListDataItem10);
|
|
this.rcbDropDownTicketStatus.Items.Add(radCheckedListDataItem11);
|
|
this.rcbDropDownTicketStatus.Items.Add(radCheckedListDataItem12);
|
|
|
|
|
|
|
|
// get all dispatchers and add them into a dictionary
|
|
List<User> dispatchers = DBU.getAllDispatcher();
|
|
foreach(User user in dispatchers)
|
|
{
|
|
dispatchersList.Add(user.Id, user);
|
|
}
|
|
|
|
//convDT = new ConvertDT();
|
|
|
|
RefreshGrid();
|
|
|
|
ContextMenuService menuService = this.radDock1.GetService<ContextMenuService>();
|
|
menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying;
|
|
//this disables the context menu
|
|
menuService.AllowActiveWindowListContextMenu = false;
|
|
menuService.AllowDocumentContextMenu = false;
|
|
menuService.AllowToolContextMenu = false;
|
|
|
|
//set language
|
|
documentWindowTicketing.Text = MainForm2.returnLNGString("tabTicketing");
|
|
rgbFilters.Text = MainForm2.returnLNGString("filters");
|
|
labelReportName.Text = MainForm2.returnLNGString("tabTicketing");
|
|
labelReportDetails.Text = MainForm2.returnLNGString("jtsDet");
|
|
radLabel12.Text = MainForm2.returnLNGString("subjectOrMessage");
|
|
radLabel4.Text = MainForm2.returnLNGString("ticketStatus");
|
|
radLabel6.Text = MainForm2.returnLNGString("createdFrom");
|
|
radLabel5.Text = MainForm2.returnLNGString("priorityFilters");
|
|
radLabel2.Text = MainForm2.returnLNGString("createdUntil");
|
|
radLabel3.Text = rcbHandledBy.Text = MainForm2.returnLNGString("handledBy");
|
|
radLabel1.Text = MainForm2.returnLNGString("ticketNumber");
|
|
rgbColumns.Text = MainForm2.returnLNGString("showHideColumns");
|
|
rbNewTicket.Text = MainForm2.returnLNGString("newTicket");
|
|
rtbSubjectFilter.NullText = rcbDropDownTicketStatus.NullText = rdpEndTime.NullText =
|
|
rdpStartTime.NullText = rcbDropDropDownHandledBy.NullText = MainForm2.returnLNGString("displayall");
|
|
btExportReport.Text = MainForm2.returnLNGString("exportFilteredTickets");
|
|
rcbDeleted.Text = MainForm2.returnLNGString("displayDeleted");
|
|
rcbExpired.Text = MainForm2.returnLNGString("displayOnlyExpired");
|
|
cbPriorityLow.Text = MainForm2.returnLNGString("Low");
|
|
cbPriorityHigh.Text = MainForm2.returnLNGString("High");
|
|
cbPriorityNormal.Text = MainForm2.returnLNGString("Normal");
|
|
cbPriorityCritical.Text = MainForm2.returnLNGString("Critical");
|
|
rcbTicket.Text = MainForm2.returnLNGString("t_ticket");
|
|
rcbCreatedBy.Text = MainForm2.returnLNGString("createdBy");
|
|
rcbPriority.Text = MainForm2.returnLNGString("priority");
|
|
rcbSharedWith.Text = MainForm2.returnLNGString("sharedWith");
|
|
rcbCreationTime.Text = MainForm2.returnLNGString("creationTime");
|
|
rcbStartTime.Text = MainForm2.returnLNGString("t_startTime");
|
|
rcbEndTime.Text = MainForm2.returnLNGString("endTime");
|
|
rcbAllocatedTime.Text = MainForm2.returnLNGString("dueDate");
|
|
rcbLastUpdate.Text = MainForm2.returnLNGString("lastUpdate");
|
|
|
|
ticketingGridView.Columns["ticketInfo"].HeaderText = MainForm2.returnLNGString("t_ticket");
|
|
ticketingGridView.Columns["created_by"].HeaderText = MainForm2.returnLNGString("createdBy");
|
|
ticketingGridView.Columns["imei"].HeaderText = MainForm2.returnLNGString("handledBy");
|
|
ticketingGridView.Columns["priority"].HeaderText = MainForm2.returnLNGString("priority");
|
|
ticketingGridView.Columns["start_time"].HeaderText = MainForm2.returnLNGString("t_startTime");
|
|
ticketingGridView.Columns["end_time"].HeaderText = MainForm2.returnLNGString("endTime");
|
|
ticketingGridView.Columns["lastUpdate"].HeaderText = MainForm2.returnLNGString("lastUpdate");
|
|
ticketingGridView.Columns["creation_time"].HeaderText = MainForm2.returnLNGString("createdOn");
|
|
ticketingGridView.Columns["specified_end_time"].HeaderText = MainForm2.returnLNGString("dueDate");
|
|
ticketingGridView.Columns["share_with"].HeaderText = MainForm2.returnLNGString("sharedWith");
|
|
}
|
|
|
|
|
|
private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e)
|
|
{
|
|
if (e.MenuType == ContextMenuType.DockWindow &&
|
|
e.DockWindow.DockTabStrip is DocumentTabStrip)
|
|
{
|
|
for (int i = 0; i < e.MenuItems.Count; i++)
|
|
e.MenuItems[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void btn_write_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
////open write job ticketing form
|
|
Form fc = Application.OpenForms["NewJobTicketingForm"];
|
|
if (fc != null)
|
|
fc.BringToFront();
|
|
else
|
|
{
|
|
NewJobTicketingForm ntf = new NewJobTicketingForm(this, SMSmode.New4Unit, "", "");
|
|
ntf.FormClosed += new FormClosedEventHandler(ntf_FormClosed);
|
|
ntf.Show();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Can't show new SMS form" + ex.ToString());
|
|
}
|
|
}
|
|
|
|
void ntf_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
}
|
|
|
|
public void SendSMS(string text, int sc_id, int sched_timegmt)
|
|
{
|
|
try
|
|
{
|
|
if ((MainForm2.VehIDHash[sc_id] != null) && (MainForm2.vehicleHT[MainForm2.VehIDHash[sc_id].ToString()] != null))
|
|
{
|
|
((Vehicle)MainForm2.vehicleHT[MainForm2.VehIDHash[sc_id].ToString()]).CheckPositionInSystem();
|
|
String Totrans = "#142#" + ((Vehicle)MainForm2.vehicleHT[MainForm2.VehIDHash[sc_id].ToString()]).GwandRadioID + "." + ((Vehicle)MainForm2.vehicleHT[MainForm2.VehIDHash[sc_id].ToString()]).IMEI + "#" + text + "#" + sched_timegmt + "#" +
|
|
MainForm2.userIDX + "#";
|
|
parent.Send_UDP_cmd(Totrans, 0, 0);
|
|
((Vehicle)MainForm2.vehicleHT[MainForm2.VehIDHash[sc_id].ToString()]).EventLists.Add(new Alarms(rep_type.SMSSEND, DateTime.Now, "", text));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Send SMS error on hash:" + ex.ToString());
|
|
}
|
|
}
|
|
|
|
public void SendSMSGroup(string text, int cps_id, int sched_timegmt)
|
|
{
|
|
try
|
|
{
|
|
String Totrans = "";
|
|
Int32 oldgatewayID = 0;
|
|
foreach (GatewayIDandIP obj in MainForm2.RadioListIP)
|
|
{
|
|
if (oldgatewayID != obj.GWID)
|
|
{
|
|
oldgatewayID = obj.GWID;
|
|
Totrans = "#144#" + obj.GWID + "." + obj.ID + "." + cps_id + "#" + text + "#" + sched_timegmt + "#";
|
|
parent.Send_UDP_cmd(Totrans, 0, 0);
|
|
}
|
|
}
|
|
Totrans = "#144#0.0." + cps_id + "#" + text + "#" + sched_timegmt + "#";
|
|
parent.Send_UDP_cmd(Totrans, 0, 0);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Send SMS Group error:" + ex.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
private void UpdateTicketNumberTrackList(int minTicketNumber, int maxTicketNumber, int ticketCount)
|
|
{
|
|
// save ranges
|
|
//TrackBarRangeCollection ranges = rtbarTicketNumbers.Ranges;
|
|
rtbarTicketNumbers.TrackBarMode = Telerik.WinControls.UI.TrackBarRangeMode.Range;
|
|
rtbarTicketNumbers.Minimum = minTicketNumber;
|
|
rtbarTicketNumbers.Maximum = maxTicketNumber;
|
|
|
|
int largeTicketTicks = (int)(maxTicketNumber / 5);
|
|
int smallTicketTicks = (int)(maxTicketNumber / 25);
|
|
|
|
rtbarTicketNumbers.LargeTickFrequency = largeTicketTicks == 0 ? 1 : largeTicketTicks;
|
|
rtbarTicketNumbers.SmallTickFrequency = smallTicketTicks == 0 ? 1 : smallTicketTicks;
|
|
|
|
rtbarTicketNumbers.Ranges[0].Start = minTicketNumber;
|
|
rtbarTicketNumbers.Ranges[0].End = maxTicketNumber;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Refresh the Ticketing grid in order to bring the new tickets
|
|
/// </summary>
|
|
public void RefreshGrid()
|
|
{
|
|
template = new GridViewTemplate();
|
|
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
|
|
//ticketingGridView.Rows.Clear();
|
|
List<String> handledByList = new List<string>();
|
|
|
|
// get all tickets from the DB
|
|
List<JobTickets> jtlist = DBT.getAllTickets(MainForm2.userLog, MainForm2.userIDX.ToString(), MainForm2.userType == USERTYPE.TicketingAdmin, rcbDeleted.Checked);
|
|
|
|
// hide or show hint panel if not records
|
|
if (jtlist.Count == 0)
|
|
panelNoEvents.Visible = true;
|
|
else
|
|
panelNoEvents.Visible = false;
|
|
|
|
int minTicketNumber = 0;
|
|
int maxTicketNumber = 0;
|
|
|
|
if(jtlist.Count > 0)
|
|
{
|
|
minTicketNumber = jtlist[0].Ticket_id;
|
|
maxTicketNumber = jtlist[0].Ticket_id;
|
|
}
|
|
|
|
foreach (JobTickets jtl in jtlist)
|
|
{
|
|
|
|
// save minimum ticket number
|
|
if (jtl.Ticket_id < minTicketNumber)
|
|
minTicketNumber = jtl.Ticket_id;
|
|
|
|
// save max ticket number
|
|
if (jtl.Ticket_id > maxTicketNumber)
|
|
maxTicketNumber = jtl.Ticket_id;
|
|
|
|
|
|
// split imeis list by comma in order to get the list of units
|
|
// to which the tickets were assigned
|
|
String[] splitHandledBy = jtl.Imei.Split(',');
|
|
foreach(String imei in splitHandledBy)
|
|
{
|
|
// see if the imei was already added
|
|
if (!handledByList.Contains(imei))
|
|
handledByList.Add(imei);
|
|
}
|
|
|
|
jtl.Priority = MainForm2.returnLNGString(jtl.Priority);
|
|
// add ticket to hash if newer
|
|
if (!MainForm2.jobTicketHT.Contains(jtl.Ticket_id))
|
|
MainForm2.jobTicketHT.Add(jtl.Ticket_id, jtl);
|
|
else
|
|
MainForm2.jobTicketHT[jtl.Ticket_id] = jtl;
|
|
|
|
// format the date time values to Culture format
|
|
if (jtl.Start_time_int > 0) jtl.Start_time = jtl.Start_time_int.GetRegionalFormat(MainForm2.is24hours, MainForm2.DayFirst);
|
|
jtl.Creation_time = jtl.Creation_time_int.GetRegionalFormat(MainForm2.is24hours, MainForm2.DayFirst);
|
|
if (jtl.End_time_int > 0) jtl.End_time = jtl.End_time_int.GetRegionalFormat(MainForm2.is24hours, MainForm2.DayFirst);
|
|
if (jtl.End_time_specified_int > 0) jtl.End_time_specified = jtl.End_time_specified_int.GetRegionalFormat(MainForm2.is24hours, MainForm2.DayFirst);
|
|
//if (MainForm2.is24hours)
|
|
//{
|
|
// if (MainForm2.DayFirst)
|
|
// {
|
|
// if (jtl.Start_time_int > 0) jtl.Start_time = convDT.GetDTLocalFromSeconds(jtl.Start_time_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// jtl.Creation_time = convDT.GetDTLocalFromSeconds(jtl.Creation_time_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// if (jtl.End_time_int > 0) jtl.End_time = convDT.GetDTLocalFromSeconds(jtl.End_time_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// if (jtl.End_time_specified_int > 0) jtl.End_time_specified = convDT.GetDTLocalFromSeconds(jtl.End_time_specified_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// }
|
|
// else
|
|
// {
|
|
// if (jtl.Start_time_int > 0) jtl.Start_time = convDT.GetDTLocalFromSeconds(jtl.Start_time_int).ToString("MM/dd/yyyy HH:mm:ss, ddd");
|
|
// jtl.Creation_time = convDT.GetDTLocalFromSeconds(jtl.Creation_time_int).ToString("MM/dd/yyyy HH:mm:ss, ddd");
|
|
// if (jtl.End_time_int > 0) jtl.End_time = convDT.GetDTLocalFromSeconds(jtl.End_time_int).ToString("MM/dd/yyyy HH:mm:ss, ddd");
|
|
// if (jtl.End_time_specified_int > 0) jtl.End_time_specified = convDT.GetDTLocalFromSeconds(jtl.End_time_specified_int).ToString("MM/dd/yyyy HH:mm:ss, ddd");
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// if (MainForm2.DayFirst)
|
|
// {
|
|
// if (jtl.Start_time_int > 0) jtl.Start_time = convDT.GetDTLocalFromSeconds(jtl.Start_time_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// jtl.Creation_time = convDT.GetDTLocalFromSeconds(jtl.Creation_time_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// if (jtl.End_time_int > 0) jtl.End_time = convDT.GetDTLocalFromSeconds(jtl.End_time_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// if (jtl.End_time_specified_int > 0) jtl.End_time_specified = convDT.GetDTLocalFromSeconds(jtl.End_time_specified_int).ToString("dd/MM/yyyy HH:mm:ss, ddd");
|
|
// }
|
|
// else
|
|
// {
|
|
// if (jtl.Start_time_int > 0) jtl.Start_time = convDT.GetDTLocalFromSeconds(jtl.Start_time_int).ToString("MM/dd/yyyy hh:mm:ss tt, ddd");
|
|
// jtl.Creation_time = convDT.GetDTLocalFromSeconds(jtl.Creation_time_int).ToString("MM/dd/yyyy hh:mm:ss tt, ddd");
|
|
// if (jtl.End_time_int > 0) jtl.End_time = convDT.GetDTLocalFromSeconds(jtl.End_time_int).ToString("MM/dd/yyyy hh:mm:ss tt, ddd");
|
|
// if (jtl.End_time_specified_int > 0) jtl.End_time_specified = convDT.GetDTLocalFromSeconds(jtl.End_time_specified_int).ToString("MM/dd/yyyy hh:mm:ss tt, ddd");
|
|
// }
|
|
//}
|
|
}
|
|
|
|
// set the data source of the ticketing grid
|
|
ticketingGridView.DataSource = null;
|
|
ticketingGridView.DataSource = jtlist;
|
|
|
|
// add handledBy list to the checkbox
|
|
rcbDropDropDownHandledBy.DataSource = handledByList;
|
|
|
|
|
|
|
|
// get all tickets log from the DB
|
|
List<JobTickets_log> jtllist = DBT.getAllTickets_log();
|
|
foreach(JobTickets_log jtl in jtllist)
|
|
{
|
|
// format the date time values to Culture format
|
|
|
|
jtl.Modified_date = (Convert.ToInt32(jtl.Modified_date)).GetRegionalFormat(MainForm2.is24hours, MainForm2.DayFirst);
|
|
//if (MainForm2.is24hours)
|
|
//{
|
|
// if (MainForm2.DayFirst)
|
|
// jtl.Modified_date = (Convert.ToInt32(jtl.Modified_date).GetDTLocalFromSeconds()).ToString("dd/MM/yyyy HH:mm:ss");
|
|
// else
|
|
// jtl.Modified_date = (Convert.ToInt32(jtl.Modified_date).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy HH:mm:ss");
|
|
//}
|
|
//else
|
|
//{
|
|
// if (MainForm2.DayFirst)
|
|
// jtl.Modified_date = (Convert.ToInt32(jtl.Modified_date).GetDTLocalFromSeconds()).ToString("dd/MM/yyyy hh:mm:ss tt");
|
|
// else
|
|
// jtl.Modified_date = (Convert.ToInt32(jtl.Modified_date).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy hh:mm:ss tt");
|
|
//}
|
|
|
|
// update the last time for the ticket, in the main hash table
|
|
if (MainForm2.jobTicketHT.Contains(jtl.Ticket_id))
|
|
{
|
|
((JobTickets)(MainForm2.jobTicketHT[jtl.Ticket_id])).lastUpdate = jtl.Modified_date;
|
|
((JobTickets)(MainForm2.jobTicketHT[jtl.Ticket_id])).lastUpdate70 = jtl.ModifiedDate70;
|
|
}
|
|
|
|
}
|
|
|
|
// set the data source of the child grid view
|
|
template.DataSource = null;
|
|
template.DataSource = jtllist;
|
|
|
|
#region UI STYLING
|
|
// hide row header
|
|
template.ShowColumnHeaders = true;
|
|
template.ShowRowHeaderColumn = false;
|
|
template.EnableSorting = true;
|
|
template.AllowColumnReorder = true;
|
|
template.AllowColumnHeaderContextMenu = false;
|
|
|
|
foreach (GridViewColumn col in template.Columns)
|
|
{
|
|
col.AllowSort = true;
|
|
col.AllowReorder = true;
|
|
col.AllowGroup = false;
|
|
col.MaxWidth = 20;
|
|
}
|
|
|
|
// add the ticket status transition image
|
|
TicketStatusTransitionColumn statusTransition = new TicketStatusTransitionColumn("TicketTransition");
|
|
statusTransition.Name = "TicketTransition";
|
|
statusTransition.FieldName = "TicketTransition";
|
|
statusTransition.MinWidth = 270;
|
|
statusTransition.MaxWidth = 270;
|
|
statusTransition.Width = 270;
|
|
statusTransition.HeaderText = "Ticket Status Transition";
|
|
statusTransition.HeaderTextAlignment = ContentAlignment.MiddleCenter;
|
|
statusTransition.AllowSort = false;
|
|
template.Columns.Add(statusTransition);
|
|
|
|
// hide some columns
|
|
template.Columns["Ticket_id"].IsVisible = false;
|
|
template.Columns["Imei"].IsVisible = false;
|
|
template.Columns["PreviousJobStatus"].IsVisible = false;
|
|
template.Columns["Job_status"].IsVisible = false;
|
|
template.Columns["ModifiedDate70"].IsVisible = false;
|
|
|
|
// style vehicle name
|
|
template.Columns["Vehicle_name"].Width = 200;
|
|
template.Columns["Vehicle_name"].MinWidth = 200;
|
|
template.Columns["Vehicle_name"].MaxWidth = 300;
|
|
template.Columns["Vehicle_name"].HeaderText = "Subscriber";
|
|
template.Columns["Vehicle_name"].TextAlignment = ContentAlignment.MiddleLeft;
|
|
template.Columns.Move(template.Columns["Vehicle_name"].Index, 0);
|
|
|
|
// style Job_status column
|
|
template.Columns["Ticket_id"].StretchVertically = true;
|
|
template.Columns["Ticket_id"].AllowResize = true;
|
|
template.Columns["Ticket_id"].AutoSizeMode = BestFitColumnMode.AllCells;
|
|
template.Columns["Ticket_id"].IsVisible = false;
|
|
|
|
// style Modified_date column
|
|
template.Columns["Modified_date"].Width = 200;
|
|
template.Columns["Modified_date"].MinWidth = 170;
|
|
template.Columns["Modified_date"].MaxWidth = 200;
|
|
template.Columns["Modified_date"].HeaderText = "Date";
|
|
template.Columns["Modified_date"].TextAlignment = ContentAlignment.MiddleCenter;
|
|
template.Columns.Move(template.Columns["Modified_date"].Index, 0);
|
|
#endregion
|
|
|
|
|
|
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
|
|
ticketingGridView.MasterTemplate.Templates.Add(template);
|
|
GridViewRelation relation = new GridViewRelation(ticketingGridView.MasterTemplate);
|
|
relation.ChildTemplate = template;
|
|
relation.RelationName = "Ticket";
|
|
relation.ParentColumnNames.Add("Ticket_id");
|
|
relation.ChildColumnNames.Add("Ticket_id");
|
|
relation.ChildTemplate.EnableSorting = true;
|
|
|
|
// add the relation between the Tickets and the Tickets Log datasources
|
|
ticketingGridView.Relations.Add(relation);
|
|
|
|
|
|
|
|
// update ticket number track bar filter
|
|
UpdateTicketNumberTrackList(minTicketNumber, maxTicketNumber, jtlist.Count);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Delete the selected job ticket which needs to be still ASSIGNED
|
|
/// </summary>
|
|
///
|
|
private void DeleteSelectedTicket()
|
|
{
|
|
try
|
|
{
|
|
int ticketIdToBeDeleted = (int)ticketingGridView.SelectedRows[0].Cells["ticket_id"].Value;
|
|
bool started = (!ticketingGridView.SelectedRows[0].Cells["status"].Value.ToString().Equals(SafeMobileLib.Utils.TicketingStatuses.ASSIGNED.ToString()));
|
|
RadMessageBox.SetThemeName("TelerikMetroBlue");
|
|
DialogResult dr = RadMessageBox.Show(String.Format(MainForm2.returnLNGString("t_delete_question"),ticketIdToBeDeleted.ToString()),
|
|
MainForm2.returnLNGString("t_Delete"), MessageBoxButtons.YesNo, RadMessageIcon.Question);
|
|
if (dr == DialogResult.Yes)
|
|
{
|
|
sqlResponse resp = DBT.delete_job_ticket_from_sd(ticketIdToBeDeleted, (MainForm2.userType == USERTYPE.TicketingAdmin || !started));
|
|
Utils.WriteLine("REsp " + resp.ToString(), ConsoleColor.Red);
|
|
RefreshGrid();
|
|
}
|
|
// remove ticket to hash if newer
|
|
if (MainForm2.jobTicketHT.ContainsKey(ticketIdToBeDeleted))
|
|
MainForm2.jobTicketHT.Remove(ticketIdToBeDeleted);
|
|
}
|
|
catch
|
|
{
|
|
RadMessageBox.Show("Please select a ticket", "Delete ticket", MessageBoxButtons.OK, RadMessageIcon.Question);
|
|
}
|
|
}
|
|
|
|
private void btn_delete_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Schedule the refresh of the grid after the APP Server had inserted the ticket into the DB
|
|
/// </summary>
|
|
public void StartRefresh()
|
|
{
|
|
RefreshGridTimer.Enabled = true;
|
|
RefreshGridTimer.Start();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Timer tick method used when the time expired
|
|
/// </summary>
|
|
private void RefreshGridTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
RefreshGrid();
|
|
RefreshGridTimer.Stop();
|
|
RefreshGridTimer.Enabled = false;
|
|
}
|
|
|
|
public void UpdateExpiredTickets(string listOfExpiredTickets)
|
|
{
|
|
string[] expiredTickets = listOfExpiredTickets.Split(',');
|
|
try
|
|
{
|
|
foreach (string expiredTicket in expiredTickets)
|
|
{
|
|
for (int contor = 0; contor < ticketingGridView.Rows.Count; contor++)
|
|
{
|
|
if (ticketingGridView.Rows[contor].Cells["ticket_id"].Value != null && ticketingGridView.Rows[contor].Cells["ticket_id"].Value.ToString() == expiredTicket)
|
|
{
|
|
ticketingGridView.Rows[contor].Cells["IsExpired"].Value = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Error on update expired tickets " + ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the TicketList as a result of a Ticket insertion
|
|
/// </summary>
|
|
/// <param name="ticket_id"></param>
|
|
/// <param name="status"></param>
|
|
/// <param name="ts"></param>
|
|
/// <param name="vehicle"></param>
|
|
public void UpdateTicketList(int ticket_id, string status, TicketingStatus ts, Vehicle vehicle)
|
|
{
|
|
|
|
Utils.WriteLine("FFFFFFFFFFFFFFFFFFFF", ConsoleColor.Red);
|
|
|
|
try
|
|
{
|
|
for (int contor = 0; contor < ticketingGridView.Rows.Count; contor++)
|
|
//foreach (DataforVehList obj2 in (List<DataforVehList>)vehiclesList.DataSource)
|
|
{
|
|
if (ticketingGridView.Rows[contor].Cells["ticket_id"].Value != null && ticketingGridView.Rows[contor].Cells["ticket_id"].Value.ToString() == ticket_id.ToString())
|
|
{
|
|
try
|
|
{
|
|
SM.Debug("Make the update for " + ticket_id.ToString() + " with new status" + status);
|
|
ticketingGridView.Rows[contor].Cells["status"].Value = status;
|
|
ticketingGridView.TableElement.Update(GridUINotifyAction.DataChanged);
|
|
ticketingGridView.Refresh();
|
|
string lastStatus = (template.Rows.Where(n => (int)n.Cells["ticket_id"].Value == ticket_id && n.Cells["Vehicle_name"].Value.ToString() == vehicle.busName)).LastOrDefault().Cells["Job_status"].Value.ToString();
|
|
GridViewRowInfo rowInfo = this.template.Rows.AddNew();
|
|
rowInfo.Cells["Ticket_id"].Value = ticket_id;
|
|
rowInfo.Cells["PreviousJobStatus"].Value = lastStatus;
|
|
rowInfo.Cells["Job_status"].Value = status;
|
|
rowInfo.Cells["Vehicle_name"].Value = vehicle.busName;
|
|
rowInfo.Cells["imei"].Value = vehicle.IMEI;
|
|
|
|
string timeFormat = "dd/MM/yyyy HH:mm:ss";
|
|
|
|
if (MainForm2.is24hours)
|
|
{
|
|
if (MainForm2.DayFirst)
|
|
timeFormat = "dd/MM/yyyy HH:mm:ss";
|
|
else
|
|
timeFormat = "MM/dd/yyyy HH:mm:ss";
|
|
}
|
|
else
|
|
{
|
|
if (MainForm2.DayFirst)
|
|
timeFormat = "dd/MM/yyyy hh:mm:ss tt";
|
|
else
|
|
timeFormat = "MM/dd/yyyy hh:mm:ss tt";
|
|
}
|
|
|
|
|
|
rowInfo.Cells["Modified_date"].Value = DateTime.Now.ToString(timeFormat);
|
|
if (ticketingGridView.Rows[contor].Cells["start_time"].Value == null && ts.Status != "Rejected")
|
|
ticketingGridView.Rows[contor].Cells["start_time"].Value = DateTime.Now.ToString(timeFormat);
|
|
if (ts.IsLastState == 1) ticketingGridView.Rows[contor].Cells["end_time"].Value = DateTime.Now.ToString(timeFormat);
|
|
|
|
|
|
// update the last update field
|
|
ticketingGridView.Rows[contor].Cells["lastUpdate"].Value = rowInfo.Cells["Modified_date"].Value;
|
|
//rowInfo.Cells[2].Value = DateTime.Now.ToString();
|
|
//if (ticketingGridView.Rows[contor].Cells[5].Value == null) ticketingGridView.Rows[contor].Cells[5].Value = DateTime.Now.ToString();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Error on change job ticket status " + ex.Message);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
//if (turnOFF) populateVehiclesList(vehicleListNames);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("ExLive2:" + ex.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Method used to style the text which will be displayed in the group header
|
|
/// </summary>
|
|
private void TicketingGridView_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
|
|
{
|
|
//e.FormatString = "" + e.Value + " has " + e.Group.ItemCount + " row(s).";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method used to style the group row in order to add image and change the height, bg and others
|
|
/// </summary>
|
|
private void TicketingGridView_ViewRowFormatting(object sender, RowFormattingEventArgs e)
|
|
{
|
|
//if (e.RowElement is GridGroupHeaderRowElement)
|
|
{
|
|
|
|
/*
|
|
if (e.RowElement.RowInfo.Index % 2 == 0)
|
|
e.RowElement.BackColor = Color.LightCyan;
|
|
else
|
|
e.RowElement.BackColor = Color.Thistle;
|
|
*/
|
|
/*
|
|
Utils.WriteLine("Row : " + e.RowElement.ViewInfo.CurrentIndex + " | " + e.RowElement.ViewInfo.CurrentRow.Index, ConsoleColor.Cyan);
|
|
|
|
e.RowElement.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.i_assigned, 24, 24);
|
|
e.RowElement.ImageAlignment = ContentAlignment.MiddleCenter;
|
|
e.RowElement.Size = new Size(e.RowElement.Size.Width, 45);
|
|
e.RowElement.ViewInfo.CurrentRow.Height = 45;
|
|
e.RowElement.Invalidate();
|
|
|
|
|
|
if (e.RowElement.IsCurrent)
|
|
{
|
|
|
|
e.RowElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
|
|
e.RowElement.BackColor = Color.FromArgb(0, 143, 227);
|
|
e.RowElement.DrawFill = true;
|
|
}
|
|
else
|
|
{
|
|
e.RowElement.DrawFill = false;
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Method to handle the styling of various cells inside the radGrid, including Group Items
|
|
/// </summary>
|
|
private void TicketingGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
|
|
{
|
|
// format Ticket Log table
|
|
if (e.Row is GridDataRowElement)
|
|
{
|
|
// increase row height
|
|
//e.Row.RowInfo.Height = 53;
|
|
|
|
if (e.Column.Name.Equals("MyTicket"))
|
|
{
|
|
e.CellType = typeof(CustomTicketColumn);
|
|
e.CellElement = new CustomTicketCellElement(e.Column, e.Row);
|
|
}
|
|
|
|
if (e.Column.Name.Equals("TicketTransition"))
|
|
{
|
|
e.CellType = typeof(TicketStatusTransitionColumn);
|
|
e.CellElement = new TicketStatusTransitionCellElement(e.Column, e.Row);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Hide or display grid columns with every checkbox tick.
|
|
/// </summary>
|
|
/// <param name="sender">Corresponding column checkbox</param>
|
|
private void ticketingColumn_StateChanged(object sender, StateChangedEventArgs args)
|
|
{
|
|
// check which checkbox generated this event and then set the column name
|
|
string columnName = "";
|
|
if ((RadCheckBox)sender == rcbTicket)
|
|
columnName = "MyTicket";
|
|
else if ((RadCheckBox)sender == rcbAllocatedTime)
|
|
columnName = "specified_end_time";
|
|
else if ((RadCheckBox)sender == rcbCreatedBy)
|
|
columnName = "created_by";
|
|
else if ((RadCheckBox)sender == rcbCreationTime)
|
|
columnName = "creation_time";
|
|
else if ((RadCheckBox)sender == rcbEndTime)
|
|
columnName = "end_time";
|
|
else if ((RadCheckBox)sender == rcbHandledBy)
|
|
columnName = "imei";
|
|
else if ((RadCheckBox)sender == rcbPriority)
|
|
columnName = "priority";
|
|
else if ((RadCheckBox)sender == rcbSharedWith)
|
|
columnName = "share_with";
|
|
else if ((RadCheckBox)sender == rcbStartTime)
|
|
columnName = "start_time";
|
|
else if ((RadCheckBox)sender == rcbLastUpdate)
|
|
columnName = "lastUpdate";
|
|
|
|
// show/hide selected column
|
|
this.ticketingGridView.Columns[columnName].IsVisible = args.ToggleState == ToggleState.On;
|
|
VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Format the cells for each cell or column
|
|
/// </summary>
|
|
/// <param name="e">Cell parameters including column, row, databound item</param>
|
|
private void ticketingGridView_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
|
|
{
|
|
|
|
|
|
GridCellElement cellElement = e.CellElement;
|
|
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
|
|
|
|
if (e.Row is GridViewDataRowInfo)
|
|
{
|
|
if (showCellBorders)
|
|
{
|
|
e.CellElement.ResetValue(GridDataCellElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local);
|
|
}
|
|
else
|
|
{
|
|
e.CellElement.DrawBorder = false;
|
|
}
|
|
}
|
|
|
|
/*
|
|
// change priority image according to the type
|
|
if (cellElement is GridDataCellElement && columnInfo.Name == "priority")
|
|
{
|
|
JobTickets jb = null;
|
|
if (e.Row.DataBoundItem is JobTickets)
|
|
{
|
|
cellElement.DrawText = false;
|
|
//cellElement.Text = "";
|
|
jb = (JobTickets)e.Row.DataBoundItem;
|
|
cellElement.BackgroundImageLayout = ImageLayout.Center;
|
|
|
|
// select icon from data bound
|
|
if (jb.Priority.Equals("High"))
|
|
cellElement.BackgroundImage = Utils.ScaleImage(global::Dispatcher.Properties.Resources.b_high, 25, 25);
|
|
else if (jb.Priority.Equals("Low"))
|
|
cellElement.BackgroundImage = Utils.ScaleImage(global::Dispatcher.Properties.Resources.b_low, 25, 25);
|
|
else
|
|
cellElement.BackgroundImage = Utils.ScaleImage(global::Dispatcher.Properties.Resources.b_medium, 25, 25);
|
|
}
|
|
}*/
|
|
/*
|
|
// change status image according to it's state
|
|
else if (cellElement is GridDataCellElement && columnInfo.Name == "status")
|
|
{
|
|
JobTickets jb = null;
|
|
if(e.Row.DataBoundItem is JobTickets)
|
|
{
|
|
jb = (JobTickets)e.Row.DataBoundItem;
|
|
if (jb.Status == "Assigned")
|
|
{
|
|
cellElement.BackgroundImage = Utils.ScaleImage(global::Dispatcher.Properties.Resources.i_assigned, 24,24);
|
|
cellElement.BackgroundImageLayout = ImageLayout.Center;
|
|
}
|
|
cellElement.Text = "";
|
|
}
|
|
}*/
|
|
|
|
// change priority image according to the type
|
|
if (cellElement is GridDataCellElement && columnInfo.Name == "share_with")
|
|
{
|
|
cellElement.Padding = new Padding(0, 0, 10, 0);
|
|
|
|
JobTickets jb = null;
|
|
if (e.Row.DataBoundItem is JobTickets)
|
|
{
|
|
jb = (JobTickets)e.Row.DataBoundItem;
|
|
|
|
// get the name of all dispatchers
|
|
string sharedWith = "";
|
|
|
|
if (jb.Share_with != null && jb.Share_with.Length > 0)
|
|
{
|
|
// split shared with based on the ;
|
|
String[] shared = jb.Share_with.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
|
foreach (string dispatcherID in shared)
|
|
{
|
|
// get dispatcher name if exists
|
|
if (dispatchersList.ContainsKey(Int32.Parse(dispatcherID)))
|
|
sharedWith += dispatchersList[Int32.Parse(dispatcherID)].UserName + ";";
|
|
else
|
|
sharedWith += dispatcherID + ";";
|
|
}
|
|
|
|
// remove last ; character
|
|
if (sharedWith.Length > 0 && sharedWith[sharedWith.Length - 1] == ';')
|
|
sharedWith = sharedWith.Substring(0, sharedWith.Length - 1);
|
|
|
|
// set text to the cell
|
|
cellElement.Text = sharedWith;
|
|
}
|
|
}
|
|
}
|
|
else if (cellElement is GridImageCellElement && columnInfo.Name == "scheduled")
|
|
{
|
|
|
|
if (e.Row.DataBoundItem is JobTickets)
|
|
{
|
|
string timeValue = "";
|
|
JobTickets jb = (JobTickets)e.Row.DataBoundItem;
|
|
|
|
DateTime scheduledTicketTime = (new DateTime(1970, 1, 1)).AddSeconds(jb.sched_timegmt);
|
|
|
|
|
|
string timeFormat = "dd/MM/yyyy HH:mm:ss";
|
|
|
|
if (MainForm2.is24hours)
|
|
{
|
|
if (MainForm2.DayFirst)
|
|
timeFormat = "dd/MM/yyyy HH:mm:ss";
|
|
else
|
|
timeFormat = "MM/dd/yyyy HH:mm:ss";
|
|
}
|
|
else
|
|
{
|
|
if (MainForm2.DayFirst)
|
|
timeFormat = "dd/MM/yyyy hh:mm:ss tt";
|
|
else
|
|
timeFormat = "MM/dd/yyyy hh:mm:ss tt";
|
|
}
|
|
|
|
timeValue = String.Format("{0:" + timeFormat + "}", scheduledTicketTime);
|
|
|
|
cellElement.DrawText = false;
|
|
if (jb.sched_timegmt > 0)
|
|
{
|
|
cellElement.BackgroundImageLayout = ImageLayout.Zoom;
|
|
cellElement.BackgroundImage = global::Dispatcher.Properties.Resources.schedule;
|
|
cellElement.Text = timeValue;
|
|
}
|
|
else
|
|
{
|
|
cellElement.BackgroundImage = global::Dispatcher.Properties.Resources.transparent;
|
|
cellElement.Text = "";
|
|
}
|
|
}
|
|
}
|
|
// change the way on which the DateTime is displayed
|
|
else if (cellElement is GridDataCellElement && (columnInfo.Name == "creation_time" || columnInfo.Name == "start_time"
|
|
|| columnInfo.Name == "end_time" || columnInfo.Name == "specified_end_time" || columnInfo.Name == "lastUpdate"))
|
|
{
|
|
Font font = new Font(
|
|
cellElement.Font.FontFamily,
|
|
10,
|
|
FontStyle.Bold,
|
|
GraphicsUnit.Pixel);
|
|
|
|
cellElement.ForeColor = Color.FromArgb(0x66, 0x66, 0x66);
|
|
cellElement.Font = font;
|
|
|
|
|
|
JobTickets jb = null;
|
|
if(e.Row.DataBoundItem is JobTickets)
|
|
{
|
|
string timeValue = "";
|
|
jb = (JobTickets)e.Row.DataBoundItem;
|
|
|
|
if (jb.Creation_time != null && jb.Creation_time.Length > 0 && columnInfo.Name == "creation_time")
|
|
{
|
|
timeValue = jb.Creation_time;
|
|
//cellElement.ForeColor = Color.FromArgb(0, 0, 0);
|
|
}
|
|
else if (jb.Start_time != null && jb.Start_time.Length > 0 && columnInfo.Name == "start_time")
|
|
{
|
|
timeValue = jb.Start_time;
|
|
//cellElement.ForeColor = Color.FromArgb(66, 66, 66);
|
|
}
|
|
else if (jb.End_time != null && jb.End_time.Length > 0 && columnInfo.Name == "end_time")
|
|
{
|
|
timeValue = jb.End_time;
|
|
//cellElement.ForeColor = Color.FromArgb(132, 132, 132);
|
|
}
|
|
else if (jb.lastUpdate != null && jb.lastUpdate.Length > 0 && columnInfo.Name == "lastUpdate")
|
|
{
|
|
cellElement.ForeColor = Color.FromArgb(0, 0, 0);
|
|
DateTime ticketTime = (new DateTime(1970, 1, 1)).AddSeconds(jb.lastUpdate70);
|
|
|
|
Int64 secondsDifference = (Int64)((DateTime.UtcNow.Subtract(ticketTime)).TotalSeconds);
|
|
if (secondsDifference < 60)
|
|
timeValue = MainForm2.returnLNGString("lessthan1minute");
|
|
else if (secondsDifference < 3600)
|
|
//timeValue = (secondsDifference / 60) + " minute" + ((secondsDifference / 60) > 1 ? "s" : "") + " ago";
|
|
timeValue = (secondsDifference / 60) + MainForm2.returnLNGString("minutesago");
|
|
else if (secondsDifference < 7200)
|
|
timeValue = MainForm2.returnLNGString("hourAgo");
|
|
else if (secondsDifference < 86400)
|
|
{
|
|
timeValue = string.Format(MainForm2.returnLNGString("hoursAgo"),(secondsDifference / 3660)) ;
|
|
cellElement.ForeColor = Color.FromArgb(0x66, 0x66, 0x66);
|
|
}
|
|
else
|
|
{
|
|
timeValue = string.Format(MainForm2.returnLNGString("daysAgo"), (secondsDifference / 86400));
|
|
cellElement.ForeColor = Color.FromArgb(0x66, 0x66, 0x66);
|
|
}
|
|
|
|
//timeValue = jb.lastUpdate;
|
|
|
|
}
|
|
else if (jb.End_time_specified != null && jb.End_time_specified.Length > 0 && columnInfo.Name == "specified_end_time")
|
|
{
|
|
timeValue = jb.End_time_specified;
|
|
|
|
// change color for an expired ticket
|
|
if (jb.IsExpired)
|
|
cellElement.ForeColor = Color.FromArgb(255, 0, 0);
|
|
}
|
|
|
|
|
|
if (timeValue!= null && timeValue.Length > 0)
|
|
{
|
|
// find spaces to add a new line between them
|
|
string[] split = timeValue.Split(' ');
|
|
if (split.Length == 4)
|
|
cellElement.Text = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
|
|
else if (split.Length == 3)
|
|
cellElement.Text = String.Format("{0}\n{1} {2}", split[0], split[1], split[2]);
|
|
else if (split.Length == 2)
|
|
cellElement.Text = String.Format("{0}\n{1}", split[0], split[1]);
|
|
else
|
|
cellElement.Text = timeValue;
|
|
}
|
|
}
|
|
}
|
|
else if (cellElement is GridDataCellElement && columnInfo.Name == "MyTicket")
|
|
{
|
|
cellElement.Padding = new Padding(10, 0, 0, 0);
|
|
cellElement.SetContent();
|
|
cellElement.ToolTipText = "";
|
|
|
|
JobTickets jb = null;
|
|
if (e.Row.DataBoundItem is JobTickets)
|
|
{
|
|
jb = (JobTickets)e.Row.DataBoundItem;
|
|
if (jb != null && jb.Imei.Length > 0)
|
|
{
|
|
|
|
// show tooltip for imei
|
|
foreach (String imei in jb.Imei.Split(','))
|
|
cellElement.ToolTipText = cellElement.ToolTipText + String.Format("{0}: {1}", imei, jb.Status) + System.Environment.NewLine;
|
|
}
|
|
}
|
|
}
|
|
|
|
// do not highlight the cell on which was clicked
|
|
if (e.CellElement.IsCurrent)
|
|
{
|
|
e.CellElement.IsCurrent = false;
|
|
}
|
|
|
|
// format Ticket Log table
|
|
if (e.CellElement.ViewTemplate.Parent != null)
|
|
{
|
|
/*
|
|
e.CellElement.BackColor = Color.FromArgb(193, 235,255);
|
|
e.CellElement.NumberOfColors = 1;
|
|
e.CellElement.DrawFill = true;
|
|
*/
|
|
|
|
e.CellElement.Size = new Size(55, e.CellElement.Size.Height);
|
|
|
|
if (cellElement is GridDataCellElement && columnInfo.Name == "Vehicle_name")
|
|
{
|
|
// bold the font
|
|
Font font = new Font(
|
|
cellElement.Font.FontFamily,
|
|
12,
|
|
FontStyle.Bold,
|
|
GraphicsUnit.Pixel);
|
|
cellElement.Font = font;
|
|
|
|
cellElement.Padding = new System.Windows.Forms.Padding(8,0,0,0);
|
|
JobTickets_log jb = null;
|
|
if (e.Row.DataBoundItem is JobTickets_log)
|
|
{
|
|
cellElement.DrawText = true;
|
|
//cellElement.Text = "";
|
|
jb = (JobTickets_log)e.Row.DataBoundItem;
|
|
|
|
/*
|
|
if (jb != null && jb.Job_status != null)
|
|
{
|
|
if (jb.Job_status.Equals("Assigned"))
|
|
{
|
|
//cellElement.Text = "DDERDDD: " + e.Row.Parent + " | " + e.RowIndex ;
|
|
}
|
|
}*/
|
|
}
|
|
}
|
|
|
|
else if (cellElement is GridDataCellElement && columnInfo.Name == "Job_status")
|
|
{
|
|
JobTickets_log jb = null;
|
|
if (e.Row.DataBoundItem is JobTickets_log)
|
|
{
|
|
cellElement.DrawText = true;
|
|
//cellElement.Text = "";
|
|
jb = (JobTickets_log)e.Row.DataBoundItem;
|
|
cellElement.BackgroundImageLayout = ImageLayout.Center;
|
|
|
|
|
|
cellElement.BackColor =
|
|
SafeMobileLib.Utils.TicketingStatuses.GetTicketStatusColor(jb.Job_status);
|
|
}
|
|
}
|
|
|
|
else if (cellElement is GridDataCellElement && columnInfo.Name == "Modified_date")
|
|
{
|
|
cellElement.Padding = new System.Windows.Forms.Padding(0, 0, 8, 0);
|
|
Font font = new Font(
|
|
cellElement.Font.FontFamily,
|
|
10,
|
|
FontStyle.Bold,
|
|
GraphicsUnit.Pixel);
|
|
|
|
cellElement.ForeColor = Color.DarkGray;
|
|
cellElement.Font = font;
|
|
}
|
|
|
|
else if (cellElement is GridDataCellElement && columnInfo.Name == "TicketTransition")
|
|
{
|
|
cellElement.Padding = new Padding(10, 0, 0, 0);
|
|
cellElement.SetContent();
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ticketingGridView_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
|
|
{
|
|
|
|
if (sender is GridImageCellElement)
|
|
{
|
|
GridImageCellElement cell = sender as GridImageCellElement;
|
|
if(cell.Text != null)
|
|
{
|
|
cell.AutoToolTip = true;
|
|
cell.ToolTipText = cell.Text;
|
|
return;
|
|
}
|
|
}
|
|
e.ToolTipText = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Format ChildCell Height and Padding to right
|
|
/// </summary>
|
|
private void ticketingGridView_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
|
|
{
|
|
// increase the row height of the childtable element
|
|
GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement;
|
|
if (cell != null)
|
|
{
|
|
cell.Margin = new Padding(200, 0, 0, 0);
|
|
cell.ChildTableElement.RowHeight = 53;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Filter tickets based on the priority selected by the user
|
|
/// </summary>
|
|
/// <param name="sender">CheckBox which was clicked by the user</param>
|
|
/// <param name="args"></param>
|
|
private void priorityCheckBox_StateChanged(object sender, StateChangedEventArgs args)
|
|
{
|
|
// clear all priority filters
|
|
ticketingGridView.FilterDescriptors.Remove("priority");
|
|
|
|
// add filters only for selected priorities
|
|
CompositeFilterDescriptor fileDescriptor = new CompositeFilterDescriptor();
|
|
if(cbPriorityLow.Checked)
|
|
fileDescriptor.FilterDescriptors.Add(new FilterDescriptor("priority", FilterOperator.IsEqualTo, MainForm2.returnLNGString(PriorityType.Low.ToString())));
|
|
if (cbPriorityNormal.Checked)
|
|
fileDescriptor.FilterDescriptors.Add(new FilterDescriptor("priority", FilterOperator.IsEqualTo, MainForm2.returnLNGString(PriorityType.Normal.ToString())));
|
|
if (cbPriorityHigh.Checked)
|
|
fileDescriptor.FilterDescriptors.Add(new FilterDescriptor("priority", FilterOperator.IsEqualTo, MainForm2.returnLNGString(PriorityType.High.ToString())));
|
|
if (cbPriorityCritical.Checked)
|
|
fileDescriptor.FilterDescriptors.Add(new FilterDescriptor("priority", FilterOperator.StartsWith, MainForm2.returnLNGString(PriorityType.Critical.ToString())));
|
|
fileDescriptor.FilterDescriptors.Add(new FilterDescriptor("priority", FilterOperator.IsEqualTo, global::Dispatcher.Properties.Resources.i_overdue));
|
|
fileDescriptor.LogicalOperator = FilterLogicalOperator.Or;
|
|
|
|
// add only if checkbox are checked = filters are added
|
|
if (fileDescriptor.FilterDescriptors.Count > 0)
|
|
this.ticketingGridView.FilterDescriptors.Add(fileDescriptor);
|
|
VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Filter tickets based on them start time [this value can be reset to none]
|
|
/// </summary>
|
|
/// <param name="sender">DateTime Picker which changed it's value</param>
|
|
private void rdpStartTime_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (rdpStartTime.Value > new DateTime(2015, 1, 1))
|
|
rdpEndTime.MinDate = rdpStartTime.Value;
|
|
|
|
// remove file descriptor for Start time
|
|
ticketingGridView.FilterDescriptors.Remove("creation_time");
|
|
|
|
// add only if date is older than 2015
|
|
if (rdpStartTime.Value > new DateTime(2015, 1, 1))
|
|
{
|
|
FilterDescriptor startFileDescriptor = new FilterDescriptor("creation_time", FilterOperator.IsGreaterThanOrEqualTo, rdpStartTime.Value);
|
|
this.ticketingGridView.FilterDescriptors.Add(startFileDescriptor);
|
|
}
|
|
else
|
|
// remove file descriptor for Start time
|
|
ticketingGridView.FilterDescriptors.Remove("creation_time");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Filter tickets based on them end time [this value can be reset to none]
|
|
/// </summary>
|
|
/// <param name="sender">DateTime Picker which changed it's value</param>
|
|
private void rdpEndTime_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
// remove file descriptor for Start time
|
|
ticketingGridView.FilterDescriptors.Remove("creation_time");
|
|
|
|
// add only if date is older than minimum date
|
|
if (rdpEndTime.Value > rdpEndTime.MinDate)
|
|
{
|
|
FilterDescriptor startFileDescriptor = new FilterDescriptor("creation_time", FilterOperator.IsLessThanOrEqualTo, rdpEndTime.Value);
|
|
this.ticketingGridView.FilterDescriptors.Add(startFileDescriptor);
|
|
}
|
|
else
|
|
// remove file descriptor for Start time
|
|
ticketingGridView.FilterDescriptors.Remove("creation_time");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Reset start and end DateTime Picker values in order to reset the filter on
|
|
/// Start and End time
|
|
/// </summary>
|
|
/// <param name="sender">PictureBox for which datetime should be reset</param>
|
|
private void pbClearTime_Click(object sender, EventArgs e)
|
|
{
|
|
// clear start time
|
|
if ((PictureBox)sender == pbClearStartTime)
|
|
rdpStartTime.SetToNullValue();
|
|
|
|
// clear end time
|
|
if((PictureBox)sender == pbClearEndTime)
|
|
rdpEndTime.SetToNullValue();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Filter tickets based on the selected imeis from the CheckBox drop down list
|
|
/// </summary>
|
|
private void rcbDropDropDownHandledBy_ItemCheckedChanged(object sender, RadCheckedListDataItemEventArgs e)
|
|
{
|
|
// clear all priority filters
|
|
ticketingGridView.FilterDescriptors.Remove("imei");
|
|
|
|
// add filters only if selected users
|
|
if (rcbDropDropDownHandledBy.CheckedItems.Count > 0)
|
|
{
|
|
// create a composite file descriptor with OR logic
|
|
CompositeFilterDescriptor fileDescriptor = new CompositeFilterDescriptor();
|
|
fileDescriptor.LogicalOperator = FilterLogicalOperator.Or;
|
|
// for each selected imei add a custom fildescriptor
|
|
foreach (RadListDataItem item in rcbDropDropDownHandledBy.CheckedItems)
|
|
{
|
|
fileDescriptor.FilterDescriptors.Add(new FilterDescriptor("imei", FilterOperator.Contains, item.Value.ToString()));
|
|
}
|
|
|
|
// add filter
|
|
this.ticketingGridView.FilterDescriptors.Add(fileDescriptor);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// filter tickets based on the selected statuses
|
|
/// </summary>
|
|
private void rcbDropDownTicketStatus_ItemCheckedChanged(object sender, RadCheckedListDataItemEventArgs e)
|
|
{
|
|
// clear all statuses filters
|
|
ticketingGridView.FilterDescriptors.Remove("status");
|
|
|
|
// add filters only if selected ticket statuses
|
|
if (rcbDropDownTicketStatus.CheckedItems.Count > 0)
|
|
{
|
|
// Create a composite file descriptor with OR logic
|
|
CompositeFilterDescriptor statusDescriptor = new CompositeFilterDescriptor();
|
|
statusDescriptor.LogicalOperator = FilterLogicalOperator.Or;
|
|
// for each selected status add a custom filedescroptor
|
|
foreach (RadListDataItem item in rcbDropDownTicketStatus.CheckedItems)
|
|
{
|
|
statusDescriptor.FilterDescriptors.Add(new FilterDescriptor("status", FilterOperator.Contains, item.Text.ToString()));
|
|
}
|
|
|
|
// add filter
|
|
this.ticketingGridView.FilterDescriptors.Add(statusDescriptor);
|
|
if (isFilterLoaded == true)
|
|
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rcbDropDownTicketStatus.Name, rcbDropDownTicketStatus.Text);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// filter tickets based on the subject or message
|
|
/// </summary>
|
|
private void rtbSubjectFilter_TextChanged(object sender, EventArgs e)
|
|
{
|
|
// clear all subject/message filters
|
|
ticketingGridView.FilterDescriptors.Remove("name");
|
|
ticketingGridView.FilterDescriptors.Remove("comment");
|
|
|
|
// add filters only if selected ticket statuses
|
|
if (rtbSubjectFilter.Text.Length > 0)
|
|
{
|
|
// Create a composite file descriptor with OR logic
|
|
CompositeFilterDescriptor statusDescriptor = new CompositeFilterDescriptor();
|
|
statusDescriptor.LogicalOperator = FilterLogicalOperator.Or;
|
|
|
|
// add filters for name and comment
|
|
statusDescriptor.FilterDescriptors.Add(new FilterDescriptor("name", FilterOperator.Contains, rtbSubjectFilter.Text));
|
|
statusDescriptor.FilterDescriptors.Add(new FilterDescriptor("comment", FilterOperator.Contains, rtbSubjectFilter.Text));
|
|
|
|
// add filter
|
|
this.ticketingGridView.FilterDescriptors.Add(statusDescriptor);
|
|
}
|
|
}
|
|
|
|
#region CHANGE NEW TICKET BG COLOR
|
|
private void rbNewTicket_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
//rbNewTicket.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColorOver; //Color.FromArgb(1, 146, 195);
|
|
}
|
|
|
|
private void rbNewTicket_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
//rbNewTicket.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
|
|
}
|
|
|
|
private void rbNewTicket_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
//rbNewTicket.ButtonElement.ButtonFillElement.BackColor = Color.FromArgb(47,201,252);
|
|
}
|
|
#endregion
|
|
|
|
private void ticketingGridView_CustomSorting(object sender, GridViewCustomSortingEventArgs e)
|
|
{
|
|
int descriptorIndex = -1;
|
|
|
|
// search the Ticket column and get it's descriptor Index
|
|
for (int i = 0; i < this.ticketingGridView.SortDescriptors.Count; i++)
|
|
{
|
|
if (ticketingGridView.SortDescriptors[i].PropertyName == "MyTicket")
|
|
{
|
|
descriptorIndex = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// custom sort the ticket column
|
|
if (descriptorIndex != -1)
|
|
{
|
|
// get data bound items for the two rows
|
|
JobTickets jt1 = e.Row1.DataBoundItem as JobTickets;
|
|
JobTickets jt2 = e.Row2.DataBoundItem as JobTickets;
|
|
|
|
// compare based on the ticket_id
|
|
int sortResult = jt1.Ticket_id.CompareTo(jt2.Ticket_id);
|
|
|
|
// invert result if set sort descriptor is descending
|
|
if (sortResult != 0)
|
|
{
|
|
if (this.ticketingGridView.SortDescriptors[descriptorIndex].Direction == ListSortDirection.Descending)
|
|
sortResult = -sortResult;
|
|
}
|
|
|
|
// set sort result
|
|
e.SortResult = sortResult;
|
|
}
|
|
// do not handle the sorting for other columns
|
|
else
|
|
e.Handled = false;
|
|
}
|
|
|
|
//private void rcbDeleted_ToggleStateChanged(object sender, StateChangedEventArgs args)
|
|
//{
|
|
// RefreshGrid();
|
|
//}
|
|
|
|
private void rcbExpired_ToggleStateChanged(object sender, StateChangedEventArgs args)
|
|
{
|
|
// clear all expired filters
|
|
ticketingGridView.FilterDescriptors.Remove("IsExpired");
|
|
|
|
if (rcbExpired.Checked)
|
|
{
|
|
FilterDescriptor filter = new FilterDescriptor();
|
|
filter.PropertyName = "IsExpired";
|
|
filter.Operator = FilterOperator.IsEqualTo;
|
|
filter.Value = "true";
|
|
filter.IsFilterEditor = true;
|
|
|
|
|
|
// add filter
|
|
this.ticketingGridView.FilterDescriptors.Add(filter);
|
|
}
|
|
VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
|
|
}
|
|
|
|
private void rcbDeleted_ToggleStateChanged(object sender, StateChangedEventArgs args)
|
|
{
|
|
RefreshGrid();
|
|
VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Intercept when a document window had changed it's state, on double click
|
|
/// or drag/drop, and set that it is not allowed to close/hide it
|
|
/// </summary>
|
|
private void radDock1_DockStateChanged(object sender, DockWindowEventArgs e)
|
|
{
|
|
e.DockWindow.ToolCaptionButtons = ToolStripCaptionButtons.None;
|
|
e.DockWindow.AllowedDockState = AllowedDockState.Docked | AllowedDockState.TabbedDocument;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Event handler for when the left tab panel needs to be docked/transfor in floating state.
|
|
/// This will cancel this event in order to prevent the stupid case with hiding the dock window
|
|
/// </summary>
|
|
private void radDock1_DockStateChanging(object sender, DockStateChangingEventArgs e)
|
|
{
|
|
e.Cancel = true;
|
|
}
|
|
|
|
private void ticketingGridView_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.ContextMenuProvider is GridHeaderCellElement)
|
|
{
|
|
|
|
}
|
|
|
|
else if (e.ContextMenuProvider is GridDataCellElement || e.ContextMenuProvider is LiveGridCellElement)
|
|
{
|
|
GridViewRowInfo row =
|
|
(e.ContextMenuProvider is LiveGridCellElement ?
|
|
((LiveGridCellElement)e.ContextMenuProvider).RowInfo as GridViewDataRowInfo :
|
|
((GridDataCellElement)e.ContextMenuProvider).RowInfo);
|
|
|
|
JobTickets jt = row.DataBoundItem as JobTickets;
|
|
|
|
if (jt != null)
|
|
{
|
|
|
|
RadDropDownMenu contextMenu = new RadDropDownMenu();
|
|
|
|
RadMenuItem itemTitle = new RadMenuItem(MainForm2.returnLNGString("t_ticket") + " #" + jt.Ticket_id);
|
|
itemTitle.Font = new Font(
|
|
//ticketSubjectElement.Font.FontFamily,
|
|
new FontFamily("SEGOE UI"),
|
|
12,
|
|
FontStyle.Bold,
|
|
GraphicsUnit.Pixel);
|
|
itemTitle.Enabled = false;
|
|
contextMenu.Items.Add(itemTitle);
|
|
|
|
RadMenuItem tmpItem5 = null;
|
|
//markasstolen
|
|
if ((!MainForm2.LimitedUser) && (MainForm2.radioType != RADIOTYPE.ATLAS) && (MainForm2.radioType != RADIOTYPE.TETRA) && (MainForm2.radioType != RADIOTYPE.CONECTPLUS))
|
|
{
|
|
// only assigned tickets can be deleted
|
|
//bool CanBeDeleted = jt.Status.Equals("Assigned");
|
|
bool CanBeDeleted = true;
|
|
|
|
// create context menu item according to it's status
|
|
tmpItem5 = new RadMenuItem(MainForm2.returnLNGString(CanBeDeleted ? "t_Delete" : "t_DeleteAssigned"));
|
|
tmpItem5.Font = new Font(
|
|
//ticketSubjectElement.Font.FontFamily,
|
|
new FontFamily("SEGOE UI"),
|
|
11,
|
|
CanBeDeleted ? FontStyle.Regular : FontStyle.Italic,
|
|
GraphicsUnit.Pixel);
|
|
|
|
// change font color according to the ticket status
|
|
tmpItem5.ForeColor = (CanBeDeleted ? Color.Black : Color.DarkGray);
|
|
itemTitle.Enabled = false;
|
|
tmpItem5.Click += delegate(object s, EventArgs e2)
|
|
{
|
|
if (CanBeDeleted)
|
|
DeleteSelectedTicket();
|
|
};
|
|
contextMenu.Items.Add(tmpItem5);
|
|
}
|
|
e.ContextMenu = contextMenu;
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("EXLive10:" + ex.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Change background color for the row according to its state and theme
|
|
/// </summary>
|
|
private void ticketingGridView_RowFormatting(object sender, RowFormattingEventArgs e)
|
|
{
|
|
e.RowElement.DrawFill = true;
|
|
e.RowElement.NumberOfColors = 1;
|
|
|
|
if (e.RowElement.IsSelected)
|
|
e.RowElement.BackColor = MainForm2.GridSelectedRow;
|
|
else
|
|
e.RowElement.BackColor = (e.RowElement.RowInfo.Index % 2 == 0 ? Color.White : MainForm2.GridAlternateRow);
|
|
}
|
|
|
|
private void btExportReport_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
SaveFileDialog sfd = new SaveFileDialog();
|
|
sfd.Filter = "Docx|*.docx";
|
|
sfd.Title = "Save all filtered tickets";
|
|
|
|
string dateTime = DateTime.Now.ToString();
|
|
dateTime = dateTime.Replace("/", "_");
|
|
dateTime = dateTime.Replace("\\", "_");
|
|
dateTime = dateTime.Replace(" ", "_");
|
|
dateTime = dateTime.Replace(":", ".");
|
|
|
|
sfd.FileName = String.Format(@"" + (MainForm2.radioType == RADIOTYPE.SIMOCO ? "Simoco" : MainForm2.radioType == RADIOTYPE.EXCERA ? "Excera" : "SafeMobile")
|
|
+ "_ticketing_{0}.docx", dateTime);
|
|
|
|
DialogResult dr = sfd.ShowDialog();
|
|
|
|
// If the file name is not an empty string open it for saving.
|
|
if (dr == System.Windows.Forms.DialogResult.OK
|
|
|| dr == System.Windows.Forms.DialogResult.Yes)
|
|
{
|
|
// We will need a file name for our output file (change to suit your machine):
|
|
string fileNameTemplate = sfd.FileName + (sfd.FileName.EndsWith(".docx") ? "" : ".docx"); //@"Invoice_{0}-{1:MM_dd_yy_HH.mm.ss}.docx";
|
|
|
|
// Grab a reference to the desired template
|
|
var doc = Novacode.DocX.Load(@"resource\templates\export_ticketing.docx");
|
|
|
|
doc.ReplaceText("%DATA%", String.Format("{0}", DateTime.Now.ToString()));
|
|
doc.ReplaceText("%COMPANY%", "Generated using " + (MainForm2.radioType == RADIOTYPE.SIMOCO ? "Simoco" : MainForm2.radioType == RADIOTYPE.EXCERA ? "Excera" : "SafeMobile")
|
|
+ " Dispatch");
|
|
|
|
#region Works
|
|
// get the empty template row
|
|
Novacode.Row emptyRow = doc.Tables[0].Rows[doc.Tables[0].RowCount - 1];
|
|
|
|
|
|
FontFamily centuryGothic = null;
|
|
try
|
|
{
|
|
centuryGothic = new FontFamily("Century Gothic");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Utils.WriteLine(ex.ToString(), ConsoleColor.Red);
|
|
}
|
|
|
|
FontFamily font = new FontFamily("Arial");
|
|
|
|
if (centuryGothic != null)
|
|
font = centuryGothic;
|
|
|
|
foreach (GridViewRowInfo groupRow in ticketingGridView.ChildRows)
|
|
{
|
|
if (groupRow.ChildRows.Count > 0)
|
|
{
|
|
foreach (GridViewRowInfo gridRow in groupRow.ChildRows)
|
|
{
|
|
|
|
JobTickets ticket = groupRow.DataBoundItem as JobTickets;
|
|
JobTickets_log ticket_log = gridRow.DataBoundItem as JobTickets_log;
|
|
// skip group headers and others UI elements withoug databound items
|
|
if (ticket == null)
|
|
continue;
|
|
|
|
// add a new empty row and then edit it
|
|
doc.Tables[0].InsertRow(emptyRow);
|
|
|
|
// get the new inserted row which is empty
|
|
Novacode.Row row = doc.Tables[0].Rows[doc.Tables[0].RowCount - 1];
|
|
int column = 0;
|
|
row.Cells[column++].Paragraphs[0].Append(ticket.Ticket_id + "").FontSize(9).Font(font);
|
|
|
|
using (MemoryStream ms = new MemoryStream())
|
|
{
|
|
Bitmap bmp = new Bitmap(100, 40);
|
|
using (Graphics g = Graphics.FromImage(bmp))
|
|
{
|
|
using (Brush brush = new SolidBrush(
|
|
SafeMobileLib.Utils.TicketingStatuses.GetTicketStatusColor(ticket_log.Job_status)))
|
|
{
|
|
g.FillRectangle(brush, 0, 0, 100, 40);
|
|
// Create font and brush.
|
|
Font drawFont = new Font(font, 9);
|
|
|
|
// Create point for upper-left corner of drawing.
|
|
PointF drawPoint = new PointF(7, 10);
|
|
|
|
// Draw string to screen.
|
|
g.DrawString(ticket_log.Job_status, drawFont, new SolidBrush(Color.FromArgb(213, 213, 213)), drawPoint);
|
|
}
|
|
|
|
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
|
// go to the begining of the picture
|
|
ms.Seek(0, SeekOrigin.Begin);
|
|
|
|
Novacode.Image img = doc.AddImage(ms); // Create image.
|
|
Novacode.Picture pic1 = img.CreatePicture(); // Create picture.
|
|
|
|
row.Cells[column++].Paragraphs[0].AppendPicture(pic1);
|
|
}
|
|
|
|
bmp.Dispose();
|
|
}
|
|
|
|
|
|
row.Cells[column++].Paragraphs[0].Append(ticket.Name).FontSize(9).Font(font);
|
|
row.Cells[column - 1].Paragraphs[0].Bold();
|
|
if (ticket.IsExpired)
|
|
row.Cells[column - 1].Paragraphs[0].Color(Color.FromArgb(255, 0, 0));
|
|
|
|
|
|
row.Cells[column++].Paragraphs[0].Append(ticket.Priority).FontSize(9).Font(font);
|
|
|
|
row.Cells[column++].Paragraphs[0].Append(ticket.Dispatcher).FontSize(9).Font(font);
|
|
row.Cells[column++].Paragraphs[0].Append(gridRow.Cells["imei"].Value.ToString()).FontSize(9).Font(font);
|
|
row.Cells[column - 1].Paragraphs[0].Bold();
|
|
row.Cells[column++].Paragraphs[0].Append(ticket_log.Modified_date).FontSize(9).Font(font);
|
|
row.Cells[column++].Paragraphs[0].Append(ticket.Start_time + " / " + ticket.End_time).FontSize(9).Font(font);
|
|
|
|
row.Cells[column++].Paragraphs[0].Append(ticket.End_time_specified).FontSize(8).Font(font);
|
|
row.Cells[column - 1].Paragraphs[0].Color(Color.FromArgb(255, 0, 0));
|
|
|
|
#region LAST UPDATED
|
|
String timeValue = "";
|
|
DateTime ticketTime = (new DateTime(1970, 1, 1)).AddSeconds(ticket.lastUpdate70);
|
|
|
|
Int64 secondsDifference = (Int64)((DateTime.UtcNow.Subtract(ticketTime)).TotalSeconds);
|
|
if (secondsDifference < 60)
|
|
timeValue = MainForm2.returnLNGString("lessthan1minute");
|
|
else if (secondsDifference < 3600)
|
|
timeValue = (secondsDifference / 60) + MainForm2.returnLNGString("minutesago");
|
|
else if (secondsDifference < 7200)
|
|
timeValue = MainForm2.returnLNGString("hourAgo");
|
|
else if (secondsDifference < 86400)
|
|
timeValue = string.Format(MainForm2.returnLNGString("hoursAgo"), (secondsDifference / 3660));
|
|
else
|
|
timeValue = string.Format(MainForm2.returnLNGString("daysAgo"), (secondsDifference / 86400));
|
|
row.Cells[column++].Paragraphs[0].Append(timeValue).FontSize(8).Font(font);
|
|
row.Cells[column - 1].Paragraphs[0].Color(Color.FromArgb(66, 66, 66));
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
// remove first row after the header because is an empty one
|
|
doc.Tables[0].RemoveRow(1);
|
|
#endregion
|
|
|
|
// Save as New filename:
|
|
doc.SaveAs(sfd.FileName);
|
|
|
|
// Open in word:
|
|
//Process.Start("WINWORD.EXE", "\"" + outputFileName + "\"");
|
|
|
|
parent.DisplayToast(MainForm2.returnLNGString("TicketExportSaved"), string.Format(MainForm2.returnLNGString("ticketSavedHTML"),fileNameTemplate,sfd.FileName));
|
|
}
|
|
}
|
|
|
|
#region CHANGE TABS BACKGROUND
|
|
private DockWindow oldDockWindow = null;
|
|
private void radDock1_ActiveWindowChanging(object sender, DockWindowCancelEventArgs e)
|
|
{
|
|
|
|
// reset the background icon for the previous tab
|
|
e.OldWindow.TabStripItem.BackColor = Color.White;
|
|
e.OldWindow.TabStripItem.DrawFill = true;
|
|
e.OldWindow.TabStripItem.NumberOfColors = 1;
|
|
|
|
// reset the background for the new window
|
|
e.NewWindow.TabStripItem.DrawFill = true;
|
|
e.NewWindow.TabStripItem.NumberOfColors = 1;
|
|
e.NewWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor;
|
|
|
|
// save old dock window
|
|
oldDockWindow = e.OldWindow;
|
|
}
|
|
|
|
private void radDock1_ActiveWindowChanged(object sender, DockWindowEventArgs e)
|
|
{
|
|
// reset the background icon for the previous tab
|
|
oldDockWindow.TabStripItem.BackColor = Color.White;
|
|
oldDockWindow.TabStripItem.DrawFill = true;
|
|
oldDockWindow.TabStripItem.NumberOfColors = 1;
|
|
|
|
|
|
e.DockWindow.TabStripItem.DrawFill = true;
|
|
e.DockWindow.TabStripItem.NumberOfColors = 1;
|
|
e.DockWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor;
|
|
}
|
|
#endregion
|
|
|
|
private void TicketingUserControl_Load(object sender, EventArgs e)
|
|
{
|
|
VisualSettings.loadUserVisualSettings(this.Name, this.rgbFilters, MainForm2.HashVal);
|
|
VisualSettings.loadUserVisualSettings(this.Name, this.rgbColumns, MainForm2.HashVal);
|
|
isFilterLoaded = true;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|