コード例 #1
0
ファイル: PermissionMgr.cs プロジェクト: paraneye/WebService
        public SigmaResultType MultiSigmaRoleSigmaJob(TypeSigmaRole listObj)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            listObj.CreatedBy = userinfo.SigmaUserId;

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

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

            if(listObj.SigmaRoleId != null)
                RemoveSigmaRoleSigmaJob(listObj.SigmaRoleId);

            int sigmaRoleId = listObj.SigmaRoleId;

            using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();

                switch (listObj.SigmaOperation)
                {
                    case "C":
                        result = sigmaRoleMgr.AddSigmaRole(listObj);
                        sigmaRoleId = result.ScalarValue;
                        break;
                    case "U":
                        result = sigmaRoleMgr.UpdateSigmaRole(listObj);
                        break;
                }

                if (result.IsSuccessful)
                {

                    listObj.typeSigmaRoleSigmaJob.ForEach(x => x.CreatedBy = userinfo.SigmaUserId);
                    listObj.typeSigmaRoleSigmaJob.ForEach(x => x.SigmaRoleId = sigmaRoleId);

                    foreach (TypeSigmaRoleSigmaJob anObj in listObj.typeSigmaRoleSigmaJob)
                    {
                        AddSigmaRoleSigmaJob(anObj);
                    }
                    result.IsSuccessful = true;
                    scope.Complete();
                }
            }

            return result;
        }
コード例 #2
0
ファイル: ProjectMgr.cs プロジェクト: paraneye/WebService
        //public SigmaResultType MultiProject(List<TypeProject> listObj)
        //{
        //    TransactionScope scope = null;
        //    SigmaResultType result = new SigmaResultType();
        //    // Get connection string
        //    string connStr = ConnStrHelper.getDbConnString();
        //    using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
        //    {
        //        foreach (TypeProject anObj in listObj)
        //        {
        //            switch (anObj.SigmaOperation)
        //            {
        //                case "C":
        //                    AddProject(anObj);
        //                    break;
        //                case "U":
        //                    UpdateProject(anObj);
        //                    break;
        //                case "D":
        //                    RemoveProject(anObj);
        //                    break;
        //            }
        //        }
        //        scope.Complete();
        //    }
        //    return result;
        //}
        public SigmaResultType AddProjectInfo(TypeProject objProject)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();
            SigmaResultType resultProject = new SigmaResultType();

            bool isDiscipline = true;
            bool isAuthentication = true;

            // Project Closed
            if (objProject.IsActive.ToUpper().Equals("N"))
            {
                if (userinfo.SigmaUserId.ToUpper().Equals("ADMIN"))
                {
                    isAuthentication = true;
                }
                else
                {
                    isAuthentication = false;
                }
            }

            if (objProject.ProjectDiscipline.Count == 0)
            {
                isDiscipline = false;
            }

            if (!(string.IsNullOrEmpty(objProject.ProjectName))
                && !(string.IsNullOrEmpty(objProject.ProjectNumber))
                && !(string.IsNullOrEmpty(objProject.ProjectManagerId))
                //&& !(string.IsNullOrEmpty(objProject.ClientCompanyId))
                && !(string.IsNullOrEmpty(objProject.ClientProjectId))
                && !(string.IsNullOrEmpty(objProject.ClientProjectName))
                && isDiscipline
                && isAuthentication
            )
            {
                using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    if (objProject.SigmaOperation == SigmaOperation.INSERT)
                    {
                        resultProject = AddProject(objProject);
                        objProject.ProjectId = resultProject.ScalarValue;
                        objProject.ProjectDiscipline.ForEach(item => item.ProjectId = objProject.ProjectId);
                        objProject.ProjectSubcontractor.ForEach(item => item.ProjectId = objProject.ProjectId);
                    }
                    else if (objProject.SigmaOperation == SigmaOperation.UPDATE)
                    {
                        resultProject = UpdateProject(objProject);
                        objProject.ProjectDiscipline.ForEach(item => item.ProjectId = objProject.ProjectId);
                        objProject.ProjectSubcontractor.ForEach(item => item.ProjectId = objProject.ProjectId);

                        // Delete ProjectDiscipline && ProjectSubcontractor
                        if (resultProject.IsSuccessful)
                        {
                            RemoveProjectDiscipline(objProject);
                            RemoveProjectSubcontractor(objProject);
                        }
                    }

                    if (resultProject.IsSuccessful)
                    {
                        // ProjectDiscipline
                        if (objProject.ProjectDiscipline.Count > 0)
                        {
                            foreach (var item in objProject.ProjectDiscipline)
                            {
                                switch (item.SigmaOperation)
                                {
                                    case SigmaOperation.INSERT:
                                        AddProjectDiscipline(item);
                                        break;
                                }
                            }
                        }

                        // ProjectSubcontractor
                        if (objProject.ProjectSubcontractor.Count > 0)
                        {
                            foreach (var item in objProject.ProjectSubcontractor)
                            {
                                switch (item.SigmaOperation)
                                {
                                    case SigmaOperation.INSERT:
                                        AddProjectSubcontractor(item);
                                        break;
                                }
                            }
                        }

                        // Project Manager
                        #region Project Manager
                        if (!(string.IsNullOrEmpty(objProject.ProjectManagerId.ToString())))
                        {
                            SigmaUserMgr sigmaUserMgr = new SigmaUserMgr();
                            SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
                            ProjectUserDisciplineMgr projectUserDisciplineMgr = new ProjectUserDisciplineMgr();
                            TypeSigmaUserSigmaRole userRole = new TypeSigmaUserSigmaRole();
                            TypeProjectUserDiscipline userDiscipline = new TypeProjectUserDiscipline();

                            DataSet sigmaRoleDataSet = null;
                            DataSet sigmaUserSigmaRoleDataSet = null;

                            // Get SigmaRoleId
                            sigmaRoleDataSet = sigmaRoleMgr.GetSigmaRoleByName("Project Manager");
                            var sigmaRole = sigmaRoleDataSet.Tables[0].Rows[0]["SigmaRoleId"];

                            // Get SigmaUserSigmaRole
                            //sigmaUserSigmaRole = projectUserDisciplineMgr.

                            // Set SigmaUserSigmaRole
                            userRole.SigmaRoleId = int.Parse(sigmaRole.ToString());
                            userRole.SigmaUserId = objProject.ProjectManagerId;
                            userRole.ProjectId = objProject.ProjectId;
                            userRole.CreatedBy = userinfo.SigmaUserId;

                            if (objProject.SigmaOperation == SigmaOperation.INSERT)
                            {
                                sigmaUserMgr.AddSigmaUserSigmaRoleForProject(userRole);

                                // ProjectUserDiscipline
                                if (objProject.ProjectDiscipline.Count > 0)
                                {
                                    foreach (var item in objProject.ProjectDiscipline)
                                    {
                                        TypeProjectUserDiscipline projectUserDiscipline = new TypeProjectUserDiscipline();

                                        projectUserDiscipline.ProjectId = objProject.ProjectId;
                                        projectUserDiscipline.SigmaUserId = objProject.ProjectManagerId;
                                        projectUserDiscipline.DisciplineCode = item.DisciplineCode;

                                        switch (item.SigmaOperation)
                                        {
                                            case SigmaOperation.INSERT:
                                                projectUserDisciplineMgr.AddProjectUserDiscipline(projectUserDiscipline);
                                                break;
                                        }
                                    }
                                }
                            }

                            if (objProject.SigmaOperation == SigmaOperation.UPDATE)
                            {
                                //sigmaUserSigmaRoleDataSet = sigmaUserMgr.GetSigmaUserSigmaRoleBySigmaRoleId(objProject.ProjectId, int.Parse(sigmaRole.ToString()));
                                //var sigmaUserSigmaRole = sigmaUserSigmaRoleDataSet.Tables[0].Rows[0]["SigmaUserId"];

                                // 1. SigmaUserSigmaRole Delete
                                sigmaUserMgr.RemoveSigmaUserSigmaRoleByProjectId(userRole);
                                // 2. SigmaUserSigmaRole Insert
                                sigmaUserMgr.AddSigmaUserSigmaRole(userRole);

                                // 3. ProjectUserDiscipline Delete
                                userDiscipline.ProjectId = objProject.ProjectId;
                                userDiscipline.SigmaUserId = userRole.SigmaUserId;
                                userDiscipline.DisciplineCode = "ALL";
                                projectUserDisciplineMgr.RemoveProjectUserDiscipline(userDiscipline);

                                // 4. ProjectUserDiscipline Insert
                                foreach (var item in objProject.ProjectDiscipline)
                                {
                                    TypeProjectUserDiscipline projectUserDiscipline = new TypeProjectUserDiscipline();

                                    projectUserDiscipline.ProjectId = objProject.ProjectId;
                                    projectUserDiscipline.SigmaUserId = objProject.ProjectManagerId;
                                    projectUserDiscipline.DisciplineCode = item.DisciplineCode;

                                    switch (item.SigmaOperation)
                                    {
                                        case SigmaOperation.INSERT:
                                            projectUserDisciplineMgr.AddProjectUserDiscipline(projectUserDiscipline);
                                            break;
                                    }
                                }

                                // 5. ProjectUserDiscipline Delete(except ProjectManager)
                                projectUserDisciplineMgr.RemoveProjectUserDisciplineByProjectInfo(objProject.ProjectId);
                            }
                        }

                        #endregion Project Manager
                    }

                    result.AffectedRow = resultProject.AffectedRow;
                    result.ScalarValue = resultProject.ScalarValue;
                    result.IsSuccessful = true;

                    scope.Complete();
                }
            }
            else
            {
                result.AffectedRow = -1;
                result.ErrorCode = "ProjectSetting0001";
                result.ErrorMessage = "Validation";
                result.IsSuccessful = false;
            }

            return result;
        }
コード例 #3
0
 public SigmaResultType AddSigmaRole(TypeSigmaRole objSigmaRole)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
         result = sigmaRoleMgr.AddSigmaRole(objSigmaRole);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
コード例 #4
0
        public SigmaResultType MultiSigmaRole(List<TypeSigmaRole> listObj)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
                result = sigmaRoleMgr.MultiSigmaRole(listObj);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
コード例 #5
0
 public SigmaResultType ListSigmaRolesByProjectId(string projectId)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
         result = sigmaRoleMgr.ListSigmaRolesByProjectId(projectId);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
コード例 #6
0
        public SigmaResultType ListSigmaRole()
        {
            SigmaResultType result = new SigmaResultType();
            try
            {
                var queryStr = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters;
                string max = queryStr["max"];
                string offset = queryStr["offset"];
                string s_option = queryStr["s_option"];
                string s_key = queryStr["s_key"];
                string o_option = queryStr["o_option"];
                string o_desc = queryStr["o_desc"];

                SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
                result = sigmaRoleMgr.ListSigmaRole(offset, max, s_option, s_key, o_option, o_desc);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
コード例 #7
0
 public SigmaResultType GetSigmaRole(string sigmaRoleId)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
         result = sigmaRoleMgr.GetSigmaRole(sigmaRoleId);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }