/// <summary> /// Gets the mapping by server name and DB name. /// </summary> /// <param name="DBServer">The DB server name.</param> /// <param name="DB">The DB name.</param> /// <param name="company">The company name.</param> /// <returns></returns> static public Mapping GetByServerDB(string DBServer, string DB, string company) { if (mappings == null) { LoadMapping(); } var resultServer = from r in mappings where r.DbServer == DBServer select r; var resultDB = from r in resultServer where r.Db == DB select r; if ((resultDB.Count() == 0) || (resultDB == null)) { if (NVR_DynamicsNAVProtocolHandler.Properties.Settings.Default.AutoMapping) { var mapping = new Mapping(); mapping.Db = DB; mapping.DbServer = DBServer; mapping.Company = company; mapping.Instance = DB; mapping.NavServer = DBServer.Split('\\')[0] + ":" + NVR_DynamicsNAVProtocolHandler.Properties.Settings.Default.NAVServerDefaultPort.ToString(); mappings.Add(mapping); SaveMapping(); var resultServerRetry = from r in mappings where r.DbServer == DBServer select r; var resultDBRetry = from r in resultServerRetry where r.Db == DB select r; if ((resultDBRetry.Count() == 0) || (resultDBRetry == null)) { return(null); } return(resultDBRetry.First()); } else { var mapping = new Mapping(); mapping.Db = DB; mapping.DbServer = DBServer; mapping.Company = company; var editor = new MappingEditor(mapping); if (editor.ShowDialog() == true) { } var resultServerRetry = from r in mappings where r.DbServer == DBServer select r; var resultDBRetry = from r in resultServerRetry where r.Db == DB select r; if ((resultDBRetry.Count() == 0) || (resultDBRetry == null)) { return(null); } return(resultDBRetry.First()); } } return(resultDB.First()); }
private void buttonMapping_Click_1(object sender, RoutedEventArgs e) { var mapping = new MappingEditor(); mapping.ShowDialog(); }