Exemplo n.º 1
0
 /// <summary>
 /// Update Execise Video To Fitcom sprout server
 /// </summary>
 /// <param name="sPath"></param>
 /// <param name="exerciseId"></param>
 /// <param name="sproudId"></param>
 private void UpdateExeciseVideoToFitcom(string sPath, int exerciseId, string sproudId)
 {
     try
     {
         GetSingleExeciseVideo();
         using (WebClient httpWebClient = new WebClient())
         {
             httpWebClient.Headers[ConstantHelper.constSproutVideoApiKey] = ConstantHelper.constSproutVideoApiKeyValue;
             httpWebClient.Headers[HttpRequestHeader.Host] = ConstantHelper.constSproutHost;
             string replacedExerciseWepApi = string.Format(ConstantHelper.constSproutReplacedUploadApi, sproudId);
             Uri    replacedUrl            = new Uri(replacedExerciseWepApi);
             var    uploadedExecisedata    = httpWebClient.UploadFile(replacedUrl, "POST", sPath);
             if (uploadedExecisedata != null)
             {
                 if (System.IO.File.Exists(sPath))
                 {
                     System.IO.File.Delete(sPath);
                 }
                 var uploadesfile = System.Text.Encoding.ASCII.GetString(uploadedExecisedata);
                 if (uploadesfile != null)
                 {
                     ExerciseVideoResponse response = JsonConvert.DeserializeObject <ExerciseVideoResponse>(uploadesfile);
                     if (response != null)
                     {
                         UpdateExerciseSproutLink objUpdateExerciseSproutLink = new UpdateExerciseSproutLink
                         {
                             SecuryId    = response.security_token,
                             VideoId     = response.id,
                             V1080pUrl   = response.assets.videos._1080p,
                             V240pUrl    = response.assets.videos._240p,
                             V360pUrl    = response.assets.videos._360p,
                             V480pUrl    = response.assets.videos._480p,
                             V720pUrl    = response.assets.videos._720p,
                             ThumnailUrl = response.assets.thumbnails[0],
                             ExerciseId  = exerciseId
                         };
                         // Get all details of
                         ExerciseBL.UpdateExerciseSproutData(objUpdateExerciseSproutLink);
                     }
                 }
             }
             System.IO.File.Delete(sPath);
         }
     }
     catch (WebException ex)
     {
         LogManager.LogManagerInstance.WriteErrorLog(ex);
         throw;
     }
     catch (Exception ex)
     {
         LogManager.LogManagerInstance.WriteErrorLog(ex);
         throw;
     }
 }
Exemplo n.º 2
0
 private void UploadExecelToFitcom(string sPath)
 {
     try
     {
         using (WebClient httpWebClient = new WebClient())
         {
             httpWebClient.Headers[ConstantHelper.constSproutVideoApiKey] = ConstantHelper.constSproutVideoApiKeyValue;
             httpWebClient.Headers[HttpRequestHeader.Host] = ConstantHelper.constSproutHost;
             Uri uploadExerciseUri   = new Uri(ConstantHelper.constSproutUploadApi);
             var uploadedExecisedata = httpWebClient.UploadFile(uploadExerciseUri, "POST", sPath);
             if (uploadedExecisedata != null)
             {
                 var uploadesfile = System.Text.Encoding.ASCII.GetString(uploadedExecisedata);
                 if (uploadesfile != null)
                 {
                     ExerciseVideoResponse response = JsonConvert.DeserializeObject <ExerciseVideoResponse>(uploadesfile);
                     if (response != null)
                     {
                         UpdateExerciseSproutLink objUpdateExerciseSproutLink = new UpdateExerciseSproutLink
                         {
                             SecuryId = response.security_token,
                             VideoId  = response.id
                         };
                         // Get all details of
                         ExerciseBL.UpdateExerciseSproutData(objUpdateExerciseSproutLink);
                     }
                 }
             }
             if (System.IO.File.Exists(sPath))
             {
                 System.IO.File.Delete(sPath);
             }
         }
     }
     catch (WebException ex)
     {
         LogManager.LogManagerInstance.WriteErrorLog(ex);
         throw;
     }
     catch (Exception ex)
     {
         LogManager.LogManagerInstance.WriteErrorLog(ex);
         throw;
     }
 }