Ejemplo n.º 1
0
 /// <summary>
 /// Пользователь выполнил или закрыл таск
 /// </summary>
 /// <param name="completed"></param>
 /// <param name="rank"></param>
 /// <param name="comment"></param>
 public void SendTaskDone(bool completed, byte rank = 0, string comment = "")
 {
     try
     {
         var request = new NetRequest(PacketTypes.sendtask);
         request.AddParam("completed", completed);
         if (completed)
         {
             if (rank != 0)
                 request.AddParam("rank", rank);
             if (!string.IsNullOrEmpty(comment.Trim()) && comment.Length > 0)
                 request.AddParam("comment", comment);
             _storage.SetCompletedTasks();
         }
         else
         {
             _storage.SetSkippedTasks();
         }
         SendRequest(request);
     }
     catch (Exception ex)
     {
         Logger.Log("error sendTaskDone:" + ex);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Посылаем при нажатии кнопки "Вход через..." или "Вход" для стендэлон
        /// </summary>
        /// <param name="loginType"></param>
        /// <param name="login"></param>
        /// <param name="pass"></param>
        public void SendAuth(LoginTypeEnum loginType, string login = "", string pass = "")
        {
            var request = new NetRequest(PacketTypes.auth);
            request.AddParam("auth_type", loginType.ToString());
            switch (loginType)
            {
                case LoginTypeEnum.stand_alone:
                    request.AddParam("login", login);
                    request.AddParam("pass", pass);
                    break;
                case LoginTypeEnum.vk:
                    break;
                default:
                    break;
            }

            SendRequest(request);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Отправляет запрос на сервер.
 /// Прикручивает валидацию
 /// </summary>
 /// <param name="request"></param>
 private void SendRequest(NetRequest request)
 {
     try
     {
         if (_storage.Id != 0)
         {
             request.AddParam("userdbid", _storage.Id);
         }
         Logger.Log("[Network] Send packet: {0} into {1}", request.GetMethod, string.Concat(SERVER_PATCH, "?", request.GetParamsString()));
         var webClient = new WebClient();
         //webClient.DownloadDataAsync(new Uri(string.Concat(SERVER_PATCH, "?", request.GetParamsString())));
         //webClient.DownloadDataCompleted += OnDownloadedData;
         ParseInputData(Encoding.ASCII.GetString(webClient.DownloadData(new Uri(string.Concat(SERVER_PATCH, "?", request.GetParamsString())))));
     }
     catch (Exception ex)
     {
         Logger.Log("SendRequest ERROR:" + ex);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Посылаем при нажатии кнопки "Вход через..." или "Вход" для стендэлон
        /// </summary>
        /// <param name="loginType"></param>
        /// <param name="login"></param>
        /// <param name="pass"></param>
        public void SendAuth(LoginTypeEnum loginType, string login = "", string pass = "")
        {
            var request = new NetRequest(PacketTypes.auth);

            request.AddParam("auth_type", loginType.ToString());
            switch (loginType)
            {
            case LoginTypeEnum.stand_alone:
                request.AddParam("login", login);
                request.AddParam("pass", pass);
                break;

            case LoginTypeEnum.vk:
                break;

            default:
                break;
            }

            SendRequest(request);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Получить таск
 /// </summary>
 public void GetTask()
 {
     var request = new NetRequest(PacketTypes.gettask);
     SendRequest(request);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Получить таск
        /// </summary>
        public void GetTask()
        {
            var request = new NetRequest(PacketTypes.gettask);

            SendRequest(request);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Отправляет запрос на сервер.
 /// Прикручивает валидацию
 /// </summary>
 /// <param name="request"></param>
 private void SendRequest(NetRequest request)
 {
     try
     {
         if (_storage.Id != 0)
             request.AddParam("userdbid", _storage.Id);
         Logger.Log("[Network] Send packet: {0} into {1}", request.GetMethod, string.Concat(SERVER_PATCH, "?", request.GetParamsString()));
         var webClient = new WebClient();
         //webClient.DownloadDataAsync(new Uri(string.Concat(SERVER_PATCH, "?", request.GetParamsString())));
         //webClient.DownloadDataCompleted += OnDownloadedData;
         ParseInputData(Encoding.ASCII.GetString(webClient.DownloadData(new Uri(string.Concat(SERVER_PATCH, "?", request.GetParamsString())))));
     }
     catch (Exception ex)
     {
         Logger.Log("SendRequest ERROR:" + ex);
     }
 }