Exemple #1
0
        public static string GetSqlConnectionString(EsbProvider provider)
        {
            if (provider == null)
                throw new ApplicationException("系统不存在对应的业务系统!");

            if (string.IsNullOrEmpty(provider.DbServer) || string.IsNullOrEmpty(provider.DbName) || string.IsNullOrEmpty(provider.DBUserName))
                return string.Empty;

            string sqlConnection = string.Empty;
            if (provider.DbPort != "1433" && !string.IsNullOrEmpty(provider.DbPort))
                sqlConnection = string.Format("server={0},{1};uid={2};pwd={3};database={4}", provider.DbServer, provider.DbPort, provider.DBUserName, provider.DbPassword, provider.DbName);
            else
                sqlConnection = string.Format("server={0};uid={1};pwd={2};database={3}", provider.DbServer, provider.DBUserName, provider.DbPassword, provider.DbName);

            return sqlConnection;
        }
Exemple #2
0
        /// <summary>
        /// Get the SqlConnectionString
        /// </summary>
        /// <param name="provider"></param>
        /// <returns></returns>
        public string GetSqlConnectionString(EsbProvider provider)
        {
            string sqlConnection = string.Empty;
            if (provider.DbPort != "1433" && !string.IsNullOrEmpty(provider.DbPort))
                sqlConnection = string.Format("server={0},{1};uid={2};pwd={3};database={4}", provider.DbServer, provider.DbPort, provider.DBUserName, provider.DbPassword, provider.DbName);
            else
                sqlConnection = string.Format("server={0};uid={1};pwd={2};database={3}", provider.DbServer, provider.DBUserName, provider.DbPassword, provider.DbName);

            return Cryptography.Encode(sqlConnection);
        }
Exemple #3
0
        public JsonResult SaveProvider(EsbProvider provider)
        {
            if( provider == null )
                throw new ArgumentNullException("业务站点不能为空.");

            HttpResult hr = new HttpResult() { Result = true };
            Uri uri = new Uri(provider.Domain);
            provider.Protocol = uri.Scheme;
            provider.Port = uri.Port;
            provider.Domain = uri.Host;

            using( ConnectionScope scope = new ConnectionScope(TransactionMode.Required) ) {
                if( provider.ProviderID == Guid.Empty ) {
                    if( EntityCommon.IsExistData("Esb_Provider", "ProviderName", provider.ProviderName) ) {
                        hr.Result = false;
                        hr.ErrorMessage = "系统编码不允许重复,请重新录入系统编码!";
                        return new JsonResult(hr);
                        ;
                    }
                    provider.ProviderID = Guid.NewGuid();
                    provider.CreatedOn = DateTime.Now;
                    provider.Insert();
                } else {
                    provider.ModifiedOn = DateTime.Now;
                    provider.Update();
                }

                hr.KeyValue = provider.ProviderID.ToString();
                scope.Commit();
            }

            return new JsonResult(hr);
        }
 private string GetConnectionString(EsbProvider provider)
 {
     if (provider.DbPort == null || provider.DbPort == "1433")
     {
         return String.Format("Server={0};Database={1};User Id={2};Password={3}",
             provider.DbServer, provider.DbName, provider.DBUserName, provider.DbPassword);
     }
     else{
         return String.Format("Server={0},{1};Database={2};User Id={3};Password={4}",
             provider.DbServer, provider.DbPort, provider.DbName, provider.DBUserName, provider.DbPassword);
     }
 }