public int proc3(INSAppBase appBase) { String server, db, company, user; appBase.GetInfos(out server, out db, out company, out user); Debug.WriteLine("Hook.Proc3:" + server + " " + db + " " + company + " " + user); return(0); }
/// <summary> /// Initializes a new instance of the <see cref="NAVClient"/> class. /// </summary> /// <param name="navObject">The nav object from ROT.</param> public NAVClient(object navObject) { Debug.WriteLine("NAVClient.New:" + myId); watchers = new List <FileSystemWatcher>(); rotObject = navObject; appBase = (INSAppBase)navObject; application = navObject as INSApplication; hyperlink = navObject as INSHyperlink; if (appBase == null) { throw (new InvalidDataException(@"ROT Object is not NAV!")); } if (hyperlink != null) { do { int handle; try { hyperlink.GetNavWindowHandle(out handle); hwnd = new IntPtr(handle); uint res = Win32.User32.GetWindowThreadProcessId(hwnd, out processID); StringBuilder text = new StringBuilder(1000); int res2 = Win32.User32.GetWindowText(hwnd, text, 1000); //if (text.ToString().IndexOf("TFS TRACKED") == -1) // Win32.User32.SetWindowText(hwnd, "TFS TRACKED " + text); } catch (Exception) { Thread.Sleep(500); } } while (hwnd == IntPtr.Zero); } appBase.GetInfos(out serverName, out databaseName, out companyName, out userName); }
public static void CheckInterface(object obj) { IObjectDesigner designer = obj as IObjectDesigner; Debug.WriteLineIf(designer != null, "Is IObjectDesigner");//* INSCallbackEnum callbackEnum = obj as INSCallbackEnum; Debug.WriteLineIf(callbackEnum != null, "Is INSCallbackEnum"); INSRec rec = obj as INSRec; Debug.WriteLineIf(rec != null, "Is INSRec"); INSAppBase appBase = obj as INSAppBase; Debug.WriteLineIf(appBase != null, "Is INSAppBase");//* INSApplication app = obj as INSApplication; Debug.WriteLineIf(app != null, "Is INSApplication");//* INSForm form = obj as INSForm; Debug.WriteLineIf(form != null, "Is INSForm"); INSHook hook = obj as INSHook; Debug.WriteLineIf(hook != null, "Is INSHook"); INSHyperlink hyper = obj as INSHyperlink; Debug.WriteLineIf(hyper != null, "Is INSHyperlink");//* INSMenuButton menub = obj as INSMenuButton; Debug.WriteLineIf(menub != null, "Is INSMenuButton"); INSTable table = obj as INSTable; Debug.WriteLineIf(table != null, "Is INSTable"); IConnectionPointContainer conn = obj as IConnectionPointContainer; Debug.WriteLineIf(conn != null, "Is IConnectionPointContainer"); }
//private const string ObjectDesignerGuid = "50000004-0000-1000-0001-0000836BD2D2"; public ObjectDesignerTest() { Hashtable runningObjects = GetActiveObjectList(DefaultMonikerName); foreach (DictionaryEntry de in runningObjects) { string progId = de.Key.ToString(); if (progId.IndexOf("{") != -1) { // Convert a class id into a friendly prog Id progId = ConvertClassIdToProgId(de.Key.ToString()); } object getObj = GetActiveObject(progId); if (getObj != null) { INSApplication app = getObj as INSApplication; IObjectDesigner objDis = getObj as IObjectDesigner; INSAppBase appBase = getObj as INSAppBase; INSHyperlink hyp = getObj as INSHyperlink; //Debug.WriteLine("App.="+app.GetType().FullName); if (hyp != null) { int handle; hyp.GetNavWindowHandle(out handle); Debug.WriteLine("WindowHandle=" + handle.ToString()); } if (appBase != null) { int res = 0; try { //res = appBase.Error("What<???"); } catch (Exception) {} //appBase.proc6(); //appBase.GetInfos(out a, out b,out c, out d); Debug.WriteLine("Appbase="); Debug.Indent(); Debug.WriteLine("res=" + res); //Debug.WriteLine("b=" + b); //Debug.WriteLine("c=" + c); //Debug.WriteLine("d=" + d); Debug.Unindent(); } if (objDis != null) { String version; int res = objDis.GetDatabaseName(out version); Debug.WriteLine("ObjDis=" + version); } if (app != null) { INSForm form; Debug.WriteLine("appGetform=" + app.GetForm(out form).ToString()); String hyperlink; if (form != null) { form.GetID(out hyperlink); /*form.GetButtons(out button); * if (button != null) * { * //button.proc3("Run"); * //button.proc4(0,"MyButtonB","MyButtonC"); * //Debug.WriteLine("Button="+button. * } * */ INSRec rec; CallBack callback = new CallBack(); form.GetRec(out rec); rec.EnumFieldValues(callback); Debug.WriteLine("form=" + form.ToString()); if (hyperlink != null) { Debug.WriteLine("FormID=" + hyperlink); } } } //this._objectDesigner = getObj as IObjectDesigner; } else { //Console.WriteLine("!!!!!FAILED TO fetch: " + progId); } } /* * if (this._objectDesigner == null) * { * throw new Exception("Could not connect to Dynamics NAV"); * } * */ }