示例#1
0
        public override void OnNority(Captcha captcha, byte[] binary, Action <string> call)
        {
            if (!captcha.Channel.ToUpper().StartsWith("J"))
            {
                call(null);
                return;
            }

            #region upload
            IRestResponse response = upload(captcha, binary);
            if (response == null || response.StatusCode != System.Net.HttpStatusCode.OK || !response.Content.Contains("true"))
            {
                call(null);
                return;
            }
            LzCaptcha lzCaptcha = JsonConvert.DeserializeObject <LzCaptcha>(response.Content);
            Console.WriteLine(response.Content);
            #endregion

            SharedResult sr = new SharedResult()
            {
                Ticket = captcha.Ticket,
                Id     = lzCaptcha.data.id.ToString(),
                Result = lzCaptcha.data.val
            };
            call(JsonConvert.SerializeObject(sr));
        }
示例#2
0
        public JsonResult OnPostMoveItem([FromBody] MoveAction moveAction)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                SharedResult result = new SharedResult();

                string procedureName = moveAction.IdDirectory.HasValue ? "[MoveDirectory]" : "[MoveFile]";

                using (SqlCommand command = new SqlCommand("[dbo]." + procedureName, connection))
                {
                    command.CommandType    = CommandType.StoredProcedure;
                    command.CommandTimeout = 300;

                    if (moveAction.IdDirectory.HasValue)
                    {
                        command.Parameters.Add("@IdDirectory", SqlDbType.Int);
                        command.Parameters["@IdDirectory"].Value = moveAction.IdDirectory.Value;
                    }
                    else
                    {
                        command.Parameters.Add("@IdFile", SqlDbType.Int);
                        command.Parameters["@IdFile"].Value = moveAction.IdFile.Value;
                    }

                    command.Parameters.Add("@NewIdParentDirectory", SqlDbType.Int);
                    command.Parameters["@NewIdParentDirectory"].Value = moveAction.IdParentDirectory;

                    command.Parameters.Add("@ErrorText", SqlDbType.NVarChar);
                    command.Parameters["@ErrorText"].Direction = ParameterDirection.Output;
                    command.Parameters["@ErrorText"].Size      = 4000;

                    command.ExecuteNonQuery();

                    result.ErrorText = command.Parameters["@ErrorText"].Value.ToString();
                }
                connection.Close();

                return(new JsonResult(JsonConvert.SerializeObject(result)));
            }
        }