public static void SetFieldToNull(long id, string fieldName) { try { object obj = Db4oClient.Client.Ext().GetByID(id); Db4oClient.Client.Ext().Activate(obj, 1); IReflectClass klass = DataLayerCommon.ReflectClassFor(obj); if (klass != null) { IReflectField field = DataLayerCommon.GetDeclaredFieldInHeirarchy(klass, fieldName); if (field == null) { return; } field.Set(obj, null); Db4oClient.Client.Store(obj); Db4oClient.Client.Commit(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
public Hashtable StoredClassesByAssembly() { try { IStoredClass[] storedClasses = Db4oClient.Client.Ext().StoredClasses(); Hashtable storedClassHashtable = new Hashtable(); foreach (IStoredClass stored in storedClasses) { string className = stored.GetName(); if (!ExcludeClass(className)) { string assemblyName = GetAssemblyName(className); if (!storedClassHashtable.ContainsKey(assemblyName)) { storedClassHashtable.Add(assemblyName, new List <string>()); } List <string> assemblyClasses = storedClassHashtable[assemblyName] as List <string>; assemblyClasses.Add(className); } } return(SortHashtable(storedClassHashtable)); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(null); } }
public RecentQueries ChkIfRecentConnIsInDb() { RecentQueries recConnection = null; IObjectSet objSet = null; try { container = Db4oClient.RecentConn; IQuery qry = container.Query(); qry.Constrain(typeof(RecentQueries)); if (m_connParam.Host == null) { qry.Descend("m_connParam").Descend("m_connection").Constrain(m_connParam.Connection); objSet = qry.Execute(); } else { qry.Descend("m_connParam").Descend("m_host").Constrain(m_connParam.Host); qry.Descend("m_connParam").Descend("m_port").Constrain(m_connParam.Port); qry.Descend("m_connParam").Descend("m_userName").Constrain(m_connParam.UserName); qry.Descend("m_connParam").Descend("m_passWord").Constrain(m_connParam.PassWord); objSet = qry.Execute(); } if (objSet.Count > 0) { recConnection = (RecentQueries)objSet.Next(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } return(recConnection); }
internal void RenameFolderInDatabase(FavouriteFolder oldFavFolder, FavouriteFolder newFavFolder) { try { FavouriteFolderList favList = FetchAllFavouritesForAConnection(); if (favList == null) { return; } foreach (FavouriteFolder str in favList.lstFavFolder.Where(str => str != null && str.FolderName.Equals(oldFavFolder.FolderName))) { favList.lstFavFolder.Remove(str); Db4oClient.OMNConnection.Delete(str); str.FolderName = newFavFolder.FolderName; favList.lstFavFolder.Add(str); Db4oClient.OMNConnection.Store(favList); Db4oClient.OMNConnection.Commit(); break; } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } finally { Db4oClient.CloseRecentConnectionFile(); } }
public static IStoredField GetDeclaredStoredFieldInHeirarchy(IStoredClass aClass, string attribute) { try { IStoredField sField = null; if (aClass == null) { return(null); } while (aClass != null) { sField = aClass.StoredField(attribute, null); if (sField != null) { break; } aClass = aClass.GetParentStoredClass(); } return(sField); } catch (Exception e) { LoggingHelper.HandleException(e); } return(null); }
private FavouriteList FetchAllFavouritesForAConnection() { FavouriteList FavList = null; try { container = Db4oClient.RecentConn; IQuery query = container.Query(); query.Constrain(typeof(FavouriteList)); query.Descend("m_connParam").Descend("m_connection").Constrain(m_connParam.Connection); IObjectSet objSet = query.Execute(); if (objSet != null) { if (objSet.Count != 0) { FavList = (FavouriteList)objSet.Next(); } } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } return(FavList); }
internal FavouriteFolder FindFolderWithClassesByFolderName(string folderName) { FavouriteFolder favFolder = null; try { IQuery query = Db4oClient.OMNConnection.Query(); query.Constrain(typeof(FavouriteFolderList)); query.Descend("m_connParam").Descend("m_connection").Constrain(m_connParam.Connection); IQuery query1 = query.Descend("m_lstFavfolder").Descend("_items"); query1.Constrain(typeof(FavouriteFolder)); query1.Descend("m_folderName").Constrain(folderName); IObjectSet objSet = query1.Execute(); if (objSet.Count != 0) { favFolder = objSet.Next() as FavouriteFolder; } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } finally { Db4oClient.CloseRecentConnectionFile(); } return(favFolder); }
/// <summary> /// This event handler gets the Activated event of tool window. /// When db4o Browser opens for first time, it creates menu option under ObjectManager Enterprise menu. /// Using this menu option, user can get back to db4o Browser if he has closed it before. /// </summary> /// <param name="gotFocus"></param> /// <param name="lostFocus"></param> void OnWindowActivated(Window gotFocus, Window lostFocus) { try { if (oPopup != null) { if (gotFocus.Caption.Equals(Constants.DB4OBROWSER) && omObjectBrowserControl == null) { omObjectBrowserControlHandler = AddControlToToolbar(ref omObjectBrowserControl, Constants.DB4O_BROWSER_CAPTION); omObjectBrowserControlHandler.Click += omObjectBrowserControlHandler_Click; } else if (gotFocus.Caption.Equals(Constants.QUERYBUILDER) && omQueryBuilderControl == null) { omQueryBuilderControlHandler = AddControlToToolbar(ref omQueryBuilderControl, Constants.QUERY_BUILDER_CAPTION); omQueryBuilderControlHandler.Click += omQueryBuilderControlHandler_Click; } else if (gotFocus.Caption.Equals(Constants.DB4OPROPERTIES) && omPropertiesControl == null) { omPropertiesControlHandler = AddControlToToolbar(ref omPropertiesControl, Constants.PROPERTIES_TAB_CAPTION); omPropertiesControlHandler.Click += omPropertiesControlHandler_Click; } } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
private void CreateDemoDbMethod() { try { bw = new BackgroundWorker(); bw.WorkerSupportsCancellation = true; bw.WorkerReportsProgress = true; bw.ProgressChanged += bw_ProgressChanged; bw.DoWork += bw_DoWork; bw.RunWorkerCompleted += bw_RunWorkerCompleted; isrunning = true; bw.RunWorkerAsync(); for (double i = 1; i < 10000; i++) { i++; bw.ReportProgress((int)i * 100 / 1000); if (isrunning == false) { break; } } } catch (Exception oEx) { bw.CancelAsync(); bw = null; LoggingHelper.HandleException(oEx); } }
public List <TreeGridViewRenderer> TraverseObjTree(long id, string classname) { container = Db4oClient.Client; try { object currObj = Db4oClient.Client.Ext().GetByID(id); if (currObj != null) { container.Ext().Activate(currObj, 2); } IReflectClass refClass = DataLayerCommon.ReflectClassForName(DataLayerCommon.RemoveGFromClassName(classname)); if (refClass != null) { IReflectField[] fieldArr = DataLayerCommon.GetDeclaredFieldsInHeirarchy(refClass); TraverseFields(id, fieldArr); return(listTreeGridViewRenderers); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(null); } return(listTreeGridViewRenderers); }
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> /// <param term='application'>Root object of the host application.</param> /// <param term='connectMode'>Describes how the Add-in is being loaded.</param> /// <param term='addInInst'>Object representing this Add-in.</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(DTE2 application, ext_ConnectMode connectMode, AddIn addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; ViewBase.ResetToolWindowList(); OutputWindow.Initialize(_applicationObject); try { CreateMenu(); try { Events events = _applicationObject.Events; _windowsEvents = events.get_WindowEvents(null); _windowsEvents.WindowActivated += OnWindowActivated; _eve = _applicationObject.Events.DTEEvents; } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
public List <TreeGridViewRenderer> ExpandObjectNode(object obj, bool activate) { try { //object obj = Db4oClient.Client.Ext().GetByID(id); if (obj == null) { return(null); } IReflectClass rclass = DataLayerCommon.ReflectClassFor(obj); if (rclass == null) { return(null); } string classname = rclass.GetName(); if (classname != string.Empty) { TraverseObjTree(GetLocalID(obj), classname); } return(listTreeGridViewRenderers); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(null); } }
public TreeGridViewRenderer FillValuesInTreeGridViewRenderer(long id, string classname) { TreeGridViewRenderer treeGridViewRenderer = new TreeGridViewRenderer(); try { object currObj = Db4oClient.Client.Ext().GetByID(id); Db4oClient.Client.Ext().Activate(currObj, 1); IReflectClass rclass = DataLayerCommon.ReflectClassForName(classname); IType type = ResolveType(rclass); treeGridViewRenderer.QualifiedName = rclass.GetName(); treeGridViewRenderer.DisplayFieldName = AppendIDTo(type.FullName, id, type); treeGridViewRenderer.FieldName = type.FullName; treeGridViewRenderer.FieldValue = type.DisplayName; treeGridViewRenderer.FieldType = SetFieldType(type); treeGridViewRenderer.ReadOnlyStatus = true; treeGridViewRenderer.ObjectId = id; treeGridViewRenderer.ObjectType = type; } catch (Exception e) { LoggingHelper.HandleException(e); } return(treeGridViewRenderer); }
public List <TreeGridViewRenderer> PopulatePrimitiveValues(object currObj, string fieldType) { if (!String.IsNullOrEmpty(fieldType)) { try { TreeGridViewRenderer TreeviewRenderer = new TreeGridViewRenderer(); TreeviewRenderer.DisplayFieldName = fieldType; TreeviewRenderer.FieldName = TreeviewRenderer.DisplayFieldName; TreeviewRenderer.FieldValue = currObj.ToString(); TreeviewRenderer.QualifiedName = DataLayerCommon.RemoveGFromClassName(container.Ext().Reflector().ForObject(currObj).GetName()); TreeviewRenderer.FieldType = fieldType; TreeviewRenderer.ReadOnlyStatus = readOnly; TreeviewRenderer.ObjectId = 0; TreeviewRenderer.HasSubNode = false; listTreeGridViewRenderers.Add(TreeviewRenderer); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(null); } } return(listTreeGridViewRenderers); }
public static void SaveDataIfRequired() { try { if (HashClassGUID != null) { foreach (DictionaryEntry entry in HashClassGUID) { string winCaption = entry.Key.ToString(); string caption = GetCaption(winCaption); dbDataGridView dataGridView = ListofModifiedObjects.Instance[winCaption] as dbDataGridView; if (dataGridView != null) { ListofModifiedObjects.SaveBeforeWindowHiding(caption, dataGridView); ListofModifiedObjects.Instance.Remove(winCaption); } } } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
private void ConnectToDatabaseOrServer(CommandBarButton Ctrl) { try { Assembly assembly = Assembly.GetExecutingAssembly(); if (Ctrl.Caption.Equals(CONNECT)) { ViewBase.ApplicationObject = _applicationObject; Login.CreateLoginToolWindow(assembly); } else { Helper.SaveDataIfRequired(); dbCreateDemoDbControl.Enabled = true; AppDomain.Unload(Login.appDomain.workerAppDomain); Login.appDomain.workerAppDomain = null; AssemblyInspectorObject.ClearAll(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
internal void RemoveFolderfromDatabase(FavouriteFolder favFolder) { try { container = Db4oClient.RecentConn; FavouriteList favList = FetchAllFavouritesForAConnection(); List <FavouriteFolder> lstFavFolder = favList.lstFavFolder; bool check = false; FavouriteFolder temp = null; foreach (FavouriteFolder str in lstFavFolder) { if (str.FolderName.Equals(favFolder.FolderName)) { temp = str; check = true; break; } } if (check == true) { lstFavFolder.Remove(temp); favList.lstFavFolder = lstFavFolder; container.Delete(temp); container.Ext().Store(favList, 5); container.Commit(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
public static object ExecuteScalar(string sp, List <SqlParameter> parameters) { try { object retval = null; using (SqlConnection conn = GetConnection()) { conn.Open(); // Create a command and prepare it for execution using (SqlCommand cmd = GetCommand(conn, sp)) { cmd.CommandText = sp; if (parameters != null && parameters.Count > 0) { cmd.Parameters.AddRange(parameters.ToArray()); } retval = cmd.ExecuteScalar(); } } return(retval); } catch (Exception e) { LoggingHelper.Instance.AgregarLog(new LogSqlEntity("ExecuteScalar", sp, parameters, e)); LoggingHelper.HandleException(e); return(null); } }
internal void RemoveFavouritFolderForAConnection() { try { FavouriteList Fav = FetchAllFavouritesForAConnection(); if (Fav != null) { for (int i = 0; i < Fav.lstFavFolder.Count; i++) { FavouriteFolder favFolder = Fav.lstFavFolder[i]; if (favFolder != null) { container.Delete(favFolder); } } Fav.lstFavFolder.Clear(); Fav.m_TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis(); container.Delete(Fav); container.Ext().Store(Fav, 5); container.Commit(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
public static IDataReader ExecuteReader(string sp, List <SqlParameter> parameters) { try { IDataReader dr = null; SqlConnection conn = GetConnection(); { conn.Open(); // Create a command and prepare it for execution using (SqlCommand cmd = GetCommand(conn, sp)) { cmd.CommandText = sp; if (parameters != null && parameters.Count > 0) { cmd.Parameters.AddRange(parameters.ToArray()); } dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); } } return(dr); } catch (Exception e) { LoggingHelper.Instance.AgregarLog(new LogSqlEntity("ExecuteReader", sp, parameters, e)); LoggingHelper.HandleException(e); return(null); } }
internal void RemoveFavouritFolderForAConnection() { try { FavouriteFolderList Fav = FetchAllFavouritesForAConnection(); if (Fav != null) { foreach (FavouriteFolder favFolder in Fav.lstFavFolder.Where(favFolder => favFolder != null)) { Db4oClient.OMNConnection.Delete(favFolder); } Fav.lstFavFolder.Clear(); Fav.TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis(); Db4oClient.OMNConnection.Delete(Fav); Db4oClient.OMNConnection.Store(Fav); Db4oClient.OMNConnection.Commit(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } finally { Db4oClient.CloseRecentConnectionFile(); } }
internal List <string> ReturnStringList() { List <string> stringList = null; try { SearchStringList groupSearchList = FetchAllSearchStringsForAConnection(); if (groupSearchList != null) { CompareSearchStringTimestamps cmp = new CompareSearchStringTimestamps(); groupSearchList.ListSearchString.Sort(cmp); stringList = groupSearchList.ListSearchString.Select(str => str.SearchString).ToList(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } finally { Db4oClient.CloseRecentConnectionFile(); } return(stringList); }
public override string ToString() { string strClause = string.Empty; try { foreach (OMQueryClause om in m_listQueryClauses) { strClause = strClause + string.Format("{0} ", om.ToString()); } if (strClause != string.Empty) { string subStr = strClause.Substring(strClause.Length - 3, 3); if (subStr == "OR ") { strClause = strClause.Substring(0, strClause.Length - 3); } else { strClause = strClause.Substring(0, strClause.Length - 4); } strClause = string.Format("{0}({1}) ", GroupLogicalOperator, strClause); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } return(strClause); }
internal void RemovesSearchStringsForAConnection() { try { SearchStringList grpSearchString = FetchAllSearchStringsForAConnection(); if (grpSearchString != null) { foreach (SeachString sString in grpSearchString.ListSearchString.Where(sString => sString != null)) { Db4oClient.OMNConnection.Delete(sString); } grpSearchString.ListSearchString.Clear(); grpSearchString.TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis(); Db4oClient.OMNConnection.Store(grpSearchString); Db4oClient.OMNConnection.Commit(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } finally { Db4oClient.CloseRecentConnectionFile(); } }
public Hashtable StoredClasses() { Hashtable storedClassHashtable = new Hashtable(); try { IStoredClass[] storedClasses = Db4oClient.Client.Ext().StoredClasses(); foreach (IStoredClass stored in storedClasses) { string className = stored.GetName(); if (ExcludeClass(className)) { continue; } storedClassHashtable.Add(className, SimpleName(className)); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } return(storedClassHashtable); }
public Hashtable GetFields() { try { IReflectClass rClass = DataLayerCommon.ReflectClassForName(m_className); IReflectField[] rFields = DataLayerCommon.GetDeclaredFieldsInHeirarchy(rClass); Hashtable FieldList = new Hashtable(); foreach (IReflectField field in rFields) { if (!FieldList.ContainsKey(field.GetName())) { FieldList.Add( field.GetName(), field.GetFieldType().GetName()); } } return(FieldList); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(null); } }
public static List <FieldProperties> FieldsFrom(string className) { try { List <FieldProperties> listFieldProperties = new List <FieldProperties>(); ClassDetails clDetails = new ClassDetails(className); IReflectField[] fields = clDetails.GetFieldList(); if (fields == null) { return(null); } foreach (IReflectField field in clDetails.GetFieldList()) { if (!(field is GenericVirtualField || field.IsStatic())) { FieldProperties fp = FieldPropertiesFor(className, field); listFieldProperties.Add(fp); } } return(listFieldProperties); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(null); } }
public int GetFieldCount() { try { IReflectClass rClass = DataLayerCommon.ReflectClassForName(m_className); if (rClass != null) { string type1 = rClass.ToString(); type1 = DataLayerCommon.PrimitiveType(type1); char[] arr = CommonValues.charArray; type1 = type1.Trim(arr); if (!CommonValues.IsPrimitive(type1) && !type1.Contains(BusinessConstants.DB4OBJECTS_SYS)) { IReflectField[] rFields = DataLayerCommon.GetDeclaredFieldsInHeirarchy(rClass); return(rFields.Length); } } return(0); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return(0); } }
public void drillToObject(object parentobj, string attribute) { try { string fieldName = attribute; int intIndexof = fieldName.IndexOf('.') + 1; fieldName = fieldName.Substring(intIndexof, fieldName.Length - intIndexof); string[] splitstring = fieldName.Split('.'); object holdParentObject = parentobj; foreach (string str in splitstring) { if (holdParentObject != null) { holdParentObject = getClass(str, holdParentObject, attribute); if (holdParentObject == null) { break; } } } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }
internal void RemovesSearchStringsForAConnection() { try { GroupofSearchStrings grpSearchString = FetchAllSearchStringsForAConnection(); if (grpSearchString != null) { for (int i = 0; i < grpSearchString.m_SearchStringList.Count; i++) { SeachString sString = grpSearchString.m_SearchStringList[i]; //foreach (SeachString sString in grpSearchString.m_SearchStringList) if (sString != null) { //grpSearchString.m_SearchStringList.Remove(sString); container.Delete(sString); } } grpSearchString.m_SearchStringList.Clear(); grpSearchString.m_TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis(); container.Ext().Store(grpSearchString, 5); container.Commit(); } } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } }