public void AddTicketOrganization(string id, int ticketID) { try { id = id.Trim(); if (id.Length < 1) { return; } bool isUser = id.ToLower()[0] == 'u'; int i = int.Parse(id.Remove(0, 1)); Tickets tickets = new Tickets(UserSession.LoginUser); if (isUser) { tickets.AddContact(i, ticketID); } else { tickets.AddOrganization(i, ticketID); } } catch (Exception ex) { DataUtils.LogException(UserSession.LoginUser, ex); } }
private void btnUnkownDups_Click(object sender, EventArgs e) { LoginUser loginUser = new LoginUser(LoginSession.LoginUser.ConnectionString, -1, OrganizationID, null); Organizations organizations = new Organizations(loginUser); organizations.LoadByUnknownCompany(OrganizationID); if (organizations.IsEmpty) { MessageBox.Show("_Unknown Company was not fount"); return; } int unkID = organizations[0].OrganizationID; Users unkUsers = new Users(loginUser); unkUsers.LoadByOrganizationID(unkID, false); Users users = new Users(loginUser); users.LoadContacts(OrganizationID, false); int cnt = 0; foreach (User unkUser in unkUsers) { foreach (User user in users) { if (user.OrganizationID != unkID && user.Email.Trim().ToLower() == unkUser.Email.Trim().ToLower()) { cnt++; Tickets tickets = new Tickets(loginUser); tickets.LoadByContact(unkUser.UserID); foreach (Ticket ticket in tickets) { try { tickets.AddContact(user.UserID, ticket.TicketID); } catch (Exception) { } try { tickets.RemoveContact(unkUser.UserID, ticket.TicketID); } catch (Exception) { } try { tickets.RemoveOrganization(unkID, ticket.TicketID); } catch (Exception) { } } unkUser.MarkDeleted = true; } } } unkUsers.Save(); MessageBox.Show(cnt.ToString()); }
public static string AddTicketContact(RestCommand command, int ticketIDOrNumber, int contactID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } User user = Users.GetUser(command.LoginUser, contactID); Organization organization = Organizations.GetOrganization(command.LoginUser, user.OrganizationID); if (organization == null || organization.ParentID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Tickets tickets = new Tickets(command.LoginUser); tickets.AddContact(user.UserID, ticket.TicketID); return(ContactsView.GetContactsViewItem(command.LoginUser, user.UserID).GetXml("Contact", true)); }