Skip to main content

From Basecamp to MS Project

I don't hide the fact that I really like Basecamp from anyone I know. Free for single projects and with a relatively low price-point, I've gotten one of my clients to use it for basic tracking of projects. I've also logged into Huddle ( a similar DotNet offering from British-based Ninian Solutions)) but haven't gotten right into it just yet.



One of the great things offered by Basecamp is the Basecamp API - which they describe as plain vanilla xml over HTTP.  A lot of the samples that integrate with Basecamp are primarily web-based or widgets. I think that's primarily because of the synergy of the Web 2.0 world - but you can just as easily integrate Basecamp with Windows-based apps directly with a little bit of COM automation.



While I did some basic stuff like posting messages and updating items with the API, I found imified more useful to do updates over instant messenger instead.



However, when one of our sales managers asked for an MS Project file of all the outstanding Basecamp projects, I knew it was a challenge I wanted to face.(in FoxPro and West-Wind IP Tools - of course!)



I created a number of classes to accomplish this, using collections and custom classes.



PUBLIC loBase

loBase = CREATEOBJECT("Custom")

loBase.AddObject("Projects","Collection")

loBase.AddObject("Users","Collection")

loBase.AddObject("Companies","Collection")



But the basis for everything else was pretty straight forward:

lox = lo.gethttp()

? lox.httpconnect(basecampsite,"username","password",.t.)

 lox.nhttppostmode = 4

LOCAL loXML

lcPosts = " "

lnText = 0

lnResult=lox.HTTPGetEx("/project/list",@lcPosts,@lnText,"Accept: application/xml")



loXML = CREATEOBJECT("MSXML.DomDocument")

IF loXML.LoadXML(lcPosts)

    loProjects = loXML.selectnodes("//project")

    FOR lni = 1 TO loProjects.length

        loProj =loProjects.item(lni-1)

        WITH loBase.Projects

        .Add(NEWOBJECT("cbaseproject"))

        .Item(.Count).ProjectName =loProj.selectsinglenode("name").nodetypedvalue

        .Item(.Count).ProjectID =loProj.selectsinglenode("id").nodetypedvalue

        .Item(.Count).Status =loProj.selectsinglenode("status").nodetypedvalue

        ENDWITH

    ENDFOR

ENDIF



I did a similar part for Companies and Users in the system. This was necessary to link projects to individuals and the like.



Within the cbaseproject class, I created a method called GetTasks , GetPeople and GetMilestones that all looked pretty much like this:

DEFINE CLASS cBaseProject AS Custom

    ProjectID = 0

    ProjectName = ""

    Status = ""

    Company = ""

   

    PROCEDURE GetTasks

    lcPosts = " "

    lnText = 0

   

** Reconnect


lnResult=lox.HTTPGetEx("/projects/"+THIS.ProjectID+"/todos/lists",@lcPosts,@lnText,"Accept: application/xml")

loXML = CREATEOBJECT("MSXML.DomDocument")

IF loXML.LoadXML(lcPosts)

    loProjects = loXML.selectnodes("//todo-list")

    THIS.AddObject("TaskLists","Collection")

    FOR lni = 1 TO loProjects.length

        loProj =loProjects.item(lni-1)

        WITH THIS.TaskLists

            .Add(NEWOBJECT("cbasetask"))

            .Item(.Count).TaskName =loProj.selectsinglenode("name").nodetypedvalue

            .Item(.Count).Description =loProj.selectsinglenode("description").nodetypedvalue

            .Item(.Count).ID =loProj.selectsinglenode("id").nodetypedvalue

        ENDWITH

    ENDFOR

ENDIF



    ENDPROC

   

    PROCEDURE GetMilestones

    lcPosts = " "

    lnText = 0

   

** Reconnect

lnResult=lox.HTTPGetEx("/projects/"+THIS.ProjectID+"/milestones/list",@lcPosts,@lnText,"Accept: application/xml")

loXML = CREATEOBJECT("MSXML.DomDocument")

IF loXML.LoadXML(lcPosts)

    loProjects = loXML.selectnodes("//milestone")

    THIS.AddObject("MileStones","Collection")

    FOR lni = 1 TO loProjects.length

        loProj =loProjects.item(lni-1)

        WITH THIS.Milestones

            .Add(NEWOBJECT("cMilestone"))

            .Item(.Count).Title =loProj.selectsinglenode("title").nodetypedvalue

            .Item(.Count).ID =loProj.selectsinglenode("id").nodetypedvalue

            .Item(.Count).Deadline =loProj.selectsinglenode("deadline").nodetypedvalue

            .Item(.Count).xml = loProj.Xml

            .Item(.Count).person = getperson(loProj.selectsinglenode("responsible-party-id").nodetypedvalue)

            TRY

            .Item(.Count).Completed = loProj.selectsinglenode("completed").nodetypedvalue="true"

            .Item(.Count).CompletedOn =loProj.selectsinglenode("completed-on").nodetypedvalue

            CATCH

            ENDTRY

        ENDWITH

    ENDFOR

ENDIF



    ENDPROC



  

ENDDEFINE



From here, I was now simply going to create or update my MS Project file.



LOCAL lcText

loapp = GETOBJECT(,"MSProject.application")

loProject = loapp.activeproject



LOCAL lnStartRow

lnStartRow=0

lcText = ""

LOCAL loP

FOR EACH loP IN lobase.projects

    IF NOT PEMSTATUS(lop,"milestones",5)

        lop.GetMilestones()

    ENDIF

    loProject.Tasks.add(lop.projectname)

    lnStartRow=lnStartRow+1

    loApp.selectrange(lnStartRow,3,.f.)

    loApp.outlineoutdent()

    lnS = 0

    FOR EACH loM IN lop.Milestones

        lnS = lns+1

        tsk = loProject.Tasks.add(lom.Title)

        tsk.milestone = .t.

        lnStartRow=lnStartRow+1

        loApp.selectrange(lnStartRow,3,.f.)

        IF lnS=1

            loApp.outlineindent()

        ENDIF

        IF NOT lom.Completed

            *!* ? lom.Title + " due on " + lom.deadline +" by "+lom.person

            tsk.finish = DATE(VAL(LEFT(lom.deadline,4)),VAL(SUBSTR(lom.deadline,6,2)),VAL(RIGHT(lom.deadline,2)))

        ELSE

            tsk.percentcomplete = 100

            tsk.finish = DATE(VAL(LEFT(lom.completedon,4)),VAL(SUBSTR(lom.completedon,6,2)),VAL(SUBSTR(lom.completedon,9,2)))

        ENDIF

    ENDFOR

ENDFOR





The end result? I can give a project file that always includes the latest updates to those who like the graphics appeal and project-reporting of MS Project.





Basecamp API



Powered by ScribeFire.

Comments

I agree w/ Mr. Mabusela....you just made my assignment easier. Our last assignment for the term is to create a gantt chart for training a group of data analysts. Thus, the last assignment requires us to learn a new software package. Project Libre is definitely easier than MS 2013 and you made it even easier still. Thank you, Project Woman!

Popular posts from this blog

Elevating Project Specifications with Three Insightful ChatGPT Prompts

For developers and testers, ChatGPT, the freely accessible tool from OpenAI, is game-changing. If you want to learn a new programming language, ask for samples or have it convert your existing code. This can be done in Visual Studio Code (using GitHub CoPilot) or directly in the ChatGPT app or web site.  If you’re a tester, ChatGPT can write a test spec or actual test code (if you use Jest or Cypress) based on existing code, copied and pasted into the input area. But ChatGPT can be of huge value for analysts (whether system or business) who need to validate their needs. There’s often a disconnect between developers and analysts. Analysts complain that developers don’t build what they asked for or ask too many questions. Developers complain that analysts haven’t thought of obvious things. In these situations, ChatGPT can be a great intermediary. At its worst, it forces you to think about and then discount obvious issues. At best, it clarifies the needs into documented requirements. ...

I’m Supposed to Know

https://programmingzen.com/im-supposed-to-know/ Great post for developers who are struggling with unrealistic expectations of what they should know and what they shouldn't. Thirty-forty years ago, it was possible to know a lot about a certain environment - that environment was MS-DOS (for non Mac/UNIX systems). . There was pretty much only a handful of ways to get things going. Enter networking. That added a new wrinkle to how systems worked. Networks back then were finicky. One of my first jobs was working on a 3COM + LAN and it then migrated to LAN Manager. Enter Windows or the graphical user interface. The best depiction of the complexity Windows (OS/2, Windows NT, etc) introduced that I recall was by Charles Petzold (if memory serves) at a local user group meeting. He invited a bunch of people on the stage and then acted as the Windows "Colonel", a nice play on kernel. Each person had a role but to complete their job they always had to pass things back to h...

Blogs and RSS come to Microsoft.com

MS has just introduced their portal and it's pretty comprehensive. Nothing quite like learning that some people use AIM instead of MSN messenger, or that there really may be a need for supporting 4 monitors ( Cyrus Complains ) However, it's really a great sign that MS is serious about supporting the blogging community which seems to have um, exploded in size in the past year. Blogs and RSS come to Microsoft.com