public CustomFieldCategoryProxy[] GetAllTypesCategories(ReferenceType refType) { CustomFieldCategories cats = new CustomFieldCategories(TSAuthentication.GetLoginUser()); cats.LoadByRefType(refType); return(cats.GetCustomFieldCategoryProxies()); }
public CustomFieldCategoryProxy[] GetCategoriesWithUserRights(ReferenceType refType, int?auxID) { CustomFieldCategories cats = new CustomFieldCategories(TSAuthentication.GetLoginUser()); cats.LoadByRefTypeWithUserRights(refType, auxID); return(cats.GetCustomFieldCategoryProxies()); }
public static string GetCustomFieldCategory(RestCommand command, int customFieldCategoryID) { CustomFieldCategory customFieldCategory = CustomFieldCategories.GetCustomFieldCategory(command.LoginUser, customFieldCategoryID); if (customFieldCategory.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(customFieldCategory.GetXml("CustomFieldCategory", true)); }
public void DeleteCategory(int categoryID) { if (!TSAuthentication.IsSystemAdmin) { return; } CustomFieldCategory cat = CustomFieldCategories.GetCustomFieldCategory(TSAuthentication.GetLoginUser(), categoryID); if (cat.OrganizationID != TSAuthentication.OrganizationID) { return; } cat.Delete(); cat.Collection.Save(); }
public static string GetCustomFieldCategories(RestCommand command) { CustomFieldCategories customFieldCategories = new CustomFieldCategories(command.LoginUser); customFieldCategories.LoadByOrganizationID(command.Organization.OrganizationID); if (command.Format == RestFormat.XML) { return(customFieldCategories.GetXml("CustomFieldCategories", "CustomFieldCategory", true, command.Filters)); } else { throw new RestException(HttpStatusCode.BadRequest, "Invalid data format"); } }
public CustomFieldCategoryProxy NewCategory(ReferenceType refType, int?auxID, string text, int productFamilyID) { if (!TSAuthentication.IsSystemAdmin) { return(null); } CustomFieldCategory cat = (new CustomFieldCategories(TSAuthentication.GetLoginUser()).AddNewCustomFieldCategory()); cat.Category = text.Trim(); cat.Position = CustomFieldCategories.GetMaxPosition(TSAuthentication.GetLoginUser(), refType, auxID) + 1; cat.OrganizationID = TSAuthentication.OrganizationID; cat.AuxID = auxID; cat.RefType = refType; if (productFamilyID != -1) { cat.ProductFamilyID = productFamilyID; } cat.Collection.Save(); return(cat.GetProxy()); }
public CategoryOrder SaveOrder(string data) { List <CategoryOrder> orders = JsonConvert.DeserializeObject <List <CategoryOrder> >(data); if (!TSAuthentication.IsSystemAdmin) { return(null); } CustomFields fields = new CustomFields(TSAuthentication.GetLoginUser()); fields.LoadByOrganization(TSAuthentication.OrganizationID); CustomFieldCategories cats = new CustomFieldCategories(TSAuthentication.GetLoginUser()); cats.LoadByOrganization(TSAuthentication.OrganizationID); int x = 0; foreach (CategoryOrder order in orders) { if (order.CatID != null) { cats.FindByCustomFieldCategoryID((int)order.CatID).Position = x; x++; } int y = 0; foreach (int fieldID in order.FieldIDs) { CustomField field = fields.FindByCustomFieldID(fieldID); field.Position = y; y++; field.CustomFieldCategoryID = order.CatID; } } fields.Save(); cats.Save(); return(null); }
public bool IsDuplicateCategory(int?categoryID, ReferenceType refType, int?auxID, string text) { text = text.Trim(); CustomFieldCategories cats = new CustomFieldCategories(TSAuthentication.GetLoginUser()); cats.LoadByRefType(refType, auxID); foreach (CustomFieldCategory item in cats) { if (categoryID != null && item.CustomFieldCategoryID == categoryID) { continue; } if (item.Category.Trim().ToLower() == text.ToLower()) { return(true); } } return(false); }
public CustomFieldCategoryProxy SaveCategory(int categoryID, string text, int productFamilyID) { if (!TSAuthentication.IsSystemAdmin) { return(null); } CustomFieldCategory cat = CustomFieldCategories.GetCustomFieldCategory(TSAuthentication.GetLoginUser(), categoryID); if (cat.OrganizationID != TSAuthentication.OrganizationID) { return(null); } cat.Category = text.Trim(); if (productFamilyID != -1) { cat.ProductFamilyID = productFamilyID; } else { cat.ProductFamilyID = null; } cat.Collection.Save(); return(cat.GetProxy()); }
public void LoadCustomControls(int width, int currentColumn, HtmlTableRow currentRow) { _customControls.Clear(); //Ticket ticket = (Ticket)Tickets.GetTicket(UserSession.LoginUser, ticketID); //if (ticket == null) return; CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, _refType, _auxID); int cols = 0; HtmlTableRow tr = null; if (currentRow != null) { cols = currentColumn; tr = currentRow; } //string labelTDClass = "label" + _columns.ToString() + "ColTD"; //string inputTDClass = "input" + _columns.ToString() + "ColTD"; string labelTDClass = "labelColTD"; string inputTDClass = "inputColTD"; foreach (CustomField field in fields) { if (field.CustomFieldCategoryID == null) { tr = AddCells(tr, field, labelTDClass, inputTDClass, width, ref cols); } } if (tr != null) { _table.Controls.Add(tr); } cols = 0; CustomFieldCategories cats = new CustomFieldCategories(UserSession.LoginUser); cats.LoadByRefType(_refType, _auxID); foreach (CustomFieldCategory cat in cats) { if (tr != null) { _table.Controls.Add(tr); } cols = 0; tr = new HtmlTableRow(); HtmlTableCell tdCat = new HtmlTableCell(); tdCat.InnerHtml = cat.Category; tdCat.Attributes.Add("style", "font-size: 1.5em;"); tdCat.Attributes.Add("colspan", _columns.ToString()); tr.Controls.Add(tdCat); _table.Controls.Add(tr); tr = null; foreach (CustomField field in fields) { if (field.CustomFieldCategoryID == cat.CustomFieldCategoryID) { tr = AddCells(tr, field, labelTDClass, inputTDClass, width, ref cols); } } } if (tr != null) { HtmlTableCell tdLabel = new HtmlTableCell(); tdLabel.InnerHtml = @"<div class=""tableLabelDiv""> </div>"; tdLabel.Attributes.Add("class", labelTDClass); tr.Controls.Add(tdLabel); HtmlTableCell tdInput = new HtmlTableCell(); tdInput.InnerHtml = " "; tdInput.Attributes.Add("class", inputTDClass); tr.Controls.Add(tdInput); _table.Controls.Add(tr); } }
private void LoadProperties(int organizationID) { lblProperties.Visible = true; Organizations organizations = new Organizations(UserSession.LoginUser); organizations.LoadByOrganizationID(organizationID); if (organizations.IsEmpty) { return; } Organization organization = organizations[0]; Users users = new Users(UserSession.LoginUser); string primaryUser = ""; if (organization.PrimaryUserID != null) { users.LoadByUserID((int)organization.PrimaryUserID); primaryUser = users.IsEmpty ? "" : users[0].LastName + ", " + users[0].FirstName; } lblProperties.Visible = organizations.IsEmpty; DataTable table = new DataTable(); table.Columns.Add("Name"); table.Columns.Add("Value"); string website = organization.Website; string link = ""; if (website != null) { if (website.IndexOf("http") < 0) { website = "http://" + website; } link = @"<a href=""" + website + @""" target=""OrganizationLink"">" + organization.Website + "</a>"; } table.Rows.Add(new string[] { "Name:", organization.Name }); table.Rows.Add(new string[] { "Website:", link }); table.Rows.Add(new string[] { "Description:", organization.Description }); table.Rows.Add(new string[] { "Service Agreement Expiration Date:", organization.SAExpirationDate == null ? "[None]" : ((DateTime)organization.SAExpirationDate).ToLongDateString() }); if (organization.SlaLevelID == null) { table.Rows.Add(new string[] { "Service Level Agreement:", "[None]" }); } else { SlaLevel level = SlaLevels.GetSlaLevel(UserSession.LoginUser, (int)organization.SlaLevelID); if (level != null) { table.Rows.Add(new string[] { "Service Level Agreement:", level.Name }); } } if (organizationID != UserSession.LoginUser.OrganizationID) { table.Rows.Add(new string[] { "Active:", organization.IsActive.ToString() }); if (UserSession.CurrentUser.IsSystemAdmin) { table.Rows.Add(new string[] { "API Enabled:", (organization.IsApiActive && organization.IsApiEnabled).ToString() }); table.Rows.Add(new string[] { "API Token:", organization.WebServiceID.ToString() }); table.Rows.Add(new string[] { "OrganizationID:", organization.OrganizationID.ToString() }); } } if (UserSession.CurrentUser.HasPortalRights) { table.Rows.Add(new string[] { "Portal Access:", organization.HasPortalAccess.ToString() }); } table.Rows.Add(new string[] { "Primary Contact:", primaryUser }); if (organization.DefaultSupportUserID != null) { User supportUser = Users.GetUser(UserSession.LoginUser, (int)organization.DefaultSupportUserID); table.Rows.Add(new string[] { "Default Support User:"******"Default Support User:"******"[None]" }); } if (organization.DefaultSupportGroupID != null) { Group supportGroup = (Group)Groups.GetGroup(UserSession.LoginUser, (int)organization.DefaultSupportGroupID); if (supportGroup != null) { table.Rows.Add(new string[] { "Default Support Group:", supportGroup.Name }); } else { table.Rows.Add(new string[] { "Default Support Group:", "[None]" }); } } else { table.Rows.Add(new string[] { "Default Support Group:", "[None]" }); } table.Rows.Add(new string[] { "Domains:", organization.CompanyDomains == null ? "[None Assigned]" : organization.CompanyDomains }); if (organization.SupportHoursMonth != 0) { table.Rows.Add(new string[] { "Support hours per month:", organization.SupportHoursMonth.ToString() }); } else { table.Rows.Add(new string[] { "Support hours per month:", "0" }); } CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, ReferenceType.Organizations); StringBuilder valueAsString = null; foreach (CustomField field in fields) { if (field.CustomFieldCategoryID != null) { continue; } CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, organizationID); switch (value.FieldType) { case CustomFieldType.Date: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("d", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() }); break; case CustomFieldType.Time: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("t", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() }); break; case CustomFieldType.DateTime: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("g", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() }); break; default: table.Rows.Add(new string[] { field.Name + ":", value.Value }); break; } } CustomFieldCategories cats = new CustomFieldCategories(UserSession.LoginUser); cats.LoadByRefType(ReferenceType.Organizations); StringBuilder builder = new StringBuilder(); string prop = "<div style=\"margin: 5px 5px 5px 15px; line-height: 20px;\"><span style=\"font-weight: bold;\">{0}: </span><span> {1}<br /></span></div>"; foreach (CustomFieldCategory cat in cats) { bool isExpanded = Settings.UserDB.ReadBool("Custom Cat Expanded (Customer) - " + cat.Category, false); string markerClass = isExpanded ? "ui-icon-triangle-1-s" : "ui-icon-triangle-1-e"; string displayClass = isExpanded ? "" : "ui-helper-hidden"; builder.Append("<div class=\"customfield-cat\"><span class=\"ui-icon " + markerClass + "\"></span><span class=\"caption\">" + cat.Category); builder.Append("</span></div><div class=\"ui-widget-content ts-separator " + displayClass + "\"></div>"); builder.Append("<div class=\"" + displayClass + "\">"); foreach (CustomField field in fields) { if (field.CustomFieldCategoryID != null && field.CustomFieldCategoryID == cat.CustomFieldCategoryID) { CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, organizationID); switch (value.FieldType) { case CustomFieldType.Date: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("d", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } builder.Append(string.Format(prop, field.Name, valueAsString.ToString())); break; case CustomFieldType.Time: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("t", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } builder.Append(string.Format(prop, field.Name, valueAsString.ToString())); break; case CustomFieldType.DateTime: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("g", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } builder.Append(string.Format(prop, field.Name, valueAsString.ToString())); break; default: builder.Append(string.Format(prop, field.Name, value.Value)); break; } } } builder.Append("</div>"); } litProperties.Text = builder.ToString(); rptProperties.DataSource = table; rptProperties.DataBind(); }