import clr import sys clr.AddReference("Symyx.Framework") from Symyx.Framework.Vault import Workspace, VaultWorkspace, DataScope, RetrievalOptions, VaultId, VaultObjectTypes from Symyx.Framework.Vault.Security import Permissions 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 def GetPermission(application, permission): cid = 'ConfigurationVaultId' data = None ape = active_workspace.CurrentUser.ApplicationPermissions.GetApplicationPermissionFor(application, permission) if ape is not None and ape.ExtendedProperties.Contains(cid): vid = VaultId(ape.ExtendedProperties[cid].Value.ToString()) data = active_workspace.Get(vid, DataScope.All, RetrievalOptions.UseCachedVersionOffline) return data def GetPermissionData(appermission, name): reso = None if appermission is not None and not String.IsNullOrEmpty(name): for item in appermission: if item.Key == name: reso = item.Value.ToString().Replace("\r", "") break return reso assemblyLoaded = True proxy = None endpoint = None try: # This next line is only used if you are debugging an assembly. # This AddReference assumes that the SolutionCalc.dll is in perma = GetPermission('Recordati.Custom', 'Templates.LT') endpoint = GetPermissionData(perma, 'recnetWS') proxy = GetPermissionData(perma, 'recnetProxy') assembly = AssemblyCache.GetAssembly(proxy) clr.AddReference(assembly) from RecNetReg import RecNetIO #proxy = AssemblyCache.GetAssemblyFullName('AppHelpers') #assembly = AssemblyCache.GetAssembly(proxy) #clr.AddReference(assembly) #from AppHelpers import * except: assemblyLoaded = False errMsg = 'An error was encountered referencing a required assembly.' + proxy 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.SharedInstance(endpoint, userid) #recnet = RecNetIO() recnet.Initialize(endpoint, 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()