从SmartObject中读取数据

作者:互联网   出处:控件中国网   2014-11-05 19:05:29   阅读:1

从SmartObject中读取数据

       //根据KEY ID从SmartObject中取数据
        private void LoadData(string argProInstanceID)
        {
            SourceCode.SmartObjects.Client.SmartObjectClientServer socs = new SourceCode.SmartObjects.Client.SmartObjectClientServer();
           
            // build a connection string
            SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
            connectionString.Authenticate = true;
            connectionString.Host = System.Configuration.ConfigurationManager.AppSettings["K2Server"];
            connectionString.Integrated = true;
            connectionString.IsPrimaryLogin = true;
            connectionString.Port = Convert.ToUInt32(System.Configuration.ConfigurationManager.AppSettings["HostServicePort"]);
            //connectionString.UserID = ";k2admin";
            //connectionString.Password = "******";
            connectionString.WindowsDomain = "dahanis";
            connectionString.SecurityLabelName = "K2";

            // open a K2 Server connection
            socs.CreateConnection();
            socs.Connection.Open(connectionString.ToString());
            try
            {
                // get a handle to the 'SODHFKSQ' SmartObject
                SourceCode.SmartObjects.Client.SmartObject so = socs.GetSmartObject("so_DHFKSQ");

                // specify which method will be called
                so.MethodToExecute = "Load";

                // specify input parameters for the method
                so.Properties["ProInstanceID"].Value = argProInstanceID;

                // call the method
                socs.ExecuteScalar(so);

                // note: if a method of type 'list' was specified, then the 'ExecuteList' method should be called
                // serverName.ExecuteList(smartObject);

                // read the return properties of the SmartObject
                Folio.Text = so.Properties["Folio"].Value;
                ApplyEmployee.Text = so.Properties["ApplyEmployee"].Value;
                ApplyAmount.Text = so.Properties["ApplyAmount"].Value;
                ApplyDate.Text = so.Properties["ApplyDate"].Value;
                HigherLevelApprover.Text = so.Properties["HigherLevelApprover"].Value;
                FinanceApprover.Text = so.Properties["FinanceApprover"].Value;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                // close the connection
                socs.Connection.Close();
            }
        }

 

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat