private bool CheckConnection(bool display) { bool result = false; var workflowManagementServer = new WorkflowManagementServer(); try { if (string.IsNullOrEmpty(txtServerName.Text) || string.IsNullOrEmpty(txtServerPort.Text.ToString())) { this.DisplayError("Enter servername and port", "ServerName or Port empty"); return(result); } ConnectionBuilder = new SCConnectionStringBuilder(); ConnectionBuilder.Host = txtServerName.Text; ConnectionBuilder.Port = uint.Parse(txtServerPort.Text); ConnectionBuilder.IsPrimaryLogin = true; ConnectionBuilder.Integrated = chkIntegratedSecurity.Checked; if (!string.IsNullOrEmpty(txtUserName.Text)) { if (string.IsNullOrEmpty(txtServerName.Text) || string.IsNullOrEmpty(txtServerPort.Text.ToString())) { this.DisplayError("Enter servername and port", "ServerName or Port empty"); return(result); } ConnectionBuilder.UserID = txtUserName.Text; ConnectionBuilder.Password = txtUserPassword.Text; ConnectionBuilder.SecurityLabelName = txtLabel.Text; ConnectionBuilder.WindowsDomain = txtDomain.Text; } workflowManagementServer.CreateConnection(); workflowManagementServer.Connection.Open(ConnectionBuilder.ConnectionString); if (display) { this.DisplayInfo("Connection to '" + txtServerName.Text + "' succeeded", "Connection succeeded"); } btnOK.Enabled = true; result = true; } catch (Exception ex) { this.DisplayError("Connection Failed to '" + txtServerName.Text + ":" + txtServerPort.Text + "' Message: " + ex.Message, "Connection Failed"); btnOK.Enabled = false; result = false; } finally { this.Stop(); workflowManagementServer?.Connection?.Dispose(); } return(result); }
public Boolean WorkItemAction(string serialno, string action) { //TODO - Move into K2 Helpers Connection K2Conn = new Connection(); SCConnectionStringBuilder K2ConnString = new SCConnectionStringBuilder(); //Setup Connection String K2ConnString.Host = "Win2012-K2"; K2ConnString.Integrated = false; K2ConnString.UserID = "Sa4Demo\\Tberry"; K2ConnString.Password = "******"; K2ConnString.Port = 5252; K2ConnString.WindowsDomain = "Sa4Demo"; K2ConnString.SecurityLabelName = "K2"; K2ConnString.Authenticate = true; K2ConnString.IsPrimaryLogin = true; K2Conn.Open("Win2012-K2", K2ConnString.ConnectionString); SourceCode.Workflow.Client.WorklistItem worklistItem = K2Conn.OpenWorklistItem(serialno); // action the workflow by executing the action if (worklistItem.Actions.Count > 0) { worklistItem.Actions[action].Execute(); return (true); } else { return (false); } }
public static SCConnectionStringBuilder[] GetAllServerConfiguration() { var servers = new List <SCConnectionStringBuilder>(); using (var userStorage = IsolatedStorageFile.GetUserStoreForAssembly()) { if (userStorage.GetFileNames(_k2ConfigFile).Contains(_k2ConfigFile)) { using (var userStream = new IsolatedStorageFileStream(_k2ConfigFile, FileMode.Open, userStorage)) using (var cryptostreamLoad = new CryptoStream(userStream, Decryptor(), CryptoStreamMode.Read)) { var xpathDoc = new XPathDocument(cryptostreamLoad); var xpathNavigator = xpathDoc.CreateNavigator(); var connections = xpathNavigator.Select("//connectionstring"); foreach (XPathNavigator connection in connections) { var server = new SCConnectionStringBuilder(connection.GetAttribute("connectionstring", string.Empty)); servers.Add(server); } } } } return(servers.ToArray()); }
public List<SA4Launcher.Models.WorklistItem> LoadWorkList() { Connection K2Conn = new Connection(); SCConnectionStringBuilder K2ConnString = new SCConnectionStringBuilder(); List<SA4Launcher.Models.WorklistItem> _currentWorkList = new List<SA4Launcher.Models.WorklistItem>(); //Setup Connection String K2ConnString.Host = "Sa4DemoK2wAD"; K2ConnString.Integrated = false; K2ConnString.UserID = "SA4Demo\\Tberry"; K2ConnString.Password = "******"; K2ConnString.Port = 5252; K2ConnString.WindowsDomain = "Sa4Demo"; K2ConnString.SecurityLabelName = "K2"; K2ConnString.Authenticate = false; K2ConnString.IsPrimaryLogin = true; K2Conn.Open("Sa4DemoK2wAD", K2ConnString.ConnectionString.ToString()); //TODO: Need to add try loop with true false return Worklist K2WorkList = K2Conn.OpenWorklist(); List<SA4Launcher.Models.Action> CurrentActions = new List<SA4Launcher.Models.Action>(); if (K2WorkList != null) { _currentWorkList.Clear(); foreach (SourceCode.Workflow.Client.WorklistItem K2worklistitem in K2WorkList) { //Build Actions First CurrentActions.Clear(); foreach (SourceCode.Workflow.Client.Action K2action in K2worklistitem.Actions) { CurrentActions.Add(new SA4Launcher.Models.Action { Name = K2action.Name, Batchable = K2action.Batchable }); } //Load worklist items into model _currentWorkList.Add(new SA4Launcher.Models.WorklistItem { ID = K2worklistitem.ID, serialno = K2worklistitem.SerialNumber, Name = K2worklistitem.ProcessInstance.Name, UserName = K2worklistitem.AllocatedUser, Folio = K2worklistitem.ProcessInstance.Folio, StartDate = K2worklistitem.ProcessInstance.StartDate, Status = K2worklistitem.Status.ToString(), ViewFlow = K2worklistitem.ProcessInstance.ViewFlow, Data = K2worklistitem.Data, Priority = K2worklistitem.ProcessInstance.Priority, Actions = CurrentActions.ToList() }); } } K2Conn.Close(); return (_currentWorkList); }
private void InitializeConnectionString() { _connectionString = new SCConnectionStringBuilder(); _connectionString.Host = _serverName; _connectionString.Port = _serverPort; _connectionString.IsPrimaryLogin = true; _connectionString.Integrated = true; }
private void cboRecentServers_SelectedIndexChanged(object sender, EventArgs e) { SCConnectionStringBuilder selectedServer = ((sender as ComboBox).SelectedItem as DisplayServer).ServerSetting; ConnectionBuilder = selectedServer; this.UpdateTextBoxes(); btnDelete.Enabled = true; }
public string GetSOConnectionString() { SCConnectionStringBuilder scConStr = new SCConnectionStringBuilder(_sessionConnectionString); SOConnectionStringBuilder soConStr = new SOConnectionStringBuilder() { Server = scConStr.Host, Port = Convert.ToInt32(scConStr.Port) }; return soConStr.ConnectionString; }
private string CreateConnectionString(string host, int port) { SCConnectionStringBuilder connBuilder = new SCConnectionStringBuilder(); connBuilder.Host = host; connBuilder.Port = (uint)port; connBuilder.IsPrimaryLogin = true; connBuilder.Integrated = true; return(connBuilder.ConnectionString); }
public static List<SmartObject> SmartObjectExplorer() { List<SmartObject> list = new List<SmartObject>(); SCConnectionStringBuilder hostServerConnectionString = new SCConnectionStringBuilder(); hostServerConnectionString.Host = "dlx"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Management.SmartObjectManagementServer smomgt = new SourceCode.SmartObjects.Management.SmartObjectManagementServer(); smomgt.CreateConnection(); try { smomgt.Connection.Open(hostServerConnectionString.ConnectionString.ToString()); SourceCode.SmartObjects.Management.SmartObjectExplorer smartobjects = smomgt.GetSmartObjects(); foreach (SourceCode.SmartObjects.Management.SmartObjectInfo info in smartobjects.SmartObjectList) { list.Add(new SmartObject { Description = info.Metadata.Description.ToString(), Name = info.Name, guid = info.Guid, ArtefactType = "SmartObject", displayname = info.Metadata.DisplayName, Version = info.Version.ToString(), Service = info.ServiceObjectName, ServiceGUID = info.ServiceInstanceGuid }); } } catch (Exception ex) { list.Add(new SmartObject { Description = ex.Message, Name = ex.Source, ArtefactType = "SmartObject Error" }); } finally { smomgt.Connection.Close(); } return list; }
public static string GetDisplayName(this SCConnectionStringBuilder connectionStringBuilder) { var displayName = $"{connectionStringBuilder.Host}:{connectionStringBuilder.Port}"; if (!string.IsNullOrEmpty(connectionStringBuilder.UserID)) { displayName = $"{displayName} - {connectionStringBuilder.UserID}"; } return(displayName.ToUpperInvariant()); }
private void btnDelete_Click(object sender, EventArgs e) { if (cboRecentServers.SelectedItem is DisplayServer) { SCConnectionStringBuilder serverSetting = (cboRecentServers.SelectedItem as DisplayServer).ServerSetting; var config = new ServerConfiguration(); config.Remove(serverSetting); cboRecentServers.Items.Remove(cboRecentServers.SelectedItem); } }
void IPartImportsSatisfiedNotification.OnImportsSatisfied() { // Called when all [Import]s have been resolved. var builder = new SCConnectionStringBuilder(); builder.Host = Dns.GetHostName(); builder.Integrated = true; builder.IsPrimaryLogin = true; builder.Port = _k2ServerPort; _k2ServerConnectionString = builder.ConnectionString; }
private static string GetConnectionString() { SCConnectionStringBuilder connectionStringBuilder = new SCConnectionStringBuilder { Host = ConfigurationManager.AppSettings["Host"], Port = Convert.ToUInt32(ConfigurationManager.AppSettings["Port"]), IsPrimaryLogin = true, Integrated = true }; return(connectionStringBuilder.ConnectionString); }
/* * /// <summary> * /// Method creates a SqlExecute object which only needs a SqlQuery and Parameters to be set. * /// </summary> * /// <returns></returns> * protected SqlExecute CreateDirectSqlExecute() * { * //SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();//BuildConnectionString(); * ServiceBroker.IsSqlExecute = true; * ServiceBroker.SqlQueryExecute = new SqlExecute(); * ServiceBroker.SqlQueryExecute.ServerName = string.Empty; //"DLX"; * ServiceBroker.SqlQueryExecute.Provider = string.Empty; //"SQLOLEDB"; * ServiceBroker.SqlQueryExecute.UserID = string.Empty; * ServiceBroker.SqlQueryExecute.Password = string.Empty; * * if (this.ServiceBroker.Service.ServiceConfiguration.ServiceAuthentication.AuthenticationMode == AuthenticationMode.SSO || * this.ServiceBroker.Service.ServiceConfiguration.ServiceAuthentication.AuthenticationMode == AuthenticationMode.Static) * { * ServiceBroker.SqlQueryExecute.UserID = this.ServiceBroker.Service.ServiceConfiguration.ServiceAuthentication.UserName; * ServiceBroker.SqlQueryExecute.Password = this.ServiceBroker.Service.ServiceConfiguration.ServiceAuthentication.Password; * } * else * { * ServiceBroker.SqlQueryExecute.IntegratedSecurity = true.ToString(); * } * * ServiceBroker.SqlQueryExecute.DifferentSQLServer = false; * * return ServiceBroker.SqlQueryExecute; * } */ #endregion Protected Methods and properties that are useful for the child class #region Private helper methods private string GetBaseConnection(uint port) { if (this.baseConnection == null) { this.baseConnection = new SCConnectionStringBuilder(); this.baseConnection.Authenticate = true; this.baseConnection.Host = "localhost"; //hardcoded, always connect to yourself. Works better on NLB environments. this.baseConnection.Integrated = true; this.baseConnection.IsPrimaryLogin = true; this.baseConnection.Port = port; } return(this.baseConnection.ToString()); }
private static string EnvionmentServerConnection(string environmentServer) { SCConnectionStringBuilder cb = new SCConnectionStringBuilder(); cb.Host = environmentServer; cb.Port = 5555; cb.Integrated = true; cb.IsPrimaryLogin = true; cb.Authenticate = true; cb.EncryptedPassword = false; string envionmentServerConnection = cb.ToString(); return(envionmentServerConnection); }
/// <summary> /// Builds the connection string /// </summary> /// <returns></returns> public static string ConnectToK2() { GetDetails(); SCConnectionStringBuilder connectionstring = new SCConnectionStringBuilder(); connectionstring.Host = _Server; connectionstring.Port = _Port; connectionstring.IsPrimaryLogin = true; connectionstring.Integrated = true; return(connectionstring.ToString()); }
private void recentServer_Click(object sender, EventArgs e) { SCConnectionStringBuilder selectedServer = (SCConnectionStringBuilder)(sender as ToolStripMenuItem).Tag; ServerConfiguration config = new ServerConfiguration(); config.CreateNewServerConfig(selectedServer); this.GetRecentServers(); K2Client.Instance.K2Config.HostServerConnectionString = selectedServer.ConnectionString; this.ChangeServerStatus(); SyncFromServer(); }
public void CreateNewServerConfig(SCConnectionStringBuilder hostServerConfig) { hostServerConfig.ThrowIfNull(nameof(hostServerConfig)); string name = hostServerConfig.GetDisplayName(); string connectionstring = hostServerConfig.ConnectionString; CreateIsolatedStorage(); using (var userStorage = IsolatedStorageFile.GetUserStoreForAssembly()) { XmlDocument k2ConfDoc = null; using (var userStream = new IsolatedStorageFileStream(_k2ConfigFile, FileMode.Open, userStorage)) using (var cryptostreamLoad = new CryptoStream(userStream, Decryptor(), CryptoStreamMode.Read)) { k2ConfDoc = new XmlDocument(); k2ConfDoc.Load(cryptostreamLoad); } using (var userStream = new IsolatedStorageFileStream(_k2ConfigFile, FileMode.Create, userStorage)) using (var cryptostream = new CryptoStream(userStream, Encryptor(), CryptoStreamMode.Write)) { try { var connectionStringsElement = k2ConfDoc.SelectSingleNode("/configuration/connectionstrings"); var currentNode = connectionStringsElement.SelectSingleNode(string.Format("connectionstring[@name='{0}']", name)); if (currentNode != null) { connectionStringsElement.RemoveChild(currentNode); } var connStringNode = k2ConfDoc.CreateElement("connectionstring"); connectionStringsElement.PrependChild(connStringNode); connStringNode.SetAttribute("name", name); connStringNode.SetAttribute("connectionstring", connectionstring); k2ConfDoc.Save(cryptostream); userStream.Flush(); } finally { k2ConfDoc = null; } } } }
/// <summary> /// Get Connection String Connect to K2. /// </summary> /// <returns>The connection string.</returns> private string GetConnectionString() { var hostServerConnectionString = new SCConnectionStringBuilder { Host = ConfigurationManager.AppSettings[ConstantValueService.K2_URL], Port = Convert.ToUInt32(ConfigurationManager.AppSettings[ConstantValueService.K2_MANAGEMENT_PORT]), IsPrimaryLogin = true, Integrated = false, UserID = ConfigurationManager.AppSettings[ConstantValueService.K2_ADMINUSERNAME], Password = ConfigurationManager.AppSettings[ConstantValueService.K2_ADMINPASSWORD], SecurityLabelName = ConfigurationManager.AppSettings[ConstantValueService.K2_SECURITYLABEL] }; return(hostServerConnectionString.ToString()); }
public static List<SmartObjectProperty> SmartObjectMethodsExplorer(Guid SmartObjectGUID) { List<SmartObjectProperty> list = new List<SmartObjectProperty>(); SCConnectionStringBuilder hostServerConnectionString = new SCConnectionStringBuilder(); hostServerConnectionString.Host = "dlx"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Management.SmartObjectManagementServer smomgt = new SourceCode.SmartObjects.Management.SmartObjectManagementServer(); smomgt.CreateConnection(); try { smomgt.Connection.Open(hostServerConnectionString.ConnectionString.ToString()); foreach (SourceCode.SmartObjects.Management.SmartMethodInfo info in smomgt.GetSmartObjectInfo(smomgt.GetSmartObjectDefinition(SmartObjectGUID).ToString()).Methods) { list.Add(new SmartObjectProperty { Description = info.Metadata.Description.ToString(), Name = info.Name, Type = info.Type.ToString(), Transaction = info.Transaction.ToString(), displayname = info.Metadata.DisplayName }); } } catch (Exception ex) { list.Add(new SmartObjectProperty { Description = ex.Message, Name = ex.Source, displayname = "SmartObject Property Error" }); } finally { smomgt.Connection.Close(); } return list; }
private static string GetServerConnectionSetup() { SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder(); connectionString.Authenticate = true; connectionString.Host = K2ServerName; connectionString.Integrated = true; connectionString.IsPrimaryLogin = true; connectionString.Port = 5555; connectionString.UserID = K2User; connectionString.Password = Password; connectionString.WindowsDomain = K2Domain; connectionString.SecurityLabelName = SecurityLabelName; return(connectionString.ConnectionString); }
public SmartObjectClientServer NewSmartObjectClientServer() { SCConnectionStringBuilder hostServerConnectionString = new SCConnectionStringBuilder(); hostServerConnectionString.Host = this.AppConfig.K2Server; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SmartObjectClientServer result = new SmartObjectClientServer(); result.CreateConnection(); //open the connection to the K2 server result.Connection.Open(hostServerConnectionString.ToString()); //return the SOClientServer object return(result); }
public K2ConnectionStringBuilder(string userID) { ConnSetup = new ConnectionSetup(); SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder(); connectionString.Authenticate = true; connectionString.Integrated = false; connectionString.IsPrimaryLogin = true; connectionString.EncryptedPassword = false; connectionString.Host = K2Environments.Host; connectionString.Port = K2Environments.Port; connectionString.SecurityLabelName = K2Environments.SecurityLabelName; connectionString.UserID = userID; connectionString.Password = "******"; ConnSetup.ConnectionString = connectionString.ToString(); }
private static SCConnectionStringBuilder GetSmOConnection() { SCConnectionStringBuilder scbuilder = new SCConnectionStringBuilder(); scbuilder.Authenticate = true; scbuilder.Host = "localhost"; scbuilder.Integrated = true; scbuilder.IsPrimaryLogin = true; scbuilder.Port = 5555; //scbuilder.WindowsDomain = "Denallix"; //scbuilder.UserID = "k2service"; //scbuilder.Password = "******"; //scbuilder.SecurityLabelName = "K2"; return(scbuilder); }
/// <summary> /// Aligns your expected user's context to the BaseAPIConnection /// </summary> /// <param name="connection">Your current BaseAPIConnection who's context will be alligned</param> /// <param name="k2Connection">The broker base.</param> internal static void ImpersonateSessionUser(this BaseAPIConnection connection, K2Connection k2Connection) { connection.ThrowIfNull("connection"); k2Connection.ThrowIfNull("k2Connection"); try { // Don't impersonate if the connection does not have a session cookie var sessionCookie = connection.GetPropertyValue("SessionCookie") as string; if (string.IsNullOrEmpty(sessionCookie)) { return; } // Don't impersonate if the session's FQN is the same as the expected user's FQN var activeSession = k2Connection.SessionManager.GetActiveSession(sessionCookie); activeSession.ThrowIfNull("activeSession"); if (string.Equals(k2Connection.UserName, activeSession.Owner.PrimaryCredential.FullyQualifiedName.FQN, StringComparison.OrdinalIgnoreCase)) { return; } // Don't impersonate if not integrated or connection has a password var builder = new SCConnectionStringBuilder(k2Connection.SessionConnectionString); if (!builder.Integrated || !string.IsNullOrEmpty(builder.Password)) { return; } //In A PTA scenario, you would have fallen back to the service account and we would have Authenticated you as the service account. //If we are in a PTA context we should call the ImpersonateSessionUserByName method to align this connetion's user to the expected user K2NEServiceBroker.SecurityManager.ImpersonateSessionUserByName(sessionCookie, k2Connection.UserName, ImpersonationType.PassThrough, true); } catch { if (connection != null) { connection.Dispose(); } throw; } }
public K2NotificationManager() { this.serverName = ConfigurationManager.AppSettings[Constants.ConfigurationConstants.K2Server]; var port = ConfigurationManager.AppSettings[Constants.ConfigurationConstants.K2Port]; this.connectionString = new SCConnectionStringBuilder { Authenticate = true, Host = ConfigurationManager.AppSettings[Constants.ConfigurationConstants.K2Host], Integrated = false, IsPrimaryLogin = true, Port = !string.IsNullOrWhiteSpace(port) ? Convert.ToUInt32(ConfigurationManager.AppSettings[Constants.ConfigurationConstants.K2Port]) : 5252, UserID = ConfigurationManager.AppSettings[Constants.ConfigurationConstants.K2UserName], //WindowsDomain = this.domain, Password = ConfigurationManager.AppSettings[Constants.ConfigurationConstants.K2Password], //SecurityLabelName = "K2" }; }
/// <summary> /// Connect to and open the SmartObject Client service of the K2 server. /// </summary> /// <returns>The SmartObjectClientServer connection</returns> private SmartObjectClientServer GetSmartObjectConnection() { var client = new SmartObjectClientServer(); client.CreateConnection(); // Connect to the K2 server var scConnectionString = new SCConnectionStringBuilder { Host = _settings.K2Server, Port = _settings.Port, IsPrimaryLogin = true, Integrated = true }; client.Connection.Open(scConnectionString.ConnectionString); return(client); }
public void Remove(SCConnectionStringBuilder hostServerConfig) { hostServerConfig.ThrowIfNull(nameof(hostServerConfig)); string name = hostServerConfig.GetDisplayName(); CreateIsolatedStorage(); using (var userStorage = IsolatedStorageFile.GetUserStoreForAssembly()) { XmlDocument k2ConfDoc = null; using (var userStream = new IsolatedStorageFileStream(_k2ConfigFile, FileMode.Open, userStorage)) using (CryptoStream cryptostreamLoad = new CryptoStream(userStream, Decryptor(), CryptoStreamMode.Read)) { k2ConfDoc = new XmlDocument(); k2ConfDoc.Load(cryptostreamLoad); } var deleteNode = k2ConfDoc.SelectSingleNode(string.Format("//configuration/connectionstrings/connectionstring[@name='{0}']", name)); if (deleteNode != null) { var connectionstringsNode = k2ConfDoc.SelectSingleNode("//configuration/connectionstrings"); connectionstringsNode.RemoveChild(deleteNode); using (var userStream = new IsolatedStorageFileStream(_k2ConfigFile, FileMode.Create, userStorage)) using (var cryptostream = new CryptoStream(userStream, Encryptor(), CryptoStreamMode.Write)) { try { k2ConfDoc.Save(cryptostream); userStream.Flush(); } finally { k2ConfDoc = null; } } } } }
public static DeploymentResults DeployProcess(Process process) { // Create a connection string SCConnectionStringBuilder connBuilder = new SCConnectionStringBuilder(); connBuilder.Host = "localhost"; connBuilder.Port = 5555; connBuilder.IsPrimaryLogin = true; connBuilder.Integrated = true; // Set up the deployment manager DeploymentManager deploymentMng = new DeploymentManager(); // The workflow management connection string points to the workflow server. // The SmartObject connection string points to the SmartObject server and is // required by the deployment because a SmartObject is created from the process. deploymentMng.WorkflowManagementConnectionString = connBuilder.ConnectionString; deploymentMng.SmartObjectConnectionString = connBuilder.ConnectionString; return(deploymentMng.Deploy(process)); }
public K2ConnectionStringBuilder(ServerType type) { switch (type) { case ServerType.UserRoleManager: SCConnectionStringBuilder builder = new SCConnectionStringBuilder() { Host = K2Environments.Host, Port = 5555, Integrated = true, IsPrimaryLogin = true, }; this.ConnectionString = builder.ToString(); break; } }
public static string GetDefaultHostServerConnectionString() { var builder = new SCConnectionStringBuilder(); builder.Host = Environment.MachineName; builder.Port = 5555; builder.IsPrimaryLogin = true; builder.Integrated = true; var connectionString = builder.ConnectionString; try { using (var environmentSettingsManager = new EnvironmentSettingsManager(false)) { environmentSettingsManager.ConnectionString = connectionString; environmentSettingsManager.InitializeSettingsManager(false); if (environmentSettingsManager.EnvironmentTemplates.Count <= 0) { environmentSettingsManager.ConnectToServer(); environmentSettingsManager.InitializeSettingsManager(true); environmentSettingsManager.Disconnect(); } if (environmentSettingsManager.CurrentEnvironment != null) { var smartObjectfield = (SmartObjectField)environmentSettingsManager.CurrentEnvironment.GetDefaultField(typeof(SmartObjectField)); if (smartObjectfield != null) { return(smartObjectfield.ConnectionString); } } } } catch { } return(connectionString); }
private static SmartObjectClientServer GetSOClientConnection() { SmartObjectClientServer soClient = new SmartObjectClientServer(); soClient.Connection = soClient.CreateConnection(); if (!soClient.Connection.IsConnected) { //use connection string builder to create connection string. SCConnectionStringBuilder connectionStr = new SCConnectionStringBuilder(); //set server info connectionStr.Host = _K2ServerName; connectionStr.Integrated = true; connectionStr.IsPrimaryLogin = true; connectionStr.Password = _Password; connectionStr.Port = 5555; connectionStr.UserID = _K2User; connectionStr.WindowsDomain = _K2Domain; connectionStr.SecurityLabelName = _SecurityLabelName; //open connection try { soClient.Connection.Open(connectionStr.ConnectionString); } catch { return(null); } } return(soClient); }
private static SCConnectionStringBuilder GetSmOConnection() { SCConnectionStringBuilder scbuilder = new SCConnectionStringBuilder(); scbuilder.Authenticate = true; scbuilder.Host = "localhost"; scbuilder.Integrated = true; scbuilder.IsPrimaryLogin = true; scbuilder.Port = 5555; //scbuilder.WindowsDomain = "Denallix"; //scbuilder.UserID = "k2service"; //scbuilder.Password = "******"; //scbuilder.SecurityLabelName = "K2"; return scbuilder; }
static void Main(string[] args) { SmartObjectClientServer server = new SmartObjectClientServer(); try { SCConnectionStringBuilder cb = new SCConnectionStringBuilder(); cb.Host = "DLX"; cb.Port = 5555; cb.Integrated = true; cb.IsPrimaryLogin = true; //Connect to server server.CreateConnection(); server.Connection.Open(cb.ToString()); //-------------------------- //Get the Employee //Get SmartObject Definition SmartObject employee = server.GetSmartObject("Employee"); //Set properties employee.Properties["ID"].Value = "2"; //Get the record employee.MethodToExecute = "FindEmployee"; server.ExecuteScalar(employee); System.Diagnostics.Trace.WriteLine( employee.Properties["FirstName"].Value); System.Diagnostics.Trace.WriteLine( employee.Properties["LastName"].Value); System.Diagnostics.Trace.WriteLine( employee.Properties["Email"].Value); } catch (Exception ex) { throw new Exception("Error Creating Request >> " + ex.Message); } }
private SourceCode.SmartObjects.Client.SmartObjectClientServer GetSmOServer() { SCConnectionStringBuilder ConnectionString = new SCConnectionStringBuilder(); ConnectionString.Authenticate = true; ConnectionString.IsPrimaryLogin = true; ConnectionString.Integrated = true; ConnectionString.Host = "localhost"; ConnectionString.Port = 5555; SourceCode.SmartObjects.Client.SmartObjectClientServer SmoClient = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); SmoClient.CreateConnection(); SmoClient.Connection.Open(ConnectionString.ConnectionString); return SmoClient; }
private SourceCode.SmartObjects.Management.SmartObjectManagementServer GetSmOMgmServer() { SCConnectionStringBuilder ConnectionString = new SCConnectionStringBuilder(); ConnectionString.Authenticate = true; ConnectionString.IsPrimaryLogin = true; ConnectionString.Integrated = true; ConnectionString.Host = "localhost"; ConnectionString.Port = 5555; SourceCode.SmartObjects.Management.SmartObjectManagementServer SmartObjectManagementSvr = new SourceCode.SmartObjects.Management.SmartObjectManagementServer(); SmartObjectManagementSvr.CreateConnection(); SmartObjectManagementSvr.Connection.Open(ConnectionString.ConnectionString); //ServiceManagementSvr = new ServiceManagementServer(); //ServiceManagementSvr.Connection = SmartObjectManagementSvr.Connection; return SmartObjectManagementSvr; }
private string GetBaseConnection(uint port) { if (this.baseConnection == null) { this.baseConnection = new SCConnectionStringBuilder(); this.baseConnection.Authenticate = true; this.baseConnection.Host = "localhost"; //hardcoded, always connect to yourself. Works better on NLB environments. this.baseConnection.Integrated = true; this.baseConnection.IsPrimaryLogin = true; this.baseConnection.Port = port; } return this.baseConnection.ToString(); }
private void ChangeServerStatus() { var connectionStringBuilder = new SCConnectionStringBuilder(K2Client.Instance.K2Config.HostServerConnectionString); tssServer.Text = connectionStringBuilder.GetDisplayName(); }
static void Main(string[] args) { //Get Form View Relation DataTable dtFormView = new DataTable(); dtFormView.Columns.Add("FormGUID", typeof(Guid)); dtFormView.Columns.Add("ViewGUID", typeof(Guid)); SCConnectionStringBuilder sb = new SCConnectionStringBuilder(); sb.Authenticate = true; sb.IsPrimaryLogin = true; sb.Integrated = true; sb.Host = "localhost"; sb.Port = 5555; SmartObjectClientServer socs = new SmartObjectClientServer(); socs.CreateConnection(); socs.Connection.Open(sb.ToString()); FormsManager fm = new FormsManager(sb.ToString()); FormExplorer fe = fm.GetForms(); foreach (FormInfo fi in fe.Forms) { Guid formGUID = fi.Guid; //Console.WriteLine("Form: " + fi.DisplayName); ViewExplorer ve = fm.GetViewsForForm(fi.Guid); foreach (ViewInfo vi in ve.Views) { DataRow dr = dtFormView.NewRow(); dr["FormGUID"] = formGUID; dr["ViewGUID"] = vi.Guid; dtFormView.Rows.Add(dr); } } //Get Form Process Relation DataTable dtFormProcess = new DataTable(); dtFormProcess.Columns.Add("ProcessName", typeof(string)); dtFormProcess.Columns.Add("FormGUID", typeof(Guid)); fe = fm.GetForms(); foreach (FormInfo fi in fe.Forms) { Guid formGUID = fi.Guid; IEnumerable<string> processes = fm.GetProcessesForForm(fi.Guid); foreach (var process in processes) { DataRow dr = dtFormProcess.NewRow(); dr["FormGUID"] = formGUID; dr["ProcessName"] = process; dtFormProcess.Rows.Add(dr); } } //Get View SMO Relation DataTable dtViewSMO = new DataTable(); dtViewSMO.Columns.Add("ViewGUID", typeof(Guid)); dtViewSMO.Columns.Add("SmartObjectGUID", typeof(Guid)); fe = fm.GetForms(); foreach (FormInfo fi in fe.Forms) { ViewExplorer ve = fm.GetViewsForForm(fi.Guid); foreach (ViewInfo vi in ve.Views) { Guid viewGUID = vi.Guid; foreach (Guid soGuid in fm.GetObjectsForView(vi.Guid)) { DataRow dr = dtViewSMO.NewRow(); dr["ViewGUID"] = viewGUID; dr["SmartObjectGUID"] = soGuid; dtViewSMO.Rows.Add(dr); } } } fm.Connection.Close(); socs.Connection.Close(); //Delete data from table string stmt = "Delete From FormViewDependency"; ExecuteNoneQuery(stmt, CommandType.Text); //Insert Form View Relation to table for(int i = 0; i < dtFormView.Rows.Count; i++) { DataRow dr = dtFormView.Rows[i]; stmt = @"INSERT INTO [dbo].[FormViewDependency] ([FormGUID] ,[ViewGUID]) VALUES ('" + dr["FormGUID"].ToString() + @"' ,'" + dr["ViewGUID"].ToString() + "')"; ExecuteNoneQuery(stmt, CommandType.Text); } //Delete data from table stmt = "Delete From FormProcessDependency"; ExecuteNoneQuery(stmt, CommandType.Text); //Insert Form Process Relation to table for (int i = 0; i < dtFormProcess.Rows.Count; i++) { DataRow dr = dtFormProcess.Rows[i]; stmt = @"INSERT INTO [dbo].[FormProcessDependency] ([FormGUID] ,[ProcessName]) VALUES ('" + dr["FormGUID"].ToString() + @"' ,'" + dr["ProcessName"].ToString() + "')"; ExecuteNoneQuery(stmt, CommandType.Text); } //Delete data from table stmt = "Delete From ViewSMODependency"; ExecuteNoneQuery(stmt, CommandType.Text); //Insert View SMO Relation to table for (int i = 0; i < dtViewSMO.Rows.Count; i++) { DataRow dr = dtViewSMO.Rows[i]; stmt = @"INSERT INTO [dbo].[ViewSMODependency] ([ViewGUID] ,[SmartObjectGUID]) VALUES ('" + dr["ViewGUID"].ToString() + @"' ,'" + dr["SmartObjectGUID"].ToString() + "')"; ExecuteNoneQuery(stmt, CommandType.Text); } //SmartObjectClientServer socs = new SmartObjectClientServer(); //socs.CreateConnection(); //socs.Connection.Open(sb.ToString()); //FormsManager fm = new FormsManager(sb.ToString()); //FormExplorer fe = fm.GetForms(); //foreach (FormInfo fi in fe.Forms) //{ // Console.WriteLine("Form: " + fi.DisplayName); // ViewExplorer ve = fm.GetViewsForForm(fi.Guid); // IEnumerable<string> x = fm.GetProcessesForForm(fi.Guid); // foreach (var y in x) // { // Console.WriteLine("Process: " + y); // } // foreach (ViewInfo vi in ve.Views) // { // Console.WriteLine("View: " + vi.DisplayName); // foreach(Guid soGuid in fm.GetObjectsForView(vi.Guid)) // { // try // { // SmartObject so = socs.GetSmartObject(soGuid); // Console.WriteLine("SmartObject: " + so.Name); // } // catch (Exception ex) // { // Console.WriteLine(ex.Message); // } // } // Console.WriteLine(); // } //} //fm.Connection.Close(); //socs.Connection.Close(); //Console.ReadLine(); }