public string GetRegularExpression(string control) { SmartObjectSMOConnection smoConnection = new SmartObjectSMOConnection(); smoConnection.GetSmartObjectDetails(); string Result = string.Empty; SmartObjectClientServer soServer = new SmartObjectClientServer(); soServer.CreateConnection(); try { soServer.Connection.Open(ConnectToK2()); SourceCode.SmartObjects.Client.SmartObject ControlExpressionLibrary = soServer.GetSmartObject(smoConnection.SmartObjectName); ControlExpressionLibrary.Properties[smoConnection.SmartObjectInputParameter].Value = control; ControlExpressionLibrary.MethodToExecute = smoConnection.SmartObjectMethod; soServer.ExecuteScalar(ControlExpressionLibrary); Result = ControlExpressionLibrary.Properties[smoConnection.SmartObjectProperty].Value; } catch (Exception ex) { Result = ex.Message; } finally { soServer.Connection.Close(); } return(Result); }
public SmartObjectSMOConnection GetSmartObjectDetails() { SmartObjectSMOConnection smo = new SmartObjectSMOConnection(); string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string xmlFileName = Path.Combine(assemblyFolder, "settings.xml"); if (File.Exists(xmlFileName)) { XmlDocument doc = new XmlDocument(); doc.Load(xmlFileName); smo. _SmartObjectName = doc.ChildNodes[1].ChildNodes[2].InnerText; _SmartObjectInputParameter = doc.ChildNodes[1].ChildNodes[3].InnerText; _SmartObjectMethod = doc.ChildNodes[1].ChildNodes[4].InnerText; _SmartObjectProperty = doc.ChildNodes[1].ChildNodes[5].InnerText; } else { throw new Exception("Can't find Settings.xml"); } return(smo); }