//Reflow Temperature Setup ------------------------------------------------------------------------------------ private void InitTable(DataTable dt, string Type, ColumnTitle Title) { if (dt.Columns.Count > 0) { return; } for (int col = 0; col < 13; col++) { if (col == 0) { var column = dt.Columns.Add($"Reflow{Type}{col}", typeof(string)); column.Caption = Title.GetEnumDescription(); column.DataType = typeof(string); } else { var column = dt.Columns.Add($"Reflow{Type}{col}", typeof(decimal)); column.Caption = col.ToString(); } } for (int row = 0; row < 7; row++) { var nowrow = dt.Rows.Add(); nowrow[0] = ColumnFixedName_CHS[row]; } }
private List <ColumnTitle> GetColumnTitle(Type entityType, params string[] notExportCol) { var coltitle = new List <ColumnTitle>(); var Properties = entityType.GetProperties().Where(p => p.SetMethod.Attributes == (MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName)).ToList(); foreach (var prop in Properties) { if (!notExportCol.Any(p => p == prop.Name)) { var attr = (DisplayAttribute)entityType.GetProperty(prop.Name).GetCustomAttributes(typeof(DisplayAttribute), true).SingleOrDefault(); if (attr == null) { MetadataTypeAttribute metadataType = (MetadataTypeAttribute)entityType.GetCustomAttributes(typeof(MetadataTypeAttribute), true).FirstOrDefault(); if (metadataType != null) { var property = metadataType.MetadataClassType.GetProperty(prop.Name); if (property != null) { attr = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), true).SingleOrDefault(); } } } var column = new ColumnTitle(); if (attr == null) { column = new ColumnTitle() { Name = prop.Name, DisplayName = prop.Name }; coltitle.Add(column); } else if (!notExportCol.Any(p => p == attr.Name)) { column = new ColumnTitle() { Name = prop.Name, DisplayName = attr.GetName(), ShortName = attr.GetShortName(), Description = attr.GetDescription(), GroupName = attr.GetGroupName(), Prompt = attr.GetPrompt(), Order = attr.GetOrder() }; coltitle.Add(column); } } } if (coltitle.Any(p => p.Order == null)) { return(coltitle); } else { return(coltitle.OrderBy(p => p.Order).ToList()); } }
public void Remove(ColumnTitle title) { if (Context.Entry(title).State == EntityState.Detached) { context.ColumnTitles.Attach(title); } context.ColumnTitles.Remove(title); }
public void Add(ColumnTitle columnTitle) { context.ColumnTitles.Add(columnTitle); }
public DbEntityEntry <ColumnTitle> Entry(ColumnTitle columnTitle) { return(Context.Entry(columnTitle)); }
public void Attach(ColumnTitle columnTitle) { context.ColumnTitles.Attach(columnTitle); }
public ActionResult CreateFlexColumns(IEnumerable <FlexColumnsViewModel> models, int pageId, IEnumerable <OptionsViewModel> options) { var result = new List <FlexColumn>(); var datasource = new DataSource <FlexColumnsViewModel>(); datasource.Data = models; datasource.Total = models.Count(); var page = _hrUnitOfWork.Repository <PageDiv>().Where(a => a.Id == pageId).Select(a => new { a.ObjectName, a.Version, a.TableName }).FirstOrDefault(); var titles = _hrUnitOfWork.Repository <ColumnTitle>().Where(a => a.CompanyId == CompanyId && a.Culture == Language && a.ObjectName == page.ObjectName && a.Version == page.Version).ToList(); if (ModelState.IsValid) { if (ServerValidationEnabled) { var errors = _hrUnitOfWork.MenuRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "FlexColumns", Columns = Models.Utils.GetModifiedRows(ModelState), ParentColumn = "PageId", Culture = Language, TableName = page.TableName }); if (errors.Count() > 0) { datasource.Errors = errors; return(Json(datasource)); } } for (var i = 0; i < models.Count(); i++) { { var model = models.ElementAtOrDefault(i); var title = titles.FirstOrDefault(a => a.ColumnName == model.ColumnName); var flexCol = new FlexColumn(); AutoMapper(new Models.AutoMapperParm { Destination = flexCol, Source = model, ObjectName = "FlexColumns", Transtype = TransType.Insert, Options = options.ElementAtOrDefault(i) }); if (title == null) { title = new ColumnTitle { ColumnName = model.ColumnName, Culture = Language, Version = page.Version, ObjectName = page.ObjectName, Title = model.Title, CompanyId = CompanyId }; _hrUnitOfWork.PageEditorRepository.Add(title); } flexCol.PageId = pageId; flexCol.TableName = page.TableName; result.Add(flexCol); _hrUnitOfWork.PageEditorRepository.Add(flexCol); } datasource.Errors = SaveChanges(Language); } } else { datasource.Errors = Models.Utils.ParseErrors(ModelState.Values); } datasource.Data = (from m in models join r in result on m.ColumnName equals r.ColumnName select new FlexColumnsViewModel { Id = r.Id, CodeName = m.CodeName, ColumnOrder = m.ColumnOrder, isVisible = m.isVisible, Max = m.Max, Min = m.Min, InputType = m.InputType, Pattern = m.Pattern, PlaceHolder = m.PlaceHolder, Title = m.Title, Required = m.Required, UniqueColumns = m.UniqueColumns, IsUnique = m.IsUnique, ColumnName = m.ColumnName, PageId = pageId, TableName = page.TableName }).ToList(); if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json(datasource.Data)); } }
public ActionResult UpdateFlexColumns(IEnumerable <FlexColumnsViewModel> models, int pageId, IEnumerable <OptionsViewModel> options) { var datasource = new DataSource <FlexColumnsViewModel>(); datasource.Data = models; datasource.Total = models.Count(); var page = _hrUnitOfWork.Repository <PageDiv>().Where(a => a.Id == pageId).Select(a => new { a.ObjectName, a.Version, a.TableName }).FirstOrDefault(); var titles = _hrUnitOfWork.Repository <ColumnTitle>().Where(a => a.CompanyId == CompanyId && a.Culture == Language && a.ObjectName == page.ObjectName && a.Version == page.Version).ToList(); if (ModelState.IsValid) { if (ServerValidationEnabled) { var errors = _hrUnitOfWork.PageEditorRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "FlexColumns", Columns = Models.Utils.GetModifiedRows(ModelState.Where(a => a.Key.Contains("models"))), ParentColumn = "PageId", Culture = Language, TableName = page.TableName }); if (errors.Count() > 0) { datasource.Errors = errors; return(Json(datasource)); } } var ids = models.Select(a => a.Id); var db_flexcolumns = _hrUnitOfWork.Repository <FlexColumn>().Where(a => ids.Contains(a.Id)).ToList(); for (var i = 0; i < models.Count(); i++) { var model = models.ElementAtOrDefault(i); var title = titles.FirstOrDefault(a => a.ColumnName == model.ColumnName); var flexCol = db_flexcolumns.FirstOrDefault(a => a.Id == model.Id); AutoMapper(new AutoMapperParm() { ObjectName = "FlexColumns", Destination = flexCol, Source = model, Version = 0, Options = options.ElementAtOrDefault(i), Transtype = TransType.Update }); flexCol.TableName = page.TableName; if (title != null) { title.ColumnName = model.ColumnName; title.Title = model.Title; title.ObjectName = page.ObjectName; title.Culture = Language; title.Version = page.Version; title.CompanyId = CompanyId; _hrUnitOfWork.PageEditorRepository.Attach(title); _hrUnitOfWork.PageEditorRepository.Entry(title).State = EntityState.Modified; } else { title = new ColumnTitle { ColumnName = model.ColumnName, Culture = Language, Version = page.Version, ObjectName = page.ObjectName, Title = model.Title, CompanyId = CompanyId }; _hrUnitOfWork.PageEditorRepository.Add(title); } //_hrUnitOfWork.PageEditorRepository.Attach(flexCol); //_hrUnitOfWork.PageEditorRepository.Entry(flexCol).State = EntityState.Modified; } datasource.Errors = SaveChanges(Language); } else { datasource.Errors = Models.Utils.ParseErrors(ModelState.Values); } if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json(datasource.Data)); } }