예제 #1
0
        public static DatabaseBrowserConfiguration GetDatabaseBrowserConfiguration(int packageId, string groupName)
        {
            DatabaseBrowserConfiguration config = new DatabaseBrowserConfiguration();

            int serviceId = PackageController.GetPackageServiceId(packageId, groupName);

            if (serviceId == 0)
            {
                return(config);
            }

            StringDictionary settings = ServerController.GetServiceSettings(serviceId);

            config.Enabled = !String.IsNullOrEmpty(settings["BrowseURL"]);

            return(config);
        }
예제 #2
0
        public static DatabaseBrowserConfiguration GetDatabaseBrowserLogonScript(int packageId,
                                                                                 string groupName, string username)
        {
            int serviceId = PackageController.GetPackageServiceId(packageId, groupName);

            if (serviceId == 0)
            {
                return(null);
            }

            StringDictionary settings = ServerController.GetServiceSettings(serviceId);
            string           url      = settings["BrowseURL"];
            string           method   = settings["BrowseMethod"];
            string           prms     = settings["BrowseParameters"];

            DatabaseBrowserConfiguration config = new DatabaseBrowserConfiguration();

            config.Enabled = !String.IsNullOrEmpty(url);
            config.Method  = method;

            prms = Utils.ReplaceStringVariable(prms, "server", settings["InternalAddress"]);

            // load database user
            SqlUser user = (SqlUser)PackageController.GetPackageItemByName(packageId, groupName, username, typeof(SqlUser));

            if (user != null)
            {
                prms = Utils.ReplaceStringVariable(prms, "user", username);
                prms = Utils.ReplaceStringVariable(prms, "password", CryptoUtils.Decrypt(user.Password));

                string[] lines = Utils.ParseDelimitedString(prms, '\n', '\r');

                StringBuilder sb = new StringBuilder();
                if (String.Compare(method, "get", true) == 0)
                {
                    // GET
                    sb.Append(url).Append("?");
                    foreach (string line in lines)
                    {
                        sb.Append(line).Append("&");
                    }

                    config.GetData = sb.ToString();
                }
                else
                {
                    // POST
                    sb.Append("<html><body>");
                    sb.Append("<form id=\"AspForm\" method=\"POST\" action=\"").Append(url).Append("\">");

                    foreach (string line in lines)
                    {
                        //
                        var indexOfSplit = line.IndexOf('=');
                        //
                        if (indexOfSplit == -1)
                        {
                            continue;
                        }
                        //
                        sb.Append("<input type=\"hidden\" name=\"").Append(line.Substring(0, indexOfSplit))
                        .Append("\" value=\"").Append(line.Substring(indexOfSplit + 1)).Append("\"></input>");
                    }

                    sb.Append("</form><script language=\"javascript\">document.getElementById(\"AspForm\").submit();</script>");
                    sb.Append("</body></html>");

                    config.PostData = sb.ToString();
                }
            }

            return(config);
        }