public EntityDTO ProcessCreateNewEntity() { var databaseID = new ProjectTreeHelper().GetFirstAncestorID <DatabaseDTO>(); if (databaseID == Guid.Empty) { throw new InvalidOperationException("No database selected."); } var newEntity = new EntityDTO() { EntityName = "<Enter name>", SchemaName = "dbo", DatabaseID = databaseID }; var view = new EntityDetailsView(); view.Object = newEntity; var popup = new PopupWindow(); popup.Title = "New Entity"; popup.Validate = () => { return(new Validator().Validate(newEntity)); }; popup.ViewPanel.Children.Add(view); if (popup.ShowDialog() != true) { return(null); } new ObjectDataSource().SaveObject(newEntity); ServiceLocator serviceLocator = ServiceLocator.GetActive(); serviceLocator.BasicController.ProcessProjectTreeRefresh(); return(newEntity); }
public void ProcessEditEntity(EntityDTO entity) { if (entity == null) { throw new ArgumentNullException("entity"); } var databaseID = new ProjectTreeHelper().GetFirstAncestorID <DatabaseDTO>(); if (databaseID == Guid.Empty) { throw new InvalidOperationException("No database selected."); } var view = new EntityDetailsView(); view.Object = entity; var popup = new PopupWindow(); popup.Title = "Edit Entity"; popup.Validate = () => { return(new Validator().Validate(entity)); }; popup.ViewPanel.Children.Add(view); if (popup.ShowDialog() == true) { new ObjectDataSource().SaveObject(entity); // Do not refresh node, since can be called from RelationDetailsView } }
private List <RolesAndResponsibilityItem> RolesAndResponsibilities(int id) { List <RolesAndResponsibilityItem> rrs = new List <RolesAndResponsibilityItem>(); EntityData entityData = new EntityData(); List <EntityDTO> rolesAndResponsibilities = entityData.GetRolesAndResponsibilities(id); if (rolesAndResponsibilities.Count > 0) { foreach (EntityDTO dto in rolesAndResponsibilities) { RolesAndResponsibilityItem rr = new RolesAndResponsibilityItem(); dto.ExtractProperties(); EntityDTO descriptionDto = entityData.GetRolesDescription(dto.ID); string description = string.Empty; if (descriptionDto != null) { descriptionDto.ExtractProperties(); description = descriptionDto.RenderHTML(GlobalStringResource.Description, RenderOption.Break); } rr.Role = dto.RenderHTML(GlobalStringResource.Role, RenderOption.None); rr.Responsibilities = description; rrs.Add(rr); } } return(rrs); }
protected override string BuildDiagramDescription(EntityDTO dto) { HtmlTable t = new HtmlTable(2, 0, "grid", new int[] { 15, 85 }); t.AddHeader(" ", 2); t.AddCell(GlobalStringResource.ProcessName); t.AddCell(dto.Name); t.AddCell(GlobalStringResource.Description); t.AddCell(dto.RenderHTML(GlobalStringResource.ProcessDescription, RenderOption.Paragraph)); t.AddCell(GlobalStringResource.Purpose); t.AddCell(dto.RenderHTML(GlobalStringResource.Description, RenderOption.Paragraph)); t.AddCell(GlobalStringResource.Objective); t.AddCell(dto.RenderHTML(GlobalStringResource.ProcessObjective, RenderOption.Paragraph)); t.AddCell(GlobalStringResource.Strategy); t.AddCell(dto.RenderHTML(GlobalStringResource.Strategy, RenderOption.Paragraph)); t.AddCell(GlobalStringResource.DocumentOwners); t.AddCell(dto.RenderHTML(GlobalStringResource.DocumentOwners, RenderOption.Break)); return(t.EndHtmlTable()); }
public void GenerateReport(int id) { EntityDTO dto = entityData.GetOneEntity(id); dto.ExtractProperties(); FileDTO file = filesData.GetFile(dto.DGXFileName); byte[] diagram = file.Data; //Save the raw .wmf file int poolCount = entityData.GetPoolCount(dto.ID); this.imageManager = new WmfImageManager(dto, diagram, dto.DGXFileName, dto.Type, poolCount, true); string resizedDiagram = imageManager.SaveAndResizeImage(diagram, dto.DGXFileName, dto.Type, poolCount, true); string[] images = new string[] { PathResolver.MapPath(resizedDiagram) }; if (poolCount > 1 && dto.Type == 142) { //slice the wmf SubProcessSlicer slicer = new SubProcessSlicer(resizedDiagram); images = slicer.Slice(); } List <PdfContentParameter> contents = ReportBuilder.BuildReport(dto); byte[] pdfBytes = PDFBuilder.CreatePDF(contents, images, dto.Type); this.view.RenderReport(pdfBytes); }
/// <summary> /// Converts a reader to EntityDTO instance. /// </summary> /// Column indexes: /// /// Audit = 0 /// Class = 1 /// FromArrow = 2 /// FromAssc = 3 /// ID = 4 /// Name = 5 /// SeqNum = 6 /// Properties = 7 /// ToArrow = 8 /// ToAssc = 9 /// Type = 10 /// UpdateDate = 11 /// SAGuid = 12 /// PropType = 13 /// ShortProps = 14 /// <param name="reader">The data reader instance.</param> /// <returns>Instance of EntityDTO populated from the reader.</returns> private static EntityDTO ReaderToEntityDTO(IDataReader reader) { EntityDTO dto = new EntityDTO(); dto.Audit = reader.GetString(0); dto.Class = reader.GetInt16(1); dto.FromArrow = reader.GetBoolean(2); dto.FromAssc = reader.GetInt32(3); dto.ID = reader.GetInt32(4); dto.Name = reader.IsDBNull(5) ? string.Empty : reader.GetString(5); dto.SeqNum = reader.GetInt16(6); dto.Properties = reader.IsDBNull(7) ? string.Empty : reader.GetString(7); dto.ToArrow = reader.GetBoolean(8); dto.ToAssc = reader.GetInt32(9); dto.Type = reader.GetInt16(10); dto.UpdateDate = reader.GetDateTime(11); dto.SAGuid = reader.IsDBNull(12) ? string.Empty : reader.GetString(12); dto.PropType = reader.GetInt16(13); dto.ShortProps = reader.IsDBNull(14) ? string.Empty : reader.GetString(14); return(dto); }
public HttpResponseMessage Delete(Guid id) { try { EntityDTO entityDto = Find(id); if (entityDto == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Entidade não encontrada")); } else { bool removed = Remove(id); if (removed) { return(Request.CreateResponse(HttpStatusCode.OK, id)); } } } catch (ApplicationException ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Erro ao excluir entidade")); }
public async Task <EntityDTO> GetEntityByName(string name) { EntityDTO row = null; await _connection.OpenAsync(); try { using (MySqlCommand cmd = new MySqlCommand("Get_EntityByName", _connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("EntityNameVal", name); var dr = cmd.ExecuteReader(); while (dr.Read()) { row = new EntityDTO(); row.EntityId = Convert.ToInt32(dr["ID"]); row.EntityTypeId = Convert.ToInt32(dr["EntityTypeId"]); row.EntityName = dr["Name"].ToString(); row.EntityDescription = dr["Description"].ToString(); } } return(row); } catch { throw; } finally { await _connection.CloseAsync(); } }
public async Task <List <ReadRelationDTO> > GetAllRelations() { var location = HttpContext.Session.GetString("LocationId"); EntityDTO dto = new EntityDTO(); dto.Id = Guid.Parse(location); try { var relations = await _relationService.GetAllRelations(dto); if (relations.Count > 0) { return(relations); } else { return(null); } } catch (Exception e) { throw e; } }
private static void CheckEntityDtoWithItems(TypeModel model, string message) { var entity = new EntityDTO() { Id = 1 }; var healthComponent = new HealthDTO() { CurrentHealth = 100, Owner = entity, Name = "Health", Id = 2 }; entity.Components.Add(healthComponent); var locationComponent = new PhysicalLocationDTO() { X = 1, Y = 2, Owner = entity, Name = "PhysicalLocation", Id = 3 }; entity.Components.Add(locationComponent); MemoryStream memstream2 = new MemoryStream(); model.Serialize(memstream2, entity); memstream2.Seek(0, SeekOrigin.Begin); var result2 = (EntityDTO)model.Deserialize(memstream2, null, typeof(EntityDTO)); Assert.AreEqual(1, result2.Id, message + ":Id"); Assert.AreEqual(2, result2.Components.Count, message + ":Count"); // These two tests are lame and will not be used for long Assert.AreEqual(typeof(HealthDTO), result2.Components.First().GetType(), message + ":First"); Assert.AreEqual(typeof(PhysicalLocationDTO), result2.Components.Last().GetType(), message + ":Last"); }
public void RenderEntity(int id) { EntityDTO dto = data.GetOneEntity(id); dto.ExtractProperties(); ProcessStrategy2 st = new ProcessStrategy2(); PageResponseDTO response = new PageResponseDTO(); response.BreadCrumbContent = BreadcrumbHelper.BuildBreadcrumbContent(dto); response.Header = dto.Name; response.Content = MainContentBuilder.BuildContent(dto); switch (dto.Type) { case 111: response.RenderType = "process"; break; case 142: response.RenderType = "subprocess"; break; case 145: response.RenderType = "st2020"; break; default: break; } this.view.RenderContent(response); }
public void GetAllComments(string diagramId) { List <CommentDTO> comments = this.cData.GetAllCommentsByDiagramID(int.Parse(diagramId)); StringBuilder html = new StringBuilder(); EntityDTO dto = this.eData.GetOneEntity(int.Parse(diagramId)); if (dto != null) { html.AppendFormat("<h3 style='color: #517704;'>{0}</h3>", dto.Name); } foreach (CommentDTO c in comments) { StringBuilder attachmentHtml = new StringBuilder(); if (c.Attachments.Count > 0) { foreach (CommentAttachment ca in c.Attachments) { attachmentHtml.AppendFormat( "<a onclick=\"downloadattachment('{0}');\">{1}</a><b>|</b>", ca.VirtualPath.Replace(@"\", @"\\"), Path.GetFileName(ca.VirtualPath)); } attachmentHtml.Remove(attachmentHtml.Length - 8, 8); } html.AppendFormat("<div class='comment-item'>{0}<div id='attachments'><b>Attachments:</b> {1}</div><br/>by: <b>{2}</b> on <i>{3}</i></div>", c.Comment, attachmentHtml.ToString(), c.Username, c.CommentDate); } this.view.RenderComments(html.ToString()); }
public static string RenderDetailAsLink(this EntityDTO dto) { StringBuilder html = new StringBuilder(); html.Append(string.Format("<a class=\"obvious-link\" onclick=\"RenderEntity('Default.aspx?id={0}&isDetail=1');\">{1}</a>", dto.ID, dto.Name)); return(html.ToString()); }
//TODO: Revisit public static string RenderAsPopupLink(this EntityDTO dto) { StringBuilder html = new StringBuilder(); html.Append(string.Format("<a class=\"obvious-link\" id=\"{3}\" onclick=\"getDetailAjax({0},\'{1}\');\">{2}</a>", dto.ID, PrepareStringForJavascript(dto.Name), dto.Name, dto.ID)); return(html.ToString()); }
public static string RenderAsLink(this EntityDTO dto, int id, string name, RenderOption option) { StringBuilder html = new StringBuilder(); html.Append(string.Format("<a class=\"obvious-link\" href=\"Default.aspx?id={0}\">{1}</a>", id, dto.RenderHTML(name, option))); return(html.ToString()); }
//TODO: Revisit public static string RenderAsLink(this EntityDTO dto, string label, int id, RenderOption option) { StringBuilder html = new StringBuilder(); html.Append(string.Format("<a class=\"obvious-link\" href='Default.aspx?id={0}'>{1}</a>", id, label)); return(html.ToString()); }
public static string RenderAsLink(this EntityDTO dto) { StringBuilder html = new StringBuilder(); html.Append(string.Format("<a class=\"obvious-link\" href=\"Default.aspx?id={0}\">{1}</a>", dto.ID, dto.Name)); return(html.ToString()); }
public static object BuildContent(EntityDTO dto) { MainContentContext context = null; switch (dto.Type) { case 111: context = new MainContentContext(new ProcessStrategy2()); break; case 142: context = new MainContentContext(new SubProcessContentStrategy2()); break; ////case 79: //// context = new ContentContext(new SystemArchitectureContentStrategy()); //// break; case 145: context = new MainContentContext(new Strategy2020ContentStrategy2()); break; default: context = new MainContentContext(new GenericContentStrategy2()); break; } return(context.BuildContent(dto)); }
public async Task <IActionResult> Put(int id, EntityDTO entity) { if (id != entity.Id) { return(BadRequest()); } var _entity = await _context.Entities .Include(p => p.Category) .Include(p => p.Subcategory) .FirstOrDefaultAsync(p => p.Id == id); _entity.Name = entity.Name; _entity.Category = await _context.Categories.FirstOrDefaultAsync(p => p.Id == entity.CategoryId); _entity.Subcategory = await _context.Subcategories.FirstOrDefaultAsync(p => p.Id == entity.SubcategoryId); _entity.Type = entity.Type; _entity.DefaultCost = entity.DefaultCost; _context.Entities.Update(_entity); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Index() { IEnumerable <ReadRelationDTO> relations = null; var location = HttpContext.Session.GetString("LocationId"); EntityDTO dto = new EntityDTO { Id = Guid.Parse(location) }; try { relations = await _relationService.GetAllRelations(dto); } catch (Exception e) { throw e; } if (relations != null) { return(View(relations)); } else { return(View()); } }
public static string RenderDetailAsLink(this EntityDTO dto, string name, RenderOption option) { StringBuilder html = new StringBuilder(); html.Append(string.Format("<a class=\"obvious-link\" onclick=\"getDetailAjax({0},'{1}');\">{2}</a>", dto.ID, dto.RenderHTML(name, option), dto.RenderHTML(name, option))); return(html.ToString()); }
/// <summary> /// This method creates the first and starting point Data object /// </summary> /// <param name="id"></param> /// <param name="subItems"></param> /// <returns></returns> private EndToEndDTO CreateMainDTO(int id, List <EntityDTO> subItems) { //Get the actual sub process EntityDTO actualSubProcess = eData.GetOneEntity(id); EndToEndDTO ee = new EndToEndDTO(); //assign the AssociatedEventDTO ee.AssociatedEventDTO = actualSubProcess; ee.SubItems = new List <EndToEndDTO>(); //WHY DO THIS??? ancestors.Add(actualSubProcess); //Add all the sub items to the //subitems in the EndToEndDTO instance foreach (var item in subItems) { ee.SubItems.Add(new EndToEndDTO() { AssociatedEventDTO = item, FromDiagramDTO = null, ToDiagramDTO = null }); } //Sort items ee.SubItems.Sort((x, y) => x.AssociatedEventDTO.Name.CompareTo(y.AssociatedEventDTO.Name)); return(ee); }
public async Task <IActionResult> Post(EntityDTO entity) { var datatoSave = _mapper.Map <StageActions>(entity); var data = await _StageActionsService.Save(datatoSave); return(Ok(data)); }
public async Task <IActionResult> SaveEntity(EntityDTO entity) { //var entitySaver = new EntitySaverService(); await entitySaverService.SaveEntity(entity); return(Ok()); }
protected override string BuildDiagramImage(EntityDTO dto) { StringBuilder html = new StringBuilder(); EntityData data = new EntityData(); FileData files = new FileData(); FileDTO file = files.GetFile(dto.DGXFileName); byte[] imageBytes = file.Data; string path = string.Format("{0}_{1}", file.Date.ToFileTime().ToString(), dto.DGXFileName); int poolCount = data.GetPoolCount(dto.ID); WmfImageManager imageManager = new WmfImageManager(dto, imageBytes, path, dto.Type, poolCount, false); path = imageManager.ProcessImage(); html.Append("<div id=\"diagram-line\" class=\"clearfix\">"); html.Append("<div id=\"diagram-line-left\" class=\"infoBox\">To navigate to the related process and sub-process of this diagram, use the menu on the right.<br/>To navigate related informations, select the tabs above.</div>"); if (dto.Type == 111) { html.Append(BuildQuickLinks(dto)); } html.Append("<div style=\"clear: both;\"></div>"); html.Append("</div>"); html.AppendFormat(GlobalStringResource.Presenter_BuildDiagramImage_Tag, path.Replace(@"\", @"/")); html.Append(GlobalStringResource.BreakTag); return(html.ToString()); }
private Phrase CreateBusinessRulesRequiredData(string businessRuleKey) { if (string.IsNullOrEmpty(businessRuleKey)) { return(new Phrase(new Chunk(string.Empty))); } string[] keys = businessRuleKey.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); EntityData data = new EntityData(); StringBuilder html = new StringBuilder(); foreach (string key in keys) { EntityDTO dto = entityData.GetOneEntity(key.Trim()); if (dto != null) { dto.ExtractProperties(); html.AppendFormat("{0}{1}{2}", key, Environment.NewLine, dto.RenderHTML(GlobalStringResource.Description, RenderOption.NewLine)); } } return(new Phrase(new Chunk(html.ToString(), FontFactory.GetFont(GlobalStringResource.Font_Arial, 10)))); }
protected virtual string BuildRolesAndResponsibilities(int id) { string result = string.Empty; EntityData entityData = new EntityData(); List <EntityDTO> rolesAndResponsibilities = entityData.GetRolesAndResponsibilities(id); if (rolesAndResponsibilities.Count > 0) { HtmlTable t = new HtmlTable(2, 0, "grid", new int[] { 20, 80 }); t.AddHeader(GlobalStringResource.Role); t.AddHeader(GlobalStringResource.Responsibilities); foreach (EntityDTO dto in rolesAndResponsibilities) { dto.ExtractProperties(); EntityDTO descriptionDto = entityData.GetRolesDescription(dto.ID); string description = string.Empty; if (descriptionDto != null) { descriptionDto.ExtractProperties(); description = descriptionDto.RenderHTML(GlobalStringResource.Description, RenderOption.Break); } t.AddCell(dto.RenderHTML(GlobalStringResource.Role, RenderOption.None));//(Resources.Role, RenderOption.Paragraph)); t.AddCell(description); } result = t.EndHtmlTable(); } return(result); }
public static Entity ToDomain(EntityDTO entity) { return(new Entity() { UserId = entity.UserId, EntityId = entity.Id, IsApproved = entity.IsApproved, EntityName = entity.EntityName, EntityResponsableName = entity.EntityResponsableName, Email = entity.Email, EntityPhone = entity.EntityPhone, Password = entity.Password, EntityReferencePoint = entity.EntityReferencePoint, EntityAffinity = AffinityAdapter.ListToDomain(entity.EntityAffinity), EntityInitials = entity.EntityInitials, EntityCreationDate = entity.EntityCreationDate, EntitySocialNetwork = entity.EntitySocialNetwork, EntityWebSite = entity.EntityWebSite, EntityDescription = entity.EntityDescription, EntityAddress = new Address() { AddressId = entity.EntityAddress.AddressId, CEP = entity.EntityAddress.CEP, Avenue = entity.EntityAddress.Avenue, Number = entity.EntityAddress.Number, Neighborhood = entity.EntityAddress.Neighborhood, City = entity.EntityAddress.City, State = entity.EntityAddress.State } }); }
public async Task <List <EntityDTO> > SearchEntity(string name) { List <EntityDTO> dt = new List <EntityDTO>(); await _connection.OpenAsync(); try { using (MySqlCommand cmd = new MySqlCommand("Search_Entity", _connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("EntityNameVal", "%" + name + "%"); var dr = cmd.ExecuteReader(); while (dr.Read()) { var row = new EntityDTO(); row.EntityId = Convert.ToInt32(dr["ID"]); row.EntityTypeId = Convert.ToInt32(dr["EntityTypeId"]); row.EntityName = dr["Name"].ToString(); row.EntityDescription = dr["Description"].ToString(); dt.Add(row); } } return(dt); } catch { throw; } finally { await _connection.CloseAsync(); } }
public static bool IsValidForShow(int type, int id) { bool result = false; EntityData data = new EntityData(); MenuFilterSection menuFilter = MenuFilterSection.GetConfig(); List <GroupMenuFilter> groupFilters = menuFilter.GetGroupMenuFilters(); if (groupFilters.FirstOrDefault(y => y.TargetType == type) != null) { GroupMenuFilter filter = groupFilters.FirstOrDefault(y => y.TargetType == type); EntityDTO dto = data.GetOneEntity(id); if (dto != null) { dto.ExtractProperties(); string category = dto.RenderHTML(filter.PropertyName, RenderOption.None); if (category == filter.PropertyValue) { result = true; } } } else { result = true; } return(result); }
private static void CheckEntityDtoWithItems(TypeModel model, string message) { var entity = new EntityDTO() { Id = 1 }; var healthComponent = new HealthDTO() { CurrentHealth = 100, Owner = entity, Name = "Health", Id = 2 }; entity.Components.Add(healthComponent); var locationComponent = new PhysicalLocationDTO() { X = 1, Y = 2, Owner = entity, Name = "PhysicalLocation", Id = 3 }; entity.Components.Add(locationComponent); MemoryStream memstream2 = new MemoryStream(); model.Serialize(memstream2, entity); memstream2.Seek(0, SeekOrigin.Begin); var result2 = (EntityDTO)model.Deserialize(memstream2, null, typeof(EntityDTO)); Assert.AreEqual(1, result2.Id, message + ":Id"); Assert.AreEqual(2, result2.Components.Count, message + ":Count"); // These two tests are lame and will not be used for long Assert.AreEqual(typeof(HealthDTO), result2.Components.First().GetType(), message + ":First"); Assert.AreEqual(typeof(PhysicalLocationDTO), result2.Components.Last().GetType(), message + ":Last"); }