public TcpProjectDatabaseServer(ProjectDatabase manager, int port, string tempStagingDirectory) { m_Manager = manager; m_Listener = TcpListener.Create(port); m_TempStagingDirectory = tempStagingDirectory; Directory.CreateDirectory(m_TempStagingDirectory); }
private void newProjectButton_Click(object sender, EventArgs e) { try { Project p = null; using (NewProjectForm dial = new NewProjectForm()) { if (dial.ShowDialog() == DialogResult.OK) { string projectName = dial.NewProjectName; m_Parent.OnProjectOpening(); p = new ProjectDatabase().OpenProject(projectName); } } if (p != null) { DialogResult = DialogResult.OK; Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ProjectDatabaseUnsupportedEvent(ProjectDatabase manager, string feature) : base( $"'{manager}' does not support {feature}", ErrorEventKeys.s_ModuleManagerUnsupportedFeature, false ) { }
public App() { ProjectDatabase.Load(); InitializeComponent(); MainPage = new NavigationPage(new MainPage()); }
/// <summary> /// Initializes a new instance of the <see cref="NewProjectForm"/> class. /// </summary> /// <param name="pd">The container for the project (not null).</param> /// <exception cref="ArgumentNullException">If the specified container is null.</exception> internal NewProjectForm(ProjectDatabase pd) { InitializeComponent(); if (pd == null) throw new ArgumentNullException(); m_Container = pd; }
/// <summary> /// Initializes a new instance of the <see cref="Project"/> class /// upon creation of a brand new project. /// </summary> /// <param name="container">The container for this project (not null).</param> /// <param name="projectId">The unique ID for the project.</param> /// <param name="ps">The initial project settings (not null).</param> internal Project(ProjectDatabase container, Guid projectId, ProjectSettings ps) { if (container == null || ps == null) throw new ArgumentNullException(); m_Container = container; m_Id = projectId; m_Settings = ps; m_MapModel = new CadastralMapModel(); }
/// <summary> /// Initializes a new instance of the <see cref="NewProjectForm"/> class. /// </summary> /// <param name="pd">The container for the project (not null).</param> /// <exception cref="ArgumentNullException">If the specified container is null.</exception> internal NewProjectForm(ProjectDatabase pd) { InitializeComponent(); if (pd == null) { throw new ArgumentNullException(); } m_Container = pd; }
public ProjectConfig( ProjectDatabase manager, string projectName, string projectVersion, ProjectDependency[] dependencies) { ProjectName = projectName; ProjectVersion = projectVersion; Manager = manager; Dependencies = dependencies.ToList(); }
public void SaveXML(ProjectDatabase projectData) { XmlSerializer ser = new XmlSerializer(typeof(ProjectDatabase)); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true, IndentChars = " ", NewLineChars = "\r\n", NewLineHandling = NewLineHandling.Replace }; using (XmlWriter writer = XmlWriter.Create(@"Resources/ProjectDatabase.xml", settings)) { ser.Serialize(writer, projectData); } }
public override void AddNewItemRaw() { try { string defaultValue = Clipboard.ContainsText() ? Clipboard.GetText() : ""; InputDialog dialog = new InputDialog("Paste the database lines here.", "Add new raw items", defaultValue, false, false); dialog.Owner = WpfUtilities.TopWindow; dialog.TextBoxInput.Loaded += delegate { dialog.TextBoxInput.SelectAll(); dialog.TextBoxInput.Focus(); }; dialog.TextBoxInput.AcceptsReturn = true; dialog.TextBoxInput.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; dialog.TextBoxInput.TextWrapping = TextWrapping.NoWrap; dialog.TextBoxInput.Height = 200; dialog.TextBoxInput.MinHeight = 200; dialog.TextBoxInput.MaxHeight = 200; dialog.TextBoxInput.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; if (dialog.ShowDialog() == true) { try { Table.Commands.Begin(); string text = dialog.Input; string tempPath = TemporaryFilesManager.GetTemporaryFilePath("db_tmp_{0:0000}.txt"); File.WriteAllText(tempPath, text); ProjectDatabase.GetDb <TKey>(Settings.DbData).LoadFromClipboard(tempPath); } catch { Table.Commands.CancelEdit(); } finally { Table.Commands.EndEdit(); } _listView_SelectionChanged(this, null); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
//new db method protected void GetDatabase() { dataItemList = new ObservableCollection <Project>(ProjectDatabase.GetItems()); // dataItemList = new ObservableCollection<Project>(); //int count = dataItemList_Temp.Count; //for (int index = 0; index < count; index++) //{ // dataItemList.Add(new Project // { // Id = dataItemList_Temp[index].Id, // Name = dataItemList_Temp[index].Name, // DateCreated = dataItemList_Temp[index].DateCreated, // DateModified = dataItemList_Temp[index].DateModified, // Description = dataItemList_Temp[index].Description, // dataItemDescList = dataItemList_Temp[index].dataItemDescList // }) ; //} // Debug.WriteLine("Action: " + (dataItemList[0]).Name); OnPropertyChanged(); }
public void SaveNewItemToList(Project newItem, int pageType, int updateItemIndex) { //if new item if (pageType == ProjectDatabase.PAGE_TYPE_NEW) { dataItemList.Add(newItem); } else { dataItemList[updateItemIndex] = newItem; } if (sort) { dataItemList = new ObservableCollection <Project>(dataItemList.OrderBy(i => i.DateModified)); } else { dataItemList = new ObservableCollection <Project>(dataItemList.OrderByDescending(i => i.DateModified)); } OnPropertyChanged(nameof(DataItemList)); ProjectDatabase.SaveItem(newItem, pageType);///new line for db }
private void StartupForm_Load(object sender, EventArgs e) { // Pick up a canned environment from embedded resource file if (String.IsNullOrEmpty(LastDatabase.ConnectionString)) { EnvironmentContainer.Current = new EnvironmentResource(); } else { EnvironmentContainer.Current = new EnvironmentDatabase(LastDatabase.ConnectionString); } ShowDatabaseName(); // Determine whether a previously open project is still available bool canOpen = false; string lastProjectName = Settings.Default.LastProjectName; if (!String.IsNullOrEmpty(lastProjectName)) { ProjectDatabase pd = new ProjectDatabase(); canOpen = pd.CanOpen(lastProjectName); } if (canOpen) { openLastButton.Text = "&Open " + lastProjectName; this.AcceptButton = openLastButton; } else { newProjectButton.BackColor = openLastButton.BackColor; this.AcceptButton = newProjectButton; openLastButton.BackColor = SystemColors.Control; openLastButton.Enabled = false; } }
/// <summary> /// Constructor /// </summary> /// <param name="context">Context of the database</param> public AlertServices(ProjectDatabase context) { _context = context.database; }
/// <summary> /// Sale service constructor /// </summary> /// <param name="context">Context of the database</param> /// <param name="productServices">Services of the "Product" table</param> public SaleServices(ProjectDatabase context, ProductServices productServices) { _context = context.database; _productServices = productServices; }
private void FileNew(IUserAction action) { using (NewProjectForm dial = new NewProjectForm()) { if (dial.ShowDialog() == DialogResult.OK) { string projectName = dial.NewProjectName; OnProjectOpening(); Project p = new ProjectDatabase().OpenProject(projectName); AddRecentProject(projectName); } } }
/// <summary> /// Constructor /// </summary> /// <param name="context">Context of the database</param> /// <param name="alertServices">Services for the "Alert" table</param> public MaterialServices(ProjectDatabase context, AlertServices alertServices) { _context = context.database; _alertServices = alertServices; }
public AbstractDb <T> GetDb <T>(ServerDbs source) { return(ProjectDatabase.GetDb <T>(source)); }
public Table <T, ReadableTuple <T> > GetTable <T>(ServerDbs db) { return(ProjectDatabase.GetTable <T>(db)); }
public ProjectPackage(ProjectDatabase manager, string moduleName, string[] moduleVersions) { ModuleName = moduleName; ModuleVersions = moduleVersions.ToList(); Manager = manager; }
public List <Entity> GetEntitiesFromDatabase(ProjectDatabase db) { List <Entity> list = new List <Entity>(); string connString = CreateConnectionString(db); using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); // first get the tables string tableQ = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name NOT IN ('sysdiagrams', 'CHANGELOG') ORDER BY table_name"; using (SqlCommand cmd = new SqlCommand(tableQ, conn)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Entity ent = new Entity(); ent.EntityFields = new List <EntityField>(); ent.EntityName = reader["table_name"].ToString(); ent.StatusCode = EntityStatusCodes.Staged; list.Add(ent); } } } string fieldQ = "SELECT column_name, is_nullable, data_type, character_maximum_length, numeric_precision, numeric_scale FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = @TableName"; using (SqlCommand fieldCmd = new SqlCommand(fieldQ, conn)) { fieldCmd.Parameters.Add("@TableName", System.Data.SqlDbType.VarChar); foreach (var entity in list) { fieldCmd.Parameters["@TableName"].Value = entity.EntityName; using (SqlDataReader fieldReader = fieldCmd.ExecuteReader()) { while (fieldReader.Read()) { EntityField field = new EntityField(); field.Entity = entity; field.FieldName = fieldReader["column_name"].ToString(); field.Datatype = fieldReader["data_type"].ToString(); field.IsSearchField = true; field.IsDTO = true; field.IsRequired = fieldReader["is_nullable"].ToString().Equals("NO"); field.Scale = ValueOrNull(fieldReader["numeric_scale"]); // setup the max length if (IsStringType(field.Datatype)) { field.MaxLength = ValueOrNull(fieldReader["character_maximum_length"]); } else if (field.Datatype == DBDataTypes.Decimal) { field.MaxLength = ValueOrNull(fieldReader["numeric_precision"]); } field.StatusCode = EntityFieldStatusCodes.Staged; entity.EntityFields.Add(field); } } } } // now get the primary key for each entity string keyQ = @" SELECT pkt.name, pkc.name AS ColumnName, pkc.is_identity AS IsIdentity FROM sys.indexes c INNER JOIN sys.tables pkt ON pkt.object_id = c.object_id INNER JOIN sys.index_columns ic ON ic.index_id = c.index_id AND ic.object_id = c.object_id INNER JOIN sys.columns pkc ON pkc.column_id = ic.column_id AND pkc.object_id = c.object_id WHERE c.is_primary_key = 1 AND pkt.name = @TableName "; using (SqlCommand keyCmd = new SqlCommand(keyQ, conn)) { keyCmd.Parameters.Add("@TableName", System.Data.SqlDbType.VarChar); foreach (var entity in list) { keyCmd.Parameters["@TableName"].Value = entity.EntityName; using (SqlDataReader keyReader = keyCmd.ExecuteReader()) { while (keyReader.Read()) { string fieldName = keyReader["ColumnName"].ToString(); // find the field var field = entity.EntityFields.Where(f => f.FieldName == fieldName).First(); field.IsKey = true; field.IsIdentity = keyReader["IsIdentity"].ToString().Equals("True"); } } } } // now get all the foreign keys and match them up to the tables we've found string fkSql = @" SELECT fkt.name AS FKTable, fkcol.name AS FKColumn, pkt.name AS PKTable, pkcol.name AS PKColumn FROM sys.foreign_keys fk INNER JOIN sys.tables fkt ON fkt.object_id = fk.parent_object_id INNER JOIN sys.tables pkt ON pkt.object_id = fk.referenced_object_id INNER JOIN sys.foreign_key_columns fkc ON fkc.parent_object_id = fkt.object_id AND fkc.referenced_object_id = pkt.object_id INNER JOIN sys.columns fkcol ON fkcol.column_id = fkc.parent_column_id AND fkcol.object_id = fkc.parent_object_id INNER JOIN sys.columns pkcol ON pkcol.column_id = fkc.referenced_column_id AND pkcol.object_id = fkc.referenced_object_id ORDER BY fkt.name "; using (SqlCommand fkCmd = new SqlCommand(fkSql, conn)) { using (SqlDataReader fkReader = fkCmd.ExecuteReader()) { while (fkReader.Read()) { // get the foreign key entity info var fkEntityName = fkReader["FKTable"].ToString(); var fkFieldName = fkReader["FKColumn"].ToString(); var pkEntityName = fkReader["PKTable"].ToString(); var pkFieldName = fkReader["PKColumn"].ToString(); // see if this entity is in the list var fkEntity = list.Where(e => e.EntityName == fkEntityName).FirstOrDefault(); // find the primary key entity var pkEntity = list.Where(e => e.EntityName == pkEntityName).FirstOrDefault(); if (fkEntity != null && pkEntity != null) { // find the field var field = fkEntity.EntityFields.Where(f => f.FieldName == fkFieldName).First(); if (field.ParentLinks == null) { field.ParentLinks = new List <EntityLink>(); } var pkField = pkEntity.EntityFields.Where(f => f.FieldName == pkFieldName).First(); // add an entity link for this entity EntityLink link = new EntityLink(); link.StatusCode = EntityLinkStatusCodes.Staged; field.ParentLinks.Add(link); link.PrimaryKeyField = pkField; link.ForeignKeyField = field; // try to determine which type of link this is if (pkFieldName.ToUpper().EndsWith("CODE") || pkFieldName.ToUpper().EndsWith("TYPE")) { link.LinkTypeCode = EntityLinkTypes.Reference; } else { link.LinkTypeCode = EntityLinkTypes.Collection; } } } } } } return(list); }
/* void AddNewDataItemToList() * { * Project dataItem1 = new Project(); * * dataItem1.ID = "PR 01"; * dataItem1.Name = "Adding Machine"; * dataItem1.DateCreated = DateTime.Now.Date; * dataItem1.DateModified = DateTime.Now.Date; * dataItem1.Description = "Machine that can add its input to the previous sum. Numbers should be less than 5 digits, floating point numbers are also possible"; * dataItem1.dataItemDescList.Add(new ProjectListItem {Versions = "Ver 1.2.2", CreatorName = "Jhon" }); * dataItem1.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 1.2.2", CreatorName = "CHaun" }); * dataItem1.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 1.2.2", CreatorName = "Jhon" }); * dataItem1.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 1.2.2", CreatorName = "Jhon" }); * dataItem1.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 1.2.2", CreatorName = "Jhon" }); * dataItemList.Add(dataItem1); * // Debug.WriteLine("IN Data View: " + dataItem1.dataItemDescList.ElementAt(0).Versions); * * Project dataItem2 = new Project(); * dataItem2.ID = "PR 06"; * dataItem2.Name = "Adding Machine"; * dataItem2.DateCreated = DateTime.Now.Date; * dataItem2.DateModified = DateTime.Now.Date; * dataItem2.Description = "Machine that can add its input to the previous sum. Numbers should be less than 5 digits, floating point numbers are also possible"; * dataItem2.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 6.2.2", CreatorName = "Jhon" }); * dataItem2.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 6.2.2", CreatorName = "CHaun" }); * dataItem2.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 6.2.2", CreatorName = "Jhon" }); * dataItem2.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 6.2.2", CreatorName = "Jhon" }); * dataItem2.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 6.2.2", CreatorName = "Jhon" }); * dataItemList.Add(dataItem2); * Debug.WriteLine("IN Data View: " + dataItem2.dataItemDescList.ElementAt(0).Versions); * * Project dataItem6 = new Project(); * dataItem6.ID = "PR 02"; * dataItem6.Name = "Date Storage Machine"; * dataItem6.DateCreated = DateTime.Now.Date; * dataItem6.DateModified = DateTime.Now.Date; * dataItem6.Description = "Machine that can add its input to the previous sum. Numbers should be less than 5 digits, floating point numbers are also possible"; * dataItem6.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItem6.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "CHaun" }); * dataItem6.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItem6.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItem6.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItemList.Add(dataItem6); * * Project dataItem3 = new Project(); * dataItem3.ID = "PR 03"; * dataItem3.Name = "Paitient Record Keeping"; * dataItem3.DateCreated = DateTime.Now.Date; * dataItem3.DateModified = DateTime.Now.Date; * dataItem3.Description = "Machine that can add its input to the previous sum. Numbers should be less than 5 digits, floating point numbers are also possible"; * dataItem3.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItem3.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "CHaun" }); * dataItem3.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItem3.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItem3.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 3.2.2", CreatorName = "Jhon" }); * dataItemList.Add(dataItem3); * * Project dataItem4 = new Project(); * dataItem4.ID = "PR 04"; * dataItem4.Name = "Grossary Store Inventory Record Management Program"; * dataItem4.DateCreated = DateTime.Now.Date; * dataItem4.DateModified = DateTime.Now.Date; * dataItem4.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 4.2.2", CreatorName = "Jhon" }); * dataItem4.Description = "Machine that can add its input to the previous sum. Numbers should be less than 5 digits, floating point numbers are also possible"; * dataItem4.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 4.2.2", CreatorName = "CHaun" }); * dataItem4.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 4.2.2", CreatorName = "Jhon" }); * dataItem4.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 4.2.2", CreatorName = "Jhon" }); * dataItem4.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 4.2.2", CreatorName = "Jhon" }); * dataItemList.Add(dataItem4); * * Project dataItem5 = new Project(); * dataItem5.ID = "PR 05"; * dataItem5.Name = "Photo Editing software"; * dataItem5.DateCreated = DateTime.Now.Date; * dataItem5.DateModified = DateTime.Now.Date; * dataItem5.Description = "Machine that can add its input to the previous sum. Numbers should be less than 5 digits, floating point numbers are also possible"; * dataItem5.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 5.2.2", CreatorName = "Jhon" }); * dataItem5.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 5.2.2", CreatorName = "CHaun" }); * dataItem5.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 5.2.2", CreatorName = "Jhon" }); * dataItem5.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 5.2.2", CreatorName = "Jhon" }); * dataItem5.dataItemDescList.Add(new ProjectListItem { Versions = "Ver 5.2.2", CreatorName = "Jhon" }); * dataItemList.Add(dataItem5); * // OnPropertyChanged(); * * } */ /* void AddNewDataItem() * { * Debug.WriteLine("Action: New event"); * * } */ void DeleteDataItem(Project dRItem) { dataItemList.Remove(dRItem); ProjectDatabase.DeleteItem(dRItem); }
string CreateConnectionString(ProjectDatabase database) { return($"Data Source={database.ServerName};Initial Catalog={database.DatabaseName};Persist Security Info=True;User ID={database.Username};Password={database.Password}"); }
/// <summary> /// Constructor /// </summary> /// <param name="context">Database context</param> public MaterialsProductServices(ProjectDatabase context) { _context = context.database; }
public void Initialize(GTabSettings <TKey, TValue> settings) { Settings = settings; _displayGrid = new Grid(); _displayGrid.SetValue(Grid.ColumnProperty, 2); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()); if (Settings.DbData == ServerDbs.ClientItems || Settings.DbData == ServerDbs.Pet || Settings.DbData == ServerDbs.Pet2 || Settings.DbData == ServerDbs.Mobs || Settings.DbData == ServerDbs.Mobs2 || Settings.DbData == ServerDbs.MobGroups || Settings.DbData == ServerDbs.Items || Settings.DbData == ServerDbs.Items2) { _viewGrid.Children.Add(_displayGrid); } else { ScrollViewer sv = new ScrollViewer(); sv.SetValue(Grid.ColumnProperty, 2); sv.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto); sv.Focusable = false; sv.Content = _displayGrid; _viewGrid.Children.Add(sv); } ProjectDatabase = settings.ClientDatabase; DbComponent = ProjectDatabase.GetDb <TKey>(settings.DbData); Table = Settings.Table; Header = Settings.TabName; Style = TryFindResource(settings.Style) as Style ?? Style; SearchEngine = settings.SearchEngine; SearchEngine.Init(_dbSearchPanel, this); Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated); if (Settings.SearchEngine.SetupImageDataGetter != null) { ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24 }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" }); } else { ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" }); } if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable)) { _deployTabControls(); } _initTableEvents(); if (Settings.ContextMenu != null) { if (Header is Control) { ((Control)Header).ContextMenu = Settings.ContextMenu; } } if (Settings.Loaded != null) { Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData)); } if (Settings.DisplayablePropertyMaker.OnTabVisible != null) { Settings.DisplayablePropertyMaker.OnTabVisible(this); } Loaded += delegate { TabControl parent = WpfUtilities.FindParentControl <TabControl>(this); if (parent != null) { parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged); } }; _listView.PreviewMouseDown += delegate { _listView.Focus(); }; _listView.Loaded += delegate { try { if (IsVisible) { Keyboard.Focus(_listView); } } catch { } }; ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView); ApplicationShortcut.Link(ApplicationShortcut.FromString("F3", "Search next empty ID"), () => { if (_listView.SelectedItems.Count > 0) { ReadableTuple <int> item = (_listView.SelectedItems[_listView.SelectedItems.Count - 1]) as ReadableTuple <int>; var original = item; if (item != null) { int id = item.Key; while (true) { id++; var idGeneric = (TKey)(object)id; var tuple = (ReadableTuple <int>)(object) Table.TryGetTuple(idGeneric); if (tuple == null && item != original && item != null) { TabNavigation.SelectList(DbComponent.DbSource, new TKey[] { item.GetKey <TKey>() }); break; } item = tuple; } } } }, _listView); }
public static ProjectConfig Resolve(ProjectDatabase manager, ProjectDependency dependency) { return(manager.GetPackage(dependency.ProjectName). GetInstallTarget(dependency.ProjectVersion == "ANY" ? null : dependency.ProjectVersion)); }
public MetaTable <T> GetMetaTable <T>(ServerDbs db) { return(ProjectDatabase.GetMetaTable <T>(db)); }
private void _menuItemUpdateClientQuests_Click(object sender, RoutedEventArgs e) { try { var tab = FindTopmostTab(); if (tab == null) { return; } string file = PathRequest.OpenFileCde("fileName", "iRO-questid2display.txt"); if (file != null) { var db = ProjectDatabase.GetDb <int>(ServerDbs.CQuests); var table = db.Table; try { table.Commands.BeginNoDelay(); foreach (string[] elements in TextFileHelper.GetElementsInt(File.ReadAllBytes(file))) { int itemId = Int32.Parse(elements[0]); var tuple = table.TryGetTuple(itemId); if (tuple != null) { DbIOClientQuests.SetQuestValue(table, tuple, elements, 1); table.Set(itemId, ClientQuestsAttributes.SG, elements[2]); table.Set(itemId, ClientQuestsAttributes.QUE, elements[3]); DbIOClientQuests.SetQuestValue(table, tuple, elements, 4); DbIOClientQuests.SetQuestValue(table, tuple, elements, 5); } else { ReadableTuple <int> newTuple = new ReadableTuple <int>(itemId, ClientQuestsAttributes.AttributeList); table.Commands.AddTuple(itemId, newTuple); table.Commands.Set(newTuple, ClientQuestsAttributes.Name, elements[1]); table.Commands.Set(newTuple, ClientQuestsAttributes.SG, elements[2]); table.Commands.Set(newTuple, ClientQuestsAttributes.QUE, elements[3]); table.Commands.Set(newTuple, ClientQuestsAttributes.FullDesc, elements[4]); table.Commands.Set(newTuple, ClientQuestsAttributes.ShortDesc, elements[5]); } } var db2 = db.ProjectDatabase.GetMetaTable <int>(ServerDbs.Quests); foreach (var quest in db2.FastItems) { var id = quest.Key; var tuple = table.TryGetTuple(id); if (tuple != null) { DbIOClientQuests.SetQuestValue(table, tuple, quest.GetValue <string>(ServerQuestsAttributes.QuestTitle), ClientQuestsAttributes.Name.Index); } else { ReadableTuple <int> newTuple = new ReadableTuple <int>(id, ClientQuestsAttributes.AttributeList); table.Commands.AddTuple(id, newTuple); table.Commands.Set(newTuple, ClientQuestsAttributes.Name, quest.GetValue <string>(ServerQuestsAttributes.QuestTitle)); table.Commands.Set(newTuple, ClientQuestsAttributes.SG, "SG_FEEL"); table.Commands.Set(newTuple, ClientQuestsAttributes.QUE, "QUE_NOIMAGE"); table.Commands.Set(newTuple, ClientQuestsAttributes.FullDesc, "..."); table.Commands.Set(newTuple, ClientQuestsAttributes.ShortDesc, ""); } } Debug.Ignore(() => DbDebugHelper.OnLoaded(db.DbSource, db.ProjectDatabase.MetaGrf.FindTkPath(file), db)); } catch (Exception err) { table.Commands.CancelEdit(); ErrorHandler.HandleException(err); } finally { table.Commands.End(); } } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public override void ImportFromFile(string fileDefault = null, bool autoIncrement = false) { try { string file = fileDefault ?? PathRequest.OpenFileCde("filter", "All db files|*.conf;*.txt"); if (file == "clipboard") { if (!Clipboard.ContainsText()) { return; } file = TemporaryFilesManager.GetTemporaryFilePath("clipboard_{0:0000}.txt"); File.WriteAllText(file, Clipboard.GetText()); } if (file != null) { try { Table.Commands.Begin(); ProjectDatabase.GetDb <TKey>(Settings.DbData).LoadFromClipboard(file); } catch { Table.Commands.CancelEdit(); } finally { Table.Commands.EndEdit(); if (autoIncrement && typeof(TKey) == typeof(int)) { var cmds = Table.Commands.GetUndoCommands(); if (cmds.Count > 0) { var lastCmd = cmds.Last() as GroupCommand <TKey, TValue>; if (lastCmd != null) { if (lastCmd.Commands.Count > 0 && lastCmd.Commands.OfType <ChangeTupleProperties <TKey, TValue> >().Count() == 1) { var firstKey = lastCmd.Commands.First().Key; var tuple = new ReadableTuple <TKey>(firstKey, Table.AttributeList); var oldTuple = (ReadableTuple <TKey>)(object) Table.TryGetTuple(firstKey); tuple.Copy(oldTuple); tuple.Added = true; ProjectDatabase.Commands.Undo(); Table.Commands.AddTuple(tuple.GetKey <TKey>(), (TValue)(object)tuple, false, true, null); } } } } } _listView_SelectionChanged(this, null); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
internal Project OpenProject(string projectName) { if (String.IsNullOrEmpty(projectName)) return null; ProjectDatabase pd = new ProjectDatabase(); ProjectSettings ps = pd.GetProjectSettings(projectName); if (ps == null) return null; // Close any currently open project or dialog. OnProjectOpening(); ForwardingTraceListener trace = new ForwardingTraceListener(ShowLoadProgress); Stopwatch sw = Stopwatch.StartNew(); try { string increment = ps.SplashIncrement; string percents = ps.SplashPercents; // Don't show splash screen if it's a brand new file //if (percents.Length > 0) SplashScreen.ShowSplashScreen(increment, percents); Trace.Listeners.Add(trace); Trace.Write("Loading " + projectName); // Display the map name in the dialog title (nice to see what's loading // rather than the default "Map Title" text) this.Text = projectName; Project p = pd.OpenProject(projectName); // Remember the project the user is now working with //EditingController.Current.SetProject(p); // Update splashscreen metrics. This is perhaps a little premature, since // the original splash screen implementation waited until the screen had // completely faded away. The drawback with that is that the project settings would // then be rewritten on another thread, which could trample on things that // are happening here. SplashScreen ss = SplashScreen.SplashForm; p.Settings.SplashIncrement = ss.GetIncrement(); p.Settings.SplashPercents = ss.GetPercents(); p.SaveSettings(); sw.Stop(); ShowLoadProgress(String.Format("Load time: {0:0.00} seconds", sw.ElapsedMilliseconds / 1000.0)); // If the splash screen has been displayed for less than two seconds, WAIT (block // this thread!) int waitTime = (int)(2000 - sw.ElapsedMilliseconds); if (waitTime > 0) System.Threading.Thread.Sleep(waitTime); // Need to first initialize overview extent before defining center and scale // ...but first pick up the last draw info before defining the overview extent (really, // should modify SetMapModel so it accepts the DrawInfo rather than an extent). // ...I think initialization of the overview extent will adjust the last draw // data that's saved in the project settings //DrawInfo drawInfo = p.Settings.LastDraw; DrawInfo drawInfo = ps.LastDraw; //EditingController.Current.SetMapModel(p.Model, null); if (drawInfo.MapScale > 0) { double cx = drawInfo.CenterX; double cy = drawInfo.CenterY; double mapScale = drawInfo.MapScale; (EditingController.Current.ActiveDisplay as MapControl).SetCenterAndScale(cx, cy, mapScale, true); } return p; } catch (Exception ex) { SplashScreen.CloseForm(); ShowMessageBox(ex); Trace.Write(ex.StackTrace); } finally { SplashScreen.CloseForm(); Trace.Listeners.Remove(trace); } return null; }
/// <summary> /// Constructor /// </summary> /// <param name="context">Context of the database</param> public UserServices(ProjectDatabase context) { _context = context.database; }
public void Initialize(GTabSettings <TKey, TValue> settings) { Settings = settings; ProjectDatabase = settings.ClientDatabase; DbComponent = ProjectDatabase.GetDb <TKey>(settings.DbData); Table = Settings.Table; Header = Settings.TabName; Style = TryFindResource(settings.Style) as Style ?? Style; SearchEngine = settings.SearchEngine; SearchEngine.Init(_dbSearchPanel, this); Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated); if (Settings.SearchEngine.SetupImageDataGetter != null) { Extensions.GenerateListViewTemplate(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24 }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false"); } else { Extensions.GenerateListViewTemplate(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false"); } if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable)) { _deployTabControls(); } _initTableEvents(); if (Settings.ContextMenu != null) { if (Header is Control) { ((Control)Header).ContextMenu = Settings.ContextMenu; } } if (Settings.Loaded != null) { Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData)); } if (Settings.DisplayablePropertyMaker.OnTabVisible != null) { Settings.DisplayablePropertyMaker.OnTabVisible(this); } Loaded += delegate { TabControl parent = WpfUtilities.FindParentControl <TabControl>(this); if (parent != null) { parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged); } }; _listView.PreviewMouseDown += delegate { _listView.Focus(); }; _listView.Loaded += delegate { try { if (IsVisible) { Keyboard.Focus(_listView); } } catch { } }; ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView); }