Exemple #1
0
        public void AutoDeploy()
        {
            System.Reflection.Assembly thisExe;
            thisExe = System.Reflection.Assembly.GetEntryAssembly();
            string[] resources = thisExe.GetManifestResourceNames();

            if (resources.Length == 0)
            {
                return;
            }

            // TODO: Verify if this is the correct way of doing it:
            String assemblyBaseName = thisExe.GetName().Name;

            List <object> files = new List <object>();

            foreach (string resource in resources)
            {
                // TODO Check if Camunda relevant (BPMN, DMN, HTML Forms)

                // Read and add to Form for Deployment
                Stream resourceAsStream = thisExe.GetManifestResourceStream(resource);
                byte[] resourceAsBytearray;
                using (MemoryStream ms = new MemoryStream())
                {
                    resourceAsStream.CopyTo(ms);
                    resourceAsBytearray = ms.ToArray();
                }

                String fileLocalName = resource.Replace(assemblyBaseName + ".", "");
                files.Add(new FormUpload.FileParameter(resourceAsBytearray, fileLocalName));

                Console.WriteLine("Adding resource to deployment: " + resource);
            }
            Dictionary <string, object> postParameters = new Dictionary <string, object>();

            postParameters.Add("deployment-name", assemblyBaseName);
            postParameters.Add("deployment-source", "C# Process Application");
            postParameters.Add("enable-duplicate-filtering", "true");
            postParameters.Add("data", files);

            // Create request and receive response
            string          postURL     = helper.RestUrl + "deployment/create";
            HttpWebResponse webResponse = FormUpload.MultipartFormDataPost(postURL, helper.RestUsername, helper.RestPassword, postParameters);

            Console.WriteLine("Deployment to Camunda BPM succeeded.");
        }
        public string Deploy(string deploymentName, List <object> files)
        {
            Dictionary <string, object> postParameters = new Dictionary <string, object>();

            postParameters.Add("deployment-name", deploymentName);
            postParameters.Add("deployment-source", "C# Process Application");
            postParameters.Add("enable-duplicate-filtering", "true");
            postParameters.Add("data", files);

            // Create request and receive response
            string          postURL     = helper.RestUrl + "deployment/create";
            HttpWebResponse webResponse = FormUpload.MultipartFormDataPost(postURL, helper.RestUsername, helper.RestPassword, postParameters);

            using (var reader = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8))
            {
                var deployment = JsonConvert.DeserializeObject <Deployment>(reader.ReadToEnd());
                return(deployment.Id);
            }
        }