Exemple #1
0
 public bool SetTokens(string ChatHelpDesk, string Gmail, string Host)
 {
     if (ChatHelpDesk != null && ChatHelpDesk != "" && Host != "")
     {
         string name = "ChHToken.json";
         string path = HostingEnvironment.ApplicationPhysicalPath;
         try
         {
             Configer.SetToken(ChatHelpDesk);
             var client  = new RestClient("https://api.chat2desk.com/v1/companies/web_hook");
             var request = new RestRequest(Method.POST);
             request.AddHeader("cache-control", "no-cache");
             request.AddHeader("content-type", "application/json");
             request.AddHeader("authorization", Configer.GetToken());
             request.AddParameter("application/json", JsonConvert.SerializeObject(new { url = Host }), ParameterType.RequestBody);
             IRestResponse response = client.Execute(request);
         }
         catch (Exception ex)
         {
             string ModelError = ex.Message;
         }
     }
     if (Gmail != null && Gmail != "")
     {
         string name = "Google.Apis.Auth.OAuth2.Responses.TokenResponse-user";
         string path = HostingEnvironment.ApplicationPhysicalPath;
         try
         {
             using (FileStream fstream = new FileStream(path + name, FileMode.Create))
             {
                 //string json = JsonConvert.SerializeObject(Gmail);
                 // преобразуем строку в байты
                 byte[] array = System.Text.Encoding.Default.GetBytes(Gmail);
                 // запись массива байтов в файл
                 fstream.Write(array, 0, array.Length);
             }
         }
         catch (Exception ex)
         {
             string ModelError = ex.Message;
         }
     }
     return(true);
 }
Exemple #2
0
 public ActionResult GetChat(string Token)
 {
     Configer.SetToken(Token);
     ViewBag.chat = "Ваш Токен Зарегистрирован, Первичная настройка для Chat2Deck завершена.";
     return(View("Index"));
 }