Ejemplo n.º 1
0
        public static CustomValue GetValue(LoginUser loginUser, int customFieldID, int refID, bool createValue)
        {
            CustomValues values = new CustomValues(loginUser);

            values.LoadByFieldID(customFieldID, refID);

            if (values.IsEmpty)
            {
                CustomField field = CustomFields.GetCustomField(loginUser, customFieldID);
                values = new CustomValues(loginUser);
                CustomValue value = values.AddNewCustomValue();
                value.CustomFieldID = customFieldID;
                value.Value         = "";
                if (field.FieldType == CustomFieldType.PickList)
                {
                    string[] items = field.ListValues.Split('|');
                    if (items.Length > 0)
                    {
                        value.Value = items[0];
                    }
                }
                value.RefID = refID;
                if (createValue == false)
                {
                    return(value);
                }
                value.Collection.Save();
                values.LoadByFieldID(customFieldID, refID);
                return(values[0]);
            }
            else
            {
                return(values[0]);
            }
        }
Ejemplo n.º 2
0
        public static CustomValue GetCustomValue(LoginUser loginUser, int customValueID)
        {
            CustomValues customValues = new CustomValues(loginUser);

            customValues.LoadByCustomValueID(customValueID);
            if (customValues.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(customValues[0]);
            }
        }
Ejemplo n.º 3
0
        partial void BeforeRowEdit(CustomValue newValue)
        {
            CustomValue oldValue = CustomValues.GetCustomValue(LoginUser, newValue.CustomValueID);

            newValue.OrganizationID = LoginUser.OrganizationID;
            if (oldValue.Value == newValue.Value)
            {
                return;
            }
            CustomField customField = CustomFields.GetCustomField(LoginUser, newValue.CustomFieldID);
            string      format      = "Changed {0} from '{1}' to '{2}'.";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, customField.RefType, newValue.RefID, string.Format(format, customField.Name, oldValue.Value, newValue.Value));
        }
Ejemplo n.º 4
0
 public CustomValue(DataRow row, CustomValues customValues) : base(row, customValues)
 {
     _customValues = customValues;
 }
Ejemplo n.º 5
0
        public static string GetTicketProperties(LoginUser loginUser, int ticketID)
        {
            TicketsViewItem ticket = TicketsView.GetTicketsViewItem(loginUser, ticketID);

            if (ticket == null)
            {
                return("");
            }

            StringBuilder builder = new StringBuilder();

            builder.Append(@"<div style=""background-color: #EDF0F5; color: #004394; margin-bottom:10px; padding-left:5px; border: solid 1px #9FB0CF; font-size: 18px; font-weight: bold;"" class=""ui-corner-all"">Ticket Properties</div>");
            builder.Append(@"<table width=""100%"" cellpadding=""0"" cellspacing=""5"" border=""0"">");

            builder.Append("<tr>");
            builder.Append(GetColumn("Opened By", ticket.CreatorName));
            builder.Append(GetColumn("Opened On", ticket.DateCreated.ToString("g", loginUser.CultureInfo)));
            builder.Append("</tr>");

            builder.Append("<tr>");
            builder.Append(GetColumn("Last Modified By", ticket.ModifierName));
            builder.Append(GetColumn("Last Modified On", ticket.DateModified.ToString("g", loginUser.CultureInfo)));

            builder.Append("</tr>");

            builder.Append("<tr>");
            if (ticket.IsClosed)
            {
                builder.Append(GetColumn("Days Closed", ticket.DaysClosed.ToString()));
            }
            else
            {
                builder.Append(GetColumn("Days Opened", ticket.DaysOpened.ToString()));
            }

            builder.Append(GetColumn("Total Time Spent", DataUtils.MinutesToDisplayTime(Tickets.GetTicketActionTime(ticket.Collection.LoginUser, ticket.TicketID))));
            builder.Append("</tr>");


            if (ticket.IsClosed && ticket.DateClosed != null)
            {
                builder.Append("<tr>");
                if (ticket.CloserID != null)
                {
                    builder.Append(GetColumn("Closed By", ticket.CloserName));
                }
                builder.Append(GetColumn("Closed On", ((DateTime)ticket.DateClosed).ToString("g", loginUser.CultureInfo)));
                builder.Append("</tr>");
            }


            builder.Append("<tr>");
            builder.Append(GetColumn("Ticket Type", ticket.TicketTypeName));
            builder.Append(GetColumn("Assigned Group", ticket.GroupName));
            builder.Append("</tr>");

            builder.Append("<tr>");
            builder.Append(GetColumn("Status", ticket.Status));
            builder.Append(GetColumn("Product", ticket.ProductName));
            builder.Append("</tr>");

            builder.Append("<tr>");
            builder.Append(GetColumn("Severity", ticket.Severity));
            builder.Append(GetColumn("Reported Version", ticket.ReportedVersion));
            builder.Append("</tr>");

            builder.Append("<tr>");
            builder.Append(GetColumn("Assigned To", ticket.UserName));
            builder.Append(GetColumn("Resolved Version", ticket.SolvedVersion));
            builder.Append("</tr>");

            builder.Append("<tr>");
            builder.Append(GetColumn("Visible On Portal", ticket.IsVisibleOnPortal.ToString()));
            builder.Append(GetColumn("Knowledge Base", ticket.IsKnowledgeBase.ToString()));
            builder.Append("</tr>");

            CustomFields fields = new CustomFields(ticket.Collection.LoginUser);

            fields.LoadByTicketTypeID(ticket.OrganizationID, ticket.TicketTypeID);

            bool flag = false;

            foreach (CustomField field in fields)
            {
                flag = !flag;
                if (flag)
                {
                    builder.Append("<tr>");
                }

                CustomValue value;
                value = CustomValues.GetValue(ticket.Collection.LoginUser, field.CustomFieldID, ticket.TicketID);
                builder.Append(GetColumn(field.Name + "", value.Value));
                if (!flag)
                {
                    builder.Append("</tr>");
                }
            }
            if (flag)
            {
                builder.Append("</tr>");
            }
            builder.Append("</table>");

            return(builder.ToString());
        }