Exemplo n.º 1
0
        /// <summary>
        ///     执行一条sql
        /// </summary>
        /// <param name="tansEntity"></param>
        /// <returns></returns>
        private static TransEntity Execute(TransEntity tansEntity)
        {
            try
            {
                var entity = new TransitEntity();
                entity.ServiceName = "dbcservice";
                entity.FuncName    = "ExecuteNoQuery";
                entity.Parameters  = new Dictionary <string, string>
                {
                    { "1", CommonFunction.ChangArrayToStr(tansEntity.SqlString) },
                    { "2", CommonFunction.ChangArrayToStr(tansEntity.ParString) }
                };
                List <AttachFile> tmpresult = ServiceManager.GetInstance().Commit(entity);
                if (tmpresult != null && tmpresult.Count == 1)
                {
                    var result = (string)tmpresult.ToArray()[0].AttachValue;
                    tansEntity.ReceiveData = new ReceiveData {
                        ExcuteIsComplete = result == "true" ? true : false
                    };
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0]);
            }

            return(tansEntity);
        }
Exemplo n.º 2
0
 /// <summary>
 ///     向客户端发出控制命令
 /// </summary>
 /// <returns></returns>
 public static void SendCommand(string[] TellerNo, MessageType type, params string[] param)
 {
     try
     {
         var entity = new TransitEntity();
         entity.ServiceName = "commonservice";
         entity.FuncName    = "MesegePush";
         entity.Parameters  = new Dictionary <string, string>
         {
             { "0", CommonFunction.ChangArrayToStr(TellerNo) },
             { "1", ((int)type).ToString() },
             { "2", CommonFunction.ChangArrayToStr(param) }
         };
         List <AttachFile> tmpresult = ServiceManager.GetInstance().Commit(entity);
         if (tmpresult != null && tmpresult.Count == 1)
         {
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0]);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     从服务端获得数据
        /// </summary>
        /// <returns></returns>
        private static TransEntity GetData(TransEntity transEntity)
        {
            try
            {
                // 服务端暂时只支持一次一个查询sql,所以要转换回来到这个格式
                string[] s      = transEntity.ParString[0].Split(';');
                var      entity = new TransitEntity();
                entity.ServiceName = "dbcservice";
                entity.FuncName    = "ExecuteWithResult";
                entity.Parameters  = new Dictionary <string, string>
                {
                    { "1", CommonFunction.ChangArrayToStr(transEntity.SqlString) },
                    { "2", CommonFunction.ChangArrayToStr(s) }
                };
                List <AttachFile> tmpresult = ServiceManager.GetInstance().Commit(entity);
                if (tmpresult != null && tmpresult.Count == 1)
                {
                    transEntity.ReceiveData                  = new ReceiveData();
                    transEntity.ReceiveData.DataTables       = (DataTable)tmpresult.ToArray()[0].AttachValue;
                    transEntity.ReceiveData.ExcuteIsComplete = true;

                    // 特殊处理,给返回表格增加列明,如果能分析出来的话
                    try
                    {
                        string sql = transEntity.SqlString[0].ToUpper().Trim();
                        if (sql.StartsWith("SELECT"))
                        {
                            sql = sql.Replace("SELECT", "");
                            string[] c = sql.Split(new[] { "FROM" }, StringSplitOptions.RemoveEmptyEntries);
                            string   d = c[0].Trim();
                            c = d.Split(',');

                            if (transEntity.ReceiveData.DataTables.Columns.Count == 0)
                            {
                                foreach (string item in c)
                                {
                                    //for (int i = 0; i < c.Length; i++)
                                    string[] f = item.Trim().Split(' ');
                                    if (!InChar(f[f.Length - 1]))
                                    {
                                        transEntity.ReceiveData.DataTables.Columns.Add();
                                    }
                                }
                            }

                            int n = 0;
                            foreach (string item in c)
                            //for (int i = 0; i < c.Length; i++)
                            {
                                string[] f = item.Trim().Split(' ');
                                if (!InChar(f[f.Length - 1]))
                                {
                                    transEntity.ReceiveData.DataTables.Columns[n].ColumnName = f[f.Length - 1];
                                    n++;
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0]);
                    }
                }
            }
            catch (Exception)
            {
                //MessageBox.Show(e.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0]);
                throw;
            }

            return(transEntity);
        }