コード例 #1
0
ファイル: Build.cs プロジェクト: paraneye/WebService
        public ExtSchedulerDTO UpdateFiwpScheduler(ExtSchedulerDTO extScheduler, bool isUsingMpp)
        {
            decimal totalMH = 0m;
            int crewNumber = 0;
            DateTime startDt = new DateTime();
            DateTime endDt = new DateTime();

            string userName = string.Empty;
            string password = string.Empty;
            try
            {
                if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
                {
                    string[] P6LoginInfo = (new P6Manager()).GetP6Login();
                    userName = P6LoginInfo[0];
                    password = P6LoginInfo[1];
                }

                FiwpDTO fiwp = GetSingleFiwpByID(extScheduler.Id);
                //update 실패시 기존 데이터를 리턴하기위해 계산하기 전의 데이터를 보관한다.
                totalMH = fiwp.TotalManhours;
                crewNumber = fiwp.CrewMembersAssigned;
                startDt = fiwp.StartDate;
                endDt = fiwp.FinishDate;

                //계산
                fiwp.StartDate = extScheduler.StartDate;
                fiwp.FinishDate = extScheduler.EndDate;
                fiwp.UpdatedBy = extScheduler.UpdatedBy;
                fiwp.DTOStatus = (int)RowStatusNo.Update;
                fiwp = UpdateIwpPeriod_InnerCode(fiwp, extScheduler.TotalMH, userName, password);

                if (isUsingMpp)
                {
                    // project id, so get last project loaded in projectschedule.
                    //MppHelper.Instance.GetProjectInstanceByLastLoaded();
                }

                //bool dochange = false;
                if (fiwp != null)
                {
                    ProjectscheduleDTO projectSchedule = GetSignleProjscheduleByID(fiwp.ProjectScheduleID);
                    if (projectSchedule != null)
                    {
                        decimal duration = 0m;

                        if (fiwp.CrewMembersAssigned > 0)
                            duration = (decimal)Math.Round(fiwp.TotalManhours / fiwp.CrewMembersAssigned, 4);

                        P6WS.ActivityService.Activity[] fiwpAct = (new P6Manager()).ReadActivities(projectSchedule.P6ActivityObjectID, userName, password);

                        if (fiwpAct != null && fiwpAct.Count() > 0)
                        {
                            //현재시점에서는 Device에서 ScheduleLineItem의 공사기간을 넘지못하도록 막고있기때문에 쓰이지 않는코드 - 2014.04.12
                            if (extScheduler.StartDate < fiwpAct[0].StartDate)
                                extScheduler.ExceptionMessage = string.Format("The IWP StartDate, {0:d} can not be eariler than the schedule StartDate {1:d}.", extScheduler.StartDate, fiwpAct[0].StartDate);
                            if (extScheduler.EndDate > fiwpAct[0].FinishDate)
                                extScheduler.ExceptionMessage = string.Format("The IWP FinishDate, {0:d} can not be later than the schedule FinishDate {1:d}.", extScheduler.EndDate, fiwpAct[0].FinishDate);
                                //dochange = true;

                            #region UpdateToP6 & IWP

                            if (!string.IsNullOrEmpty(extScheduler.ExceptionMessage))
                            {
                                extScheduler.StartDate = startDt;
                                extScheduler.EndDate = endDt;
                                extScheduler.TotalMH = totalMH;
                                extScheduler.CrewMembers = crewNumber;
                            }
                            else
                            {
                                fiwpAct = (new P6Manager()).ReadActivities(fiwp.P6ActivityObjectID, userName, password);

                                fiwpAct[0].StartDate = Convert.ToDateTime(fiwp.StartDate.ToLongDateString() + " 07:00:00 AM");  //fiwp.StartDate;
                                fiwpAct[0].StartDateSpecified = true;
                                fiwpAct[0].RemainingDuration = (float)duration;
                                fiwpAct[0].RemainingDurationSpecified = true;
                                fiwpAct[0].FinishDate = Convert.ToDateTime(fiwp.FinishDate.ToLongDateString() + " 05:00:00 PM");  //fiwp.FinishDate;
                                fiwpAct[0].FinishDateSpecified = true;
                                fiwpAct = (new P6Manager()).UpdateActivities(fiwpAct, userName, password);

                                fiwpAct[0].StartDate = Convert.ToDateTime(fiwp.StartDate.ToLongDateString() + " 07:00:00 AM");  //fiwp.StartDate;
                                fiwpAct[0].StartDateSpecified = true;
                                fiwpAct[0].RemainingDuration = (float)duration;
                                fiwpAct[0].RemainingDurationSpecified = true;
                                fiwpAct[0].FinishDate = Convert.ToDateTime(fiwp.FinishDate.ToLongDateString() + " 05:00:00 PM");  //fiwp.FinishDate;
                                fiwpAct[0].FinishDateSpecified = true;
                                fiwpAct = (new P6Manager()).UpdateActivities(fiwpAct, userName, password);

                                if (fiwpAct != null && fiwpAct.Count() > 0)
                                {
                                    //update fiwp
                                    fiwp.DTOStatus = (int)RowStatusNo.Update;
                                    fiwp.StartDate = extScheduler.StartDate = fiwpAct[0].StartDate;
                                    fiwp.FinishDate = extScheduler.EndDate = fiwpAct[0].FinishDate;
                                    //fiwp.P6RemainingDuration = (fiwpAct[0].RemainingDuration != null) ? Math.Round(Convert.ToDecimal(fiwpAct[0].RemainingDuration), 4) : 0m;

                                    List<FiwpDTO> fiwps = new List<FiwpDTO>();
                                    fiwps.Add(fiwp);
                                    SaveIwp(fiwps);
                                }
                                //현재시점에서는 Device에서 ScheduleLineItem의 공사기간을 넘지못하도록 막고있기때문에 쓰이지 않는코드 - 2014.04.12
                                //if (dochange)
                                //    UpdateFIWPOutcomeProjectScheduleAndP6(projectSchedule, fiwp, userName, password);

                            }

                            #endregion
                        }
                        else
                            extScheduler.ExceptionMessage = "Couldn't update server. Please contact administrator.";

                    }
                }
            }
            catch (Exception ex)
            {
                extScheduler.ExceptionMessage = "Couldn't update server. Please contact administrator.";
            }

            return extScheduler;
        }
コード例 #2
0
 //public ProgressAssignment UpdateSIWPProgressAssignment(ProgressAssignment progress, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignment(progress, userName, password);
 //}
 //public ProgressAssignment UpdateSIWPProgressAssignmentByScope(ProgressAssignment progress, int startdrawingId, int enddrawingId, int startidfseq, int endidfseq,
 //                                                              List<int> withindrawingList, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignmentByScope(progress, startdrawingId, enddrawingId, startidfseq, endidfseq, withindrawingList, userName, password);
 //}
 //public ProgressAssignment UpdateHydroProgressAssignmentByStartPoint(ProgressAssignment progress, int drawingId, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateHydroProgressAssignmentByStartPoint(progress, drawingId, userName, password);
 //}
 //public ProgressAssignment UpdateSIWPProgressAssignmentByRange(ProgressAssignment progress, int startprogressid, int endprogressid, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignmentByRange(progress, startprogressid, endprogressid, userName, password);
 //}
 //public ProgressAssignment UpdateSIWPProgressUnAssignment(ProgressAssignment progress, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressUnAssignment(progress, userName, password);
 //}
 //public ProgressAssignment JsonUpdateSIWPProgressAssignment(ProgressAssignment progress, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignment(progress, userName, password);
 //}
 //public ProgressAssignment UpdateSIWPProgressAssignmentForTurnOver(ProgressAssignment progress, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignmentForTurnOver(progress, userName, password);
 //}
 //public ProgressAssignment UpdateSIWPProgressAssignmentForTurnOverByRange(ProgressAssignment progress, int startprogressid, int endprogressid, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignmentForTurnOverByRange(progress, startprogressid, endprogressid, userName, password);
 //}
 //public ProgressAssignment JsonUpdateSIWPProgressAssignmentForTurnOver(ProgressAssignment progress, string userName, string password)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateSIWPProgressAssignmentForTurnOver(progress, userName, password);
 //}
 //public List<FiwpmaterialDTO> RegenerateFIWPMaterial(int fiwpId, int projectId, string disciplineCode)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).RegenerateFIWPMaterial(fiwpId, projectId, Helper.RemoveJsonParameterWrapper(disciplineCode));
 //}
 //public List<FiwpmaterialDTO> JsonRegenerateFIWPMaterial(string fiwpId, string projectId, string disciplineCode)
 //{
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).RegenerateFIWPMaterial(Int32.Parse(fiwpId), Int32.Parse(projectId), Int32.Parse(disciplineCode));
 //}
 //public ExtSchedulerDTO UpdateFiwpScheduler(ExtSchedulerDTO extscheduler, string userName, string password)
 //{
 //    if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
 //    {
 //        string[] info = (new P6ManagerService()).GetP6Login();
 //        userName = info[0];
 //        password = info[1];
 //    }
 //    return (new Element.Reveal.Server.BALC.ScheduleWriter()).UpdateFiwpScheduler(extscheduler, userName, password);
 //}
 public ExtSchedulerDTO JsonUpdateFiwpScheduler(ExtSchedulerDTO extscheduler)
 {
     return (new Element.Sigma.Web.Biz.TrueTask.Build()).UpdateFiwpScheduler(extscheduler, Helper.isUsingMpp);
 }