コード例 #1
0
        public String GetWBSData(string sProjectDef,
                                 string sWBS)
        {
            Boolean bReturn = new Boolean();
            //   Get the full project
            String sWithActivities = "X";
            String sWithMilestones = "X";
            String sWithSubtree    = "";

            //	 Get a specific WBS and subtree
            if (sWBS.Length > 0)
            {
                if (sProjectDef.Length > 0)
                {
                    MessageBox.Show("Error; Project Def and WBS can not be entered at the same time.");
                    return("Error; Project Def and WBS can not be entered at the same time.");
                }

                sWithSubtree = "X";
                CSAPData.BAPI_WBS_ELEMENTS sWBSSelect = new CSAPData.BAPI_WBS_ELEMENTS();
                sWBSSelect.Wbs_Element = sWBS;
                arWBSELEMSELECT.Add(sWBSSelect);
            }

            try
            {
                bReturn = oSAP.GetPrjWBSData(sProjectDef,
                                             sWithActivities,
                                             sWithMilestones,
                                             sWithSubtree,
                                             out stProjectDef,
                                             out stBAPIReturn1,
                                             ref arNtwkActy,
                                             ref arMsgs,
                                             ref arWBSELEMEXP,
                                             ref arWBSHRCY,
                                             ref arWBSMLST,
                                             ref arWBSELEMSELECT);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error in GetPrjWBSData.");
                return("Error in CSAPInterface:GetWBSData.");
            }

            if (bReturn == true)
            {
                return("WBS & children data loaded.");
            }
            else
            {
                if (arMsgs != null)
                {
                    MessageBox.Show("Error in CSAPInterface:GetWBSData");
                    frmSAPData frmSAP = new frmSAPData(this, rProject.ProjectID);
                    frmSAP.Show();
                    frmSAP.SetTab(4);  // set to error message tab
                }
            }


            return("WBS & children data loaded.");
        }
コード例 #2
0
        public String MaintainSAPProject()
        //   Assumption: Projects are created in SAP
        //     - Provide support for creating/updating Activity & Network
        //     - Can add support for updating WBSs,
        //       and updating/creating WBS Milestones, WBS Hierarchies
        {
            // MaintainSAPProject
            CSAPData.BAPI_NETWORK_ACTIVITYTable    arNtwkActivities       = new CSAPData.BAPI_NETWORK_ACTIVITYTable();
            CSAPData.BAPI_ACT_ELEMENTTable         arActyElements         = new CSAPData.BAPI_ACT_ELEMENTTable();
            CSAPData.BAPI_ACT_ELEMENT_UPDTable     arActyElementsUpDate   = new CSAPData.BAPI_ACT_ELEMENT_UPDTable();
            CSAPData.BAPI_ACT_MILESTONETable       arActyMilestones       = new CSAPData.BAPI_ACT_MILESTONETable();
            CSAPData.BAPI_ACT_MILESTONE_UPDTable   arActyMilestonesUpDate = new CSAPData.BAPI_ACT_MILESTONE_UPDTable();
            CSAPData.BAPI_NETWORK_ACTIVITY_UPTable arNtwkActivitiesUpDate = new CSAPData.BAPI_NETWORK_ACTIVITY_UPTable();
            CSAPData.BAPI_METHOD_PROJECTTable      arPrjMethod            = new CSAPData.BAPI_METHOD_PROJECTTable();
            CSAPData.BAPI_NETWORKTable             arNtwks       = new CSAPData.BAPI_NETWORKTable();
            CSAPData.BAPI_NETWORK_UPDATETable      arNtwksUpDate = new CSAPData.BAPI_NETWORK_UPDATETable();
            CSAPData.BAPI_NETWORK_RELATIONTable    arRltns       = new CSAPData.BAPI_NETWORK_RELATIONTable();
            CSAPData.BAPI_NETWORK_RELATION_UPTable arRltnsUpDate = new CSAPData.BAPI_NETWORK_RELATION_UPTable();
            CTaskHier oTaskH     = new CTaskHier();
            CTaskHier oTaskHBuff = new CTaskHier();
            Boolean   bReturn    = new Boolean();

            // We save Tasks from MSP to SAP as Network Activities
            //   No WBSs or Networks are added.
            int iRefNum = new int();  //Reference parameter required by SAP

            foreach (MSProject.Task oMSPTask in rProject.Tasks)
            {
                // Maintain Activity
                // We are only adding MSP tasks flagged for SAP and of type Activity
                if (oMSPTask.GetField(Microsoft.Office.Interop.MSProject.PjField.pjTaskOutlineCode1) != "No" &&
                    (oMSPTask.Text16 == TaskType.Activity))
                {
                    // Search for the Activity in the SAP Collection.  Is it a new addition?
                    oTaskHBuff = oTaskCollection.Find(oMSPTask.Text16, oMSPTask.Text30, oMSPTask.Text1);
                    if (oTaskHBuff != null) // Found the related Activity
                    {
                        iRefNum++;
                        MaintainSAPActivity(oMSPTask, "UPDATE", iRefNum, arPrjMethod, arNtwks, arNtwkActivities, arNtwkActivitiesUpDate);
                    }
                    else  // New Activity so we add it
                    {
                        // Assign Activity characteristics
                        iRefNum++;
                        MaintainSAPActivity(oMSPTask, "CREATE", iRefNum, arPrjMethod, arNtwks, arNtwkActivities, arNtwkActivitiesUpDate);
                    }
                } //if (oMSPTask.GetField(Microsoft....PjField.pjTaskOutlineCode1) == "No")
            }     //foreach (MSProject.Task oMSPTask in rProject.Tasks)


            try
            {
                bReturn = oSAP.MaintainNetworkActivities(out stBAPIReturn1, ref arMsgs, ref arNtwkActivities,
                                                         ref arActyElements, ref arActyElementsUpDate, ref arActyMilestones,
                                                         ref arActyMilestonesUpDate, ref arNtwkActivitiesUpDate, ref arPrjMethod,
                                                         ref arNtwks, ref arNtwksUpDate, ref arRltns, ref arRltnsUpDate);
                bSaveMethodAdded = false;  //flag so we only add one "SAVE" method to this fcn call
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error in MaintainSAPProject.");
                return("Error in CSAPInterface:MaintainSAPProject");
            }

            if (bReturn == true)
            {
                return("Project saved to SAP successfully.");
            }
            else
            {
                if (arMsgs != null)
                {
                    MessageBox.Show("Error in MaintainSAPProject.");
                    frmSAPData frmSAP = new frmSAPData(this, rProject.ProjectID);
                    frmSAP.Show();
                    frmSAP.SetTab(4);  // set to error message tab
                }
            }

            return("Error,MaintainSAPProject;" + stBAPIReturn1.Message);
        }
コード例 #3
0
 public void ShowSAPData_Debug()
 {
     frmSAP = new frmSAPData(oSAPInterface, oProject.ProjectID);
     frmSAP.Show();
 }