コード例 #1
0
        public static StatScript GetStatScript(string statType, string scriptFilePath,
                                               string inputFilePath)
        {
            //used to test the post http (create) controller action in web api
            //client in DevTreks posts directly to create controller and doesn't use this at all
            StatScript testStat = new StatScript();

            testStat.Key  = Guid.NewGuid().ToString();
            testStat.Name = "GetStatScript";

            //make sure these exist
            testStat.DataURL   = inputFilePath;
            testStat.ScriptURL = scriptFilePath;
            if (statType == STAT_TYPE.py.ToString())
            {
                //py script
                testStat.StatType = StatScript.STAT_TYPE.py.ToString();
            }
            else if (statType == STAT_TYPE.julia.ToString())
            {
                //py script
                testStat.StatType = StatScript.STAT_TYPE.julia.ToString();
            }
            else
            {
                //r script
                testStat.StatType = StatScript.STAT_TYPE.r.ToString();
            }
            testStat.IsComplete = false;
            return(testStat);
        }
コード例 #2
0
        public static async Task <bool> ClientCreate(StatScript statScript)
        {
            bool bIsSuccess = false;
            // HTTP POST example
            HttpClient client = new HttpClient();

            var json = JsonConvert.SerializeObject(statScript);

            // Post statscript
            Uri address = new Uri(string.Concat(statScript.DefaultWebDomain, "api/statscript"));

            try
            {
                //create controller actionresult says this only returns a url
                //to the created statscript referenced in Location Header
                //needs the configure or returns without the results
                HttpResponseMessage response =
                    await client.PostAsync(address,
                                           new StringContent(json, Encoding.UTF8, "application/json")).ConfigureAwait(false);

                //can also use .PostAsJson(address, statScript) but requires Microsoft.AspNet.WebApi.Client.5.2.3 package

                // Check that response was successful or throw exception
                response.EnsureSuccessStatusCode();

                //the response body contains the json string result
                string statResult = JsonConvert.SerializeObject(response);
                if (!string.IsNullOrEmpty(statResult))
                {
                    string body = await response.Content.ReadAsStringAsync();

                    StatScript deserializedScript = JsonConvert.DeserializeObject <StatScript>(body);
                    statScript.StatisticalResult = deserializedScript.StatisticalResult;
                    if (!string.IsNullOrEmpty(statScript.StatisticalResult))
                    {
                        bIsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                statScript.ErrorMessage = ex.Message.ToString();
            }

            return(bIsSuccess);
        }
コード例 #3
0
 public StatScript(StatScript statScript)
 {
     this.Key                       = statScript.Key;
     this.Name                      = statScript.Name;
     this.DateCompleted             = statScript.DateCompleted;
     this.DataURL                   = statScript.DataURL;
     this.ScriptURL                 = statScript.ScriptURL;
     this.OutputURL                 = statScript.OutputURL;
     this.StatType                  = statScript.StatType;
     this.RExecutablePath           = statScript.RExecutablePath;
     this.PyExecutablePath          = statScript.PyExecutablePath;
     this.JuliaExecutablePath       = statScript.JuliaExecutablePath;
     this.DefaultRootFullFilePath   = statScript.DefaultRootFullFilePath;
     this.DefaultRootWebStoragePath = statScript.DefaultRootWebStoragePath;
     this.DefaultWebDomain          = statScript.DefaultWebDomain;
     this.StatisticalResult         = statScript.StatisticalResult;
     this.IsComplete                = statScript.IsComplete;
     this.IsDevelopment             = statScript.IsDevelopment;
     this.ErrorMessage              = statScript.ErrorMessage;
 }