public async Task <IHttpActionResult> ImportKtp()
        {
            _logger.Info("Start import ktp ");
            HubFunctions.SendMessage("Start import ktp ");
            HubFunctions.WaitProcess("Import Ktp");
            HttpResponseMessage response = new HttpResponseMessage();
            var httpRequest = HttpContext.Current.Request;

            try
            {
                int i = 0;
                if (httpRequest.Files.Count > 0)
                {
                    foreach (string file in httpRequest.Files)
                    {
                        i++;
                        var hedgeimport = new HedgeImport();
                        var postedFile  = httpRequest.Files[file];
                        //var filePath = HttpContext.Current.Server.MapPath("~/UploadFile/" + postedFile.FileName);
                        var filePath = System.Configuration.ConfigurationManager.AppSettings["ShareFolderPath"] + @"\" + postedFile.FileName;
                        postedFile.SaveAs(filePath);
                        //CALLING A FUNCTION THAT CALCULATES PERCENTAGE AND SENDS THE DATA TO THE CLIENT
                        HubFunctions.SendMessage("file uploded successfully : " + postedFile.FileName);

                        //byte[] buffer = new byte[postedFile.InputStream.Length];
                        //postedFile.InputStream.Seek(0, SeekOrigin.Begin);
                        //postedFile.InputStream.Read(buffer, 0, Convert.ToInt32(postedFile.InputStream.Length));
                        //MemoryStream stream2 = new MemoryStream(buffer);

                        hedgeimport.ImportKtp(filePath);
                        HubFunctions.SendRefreshData("All");
                    }
                }
                _logger.Info("End import ktp ");
                HubFunctions.SendMessage("End import ktp ");
                HubFunctions.EndProcess("Import Ktp");


                //for (int j = 0; j <= 10; j++)
                //{
                //    //SIMULATING SOME TASK
                //    Thread.Sleep(500);

                //    //CALLING A FUNCTION THAT CALCULATES PERCENTAGE AND SENDS THE DATA TO THE CLIENT
                //    Functions.SendProgress("Process in progress...", j, 10);
                //}
                return(Ok());
            }
            catch (Exception exp)
            {
                HubFunctions.EndProcess("ImportKTp");
                HubFunctions.SendMessage("Error in ktp import : " + exp.Message);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(exp.Message),
                    ReasonPhrase = "Critical Exception : " + exp.Message
                });
            }
        }
 public async Task <IHttpActionResult> ImportSignal(string programCode, DateTime startDate, DateTime endDate, string operationsInternes = "")
 {
     try
     {
         string authToken = string.Empty;
         if (Request.Headers.Contains("Authorization"))
         {
             authToken = Request.Headers.GetValues("Authorization").First();
             //check authentification
             _logger.Info("Authorization infos sended from client " + authToken);
         }
         string message = "Start Import Signal " + authToken;
         _logger.Info(message);
         HubFunctions.SendMessage(message);
         HubFunctions.WaitProcess("ImportSignal");
         HttpResponseMessage response = new HttpResponseMessage();
         var httpRequest = HttpContext.Current.Request;
         if (string.IsNullOrEmpty(operationsInternes))
         {
             operationsInternes = "NON";
         }
         var outmessage = await new SignalService().GetOperations("REFERENCE", startDate, endDate, operationsInternes);
         HubFunctions.SendRefreshData("All");
         message = "End import Signal " + authToken;
         _logger.Info(message);
         HubFunctions.SendMessage(message);
         HubFunctions.SendMessage(outmessage);
         HubFunctions.EndProcess("ImportSignal");
         HubFunctions.SendRefreshData("All");
         return(Ok(outmessage));
     }
     catch (Exception exp)
     {
         HubFunctions.EndProcess("ImportSignal");
         HubFunctions.SendMessage("Error in signal import : " + exp.Message);
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content      = new StringContent(exp.Message),
             ReasonPhrase = "Critical Exception : " + exp.Message
         });
     }
 }