public CustomValueProxy[] GetValues(ReferenceType refType, int id)
        {
            CustomValues values = new CustomValues(TSAuthentication.GetLoginUser());

            values.LoadByReferenceType(TSAuthentication.OrganizationID, refType, id);
            return(values.GetCustomValueProxies());
        }
Пример #2
0
        override protected void GetNextRecord()
        {
            Product product = Products.GetProduct(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = product.ProductID;
            UpdatedItems.Add((int)_lastItemID);

            StringBuilder builder = new StringBuilder();

            builder.AppendLine(product.Description
                               + " " + product.Name
                               + " " + product.DateCreated
                               + " " + product.DateModified);

            DocText = builder.ToString();

            _docFields.Clear();
            AddDocField("ProductID", product.ProductID);
            AddDocField("Name", product.Name);
            if (product.ProductFamilyID != null)
            {
                AddDocField("ProductFamilyID", (int)product.ProductFamilyID);
            }
            DocDisplayName = product.Name;

            ProductSearch productItem = new ProductSearch(product);
            Tickets       tickets     = new Tickets(_loginUser);

            productItem.openTicketCount = tickets.GetProductTicketCount(product.ProductID, 0);
            AddDocField("**JSON", JsonConvert.SerializeObject(productItem));

            CustomValues customValues = new CustomValues(_loginUser);

            customValues.LoadByReferenceType(_organizationID, ReferenceType.Products, product.ProductID);

            foreach (CustomValue value in customValues)
            {
                object o = value.Row["CustomValue"];
                string s = o == null || o == DBNull.Value ? "" : o.ToString();
                AddDocField(value.Row["Name"].ToString(), s);
            }
            DocFields = _docFields.ToString();
            DocIsFile = false;
            DocName   = product.ProductID.ToString();
            try
            {
                DocCreatedDate  = (DateTime)product.Row["DateCreated"];
                DocModifiedDate = (DateTime)product.Row["DateModified"];
            }
            catch (Exception)
            {
            }
        }
        override protected void GetNextRecord()
        {
            ProductVersionsViewItem productVersion = ProductVersionsView.GetProductVersionsViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = productVersion.ProductVersionID;
            UpdatedItems.Add((int)_lastItemID);

            DocText = HtmlToText.ConvertHtml(productVersion.Description == null ? string.Empty : productVersion.Description);

            _docFields.Clear();
            foreach (DataColumn column in productVersion.Collection.Table.Columns)
            {
                object value = productVersion.Row[column];
                string s     = value == null || value == DBNull.Value ? "" : value.ToString();
                AddDocField(column.ColumnName, s);
            }

            ProductVersionsSearch productVersionsSearch = new ProductVersionsSearch(productVersion);
            Tickets tickets = new Tickets(_loginUser);

            productVersionsSearch.openTicketCount = tickets.GetProductVersionTicketCount(productVersion.ProductVersionID, 0, _organizationID);
            AddDocField("**JSON", JsonConvert.SerializeObject(productVersionsSearch));

            CustomValues customValues = new CustomValues(_loginUser);

            customValues.LoadByReferenceType(_organizationID, ReferenceType.ProductVersions, null, productVersion.ProductVersionID);

            foreach (CustomValue value in customValues)
            {
                object o = value.Row["CustomValue"];
                string s = o == null || o == DBNull.Value ? "" : o.ToString();
                AddDocField(value.Row["Name"].ToString(), s);
            }
            DocFields       = _docFields.ToString();
            DocIsFile       = false;
            DocName         = productVersion.ProductVersionID.ToString();
            DocCreatedDate  = productVersion.DateCreatedUtc;
            DocModifiedDate = DateTime.UtcNow;
        }
        override protected void GetNextRecord()
        {
            TicketsViewItem ticket = TicketsView.GetTicketsViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = ticket.TicketID;
            UpdatedItems.Add((int)_lastItemID);

            StringBuilder actionsBuilder = new StringBuilder();
            Actions       actions        = new Actions(_loginUser);

            actions.LoadByTicketID(ticket.TicketID);
            foreach (TeamSupport.Data.Action action in actions)
            {
                string actionText = action.Description;

                if (!action.IsClean)
                {
                    try
                    {
                        actionText = HtmlUtility.Sanitize(actionText);
                        SqlCommand command = new SqlCommand();
                        command.CommandText = "UPDATE Actions SET Description = @Description, IsClean=1 WHERE ActionID=@ActionID";
                        command.Parameters.AddWithValue("ActionID", action.ActionID);
                        command.Parameters.AddWithValue("Description", actionText);
                        SqlExecutor.ExecuteNonQuery(_loginUser, command);
                    }
                    catch (Exception)
                    {
                        _logs.WriteEvent("Unable to sanitize action: " + action.ActionID);
                    }
                }

                try
                {
                    //actionText = HtmlToText.ConvertHtml(actionText);
                    actionsBuilder.AppendLine(actionText);
                }
                catch (Exception ex)
                {
                    _logs.WriteEvent("Unable to convert action html: " + action.ActionID);
                    _logs.WriteException(ex);
                }
            }

            DocText = actionsBuilder.ToString();

            _docFields.Clear();
            foreach (DataColumn column in ticket.Collection.Table.Columns)
            {
                object value = ticket.Row[column];
                string s     = value == null || value == DBNull.Value ? "" : value.ToString();
                AddDocField(column.ColumnName, s);
            }

            CustomValues customValues = new CustomValues(_loginUser);

            customValues.LoadByReferenceType(_organizationID, ReferenceType.Tickets, ticket.TicketTypeID, ticket.TicketID);

            foreach (CustomValue value in customValues)
            {
                object o = value.Row["CustomValue"];
                string s = o == null || o == DBNull.Value ? "" : o.ToString();
                AddDocField(value.Row["Name"].ToString(), s);
            }
            DocFields = _docFields.ToString();

            DocIsFile       = false;
            DocName         = ticket.TicketID.ToString();
            DocDisplayName  = string.Format("{0}: {1}", ticket.TicketNumber.ToString(), ticket.Name);
            DocCreatedDate  = (DateTime)ticket.Row["DateCreated"];
            DocModifiedDate = (DateTime)ticket.Row["DateModified"];
        }
Пример #5
0
        override protected void GetNextRecord()
        {
            AssetsViewItem asset = AssetsView.GetAssetsViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = asset.AssetID;
            UpdatedItems.Add((int)_lastItemID);

            StringBuilder builder = new StringBuilder();

            builder.AppendLine(asset.CreatorName
                               + " " + asset.DisplayName
                               + " " + asset.DateCreated
                               + " " + asset.DateModified
                               + " " + asset.ModifierName
                               + " " + asset.Notes
                               + " " + asset.ProductName
                               + " " + asset.ProductVersionNumber
                               + " " + asset.SerialNumber
                               + " " + asset.WarrantyExpiration);

            AssetHistoryView assetHistoryView = new AssetHistoryView(_loginUser);

            assetHistoryView.LoadByAssetID(asset.AssetID);
            foreach (AssetHistoryViewItem assetHistoryViewItem in assetHistoryView)
            {
                builder.AppendLine(assetHistoryViewItem.ActionTime
                                   + " " + assetHistoryViewItem.ActionDescription
                                   + " " + assetHistoryViewItem.NameAssignedFrom
                                   + " " + assetHistoryViewItem.NameAssignedTo
                                   + " " + assetHistoryViewItem.TrackingNumber
                                   + " " + assetHistoryViewItem.ShippingMethod
                                   + " " + assetHistoryViewItem.ReferenceNum
                                   + " " + assetHistoryViewItem.Comments
                                   + " " + assetHistoryViewItem.ActorName
                                   + " " + assetHistoryViewItem.DateModified
                                   + " " + assetHistoryViewItem.ModifierName
                                   + " " + assetHistoryViewItem.DateCreated);
            }

            DocText = builder.ToString();

            StringBuilder assetLocationString = new StringBuilder();

            switch (asset.Location)
            {
            case "1":
                assetLocationString.Append("Assigned");
                break;

            case "2":
                assetLocationString.Append("Warehouse");
                break;

            case "3":
                assetLocationString.Append("Junkyard");
                break;
            }
            _docFields.Clear();
            AddDocField("AssetID", asset.AssetID);
            AddDocField("Location", assetLocationString.ToString());
            AddDocField("SerialNumber", asset.SerialNumber);

            if (string.IsNullOrWhiteSpace(asset.Name))
            {
                if (string.IsNullOrWhiteSpace(asset.SerialNumber))
                {
                    AddDocField("Name", asset.AssetID);
                    DocDisplayName = asset.AssetID.ToString();
                }
                else
                {
                    AddDocField("Name", asset.SerialNumber);
                    DocDisplayName = asset.SerialNumber;
                }
            }
            else
            {
                AddDocField("Name", asset.Name);
                DocDisplayName = asset.Name;
            }

            InventorySearchAsset assetItem = new InventorySearchAsset(asset);

            AddDocField("**JSON", JsonConvert.SerializeObject(assetItem));

            CustomValues customValues = new CustomValues(_loginUser);

            customValues.LoadByReferenceType(_organizationID, ReferenceType.Assets, asset.AssetID);

            foreach (CustomValue value in customValues)
            {
                object o = value.Row["CustomValue"];
                string s = o == null || o == DBNull.Value ? "" : o.ToString();
                AddDocField(value.Row["Name"].ToString(), s);
            }
            DocFields = _docFields.ToString();
            DocIsFile = false;
            DocName   = asset.AssetID.ToString();
            try
            {
                DocCreatedDate  = (DateTime)asset.Row["DateCreated"];
                DocModifiedDate = (DateTime)asset.Row["DateModified"];
            }
            catch (Exception)
            {
            }
        }
        protected override void GetNextRecord()
        {
            ContactsViewItem contact = ContactsView.GetContactsViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = contact.UserID;
            UpdatedItems.Add((int)_lastItemID);

            List <CustomerSearchPhone> phones = new List <CustomerSearchPhone>();
            StringBuilder builder             = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(contact.Email))
            {
                builder.AppendLine(Regex.Replace(contact.Email, "[,.]+", ""));
            }
            PhoneNumbers phoneNumbers = new PhoneNumbers(_loginUser);

            phoneNumbers.LoadByID(contact.UserID, ReferenceType.Users);
            foreach (PhoneNumber number in phoneNumbers)
            {
                phones.Add(new CustomerSearchPhone(number));
                builder.AppendLine(Regex.Replace(number.Number, "[^0-9]", ""));
            }

            Addresses addresses = new Addresses(_loginUser);

            addresses.LoadByID(contact.UserID, ReferenceType.Users);
            foreach (Address address in addresses)
            {
                builder.AppendLine(address.Description
                                   + " " + address.Addr1
                                   + " " + address.Addr2
                                   + " " + address.Addr3
                                   + " " + address.City
                                   + " " + address.State
                                   + " " + address.Zip
                                   + " " + address.Country);
            }

            EmailAddresses emailAddresses = new EmailAddresses(_loginUser);

            emailAddresses.LoadByRefID(contact.UserID, ReferenceType.Users);
            foreach (EmailAddress emailAddress in emailAddresses)
            {
                builder.AppendLine(Regex.Replace(emailAddress.Email, "[,.]+", ""));
            }

            _docFields.Clear();
            AddDocField("UserID", contact.UserID);
            AddDocField("OrganizationID", contact.OrganizationID);
            AddDocField("Organization", contact.Organization);
            AddDocField("Email", contact.Email);
            AddDocField("IsActive", contact.IsActive);

            if (string.IsNullOrWhiteSpace(contact.FirstName))
            {
                AddDocField("Name", contact.LastName);
                DocDisplayName = string.IsNullOrWhiteSpace(contact.FirstName) ? "" : contact.FirstName.Trim();
            }
            else
            {
                AddDocField("Name", contact.FirstName + " " + contact.LastName);
                DocDisplayName = contact.LastName.Trim() + (string.IsNullOrWhiteSpace(contact.FirstName) ? "" : ", " + contact.FirstName.Trim());
            }

            builder.AppendLine(Regex.Replace(DocDisplayName, "[^a-zA-Z0-9 -]", ""));
            builder.AppendLine(Regex.Replace(contact.Organization, "[^a-zA-Z0-9 -]", ""));

            DocText = builder.ToString();

            CustomerSearchContact contactItem = new CustomerSearchContact(contact);

            contactItem.phones = phones.ToArray();
            TicketsView tickets = new TicketsView(_loginUser);

            contactItem.openTicketCount = tickets.GetUserTicketCount(contact.UserID, 0);

            AddDocField("**JSON", JsonConvert.SerializeObject(contactItem));

            CustomValues customValues = new CustomValues(_loginUser);

            customValues.LoadByReferenceType(_organizationID, ReferenceType.Contacts, contact.UserID);

            foreach (CustomValue value in customValues)
            {
                object o = value.Row["CustomValue"];
                string s = o == null || o == DBNull.Value ? "" : o.ToString();
                AddDocField(value.Row["Name"].ToString(), s);
            }

            DocFields       = _docFields.ToString();
            DocIsFile       = false;
            DocName         = contact.UserID.ToString();
            DocCreatedDate  = (DateTime)contact.Row["DateCreated"];
            DocModifiedDate = (DateTime)contact.Row["DateModified"];
        }
Пример #7
0
        override protected void GetNextRecord()
        {
            OrganizationsViewItem organization = OrganizationsView.GetOrganizationsViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = organization.OrganizationID;
            UpdatedItems.Add((int)_lastItemID);

            StringBuilder builder             = new StringBuilder();
            List <CustomerSearchPhone> phones = new List <CustomerSearchPhone>();
            PhoneNumbers phoneNumbers         = new PhoneNumbers(_loginUser);

            phoneNumbers.LoadByID(organization.OrganizationID, ReferenceType.Organizations);
            foreach (PhoneNumber number in phoneNumbers)
            {
                phones.Add(new CustomerSearchPhone(number));
                builder.AppendLine(Regex.Replace(number.Number, "[^0-9]", ""));
            }

            Addresses addresses = new Addresses(_loginUser);

            addresses.LoadByID(organization.OrganizationID, ReferenceType.Organizations);
            foreach (Address address in addresses)
            {
                builder.AppendLine(address.Description
                                   + " " + address.Addr1
                                   + " " + address.Addr2
                                   + " " + address.Addr3
                                   + " " + address.City
                                   + " " + address.State
                                   + " " + address.Zip
                                   + " " + address.Country);
            }

            builder.AppendLine(Regex.Replace(organization.Name, "[^a-zA-Z0-9 -]", ""));

            DocText = builder.ToString();
            _docFields.Clear();
            AddDocField("OrganizationID", organization.OrganizationID);
            AddDocField("Name", organization.Name);
            AddDocField("Description", organization.Description);
            AddDocField("Website", organization.Website);
            AddDocField("IsActive", organization.IsActive);
            AddDocField("PrimaryContact", organization.PrimaryContact);
            AddDocField("IsParent", Organizations.GetIsParent(_loginUser, organization.OrganizationID));

            CustomerSearchCompany companyItem = new CustomerSearchCompany(organization);

            companyItem.phones = phones.ToArray();
            TicketsView tickets = new TicketsView(_loginUser);

            companyItem.openTicketCount = tickets.GetOrganizationTicketCount(organization.OrganizationID, 0);

            AddDocField("**JSON", JsonConvert.SerializeObject(companyItem));

            CustomValues customValues = new CustomValues(_loginUser);

            customValues.LoadByReferenceType(_organizationID, ReferenceType.Organizations, organization.OrganizationID);

            foreach (CustomValue value in customValues)
            {
                object o = value.Row["CustomValue"];
                string s = o == null || o == DBNull.Value ? "" : o.ToString();
                AddDocField(value.Row["Name"].ToString(), s);
            }

            DocFields       = _docFields.ToString();
            DocIsFile       = false;
            DocName         = organization.OrganizationID.ToString();
            DocDisplayName  = string.IsNullOrWhiteSpace(organization.Name) ? "" : organization.Name.Trim();
            DocCreatedDate  = (DateTime)organization.Row["DateCreated"];
            DocModifiedDate = (DateTime)organization.Row["DateModified"];
        }