コード例 #1
0
        public int AddJia_ApiFailLog(Jia_ApiFailLog jia_apifaillog)
        {
            string sql = "insert Jia_ApiFailLog(Guid,ApiName,ActDate,Data,ErrInfo) values(@Guid,@ApiName,@ActDate,@Data,@ErrInfo)";

            SqlParameter[] param = CreateParameter(jia_apifaillog);
            return(DBHelper.ExecuteNonQuery(sql, param));
        }
コード例 #2
0
        public int ModifyJia_ApiFailLog(Jia_ApiFailLog jia_apifaillog)
        {
            string sql = "update Jia_ApiFailLog set ApiName=@ApiName,ActDate=@ActDate,Data=@Data,ErrInfo=@ErrInfo where Guid=@Guid";

            SqlParameter[] param = CreateParameter(jia_apifaillog);
            return(DBHelper.ExecuteNonQuery(sql, param));
        }
コード例 #3
0
 private SqlParameter[] CreateParameter(Jia_ApiFailLog jia_apifaillog)
 {
     SqlParameter[] param = new SqlParameter[]
     {
         new SqlParameter("@Guid", jia_apifaillog.Guid),
         new SqlParameter("@ApiName", jia_apifaillog.ApiName),
         new SqlParameter("@ActDate", jia_apifaillog.ActDate),
         new SqlParameter("@Data", jia_apifaillog.Data),
         new SqlParameter("@ErrInfo", jia_apifaillog.ErrInfo)
     };
     return(param);
 }
コード例 #4
0
        private IList <Jia_ApiFailLog> Jia_ApiFailLogPropertity(string sql)
        {
            DataTable dt = DBHelper.ExecuteDataTable(sql);
            IList <Jia_ApiFailLog> list = new List <Jia_ApiFailLog>();

            foreach (DataRow dr in dt.Rows)
            {
                Jia_ApiFailLog jia_apifaillog = new Jia_ApiFailLog();
                jia_apifaillog.Guid    = Convert.ToString(dr["Guid"]);
                jia_apifaillog.ApiName = Convert.ToString(dr["ApiName"]);
                jia_apifaillog.ActDate = Convert.ToDateTime(dr["ActDate"]);
                jia_apifaillog.Data    = Convert.ToString(dr["Data"]);
                jia_apifaillog.ErrInfo = Convert.ToString(dr["ErrInfo"]);
                list.Add(jia_apifaillog);
            }
            return(list);
        }
コード例 #5
0
ファイル: MethodPCI.cs プロジェクト: giagiigi/tete-for-taobao
        /// <summary>
        ///  对外发布的服务方法
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public object GetYouWant(string str)
        {
            Type type = mg.GetType();

            PasswordParam pp        = new PasswordParam();
            string        decrptStr = pp.Decrypt3DES(str);

            //最后会多出一个\0
            decrptStr = decrptStr.Replace("\0", "");

            //判断合法
            if (!decrptStr.Contains("sign="))
            {
                return("未传入sign");
            }

            string sign = decrptStr.Substring(decrptStr.IndexOf("sign=") + 5, decrptStr.Length - (decrptStr.IndexOf("sign=") + 5));

            if (pp.Encrypt3DES(decrptStr.Substring(0, decrptStr.IndexOf("sign=") - 1)) != sign)
            {
                return("不合法");
            }

            decrptStr = decrptStr.Replace("&sign=" + sign, "");

            string[] paramsNameValue = decrptStr.Split('&');
            if (paramsNameValue.Length == 0 || paramsNameValue[0] == "")
            {
                return("");
            }

            Dictionary <string, string> paramDic = new Dictionary <string, string>();

            string method = "";

            string datatype = "";

            foreach (string p in paramsNameValue)
            {
                string[] pnamevalue = p.Split('=');
                if (pnamevalue.Length != 2)
                {
                    return("");
                }

                if (pnamevalue[0].ToLower() == "method")
                {
                    method = pnamevalue[1].ToLower();
                    continue;
                }

                if (pnamevalue[0].ToLower() == "datatype")
                {
                    datatype = pnamevalue[1];
                }

                paramDic.Add(pnamevalue[0], pnamevalue[1]);
            }

            if (method == "")
            {
                return("未传入方法名");
            }

            MethodInfo methodinfo = type.GetMethod(method);

            ParameterInfo[] pinfos = methodinfo.GetParameters();

            List <string> paramsList = new List <string>();

            foreach (ParameterInfo pinfo in pinfos)
            {
                foreach (KeyValuePair <string, string> kvp in paramDic)
                {
                    if (pinfo.Name.ToLower() == kvp.Key.ToLower())
                    {
                        paramsList.Add(kvp.Value);
                        break;
                    }
                }
            }
            bool   isdoit  = false;
            string errinfo = "";

            try
            {
                object obj = methodinfo.Invoke(mg, paramsList.ToArray());
                isdoit = true;
                return(obj);
            }
            catch (Exception ex)
            {
                errinfo = ex.Message;
                if (datatype.ToLower() == "json")
                {
                    return(GetJsonErr(ex.Message));
                }

                return(GetXmlErr(ex.Message));
            }

            finally
            {
                if (isdoit)
                {
                    Jia_ApiSucLog slog = new Jia_ApiSucLog {
                        ActDate = DateTime.Now, ApiName = method, Data = str, Guid = Guid.NewGuid().ToString()
                    };
                    slogDal.AddJia_ApiSucLog(slog);
                }
                else
                {
                    Jia_ApiFailLog flog = new Jia_ApiFailLog {
                        ActDate = DateTime.Now, ApiName = method, Data = str, Guid = Guid.NewGuid().ToString(), ErrInfo = errinfo
                    };
                    flogDal.AddJia_ApiFailLog(flog);
                }
            }
        }