public bool DownloadLogAndLoss(WeightVersionModel weight, string destinationFolder) { try { if (string.IsNullOrEmpty(weight.LogPath) || string.IsNullOrEmpty(weight.LossFunctionPath)) { return(false); } var pk = new PrivateKeyFile(ApplicationConstant.PrivateKeyFilePath); //var folder = DateTime.Now.ToString(ApplicationConstant.DatetimeFormat); var destination = new DirectoryInfo(destinationFolder); var logPath = $"{ServerDetectConstant.ApiPath}/{weight.LogPath}"; var lossPath = $"{ServerDetectConstant.ApiPath}/{weight.LossFunctionPath}"; var detectSertver = CommonService.GetUrlDetectServer(); using (var client = new ScpClient(detectSertver, 22, ServerTrainConstant.Username, pk)) { client.Connect(); client.Download(logPath, destination); client.Download(lossPath, destination); client.Disconnect(); } } catch { return(false); } return(true); }
public WeightVersionModel GetWeightVersion(string classId) { var url = CommonService.GetUrlApi(); var client = new RestClient(url); var request = new RestRequest($"versions/{classId}/weights/weight-get-last-version", Method.GET); WeightVersionModel result = null; request.AddHeader("Authorization", UserLoginModel.AccessToken); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Charset", "utf-8"); request.AddHeader("Connection", "close"); var response = client.Execute <Customer>(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var resultContent = response.Content; var data = JsonConvert.DeserializeObject <WeightVersionEntity>(resultContent); result = _mapper.Map <WeightVersionModel>(data); } return(result); }