Esempio n. 1
0
        /// <summary>
        /// 保存数据入数据库
        /// </summary>
        /// <param name="functionParms">方法的参数</param>
        /// <returns>保存数据入库</returns>
        public ResultValue FuncSaveData(FunctionParms functionParms)
        {
            lock (lockSignle)
            {
                try
                {
                    if (functionParms.FunctionName.StartsWith("ufc"))
                    {
                        var mothed = this.GetType().GetMethod(functionParms.FunctionName.Remove(0, 3));
                        if (mothed == null)
                            throw new NotImplementedException(functionParms.FunctionName);

                        mothed.Invoke(this, (functionParms.Pams.Values ?? new List<object>()).ToArray());
                    }
                    else
                    {
                        //SQLHelper.ExecuteNonQuery(connectionString, functionParms.FunctionName, functionParms.Pams);
                        MySqlHelper.ExecuteNonQuery(connectionString, functionParms.FunctionName, functionParms.Pams);
                    }

                    return new ResultValue();
                }
                catch (Exception e)
                {
                    return new ResultValue(e);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 批量保存数据入数据库
        /// </summary>
        /// <param name="functionParms">方法的参数</param>
        /// <returns>保存数据入库</returns>
        public ResultValue[] FuncBatchSaveData(FunctionParms[] funcParms)
        {
            lock (lockBatch)
            {
                List<ResultValue> results = new List<ResultValue>();

                foreach (FunctionParms funcParm in funcParms)
                {
                    ResultTable resultTable = new ResultTable();
                    try
                    {
                        using (var reader = SQLHelper.ExecuteReader(connectionString, funcParm.FunctionName, funcParm.Pams))
                        {
                            List<string> columns = new List<string>();
                            List<object[]> rows = new List<object[]>();
                            while (reader.Read())
                            {
                                if (columns.Count == 0)
                                {
                                    columns = new List<string>();
                                    for (int i = 0; i < reader.FieldCount; i++)
                                    {
                                        columns.Add(reader.GetName(i));
                                    }
                                }
                                List<object> cellValues = new List<object>();
                                for (int i = 0; i < reader.FieldCount; i++)
                                {
                                    object cellValue = reader.GetValue(i);
                                    cellValues.Add(cellValue == DBNull.Value ? null : cellValue);
                                }
                                rows.Add(cellValues.ToArray());
                            }
                            resultTable.Columns = columns.ToArray();
                            resultTable.Rows = rows.ToArray();
                        }
                        ResultValue resultValue = new ResultValue();
                        resultValue.ResultTable = resultTable;
                        results.Add(resultValue);

                        //SQLHelper.ExecuteNonQuery(connectionString, funcParm.FunctionName, funcParm.Pams);
                        //results.Add(new ResultValue());
                    }
                    catch (Exception e)
                    {
                        results.Add(new ResultValue(e));
                    }
                }

                return results.ToArray();
            }
        }
Esempio n. 3
0
 public ResultValue FuncGetResults(FunctionParms functionParms)
 {
     return localDataService.FuncGetResults(functionParms);
 }
Esempio n. 4
0
 public ResultValue[] FuncBatchSaveData(FunctionParms[] functionParms)
 {
     return localDataService.FuncBatchSaveData(functionParms);
 }
Esempio n. 5
0
 public ResultValue FuncSaveData(FunctionParms functionParms)
 {
     return localDataService.FuncSaveData(functionParms);
 }
Esempio n. 6
0
 /// <summary>
 /// 获取查询结果集合
 /// </summary>
 /// <param name="functionParms">查询条件</param>
 /// <returns>返回结果集合</returns>
 public ResultValue FuncGetResults(FunctionParms functionParms)
 {
     try
     {
         ResultTable resultTable = new ResultTable();
         //using (var reader = SQLHelper.ExecuteReader(connectionString, functionParms.FunctionName, functionParms.Pams))
         using (var reader = MySqlHelper.ExecuteDataReader(connectionString, functionParms.FunctionName, functionParms.Pams))
         {
             List<string> columns = new List<string>();
             List<object[]> rows = new List<object[]>();
             while (reader.Read())
             {
                 if (columns.Count == 0)
                 {
                     columns = new List<string>();
                     for (int i = 0; i < reader.FieldCount; i++)
                     {
                         columns.Add(reader.GetName(i));
                     }
                 }
                 List<object> cellValues = new List<object>();
                 for (int i = 0; i < reader.FieldCount; i++)
                 {
                     object cellValue = reader.GetValue(i);
                     cellValues.Add(cellValue == DBNull.Value ? null : cellValue);
                 }
                 rows.Add(cellValues.ToArray());
             }
             resultTable.Columns = columns.ToArray();
             resultTable.Rows = rows.ToArray();
         }
         ResultValue resultValue = new ResultValue();
         resultValue.ResultTable = resultTable;
         return resultValue;
     }
     catch (Exception e)
     {
         return new ResultValue(e);
     }
 }