Esempio n. 1
0
        public SigmaResultType AddSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            objSigmaUserSigmaRole.CreatedBy = userinfo.SigmaUserId;
            //objSigmaUserSigmaRole.ProjectId = userinfo.CurrentProjectId;

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

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

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@SigmaRoleId", objSigmaUserSigmaRole.SigmaRoleId));
            paramList.Add(new SqlParameter("@SigmaUserId", objSigmaUserSigmaRole.SigmaUserId));
            paramList.Add(new SqlParameter("@ReportTo", objSigmaUserSigmaRole.ReportTo));
            paramList.Add(new SqlParameter("@ReportToRole", objSigmaUserSigmaRole.ReportToRole));
            paramList.Add(new SqlParameter("@IsDefault", objSigmaUserSigmaRole.IsDefault));
            paramList.Add(new SqlParameter("@ProjectId", objSigmaUserSigmaRole.ProjectId));
            paramList.Add(new SqlParameter("@CreatedBy", objSigmaUserSigmaRole.CreatedBy));

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddSigmaUserSigmaRole", paramList.ToArray());
                result.IsSuccessful = true;

                scope.Complete();
            }

            return result;
        }
Esempio n. 2
0
        public SigmaResultType UpdateSigmaUserSigmaRoleForHierarchy(TypeSigmaUserSigmaRole objSigmaUserSigmaRole)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

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

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@SigmaTrgRoleId", objSigmaUserSigmaRole.SigmaTrgRoleId),
                    new SqlParameter("@SigmaRoleId", objSigmaUserSigmaRole.SigmaRoleId),
                    new SqlParameter("@SigmaUserId", objSigmaUserSigmaRole.SigmaUserId),
                    new SqlParameter("@ProjectId", userinfo.CurrentProjectId),
                    new SqlParameter("@UpdatedBy", userinfo.SigmaUserId),
                };

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

            }

            return result;
        }
Esempio n. 3
0
        public SigmaResultType MultiUsers(TypeSigmaUser objSigmaUser)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

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

            if(objSigmaUser.SigmaOperation == "D"){
                result = RemoveSigmaUser(objSigmaUser);
            }else
            {
                switch (objSigmaUser.SigmaOperation)
                {
                    case "C":
                        if (IsAddUser())
                            result = AddSigmaUser(objSigmaUser);
                        else
                        {
                            result.IsSuccessful = false;
                            result.ErrorMessage = "You have exceeded the number of user licenses.";
                        }
                        break;
                    case "U":
                        result = UpdateSigmaUser(objSigmaUser);
                        break;
                }

                if (result.IsSuccessful)
                {
                    TypeSigmaUserSigmaRole objSigmaUserSigmaRole = new TypeSigmaUserSigmaRole();
                    objSigmaUserSigmaRole.SigmaUserId = objSigmaUser.SigmaUserId;
                    result = MultiSigmaUserSigmaRole(objSigmaUserSigmaRole, objSigmaUser.SigmaUserSigmaRoles);
                }
            }

            return result;
        }
Esempio n. 4
0
        public SigmaResultType RemoveSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

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

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

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

            return result;
        }
Esempio n. 5
0
        public SigmaResultType MultiSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole, List<TypeSigmaUserSigmaRole> listObj)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

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

            using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                if(objSigmaUserSigmaRole != null)
                    RemoveSigmaUserSigmaRole(objSigmaUserSigmaRole);

                foreach (TypeSigmaUserSigmaRole anObj in listObj)
                {
                    AddSigmaUserSigmaRole(anObj);
                }
                result.IsSuccessful = true;
                scope.Complete();
            }

            return result;
        }
Esempio n. 6
0
        //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;
        }
 public SigmaResultType AddSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         MemberMgr memberMgr = new MemberMgr();
         result = memberMgr.AddSigmaUserSigmaRole(objSigmaUserSigmaRole);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
        public SigmaResultType UpdateSigmaUserSigmaRoleForHierarchy(TypeSigmaUserSigmaRole objSigmaUser)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                SigmaUserMgr sigmaUserMgr = new SigmaUserMgr();
                result = sigmaUserMgr.UpdateSigmaUserSigmaRoleForHierarchy(objSigmaUser);
                result.IsSuccessful = true;
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
        public SigmaResultType UpdateSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                result.IsSuccessful = true;
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }