Exemplo n.º 1
0
		private void SaveIndex()
		{
			try
			{
				SaveIndexClass saveIndexInstance = new SaveIndexClass(Helper.ClassName);
				
				foreach (DataGridViewRow row in dbGridViewProperties.Rows)
				{
					bool boolValue = Convert.ToBoolean(row.Cells[2].Value);
					saveIndexInstance.Fieldname.Add(row.Cells[0].Value.ToString());
					saveIndexInstance.Indexed.Add(boolValue);
				}

				CloseQueryResultToolWindows();
				
				ConnParams conparam = dbInteraction.GetCurrentRecentConnection().ConnParam;
				dbInteraction.CloseCurrDb();
				saveIndexInstance.SaveIndex();

				RecentQueries currRecentConnection = new RecentQueries(conparam);
				Db4oClient.conn = conparam;  
				RecentQueries tempRc = currRecentConnection.ChkIfRecentConnIsInDb();
				if (tempRc != null)
					currRecentConnection = tempRc;
				currRecentConnection.Timestamp = DateTime.Now;
				dbInteraction.ConnectoToDB(currRecentConnection);
				dbInteraction.SetCurrentRecentConnection(currRecentConnection);

				//Only if following line is added the index is saved.
				OMQuery omQuery = new OMQuery(saveIndexInstance.Classname , DateTime.Now);
				long[] objectid = dbInteraction.ExecuteQueryResults(omQuery);

				if (ObjectBrowser.Instance.ToolStripButtonAssemblyView.Checked)
					ObjectBrowser.Instance.DbtreeviewObject.FindNSelectNode(ObjectBrowser.Instance.DbAssemblyTreeView.Nodes[0], saveIndexInstance.Classname, ObjectBrowser.Instance.DbAssemblyTreeView);
				else
					ObjectBrowser.Instance.DbtreeviewObject.FindNSelectNode(ObjectBrowser.Instance.DbtreeviewObject.Nodes[0], saveIndexInstance.Classname, ObjectBrowser.Instance.DbtreeviewObject);

				tabStripProperties.SelectedItem = tabItemClassProperties;
				MessageBox.Show("Index Saved Successfully!", Helper.GetResourceString(Constants.PRODUCT_CAPTION), MessageBoxButtons.OK);
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}