예제 #1
0
        /// <summary>
        /// Builds up the POST data for editing a resource
        /// </summary>
        /// <param name="resourceType"></param>
        /// <param name="rm"></param>
        /// <returns></returns>
        public static string BuildStudioEditPayload(string resourceType, IResourceModel rm)
        {
            StringBuilder result  = new StringBuilder();
            string        resType = string.Empty;

            // add service type
            result.Append(ResourceKeys.Dev2ServiceType);
            result.Append("=");
            result.Append(resType);

            // add service name
            result.Append("&");
            result.Append(ResourceKeys.Dev2ServiceName);
            result.Append("=");
            result.Append(rm.ResourceName);

            // add category
            result.Append("&");
            result.Append(ResourceKeys.Dev2Category);
            result.Append("=");
            result.Append(rm.Category);

            // add help
            result.Append("&");
            result.Append(ResourceKeys.Dev2Help);
            result.Append("=");
            result.Append(rm.HelpLink); // rm.HelpLink

            // add icon
            result.Append("&");
            result.Append(ResourceKeys.Dev2Icon);
            result.Append("=");
            result.Append(rm.IconPath);

            // add comment
            result.Append("&");
            result.Append(ResourceKeys.Dev2Description);
            result.Append("=");
            result.Append(rm.Comment);

            // add tags
            result.Append("&");
            result.Append(ResourceKeys.Dev2Tags);
            result.Append("=");
            result.Append(rm.Tags);

            string serviceDef = string.Empty; //rm.ServiceDefinition;

            if (serviceDef.IndexOf(" SourceName=", StringComparison.Ordinal) > 0)
            {
                // we have
                string sourceName   = DataListUtil.ExtractAttribute(serviceDef, "Action", "SourceName");
                string sourceMethod = DataListUtil.ExtractAttribute(serviceDef, "Action", "SourceMethod");

                // add source method
                result.Append("&");
                result.Append(ResourceKeys.Dev2SourceMethod);
                result.Append("=");
                result.Append(sourceMethod);

                // add source name
                result.Append("&");
                result.Append(ResourceKeys.Dev2SourceName);
                result.Append("=");
                result.Append(sourceName);

                result.Append("&");
                result.Append(ResourceKeys.Dev2StudioExe);
                result.Append("=");
                result.Append("yes");
            }
            else if (serviceDef.IndexOf("<Source", StringComparison.Ordinal) >= 0)
            {
                // we have a source to process
                if (resType == "Plugin")
                {
                    result.Append("&");
                    result.Append(ResourceKeys.Dev2SourceManagementSource);
                    result.Append("=");
                    result.Append(rm.ResourceName);
                }
                else if (resType == "Database")
                {
                    result.Append("&");
                    result.Append(ResourceKeys.Dev2SourceManagementDatabaseSource);
                    result.Append("=");
                    result.Append(rm.ResourceName);
                }

                result.Append("&");
                result.Append(ResourceKeys.Dev2SourceName);
                result.Append("=");
                result.Append(rm.ResourceName);

                result.Append("&");
                result.Append(ResourceKeys.Dev2StudioExe);
                result.Append("=");
                result.Append("yes");
            }

            return(result.ToString());
        }