import clr import sys clr.AddReference("Symyx.Framework") from Symyx.Framework.Vault import VaultWorkspace from Symyx.Framework import Extensibility, UnitsHelper, UnitKey from Symyx.Framework.Chemistry import * from Symyx.Framework.Extensibility import * from System.Windows.Forms import DialogResult, MessageBox, MessageBoxButtons, MessageBoxIcon from System import String def FindSectionToUpdate(sectionName): for section in editor.Document.Sections: if(sectionName == section.Title): return section return None assemblyLoaded = True try: # This next line is only used if you are debugging an assembly. # This AddReference assumes that the SolutionCalc.dll is in # C:\Program Files\Symyx\Symyx Notebook\bin. Comment out this # line if you are loading the assembly from Vault. clr.AddReference("RecNetReg") # Uncomment the next two lines if you want to load the assembly # from Vault. You will need to match Version and PublicKeyToken # with those assigned to the DLL. # assembly = AssemblyCache.GetAssembly("IsMaterialLookup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=861ce1c5ef4a55b3") # clr.AddReference(assembly) from RecNetReg import * except: assemblyLoaded = False errMsg = 'An error was encountered referencing a required assembly.' MessageBox.Show(errMsg, 'Assembly Reference Error', MessageBoxButtons.OK, MessageBoxIcon.Error) if assemblyLoaded: # The calls to the custom assembly follow. The first line userid = VaultWorkspace.Current.CurrentUser.UserName section = editor.ActiveDocumentSection bckSection = FindSectionToUpdate('Background') conto = bckSection.View.Forms['BaseForm1'].Controls labno = conto['GroupBox1'].Controls['TextBox1'].Text recnet = RecNetIO() recnet.Initialize('drdisc', 'chem', 'chem', 'chem', userid) rows = section.GetSelectedRows() rowIndex = 0 for row in rows: zebatch = row.PropertySets["Rec_Reg"]["B_BatchCode"].Value if zebatch is None: MessageBox.Show('Please select a row with a valid batch code', 'Invalid batch code', MessageBoxButtons.OK, MessageBoxIcon.Error) else: reso = recnet.Register(zebatch) editor.RefreshView()