public void DeleteUser(int userID) { if (!UserSession.CurrentUser.IsSystemAdmin) { return; } Users.MarkUserDeleted(UserSession.LoginUser, userID); User user = Users.GetUser(UserSession.LoginUser, userID); string description = String.Format("{0} deleted user {1} ", UserSession.CurrentUser.FirstLastName, user.FirstLastName); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Delete, ReferenceType.Organizations, user.OrganizationID, description); Organization org = Organizations.GetOrganization(TSAuthentication.GetLoginUser(), user.OrganizationID); if (org.DefaultSupportUserID == user.UserID) { org.DefaultSupportUserID = null; org.Collection.Save(); } if (user.IsActive && org.ParentID == 1) { user.EmailCountToMuroc(false); } }
public void DeleteTask(int taskID) { Task task = Tasks.GetTask(UserSession.LoginUser, taskID); if (task.CreatorID != UserSession.CurrentUser.UserID && !UserSession.CurrentUser.IsSystemAdmin) { return; } TaskAssociations associations = new TaskAssociations(UserSession.LoginUser); associations.DeleteByReminderIDOnly(taskID); Tasks subtasks = new Tasks(UserSession.LoginUser); subtasks.LoadIncompleteByParentID(taskID); foreach (Task subtask in subtasks) { DeleteTask(subtask.TaskID); } if (task.ReminderID != null) { Data.Reminder reminder = Reminders.GetReminder(UserSession.LoginUser, (int)task.ReminderID); reminder.Delete(); reminder.Collection.Save(); } string description = String.Format("{0} deleted task {1} ", UserSession.CurrentUser.FirstLastName, task.Description); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Delete, ReferenceType.Tasks, taskID, description); task.Delete(); task.Collection.Save(); }
public void DeleteOrganizationProduct(int organizationProductID, bool bypass = true) { if (!UserSession.CurrentUser.IsSystemAdmin && bypass) { return; } try { OrganizationProducts organizationProducts = new OrganizationProducts(UserSession.LoginUser); organizationProducts.LoadByOrganizationProductID(organizationProductID); UserProducts userProducts = new UserProducts(UserSession.LoginUser); //userProducts.LoadByOrganizationProductAndVersionID(organizationProducts[0].OrganizationID, "hola", "adios"); userProducts.LoadByOrganizationProductAndVersionID(organizationProducts[0].OrganizationID, organizationProducts[0].ProductID, organizationProducts[0].ProductVersionID); userProducts.DeleteAll(); userProducts.Save(); organizationProducts.DeleteFromDB(organizationProductID); Product p = Products.GetProduct(TSAuthentication.GetLoginUser(), organizationProducts[0].ProductID); string description = String.Format("{0} deleted product association to {1} ", TSAuthentication.GetUser(TSAuthentication.GetLoginUser()).FirstLastName, p.Name); ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Delete, ReferenceType.Organizations, organizationProducts[0].OrganizationID, description); } catch (Exception ex) { DataUtils.LogException(UserSession.LoginUser, ex); } }
/// <summary> Log Message </summary> public static void LogMessage(ActionLogType logType, ReferenceType refType, int?refID, string message) { AuthenticationModel authentication = new AuthenticationModel(); LoginUser user = new LoginUser(authentication.UserID, authentication.OrganizationID); ActionLogs.AddActionLog(user, logType, refType, refID.HasValue ? refID.Value : 0, message); // 0 if no ID? }
public string SetAssetNotes(int assetID, string value) { LoginUser loginUser = TSAuthentication.GetLoginUser(); Asset o = Assets.GetAsset(loginUser, assetID); string description = String.Format("Changed Notes from \"{0}\" to \"{1}\".", o.Notes, value); o.Notes = value; o.DateModified = DateTime.UtcNow; o.ModifierID = loginUser.UserID; o.Collection.Save(); ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, description); return(value != "" ? value : "Empty"); }
public void RequestTicketUpdate(int ticketID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItem(UserSession.LoginUser, ticketID); if (ticket == null) { return; } EmailPosts.SendTicketUpdateRequest(UserSession.LoginUser, ticketID); string description = String.Format("{0} requested an update from {1} for {2}", UserSession.CurrentUser.FirstLastName, ticket.UserName, Tickets.GetTicketLink(UserSession.LoginUser, ticketID)); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, description); }
public void DeleteAttachment(int attachmentID) { //if (!UserSession.CurrentUser.IsSystemAdmin) return; try { string fileName = ModelAPI.AttachmentAPI.DeleteAttachment(attachmentID, AttachmentProxy.References.None); string description = String.Format("{0} deleted attachment {1}", UserSession.CurrentUser.FirstLastName, fileName); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Delete, ReferenceType.Attachments, attachmentID, description); } catch (Exception ex) { DataUtils.LogException(UserSession.LoginUser, ex); } }
public int SetAssetProductVersion(int assetID, int value, string oldName, string newName) { LoginUser loginUser = TSAuthentication.GetLoginUser(); Asset o = Assets.GetAsset(loginUser, assetID); o.ProductVersionID = value; o.DateModified = DateTime.UtcNow; o.ModifierID = loginUser.UserID; o.Collection.Save(); string description = String.Format("Changed Product Version from \"{0}\" to \"{1}\".", oldName, newName); ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, description); return(value); }
public ReminderProxy EditReminder(int?reminderID, ReferenceType refType, int refID, string description, DateTime dueDate, int userID) { Reminder reminder; if (reminderID == null) { string logdescription; reminder = (new Reminders(TSAuthentication.GetLoginUser())).AddNewReminder(); reminder.OrganizationID = TSAuthentication.OrganizationID; User reminderUser = (User)Users.GetUser(TSAuthentication.GetLoginUser(), userID); if (refType == ReferenceType.Tickets) { logdescription = String.Format("Added Reminder for {0} , for {1}", reminderUser.FirstLastName, Tickets.GetTicketLink(TSAuthentication.GetLoginUser(), refID)); } else { logdescription = String.Format("Added Reminder for {0}", reminderUser.FirstLastName); } ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Tickets, refID, logdescription); ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Users, userID, logdescription); } else { reminder = Reminders.GetReminder(TSAuthentication.GetLoginUser(), (int)reminderID); if (reminder.OrganizationID != TSAuthentication.OrganizationID) { return(null); } } User user = Users.GetUser(reminder.Collection.LoginUser, userID); if (user.OrganizationID != TSAuthentication.OrganizationID) { return(null); } reminder.Description = description; reminder.RefType = refType; reminder.RefID = refID; reminder.DueDate = dueDate; reminder.UserID = userID; reminder.HasEmailSent = false; reminder.Collection.Save(); return(reminder.GetProxy()); }
public void SignOut() { try { ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Users, TSAuthentication.UserID, "Logged out"); TSEventLog.WriteEvent(TSEventLogEventType.LogoutSuccess, HttpContext.Current.Request, TSAuthentication.GetLoginUser().GetUser(), TSAuthentication.GetLoginUser().GetOrganization()); } catch (Exception) { } HttpContext.Current.Response.Cookies["sl"].Value = null; HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName].Value = null; //HttpContext.Current.Session.Clear(); //HttpContext.Current.Session.Abandon(); FormsAuthentication.SignOut(); }
public void DeleteNote(int noteID) { Note note = Notes.GetNote(UserSession.LoginUser, noteID); if (note.CreatorID != UserSession.CurrentUser.UserID && !UserSession.CurrentUser.IsSystemAdmin) { return; } // delete attachments which point to this Note (Activity) string description = String.Format("{0} deleted note {1} ", UserSession.CurrentUser.FirstLastName, note.Title); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Delete, ReferenceType.Notes, noteID, description); note.Delete(); note.Collection.Save(); }
public int JunkAsset(int assetID, string comments) { LoginUser loginUser = TSAuthentication.GetLoginUser(); Asset o = Assets.GetAsset(loginUser, assetID); //Location 1=assigned (shipped), 2=warehouse, 3=junkyard o.Location = "3"; o.AssignedTo = null; DateTime now = DateTime.UtcNow; o.DateModified = now; o.ModifierID = loginUser.UserID; o.Collection.Save(); AssetHistory assetHistory = new AssetHistory(loginUser); AssetHistoryItem assetHistoryItem = assetHistory.AddNewAssetHistoryItem(); assetHistoryItem.AssetID = assetID; assetHistoryItem.OrganizationID = loginUser.OrganizationID; assetHistoryItem.ActionTime = DateTime.UtcNow; assetHistoryItem.ActionDescription = "Asset assigned to Junkyard"; assetHistoryItem.ShippedFrom = -1; assetHistoryItem.ShippedFromRefType = -1; assetHistoryItem.ShippedTo = -1; assetHistoryItem.RefType = -1; assetHistoryItem.TrackingNumber = string.Empty; assetHistoryItem.ShippingMethod = string.Empty; assetHistoryItem.ReferenceNum = string.Empty; assetHistoryItem.Comments = comments; assetHistoryItem.DateCreated = now; assetHistoryItem.Actor = loginUser.UserID; assetHistoryItem.DateModified = now; assetHistoryItem.ModifierID = loginUser.UserID; assetHistory.Save(); ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, "Junked asset."); return(assetID); }
public string SetAssetWarrantyExpiration(int assetID, object value) { LoginUser loginUser = TSAuthentication.GetLoginUser(); Asset o = Assets.GetAsset(loginUser, assetID); StringBuilder description = new StringBuilder(); if (o.WarrantyExpiration == null) { description.Append(String.Format("Changed Warranty Expiration from \"{0}\" to \"{1}\".", "Unassigned", ((DateTime)value).ToString(GetDateFormatNormal()))); } else { description.Append(String.Format("Changed Warranty Expiration from \"{0}\" to \"{1}\".", ((DateTime)o.WarrantyExpiration).ToString(GetDateFormatNormal()), ((DateTime)value).ToString(GetDateFormatNormal()))); } o.WarrantyExpiration = (DateTime)value; o.DateModified = DateTime.UtcNow; o.ModifierID = loginUser.UserID; o.Collection.Save(); ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, description.ToString()); return(value.ToString() != "" ? value.ToString() : null); }
private void ProcessTaskAssigned(int taskID, int modifierID) { TasksViewItem task = TasksView.GetTasksViewItem(LoginUser, taskID); try { User modifier = Users.GetUser(LoginUser, modifierID); if (task == null) { Logs.WriteEvent("Unable to find Task, TaskID: " + taskID.ToString()); return; } if (modifier == null) { Logs.WriteEvent("Unable to find Modifying User, UserID: " + modifierID.ToString()); return; } if (task.UserID == null) { Logs.WriteEvent("Assigned Task User is null"); return; } Organization taskOrganization = Organizations.GetOrganization(LoginUser, task.OrganizationID); if (taskOrganization == null) { Logs.WriteEvent("Task's Organization IS NULL!!!!"); return; } User owner = Users.GetUser(LoginUser, (int)task.UserID); if (owner.UserID == modifier.UserID) { Logs.WriteEvent("Modifier and Owner are the same person."); return; } if (Emails.IsEmailDisabled(LoginUser, owner.UserID, "Tasks")) { return; } MailMessage message = EmailTemplates.GetTaskAssigned(LoginUser, UsersView.GetUsersViewItem(LoginUser, modifierID), UsersView.GetUsersViewItem(LoginUser, (int)task.UserID), task); message.To.Add(GetMailAddress(owner.Email, owner.FirstLastName)); //message.Subject = message.Subject + " [pvt]"; EmailTemplates.ReplaceMailAddressParameters(message); String description = String.Format("Task assigned notification sent to {0} for Task {1}", message.To.ToString(), task.Name); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tasks, task.TaskID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, (int)task.UserID, description); //string emailReplyToAddress = GetEmailReplyToAddress(LoginUser, ticket); //AddMessage(taskOrganization, "Ticket Update Request [" + ticket.TicketNumber.ToString() + "]", message, emailReplyToAddress); Emails.AddEmail(LoginUser, task.OrganizationID, null, message.Subject, message); Logs.WriteEvent("Message queued"); } catch (Exception ex) { Logs.WriteEvent("Error with ProcessTaskAssigned"); Logs.WriteException(ex); ExceptionLogs.LogException(LoginUser, ex, "ProcessTaskModified", task.Row); } }
/// <summary> /// Update the Ticket related fields that live in their own table. /// </summary> /// <param name="command">Command received in the request to read and process the data in the request body.</param> /// <param name="ticketId">TicketId to update its record.</param> private static void UpdateFieldsOfSeparateTable(RestCommand command, Ticket ticket, bool isCustomerTicket = false) { try { //Add as necessary to the list and then to the switch-case below for the work to update it. List <string> fields = new List <string>() { "jirakey", "tags" }; foreach (string field in fields.Select(p => p.ToLower()).ToList()) { XmlNode node = GetNode(command, field); if (node != null) { switch (field) { case "jirakey": string jiraKey = node.InnerText; TicketLinkToJira ticketLinkToJira = new TicketLinkToJira(command.LoginUser); ticketLinkToJira.LoadByTicketID(ticket.TicketID); int?crmLinkId = null; //Next line and 2 If statements are the same as in \webapp\app_code\ticketservice.cs SetSyncWithJira(). Might need to consider making a common funcion for both crmLinkId = CRMLinkTable.GetIdBy(ticket.OrganizationID, IntegrationType.Jira.ToString().ToLower(), ticket.ProductID, command.LoginUser); //If product is not associated to an instance then get the 'default' instance if (crmLinkId == null || crmLinkId <= 0) { CRMLinkTable crmlink = new CRMLinkTable(command.LoginUser); crmlink.LoadByOrganizationID(ticket.OrganizationID); crmLinkId = crmlink.Where(p => p.InstanceName == "Default" && p.CRMType.ToLower() == IntegrationType.Jira.ToString().ToLower()) .Select(p => p.CRMLinkID).FirstOrDefault(); } if (ticketLinkToJira != null && ticketLinkToJira.Any()) { string oldJiraKey = ticketLinkToJira[0].JiraKey; ticketLinkToJira[0].JiraKey = jiraKey.ToLower() == "newjiraissue" ? null : jiraKey; ticketLinkToJira[0].CrmLinkID = crmLinkId; ticketLinkToJira.Save(); ActionLogs.AddActionLog(command.LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, string.Format("Changed JiraKey from '{0}' to '{1}'.", oldJiraKey, jiraKey)); } else { TicketLinkToJiraItem newJiraLink = ticketLinkToJira.AddNewTicketLinkToJiraItem(); newJiraLink.TicketID = ticket.TicketID; newJiraLink.SyncWithJira = true; newJiraLink.JiraID = null; newJiraLink.JiraKey = jiraKey.ToLower() == "newjiraissue" ? null : jiraKey; newJiraLink.JiraLinkURL = null; newJiraLink.JiraStatus = null; newJiraLink.CreatorID = command.LoginUser.UserID; newJiraLink.CrmLinkID = crmLinkId; if (newJiraLink.CrmLinkID != null && newJiraLink.CrmLinkID > 0) { newJiraLink.Collection.Save(); ActionLogs.AddActionLog(command.LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, string.Format("Linked to JiraKey '{0}'.", jiraKey)); } } break; case "tags": TagLinks currentTagLinks = new TagLinks(command.LoginUser); currentTagLinks.LoadByReference(ReferenceType.Tickets, ticket.TicketID); XmlNodeList nodeList = node.ChildNodes; List <int> newTags = new List <int>(); foreach (XmlNode tagNode in nodeList) { string tagValue = tagNode["Value"].InnerText; Tag newTag = Tags.GetTag(command.LoginUser, tagValue); if (newTag == null) { Tags tag = new Tags(command.LoginUser); newTag = tag.AddNewTag(); newTag.OrganizationID = isCustomerTicket ? command.Organization.ParentID ?? command.Organization.OrganizationID : command.Organization.OrganizationID; newTag.Value = tagValue; tag.Save(); } newTags.Add(newTag.TagID); } foreach (int tag in newTags) { TagLink newTagLink = currentTagLinks.Where(p => p.TagID == tag && p.RefID == ticket.TicketID).SingleOrDefault(); if (newTagLink == null) { TagLinks tagLink = new TagLinks(command.LoginUser); newTagLink = tagLink.AddNewTagLink(); newTagLink.TagID = tag; newTagLink.RefType = ReferenceType.Tickets; newTagLink.RefID = ticket.TicketID; tagLink.Save(); } } List <TagLink> deleteTagLinks = currentTagLinks.Where(p => !newTags.Contains(p.TagID)).ToList(); foreach (TagLink deleteTagLink in deleteTagLinks) { deleteTagLink.Delete(); deleteTagLink.Collection.Save(); } break; default: break; } } } } catch (Exception ex) { ExceptionLogs.LogException(command.LoginUser, ex, "API", string.Format("OrgID: {0}{1}Verb: {2}{1}Url: {3}{1}Body: {4}", command.Organization.OrganizationID, Environment.NewLine, command.Method, command.Method, command.Data)); } }
private void NotifyViolation(int ticketID, bool useUser, bool useGroup, bool isWarning, SlaViolationType slaViolationType, SlaNotification notification, int?triggerId) { Users users = new Users(LoginUser); User user = null; Logs.WriteLine(); Logs.WriteEvent("***** Processing TicketID: " + ticketID.ToString()); TicketsViewItem ticket = TicketsView.GetTicketsViewItem(LoginUser, ticketID); if (ticket == null) { Logs.WriteEvent("Ticket is NULL, exiting"); return; } //Since we are already re-loading the Ticket information we will check again if the SLAs still apply at this point string violationType = ""; bool slaNotApplyAnymore = false; switch (slaViolationType) { case SlaViolationType.InitialResponse: violationType = "Initial Response"; slaNotApplyAnymore = ticket.SlaWarningInitialResponse == null; break; case SlaViolationType.LastAction: violationType = "Last Action"; slaNotApplyAnymore = ticket.SlaViolationLastAction == null; break; case SlaViolationType.TimeClosed: violationType = "Time to Close"; slaNotApplyAnymore = ticket.SlaViolationTimeClosed == null; break; default: break; } if (slaNotApplyAnymore) { Logs.WriteEvent($"The {((isWarning) ? "warning" : "violation")} for {violationType} does not apply anymore because the Ticket has been updated to satisfy this SLA while it was in process for the notification."); } else { if (!isWarning) { SlaViolationHistoryItem history = (new SlaViolationHistory(LoginUser)).AddNewSlaViolationHistoryItem(); history.DateViolated = DateTime.UtcNow; history.GroupID = ticket.GroupID; history.UserID = ticket.UserID; history.ViolationType = slaViolationType; history.TicketID = ticket.TicketID; history.SlaTriggerId = triggerId; history.Collection.Save(); } Actions actions = new Actions(LoginUser); actions.LoadLatestByTicket(ticket.TicketID, false); ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, violationType + " SLA " + (isWarning ? "warning" : "violation") + " occurred"); MailMessage message = EmailTemplates.GetSlaEmail(LoginUser, ticket, violationType, isWarning); if (ticket.GroupID != null && useGroup) { users.LoadByGroupID((int)ticket.GroupID); } if (ticket.UserID != null && useUser && users.FindByUserID((int)ticket.UserID) == null) { user = Users.GetUser(LoginUser, (int)ticket.UserID); } foreach (User item in users) { if (Emails.IsEmailDisabled(LoginUser, item.UserID, "SLA")) { continue; } message.To.Add(new MailAddress(item.Email, item.FirstLastName)); } if (user != null) { if (!Emails.IsEmailDisabled(LoginUser, user.UserID, "SLA")) { message.To.Add(new MailAddress(user.Email, user.FirstLastName)); Logs.WriteEvent(string.Format("Adding Main User, Name:{0} Email:{1} UserID:{2}", user.FirstLastName, user.Email, user.UserID.ToString())); } } if (message.To.Count > 0) { Email email = Emails.AddEmail(LoginUser, ticket.OrganizationID, null, "Sla Message", message); Logs.WriteEvent("Email Added (EmailID: " + email.EmailID.ToString() + ")", true); } try { TimeZoneInfo tz = null; Organization org = Organizations.GetOrganization(LoginUser, ticket.OrganizationID); if (org.TimeZoneID != null) { tz = System.TimeZoneInfo.FindSystemTimeZoneById(org.TimeZoneID); } if (tz == null) { Logs.WriteEvent("Timezone is null, using system's"); tz = System.TimeZoneInfo.Local; } Logs.WriteEvent(tz.DisplayName); Logs.WriteEvent("Supports DLS: " + tz.SupportsDaylightSavingTime.ToString()); Logs.WriteEvent("Is DLS: " + tz.IsDaylightSavingTime(DateTime.UtcNow).ToString()); Logs.WriteEvent("UTC: " + DateTime.UtcNow.ToString()); Logs.WriteEvent(string.Format("NOTIFYING TicketID:{0} TicketNumber:{1} OrganizationID:{2} ", ticket.TicketID.ToString(), ticket.TicketNumber.ToString(), ticket.OrganizationID.ToString())); Logs.WriteEvent(string.Format("User:{1} Group:{2} IsWarning:{3} NoficationType:{4}", ticketID.ToString(), useUser.ToString(), useGroup.ToString(), isWarning.ToString(), slaViolationType)); Logs.WriteEvent("Ticket Data:"); Logs.WriteData(ticket.Row); Logs.WriteEvent("Notification Data:"); Logs.WriteData(notification.Row); Logs.WriteEvent("Organization Data:"); Logs.WriteData(org.Row); Organizations customers = new Organizations(LoginUser); customers.LoadByTicketID(ticket.TicketID); foreach (Organization customer in customers) { Logs.WriteEvent("-- Customer: " + customer.Name); if (customer.SlaLevelID != null) { SlaLevel level = SlaLevels.GetSlaLevel(LoginUser, (int)customer.SlaLevelID); Logs.WriteEvent("SLA Level: " + level.Name); SlaTriggers triggers = new SlaTriggers(LoginUser); triggers.LoadByTicketTypeAndSeverity(level.SlaLevelID, ticket.TicketTypeID, ticket.TicketSeverityID); foreach (SlaTrigger trigger in triggers) { Logs.WriteData(trigger.Row); } } else { Logs.WriteEvent("No SLA Level Assigned to " + customer.Name); } } if (org.InternalSlaLevelID != null) { Logs.WriteEvent("Internal SLA:"); SlaTriggers triggers = new SlaTriggers(LoginUser); triggers.LoadByTicketTypeAndSeverity((int)org.InternalSlaLevelID, ticket.TicketTypeID, ticket.TicketSeverityID); foreach (SlaTrigger trigger in triggers) { Logs.WriteData(trigger.Row); } } else { Logs.WriteEvent("No Internal SLA"); } } catch (Exception ex) { Logs.WriteEvent("Logging Exception:"); Logs.WriteException(ex); } } }
private bool UpdateCompanyInformation(CompanyObjects.RootObject customerInsightsOrganizationInfo, Organization currentCompanyInfo) { bool isUpdated = false; string useSocialProfile = CustomerInsightsUtilities.SocialProfiles.LinkedIn.ToString(); if (customerInsightsOrganizationInfo.socialProfiles != null && customerInsightsOrganizationInfo.socialProfiles.Count > 0) { //We will use LinkedIn for bio, if not found then use the first one of the others with that information if (!customerInsightsOrganizationInfo.socialProfiles.Exists(p => p.typeName.ToLower() == useSocialProfile.ToLower())) { useSocialProfile = string.Empty; useSocialProfile = customerInsightsOrganizationInfo.socialProfiles.Where(p => !string.IsNullOrEmpty(p.bio)).Select(p => p.typeName).FirstOrDefault(); } if (!string.IsNullOrEmpty(useSocialProfile)) { string bio = customerInsightsOrganizationInfo.socialProfiles.Where(p => p.typeName.ToLower() == useSocialProfile.ToLower() && !string.IsNullOrEmpty(p.bio)).Select(p => p.bio).FirstOrDefault(); if (CanUpdateCompanyBio(currentCompanyInfo, bio)) { currentCompanyInfo.Description = bio; isUpdated = true; } } else { Logs.WriteEvent("No bio found in any of the social profiles"); } } else { Logs.WriteEvent("No social profile found"); } if (!string.IsNullOrEmpty(customerInsightsOrganizationInfo.logo)) { string resultMessage = string.Empty; string logoPath = TeamSupport.Data.Quarantine.ServiceQ.GetAttachmentPath10(LoginUser, (int)currentCompanyInfo.ParentID); string logoFullPath = string.Format("{0}\\{1}.png", logoPath, currentCompanyInfo.OrganizationID); if (CustomerInsightsUtilities.DownloadImage(customerInsightsOrganizationInfo.logo, logoFullPath, currentCompanyInfo.OrganizationID, AttachmentProxy.References.Organizations, LoginUser, out resultMessage)) { string description = string.Format("TeamSupport System updated Logo for '{0}'", currentCompanyInfo.Name); ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Organizations, currentCompanyInfo.OrganizationID, description); //delete cached image string cachePath = string.Empty; string pattern = string.Empty; try { cachePath = TeamSupport.Data.Quarantine.ServiceQ.GetAttachmentPath11(LoginUser, currentCompanyInfo.ParentID.ToString()); if (System.IO.Directory.Exists(cachePath)) { pattern = currentCompanyInfo.OrganizationID.ToString() + "-*.*"; string[] files = System.IO.Directory.GetFiles(cachePath, pattern, System.IO.SearchOption.TopDirectoryOnly); foreach (String file in files) { System.IO.File.Delete(file); Logs.WriteEvent(string.Format("Cached file {0} deleted.", file)); } } } catch (Exception ex) { Logs.WriteEvent("Exception deleting cached images for company."); Logs.WriteEventFormat("CachePath: {0}", cachePath.ToString()); Logs.WriteEventFormat("Pattern: {0}", pattern.ToString()); Logs.WriteEventFormat("Exception Message: {0}", ex.Message.ToString()); Logs.WriteEventFormat("Exception StackTrace: {0}", ex.StackTrace.ToString()); } } if (!string.IsNullOrEmpty(resultMessage)) { Logs.WriteEvent(resultMessage); } } else { Logs.WriteEvent("No logo found"); } if (isUpdated) { currentCompanyInfo.Collection.Save(); Logs.WriteEvent(string.Format("Bio pulled from {0}", useSocialProfile)); string description = "TeamSupport System changed description for organization '" + currentCompanyInfo.Name + "'"; ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Organizations, currentCompanyInfo.OrganizationID, description); } return(isUpdated); }
private bool UpdateContactInformation(ContactObjects.RootObject customerInsightsContactInfo, User currentContactInfo, int organizationParentId) { bool isTitleUpdated = false; bool isLinkedInUpdated = false; string useSocialProfile = CustomerInsightsUtilities.SocialProfiles.LinkedIn.ToString(); if (customerInsightsContactInfo.socialProfiles != null && customerInsightsContactInfo.socialProfiles.Count > 0) { if (!customerInsightsContactInfo.socialProfiles.Exists(p => p.typeName.ToLower() == CustomerInsightsUtilities.SocialProfiles.LinkedIn.ToString().ToLower())) { Logs.WriteEvent("LinkedIn not found"); } else { ContactObjects.SocialProfile contactInfo = customerInsightsContactInfo.socialProfiles.Where(p => p.typeName.ToLower() == useSocialProfile.ToLower()).FirstOrDefault(); if (contactInfo != null && CanUpdateContactLinkedIn(currentContactInfo, contactInfo.url)) { currentContactInfo.LinkedIn = contactInfo.url; isLinkedInUpdated = true; } } } else { Logs.WriteEvent("No social profile found"); } if (customerInsightsContactInfo.organizations != null && customerInsightsContactInfo.organizations.Count > 0) { ContactObjects.Organization organization = customerInsightsContactInfo.organizations.Where(p => p.isPrimary).FirstOrDefault(); if (organization != null && CanUpdateContactTitle(currentContactInfo, organization.title)) { currentContactInfo.Title = organization.title; isTitleUpdated = true; } } else { Logs.WriteEvent("No organizations found"); } if (isLinkedInUpdated || isTitleUpdated) { currentContactInfo.Collection.Save(); string description = string.Empty; if (isLinkedInUpdated) { Logs.WriteEventFormat("LinkedIn updated to {0}", currentContactInfo.LinkedIn); description = string.Format("TeamSupport System changed LinkedIn to {0} ", currentContactInfo.LinkedIn); ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Users, currentContactInfo.UserID, description); } if (isTitleUpdated) { Logs.WriteEventFormat("Title updated to {0}", currentContactInfo.Title); description = string.Format("TeamSupport System set contact title to {0} ", currentContactInfo.Title); ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Users, currentContactInfo.UserID, description); } } string usePhotoFrom = CustomerInsightsUtilities.SocialProfiles.LinkedIn.ToString(); string photoUrl = string.Empty; if (customerInsightsContactInfo.photos != null && customerInsightsContactInfo.photos.Any()) { if (customerInsightsContactInfo.photos.Exists(p => p.typeName.ToLower() == usePhotoFrom.ToLower())) { photoUrl = customerInsightsContactInfo.photos.Where(p => p.typeName.ToLower() == usePhotoFrom.ToLower() && !string.IsNullOrEmpty(p.url)).Select(p => p.url).FirstOrDefault(); } if (string.IsNullOrEmpty(photoUrl)) { photoUrl = customerInsightsContactInfo.photos.Where(p => !string.IsNullOrEmpty(p.url)).Select(p => p.url).FirstOrDefault(); } } if (!string.IsNullOrEmpty(photoUrl)) { string resultMessage = string.Empty; string logoPath = TeamSupport.Data.Quarantine.ServiceQ.GetAttachmentPath12(LoginUser, organizationParentId); string logoFullPath = string.Format("{0}\\{1}avatar.jpg", logoPath, currentContactInfo.UserID.ToString()); if (CustomerInsightsUtilities.DownloadImage(photoUrl, logoFullPath, currentContactInfo.OrganizationID, AttachmentProxy.References.Contacts, LoginUser, out resultMessage)) { string description = "TeamSupport System updated Photo for '" + currentContactInfo.DisplayName + "'"; ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Users, currentContactInfo.UserID, description); //delete cached image string cachePath = string.Empty; string pattern = string.Empty; try { cachePath = TeamSupport.Data.Quarantine.ServiceQ.GetAttachmentPath13(LoginUser, organizationParentId); pattern = currentContactInfo.UserID.ToString() + "-*.*"; string[] files = System.IO.Directory.GetFiles(cachePath, pattern, System.IO.SearchOption.TopDirectoryOnly); foreach (String file in files) { System.IO.File.Delete(file); } } catch (Exception ex) { Logs.WriteEvent("Exception deleting cached images for contact."); Logs.WriteEventFormat("CachePath: {0}", cachePath.ToString()); Logs.WriteEventFormat("Pattern: {0}", pattern.ToString()); Logs.WriteEventFormat("Exception Message: {0}", ex.Message.ToString()); Logs.WriteEventFormat("Exception StackTrace: {0}", ex.StackTrace.ToString()); } } if (!string.IsNullOrEmpty(resultMessage)) { Logs.WriteEvent(resultMessage); } } else { Logs.WriteEvent("No photo url found"); } return(isLinkedInUpdated || isTitleUpdated); }
private void ProcessReminder(Reminder reminder) { Logs.WriteLine(); Logs.WriteEvent("***********************************************************************************"); Logs.WriteEvent("Processing Reminder ReminderID: " + reminder.ReminderID.ToString()); Logs.WriteData(reminder.Row); Logs.WriteLine(); Logs.WriteEvent("***********************************************************************************"); MailMessage message; UsersViewItem user = UsersView.GetUsersViewItem(LoginUser, (int)reminder.UserID); if (user == null) { return; } string description = ""; switch (reminder.RefType) { case ReferenceType.Organizations: OrganizationsViewItem org = OrganizationsView.GetOrganizationsViewItem(LoginUser, reminder.RefID); if (org == null) { return; } message = EmailTemplates.GetReminderCustomerEmail(LoginUser, reminder, user, org); description = String.Format("Reminder sent to {0} for Organization {1}", message.To.ToString(), org.Name); Logs.WriteEvent(description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, reminder.RefType, reminder.RefID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Organizations, org.OrganizationID, description); break; case ReferenceType.Tickets: TicketsViewItem ticket = TicketsView.GetTicketsViewItem(LoginUser, reminder.RefID); if (ticket == null) { return; } message = EmailTemplates.GetReminderTicketEmail(LoginUser, reminder, user, ticket); EmailTemplates.ReplaceEmailRecipientParameters(LoginUser, message, Tickets.GetTicket(LoginUser, ticket.TicketID), reminder.UserID); //vv TeamSupport.Data.Action action = (new Actions(LoginUser)).AddNewAction(); action.ActionTypeID = null; action.Name = "Reminder"; action.ActionSource = "Reminder"; action.SystemActionTypeID = SystemActionType.Reminder; action.Description = String.Format("<p>The following is a reminder for {0} {1}:</p><p> </p><p>{2}</p>", user.FirstName, user.LastName, reminder.Description); action.IsVisibleOnPortal = false; action.IsKnowledgeBase = false; action.TicketID = ticket.TicketID; action.Collection.Save(); description = String.Format("Reminder sent to {0} for Ticket {1}", message.To.ToString(), ticket.TicketNumber.ToString()); Logs.WriteEvent(description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, reminder.RefType, reminder.RefID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tickets, ticket.TicketID, description); break; case ReferenceType.Contacts: ContactsViewItem contact = ContactsView.GetContactsViewItem(LoginUser, reminder.RefID); if (contact == null) { return; } message = EmailTemplates.GetReminderContactEmail(LoginUser, reminder, user, contact); description = String.Format("Reminder sent to {0} for Contact {1}", message.To.ToString(), contact.FirstName + " " + contact.LastName); Logs.WriteEvent(description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, reminder.RefType, reminder.RefID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, contact.UserID, description); break; case ReferenceType.Tasks: TasksViewItem task = TasksView.GetTasksViewItem(LoginUser, reminder.RefID); if (task == null || task.IsComplete) { reminder.IsDismissed = true; reminder.Collection.Save(); return; } message = EmailTemplates.GetReminderTaskEmail(LoginUser, reminder, user, task); description = String.Format("Reminder sent to {0} for Task {1}", message.To.ToString(), task.Name); Logs.WriteEvent("ver. 05162017: " + description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tasks, task.TaskID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, (int)reminder.UserID, description); TaskAssociations taskAssociations = new TaskAssociations(LoginUser); taskAssociations.LoadByTaskIDOnly(task.TaskID); foreach (TaskAssociation taskAssociation in taskAssociations) { if (taskAssociation.RefType == (int)ReferenceType.Tickets) { TeamSupport.Data.Action taskAction = (new Actions(LoginUser)).AddNewAction(); taskAction.ActionTypeID = null; taskAction.Name = "Reminder"; taskAction.ActionSource = "Reminder"; taskAction.SystemActionTypeID = SystemActionType.Reminder; taskAction.Description = String.Format("<p>The following is a reminder for {0} {1}:</p><p> </p><p>{2}</p>", user.FirstName, user.LastName, reminder.Description); taskAction.IsVisibleOnPortal = false; taskAction.IsKnowledgeBase = false; taskAction.TicketID = taskAssociation.RefID; try { taskAction.Collection.Save(); } catch (Exception ex) { Logs.WriteEvent("Ex Reminder Action.Save: " + ex.StackTrace); } } } break; default: message = null; break; } if (message == null) { return; } reminder.HasEmailSent = true; reminder.Collection.Save(); if (Emails.IsEmailDisabled(LoginUser, user.UserID, "Reminders")) { Logs.WriteEvent("Message skipped due to disabled user setting."); } else { MailAddress address = new MailAddress(user.Email, user.FirstName + " " + user.LastName); Logs.WriteEvent("Mail Address: " + address.ToString()); message.To.Add(address); EmailTemplates.ReplaceMailAddressParameters(message); Emails.AddEmail(LoginUser, reminder.OrganizationID, null, message.Subject, message); Logs.WriteEvent("Message queued"); } }
public override bool Save() { if (textName.Text.Trim() == "") { _manager.Alert("Please give the custom field a name."); return(false); } string apiFieldName = GetApiFieldName(); if (apiFieldName == "") { _manager.Alert("Please give the custom field an API field name."); return(false); } if (FieldExists(apiFieldName)) { return(false); } int?catID = Request["CatID"] == null ? null : (int?)int.Parse(Request["CatID"]); CustomFields fields = new CustomFields(UserSession.LoginUser); CustomField field; if (_customFieldID < 0) { field = fields.AddNewCustomField(); field.OrganizationID = UserSession.LoginUser.OrganizationID; field.RefType = _refType; field.AuxID = _auxID; field.CustomFieldCategoryID = catID; field.Position = fields.GetMaxPosition(UserSession.LoginUser.OrganizationID, _refType, _auxID) + 1; } else { fields.LoadByCustomFieldID(_customFieldID); if (fields.IsEmpty) { return(false); } field = fields[0]; } field.Description = textDescription.Text; field.Name = textName.Text; field.ApiFieldName = apiFieldName; field.FieldType = GetSelectedFieldType(); field.ParentCustomFieldID = GetSelectedParentCustomFieldID(); field.ParentCustomValue = GetSelectedParentCustomValue(); field.ParentProductID = GetSelectedParentProductID(); field.IsVisibleOnPortal = cbIsVisibleOnPortal.Checked; field.IsFirstIndexSelect = cbFirstSelect.Checked; field.IsRequired = cbIsRequired.Checked; field.IsRequiredToClose = cbIsRequiredToClose.Checked; field.Mask = textMask.Text; string list = textList.Text.Replace("\n", "|"); if (list != "") { string[] items = list.Split('|'); CommaDelimitedStringCollection collection = new CommaDelimitedStringCollection(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < items.Length; i++) { builder.Append(items[i].Trim()); if (i < items.Length - 1) { builder.Append("|"); } } field.ListValues = builder.ToString(); } else { field.ListValues = list; } field.Collection.Save(); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Update, ReferenceType.CustomFields, field.CustomFieldID, string.Format( "{0} updated custom field \"{1}\" ({2})", Users.GetUserFullName(UserSession.LoginUser, UserSession.LoginUser.UserID), field.Name, field.CustomFieldID)); return(true); }
private static string AuthenticateUser(int userId, int organizationId, bool storeInfo, bool isBackDoor = false) { string result = string.Empty; LoginUser loginUser = new LoginUser(UserSession.ConnectionString, userId, organizationId, null); User user = Users.GetUser(loginUser, userId); string deviceID = GetDeviceID(); TSAuthentication.Authenticate(user, isBackDoor, deviceID); if (!isBackDoor) { LoginAttempts.AddAttempt(loginUser, userId, true, HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.Browser, HttpContext.Current.Request.UserAgent, deviceID); System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser; ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, ReferenceType.Users, userId, "Logged in (" + browser.Browser + " " + browser.Version + ")"); ConfirmBaseData(loginUser); if (storeInfo) { HttpContext.Current.Response.Cookies["rm"]["a"] = user.Email; HttpContext.Current.Response.Cookies["rm"]["b"] = user.OrganizationID.ToString(); HttpContext.Current.Response.Cookies["rm"].Expires = DateTime.UtcNow.AddDays(7); } else { HttpContext.Current.Response.Cookies["rm"].Value = ""; } } if (user.IsPasswordExpired && !isBackDoor) { result = string.Format("vcr/1/LoginNewPassword.html?UserID={0}&Token={1}", user.UserID, user.CryptedPassword); } else { string rawQueryString = null; try { rawQueryString = HttpContext.Current.Request.UrlReferrer.Query; } catch (Exception) { //vv } if (!string.IsNullOrEmpty(rawQueryString)) { string urlRedirect = GetQueryStringValue(rawQueryString, "ReturnUrl"); if (!string.IsNullOrEmpty(urlRedirect) && urlRedirect.Trim().Length > 0) { result = urlRedirect; } else { result = "."; } } else { result = "."; } } return(result); }
public int SaveAsset(string data) { NewAssetSave info; try { info = Newtonsoft.Json.JsonConvert.DeserializeObject <NewAssetSave>(data); } catch (Exception e) { return(-1); } LoginUser loginUser = TSAuthentication.GetLoginUser(); Assets assets = new Assets(loginUser); Asset asset = assets.AddNewAsset(); asset.OrganizationID = TSAuthentication.OrganizationID; asset.Name = info.Name; asset.ProductID = info.ProductID; asset.ProductVersionID = info.ProductVersionID; asset.SerialNumber = info.SerialNumber; asset.WarrantyExpiration = DataUtils.DateToUtc(TSAuthentication.GetLoginUser(), info.WarrantyExpiration); asset.Notes = info.Notes; //Location 1=assigned (shipped), 2=warehouse, 3=junkyard asset.Location = "2"; asset.DateCreated = DateTime.UtcNow; asset.DateModified = DateTime.UtcNow; asset.CreatorID = loginUser.UserID; asset.ModifierID = loginUser.UserID; asset.Collection.Save(); string description = String.Format("Created asset {0} ", GetAssetReference(asset)); ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Assets, asset.AssetID, description); foreach (CustomFieldSaveInfo field in info.Fields) { CustomValue customValue = CustomValues.GetValue(TSAuthentication.GetLoginUser(), field.CustomFieldID, asset.AssetID); if (field.Value == null) { customValue.Value = ""; } else { if (customValue.FieldType == CustomFieldType.DateTime) { customValue.Value = ((DateTime)field.Value).ToString(); //DateTime dt; //if (DateTime.TryParse(((string)field.Value), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal, out dt)) //{ // customValue.Value = dt.ToUniversalTime().ToString(); //} } else { customValue.Value = field.Value.ToString(); } } customValue.Collection.Save(); } AssetHistory history = new AssetHistory(loginUser); AssetHistoryItem historyItem = history.AddNewAssetHistoryItem(); historyItem.OrganizationID = loginUser.OrganizationID; historyItem.Actor = loginUser.UserID; historyItem.AssetID = asset.AssetID; historyItem.ActionTime = DateTime.UtcNow; historyItem.ActionDescription = "Asset created."; historyItem.ShippedFrom = 0; historyItem.ShippedTo = 0; historyItem.TrackingNumber = string.Empty; historyItem.ShippingMethod = string.Empty; historyItem.ReferenceNum = string.Empty; historyItem.Comments = string.Empty; history.Save(); return(asset.AssetID); }
public override bool Save() { Organization organization = (Organization)Organizations.GetOrganization(UserSession.LoginUser, _organizationID); int?id = int.Parse(cmbUsers.SelectedValue); organization.PrimaryUserID = id < 0 ? null : id; organization.TimeZoneID = cmbTimeZones.SelectedValue; UserSession.LoginUser.TimeZoneInfo = null; try { TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(organization.TimeZoneID); } catch (Exception) { } Settings.OrganizationDB.WriteBool("ShowOnlyCustomerProducts", cbLinkTicketCustomersWithProducts.Checked); organization.AutoAssignCustomerWithAssetOnTickets = cbAutoAssignCustomerWithAssetOnTickets.Checked; organization.AutoAssociateCustomerToTicketBasedOnAssetAssignment = cbAutoAssociateCustomerToTicketBasedOnAssetAssignment.Checked; organization.CultureName = cmbDateFormat.SelectedValue; organization.UseEuropeDate = (cmbDateFormat.SelectedValue == "en-GB"); organization.FontFamily = (FontFamily)Convert.ToInt32(cmbFontFamily.SelectedValue); organization.FontSize = (TeamSupport.Data.FontSize)Convert.ToInt32(cmbFontSize.SelectedValue); if (cmbSla.SelectedIndex == 0) { organization.InternalSlaLevelID = null; } else { organization.InternalSlaLevelID = int.Parse(cmbSla.SelectedValue); } Settings.OrganizationDB.WriteBool("DisableStatusNotification", cbDisableStatusNotifications.Checked); organization.SetNewActionsVisibleToCustomers = cbNewActionsVisible.Checked; organization.AllowUnsecureAttachmentViewing = cbUnsecureAttachments.Checked; organization.SlaInitRespAnyAction = cbSlaInitRespAnyAction.Checked; organization.ShowGroupMembersFirstInTicketAssignmentList = cbShowGroupMembersFirstInTicketAssignmentList.Checked; organization.HideDismissNonAdmins = cbHideDismissNonAdmins.Checked; organization.UpdateTicketChildrenGroupWithParent = cbUpdateTicketChildrenGroupWithParent.Checked; //organization.UseForums = cbCommunity.Checked; Settings.OrganizationDB.WriteBool("RequireNewTicketCustomer", cbRequireCustomer.Checked); //organization.AdminOnlyCustomers = cbAdminCustomers.Checked; organization.TimedActionsRequired = cbTimeRequired.Checked; organization.AdminOnlyReports = cbAdminReports.Checked; organization.Website = textWebSite.Text; organization.CompanyDomains = textDomains.Text; organization.Description = textDescription.Text; if (timeBDStart.SelectedDate != null) { organization.BusinessDayStart = (DateTime)DataUtils.DateToUtc(UserSession.LoginUser, timeBDStart.SelectedDate); } if (timeBDEnd.SelectedDate != null) { organization.BusinessDayEnd = (DateTime)DataUtils.DateToUtc(UserSession.LoginUser, timeBDEnd.SelectedDate); } organization.ClearBusinessDays(); if (cbBDSunday.Checked) { organization.AddBusinessDay(DayOfWeek.Sunday); } if (cbBDMonday.Checked) { organization.AddBusinessDay(DayOfWeek.Monday); } if (cbBDTuesday.Checked) { organization.AddBusinessDay(DayOfWeek.Tuesday); } if (cbBDWednesday.Checked) { organization.AddBusinessDay(DayOfWeek.Wednesday); } if (cbBDThursday.Checked) { organization.AddBusinessDay(DayOfWeek.Thursday); } if (cbBDFriday.Checked) { organization.AddBusinessDay(DayOfWeek.Friday); } if (cbBDSaturday.Checked) { organization.AddBusinessDay(DayOfWeek.Saturday); } organization.ProductRequired = cbRequireProduct.Checked; organization.ProductVersionRequired = cbRequireProductVersion.Checked; organization.UseProductFamilies = cbUseProductFamilies.Checked; organization.IsCustomerInsightsActive = cbIsCustomerInsightsActive.Checked; organization.TwoStepVerificationEnabled = cbTwoStepVerification.Checked; organization.NoAttachmentsInOutboundEmail = cbNoAttachmentsInOutboundEmail.Checked; if (organization.NoAttachmentsInOutboundEmail && lbNoAttachmentsInOutboundExcludeProductLine.Items.Count > 0) { string exclude = null; foreach (ListItem item in lbNoAttachmentsInOutboundExcludeProductLine.Items) { if (item.Selected) { exclude += string.Empty + item.Value + ","; } } if (!string.IsNullOrEmpty(exclude) && exclude.LastIndexOf(",") == exclude.Length - 1) { exclude = exclude.TrimEnd(','); } organization.NoAttachmentsInOutboundExcludeProductLine = exclude; } organization.UseWatson = cbUseWatson.Checked; organization.RequireTwoFactor = cbRequireTwoFactor.Checked; organization.RequireGroupAssignmentOnTickets = cbRequireGroupAssignmentOnTickets.Checked; organization.AlertContactNoEmail = cbAlertContactNoEmail.Checked; if (organization.DisableSupportLogin != !cbDisableSupport.Checked) { ActionLogs.AddActionLog(organization.Collection.LoginUser, ActionLogType.Update, ReferenceType.SystemSettings, organization.Collection.LoginUser.UserID, "Changed the 'Allow TeamSupport to log into your account for technical support' to: " + (cbDisableSupport.Checked).ToString()); } organization.DisableSupportLogin = !cbDisableSupport.Checked; organization.DaysBeforePasswordExpire = (int)textPWExpire.Value; try { organization.DefaultWikiArticleID = int.Parse(cmbWikiArticle.SelectedValue); } catch (Exception) { organization.DefaultWikiArticleID = null; } organization.Collection.Save(); UserSession.RefreshCurrentUserInfo(); UserSession.RefreshLoginUser(); return(true); }
public string AssignAsset(int assetID, string data) { AssignAssetSave info; try { info = Newtonsoft.Json.JsonConvert.DeserializeObject <AssignAssetSave>(data); } catch (Exception e) { return("error"); } LoginUser loginUser = TSAuthentication.GetLoginUser(); Asset o = Assets.GetAsset(loginUser, assetID); //Location 1=assigned (shipped), 2=warehouse, 3=junkyard o.Location = "1"; o.AssignedTo = info.RefID; DateTime now = DateTime.UtcNow; o.DateModified = now; o.ModifierID = loginUser.UserID; o.Collection.Save(); AssetHistory assetHistory = new AssetHistory(loginUser); AssetHistoryItem assetHistoryItem = assetHistory.AddNewAssetHistoryItem(); assetHistoryItem.AssetID = assetID; assetHistoryItem.OrganizationID = loginUser.OrganizationID; assetHistoryItem.ActionTime = DateTime.UtcNow; assetHistoryItem.ActionDescription = "Asset Shipped on " + info.DateShipped.Month.ToString() + "/" + info.DateShipped.Day.ToString() + "/" + info.DateShipped.Year.ToString(); assetHistoryItem.ShippedFrom = loginUser.OrganizationID; assetHistoryItem.ShippedFromRefType = (int)ReferenceType.Organizations; assetHistoryItem.ShippedTo = info.RefID; assetHistoryItem.TrackingNumber = info.TrackingNumber; assetHistoryItem.ShippingMethod = info.ShippingMethod; assetHistoryItem.ReferenceNum = info.ReferenceNumber; assetHistoryItem.Comments = info.Comments; assetHistoryItem.DateCreated = now; assetHistoryItem.Actor = loginUser.UserID; assetHistoryItem.RefType = info.RefType; assetHistoryItem.DateModified = now; assetHistoryItem.ModifierID = loginUser.UserID; assetHistory.Save(); AssetAssignments assetAssignments = new AssetAssignments(loginUser); AssetAssignment assetAssignment = assetAssignments.AddNewAssetAssignment(); assetAssignment.HistoryID = assetHistoryItem.HistoryID; assetAssignments.Save(); string description = String.Format("Assigned asset to {0}.", info.AssigneeName); ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, description); AssetsView assetsView = new AssetsView(loginUser); assetsView.LoadByAssetID(assetID); StringBuilder productVersionNumberDisplayName = new StringBuilder(); if (!string.IsNullOrEmpty(assetsView[0].ProductVersionNumber)) { productVersionNumberDisplayName.Append(" - " + assetsView[0].ProductVersionNumber); } StringBuilder serialNumberDisplayValue = new StringBuilder(); if (string.IsNullOrEmpty(assetsView[0].SerialNumber)) { serialNumberDisplayValue.Append("Empty"); } else { serialNumberDisplayValue.Append(assetsView[0].SerialNumber); } StringBuilder warrantyExpirationDisplayValue = new StringBuilder(); if (assetsView[0].WarrantyExpiration == null) { warrantyExpirationDisplayValue.Append("Empty"); } else { warrantyExpirationDisplayValue.Append(((DateTime)assetsView[0].WarrantyExpiration).ToString(GetDateFormatNormal())); } return(string.Format(@"<div class='list-group-item'> <a href='#' id='{0}' class='assetLink'><h4 class='list-group-item-heading'>{1}</h4></a> <div class='row'> <div class='col-xs-8'> <p class='list-group-item-text'>{2}{3}</p> </div> </div> <div class='row'> <div class='col-xs-8'> <p class='list-group-item-text'>SN: {4} - Warr. Exp.: {5}</p> </div> </div> </div>" , assetID , assetsView[0].DisplayName , assetsView[0].ProductName , productVersionNumberDisplayName , serialNumberDisplayValue , warrantyExpirationDisplayValue)); }
private void ProcessOldUser(int taskID, int modifierID, int oldUserID) { TasksViewItem task = TasksView.GetTasksViewItem(LoginUser, taskID); try { User modifier = Users.GetUser(LoginUser, modifierID); if (task == null) { Logs.WriteEvent("Unable to find Task, TaskID: " + taskID.ToString()); return; } if (modifier == null) { Logs.WriteEvent("Unable to find Modifying User, UserID: " + modifierID.ToString()); return; } Organization taskOrganization = Organizations.GetOrganization(LoginUser, task.OrganizationID); if (taskOrganization == null) { Logs.WriteEvent("Task's Organization IS NULL!!!!"); return; } User oldUser = Users.GetUser(LoginUser, oldUserID); UsersViewItem owner = null; if (task.UserID != null) { owner = UsersView.GetUsersViewItem(LoginUser, (int)task.UserID); } if (Emails.IsEmailDisabled(LoginUser, oldUser.UserID, "Tasks")) { return; } MailMessage message = EmailTemplates.GetTaskOldUser(LoginUser, UsersView.GetUsersViewItem(LoginUser, modifierID), UsersView.GetUsersViewItem(LoginUser, (int)oldUserID), owner, task); //if (oldUser.UserID == modifier.UserID) //{ // User creator = Users.GetUser(LoginUser, (int)task.CreatorID); // message.To.Add(GetMailAddress(creator.Email, creator.FirstLastName)); //} //else //{ message.To.Add(GetMailAddress(oldUser.Email, oldUser.FirstLastName)); //} //message.Subject = message.Subject + " [pvt]"; //EmailTemplates.ReplaceEmailRecipientParameters(LoginUser, message, ticket, owner.UserID, owner.OnlyEmailAfterHours); EmailTemplates.ReplaceMailAddressParameters(message); String description = String.Format("Task old user notification sent to {0} for Task {1}", message.To.ToString(), task.Name); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tasks, task.TaskID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, (int)task.UserID, description); //string emailReplyToAddress = GetEmailReplyToAddress(LoginUser, ticket); //AddMessage(taskOrganization, "Ticket Update Request [" + ticket.TicketNumber.ToString() + "]", message, emailReplyToAddress); Emails.AddEmail(LoginUser, task.OrganizationID, null, message.Subject, message); Logs.WriteEvent("Message queued"); } catch (Exception ex) { Logs.WriteEvent("Error with ProcessTaskComplete"); Logs.WriteException(ex); ExceptionLogs.LogException(LoginUser, ex, "ProcessTaskComplete", task.Row); } }
public int ReturnAsset(int assetID, string data) { AssignAssetSave info; try { info = Newtonsoft.Json.JsonConvert.DeserializeObject <AssignAssetSave>(data); } catch (Exception e) { return(-1); } LoginUser loginUser = TSAuthentication.GetLoginUser(); Asset o = Assets.GetAsset(loginUser, assetID); //Location 1=assigned (shipped), 2=warehouse, 3=junkyard o.Location = "2"; o.AssignedTo = null; DateTime now = DateTime.UtcNow; o.DateModified = now; o.ModifierID = loginUser.UserID; o.Collection.Save(); AssetAssignmentsView assetAssignmentsView = new AssetAssignmentsView(loginUser); assetAssignmentsView.LoadByAssetID(assetID); AssetHistory assetHistory = new AssetHistory(loginUser); AssetHistoryItem assetHistoryItem = assetHistory.AddNewAssetHistoryItem(); assetHistoryItem.AssetID = assetID; assetHistoryItem.OrganizationID = loginUser.OrganizationID; assetHistoryItem.ActionTime = DateTime.UtcNow; assetHistoryItem.ActionDescription = "Item returned to warehouse on " + info.DateShipped.Month.ToString() + "/" + info.DateShipped.Day.ToString() + "/" + info.DateShipped.Year.ToString(); assetHistoryItem.ShippedFrom = assetAssignmentsView[0].ShippedTo; assetHistoryItem.ShippedFromRefType = assetAssignmentsView[0].RefType; assetHistoryItem.ShippedTo = loginUser.OrganizationID; assetHistoryItem.RefType = (int)ReferenceType.Organizations; assetHistoryItem.TrackingNumber = info.TrackingNumber; assetHistoryItem.ShippingMethod = info.ShippingMethod; assetHistoryItem.ReferenceNum = info.ReferenceNumber; assetHistoryItem.Comments = info.Comments; assetHistoryItem.DateCreated = now; assetHistoryItem.Actor = loginUser.UserID; assetHistoryItem.DateModified = now; assetHistoryItem.ModifierID = loginUser.UserID; assetHistory.Save(); AssetAssignments assetAssignments = new AssetAssignments(loginUser); foreach (AssetAssignmentsViewItem assetAssignmentViewItem in assetAssignmentsView) { assetAssignments.DeleteFromDB(assetAssignmentViewItem.AssetAssignmentsID); } ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, "Returned asset."); return(assetID); }