public SigmaResultType AddScheduledWorkItem(TypeScheduledWorkItem objScheduledWorkItem)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@ExternalScheduleId", objScheduledWorkItem.ExternalScheduleId));
            paramList.Add(new SqlParameter("@CwpId", objScheduledWorkItem.CwpId));
            paramList.Add(new SqlParameter("@ScheduleName", objScheduledWorkItem.ScheduleName));
            paramList.Add(new SqlParameter("@StartDate", objScheduledWorkItem.StartDate));
            paramList.Add(new SqlParameter("@EndDate", objScheduledWorkItem.EndDate));
            paramList.Add(new SqlParameter("@CrewMemebersAssigned", objScheduledWorkItem.CrewMemebersAssigned));
            paramList.Add(new SqlParameter("@TotalWorkingHours", objScheduledWorkItem.TotalWorkingHours));
            paramList.Add(new SqlParameter("@LeaderId", objScheduledWorkItem.LeaderId));
            paramList.Add(new SqlParameter("@CreatedBy", objScheduledWorkItem.CreatedBy));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddScheduledWorkItem", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;
                scope.Complete();

            }

            return result;
        }
Exemple #2
0
        /// <summary>
        /// 2014-02-28 
        /// ReadWBS & Set
        /// </summary>
        /// <param name="projectObjectId">projectId</param>
        /// /// <param name="Url">Url</param>
        /// <param name="userName">userName</param>
        /// <param name="password">password</param>
        public SigmaResultType ReadP6WBSManager(int p6projectId)
        {
            SigmaResultType Result = new SigmaResultType();
            CommonCodeMgr commonMgr = new CommonCodeMgr();
            string p6username, p6password, p6login;

            p6login = System.Configuration.ConfigurationManager.AppSettings["P6Login"].ToString();
            p6username = p6login.Split(';')[0].Split('=')[1].Trim();
            p6password = p6login.Split(';')[1].Split('=')[1].Trim();

            P6WS.WBSService.WBSPortBinding wbsp = new P6WS.WBSService.WBSPortBinding();
            //wbsp.Url = ConfigurationManager.AppSettings[P6WS_SERVICES_WBS_SERVICE].ToString();//임시루

            wbsp.Url = System.Configuration.ConfigurationManager.AppSettings["P6WS.WBSService"];

            P6WS.WBSService.ReadWBS rwbs = new P6WS.WBSService.ReadWBS();

            wbsp.CookieContainer = P6Login(p6username, p6password);
            P6WS.WBSService.WBSFieldType[] wbsFields = new P6WS.WBSService.WBSFieldType[17];

            P6ProjectCombo(p6username, p6password); // 이 구문이 실행되면 P6DT에 값이 채워짐.
            projectRow = P6DT.Select("ProjectObjectId ='" + p6projectId.ToString() + "'");

            #region set p6
            wbsFields[0] = P6WS.WBSService.WBSFieldType.ObjectId;
            wbsFields[2] = P6WS.WBSService.WBSFieldType.Name;
            wbsFields[3] = P6WS.WBSService.WBSFieldType.ProjectId;
            wbsFields[4] = P6WS.WBSService.WBSFieldType.ProjectObjectId;
            wbsFields[5] = P6WS.WBSService.WBSFieldType.SummaryRemainingDuration;
            wbsFields[6] = P6WS.WBSService.WBSFieldType.StartDate;
            wbsFields[7] = P6WS.WBSService.WBSFieldType.FinishDate;
            wbsFields[8] = P6WS.WBSService.WBSFieldType.ObjectId;
            wbsFields[9] = P6WS.WBSService.WBSFieldType.Code;
            wbsFields[10] = P6WS.WBSService.WBSFieldType.Name;
            wbsFields[11] = P6WS.WBSService.WBSFieldType.SequenceNumber;
            wbsFields[12] = P6WS.WBSService.WBSFieldType.Code;
            wbsFields[13] = P6WS.WBSService.WBSFieldType.ParentObjectId;
            rwbs.Field = wbsFields;
            rwbs.Filter = "ProjectObjectId='" + p6projectId + "'";
            P6WS.WBSService.WBS[] wbs = wbsp.ReadWBS(rwbs);
            #endregion

            if (wbs != null && wbs.Length > 0)
            {
                for (int i = 0; i < wbs.Length; i++)
                {
                    TypeExternalSchedule TypeExSchedule = new TypeExternalSchedule();
                    TypeScheduledWorkItem TypeSWI = new TypeScheduledWorkItem();
                    ExternalScheduleMgr ExSchMgr = new ExternalScheduleMgr();
                    ScheduledWorkItemMgr SchMgr = new ScheduledWorkItemMgr();

                    if (wbs[i].Name != "WBSFIWP" && wbs[i].Code != "FIWP") // 뭐냐 이건...
                    {
                        #region  set Level = 3
                        // Set TypeExternalSchedule
                        TypeExSchedule.Level = "3";
                        TypeExSchedule.StartDate = wbs[i].StartDate.ToString();
                        TypeExSchedule.EndDate = wbs[i].FinishDate.ToString();
                        TypeExSchedule.ProjectObjectId = p6projectId;
                        TypeExSchedule.ParentObjectId = 0;
                        TypeExSchedule.OriginalDuration = Convert.ToInt32(wbs[i].SummaryRemainingDuration);
                        TypeExSchedule.RemainingDuration = Convert.ToInt32(wbs[i].SummaryRemainingDuration);
                        TypeExSchedule.ActivityObjectId = wbs[i].ObjectId;
                        TypeExSchedule.ExternalProjectName = projectRow[0]["P6ProjectName"].ToString();
                        TypeExSchedule.CalendarId = 0;
                        TypeExSchedule.CreatedBy = userinfo.SigmaUserId;
                        TypeExSchedule.ProjectId = userinfo.CurrentProjectId;
                        Result = ExSchMgr.AddExternalSchedule(TypeExSchedule);

                        // Set TypeScheduledWorkItem
                        TypeSWI.ExternalScheduleId = Result.ScalarValue;
                        TypeSWI.CwpId = null;
                        TypeSWI.ScheduleName = wbs[i].Name;
                        TypeSWI.StartDate = wbs[i].StartDate.ToString();
                        TypeSWI.EndDate = wbs[i].FinishDate.ToString();
                        TypeSWI.CrewMemebersAssigned = 0;
                        TypeSWI.TotalWorkingHours = 0;
                        TypeSWI.LeaderId = "0";
                        TypeSWI.CreatedBy = userinfo.SigmaUserId;
                        Result = SchMgr.AddScheduledWorkItem(TypeSWI);
                        #endregion

                        //Level 4 로 Input
                        ReadActivities(TypeExSchedule.ActivityObjectId,  p6projectId, p6username, p6password);
                    }

                }
            }

            return Result;
        }
Exemple #3
0
        /// <summary>
        /// ReadActivities & Set 
        /// </summary>
        /// <param name="activityObjectId"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public virtual SigmaResultType ReadActivities(int activityObjectId, int projectId, string userName, string password)
        {
            SigmaResultType Result = new SigmaResultType();
            TypeExternalSchedule TypeExSchedule = new TypeExternalSchedule();
            TypeScheduledWorkItem TypeSWI = new TypeScheduledWorkItem();
            ExternalScheduleMgr ExSchMgr = new ExternalScheduleMgr();
            ScheduledWorkItemMgr SchMgr = new ScheduledWorkItemMgr();

            P6WS.ActivityService.ActivityPortBinding apb = new P6WS.ActivityService.ActivityPortBinding();
            apb.CookieContainer = P6Login(userName, password);

            apb.Url = System.Configuration.ConfigurationManager.AppSettings["P6WS.ActivityService"];
            P6WS.ActivityService.ReadActivities ra = new P6WS.ActivityService.ReadActivities();
            P6WS.ActivityService.ActivityFieldType[] actFields = new P6WS.ActivityService.ActivityFieldType[18];

            #region   set Activity Data
            actFields[0] = P6WS.ActivityService.ActivityFieldType.Id;
            actFields[1] = P6WS.ActivityService.ActivityFieldType.ObjectId;
            actFields[2] = P6WS.ActivityService.ActivityFieldType.Name;
            actFields[3] = P6WS.ActivityService.ActivityFieldType.ProjectId;
            actFields[4] = P6WS.ActivityService.ActivityFieldType.ProjectObjectId;
            actFields[5] = P6WS.ActivityService.ActivityFieldType.RemainingDuration;
            actFields[6] = P6WS.ActivityService.ActivityFieldType.StartDate;
            actFields[7] = P6WS.ActivityService.ActivityFieldType.FinishDate;
            actFields[8] = P6WS.ActivityService.ActivityFieldType.WBSObjectId;
            actFields[9] = P6WS.ActivityService.ActivityFieldType.ActualDuration;
            actFields[10] = P6WS.ActivityService.ActivityFieldType.ActualStartDate;
            actFields[11] = P6WS.ActivityService.ActivityFieldType.ExpectedFinishDate;
            actFields[12] = P6WS.ActivityService.ActivityFieldType.DurationPercentComplete;
            actFields[13] = P6WS.ActivityService.ActivityFieldType.AtCompletionDuration;
            actFields[14] = P6WS.ActivityService.ActivityFieldType.RemainingDuration;
            actFields[15] = P6WS.ActivityService.ActivityFieldType.ActualStartDate;
            actFields[16] = P6WS.ActivityService.ActivityFieldType.Status;
            actFields[17] = P6WS.ActivityService.ActivityFieldType.CalendarObjectId;
            #endregion

            ra.Field = actFields;
            ra.Filter = string.Format("WBSObjectId={0}", activityObjectId);
            P6WS.ActivityService.Activity[] acts = apb.ReadActivities(ra);

            if (acts != null && acts.Length > 0)
            {
                for (int i = 0; i < acts.Length; i++)
                {
                    // Set TypeExternalSchedule
                    TypeExSchedule.Level = "4";
                    TypeExSchedule.StartDate = acts[i].StartDate.ToString();
                    TypeExSchedule.EndDate = acts[i].FinishDate.ToString();
                    TypeExSchedule.ProjectObjectId = projectId;
                    TypeExSchedule.ParentObjectId = activityObjectId;
                    TypeExSchedule.OriginalDuration = Convert.ToInt32(acts[i].RemainingDuration);
                    TypeExSchedule.RemainingDuration = Convert.ToInt32(acts[i].ActualDuration);
                    TypeExSchedule.ActivityObjectId = Convert.ToInt32(acts[i].ObjectId);
                    TypeExSchedule.CalendarId = Convert.ToInt32(acts[i].CalendarObjectId);
                    TypeExSchedule.ExternalProjectName = projectRow[0]["P6ProjectName"].ToString();
                    TypeExSchedule.CreatedBy = userinfo.SigmaUserId;
                    TypeExSchedule.ProjectId = userinfo.CurrentProjectId;
                    Result = ExSchMgr.AddExternalSchedule(TypeExSchedule);

                    // Set TypeScheduledWorkItem
                    TypeSWI.ExternalScheduleId = Result.ScalarValue;
                    TypeSWI.CwpId = null;
                    TypeSWI.ScheduleName = acts[i].Name.ToString();
                    TypeSWI.StartDate = acts[i].StartDate.ToString();
                    TypeSWI.EndDate = acts[i].FinishDate.ToString();
                    TypeSWI.CrewMemebersAssigned = 0;
                    TypeSWI.TotalWorkingHours = 0; //차후 확인 필요
                    TypeSWI.LeaderId = null;//차후 확인 필요
                    TypeSWI.CreatedBy = userinfo.SigmaUserId;
                    Result = SchMgr.AddScheduledWorkItem(TypeSWI);
                }
            }

            return Result;
        }
        public SigmaResultType UpdateScheduledWorkItem(TypeScheduledWorkItem objScheduledWorkItem)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@ExternalScheduleId", objScheduledWorkItem.ExternalScheduleId),
                    new SqlParameter("@CwpId", objScheduledWorkItem.CwpId),
                    new SqlParameter("@ScheduleName", objScheduledWorkItem.ScheduleName),
                    new SqlParameter("@StartDate", objScheduledWorkItem.StartDate),
                    new SqlParameter("@EndDate", objScheduledWorkItem.EndDate),
                    new SqlParameter("@CrewMemebersAssigned", objScheduledWorkItem.CrewMemebersAssigned),
                    new SqlParameter("@TotalWorkingHours", objScheduledWorkItem.TotalWorkingHours),
                    new SqlParameter("@LeaderId", objScheduledWorkItem.LeaderId),
                    new SqlParameter("@CreatedBy", objScheduledWorkItem.CreatedBy),
                    new SqlParameter("@UpdatedBy", objScheduledWorkItem.UpdatedBy),
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_UpdateScheduledWorkItem", parameters);
                result.IsSuccessful = true;
                scope.Complete();

            }

            return result;
        }
        public SigmaResultType RemoveScheduledWorkItem(TypeScheduledWorkItem objScheduledWorkItem)
        {
            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@ScheduledWorkItemId", objScheduledWorkItem.ScheduledWorkItemId)
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_RemoveScheduledWorkItem", parameters);
                result.IsSuccessful = true;
                scope.Complete();
            }

            return result;
        }