public override bool SaveAddNew() { TablesInfo info = new TablesInfo(); SetInfo(info); try { #region 新增数据 XmlHelper xmltableshelper = new XmlHelper(@"XML\entity.xml"); // <name>{0}</name><chineseName>{1}</chineseName><functionId>{2}</functionId><path>{3}</path> xmltableshelper.InsertElement("datatype/dataitem", "item", "gid", info.Gid, string.Format(tablesModel, info.Name, info.ChineseName, info.FunctionId, info.BasicdataPath)); xmltableshelper.Save(); // 新增表名.entity文件 FileUtil.AppendText(string.Format(@"XML\{0}.entity", info.Name), string.Format(tablesDetailModel, System.Guid.NewGuid(), info.FunctionId, info.Name, info.ChineseName, string.Empty, "1.0.0.0", string.Empty, string.Empty, DateTimeHelper.GetServerDateTime(), string.Empty), Encoding.UTF8); strItemName = info.Name; intFunction = info.FunctionId; strChineseName = info.ChineseName; // TODO //Id = info.GUID; return(true); #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemName)); MessageDxUtil.ShowError(ex.Message); } return(false); }
public override bool SaveAddNew() { TablesInfo info = new TablesInfo(); SetInfo(info); try { #region 新增数据 XmlHelper xmltableshelper = new XmlHelper(@"XML\tables.xml"); xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/basicdatapath", info.Gid), info.BasicdataPath); xmltableshelper.Save(); if (FileUtil.FileIsExist(info.BasicdataPath)) { FileUtil.DeleteFile(info.BasicdataPath); } string tablesdataDetailModel = "<?xml version=\"1.0\" encoding=\"utf-8\"?><datatype><dataitem></dataitem></datatype>"; FileUtil.AppendText(info.BasicdataPath, tablesdataDetailModel, System.Text.Encoding.UTF8); //ID = info.GUID; strItemName = cbbItemName.SelectedText; return(true); #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditBasicDataItemName)); MessageDxUtil.ShowError(ex.Message); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="SQliteExport"/> class. /// </summary> /// <param name="fileLocation">The location of the export file.</param> public SQliteExport(string fileLocation) { this.ExportFileLocation = fileLocation; this.TblInfo = new(); this.AllTblInfo = new(); this.CsvSeparator = ";"; // TODO make optional }
public CodeCompileUnit Build() { CodeCompileUnit compileUnit = new CodeCompileUnit(); CodeNamespace nsModels = new CodeNamespace("InfoBridge.SuperLinq.Core.Models"); nsModels.Imports.Add(new CodeNamespaceImport("System")); nsModels.Imports.Add(new CodeNamespaceImport("InfoBridge.SuperLinq.Core.ModelBase")); nsModels.Imports.Add(new CodeNamespaceImport("InfoBridge.SuperLinq.Core.Attributes")); compileUnit.Namespaces.Add(nsModels); for (int tableNumber = 0; tableNumber < 500; tableNumber++) { TableInfo ti = TablesInfo.GetTableInfo(tableNumber); if (ti != null) { if (IsExcluded(ti.DbName) || ti.Definition.Kind != TableKind.System) { continue; } CodeTypeDeclaration clss = new CodeTypeDeclaration(FormatName(ti.DbName)); clss.BaseTypes.Add(GetBaseType(ti)); var tableAttr = new CodeAttributeDeclaration { Name = nameof(Core.Attributes.TableInfo) }; tableAttr.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(ti.DbName))); clss.CustomAttributes.Add(tableAttr); nsModels.Types.Add(clss); foreach (FieldInfo fi in ti.All) { //filter out cs extra fields, fetching Definition to look at IsEjournalExtraField throws exceptions on some tables if (fi.Name.StartsWith("x_")) { continue; } string name = fi.Name; //we cannot have a class and propery with the same name if (name.ToLower() == ti.DbName.ToLower()) { name = name + "_"; } AddProperty(clss, name, GetDbName(fi), ConvertType(fi, fi.DataType)); if (GetPrimaryKeyField(ti) == fi.Name) { AddProperty(clss, "PK", GetDbName(fi), typeof(int)); } } } } return(compileUnit); }
public override bool SaveAddNew() { TablesInfo info = new TablesInfo(); SetInfo(info); try { #region 新增数据 // 获取数据库数据类型 XmlHelper xmlprojhelper = new XmlHelper(@"XML\project.xml"); XmlNodeList xmlprejectNodeLst = xmlprojhelper.Read("datatype"); if (xmlprejectNodeLst.Count == 0) { return(false); } XmlNode xn1project = xmlprejectNodeLst[0]; // 将节点转换为元素,便于得到节点的属性值 XmlElement xeproject = (XmlElement)xn1project; // 得到DataTypeInfo节点的所有子节点 XmlNodeList xnl0project = xeproject.ChildNodes; string DbType = xnl0project.Item(4).InnerText; XmlHelper xmltableshelper = new XmlHelper(@"XML\tables.xml"); xmltableshelper.InsertElement("datatype/dataitem", "item", "guid", info.GUID, string.Format(tablesModel, info.Name, info.ChineseName, info.FunctionId, info.TypeGuid, info.Path)); xmltableshelper.Save(); // 新增表名.table文件 FileUtil.AppendText(string.Format(@"XML\{0}.table", info.Name), string.Format(tablesDetailModel, System.Guid.NewGuid(), info.FunctionId, info.Name, info.ChineseName, Const.Zero, DbType, "1.0.0.0", DateTimeHelper.GetServerDateTime(), string.Empty), Encoding.UTF8); strItemName = info.Name; strFunction = info.FunctionId; strChineseName = info.ChineseName; ID = info.GUID; return(true); #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemName)); MessageDxUtil.ShowError(ex.Message); } return(false); }
public override bool SaveUpdated() { TablesInfo info = new TablesInfo(); if (info != null) { SetInfo(info); #region 更新数据 // 获取数据库数据类型 XmlHelper xmltableshelper = new XmlHelper(@"XML\tables.xml"); // 更新操作 xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/name", strGuid), info.Name); xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/chineseName", strGuid), info.ChineseName); xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/functionId", strGuid), info.FunctionId.ToString()); xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/typegid", strGuid), info.TypeGuid); xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/path", strGuid), info.BasicdataPath); xmltableshelper.Save(); if (!string.Equals(tmpName, info.Name)) { // 表结构重命名 if (FileUtil.IsExistFile(string.Format(@"XML\{0}.table", tmpName))) { System.IO.File.Move(string.Format(@"XML\{0}.table", tmpName), string.Format(@"XML\{0}.table", info.Name)); } // 基础数据重命名 if (FileUtil.IsExistFile(string.Format(@"XML\{0}.basicdata", tmpName))) { xmltableshelper.Replace(string.Format("datatype/dataitem/item[@gid=\"{0}\"]/basicdatapath", strGuid), string.Format(@"XML\{0}.basicdata", info.Name)); System.IO.File.Move(string.Format(@"XML\{0}.basicdata", tmpName), string.Format(@"XML\{0}.basicdata", info.Name)); } } // 新增表名.table文件 XmlHelper xmltablesdetailhelper = new XmlHelper(info.BasicdataPath); xmltablesdetailhelper.Replace("datatype/basicinfo/item/functionId", info.FunctionId.ToString()); xmltablesdetailhelper.Replace("datatype/basicinfo/item/name", info.Name); xmltablesdetailhelper.Replace("datatype/basicinfo/item/chineseName", info.ChineseName); xmltablesdetailhelper.Save(); strItemName = info.Name; intFunction = info.FunctionId; strChineseName = info.ChineseName; strGuid = info.Gid; return(true); #endregion } return(false); }
public static void Init() { var ser = new XmlSerializer(typeof(TablesInfo)); using (var tr = new StreamReader(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "AprioriCoeffs.xml"))) { try { _tables = (TablesInfo)ser.Deserialize(tr); } catch (Exception ex) { Console.Error.WriteLine(ex.ToString() + "\r\n(error in reading XML)"); } } }
/// <summary> /// 添加列头 /// </summary> private void AddCol() { lstCol = new List <SquareControl>(); int index = 0; for (int i = 0; i < 13; i++) { if (i == 0) { SquareControl SquControl = new SquareControl(); TablesInfo tbleEs = new TablesInfo(); tbleEs.BgColor = Color.Transparent; tbleEs.X = 3; tbleEs.Y = 5; tbleEs.SWidth = 42; tbleEs.SHeight = 27; tbleEs.ColFla = true; tbleEs.RowFla = false; tbleEs.AllCheckedFla = true; tbleEs.CheckedFla = false; tbleEs.StrTitle = ""; SquControl.TablesInfoEs = tbleEs; panel1.Controls.Add(SquControl); lstCol.Add(SquControl); } else { //intX =(intWidth *13 +24 ) + (intWidth - 42); index += intWidth + 5; SquareControl SquControl = new SquareControl(); TablesInfo tbleEs = new TablesInfo(); tbleEs.BgColor = Color.Transparent; tbleEs.X = index; tbleEs.Y = 5; tbleEs.SWidth = 42; tbleEs.SHeight = 27; tbleEs.ColFla = true; tbleEs.RowFla = false; tbleEs.AllCheckedFla = false; tbleEs.CheckedFla = false; tbleEs.StrTitle = i.ToString(); SquControl.TablesInfoEs = tbleEs; panel1.Controls.Add(SquControl); lstCol.Add(SquControl); } } }
private void AddTable() { AddCol(); //列 AddRow(); //行 lstTable = new List <TablesInfo>(); int _x = 0; int _y = 0; int intRecord = 0; for (int i = 0; i < 96; i++) { if (i % 12 == 0 && i == 0) { _x = 59; _y = 40; } else { if (i % 12 == 0) { _x = 59; _y += intHeight + 4; } else { _x += intWidth + 4; } } SquareControl SquControl = new SquareControl(); TablesInfo tbleEs = new TablesInfo(); tbleEs.BgColor = Color.White; tbleEs.X = _x; tbleEs.Y = _y; tbleEs.SWidth = 53; tbleEs.SHeight = 38; tbleEs.ColFla = false; tbleEs.RowFla = false; tbleEs.AllCheckedFla = false; tbleEs.CheckedFla = false; tbleEs.CenterTable = true; tbleEs.StrTitle = ""; SquControl.TablesInfoEs = tbleEs; panel1.Controls.Add(SquControl); lstTable.Add(tbleEs); } }
private void SetInfo(TablesInfo info) { info.Gid = txtGUID.Text; info.Name = txtTableName.Text; info.ChineseName = txtChineseName.Text; info.FunctionId = txtFunctionId.Text; info.BasicdataPath = string.Format(@"XML\{0}.entity", info.Name); // 如果是新增 则赋值路径 if (string.IsNullOrEmpty(strGuid)) { // 删除table文件 if (FileUtil.FileIsExist(info.BasicdataPath)) { FileUtil.DeleteFile(info.BasicdataPath); } FileUtil.CreateFile(info.BasicdataPath); } }
public static Dictionary <string, int> FindUsers() { AssociateTableInfo tbi = TablesInfo.GetAssociateTableInfo(); Select select = S.NewSelect(); select.ReturnFields.Add(tbi.AssociateId); select.ReturnFields.Add(tbi.Name); select.Restriction = tbi.PersonId.GreaterThan(S.Parameter(0)); Dictionary <string, int> users = new Dictionary <string, int>(); using (QueryExecutionHelper qeh = new QueryExecutionHelper(select)) { while (qeh.Reader.Read()) { users.Add(qeh.Reader.GetString(1), qeh.Reader.GetInt32(0)); } } return(users); }
private void SetInfo(TablesInfo info) { info.GUID = txtGUID.Text; info.Name = txtTableName.Text; info.ChineseName = txtChineseName.Text; info.FunctionId = txtFunctionId.Text; info.TypeGuid = (cbbTypeGuid.SelectedItem as CListItem).Value; info.Path = string.Format(@"XML\{0}.table", info.Name); // 如果是新增 则赋值路径 if (string.IsNullOrEmpty(ID)) { // 删除table文件 if (FileUtil.FileIsExist(info.Path)) { FileUtil.DeleteFile(info.Path); } FileUtil.CreateFile(info.Path); } }
/// <summary> /// 添加行头 /// </summary> private void AddRow() { lstRow = new List <SquareControl>(); int index = 0; for (int i = 0; i < 8; i++) { SquareControl SquControl = new SquareControl(); TablesInfo tbleEs = new TablesInfo(); tbleEs.BgColor = Color.Transparent; tbleEs.X = 3; tbleEs.Y = index + intHeight; tbleEs.SWidth = 42; tbleEs.SHeight = 27; tbleEs.ColFla = false; tbleEs.RowFla = true; tbleEs.AllCheckedFla = false; tbleEs.StrTitle = character[i].ToString(); SquControl.TablesInfoEs = tbleEs; panel1.Controls.Add(SquControl); lstRow.Add(SquControl); index += intHeight + 4; } }
// private string sql; //public ColumnAttributeMapper(string sql) //{ // this.sql = sql; //} public ColumnAttributeMapper(TablesInfo tablesInfo) { this.TablesInfo = tablesInfo; }
private void btnLoadFile_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { using (var _session = SoSession.Authenticate(Username, Password)) { DataGridViewComboBoxColumn rolesColumn = (DataGridViewComboBoxColumn)dtUsersList.Columns["Role"]; rolesColumn.DataSource = roles.ToList(); rolesColumn.DisplayMember = "Name"; DataGridViewComboBoxColumn groupsColumn = (DataGridViewComboBoxColumn)dtUsersList.Columns["UserGroup"]; groupsColumn.DataSource = groups.ToList(); groupsColumn.DisplayMember = "Value"; p = new FileParser(openFileDialog.FileName); MessageBox.Show("File parsed, " + p.UserInfos.Count.ToString() + " users read\n"); foreach (ImportUserInfo ui in p.UserInfos) { ContactTableInfo cti = TablesInfo.GetContactTableInfo(); OwnerContactLinkTableInfo octi = TablesInfo.GetOwnerContactLinkTableInfo(); Select findOc = S.NewSelect("Find OC"); findOc.JoinRestriction.InnerJoin(cti.ContactId.Equal(octi.ContactId)); // if contact name contains a comma, assume that pre-comma is name and post-comma is department (db & file are set up that way) if (ui.Company.Contains(",")) { findOc.Restriction = cti.Name.Equal(S.Parameter(ui.Company.Split(',')[0].Trim())). And(cti.Department.Equal(S.Parameter(ui.Company.Split(',')[1].Trim()))); } else { findOc.Restriction = cti.Name.Equal(S.Parameter(ui.Company)); } findOc.ReturnFields.Add(cti.ContactId); int ocId = QueryExecutionHelper.ExecuteTypedScalar <int>(findOc); if (ocId == 0) { //MessageBox.Show("Owner company " + ui.Company + "(referenced by " + ui.UID + ") does not exist OR is not an Owner Company - setting to License Owner " + SoSystemInfo.GetCurrent().CompanyName); ui.Company = SoSystemInfo.GetCurrent().CompanyName; if (!_contacts.ContainsKey(SoSystemInfo.GetCurrent().CompanyName)) { _contacts.Add(ui.Company, SoSystemInfo.GetCurrent().CompanyId); } } else if (!_contacts.ContainsKey(ui.Company)) { _contacts.Add(ui.Company, ocId); } if (!_roles.ContainsKey(ui.Role)) { ui.Role = DefaultRole; } if (!_groups.ContainsKey(ui.Group)) { ui.Group = DefaultGroup; } } Dictionary <string, int> users = Importer.FindUsers(); dtUsersList.AutoGenerateColumns = false; dtUsersList.Columns["FirstName"].DataPropertyName = "FirstName"; dtUsersList.Columns["LastName"].DataPropertyName = "LastName"; dtUsersList.Columns["FullName"].DataPropertyName = "FullName"; dtUsersList.Columns["UserName"].DataPropertyName = "UID"; dtUsersList.Columns["Email"].DataPropertyName = "Email"; dtUsersList.Columns["Role"].DataPropertyName = "Role"; dtUsersList.Columns["UserGroup"].DataPropertyName = "Group"; dtUsersList.Columns["Company"].DataPropertyName = "Company"; dtUsersList.Columns["AssociateId"].DataPropertyName = "AssociateId"; dtUsers = Importer.ConvertToDataTable <ImportUserInfo>(p.UserInfos); dtUsersList.DataSource = dtUsers; //dtUsersList.DataSource = p.UserInfos; progressBar.Value = 0; foreach (DataGridViewRow item in dtUsersList.Rows) { string username = item.Cells["UserName"].Value.ToString(); if (users.ContainsKey(username)) { item.Cells["Status"].Value = "Exists"; item.Cells["AssociateId"].Value = users[username]; string license = Importer.GetLicense(users[username], LookupList); item.Cells["AssignedLicenses"].Value = license; } else { item.Cells["AssociateId"].Value = DBNull.Value; item.Cells["Status"].Value = "New"; item.Cells["AssignedLicenses"].Value = ""; } } } btnProcess.Enabled = true; progressBar.Value = 0; txtSearch.Text = ""; lblSearch.Visible = true; txtSearch.Visible = true; } }
private void SetInfo(TablesInfo info) { info.Gid = cbbItemName.GetComboBoxStrValue(); info.Name = cbbItemName.SelectedText.Split('(')[1].Split(' ')[1].TrimEnd(')'); info.BasicdataPath = string.Format(@"XML\{0}.basicdata", info.Name); }