Пример #1
0
        public override long Send(string text)
        {
            var responseModel = new ServerResult(text);

            var serializedResponse = JsonSerializer.Serialize(responseModel);

            return(base.Send(serializedResponse));
        }
Пример #2
0
        public long Send(Guid elementId, StatusCode status)
        {
            var responseModel = new ServerResult(elementId, status);

            var serializedResponse = JsonSerializer.Serialize(responseModel);

            return(base.Send(serializedResponse));
        }
Пример #3
0
        /// <summary>
        /// Выполнение запроса
        /// </summary>
        public ServerResult ExcecuteComand(ICommandContext context)
        {
            //List<ContextResult> listResult = new List<ContextResult>();
            //resultTrransaction = new Result(true, "");
            ServerResult result = new ServerResult();

            using (SqlCommand cmd = CreateSqlCommand(context))
            {
                SqlConnection conn             = new SqlConnection();
                string        connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                conn.ConnectionString = connectionString;
                cmd.Connection        = conn;
                try
                {
                    conn.Open();
                    SqlDataReader dbReader = cmd.ExecuteReader();
                    using (dbReader)
                    {
                        if (dbReader.HasRows)
                        {
                            while (dbReader.Read())
                            {
                                Dictionary <string, object> resultParams = new Dictionary <string, object>();
                                for (int index = 0; index < dbReader.FieldCount; index++)
                                {
                                    object value = dbReader[index] == DBNull.Value ? null : dbReader[index];
                                    resultParams.Add(dbReader.GetName(index), value);
                                }
                                result.ResultValuesList.Add(resultParams);
                            }
                        }
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    return(new ServerResult(false, ex.Message));
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }