public bool Export(DomainDef domain, string path = null) { this.domain = domain; this.path = path ?? this.path; return(Export()); }
public bool Check() { try { if (dataSet != null) { DomainDef domain = standardDef.DomainContainer.Find(x => x.Code == dataSet.DataSetName); foreach (DataTable table in dataSet.Tables) { DGObjectDef objectDef = domain.DGObjectContainer.Find(x => x.LangStr == table.TableName); CheckRows(table, objectDef); } } else if (dataTable != null) { DGObjectDef objectDef = standardDef.GetDGObjectDefByName(dataTable.TableName); CheckRows(dataTable, objectDef); } return(true); } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); return(false); } }
public DataSet Import(string path, StandardDef standard) { try { string domainName = Path.GetFileNameWithoutExtension(path); DomainDef domain = standard.DomainContainer.Find(x => x.Code == domainName | x.LangStr == domainName); DataSet ds = new DataSet(domainName); IWorkbook wb = ReadWorkbook(path); List <string> sheetNames = GetSheetNames(wb); //sheetNames equal to objectName foreach (string sheetName in sheetNames) { DGObjectDef objectDef = standard.GetDGObjectDefByName(sheetName); DataTable dt = ReadSheet(wb.GetSheet(sheetName), objectDef); if (dt != null) { ds.Tables.Add(dt); } } return(ds); } catch (Exception) { System.Windows.MessageBox.Show("Check if the Standard adapt to data"); return(null); } }
public DataSet Import(string path, DataStandardDef standard) { try { string domainName = Path.GetFileNameWithoutExtension(path); DomainDef domain = standard.DomainContainer.Find(x => x.Code == domainName); DataSet ds = new DataSet(domainName); IWorkbook wb = ReadWorkbook(path); List <string> sheetNames = GetSheetNames(wb); //sheetNames equal to objectName foreach (string sheetName in sheetNames) { DGObjectDef objectDef = domain.DGObjectContainer.Find(x => x.Code == sheetName); DataTable dt = ReadSheet(wb.GetSheet(sheetName), objectDef); ds.Tables.Add(dt); } return(ds); } catch (Exception) { return(null); } }
public void GenerateClass(DomainDef domain) { try { foreach (DGObjectDef dGObject in domain.DGObjectContainer) { string newClass = "using System; \n namespace iS3_DataManager.ObjectModels\n { \n \tpublic class " + dGObject.Code + "\n \t{ \n"; foreach (PropertyMeta meta in dGObject.PropertyContainer) { if (meta.DataType != "string") { newClass += "\t\tpublic Nullable<" + meta.DataType + "> " + meta.PropertyName + " {get;set;}\n"; } else { newClass += "\t\tpublic " + meta.DataType + " " + meta.PropertyName + " {get;set;}\n"; } } newClass += "\t}\n}"; string path = AppDomain.CurrentDomain.BaseDirectory + @"..\..\ObjectModels\" + dGObject.Code + ".cs"; FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Write(newClass); sw.Flush(); sw.Close(); fs.Close(); } } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString()); } }
public void Data2DB(DataSet dataSet, DataStandardDef standardDef) { try { string domainName = dataSet.DataSetName; DomainDef domain = standardDef.DomainContainer.Find(x => x.Code == domainName); if (domain != null) { // get current assembly(程序集) //Assembly assembly = Assembly.GetExecutingAssembly(); //create Entity for specific domain //dynamic db = assembly.CreateInstance("iS3_DataManager.DataManager." + domainName + "DB_EF"); GeologyDB_EF db = new GeologyDB_EF(); foreach (DataTable table in dataSet.Tables) { DGObjectDef objectDef = domain.DGObjectContainer.Find(x => x.Code == table.TableName); Insert(db, objectDef, table); } } System.Windows.MessageBox.Show("数据导入成功"); } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); } }
/// <summary> /// just for test /// </summary> /// <returns></returns> public DataStandardDef GetSample() { //定义隧道数据标准和地质域 DataStandardDef dsDef = new DataStandardDef() { Code = "TunnelStandard", Description = "This a Tunnel DataStandard", }; DomainDef ddDef = new DomainDef() { Code = "Geology", Desciption = "This a Geology Domain", }; dsDef.DomainContainer.Add(ddDef); //定义地质域内的数据结构 DGObjectDef dgDef = new DGObjectDef() { Code = "Borehole", Desctiption = "This a Borehole DGObject" }; ddDef.DGObjectContainer.Add(dgDef); //定义钻孔中的属性内容 dgDef.PropertyContainer.Add(new PropertyMeta("ID", "Int", null, "这是编号字段", "['zh':'编号','en':'ID']", IsKey: true, regularExpression: @"\d")); dgDef.PropertyContainer.Add(new PropertyMeta("BoreholeID", "string", null, "这是钻孔编号", "['zh':'钻孔编号','en':'BoreholeID']", true, regularExpression: @"")); dgDef.PropertyContainer.Add(new PropertyMeta("BoreholeTime", "dateTime", null, "这是钻孔时间", "['zh':'钻孔时间','en':'BoreholeTime']", true)); dgDef.PropertyContainer.Add(new PropertyMeta("BoreholeDepth", "double", "m", "这是钻孔深度", "['zh':'钻孔深度','en':'BoreholeDepth']", true)); return(dsDef); }
/// <param name="domain"></param> public void GenerateClass(DomainDef domain) { //try //{ Dictionary <string, string> Types = new DataType().Gettype; foreach (DGObjectDef dGObject in domain.DGObjectContainer) { string newClass = "using System; \nusing System.ComponentModel.DataAnnotations.Schema;\n"; newClass += "using iS3.Core.Model;\n"; newClass += "\nnamespace " + "iS3." + standard.Code + ".Model\n { \n \t"; newClass += "///<summary>///" + (dGObject.LangStr ?? dGObject.Code) + "///</summary>\n"; newClass += "\t[Table(\"" + standard.Code + "_" + dGObject.Code + "\")]\n"; newClass += "\tpublic class " + dGObject.Code + ":DGObject\n \t{ \n"; foreach (PropertyMeta meta in dGObject.PropertyContainer) { newClass += "\t\t/// <summary>\n\t\t///" + meta.LangStr + " \n\t\t///</summary>\n"; if (meta.Nullable == false) { if (Types[meta.DataType] != "string") { newClass += "\t\tpublic " + Types[meta.DataType] + " " + meta.PropertyName + " {get;set;}\n"; } else { newClass += "\t\tpublic " + Types[meta.DataType] + " " + meta.PropertyName + " {get;set;}\n"; } } else { if (Types[meta.DataType] != "string") { newClass += "\t\tpublic Nullable<" + Types[meta.DataType] + "> " + meta.PropertyName + " {get;set;}\n"; } else { newClass += "\t\tpublic " + Types[meta.DataType] + " " + meta.PropertyName + " {get;set;}\n"; } } } newClass += "\t}\n}"; string path = AppDomain.CurrentDomain.BaseDirectory + @"..\..\ObjectModels\" + dGObject.Code + ".cs"; FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Write(newClass); sw.Flush(); sw.Close(); fs.Close(); } System.Windows.MessageBox.Show("Gengerated Successfully!"); //} // catch (Exception e) // { // System.Windows.MessageBox.Show(e.ToString()); // } }
bool write2Exl(DomainDef domain, IWorkbook workbook) { foreach (DGObjectDef item in domain.DGObjectContainer) { ISheet sheet = workbook.CreateSheet(item.Code); writeDescription(sheet, item); wrtieTitle(sheet, item); } return(true); }
public bool Export(DomainDef domain, string path = null) { this.domain = domain; if (path != null) { this.path = path; } return(Export()); }
private void Filter2Standard(Category category, ref StandardDef standardDef, StandardDef dataStandard) { DomainDef domain = new DomainDef() { Code = category.CategoryName, LangStr = category.LangStr }; foreach (string obj in category.objList) { DGObjectDef objectDef = dataStandard.GetDGObjectDefByCode(obj); domain.DGObjectContainer.Add(objectDef); } standardDef.DomainContainer.Add(domain); }
/// <summary> /// generate template for only one DGobject /// </summary> void GenerateSingleTemplate(TreeNode treeNode) { try { DomainDef domain = new DomainDef() { Code = treeNode.Context, LangStr = treeNode.Context }; DGObjectDef dG = Standard.GetDGObjectDefByName(treeNode.Context); domain.DGObjectContainer.Add(dG); new TemplateGenerator_Excel().Export(domain); } catch (Exception) { throw; } }
bool write2Exl(DomainDef domain, IWorkbook workbook) { foreach (DGObjectDef item in domain.DGObjectContainer) { HSSFCellStyle cellStyle1 = (HSSFCellStyle)workbook.CreateCellStyle(); HSSFCellStyle cellStyle2 = (HSSFCellStyle)workbook.CreateCellStyle(); cellStyle1.FillForegroundColor = HSSFColor.SkyBlue.Index; cellStyle1.FillPattern = FillPattern.SolidForeground; cellStyle1.FillBackgroundColor = HSSFColor.Yellow.Index; cellStyle1.FillPattern = FillPattern.SolidForeground; cellStyle2 = cellStyle1; ISheet sheet = workbook.CreateSheet(item.LangStr ?? item.Code); writeDescription(sheet, item); wrtieTitle(sheet, item, cellStyle1, cellStyle2); } return(true); }
/// <summary> /// export standard to excel for data input /// </summary> /// <param name="standard"></param> /// <param name="path">the path where excel will generate at</param> /// <returns></returns> public bool Export(StandardDef standard, string path = null) { this.standard = standard; this.path = path ?? this.path; try { foreach (DomainDef domain in standard.DomainContainer) { this.domain = domain; Export(); } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); return(false); } return(true); }
public bool Export(DomainDef domain, string path = null) { this.domain = domain; if (path != null) { this.path = path; } bool succeed = Export(); if (succeed) { System.Windows.MessageBox.Show("The Exl templete generated successfully at Destop!"); } else { System.Windows.MessageBox.Show("Someting getting wrong during generating,Please try again!"); } return(succeed); }
void GenerateTempleteForOther(TreeNode treeNode) { try { DomainDef domain = new DomainDef() { Code = Standard.DomainContainer.Find(x => x.LangStr == treeNode.Context).Code, LangStr = treeNode.Context }; foreach (var item in treeNode.ChildNodes) { DGObjectDef dG = Standard.GetDGObjectDefByName(item.Context); domain.DGObjectContainer.Add(dG); } new TemplateGenerator_Excel().Export(domain); } catch (Exception) { throw; } }
/// <summary> /// generate template for one category /// </summary> /// <param name="selectedNode"></param> void GenerateCategoryTemplate(TreeNode selectedNode) { try { DomainDef domain = new DomainDef() { Code = Standard.Code, LangStr = selectedNode.Context }; foreach (TreeNode childNode in selectedNode.ChildNodes) { DGObjectDef dG = Standard.GetDGObjectDefByName(childNode.Context); domain.DGObjectContainer.Add(dG); } new TemplateGenerator_Excel().Export(domain); } catch (Exception a) { MessageBox.Show(a.Message); } }
public void Data2DB(DataSet ds, DataStandardDef standardDef) { try { string domainName = ds.DataSetName; DomainDef domain = standardDef.DomainContainer.Find(x => x.Code == domainName); if (domain != null) { foreach (DataTable table in ds.Tables) { DGObjectDef objectDef = domain.DGObjectContainer.Find(x => x.Code == table.TableName); Insert(objectDef, table); } System.Windows.MessageBox.Show("数据导入成功"); } } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString()); } }
void GenerateStageTemplate(TreeNode treeNode) { try { DomainDef domain = new DomainDef() { Code = "Geology", LangStr = treeNode.Context }; foreach (var item in treeNode.ChildNodes) { foreach (var obj in item.ChildNodes) { DGObjectDef dG = Standard.GetDGObjectDefByName(obj.Context); domain.DGObjectContainer.Add(dG); } } new TemplateGenerator_Excel().Export(domain); } catch (Exception) { throw; } }
bool write2Exl(DomainDef domain, IWorkbook workbook) { foreach (DGObjectDef objectDef in domain.DGObjectContainer) { XSSFCellStyle cellStyle1 = (XSSFCellStyle)workbook.CreateCellStyle(); XSSFCellStyle cellStyle2 = (XSSFCellStyle)workbook.CreateCellStyle(); XSSFColor color1 = new XSSFColor(); XSSFColor color2 = new XSSFColor(); //根据自己需要设置RGB byte[] colorRgb1 = { (byte)214, (byte)220, (byte)228 }; byte[] colorRgb2 = { (byte)221, (byte)235, (byte)247 }; color1.SetRgb(colorRgb1); color2.SetRgb(colorRgb2); cellStyle1.FillForegroundColorColor = color1; cellStyle1.FillPattern = FillPattern.SolidForeground; cellStyle2.FillBackgroundColorColor = color2; cellStyle2.FillPattern = FillPattern.SolidForeground; string sheetName = objectDef.LangStr ?? objectDef.Code; ISheet sheet = workbook.CreateSheet(sheetName); writeDescription(sheet, objectDef); wrtieTitle(sheet, objectDef, cellStyle1, cellStyle2); } return(true); }
public void Row2Object(IRow row) { try { string domainName = row.GetCell(0).ToString(); string domainDes = row.GetCell(1)?.ToString(); string domainlangStr = row.GetCell(2)?.ToString(); string objectName = row.GetCell(3)?.ToString(); string objDescrip = row.GetCell(4)?.ToString(); string objLangStr = row.GetCell(5)?.ToString(); string propertyName = row.GetCell(6).ToString(); bool IsKey = row.GetCell(7)?.ToString() == null ? false : row.GetCell(7).ToString() == "TRUE"; string dataType = row.GetCell(8)?.ToString(); bool Nullable = row.GetCell(9)?.ToString() == null ? true : row.GetCell(9).ToString() != "FALSE"; string unit = row.GetCell(10)?.ToString(); string regularExp = row.GetCell(11)?.ToString(); string proDes = row.GetCell(12)?.ToString(); string proLanStr = row.GetCell(13)?.ToString(); DomainDef domain = null; DGObjectDef objectDef = null; PropertyMeta property = new PropertyMeta { PropertyName = propertyName, IsKey = IsKey, Nullable = Nullable, DataType = dataType, Unit = unit, Description = proDes, RegularExp = regularExp }; if (this.standardDef.DomainContainer.Exists(x => x.Code == domainName)) { domain = this.standardDef.DomainContainer.Find(x => x.Code == domainName); if (domain.DGObjectContainer.Exists(x => x.Code == objectName)) { objectDef = domain.DGObjectContainer.Find(x => x.Code == objectName); if (!objectDef.PropertyContainer.Exists(x => x.PropertyName == property.PropertyName)) { objectDef.PropertyContainer.Add(property); } } else { objectDef = new DGObjectDef { Code = objectName, Desctiption = objDescrip, LangStr = objLangStr }; objectDef.PropertyContainer.Add(property); domain.DGObjectContainer.Add(objectDef); } } else { domain = new DomainDef { Code = domainName, Desciption = domainDes, LangStr = domainlangStr }; objectDef = new DGObjectDef { Code = objectName, Desctiption = objDescrip, LangStr = objLangStr }; objectDef.PropertyContainer.Add(property); domain.DGObjectContainer.Add(objectDef); this.standardDef.DomainContainer.Add(domain); } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); } }
public bool Export(DomainDef domain, string path = null) { throw new NotImplementedException(); }