Esempio n. 1
0
        public UserAD GetByFQN(string userFQN)
        {
            UserAD result = null;

            if (userFQN.Length > 3)
            {
                K2Services svcK2 = new K2Services();
                svcK2.AppConfig = this.AppConfig;
                SmartObjectClientServer soServer = svcK2.NewSmartObjectClientServer();

                using (soServer.Connection)
                {
                    string soName     = this.AppConfig.SmartObjectName_ADUser;
                    string methodName = "GetUserDetails";
                    //load the SmartObject from the server.
                    SmartObject soAD_User = soServer.GetSmartObject(soName);

                    soAD_User.MethodToExecute = methodName;
                    //this particular method has an input parameter for the UserName
                    // Assign Input properties
                    soAD_User.Methods[methodName].InputProperties["UserName"].Value = userFQN.Right(userFQN.Length - 3);

                    soAD_User = soServer.ExecuteScalar(soAD_User);

                    result             = new UserAD();
                    result.Name        = soAD_User.Properties["Name"].Value;
                    result.DisplayName = soAD_User.Properties["DisplayName"].Value;
                    result.Email       = soAD_User.Properties["Email"].Value;
                }
            }
            return(result);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="soname">Smart Object Name</param>
        /// <param name="method">Method</param>
        /// <param name="properties">Input Properties</param>
        /// <returns></returns>
        public static void SOExecuteScalar(string soname, string method, NameValueCollection properties)
        {
            SmartObjectClientServer soClient = null;

            try
            {
                // get connection to smartobject Server
                soClient = GetSOClientConnection();

                // get smartobject
                SmartObject SO = soClient.GetSmartObject(soname);

                if (properties != null)
                {
                    for (int i = 0; i < properties.Count; i++)
                    {
                        string key = properties.GetKey(i).ToString();
                        if (properties[key] != null && !string.IsNullOrEmpty(properties[key]))
                        {
                            string value = properties[key].ToString();
                            //SO.ListMethods[method].InputProperties[key].Value = value;
                            SO.Properties[key].Value = value;
                        }
                    }
                }

                SO.MethodToExecute = method;

                soClient.ExecuteScalar(SO);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // close connection
                if (soClient != null)
                {
                    soClient.Connection.Close();
                }
            }
        }
        public static string CreateDataFromPDFForm(string smartobjectName, string method, string returnProperty, Data.PDFInfo info, Dictionary<string, Data.PDFField> fields)
        {
            SourceCode.SmartObjects.Client.SmartObject smoReturn = null;
            SmartObjectClientServer smoSvr = new SmartObjectClientServer();

            Dictionary<string, string> Settings = new Dictionary<string, string>();
            string returnId = string.Empty;

            try
            {
                smoSvr.CreateConnection();
                smoSvr.Connection.Open(GetSmOConnection().ToString());

                SourceCode.SmartObjects.Client.SmartObject smoParam = smoSvr.GetSmartObject(smartobjectName);

                foreach (KeyValuePair<string, Data.PDFField> field in fields)
                {
                    smoParam.Properties[field.Key.Replace(" ", "_")].Value = field.Value.FieldValue;
                }

                smoParam.MethodToExecute = method;

                smoReturn = smoSvr.ExecuteScalar(smoParam);

                returnId = smoReturn.Properties[returnProperty].Value;

            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (smoSvr.Connection.IsConnected)
                {
                    smoSvr.Connection.Close();
                }
                smoSvr.Connection.Dispose();
            }
            return returnId;
        }
        public static Dictionary<string, string> GetAllSettings(string[] SettingKeys)
        {
            SourceCode.SmartObjects.Client.SmartObject smoReturn = null;
            SmartObjectClientServer smoSvr = new SmartObjectClientServer();

            Dictionary<string, string> Settings = new Dictionary<string, string>();

            try
            {
                smoSvr.CreateConnection();
                smoSvr.Connection.Open(GetSmOConnection().ToString());

                foreach (string setting in SettingKeys)
                {
                    SourceCode.SmartObjects.Client.SmartObject smoParam = smoSvr.GetSmartObject("K2_Generic_Settings_Shared_Setting");
                    smoParam.Properties["SectionName"].Value = "Yammer";
                    smoParam.Properties["SettingKey"].Value = setting;
                    smoParam.MethodToExecute = "Load";

                    smoReturn = smoSvr.ExecuteScalar(smoParam);

                    Settings.Add(setting, GetValue(smoReturn));
                    smoReturn = null;
                }

            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (smoSvr.Connection.IsConnected)
                {
                    smoSvr.Connection.Close();
                }
                smoSvr.Connection.Dispose();
            }
            return Settings;
        }
        public static string CreateDataFromPDFForm(string smartobjectName, string method, string returnProperty, Data.PDFInfo info, Dictionary <string, Data.PDFField> fields)
        {
            SourceCode.SmartObjects.Client.SmartObject smoReturn = null;
            SmartObjectClientServer smoSvr = new SmartObjectClientServer();

            Dictionary <string, string> Settings = new Dictionary <string, string>();
            string returnId = string.Empty;

            try
            {
                smoSvr.CreateConnection();
                smoSvr.Connection.Open(GetSmOConnection().ToString());

                SourceCode.SmartObjects.Client.SmartObject smoParam = smoSvr.GetSmartObject(smartobjectName);

                foreach (KeyValuePair <string, Data.PDFField> field in fields)
                {
                    smoParam.Properties[field.Key.Replace(" ", "_")].Value = field.Value.FieldValue;
                }

                smoParam.MethodToExecute = method;

                smoReturn = smoSvr.ExecuteScalar(smoParam);

                returnId = smoReturn.Properties[returnProperty].Value;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (smoSvr.Connection.IsConnected)
                {
                    smoSvr.Connection.Close();
                }
                smoSvr.Connection.Dispose();
            }
            return(returnId);
        }
        public static Dictionary <string, string> GetAllSettings(string[] SettingKeys)
        {
            SourceCode.SmartObjects.Client.SmartObject smoReturn = null;
            SmartObjectClientServer smoSvr = new SmartObjectClientServer();

            Dictionary <string, string> Settings = new Dictionary <string, string>();

            try
            {
                smoSvr.CreateConnection();
                smoSvr.Connection.Open(GetSmOConnection().ToString());

                foreach (string setting in SettingKeys)
                {
                    SourceCode.SmartObjects.Client.SmartObject smoParam = smoSvr.GetSmartObject("K2_Generic_Settings_Shared_Setting");
                    smoParam.Properties["SectionName"].Value = "Yammer";
                    smoParam.Properties["SettingKey"].Value  = setting;
                    smoParam.MethodToExecute = "Load";

                    smoReturn = smoSvr.ExecuteScalar(smoParam);

                    Settings.Add(setting, GetValue(smoReturn));
                    smoReturn = null;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (smoSvr.Connection.IsConnected)
                {
                    smoSvr.Connection.Close();
                }
                smoSvr.Connection.Dispose();
            }
            return(Settings);
        }
        public static string GetSettingValue(string section, string key)
        {
            SourceCode.SmartObjects.Client.SmartObject smoReturn = null;

            SmartObjectClientServer smoSvr = new SmartObjectClientServer();

            try
            {
                smoSvr.CreateConnection();
                smoSvr.Connection.Open(GetSmOConnection().ToString());

                SourceCode.SmartObjects.Client.SmartObject smoParam = smoSvr.GetSmartObject("K2_Generic_Settings_Shared_Setting");

                smoParam.Properties["SectionName"].Value = section;
                smoParam.Properties["SettingKey"].Value  = key;

                smoParam.MethodToExecute = "Load";

                smoReturn = smoSvr.ExecuteScalar(smoParam);

                if (smoReturn.IsEmpty)
                {
                    return("");
                }
                else
                {
                    return(smoReturn.Properties["SettingValue"] != null ? smoReturn.Properties["SettingValue"].Value : "");
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                smoSvr.Connection.Close();
                smoSvr.Connection.Dispose();
            }
        }
Esempio n. 9
0
        public void RetryWorkflow()
        {
            SmartObjectClientServer soServer = this.NewSmartObjectClientServer();

            try
            {
                using (soServer.Connection)
                {
                    SmartObject soError = soServer.GetSmartObject("com_K2_System_Workflow_SmartObject_ErrorLog");
                    //set method we want to execute.
                    soError.MethodToExecute = "GetErrorLogs";
                    soError.Properties["ErrorProfileName"].Value = "All";

                    //get the list of SmartObjects returned by the method
                    SmartObjectList soListError = soServer.ExecuteList(soError);
                    //iterate over the collection

                    List <K2ErrorLog> listK2ErrorLog = new List <K2ErrorLog>();
                    string[]          workflowNames  = this.AppConfig.WorkflowNames.Split(';');
                    foreach (SmartObject soItem in soListError.SmartObjectsList)
                    {
                        for (int i = 0; i < workflowNames.Length; i++)
                        {
                            if (soItem.Properties["ProcessName"].Value == workflowNames[i])
                            {
                                string soDescription = soItem.Properties["Description"].Value.ToString();
                                if (soDescription.Contains("was deadlocked on lock resources with another process") ||
                                    soDescription.Contains("SQL") ||
                                    soDescription.Contains("IIF"))
                                {
                                    listK2ErrorLog.Add(new K2ErrorLog(soItem));
                                }
                            }
                        }
                        //ambil hanya transaksi deadlocked saja
                    }

                    foreach (K2ErrorLog k2ErrorLog in listK2ErrorLog)
                    {
                        SmartObject errorSO = soServer.GetSmartObject("com_K2_System_Workflow_SmartObject_ErrorLog");
                        //set method we want to execute.
                        errorSO.MethodToExecute = "RetryError";

                        errorSO.Properties["Id"].Value         = k2ErrorLog.Id.ToString();
                        errorSO.Properties["ProcInstId"].Value = k2ErrorLog.ProcInstID.ToString();
                        errorSO.Properties["TypeId"].Value     = k2ErrorLog.TypeID.ToString();
                        errorSO.Properties["ObjectId"].Value   = k2ErrorLog.ObjectID.ToString();
                        errorSO.Properties["UserName"].Value   = "System";

                        this.Logger.Info("K2 Retry ProcInstId = " + k2ErrorLog.ProcInstID.ToString());

                        //get the list of SmartObjects returned by the method
                        Thread.Sleep(1000); //delay 1 detik
                        soServer.ExecuteScalar(errorSO);
                    }
                }
            }
            finally
            {
                soServer.DeleteConnection();
            }
        }
Esempio n. 10
0
        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);

            }
        }
Esempio n. 11
0
 public virtual SmartObject ExecuteScalar(SmartObject smartObject)
 {
     return(_serviceClientServer.ExecuteScalar(smartObject));
 }
Esempio n. 12
0
        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);
            }
        }
        public static string GetSettingValue(string section, string key)
        {
            SourceCode.SmartObjects.Client.SmartObject smoReturn = null;

            SmartObjectClientServer smoSvr = new SmartObjectClientServer();
            try
            {
                smoSvr.CreateConnection();
                smoSvr.Connection.Open(GetSmOConnection().ToString());

                SourceCode.SmartObjects.Client.SmartObject smoParam = smoSvr.GetSmartObject("K2_Generic_Settings_Shared_Setting");

                smoParam.Properties["SectionName"].Value = section;
                smoParam.Properties["SettingKey"].Value = key;

                smoParam.MethodToExecute = "Load";

                smoReturn = smoSvr.ExecuteScalar(smoParam);

                if (smoReturn.IsEmpty)
                {
                    return "";
                }
                else
                {
                    return smoReturn.Properties["SettingValue"] != null ? smoReturn.Properties["SettingValue"].Value : "";
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                smoSvr.Connection.Close();
                smoSvr.Connection.Dispose();
            }
        }