Exemple #1
1
        public virtual int[] CreateWBS(P6WS.WBSService.WBS newWbs, string userName, string password)
        {
            //not working because of Code
            P6WS.WBSService.WBS[] wbs = new P6WS.WBSService.WBS[1];

            P6WS.WBSService.WBSPortBinding wpb = new P6WS.WBSService.WBSPortBinding();
            wpb.CookieContainer = P6Login(userName, password);
            wpb.Url = System.Configuration.ConfigurationManager.AppSettings[P6WS_SERVICES_WBS_SERVICE].ToString();

            wbs[0] = newWbs;

            int[] retValue = wpb.CreateWBS(wbs);

            return retValue;
        }
Exemple #2
0
        private void DoProcessFIWPWBS(FiwpDTO fiwp, string userName, string password)
        {
            int fipwWBSId = 0;
            P6ActivityDTO pWbs = (new P6Manager()).ReadWBSFilter(string.Format("ParentObjectId={0} and Code='{1}'", fiwp.P6ParentObjectID, "FIWP"), userName, password, fiwp.ProjectID);

            if (pWbs == null)
            {
                //create fiwp Work Breakdown Structure to P6.
                P6WS.WBSService.WBS newWbs = new P6WS.WBSService.WBS();
                newWbs.ProjectObjectId = fiwp.P6ActivityObjectID;
                newWbs.ProjectObjectIdSpecified = true;
                newWbs.Name = "WBSFIWP";
                newWbs.ParentObjectId = fiwp.P6ParentObjectID; //  for p6
                newWbs.ParentObjectIdSpecified = true;
                newWbs.Code = "FIWP";
                newWbs.StartDate = Convert.ToDateTime(fiwp.StartDate.ToLongDateString() + " 07:00:00 AM");  //fiwp.StartDate;
                newWbs.StartDateSpecified = true;
                newWbs.FinishDate = Convert.ToDateTime(fiwp.FinishDate.ToLongDateString() + " 05:00:00 PM");  //fiwp.FinishDate;
                newWbs.FinishDateSpecified = true;
                int[] ids = (new P6Manager()).CreateWBS(newWbs, userName, password);
                fipwWBSId = ids[0];
            }
            else
                fipwWBSId = pWbs.P6ActivityObjectID;

            //create P6 activity.
            P6WS.ActivityService.Activity act = new P6WS.ActivityService.Activity();
            act.Name = fiwp.FiwpName;
            act.StartDate = Convert.ToDateTime(fiwp.StartDate.ToLongDateString() + " 07:00:00 AM");  //fiwp.StartDate;
            act.FinishDate = Convert.ToDateTime(fiwp.FinishDate.ToLongDateString() + " 05:00:00 PM");  //fiwp.FinishDate;
            act.ProjectObjectId = fiwp.P6ParentObjectID;
            act.WBSObjectId = fipwWBSId;
            if (fiwp.DTOStatus == (int)RowStatusNo.Update) act.CalendarObjectId = fiwp.P6CalendarID;
            // fiwpAct should get calendar object id correctly.
            P6WS.ActivityService.Activity[] fiwpAct = (new P6Manager()).CreateActivity(act, userName, password);

            if (fiwpAct != null && fiwpAct.Count() > 0)
            {
                fiwp.P6ParentObjectID = (int)fiwpAct[0].WBSObjectId;
                fiwp.P6ActivityID = fiwpAct[0].Id;
                fiwp.P6ActivityObjectID = fiwpAct[0].ObjectId;
                fiwp.StartDate = fiwpAct[0].StartDate;
                fiwp.FinishDate = fiwpAct[0].FinishDate;
                fiwp.P6CalendarID = fiwpAct[0].CalendarObjectId;
                if (!CheckAndUpdateP6Calender(fiwp.P6CalendarID, userName, password, fiwp.UpdatedBy))
                    throw new Exception("Couldn't register new calendar");
                fiwp.WorkHours = 0m;
                List<StandardworkweekDTO> standardworkweek = GetStandardWorkWeekByExternalCalendar(fiwp.P6CalendarID);
                if (standardworkweek != null && standardworkweek.Count > 0)
                    fiwp.WorkHours = Convert.ToDecimal(standardworkweek.Average(x => x.WorkHours));
                //fiwp.P6RemainingDuration = (decimal)fiwpAct[0].RemainingDuration;
            }
            else
            {
                throw new Exception("Fail to create an activity for the Iwp.");
            }
            #region old code
            /*
            int fipwWBSId = 0;
            P6ActivityDTO pWbs;

            P6Manager manager = GetP6Manager();
            if (!isUsingMpp)
            {
                pWbs = manager.ReadWBSFilter(string.Format("ParentObjectId={0} and Code='{1}'", fiwp.P6ParentObjectID, "FIWP"), userName, password, fiwp.ProjectID);
            }
            else
            {
                pWbs = manager.ReadWBSFilter(string.Format("ParentObjectId={0} and Code='{1}'", fiwp.P6ActivityObjectID, "FIWP"), userName, password, fiwp.ProjectID);
            }

            if (pWbs == null)
            {
                if (!isUsingMpp)
                {
                    //create fiwp Work Breakdown Structure to P6.
                    P6WS.WBSService.WBS newWbs = new P6WS.WBSService.WBS();
                    newWbs.ProjectObjectId = fiwp.P6ActivityObjectID;
                    newWbs.ProjectObjectIdSpecified = true;
                    newWbs.Name = "WBSFIWP";

                    newWbs.ParentObjectId = fiwp.P6ParentObjectID; //  for p6

                    newWbs.ParentObjectIdSpecified = true;
                    newWbs.Code = "FIWP";
                    newWbs.StartDate = fiwp.StartDate;
                    newWbs.StartDateSpecified = true;
                    newWbs.FinishDate = fiwp.FinishDate;
                    newWbs.FinishDateSpecified = true;
                    int[] ids = (GetP6Manager()).CreateWBS(newWbs, userName, password);
                    fipwWBSId = ids[0];
                }
                else
                {
                    //create fiwp Work Breakdown Structure to P6.
                    P6WS.WBSService.WBS newWbs = new P6WS.WBSService.WBS();
                    newWbs.ProjectObjectId = fiwp.P6ActivityObjectID;
                    newWbs.ProjectObjectIdSpecified = true;
                    newWbs.Name = "WBSFIWP";

                    newWbs.ParentObjectId = fiwp.P6ActivityObjectID; // for mpp

                    newWbs.ParentObjectIdSpecified = true;
                    newWbs.Code = "FIWP";
                    newWbs.StartDate = fiwp.StartDate;
                    newWbs.StartDateSpecified = true;
                    newWbs.FinishDate = fiwp.FinishDate;
                    newWbs.FinishDateSpecified = true;
                    int[] ids = (GetP6Manager()).CreateWBS(newWbs, userName, password);
                    fipwWBSId = ids[0];

                }

            }
            else
                fipwWBSId = pWbs.P6ActivityObjectID;

            //create P6 activity.
            P6WS.ActivityService.Activity act = new P6WS.ActivityService.Activity();
            act.Name = fiwp.FiwpName;
            act.StartDate = fiwp.StartDate;
            act.FinishDate = fiwp.FinishDate;
            act.ProjectObjectId = fiwp.P6ParentObjectID;
            act.WBSObjectId = fipwWBSId;
            if (fiwp.DTOStatus == (int)RowStatus.Update) act.CalendarObjectId = fiwp.P6CalendarID;
            // fiwpAct should get calendar object id correctly.
            P6WS.ActivityService.Activity[] fiwpAct = (GetP6Manager()).CreateActivity(act, userName, password);

            if (fiwpAct.Count() > 0)
            {
                fiwp.P6ParentObjectID = (int)fiwpAct[0].WBSObjectId;
                fiwp.P6ActivityID = fiwpAct[0].Id;
                fiwp.P6ActivityObjectID = fiwpAct[0].ObjectId;
                fiwp.StartDate = fiwpAct[0].StartDate;
                fiwp.FinishDate = fiwpAct[0].FinishDate;
                fiwp.P6CalendarID = fiwpAct[0].CalendarObjectId;
                if (!CheckAndUpdateP6Calender(dbname, fiwp.P6CalendarID, userName, password))
                    throw new Exception("Couldn't register new calendar");

                fiwp.WorkHours = (new Reveal.Server.DALC.CalendarDAL()).GetStandardWorkhourByP6CalandarID(dbname, fiwp.P6CalendarID);
                fiwp.P6RemainingDuration = (decimal)fiwpAct[0].RemainingDuration;
            }
            else
            {
                throw new Exception("Fail to create an activity for a fiwp.");
            }*/
            #endregion
        }