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

Change item id from int to long #59

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

michaelmarziani
Copy link

The item id for newly created items no longer fits within an int, thus throwing an exception when such items are parsed.

Copy link

@Ldatz Ldatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgive me if I'm incorrect. I'm looking at this code for the first time. Should public async Task int CloneItem(long itemId, bool silent = false) be Task long?

AjmalVh
AjmalVh previously approved these changes Jul 9, 2022
maarand
maarand previously approved these changes Jul 11, 2022
lowderjh
lowderjh previously approved these changes Jul 11, 2022
@michaelmarziani
Copy link
Author

forgive me if I'm incorrect. I'm looking at this code for the first time. Should public async Task int CloneItem(long itemId, bool silent = false) be Task long?

@Ldatz Thanks for the review and I believe you're correct. I'll update the PR with this fix.

@michaelmarziani michaelmarziani dismissed stale reviews from lowderjh, maarand, and AjmalVh via d90a1c7 July 11, 2022 11:18
@JonTvermose
Copy link

@michaelmarziani There are still a couple of places in ItemService.cs where the itemId is referred as an int

public async Task<Item> GetItem(int itemId, bool markedAsViewed = true)

public async Task<Item> GetItemByAppItemId(int appId, int appItemId)

And for these two I believe the int arrays should be changed to long arrays.

public async Task<List<Item>> GetTopValuesByField(int fieldId, int limit = 13, int[] notItemIds = null)

public async Task<List<Item>> FindReferenceableItems(int fieldId, int limit = 13, int[] notItemIds = null,

@michaelmarziani
Copy link
Author

@JonTvermose Thank you for the review. I agree with all the places you pointed out except the 2nd. The app item id is different than the global item id.

public async Task<Item> GetItemByAppItemId(int appId, int appItemId)

I've updated the PR to reflect the 3 fixes you pointed out.

@JonTvermose
Copy link

JonTvermose commented Jul 18, 2022

@michaelmarziani

This method probably needs an overload to accept long arrays :) Otherwise I suspect the code wont compile.

internal static string ArrayToCSV(int[] array, string splitter = ",")

Edit:
I also see some issues in CommentService.cs where the id can also be an itemId if the type specified is "item"

public async Task<List<Comment>> GetCommentsOnObject(string type, int id)

public async Task<int> AddCommentToObject(string type, int id, string text, string externalId = null,

public async Task<int> AddCommentToObject(string type, int id, CommentCreateUpdateRequest comment, bool alertInvite = false,

There are probably more places as well, but those are the ones I've encountered so far.
I have created a fork of this repository and published a nuget package (https://www.nuget.org/packages/Tvermose.Podio.Async) as our production system has been hit by this error.. Hope things get fixed in this repository eventually so I can revert back and delete the fork :-)

@michaelmarziani
Copy link
Author

@JonTvermose Would you be willing to send a PR based on your code? If so I'll cancel mine, as it looks like you've already done this work.

@GuidoKuth
Copy link

@JonTvermose Thank you for the review. I agree with all the places you pointed out except the 2nd. The app item id is different than the global item id.

public async Task<Item> GetItemByAppItemId(int appId, int appItemId)

I've updated the PR to reflect the 3 fixes you pointed out.

There seems to be one more place that have to be modified. Even if I saw in the code that this is already done it is not in your nuget package.

public async Task<Item> GetItemBasic(long itemId, bool markedAsViewed = true)

@ManuBermudez17
Copy link

ManuBermudez17 commented Jul 21, 2022

Do you know when they will commit a fix to this issue on podio/podio-dotnet?
Will someone publish these updates as packages on nuget?

@michaelmarziani
Copy link
Author

@ManuBermudez17 My sense of things is that this is a purely speculative PR, which may some day be merged and re-released, or not. The reason for this is that this library is no longer officially maintained, the repo has been archived, and it's been tagged with "No maintenance intended".

@michaelmarziani
Copy link
Author

@JonTvermose Would you be willing to send a PR based on your code? If so I'll cancel mine, as it looks like you've already done this work.

Jon et al,

I ended up integrating all the fixes from your repository. You can see the current diff between what you have and what I have:
https://github.com/JonTvermose/podio-dotnet/compare/master..ioSlate:podio-dotnet:master

I believe my code is ready for review now, having integrated all the feedback.

@ManuBermudez17
Copy link

@michaelmarziani I am using the synchronous way, I have tried the asynchronous way and I would have to change several things in the code. Is there any way to get some updated PR of the synchronous part to insert in my project? Because the packages that I see in nuget updated, are asynchronous. And I have tried some asynchronous one and I get several errors regarding the code I have.

@michaelmarziani
Copy link
Author

@ManuBermudez17 I wish I could answer that. I noticed myself that when I rebuilt the code, all my sync methods became async and I had to rework them to work with the async code.

What I noticed is that there are 2 directories under Source, one named Podio .NET, the other Podio.Async. All the code is located in the Podio .NET directory, and the code looks like it's built to be async. There must be something in one of the project or solution files (there are many) that tells the code to build without async, but I don't know what it is.

If you have an hints or could point me in the right direction, I'd be happy to try to build a sync version and try to publish it to nuget.

@ManuBermudez17
Copy link

@michaelmarziani I am like you. I have tried to compile from the Podio .NET folder, but as you say, it is asynchronous and several methods that I use fail with errors.

For example:

var filteredItems = podio.ItemService.FilterItems(appId: functionsPodio.appClientesId, filters: filter);
var filteredItemsString =  filteredItems.Filtered.ToString();

In Filtered it tells me that there is no accessible method with that name.

I have in my code:

using PodioAPI;
using PodioAPI.Utils.ItemFields;

Just like looping through a foreach, I did it like this:

foreach (var item in filteredItems.Items)
{
  ...
}

But also in Items, it tells me that there is no accessible method with that name.

And I can't find any manual on how to use the asynchronous way correctly.

@ManuBermudez17
Copy link

ManuBermudez17 commented Jul 21, 2022

@michaelmarziani I have found this branch v1, which I see that the last commits are from 2018 and I do not see the asynchronous folder, which may be the synchronous version. I would have to test it to see if it is valid for the project and I would have to update with the changes proposed by you.

Branch: https://github.com/podio/podio-dotnet/tree/v1/Source

@ManuBermudez17
Copy link

I have tried the branch that I have previously posted, and it works for me with all the code that I had developed synchronously.

I would only have to test the changes made in the files that are named here, to see if everything is correct.

@GuidoKuth
Copy link

@JonTvermose I changed the nuget package from podio.async to yours mentioned above but there are some changes missing. Would you be willing to update your nuget package to reflect all latest changes. I think this would help. Thank you for your work.

@michaelmarziani
Copy link
Author

I have tried the branch that I have previously posted, and it works for me with all the code that I had developed synchronously.

I would only have to test the changes made in the files that are named here, to see if everything is correct.

@ManuBermudez17 I looked at the v1 branch as well and it looks like up until July 7, 2018 both master and v1 were getting the same updates, so I agree that you could apply the same changes in this PR and use the v1 branch.

About the async code, I didn't have to change much, in case you're thinking of adapting your code to async. I had to change the method signature to return a Task for any methods that called Podio, and then await the Podio method, for example, sync code:

public int FetchItemFromPodio(Podio podio, long itemId)
{
    // Fetch the item
    var item = podio.ItemService.GetItemBasic(itemId);

    // Process the item and return 1 or 0 for success or failure
    // ...
}

Async code:

public async Task<int> FetchItemFromPodio(Podio podio, long itemId)
{
    // Fetch the item
    var item = await podio.ItemService.GetItemBasic(itemId);

    // Process the item and return 1 or 0 for success or failure
    // ...
}

Task is from System.Threading.Tasks.

@JonTvermose
Copy link

@JonTvermose I changed the nuget package from podio.async to yours mentioned above but there are some changes missing. Would you be willing to update your nuget package to reflect all latest changes. I think this would help. Thank you for your work.

@GuidoKuth Yes, I have updated the code and created a new package just now.

@ManuBermudez17
Copy link

@michaelmarziani I have created a branch on my github, with only the synchronous part and the changes made to make it work properly. I have tried it in my project and no error is thrown.

The only thing left would be to create the nuget package, but I've never created one.

Repository: https://github.com/ManuBermudez17/podio-dotnet-sync

@JonTvermose
Copy link

@michaelmarziani I have created a branch on my github, with only the synchronous part and the changes made to make it work properly. I have tried it in my project and no error is thrown.

The only thing left would be to create the nuget package, but I've never created one.

Repository: https://github.com/ManuBermudez17/podio-dotnet-sync

@ManuBermudez17 If you have visual studio, it's not that difficult to create a nuget package.

https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio?tabs=netcore-cli

@michaelmarziani
Copy link
Author

@AjmalVh @maarand @lowderjh when you have a spare moment, might I ask for a code review and approval if all looks good?

@JonTvermose Thanks for your advice and help.

@GuidoKuth
Copy link

GuidoKuth commented Jul 22, 2022

@JonTvermose I changed the nuget package from podio.async to yours mentioned above but there are some changes missing. Would you be willing to update your nuget package to reflect all latest changes. I think this would help. Thank you for your work.

@GuidoKuth Yes, I have updated the code and created a new package just now.

Thank you very much @JonTvermose but I think there is still something missing. I get en error in ItmeService.FilterItems cause the returned items still have an int type itemId.

In the meantime I digged a littel bit deeper and I think the Problem is in the ItemField class where the FieldId ist still an int.

@Ldatz
Copy link

Ldatz commented Jul 22, 2022

If you can't get a good working copy of Podio.Async, maybe you can start with the one called Malte.Podio.Async. I replaced the NuGet package Podio.Async with Malte.Podio.Async 2 weeks ago. I would prefer to install the package maintained by Citrix but, I couldn't wait.

@ManuBermudez17
Copy link

@Ldatz as @michaelmarziani commented, this package has the message that it will not have any more maintenance by Citrix.

https://developers.podio.com/clients/dotnet

@michaelmarziani
Copy link
Author

@ManuBermudez17 That's true this package is marked as no maintenance intended, but one of the maintainers, @PavloBasiuk and I exchanged a comment on stackoverflow where they indicated that perhaps if I submitted a PR that it might be merged, but no promises.

In any case, at the end of the day at least we'll all have a nuget package that works, whether this repo or one of our forks. I really appreciate all the people that have joined together to work on sorting this out.

@GuidoKuth
Copy link

If you can't get a good working copy of Podio.Async, maybe you can start with the one called Malte.Podio.Async. I replaced the NuGet package Podio.Async with Malte.Podio.Async 2 weeks ago. I would prefer to install the package maintained by Citrix but, I couldn't wait.

I gave it a try but I stil run into an error System.MissingMethodException: "Method not found: 'Int32 PodioAPI.Models.Item.get_ItemId()'."

@michaelmarziani
Copy link
Author

If you can't get a good working copy of Podio.Async, maybe you can start with the one called Malte.Podio.Async. I replaced the NuGet package Podio.Async with Malte.Podio.Async 2 weeks ago. I would prefer to install the package maintained by Citrix but, I couldn't wait.

I gave it a try but I stil run into an error System.MissingMethodException: "Method not found: 'Int32 PodioAPI.Models.Item.get_ItemId()'."

@GuidoKuth Can you post a snippet of the code that generates this error?

@Ldatz
Copy link

Ldatz commented Jul 23, 2022

Where are you getting the error: System.MissingMethodException: "Method not found: 'Int32 PodioAPI.Models.Item.get_ItemId()'."? After installing the Malte.Podio.Async NuGet package, I then had to change every occurrence of a call with an int item id to a long variable in my application that uses Podio.Async library.

@GuidoKuth
Copy link

If you can't get a good working copy of Podio.Async, maybe you can start with the one called Malte.Podio.Async. I replaced the NuGet package Podio.Async with Malte.Podio.Async 2 weeks ago. I would prefer to install the package maintained by Citrix but, I couldn't wait.

I gave it a try but I stil run into an error System.MissingMethodException: "Method not found: 'Int32 PodioAPI.Models.Item.get_ItemId()'."

@GuidoKuth Can you post a snippet of the code that generates this error?

Unfortunately not cause the error is thrown outside of my code.

@GuidoKuth
Copy link

Where are you getting the error: System.MissingMethodException: "Method not found: 'Int32 PodioAPI.Models.Item.get_ItemId()'."? After installing the Malte.Podio.Async NuGet package, I then had to change every occurrence of a call with an int item id to a long variable in my application that uses Podio.Async library.

Yes, I have done so. The error seems to be thrown in the library itself cause the error says in first line Thrown by external code.

@GuidoKuth
Copy link

If you can't get a good working copy of Podio.Async, maybe you can start with the one called Malte.Podio.Async. I replaced the NuGet package Podio.Async with Malte.Podio.Async 2 weeks ago. I would prefer to install the package maintained by Citrix but, I couldn't wait.

I gave it a try but I stil run into an error System.MissingMethodException: "Method not found: 'Int32 PodioAPI.Models.Item.get_ItemId()'."

@GuidoKuth Can you post a snippet of the code that generates this error?

Unfortunately not cause the error is thrown outside of my code.

I am very sorry for the confusion but as my project uses man packages and is deeply structured there was another Package Reference for Podio that caused the error. I changed the package reference to the Malte.Podio.Async nuget Package and everything works perfect. Again sorry for confusion and thanks to all for your help.

lowderjh
lowderjh previously approved these changes Jul 25, 2022
@michaelmarziani
Copy link
Author

Greetings collaborators, @lowderjh thank you for your approval and I wanted to ask if one more reviewer could give a final review and approval here if all looks good.

madslund
madslund previously approved these changes Aug 11, 2022
@JonTvermose
Copy link

I have released a new version of my fork where the Comment Id has also been changed to a long.
https://www.nuget.org/packages/Tvermose.Podio.Async

Github repo: https://github.com/JonTvermose/podio-dotnet

I have no affiliation with Podio, the fork exists as my production code is dependent on this library.

@GuidoKuth
Copy link

GuidoKuth commented Oct 11, 2022 via email

@michaelmarziani michaelmarziani dismissed stale reviews from madslund and lowderjh via 3e41562 March 7, 2023 16:45
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

Successfully merging this pull request may close these issues.

9 participants