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

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

Programmers vs. Developers vs. Architects

I received an email this morning from Brandon Savage 's newsletter. Brandon's a PHP guru (works at Mozilla) but his newsletter and books have some great overall perspectives for developers of all languages. However, this last one (What's the difference between developers and architects?) kind of rubs me the wrong way. Either that, or I've just missed the natural inflation of job descriptions. (maybe, it's like the change in terminology between Garbage man and Waste Engineer or Secretary and Office Administrator) So maybe it's just me - but I think there's still a big difference between Programmer, Developer and then of course, architect. The key thing here is that every role has a different perspective and every one of those perspectives has value. The original MSF create roles like Product Manager, Program Manager, Developer, Tester, etc - so every concept may pigeon hole people into different roles. But the statements Brandon makes are often distinction

FoxInCloud Stats

FoxInCloud sent this link a while back about their statistics regarding visits to their site: http://foxincloud.com/blog/2017/12/27/VFP-community-lessons-from-foxincloud-site.html What's interesting here is the breakdown of people. Yes, I think it's understandable that the Fox community is getting older. Another factor is the growth of the mobile and web environments taking over development. These environments really do push people towards the newer non-SQL or free SQL/hosted environments but more towards hosted storage options like Amazon and Google. A tool like FoxInCloud that helps MOVE existing applications to the cloud inherently competes with those environments. But FoxInCloud also allows developers to extend their application further by giving them a starting point using Javascript and the basic CSS (such as Bootstrap). If you're not rebuilding your application from scratch, it's certainly a great step forward. FoxPro VFP