Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public static string CreateCustomerTicket(RestCommand command)
        {
            Tickets tickets = new Tickets(command.LoginUser);
            Ticket  ticket  = tickets.AddNewTicket();

            ticket.OrganizationID = (int)command.Organization.ParentID;
            ticket.TicketSource   = "API";
            ticket.NeedsIndexing  = true;
            string description = string.Empty;
            int?   contactID   = null;
            int?   customerID  = null;

            ticket.FullReadFromXml(command.Data, true, ref description, ref contactID, ref customerID);
            ticket.Collection.Save();
            ticket.UpdateCustomFieldsFromXml(command.Data);

            Actions actions = new Actions(command.LoginUser);

            Data.Action action = actions.AddNewAction();
            action.ActionTypeID       = null;
            action.Name               = "Description";
            action.SystemActionTypeID = SystemActionType.Description;
            action.Description        = description;
            action.IsVisibleOnPortal  = ticket.IsVisibleOnPortal;
            action.IsKnowledgeBase    = ticket.IsKnowledgeBase;
            action.TicketID           = ticket.TicketID;
            actions.Save();

            tickets.AddOrganization(command.Organization.OrganizationID, ticket.TicketID);
            UpdateFieldsOfSeparateTable(command, ticket, true);
            return(TicketsView.GetTicketsViewItem(command.LoginUser, ticket.TicketID).GetXml("Ticket", true));
        }
        public static string AddTicketOrganization(RestCommand command, int ticketIDOrNumber, int organizationID)
        {
            TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber);

            if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            Organization organization = Organizations.GetOrganization(command.LoginUser, organizationID);

            if (organization == null || organization.ParentID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }

            Tickets tickets = new Tickets(command.LoginUser);

            tickets.AddOrganization(organizationID, ticket.TicketID);
            return(OrganizationsView.GetOrganizationsViewItem(command.LoginUser, organizationID).GetXml("Customer", true));
        }
Ejemplo n.º 4
0
    public override bool Save()
    {
        if (_referenceType == ReferenceType.Products || _referenceType == ReferenceType.ProductVersions || _referenceType == ReferenceType.OrganizationProducts)
        {
            Products products = new Products(UserSession.LoginUser);

            foreach (GridDataItem item in gridOrganizations.Items)
            {
                if (item.Selected)
                {
                    if (_referenceID2 < 0)
                    {
                        products.AddCustomer(int.Parse(item["OrganizationID"].Text), _referenceID1);
                    }
                    else
                    {
                        products.AddCustomer(int.Parse(item["OrganizationID"].Text), _referenceID1, _referenceID2);
                    }
                }
            }
            return(true);
        }
        else if (_referenceType == ReferenceType.Tickets)
        {
            Tickets tickets = new Tickets(UserSession.LoginUser);

            foreach (GridDataItem item in gridOrganizations.Items)
            {
                if (item.Selected)
                {
                    tickets.AddOrganization(int.Parse(item["OrganizationID"].Text), _referenceID1);
                }
            }
            return(true);
        }

        return(false);
    }
Ejemplo n.º 5
0
    public override bool Save()
    {
        User  user;
        Users users    = new Users(UserSession.LoginUser);;
        int   newOrgID = int.Parse(cmbCustomer.SelectedValue);


        string email = textEmail.Text.Trim();

        if ((cbIsPortalUser.Checked) && (email.Length < 1 || email.IndexOf('@') < 0 || email.IndexOf('.') < 0))
        {
            _manager.Alert("The email you have specified is invalid.  Please choose another email.");
            return(false);
        }

        if (email != "" && !users.IsEmailValid(email, _userID, newOrgID))
        {
            _manager.Alert("The email you have specified is already in use.  Please choose another email.");
            return(false);
        }

        if (textFirstName.Text.Trim().Length < 1 || textLastName.Text.Trim().Length < 1)
        {
            _manager.Alert("The name you have specified is invalid.  Please enter your name.");
            return(false);
        }


        if (_userID < 0)
        {
            user = users.AddNewUser();
            user.OrganizationID = newOrgID;
            if (cbActive.Checked)
            {
                user.ActivatedOn = DateTime.UtcNow;
            }
            user.LastLogin                  = DateTime.UtcNow;
            user.LastActivity               = DateTime.UtcNow.AddHours(-1);
            user.IsPasswordExpired          = true;
            user.ReceiveTicketNotifications = true;
        }
        else
        {
            users.LoadByUserID(_userID);
            if (users.IsEmpty)
            {
                _manager.Alert("There was an error updating the user information");
                return(false);
            }

            user = users[0];
            if (user.IsActive && !cbActive.Checked)
            {
                user.DeactivatedOn = DateTime.UtcNow;
            }
            if (user.OrganizationID != newOrgID)
            {
                user.OrganizationID = newOrgID;
                Tickets tickets = new Tickets(UserSession.LoginUser);
                tickets.LoadByContact(user.UserID);
                foreach (Ticket ticket in tickets)
                {
                    tickets.AddOrganization(newOrgID, ticket.TicketID);
                }
            }
        }

        user.Email             = textEmail.Text;
        user.FirstName         = textFirstName.Text;
        user.LastName          = textLastName.Text;
        user.Title             = textTitle.Text;
        user.MiddleName        = textMiddleName.Text;
        user.BlockInboundEmail = cbBlockEmail.Checked;


        user.IsActive = cbActive.Checked;

        if (UserSession.CurrentUser.HasPortalRights && UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsPortalUser = cbIsPortalUser.Checked;
        }

        if (UserSession.CurrentUser.IsTSUser && UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsSystemAdmin  = cbIsSystemAdmin.Checked;
            user.IsFinanceAdmin = cbIsFinanceAdmin.Checked;
        }



        user.Collection.Save();

        _fieldControls.RefID = user.UserID;
        _fieldControls.SaveCustomFields();

        if (_userID < 0)
        {
            string password = DataUtils.GenerateRandomPassword();
            user.CryptedPassword   = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            user.IsPasswordExpired = true;
            user.Collection.Save();
            if (UserSession.CurrentUser.IsTSUser && cbEmail.Checked)
            {
                EmailPosts.SendWelcomeTSUser(UserSession.LoginUser, user.UserID, password);
            }
            else if (cbEmail.Checked && cbIsPortalUser.Checked)
            {
                EmailPosts.SendWelcomePortalUser(UserSession.LoginUser, user.UserID, password);
            }
        }

        return(true);
    }