public SigmaResultType ForgotPassword(string userId, string email) { SigmaResultType result = new SigmaResultType(); SigmaUserMgr sigmauserMgr = new SigmaUserMgr(); TypeSigmaUser objSigmaUser = GetSigmaUser(userId); if (objSigmaUser == null) { result.JsonDataSet = "[]"; result.AffectedRow = 0; result.IsSuccessful = false; result.ErrorCode = "AUTH0001"; result.ErrorMessage = MessageHandler.GetErrorMessage("AUTH0001"); return result; } else { if (!string.IsNullOrEmpty(objSigmaUser.Email) && !objSigmaUser.Email.Equals(email)) { result.JsonDataSet = "[]"; result.AffectedRow = 0; result.IsSuccessful = false; result.ErrorCode = "AUTH0005"; result.ErrorMessage = MessageHandler.GetErrorMessage("AUTH0005"); return result; } } //init password SigmaResultType inipwd = sigmauserMgr.InitPassword(objSigmaUser); objSigmaUser.Password = inipwd.StringValue; result = SendMail(objSigmaUser); result.IsSuccessful = true; return result; }
//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 ImportFile() { SigmaResultType result = new SigmaResultType(); try { var queryStr = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters; string fileType = queryStr["filetype"]; string filePath = queryStr["filepath"]; //string rootPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentUpload"]; //string targetPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentFolderRoot"]; string rootPath = ConfigMgr.GetImportFilePath(); filePath = rootPath + filePath; //fileType = "DrawingImage"; // ImportFile switch (fileType) { case "Drawing": //importDrawing importDrawing = new ImportDrawing(); ImportDrawingMgr importDrawing = new ImportDrawingMgr(); result = importDrawing.AddDrawing(filePath, ConfigMgr.GetExportFilePath()); break; case "DrawingImage": //ImportDrawing importDrawingImage = new ImportDrawing(); ImportDrawingMgr importDrawingImage = new ImportDrawingMgr(); //result = importDrawingImage.AddDrawingImage(filePath, targetPath); result = importDrawingImage.AddDrawingImage(filePath, ConfigMgr.GetTargetPath()); break; case "MTO": ImportMgr importMgr = new ImportMgr(); result = importMgr.ImportMTOFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "CostCode": CostCodeMgr costcodeMgr = new CostCodeMgr(); result = costcodeMgr.ImportCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "ProjectCostCode": CostCodeMgr projectcostcodeMgr = new CostCodeMgr(); result = projectcostcodeMgr.ImportProjectCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "ClientCostCode": CostCodeMgr clientcostcodeMgr = new CostCodeMgr(); result = clientcostcodeMgr.ImportClientCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "HR": PersonnelMgr personnelMgr = new PersonnelMgr(); result = personnelMgr.ImportPersonnelFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "User": SigmaUserMgr sigmauserMgr = new SigmaUserMgr(); result = sigmauserMgr.ImportSigmaUserFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "MeterialLibrary": ImportMgr importMeterial = new ImportMgr(); result = importMeterial.ImportMeterialLib(filePath, ConfigMgr.GetExportFilePath()); break; case "EquipmentLibrary": ImportMgr importEquipment = new ImportMgr(); result = importEquipment.ImportEquipmentLib(filePath, ConfigMgr.GetExportFilePath()); break; case "ConsumableLibrary": ImportMgr importConsumable = new ImportMgr(); result = importConsumable.ImportConsumableLib(filePath, ConfigMgr.GetExportFilePath()); break; case "DrawingType": ImportMgr importDrawingType = new ImportMgr(); result = importDrawingType.ImportDrawingTypeLib(filePath, ConfigMgr.GetExportFilePath()); break; default: break; } 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 AddSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole) { SigmaResultType result = new SigmaResultType(); try { SigmaUserMgr sigmaUserMgr = new SigmaUserMgr(); result = sigmaUserMgr.AddSigmaUserSigmaRole(objSigmaUserSigmaRole); return result; } catch (Exception ex) { // Log Exception ExceptionHelper.logException(ex); result.IsSuccessful = false; result.ErrorMessage = ex.Message; return result; } }
public SigmaResultType MultiSigmaUser(List<TypeSigmaUser> listObj) { SigmaResultType result = new SigmaResultType(); try { SigmaUserMgr sigmaUserMgr = new SigmaUserMgr(); result = sigmaUserMgr.MultiSigmaUser(listObj); return result; } catch (Exception ex) { // Log Exception ExceptionHelper.logException(ex); result.IsSuccessful = false; result.ErrorMessage = ex.Message; return result; } }
public SigmaResultType ListSigmaUserSigmaRole() { 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"]; SigmaUserMgr sigmaUserMgr = new SigmaUserMgr(); result = sigmaUserMgr.ListSigmaUserSigmaRole(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; } }
public SigmaResultType GetSigmaUserSigmaRole(string sigmaUserId) { SigmaResultType result = new SigmaResultType(); try { SigmaUserMgr sigmaUserMgr = new SigmaUserMgr(); result = sigmaUserMgr.GetSigmaUserSigmaRole(sigmaUserId); return result; } catch (Exception ex) { // Log Exception ExceptionHelper.logException(ex); result.IsSuccessful = false; result.ErrorMessage = ex.Message; return result; } }