Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get object with AssetTag #17

Closed
danxpar opened this issue Jan 4, 2019 · 5 comments
Closed

Get object with AssetTag #17

danxpar opened this issue Jan 4, 2019 · 5 comments

Comments

@danxpar
Copy link

danxpar commented Jan 4, 2019

Hi Barry,
Really appreciate you putting this together, thanks for all your work.

I can successfully get an object using the Get object with Name.
but I was wondering if it is possible to Get and object with AssetTag?

I may be doing something wrong.

Sorry if you no longer are doing much with this, but I thought I'd just ask.

Kind Regards,

Dan.

@danxpar
Copy link
Author

danxpar commented Jan 4, 2019

Okay I solved it another way,
I just did a GetAll, and then searched for the Asset Tag through the returned data.
Here is my snippet...

        //define variables and load tempAllAssetArray with all snipeit Records
        var thisDeviceTag = "12345"
        var tempAllAssetArray = snipe.AssetManager.GetAll();
        Asset foundDevice = null;

        //loop through them all looking for the match to the AssetTag
        foreach(var tempAsset in tempAllAssetArray.Rows)
        {
            if (tempAsset.AssetTag == thisDeviceTag)
            {
                // convert long to int
                int i = (int)tempAsset.Id;
                //load the found device to the variable
                foundDevice = snipe.AssetManager.Get(i);
                // only one Asset Tag per asset so we can continue and not break the for loop
            }
            
        }
        // clear the memory
        tempAllAssetArray = null;

Please excuse my code, i'm sure there are many other ways to skin a bird with a glass house...
Kind regards and thanks again,
Dan

@danxpar danxpar closed this as completed Jan 4, 2019
@barrycarey
Copy link
Owner

Hello,

It's been a long time since I've gone through the code on this. Looking at it I don't think it's possible as it stands. However, you could extend AssertSearchFilter to include the asset tag field. I'm pretty sure that will work.

@danxpar
Copy link
Author

danxpar commented Jan 4, 2019

Thanks for the reply,
It's working for now with my mish-mash, I don't have many devices to manage, but will definitely look into it.

@cofl
Copy link

cofl commented Jan 4, 2019

I've got a pull request for a GetByAssetTag(string) method in #18.

@danxpar
Copy link
Author

danxpar commented Jan 6, 2019

Awesome, I'll test it out.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants