private void Awake() { // Make this object persistence across all levels DontDestroyOnLoad(gameObject); // Check the presence assessment related objects (from start level) if (GameObject.Find("Assessment") == null || GameObject.Find("Assessment").GetComponent<AssessmentManager>() == null) { Debug.LogError("No assessment object found"); return; } mAssesmentManager = GameObject.Find("Assessment").GetComponent<AssessmentManager>(); mFeedbackAssessor = gameObject.GetComponent<FeedbackAssessor>(); mAssesment = new Assesment(); LoadQuizForLevel(); mWindowHeight = (3 * Screen.height) / 4; mWindowWidth = Screen.width / 2; mWindowSize = new Rect(0, (Screen.height / 4), mWindowWidth, mWindowHeight); mFeedbackWindowSize = new Rect(0, (Screen.height / 4), mWindowWidth, mWindowHeight / 4); }
public void Put_Assessment_Returns_OKStatusCode() { // Arrange var fakeAssessmentModel = new AssessmentModel() { Id = 1000, Name = "test fake assessment", Duration = 5 }; assessmentRepository.Setup(x => x.Update(It.IsAny <Assessment>())); assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null); var controller = SetupControllerContext(HttpMethod.Put, string.Format("http://localhost/api/assessments/{0}", fakeAssessmentModel.Id)); // Act var response = controller.Put(fakeAssessmentModel.Id, fakeAssessmentModel); // Assert Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }
public void Delete_Assessment_Returns_Assessment() { // Arrange var fakeAssessment = new Assessment() { Id = 1000, Name = "test fake assessment", Duration = 10 }; assessmentRepository.Setup(x => x.Delete(1000)); assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null); //// Act assessmentManager.Delete(1000); //// Assert //Assert.IsNotNull(newAssessment, "Result is null"); //Assert.IsInstanceOfType(newAssessment, typeof(Assessment), "Invalid Enitity"); //Assert.AreEqual(1000, newAssessment.Id); }
public ActionResult EditEntity() { string data = Request.Params["requestData"]; if (data == null) { return(Json( new OperateResult { content = "无考核数据", }, JsonRequestBehavior.AllowGet )); } JavaScriptSerializer js = new JavaScriptSerializer(); AssessmentInfo model = js.Deserialize <AssessmentInfo>(data); if (model == null) { return(Json( new OperateResult { content = "无考核数据", }, JsonRequestBehavior.AllowGet )); } if (!ModelState.IsValid) { return(Json( new OperateResult { content = Model.Utility.GetModelStateErrors(ModelState), }, JsonRequestBehavior.AllowGet )); } OperateResult or = AssessmentManager.Update(model); return(Json(or, JsonRequestBehavior.AllowGet)); }
public virtual MoveNode runOneStepAheadAnalysis(Type assessor) { AssessmentManager manager = new AssessmentManager(config, assessor, currentPos.PossibilitySize); SymmetryEnvironment symmetryEnvironment = new SymmetryEnvironment(currentPos); ResultSet resultSet = new ResultSet(symmetryEnvironment, config); Parallel.For(short.MinValue, short.MinValue + config.combinations, m => { MoveNode testMove = currentPos.addTemporarySubMove((short)m); PossibilityDivisionAssessor assess = manager.getSetAssessor(); if (!resultSet.symmetryEnvironment.checkSymmetry(testMove)) { return; } for (int i = 0; i < resultSet.config.grades; i++) { MoveNode.GradeNode tempGrade = testMove.addSubGrade(i); if (tempGrade.PossibilitySize == 0) { tempGrade.unregister(); continue; } assess.updateNextIndividual(tempGrade.PossibilitySize); if (!assess.check(resultSet.config.grades - i - 1)) { return; } } lock (resultSet) { if (!assess.check(0)) { return; } assess.updateBestValue(); testMove.AssessmentValue = assess.CurrentSetValue; resultSet.BestMove = testMove; } }); currentPos.addSubNode(resultSet.BestMove); return(resultSet.BestMove); }
public void Get_All_Returns_AllAssessments_Action() { // Arrange IQueryable <Assessment> fakeAssessment = GetAssessments(); assessmentRepository.Setup(x => x.Get(It.IsAny <Expression <Func <Assessment, bool> > >() , It.IsAny <Func <IQueryable <Assessment>, IOrderedQueryable <Assessment> > >() , It.IsAny <List <Expression <Func <Assessment, object> > > >(), It.IsAny <int?>(), It.IsAny <int?>())).Returns(fakeAssessment); assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null); var controller = SetupControllerContext(HttpMethod.Get, "http://localhost/api/assessments/"); //// Act var pagedAssessments = controller.GetAll(); //// Assert Assert.IsNotNull(pagedAssessments, "Result is null"); Assert.IsInstanceOfType(pagedAssessments, typeof(PagedModel <AssessmentModel>), "Wrong Model"); Assert.AreEqual(4, pagedAssessments.TotalRecords, "Wrong number of record count"); Assert.AreEqual(4, pagedAssessments.PagedData.Count, "Got wrong number of Assessments"); }
public void Get_One_Assessment() { // Arrange Assessment fakeAssessment = new Assessment() { Id = 1000, Name = "test fake assessment" }; assessmentRepository.Setup(x => x.GetByID(1000)).Returns(fakeAssessment); assessmentManager = new AssessmentManager(null, assessmentRepository.Object, null); //// Act var assessment = assessmentManager.Get(1000); //// Assert Assert.IsNotNull(assessment, "Result is null"); Assert.IsInstanceOfType(assessment, typeof(Assessment), "Wrong Model"); Assert.AreEqual(1000, assessment.Id, "Got wrong number of Assessments"); }
public static ThisEntity Get(int parentId, int assessmentId) { ThisEntity entity = new ThisEntity(); if (parentId < 1 || assessmentId < 1) { return(entity); } try { using (var context = new EntityContext()) { EM.Entity_Assessment from = context.Entity_Assessment .SingleOrDefault(s => s.AssessmentId == assessmentId && s.EntityId == parentId); if (from != null && from.Id > 0) { entity.Id = from.Id; entity.AssessmentId = from.AssessmentId; entity.EntityId = from.EntityId; entity.RelationshipTypeId = from.RelationshipTypeId; entity.ProfileSummary = from.Assessment.Name; //to.Credential = from.Credential; entity.Assessment = new AssessmentProfile(); AssessmentManager.MapFromDB_Basic(from.Assessment, entity.Assessment, false //includeCosts - propose to use for credential editor ); if (IsValidDate(from.Created)) { entity.Created = ( DateTime )from.Created; } } } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".Get"); } return(entity); } //
public AssessmentManagerTest() { _assessmentRepo = new Mock <IAssessmentRepository>(MockBehavior.Strict); _assessmentValidator = new Mock <IAssessmentValidator>(MockBehavior.Strict); _assessmentManager = new AssessmentManager(_assessmentRepo.Object, _assessmentValidator.Object); _assessmentRequestModel = new AssessmentRequestModel { Duration = 1, Instructions = "instruction", Name = "Otee" }; _assessmentResponseModel = new AssessmentResponseModel { CreatedOn = DateTime.Now, Id = "ce705f44-07e0-45c6-b51d-3b1af6256848", Duration = _assessmentRequestModel.Duration, Instructions = _assessmentRequestModel.Instructions, Name = _assessmentRequestModel.Name }; }
public void Post_Assessment_Action_Returns_CreatedStatusCode() { // Arrange var fakeAssessmentModel = new AssessmentModel() { Id = 1000, Name = "test fake assessment", Duration = 10 }; assessmentRepository.Setup(x => x.Insert(It.IsAny <Assessment>())); assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null); var controller = SetupControllerContext(HttpMethod.Post, "http://localhost/api/assessments/"); //// Act var response = controller.Post(fakeAssessmentModel); //// Assert Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); var newAssessment = JsonConvert.DeserializeObject <AssessmentModel>(response.Content.ReadAsStringAsync().Result); Assert.IsNotNull(newAssessment, "Result is null"); Assert.AreEqual(string.Format("http://localhost/api/assessments/{0}", newAssessment.Id), response.Headers.Location.ToString()); }
public void Delete_Assessment_Returns_NoContentStatusCode() { // Arrange var fakeUoW = new Mock <IUnitOfWork>(); fakeUoW.Setup(u => u.Commit()); var fakeAssessmentModel = new AssessmentModel() { Id = 1000, Name = "test fake assessment", Duration = 5 }; assessmentRepository.Setup(x => x.Delete(It.IsAny <Assessment>())); assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null); var controller = SetupControllerContext(HttpMethod.Delete, string.Format("http://localhost/api/assessments/{0}", fakeAssessmentModel.Id)); // Act var response = controller.Delete(1000); // Assert Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); }
public void Get_One_Assessment_Action() { // Arrange Assessment fakeAssessment = new Assessment() { Id = 1000, Name = "test fake assessment" }; assessmentRepository.Setup(x => x.GetByID(1000)).Returns(fakeAssessment); assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null); var controller = SetupControllerContext(HttpMethod.Get, "http://localhost/api/assessments/1000"); //// Act var response = controller.Get(1000); //// Assert Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); var assessment = JsonConvert.DeserializeObject <AssessmentModel>(response.Content.ReadAsStringAsync().Result); Assert.IsNotNull(assessment, "Result is null"); Assert.IsInstanceOfType(assessment, typeof(AssessmentModel), "Wrong Model"); Assert.AreEqual(1000, assessment.Id, "Got wrong number of Assessments"); }
public ActionResult ImportExcel() { if (Request.Files.Count == 0) { return(Json( new OperateResult { content = "请上传数据文件", }, JsonRequestBehavior.AllowGet )); } HttpPostedFileBase file = Request.Files["fileName"]; if (file == null) { return(Json( new OperateResult { content = "请上传数据文件", }, JsonRequestBehavior.AllowGet )); } switch (Path.GetExtension(file.FileName)) { case ".xlsx": case ".xls": break; default: return(Json( new OperateResult { content = "上传的文件不是Excel文件", }, JsonRequestBehavior.AllowGet )); } string target = Server.MapPath("/") + ("/Upload/");//取得目标文件夹的路径 int pos = file.FileName.LastIndexOf('\\'); string filename; if (pos >= 0) { filename = file.FileName.Substring(pos + 1); } else { filename = file.FileName; } string path = target + filename;//获取存储的目标地址 file.SaveAs(path); OperateResult or = AssessmentManager.ImportExcel(path); return(Json(or, JsonRequestBehavior.AllowGet)); }
public ActionResult UnlockStatus(long id, string status) { OperateResult or = AssessmentManager.UpdateStatus(id, status); return(Json(or, JsonRequestBehavior.AllowGet)); }
private void Awake() { if(GameObject.Find("Assessment") != null) mAssesmentManager = GameObject.Find("Assessment").GetComponent<AssessmentManager>(); }
} // public static List <OrganizationRoleProfile> GetAllCombinedForOrganization(Guid agentUid, ref int totalRecords, int maxRecords = 25) { OrganizationRoleProfile orp = new OrganizationRoleProfile(); List <OrganizationRoleProfile> list = new List <OrganizationRoleProfile>(); EnumeratedItem eitem = new EnumeratedItem(); Guid prevTargetUid = new Guid(); string prevRoleSource = ""; int prevRoleTypeId = 0; Entity agentEntity = EntityManager.GetEntity(agentUid); if (UtilityManager.GetAppKeyValue("envType") == "production") { //show all for now in production //maxRecords = 0; } using (var context = new ViewContext()) { //first check how long this step takes DateTime start = DateTime.Now; LoggingHelper.DoTrace(4, "GetAllCombinedForOrganization start"); List <Views.Organization_CombinedQAPerformed> agentRoles = context.Organization_CombinedQAPerformed .Where(s => s.OrgUid == agentUid && s.IsQARole == true && s.TargetEntityStateId > 1) .OrderBy(s => s.TargetEntityTypeId) .ThenBy(s => s.TargetOwningOrganizationName) .ThenBy(s => s.TargetEntityName) .ThenBy(s => s.AgentToSourceRelationship) .ThenBy(s => s.roleSource) .ToList(); DateTime end = DateTime.Now; var elasped = end.Subtract(start).TotalSeconds; LoggingHelper.DoTrace(4, string.Format("GetAllCombinedForOrganization retrieve seconds: {0}", elasped)); if (agentRoles != null && agentRoles.Count() > 0) { // totalRecords = agentRoles.Count(); //may want a fudge factor? } int cntr = 0; foreach (var entity in agentRoles) { cntr++; //loop until change in entity type? if (prevTargetUid != entity.TargetEntityUid) { //handle previous fill if (IsGuidValid(prevTargetUid) && prevRoleTypeId > 0) { orp.AgentRole.Items.Add(eitem); list.Add(orp); if (maxRecords > 0 && cntr >= maxRecords) { break; } } prevTargetUid = entity.TargetEntityUid; prevRoleSource = entity.roleSource; prevRoleTypeId = entity.RelationshipTypeId; orp = new OrganizationRoleProfile { Id = 0, ParentId = agentEntity.EntityBaseId, ParentTypeId = agentEntity.EntityTypeId, ProfileSummary = entity.TargetEntityName, AgentRole = CodesManager.GetEnumeration(CodesManager.PROPERTY_CATEGORY_ENTITY_AGENT_ROLE) }; orp.AgentRole.ParentId = entity.OrgId; orp.AgentRole.Items = new List <EnumeratedItem>(); orp.SourceEntityType = entity.TargetEntityType; if (entity.TargetEntityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { //17-08-27 mp - just get the basic for each entity! orp.TargetCredential = CredentialManager.GetBasic(entity.TargetEntityBaseId ?? 0); } else if (entity.TargetEntityTypeId == CodesManager.ENTITY_TYPE_ORGANIZATION) { //orp.TargetOrganization = OrganizationManager.GetBasics( entity.TargetEntityUid ); orp.TargetOrganization.Id = entity.TargetEntityBaseId ?? 0; orp.TargetOrganization.RowId = entity.TargetEntityUid; orp.TargetOrganization.Name = entity.TargetEntityName; orp.TargetOrganization.Description = entity.TargetEntityDescription; orp.TargetOrganization.EntityStateId = entity.TargetEntityStateId ?? 2; orp.TargetOrganization.SubjectWebpage = entity.TargetEntitySubjectWebpage; orp.TargetOrganization.Image = entity.TargetEntityImageUrl; } else if (entity.TargetEntityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { orp.TargetAssessment = AssessmentManager.GetBasic(entity.TargetEntityBaseId ?? 0); } else if (entity.TargetEntityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { orp.TargetLearningOpportunity = LearningOpportunityManager.GetBasic(entity.TargetEntityBaseId ?? 0); } } /* either first one for new target * or change in relationship * or change in role source */ if (prevRoleTypeId == entity.RelationshipTypeId) { if (prevRoleSource != entity.roleSource) { if (entity.roleSource == "DirectAssertion") { eitem.IsDirectAssertion = true; } else { eitem.IsIndirectAssertion = true; } //add previous //could get a dup if there is an immediate chg in target, //orp.AgentRole.Items.Add( eitem ); prevRoleSource = entity.roleSource; continue; } } else { //if not equal, add previous, and initialize next one (fall thru) orp.AgentRole.Items.Add(eitem); } //add relationship eitem = new EnumeratedItem { Id = entity.RelationshipTypeId, Name = entity.AgentToSourceRelationship, SchemaName = entity.ReverseSchemaTag, IsQAValue = true }; //eitem.CodeId = entity.RelationshipTypeId; prevRoleTypeId = entity.RelationshipTypeId; prevRoleSource = entity.roleSource; if (entity.roleSource == "DirectAssertion") { eitem.IsDirectAssertion = true; } else { eitem.IsIndirectAssertion = true; } //eitem.Name = entity.AgentToSourceRelationship; // eitem.SchemaName = entity.ReverseSchemaTag; // orp.AgentRole.Items.Add( eitem ); } //end //check for remaining if (IsGuidValid(prevTargetUid) && orp.AgentRole.Items.Count > 0) { orp.AgentRole.Items.Add(eitem); list.Add(orp); } DateTime listEnd = DateTime.Now; elasped = listEnd.Subtract(end).TotalSeconds; LoggingHelper.DoTrace(4, string.Format("GetAllCombinedForOrganization loaded list seconds: {0}", elasped)); } return(list); } //
// /// <summary> /// Handle component import /// TODO - should a save be done for each component or wait until the end /// </summary> /// <param name="input"></param> /// <param name="pathway"></param> /// <param name="bnodes"></param> /// <param name="status">TODO - do we want to continue using the pathway SaveStatus?</param> /// <returns></returns> public OutputComponent ImportComponent(InputComponent input, ThisEntity pathway, List <BNode> bnodes, SaveStatus status) { MappingHelperV3 helper = new MappingHelperV3(CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT); //do we need to reference blank nodes here? - if so pass to this method helper.entityBlankNodes = bnodes; helper.CurrentEntityCTID = input.CTID; helper.CurrentEntityName = input.Name.ToString(); OutputComponent output = new OutputComponent(); // LoggingHelper.DoTrace(5, "======== Component ======== "); LoggingHelper.DoTrace(5, " type: "+ input.PathwayComponentType.ToString()); LoggingHelper.DoTrace(5, " name: "+ (input.Name ?? new JInput.LanguageMap("componentNameMissing")).ToString()); LoggingHelper.DoTrace(5, " ctid: "+ input.CTID); LoggingHelper.DoTrace(6, " @Id: "+ input.CtdlId); try { //add/updating Pathway if (!DoesComponentExist(input.CTID, ref output)) { //set the rowid now, so that can be referenced as needed //no, the guid comes from the resolving of entity references //actually OK, as earlier references would result in a pending record output.RowId = Guid.NewGuid(); } helper.currentBaseObject = output; if (input.CTID == "ce-fa6c139f-0615-401f-9920-6ec8c445baca") { } //initialize json properties output.JsonProperties = new PathwayComponentProperties(); // output.PathwayComponentType = input.PathwayComponentType; output.Name = helper.HandleLanguageMap(input.Name, output, "Name"); output.Description = helper.HandleLanguageMap(input.Description, output, "Description"); output.SubjectWebpage = input.SubjectWebpage; output.SourceData = input.SourceData; if (!string.IsNullOrWhiteSpace(output.SourceData) && output.SourceData.IndexOf("/resources/") > 0) { var ctid = ResolutionServices.ExtractCtid(output.SourceData); if (!string.IsNullOrWhiteSpace(ctid)) { if (output.PathwayComponentType.ToLower().IndexOf("credential") > -1) { var target = CredentialManager.GetMinimumByCtid(ctid); if (target != null && target.Id > 0) { //this approach 'buries' the cred from external references like credential in pathway output.SourceCredential = new TopLevelEntityReference() { Id = target.Id, Name = target.Name, Description = target.Description, CTID = target.CTID, SubjectWebpage = target.SubjectWebpage, //RowId = target.RowId }; output.JsonProperties.SourceCredential = output.SourceCredential; } } else if (output.PathwayComponentType.ToLower().IndexOf("assessmentcomp") > -1) { var target = AssessmentManager.GetSummaryByCtid(ctid); if (target != null && target.Id > 0) { //may not really need this, just the json output.SourceAssessment = new TopLevelEntityReference() { Id = target.Id, Name = target.Name, Description = target.Description, CTID = target.CTID, SubjectWebpage = target.SubjectWebpage, //RowId = target.RowId }; output.JsonProperties.SourceAssessment = output.SourceAssessment; } } else if (output.PathwayComponentType.ToLower().IndexOf("coursecomp") > -1) { var target = LearningOpportunityManager.GetByCtid(ctid); if (target != null && target.Id > 0) { //may not really need this, just the json output.SourceLearningOpportunity = new TopLevelEntityReference() { Id = target.Id, Name = target.Name, Description = target.Description, CTID = target.CTID, SubjectWebpage = target.SubjectWebpage, //RowId = target.RowId }; output.JsonProperties.SourceLearningOpportunity = output.SourceLearningOpportunity; } } } } output.CTID = input.CTID; output.PathwayCTID = pathway.CTID; //output.CodedNotation = input.CodedNotation; output.Identifier = helper.MapIdentifierValueListInternal(input.Identifier); if (output.Identifier != null && output.Identifier.Count() > 0) { output.IdentifierJson = JsonConvert.SerializeObject(output.Identifier, MappingHelperV3.GetJsonSettings()); } // output.ComponentDesignationList = helper.MapCAOListToList(input.ComponentDesignation); // output.CredentialType = input.CredentialType; output.CreditValue = helper.HandleValueProfileList(input.CreditValue, output.PathwayComponentType + ".CreditValue"); //TBD - how to handle. Will need to have imported the concept scheme/concept if (input.HasProgressionLevel != null && input.HasProgressionLevel.Any()) { foreach (var item in input.HasProgressionLevel) { output.HasProgressionLevels.Add(ResolutionServices.ExtractCtid(item)); } } output.PointValue = helper.HandleQuantitiveValue(input.PointValue, output.PathwayComponentType + ".PointValue"); // output.ProgramTerm = helper.HandleLanguageMap(input.ProgramTerm, output, "ProgramTerm"); //need to get relationshiptype to store-> this can be done by manager //3 output.HasChildList = helper.MapEntityReferenceGuids("PathwayComponent.HasChild", input.HasChild, CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT, ref status); //2 output.HasIsChildOfList = helper.MapEntityReferenceGuids("PathwayComponent.IsChildOf", input.IsChildOf, CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT, ref status); output.HasPrerequisiteList = helper.MapEntityReferenceGuids("PathwayComponent.Prerequisite", input.Prerequisite, CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT, ref status); output.HasPreceedsList = helper.MapEntityReferenceGuids("PathwayComponent.Preceeds", input.Preceeds, CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT, ref status); //populate JSON properties output.JsonProperties.ComponentDesignationList = output.ComponentDesignationList; output.JsonProperties.CreditValue = output.CreditValue; output.JsonProperties.Identifier = output.Identifier; output.JsonProperties.PointValue = output.PointValue; // if (input.HasCondition != null && input.HasCondition.Count() > 0) { output.HasCondition = new List <PathwayComponentCondition>(); foreach (var item in input.HasCondition) { //var jcc = JsonConvert.DeserializeObject<JInput.ComponentCondition>( item.ToString() ); var cc = new PathwayComponentCondition(); cc.Name = helper.HandleLanguageMap(item.Name, cc, "ComponentCondition.Name"); cc.Description = helper.HandleLanguageMap(item.Description, cc, "ComponentCondition.Description"); cc.RequiredNumber = item.RequiredNumber; cc.PathwayCTID = pathway.CTID; cc.HasTargetComponentList = helper.MapEntityReferenceGuids("ComponentCondition.TargetComponent", item.TargetComponent, CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT, ref status); output.HasCondition.Add(cc); } } } catch (Exception ex) { LoggingHelper.LogError(ex, "ImportPathways.ImportComponent"); //status.AddError( string.Format( "ImportPathways.ImportComponent. ComponentType: {0}, Name: {1}, Message: {2}", output.ComponentTypeId, output.Name, ex.Message ) ); } //then save return(output); }
public static Guid ResolveEntityByRegistryAtIdToGuid(string property, string referencedAtId, int entityTypeId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = new Guid(); string ctid = ""; int newEntityId = 0; if (string.IsNullOrWhiteSpace(referencedAtId)) { return(entityUid); } List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); if (ctid == "ce-fa6c139f-0615-401f-9920-6ec8c445baca") { } EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) //20-07-30 mparsons - why is EntityUid returned here? //check this return(( Guid )item.EntityUid); } else { if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( Guid )item.EntityUid); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( Guid )item2.EntityUid); } } } //add an import entry ImportManager importManager = new ImportManager(); entityUid = Guid.NewGuid(); string statusMsg = ""; if (entityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { newEntityId = new CredentialManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Credential Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { newEntityId = new AssessmentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Assessment Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { newEntityId = new LearningOpportunityManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Learning Opportunity Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COST_MANIFEST) { //should know the parent org, add to this method newEntityId = new CostManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("CostManifest Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_CONDITION_MANIFEST) { newEntityId = new ConditionManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("ConditionManifest Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE) { //not sure we will ever have a reference to a TVP? newEntityId = new TransferValueProfileManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("TransferValue Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY) { newEntityId = new PathwayManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Pathway Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT) { if (ctid == "ce-fa6c139f-0615-401f-9920-6ec8c445baca") { } //need pathwayCTID for this ce-abcb5fe0-8fde-4f06-9d70-860cd5bdc763 newEntityId = new PathwayComponentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else { //for properties like organization.Offers, we don't know what the entity type is. //SO..... } if (BaseFactory.IsGuidValid(entityUid)) { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, entityTypeId, entityUid, newEntityId, false, ref messages); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); //return 0; } } return(entityUid); }
public static Guid ResolveEntityByRegistryAtIdToGuid(string referencedAtId, int entityTypeId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = new Guid(); string ctid = ""; int newEntityId = 0; if (string.IsNullOrWhiteSpace(referencedAtId)) { return(entityUid); } List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) return(( Guid )item.EntityUid); //add activity or error //return entityUid; } else { if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( Guid )item.EntityUid); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( Guid )item2.EntityUid); } } } //add an import entry ImportManager importManager = new ImportManager(); entityUid = Guid.NewGuid(); string statusMsg = ""; if (entityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { newEntityId = new CredentialManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { newEntityId = new AssessmentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { newEntityId = new LearningOpportunityManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COST_MANIFEST) { //should know the parent org, add to this method newEntityId = new CostManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_CONDITION_MANIFEST) { newEntityId = new ConditionManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else { //for properties like organization.Offers, we don't know what the entity type is. //SO..... } if (BaseFactory.IsGuidValid(entityUid)) { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, entityTypeId, entityUid, newEntityId, false, ref messages); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); //return 0; } } return(entityUid); }
/// <summary> /// Populates a few principal assessment tables. /// </summary> /// <param name="model"></param> /// <param name="currentUserId"></param> /// <param name="primaryEmail"></param> /// <param name="db"></param> /// <returns></returns> public int RunImportManualPortion(UploadAssessmentModel model, int currentUserId, string primaryEmail, CSET_Context db) { //create the new assessment //copy each of the items to the table //as the copy occurs change to the current assessment_id //update the answer id's Dictionary <int, DOCUMENT_FILE> oldIdToNewDocument = new Dictionary <int, DOCUMENT_FILE>(); AssessmentManager man = new AssessmentManager(); AssessmentDetail detail = man.CreateNewAssessmentForImport(currentUserId); int _assessmentId = detail.Id; Dictionary <int, int> oldAnswerId = new Dictionary <int, int>(); Dictionary <int, ANSWER> oldIdNewAnswer = new Dictionary <int, ANSWER>(); Dictionary <string, int> oldUserNewUser = db.USERS.ToDictionary(x => x.PrimaryEmail, y => y.UserId); foreach (var a in model.jASSESSMENTS) { var item = db.ASSESSMENTS.Where(x => x.Assessment_Id == _assessmentId).FirstOrDefault(); if (item != null) { item.Diagram_Markup = a.Diagram_Markup; item.Diagram_Image = a.Diagram_Image; item.Assets = a.Assets; item.Charter = a.Charter; item.CreditUnionName = a.CreditUnionName; item.IRPTotalOverride = a.IRPTotalOverride; item.IRPTotalOverrideReason = a.IRPTotalOverrideReason; item.MatDetail_targetBandOnly = a.MatDetail_targetBandOnly != null ? a.MatDetail_targetBandOnly : false; db.SaveChanges(); } } foreach (var a in model.jINFORMATION) { var item = db.ASSESSMENTS.Where(x => x.Assessment_Id == _assessmentId).FirstOrDefault(); if (item != null) { item.Assessment_Date = a.Assessment_Date; db.SaveChanges(); } } // go through the assessment contacts and: // - if the contact does exist create it then add the id // - if the contact does exist update the id var dictAC = new Dictionary <int, int>(); foreach (var a in model.jASSESSMENT_CONTACTS) { // Don't create another primary contact, but map its ID if (a.PrimaryEmail == primaryEmail) { var newPrimaryContact = db.ASSESSMENT_CONTACTS.Where(x => x.PrimaryEmail == primaryEmail && x.Assessment_Id == _assessmentId).FirstOrDefault(); dictAC.Add(a.Assessment_Contact_Id, newPrimaryContact.Assessment_Contact_Id); continue; } var item = TinyMapper.Map <ASSESSMENT_CONTACTS>(a); item.Assessment_Id = _assessmentId; item.PrimaryEmail = a.PrimaryEmail; if (oldUserNewUser.TryGetValue(a.PrimaryEmail, out int userid)) { item.UserId = userid; } else { item.UserId = null; } db.ASSESSMENT_CONTACTS.Add(item); db.SaveChanges(); int newId; if (a.Assessment_Contact_Id != 0) { if (dictAC.TryGetValue(a.Assessment_Contact_Id, out newId)) { dictAC.Add(newId, newId); a.Assessment_Contact_Id = newId; } else { dictAC.Add(a.Assessment_Contact_Id, item.Assessment_Contact_Id); } } } // map the primary keys so that they can be passed to the generic import logic this.mapIdentity.Add("ASSESSMENT_CONTACTS", dictAC); // foreach (var a in model.jUSER_DETAIL_INFORMATION) { if (db.USER_DETAIL_INFORMATION.Where(x => x.Id == a.Id).FirstOrDefault() == null) { var userInfo = TinyMapper.Map <USER_DETAIL_INFORMATION>(a); userInfo.FirstName = String.IsNullOrWhiteSpace(a.FirstName) ? "First Name" : a.FirstName; userInfo.LastName = String.IsNullOrWhiteSpace(a.LastName) ? "Last Name" : a.LastName; db.USER_DETAIL_INFORMATION.Add(userInfo); foreach (var b in a.jADDRESSes) { var item = TinyMapper.Map <ADDRESS>(b); item.AddressType = "Imported"; db.ADDRESS.Add(item); } db.SaveChanges(); } } return(_assessmentId); }
} // public static void MapFromDB(DBEntity input, ThisEntity output, bool gettingAll = true) { output.Id = input.Id; output.RowId = input.RowId; output.EntityStateId = input.EntityStateId; output.Name = input.Name; output.Description = input.Description; output.CTID = input.CTID; if (input.Created != null) { output.Created = ( DateTime )input.Created; } if (input.LastUpdated != null) { output.LastUpdated = ( DateTime )input.LastUpdated; } if (IsGuidValid(input.OwningAgentUid)) { output.OwningAgentUid = ( Guid )input.OwningAgentUid; output.OwningOrganization = OrganizationManager.GetForSummary(output.OwningAgentUid); //get roles OrganizationRoleProfile orp = Entity_AgentRelationshipManager.AgentEntityRole_GetAsEnumerationFromCSV(output.RowId, output.OwningAgentUid); output.OwnerRoles = orp.AgentRole; } // output.OrganizationRole = Entity_AgentRelationshipManager.AgentEntityRole_GetAll_ToEnumeration(output.RowId, true); // //get related .... var relatedEntity = EntityManager.GetEntity(output.RowId, false); if (relatedEntity != null && relatedEntity.Id > 0) { output.EntityLastUpdated = relatedEntity.LastUpdated; } // output.SubjectWebpage = input.SubjectWebpage; output.CredentialRegistryId = input.CredentialRegistryId ?? ""; output.LifecycleStatusType = string.IsNullOrWhiteSpace(input.LifecycleStatusType) ? "lifecycle:Active" : input.LifecycleStatusType; //output.CodedNotation = input.CodedNotation; //20-12-16 changed to a string as partial dates are possible if (!string.IsNullOrWhiteSpace(input.StartDate)) { output.StartDate = input.StartDate; } else { output.StartDate = ""; } // if (!string.IsNullOrWhiteSpace(input.EndDate)) { output.EndDate = input.EndDate; } else { output.EndDate = ""; } //derived from .... //get json and expand output.IdentifierJson = input.IdentifierJson; output.TransferValueJson = input.TransferValueJson; output.TransferValueFromJson = input.TransferValueFromJson; output.TransferValueForJson = input.TransferValueForJson; // if (!string.IsNullOrWhiteSpace(output.IdentifierJson)) { output.Identifier = JsonConvert.DeserializeObject <List <Entity_IdentifierValue> >(output.IdentifierJson); } if (!string.IsNullOrWhiteSpace(output.TransferValueJson)) { output.TransferValue = JsonConvert.DeserializeObject <List <ValueProfile> >(output.TransferValueJson); } if (!gettingAll) { return; } //the top level object may not be enough. First need to confirm if reference lopps and asmts can have detail pages. if (!string.IsNullOrWhiteSpace(output.TransferValueFromJson)) { output.TransferValueFrom = JsonConvert.DeserializeObject <List <TopLevelObject> >(output.TransferValueFromJson); var lopps = output.TransferValueFrom.Where(s => s.EntityTypeId == 7).ToList(); foreach (var item in lopps) { output.TransferValueFromLopp.Add(LearningOpportunityManager.GetForDetail(item.Id)); } var assmts = output.TransferValueFrom.Where(s => s.EntityTypeId == 3).ToList(); foreach (var item in assmts) { output.TransferValueFromAsmt.Add(AssessmentManager.GetForDetail(item.Id)); } var creds = output.TransferValueFrom.Where(s => s.EntityTypeId == 1).ToList(); foreach (var item in creds) { output.TransferValueFromCredential.Add(CredentialManager.GetForDetail(item.Id)); } } // if (!string.IsNullOrWhiteSpace(output.TransferValueForJson)) { output.TransferValueFor = JsonConvert.DeserializeObject <List <TopLevelObject> >(output.TransferValueForJson); var lopps = output.TransferValueFor.Where(s => s.EntityTypeId == 7).ToList(); foreach (var item in lopps) { output.TransferValueForLopp.Add(LearningOpportunityManager.GetForDetail(item.Id)); } var assmts = output.TransferValueFor.Where(s => s.EntityTypeId == 3).ToList(); foreach (var item in assmts) { output.TransferValueForAsmt.Add(AssessmentManager.GetForDetail(item.Id)); } var creds = output.TransferValueFor.Where(s => s.EntityTypeId == 1).ToList(); foreach (var item in creds) { output.TransferValueForCredential.Add(CredentialManager.GetForDetail(item.Id)); } } //this should be a summary level, not the full TVP output.DerivedFrom = Entity_TransferValueProfileManager.GetAll(output.RowId); // List <ProcessProfile> processes = Entity_ProcessProfileManager.GetAll(output.RowId); foreach (ProcessProfile item in processes) { if (item.ProcessTypeId == Entity_ProcessProfileManager.DEV_PROCESS_TYPE) { output.DevelopmentProcess.Add(item); } else { //unexpected } } }
public static int ResolveEntityByRegistryAtId(string referencedAtId, int entityTypeId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = Guid.NewGuid(); int newEntityId = 0; string ctid = ""; List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); LoggingHelper.DoTrace(7, string.Format("ResolutionServices.ResolveEntityByRegistryAtId: EntityTypeId: {0}, referencedAtId: {1} ", entityTypeId, referencedAtId)); EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0 && (item.EntityBaseId ?? 0) > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) return((int)item.EntityBaseId); } else { LoggingHelper.DoTrace(6, string.Format("ResolutionServices. **FAILED** ResolveEntityByRegistryAtId: EntityTypeId: {0}, target.CtdlId: {1}. Trying with CTID: {2}", entityTypeId, referencedAtId, ctid)); if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0 && (item.EntityBaseId ?? 0) > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( int )item.EntityBaseId); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); LoggingHelper.DoTrace(7, string.Format("ResolutionServices.ResolveEntityByRegistryAtId. referencedAtId appears to be a ctid EntityTypeId: {0}, referencedAtId: {1}, ctid: {2} ", entityTypeId, referencedAtId, ctid)); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0 && (item2.EntityBaseId ?? 0) > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( int )item2.EntityBaseId); } else { LoggingHelper.DoTrace(5, string.Format("ResolutionServices.ResolveEntityByRegistryAtId. DID NOT RESOLVE VIA CTID referencedAtId appears to be a ctid EntityTypeId: {0}, ctid: {2} ", entityTypeId, referencedAtId, ctid)); } } } //add an import entry - need to do the base first ImportManager importManager = new ImportManager(); string statusMsg = ""; if (entityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { newEntityId = new CredentialManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { newEntityId = new AssessmentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { newEntityId = new LearningOpportunityManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COST_MANIFEST) { newEntityId = new CostManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_CONDITION_MANIFEST) { newEntityId = new ConditionManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY) { newEntityId = new PathwayManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT) { newEntityId = new PathwayComponentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COMPETENCY_FRAMEWORK) { //actually should not happen - confirm the cf must exist or will be rejected by API newEntityId = new CompetencyFrameworkManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE) { //actually should not happen - confirm the tvp must exist or will be rejected by API newEntityId = new TransferValueProfileManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } // if (newEntityId > 0) { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, entityTypeId, entityUid, newEntityId, false, ref messages, true); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); //this may be wiping out newEntityId //return 0; } } return(newEntityId); }
public IHttpActionResult GetOrganizationTypes() { AssessmentManager assessmentManager = new AssessmentManager(); return(Ok(assessmentManager.GetOrganizationTypes())); }
public int RunImportManualPortion(UploadAssessmentModel model, int currentUserId, string primaryEmail , CSET_Context db) { //create the new assessment //copy each of the items to the table //as the copy occurs change to the current assessment_id //update the answer id's Dictionary <int, DOCUMENT_FILE> oldIdToNewDocument = new Dictionary <int, DOCUMENT_FILE>(); AssessmentManager man = new AssessmentManager(); AssessmentDetail detail = man.CreateNewAssessmentForImport(currentUserId); int _assessmentId = detail.Id; Dictionary <int, int> oldAnswerId = new Dictionary <int, int>(); Dictionary <int, ANSWER> oldIdNewAnswer = new Dictionary <int, ANSWER>(); Dictionary <String, int> oldUserNewUser = db.USERS.ToDictionary(x => x.PrimaryEmail, y => y.UserId); foreach (var a in model.jASSESSMENTS) { var item = db.ASSESSMENTS.Where(x => x.Assessment_Id == _assessmentId).FirstOrDefault(); if (item != null) { item.Assets = a.Assets; item.Charter = a.Charter; item.CreditUnionName = a.CreditUnionName; item.IRPTotalOverride = a.IRPTotalOverride; item.IRPTotalOverrideReason = a.IRPTotalOverrideReason; item.MatDetail_targetBandOnly = a.MatDetail_targetBandOnly != null ? a.MatDetail_targetBandOnly : false; db.SaveChanges(); } } // go through the assessment contacts and // if the contact does exist create it then add the id // if the contact does exist update the id foreach (var a in model.jASSESSMENT_CONTACTS.Where(x => x.PrimaryEmail != primaryEmail)) { var item = TinyMapper.Map <ASSESSMENT_CONTACTS>(a); item.Assessment_Id = _assessmentId; item.PrimaryEmail = a.PrimaryEmail; int userid; if (oldUserNewUser.TryGetValue(a.PrimaryEmail, out userid)) { item.UserId = userid; } else { item.UserId = null; } db.ASSESSMENT_CONTACTS.Add(item); } db.SaveChanges(); foreach (var a in model.jUSER_DETAIL_INFORMATION) { if (db.USER_DETAIL_INFORMATION.Where(x => x.Id == a.Id).FirstOrDefault() == null) { var userInfo = TinyMapper.Map <USER_DETAIL_INFORMATION>(a); userInfo.FirstName = String.IsNullOrWhiteSpace(a.FirstName) ? "First Name" : a.FirstName; userInfo.LastName = String.IsNullOrWhiteSpace(a.LastName) ? "Last Name" : a.LastName; db.USER_DETAIL_INFORMATION.Add(userInfo); foreach (var b in a.jADDRESSes) { var item = TinyMapper.Map <ADDRESS>(b); item.AddressType = "Imported"; db.ADDRESS.Add(item); } db.SaveChanges(); } } return(_assessmentId); #region RKW Oct '19 - These table conversions are being commented out, so that the GenericImporter can do it. //foreach (var a in model.jANSWER) //{ // a.Assessment_Id = _assessmentId; // a.Old_Answer_Id = a.Answer_Id; // a.Answer_Id = 0; //} //db.SaveChanges(); //var objBulk = new BulkUploadToSql<jANSWER>() //{ // InternalStore = model.jANSWER, // TableName = "ANSWER", // CommitBatchSize = 1000, // ConnectionString = ((Microsoft.EntityFrameworkCore.DbContext)db).Database.GetDbConnection().ConnectionString //}; //objBulk.Commit(); //oldAnswerId = db.ANSWER.Where(x => x.Assessment_Id == _assessmentId).ToDictionary(x => x.Old_Answer_Id ?? 0, y => y.Answer_Id); //oldIdNewAnswer = db.ANSWER.Where(x => x.Assessment_Id == _assessmentId).ToDictionary(x => x.Old_Answer_Id ?? 0, y => y); //if (model.jSTANDARD_SELECTION.Count > 0) //{ // foreach (var a in model.jSTANDARD_SELECTION) // { // var item = TinyMapper.Map<STANDARD_SELECTION>(a); // item.Assessment_Id = _assessmentId; // db.STANDARD_SELECTION.Add(item); // } //} //else //{ // db.STANDARD_SELECTION.Add(new STANDARD_SELECTION() // { // Application_Mode = AssessmentModeData.QUESTIONS_BASED_APPLICATION_MODE, // Selected_Sal_Level = Constants.SAL_LOW, // Assessment_Id = _assessmentId, // Last_Sal_Determination_Type = Constants.SIMPLE_SAL, // Is_Advanced = false // }); //} //foreach (var a in model.jASSESSMENT_SELECTED_LEVELS) //{ // var item = TinyMapper.Map<ASSESSMENT_SELECTED_LEVELS>(a); // item.Assessment_Id = _assessmentId; // db.ASSESSMENT_SELECTED_LEVELS.Add(item); //} //foreach (var a in model.jAVAILABLE_STANDARDS) //{ // var item = TinyMapper.Map<AVAILABLE_STANDARDS>(a); // item.Assessment_Id = _assessmentId; // db.AVAILABLE_STANDARDS.Add(item); //} //foreach (var a in model.jCNSS_CIA_JUSTIFICATIONS) //{ // var item = TinyMapper.Map<CNSS_CIA_JUSTIFICATIONS>(a); // item.Assessment_Id = _assessmentId; // db.CNSS_CIA_JUSTIFICATIONS.Add(item); //} //foreach (var a in model.jCUSTOM_BASE_STANDARDS) { var item = TinyMapper.Map<CUSTOM_BASE_STANDARDS>(a); db.CUSTOM_BASE_STANDARDS.Add(item); } //foreach (var a in model.jCUSTOM_QUESTIONAIRES) { var item = TinyMapper.Map<CUSTOM_QUESTIONAIRES>(a); db.CUSTOM_QUESTIONAIRES.Add(item); } //foreach (var a in model.jCUSTOM_QUESTIONAIRE_QUESTIONS) //{ // var item = TinyMapper.Map<CUSTOM_QUESTIONAIRE_QUESTIONS>(a); db.CUSTOM_QUESTIONAIRE_QUESTIONS.Add(item); //} //foreach (var a in model.jCUSTOM_STANDARD_BASE_STANDARD) //{ // var item = TinyMapper.Map<CUSTOM_STANDARD_BASE_STANDARD>(a); db.CUSTOM_STANDARD_BASE_STANDARD.Add(item); //} //foreach (var a in model.jDEMOGRAPHICS) //{ // var item = TinyMapper.Map<DEMOGRAPHICS>(a); // item.Assessment_Id = _assessmentId; // if ((a.IndustryId == 0) || (a.SectorId == 0)) // { // //what do we want to do for a default? // } // else // db.DEMOGRAPHICS.Add(item); //} ////this needs the answers inserted first ////then the documents and finally ////we can associate documents and answers ////look at adding a reference to the answer to jDocument_File ////then as we iterate through the answers and documents keep the references //foreach (var a in model.jDOCUMENT_FILE) //{ // var item = TinyMapper.Map<DOCUMENT_FILE>(a); // oldIdToNewDocument.Add(a.Document_Id, item); // item.Assessment_Id = _assessmentId; // item.Document_Id = 0; // db.DOCUMENT_FILE.Add(item); //} //db.SaveChanges(); //foreach (var a in model.jDOCUMENT_ANSWERS) //{ // var item = oldIdToNewDocument[a.Document_Id]; // db.DOCUMENT_ANSWERS.Add(new DOCUMENT_ANSWERS() // { // Answer_Id = oldIdNewAnswer[a.Answer_Id].Answer_Id, // Document_Id = item.Document_Id // }); //} //Dictionary<int, FINDING> idToFinding = new Dictionary<int, FINDING>(); //foreach (var a in model.jFINDING) //{ // var item = TinyMapper.Map<FINDING>(a); // item.Importance_Id = item.Importance_Id == 0 ? 1 : item.Importance_Id; // item.Answer_Id = oldAnswerId[a.Answer_Id]; // idToFinding.Add(a.Finding_Id, item); // db.FINDING.Add(item); //} //var AcontactID = db.ASSESSMENT_CONTACTS.Where(x => x.UserId == currentUserId).FirstOrDefault(); //if (AcontactID != null)//if we dont have a current user we are in trouble //{ // int acid = AcontactID.Assessment_Contact_Id; // foreach (var a in model.jFINDING_CONTACT) // { // db.FINDING_CONTACT.Add(new FINDING_CONTACT() // { // Assessment_Contact_Id = a.Assessment_Contact_Id == 0 ? acid : a.Assessment_Contact_Id, // Finding_Id = idToFinding[a.Finding_Id].Finding_Id, // Id = a.Old_Contact_Id // }); // } //} //foreach (var a in model.jFRAMEWORK_TIER_TYPE_ANSWER) //{ // var item = TinyMapper.Map<FRAMEWORK_TIER_TYPE_ANSWER>(a); // item.Assessment_Id = _assessmentId; // db.FRAMEWORK_TIER_TYPE_ANSWER.Add(item); //} //foreach (var a in model.jGENERAL_SAL) //{ // var item = TinyMapper.Map<GENERAL_SAL>(a); // item.Assessment_Id = _assessmentId; // db.GENERAL_SAL.Add(item); //} //foreach (var a in model.jINFORMATION) //{ // var info = db.INFORMATION.Where(x => x.Id == _assessmentId).FirstOrDefault(); // if (info != null) // { // TinyMapper.Map(a, info); // info.Id = _assessmentId; // db.SaveChanges(); // } // else // { // var item = TinyMapper.Map<INFORMATION>(a); // item.Id = _assessmentId; // db.INFORMATION.Add(item); // } // db.ASSESSMENTS.Where(x => x.Assessment_Id == _assessmentId).First().Assessment_Date = a.Assessment_Date; // db.SaveChanges(); //} //foreach (var a in model.jNIST_SAL_INFO_TYPES) //{ // var item = TinyMapper.Map<NIST_SAL_INFO_TYPES>(a); // item.Assessment_Id = _assessmentId; // db.NIST_SAL_INFO_TYPES.Add(item); //} //foreach (var a in model.jNIST_SAL_QUESTION_ANSWERS) //{ // var item = TinyMapper.Map<NIST_SAL_QUESTION_ANSWERS>(a); // item.Question_Answer = item.Question_Answer ?? "No"; // item.Assessment_Id = _assessmentId; // db.NIST_SAL_QUESTION_ANSWERS.Add(item); // db.SaveChanges(); //} //foreach (var a in model.jPARAMETER_VALUES) //{ // var item = TinyMapper.Map<PARAMETER_VALUES>(a); // item.Answer_Id = oldAnswerId[a.Answer_Id]; // db.PARAMETER_VALUES.Add(item); //} //foreach (var a in model.jPARAMETER_ASSESSMENTs) //{ // var item = TinyMapper.Map<PARAMETER_ASSESSMENT>(a); // item.Assessment_ID = _assessmentId; // db.PARAMETER_ASSESSMENT.Add(item); //} //foreach (var a in model.jSUB_CATEGORY_ANSWERS) //{ // var item = TinyMapper.Map<SUB_CATEGORY_ANSWERS>(a); // item.Assessement_Id = _assessmentId; // if ((a.Question_Group_Heading_Id > 0) && (a.Universal_Sub_Category_Id > 0)) // { // var header = db.UNIVERSAL_SUB_CATEGORY_HEADINGS.Where(x => x.Question_Group_Heading_Id == a.Question_Group_Heading_Id && x.Universal_Sub_Category_Id == a.Universal_Sub_Category_Id).FirstOrDefault(); // if (header != null) // { // item.Heading_Pair_Id = header.Heading_Pair_Id; // } // else // { // try // { // var tempHeading = db.UNIVERSAL_SUB_CATEGORIES.Where(x => x.Universal_Sub_Category_Id == a.Universal_Sub_Category_Id).FirstOrDefault(); // if (tempHeading != null) // { // var adding = new UNIVERSAL_SUB_CATEGORY_HEADINGS() // { // Display_Radio_Buttons = false, // Question_Group_Heading_Id = a.Question_Group_Heading_Id, // Universal_Sub_Category_Id = a.Universal_Sub_Category_Id, // Sub_Heading_Question_Description = null // }; // //see if we can create the record // db.UNIVERSAL_SUB_CATEGORY_HEADINGS.Add(adding); // db.SaveChanges(); // item.Heading_Pair_Id = adding.Heading_Pair_Id; // } // } // catch // { // //silent throw away NOT MY FAVORITE // //but ok because there is nothing else we can do here. // } // } // } // if (!String.IsNullOrWhiteSpace(a.Question_Group_Heading) && !String.IsNullOrWhiteSpace(a.Universal_Sub_Category)) // { // var header = db.vQUESTION_HEADINGS.Where(x => x.Question_Group_Heading == a.Question_Group_Heading && x.Universal_Sub_Category == a.Universal_Sub_Category).FirstOrDefault(); // if (header == null) // {//try by id's // var header2 = db.UNIVERSAL_SUB_CATEGORY_HEADINGS.Where(x => x.Question_Group_Heading_Id == a.Question_Group_Heading_Id && x.Universal_Sub_Category_Id == a.Universal_Sub_Category_Id).FirstOrDefault(); // if (header2 != null) // item.Heading_Pair_Id = header2.Heading_Pair_Id; // } // else // { // item.Heading_Pair_Id = header.Heading_Pair_Id; // } // } // if (item.Heading_Pair_Id > 0) // db.SUB_CATEGORY_ANSWERS.Add(item); //} //// //// NCUA data //// //List<int> supportedDocIds = db.REQUIRED_DOCUMENTATION.Select(d => d.Documentation_Id).ToList(); //foreach (var a in model.jASSESSMENTS_REQUIRED_DOCUMENTATION) //{ // if (supportedDocIds.Contains(a.Documentation_Id)) // { // var item = TinyMapper.Map<ASSESSMENTS_REQUIRED_DOCUMENTATION>(a); // item.Assessment_Id = _assessmentId; // db.ASSESSMENTS_REQUIRED_DOCUMENTATION.Add(item); //} //} //foreach (var a in model.jFINANCIAL_ASSESSMENT_VALUES) //{ // var item = TinyMapper.Map<FINANCIAL_ASSESSMENT_VALUES>(a); // item.Assessment_Id = _assessmentId; // db.FINANCIAL_ASSESSMENT_VALUES.Add(item); //} //foreach (var a in model.jFINANCIAL_HOURS) //{ // var item = TinyMapper.Map<FINANCIAL_HOURS>(a); // item.Assessment_Id = _assessmentId; // db.FINANCIAL_HOURS.Add(item); //} //foreach (var a in model.jASSESSMENT_IRP_HEADER) //{ // var item = TinyMapper.Map<ASSESSMENT_IRP_HEADER>(a); // item.ASSESSMENT_ID = _assessmentId; // db.ASSESSMENT_IRP_HEADER.Add(item); //} //foreach (var a in model.jASSESSMENT_IRP) //{ // var item = TinyMapper.Map<ASSESSMENT_IRP>(a); // item.Assessment_Id = _assessmentId; // item.Answer_Id = 0; // db.ASSESSMENT_IRP.Add(item); //} //try //{ // db.SaveChanges(); //} //catch (Exception e) //{ // throw e; //} #endregion }
public AssessmentsController(AssessmentManager manager) { this.manager = manager; }
// Use this for initialization private void Start() { mPlayer = GameObject.Find("Player"); mAssessmentManager = GameObject.Find("Assessment").GetComponent<AssessmentManager>(); }
public bool EmployeeAssessmentStub(string month) { Random random = new Random(); QueryParam queryParam = new QueryParam { pager = new Pager { page = 1, rows = EmployeeStubSize } }; FilterModel filter = new FilterModel { key = "month", value = month }; Dictionary <string, FilterModel> filterSet = new Dictionary <string, FilterModel>(); filterSet.Add(filter.key, filter); queryParam.filters = filterSet; var or = AssessmentManager.GetEmployeesAll(queryParam); if (or.status == OperateStatus.Error) { return(false); } dynamic listAssessment = or.data; foreach (dynamic ass in listAssessment) { AssessmentInfo e = new AssessmentInfo(); PropertyInfo[] pArray = ass.GetType().GetProperties(); Type t = ass.GetType(); e.billSerial = Convert.ToString(t.GetProperty("billSerial").GetValue(ass)); e.billSerial = t.GetProperty("billSerial").GetValue(ass); e.employeeId = t.GetProperty("employeeId").GetValue(ass); e.month = month; e.benefitScore = random.Next(40, 100); e.performanceScore = random.Next(40, 100); e.shouldWorkTime = 22; e.actualWorkTime = 22; or = AssessmentManager.Add(e); if (or.status == OperateStatus.Error) { StackTrace st = new StackTrace(new StackFrame(true)); string msg = $"App Trace >>> in file: {st.GetFrame(0).GetFileName()} " + $"line {st.GetFrame(0).GetFileLineNumber()} message: {or.content}"; Trace.WriteLine(msg); return(false); } } return(true); }