EAImvertor.EAImvertorJob.Upload C# (CSharp) Méthode

Upload() private méthode

private Upload ( string actionUrl, string pincode, string processName, string imvertorProperties, string modelFilePath, string historyFilePath, string propertiesFilePath ) : string
actionUrl string
pincode string
processName string
imvertorProperties string
modelFilePath string
historyFilePath string
propertiesFilePath string
Résultat string
        private string Upload(string actionUrl,string pincode, string processName, string imvertorProperties
		                                , string modelFilePath, string historyFilePath, string propertiesFilePath )
        {
            HttpContent processNameContent = new StringContent(processName);
            HttpContent propertiesContent = new StringContent(imvertorProperties);
            HttpContent pincodeContent = new StringContent(pincode);
            HttpContent modelFileContent = null;
            if (File.Exists(modelFilePath)) modelFileContent = new StreamContent(new FileStream(modelFilePath,FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            HttpContent historyFileContent = null;
            if (File.Exists(historyFilePath)) historyFileContent = new StreamContent(new FileStream(historyFilePath,FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            HttpContent propertiesFileContent = null;
            if (File.Exists(propertiesFilePath)) propertiesFileContent = new StreamContent(new FileStream(propertiesFilePath,FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            using (var client = settings.getHttpClient())
            {
                //this might solve an issue with the proxy then uploading content
                client.DefaultRequestHeaders.ExpectContinue = false;
                using (var formData = new MultipartFormDataContent())
                {
                    formData.Add(processNameContent, "procname");
                    formData.Add(propertiesContent, "properties");
                    if (modelFileContent != null) formData.Add(modelFileContent, "umlfile", "umlfile.zip");
                    if (historyFileContent != null) formData.Add(historyFileContent, "hisfile", "hisfile");
                    if (propertiesFileContent != null) formData.Add(propertiesFileContent, "propfile", "propfile.properties");
                    formData.Add(pincodeContent, "pin");
                    var response = client.PostAsync(actionUrl, formData).Result;
                    if (!response.IsSuccessStatusCode)
                    {
                        return string.Empty;
                    }
                    StreamReader reader = new StreamReader(response.Content.ReadAsStreamAsync().Result);
                    string responseText = reader.ReadToEnd();
                    XmlDocument xmlResponse = new XmlDocument();
                    xmlResponse.LoadXml(responseText);
                    var jobIDNode = xmlResponse.SelectSingleNode("//jobid");
                    if (jobIDNode != null)
                    {
                        return jobIDNode.InnerText;
                    }
                    else return string.Empty;
                }
            }
        }