disappearing podcasts

I wanted to watch a little Tekzilla this morning, and was surprised to find Tekzila had completely disappeared from my iTunes library. Then, I noticed that about half the podcasts I download are completely missing from iTunes. Some of them are video podcasts, and some are audio. Some are podcasts that I sync to my iPhone, and some aren’t. No particular pattern.

The ones that I sync to my iPhone are still on the iPhone, but not on my Mac. And there doesn’t seem to be any way to get them back up to the Mac. They’re not in the file system, but just missing from iTunes. And they’re not in the trash. They’re just all gone.

I’ve looked around Apple’s support forums, and I’ve seen that a lot of people have had similar problems, but I haven’t found any solution that really matches my particular problem. I’m pretty sure that, at this point, I’m going to have to re-download all the podcast episodes that I haven’t listened to yet, so that’s a pain, but I really don’t know if the problem is going to recur, or if this was just a one-time thing.

I’m so annoyed with this now that I want to switch to a different podcast client, but I’m not sure if there’s a good one that actually does what I want it to — download on the Mac, and sync selected stuff to the phone. I’m looking at Downcast and Instacast right now. I’ll probably post a follow-up on this at some point, when I figure out what I’m doing.

checking user roles in AX 2012

It’s been a while since I’ve posted anything related to Dynamics AX / X++, so I thought I’d write up something I stumbled across recently. I had created a custom form, with a number of buttons on it. Two of the buttons needed to be available only to users in a certain role.

Well, first, I should point out that this can be done without any code. See here and here for information on that. And there are good reasons to do it this way, in many cases.

But there are also some good reasons to do this in code. It allows you to document what you’re doing and why, and it gives you more flexibility than just doing it through properties in the AOT. In my case, the business rules around this didn’t really fit into the permissions available in the AOT (Read, Update, Create, and Delete), so while I could have picked one of those and used it, it wouldn’t have accurately reflected the actual use case.

So I first wanted to find a method in X++ that would tell me if a given user was in a given role. I’m familiar with Roles.IsUserInRole from the .NET Framework, and have used it frequently in the context of ASP.NET sites using custom membership providers. So I looked for something similar in AX. That led me to the SysUserManagement Class.

I wound up writing a utility method that made use of this class:

// https://gist.github.com/andyhuey/9326912
/// <summary>
/// return true is the specified user is in any of the roles in the roleNames container.
/// </summary>
/// <param name="axUserId">
/// AX user id, e.g. curUserId()
/// </param>
/// <param name="roleNames">
/// container of role names to check. (use role NAME, not label.)
/// </param>
/// <returns>
/// true if user is in ANY of the specified roles.
/// </returns>
/// <remarks>
///
/// </remarks>

public static boolean isUserInRole(UserId axUserId, container roleNames)
{
    SysUserManagement userManagement = new SysUserManagement();
    List roleList = userManagement.getRolesForUser(axUserId);
    ListEnumerator listEnum = null;
    boolean isInRole = false;
    str roleStr = '';

    if (!roleList)
        return false;

    listEnum = roleList.getEnumerator();
    while (listEnum.moveNext())
    {
        if (conFind(roleNames, listEnum.current()))
            return true;
    }

    return false;
}

It worked fine on my VM, when logged in under my own ID. But, after deployment, it quickly became apparent that X++ code running under a normal user account (without SYSADMIN rights) can’t call methods in the SysUserManagement class. Now, there’s nothing I can see in the documentation that indicates that, but I should of course have tested my code under a normal user account.

So I rewrote my code to access the appropriate role-related tables directly, and it turns out that a normal user can do that, no problem:

// https://gist.github.com/andyhuey/9326939
/// <summary>
/// return true is the specified user is in any of the roles in the roleNames container.
/// </summary>
/// <param name="axUserId">
/// AX user id, e.g. curUserId()
/// </param>
/// <param name="roleNames">
/// container of role names to check. (use role NAME, not label.)
/// </param>
/// <returns>
/// true if user is in ANY of the specified roles.
/// </returns>
/// <remarks>
/// ajh 2014-02-12: previous method req'd admin perm. to run. Doh!
/// </remarks>

public static boolean isUserInRole(UserId axUserId, container roleNames)
{
    SecurityUserRole securityUserRole;
    SecurityRole securityRole;

    while select AotName from securityRole
    join securityUserRole
    where securityUserRole.User == axUserId
    && securityUserRole.SecurityRole == securityRole.RecId
    {
        if (conFind(roleNames, securityRole.AotName))
            return true;
    }
    return false;
}

So I guess the lesson here is to always test your code under a normal user account, and not to assume that the MSDN page for a given AX class will tell you everything you need to know about that class.

And, as with a lot of stuff in AX, I have a feeling that I’m still doing this “the wrong way”, even though my code works and is fairly simple. I’m guessing that, a year from now, I’ll have figured out that there’s a better way to do this.

Anime watching

It’s been so cold out, I decided to just cocoon myself in my apartment this weekend and watch anime. I haven’t actually done that in quite a while. It was kind of fun. I watched the first twelve episodes of Gatchaman, and the first season of Big O. Looking back at some old posts on this blog, I see that I’ve had the Big O DVDs sitting around since 2006. The Gatchaman DVDs are probably almost as old.

Gatchaman was fun to watch, and very campy (as I expected it would be). I don’t think I’m interested in watching any more of it though. It was fun, and nostalgic, but repetitive. I have only vague memories of watching Battle of the Planets as a kid, but they’re good memories, and it was fun to see what the original source material was like.

Big O was quite good. Kind of ridiculous, but the visual style of it is really great. It’s clearly referencing a number of disparate influences, such as the old Bruce Timm Batman animated series. The first season ends on a cliffhanger, so now I’m wishing I’d bought the second season when I bought the first.

I haven’t been closely following anime news for the past couple of years, so I’m just noticing now that a number of the companies that were issuing DVDs a few years ago are out of business now, and used copies of some DVDs are going for pretty high prices. It looks like a new company has picked up the Big O license, so they may re-issue the DVDs. Here’s hoping!

If this cold spell keeps going, I may be watching my Samurai 7 box set next weekend.

Automation

I don’t think I’ve ever linked to an XKCD comic on this blog before, but (of course) I read it regularly. This one made me chuckle, thinking about a project I’m currently working on. I have a task that involves generating output files and sending them to a few other companies via SFTP, weekly. For “phase one,” I was going to manually run my program to generate the files, then send them out with WinSCP. Then, once that was running smoothly, I was going to add SFTP capability to the program, using SSH.NET.
This is kind of a long story, but to make it short, let’s just say that I’ve spent more time than is really reasonable taking care of the SFTP automation, and have yet to put it into production. Meanwhile, I just keep sending out the files every week, manually.
I’ve actually learned a lot about a couple of things in the process of working on this automation, but the amount of effort that’s gone into the automation, vs. the five minutes it takes to send the files off manually once a week is a bit silly.

Happy New Year

I thought I would write up a quick New Year’s post today, with a few status updates. I mostly write this kind of post for my own future reference, just to see where I’ve been, and what progress (if any) I’ve made in certain areas.

First, I’m happy to say that I stepped on the scale this morning, and it read 200 pounds. I started my diet around Sept 1, at 230 lbs, with the goal of losing a pound a week, until I hit 200. So I hit my goal, and I hit it earlier than expected. I guess my next goal will be to get down to 180, again at one pound per week. We’ll see if I can manage that. I’m still logging all my calories with the Lose It app on my phone. I think that’s really been the key factor in being successful. I’m not sure when I was last under 200 lbs. Maybe back in college?

On another front, I haven’t done quite so good. I blogged, back in November, about Coursera. I had enrolled in two courses, Algorithms, Parts I and II. Part I was technically done before I enrolled, and Part II was just starting up. My plan was to breeze through the first part, then catch up with the second. I was doing OK up through the end of November, and gotten through about 80% of the material in Part I, but then I got busy with other stuff in December, and never went back to it. Meanwhile, Part II wrapped up, so here it is, 2014, and I haven’t done anything on Coursera in a month. It looks like I can still watch the lectures, and even submit the programming assignments for auto-grading, so I may just pick it up again this month, and finish Part I. Or I may wait until it “officially” starts up again, on January 30, and try to take it in “real-time”. Then, I can take Part II in real-time, when it’s next offered in March. Or maybe I’ll just try something different this year, either from Coursera or EdX.

Professionally, I started my job at SHI in January 2013, so I’m at just about the one year mark there. I had my performance review with my boss yesterday, and it went pretty well. I’ll likely stick with SHI for another year. Given that I’m doing almost 100% Dynamics AX work though, I want to see about doing more web stuff on the side this year. Last year, I did a project for my former employer, Electric Vine, that allowed me to exercise my ASP.NET and JavaScript skills a bit, but I don’t have any consulting work planned for 2014. I should really find some, or maybe get involved in an open source project, or something like that.