Example #1
0
        /// <summary>
        /// 调用服务端(不包含文件上传)
        /// </summary>
        /// <param name="authorizationParams">服务端参数</param>
        /// <param name="dic">业务参数</param>
        /// <returns></returns>
        public static string Authorization(AuthorizationParams authorizationParams, IDictionary <string, string> dic)
        {
            // 基本参数
            var      paramDictionary = getParams(authorizationParams, dic);
            WebUtils webPost         = new WebUtils();
            string   url             = authorizationParams.URL;
            string   sss             = WebUtils.Default.Post(url, Encoding.UTF8, paramDictionary);

            return(sss);
        }
Example #2
0
        /// <summary>
        /// 获取服务端登录返回的验证参数
        /// </summary>
        /// <param name="Request">Request</param>
        /// <param name="method">接口</param>
        /// <returns></returns>
        public static AuthorizationParams getParams(HttpRequestBase Request, string method)
        {
            APCookie            apCookie            = CookieHelper.GetCookie(Request);
            AuthorizationParams authorizationParams = new AuthorizationParams();

            // 必须
            authorizationParams.APP_KEY    = apCookie.app_key;
            authorizationParams.SESSION    = apCookie.app_session;
            authorizationParams.APP_SECRET = apCookie.app_secret;
            authorizationParams.METHOD     = method;
            return(authorizationParams);
        }
Example #3
0
        /// <summary>
        /// 调用服务端(包含文件上传)
        /// </summary>
        /// <param name="authorizationParams">服务端参数</param>
        /// <param name="dic">业务参数</param>
        /// <param name="files">文件</param>
        /// <returns></returns>
        public static string Authorization(AuthorizationParams authorizationParams, IDictionary <string, string> dic, Dictionary <string, string> files)
        {
            // 基本参数
            var paramDictionary = getParams(authorizationParams, dic);

            // 文件参数
            IDictionary <string, FileItem> fileParams = new Dictionary <string, FileItem>();

            foreach (string file in files.Keys)
            {
                FileItem item = new FileItem(FileItemType.FileInfo, files[file]);
                fileParams[file] = item;
            }

            WebUtils webPost = new WebUtils();
            string   url     = authorizationParams.URL;
            string   sss     = webPost.Post(url, Encoding.UTF8, null, paramDictionary, fileParams);

            return(sss);
        }
Example #4
0
        /// <summary>
        /// 获取服务端登录返回的参数,以及各式话业务参数
        /// </summary>
        /// <param name="authorizationParams">服务端登录返回的参数</param>
        /// <param name="dic">业务参数</param>
        /// <returns></returns>
        public static IDictionary <string, string> getParams(AuthorizationParams authorizationParams, IDictionary <string, string> dic)
        {
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();

            //系统级参数设置
            paramDictionary.Add(APP_KEY, authorizationParams.APP_KEY);
            paramDictionary.Add(SESSION, authorizationParams.SESSION);
            paramDictionary.Add(METHOD, authorizationParams.METHOD);
            paramDictionary.Add(FORMAT, authorizationParams.FORMAT);
            paramDictionary.Add(VERSION, authorizationParams.VERSION);
            paramDictionary.Add(TIMESTAMP, authorizationParams.TIMESTAMP);
            paramDictionary.Add(UTC_OFFSET, authorizationParams.UTC_OFFSET);
            paramDictionary.Add(SIGN_METHOD, authorizationParams.SIGN_METHOD);

            foreach (KeyValuePair <string, string> item in dic)
            {
                paramDictionary.Add(item.Key, item.Value);
            }
            paramDictionary.Add(SIGN, GetSignature(paramDictionary, authorizationParams.APP_SECRET));
            return(paramDictionary);
        }
Example #5
0
        public static string Authorization(AuthorizationParams authorizationParams, IDictionary <string, string> dic, Dictionary <string, HttpPostedFileBase> files)
        {
            // 基本参数
            var paramDictionary = getParams(authorizationParams, dic);

            // 文件参数
            IDictionary <string, FileItem> fileParams = new Dictionary <string, FileItem>();

            foreach (string file in files.Keys)
            {
                byte[] byteFile = new byte[files[file].InputStream.Length];
                files[file].InputStream.Read(byteFile, 0, (int)files[file].InputStream.Length);
                FileItem item = new FileItem(files[file].FileName, byteFile);
                fileParams[file] = item;
            }

            WebUtils webPost = new WebUtils();
            string   url     = authorizationParams.URL;
            string   sss     = webPost.Post(url, Encoding.UTF8, null, paramDictionary, fileParams);

            return(sss);
        }
Example #6
0
        /// <summary>
        /// 登录接口
        /// </summary>
        /// <param name="authorizationParams">服务端参数</param>
        /// <param name="dic">用户名&密码</param>
        /// <returns></returns>
        public static string LoginAuthorization(AuthorizationParams authorizationParams, IDictionary <string, string> dic)
        {
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();

            //系统级参数设置
            paramDictionary.Add(METHOD, authorizationParams.METHOD);
            paramDictionary.Add(FORMAT, authorizationParams.FORMAT);
            paramDictionary.Add(VERSION, authorizationParams.VERSION);
            paramDictionary.Add(TIMESTAMP, authorizationParams.TIMESTAMP);
            paramDictionary.Add(UTC_OFFSET, authorizationParams.UTC_OFFSET);

            foreach (KeyValuePair <string, string> item in dic)
            {
                paramDictionary.Add(item.Key, item.Value);
            }

            WebUtils webPost = new WebUtils();
            string   url     = authorizationParams.URL;
            string   sss     = WebUtils.Default.Post(url, Encoding.UTF8, paramDictionary);

            return(sss);
        }