コード例 #1
0
ファイル: HomeController.cs プロジェクト: BenYoshi/ShareIt
 public HomeController(IPostData postData, IGreeter greeter, UserManager <User> userManager, ICommentData commentData)
 {
     _postData    = postData;
     _greeter     = greeter;
     _userManager = userManager;
     _commentData = commentData;
 }
コード例 #2
0
        /// <summary>
        /// 组装请求参数
        /// </summary>
        /// <param name="data"></param>
        /// <param name="time">服务器时间</param>
        /// <param name="userId">用户id</param>
        /// <param name="param">参数组装格式</param>
        /// <returns></returns>
        string PostParamGroup(IPostData data, long time, string userId, string param)
        {
            string urlValue = "";
            int    count    = (int)Mathf.Min((float)requestGroupMax, (float)groupData.Count);

            for (int i = 0; i < count; i += 1)
            {
                ArrayList     tmpData   = groupData.Dequeue() as ArrayList; //拉取一个
                List <object> args      = tmpData[1] as List <object>;
                string        commandId = tmpData[0] as string;
                urlValue += ParamtersPack(commandId, args, time, userId, param);  //参数组装

                if (!data.commandId.Contains(commandId))
                {
                    data.commandId.Add(commandId);
                    data.resultBack.Add((HttpNetResultDelegate)tmpData[2]);
                }

                if (i != count - 1)
                {
                    urlValue += ",";
                }
            }

            return(urlValue);
        }
コード例 #3
0
        /// <summary>
        /// 触发回调委托
        /// </summary>
        /// <param name="data"></param>
        /// <param name="res"></param>
        /// <param name="result"></param>
        /// <param name="errMsg"></param>
        /// <param name="isError"></param>
        void TriggerResponse(IPostData data, int res, string result, string errMsg, bool isError = false)
        {
            int    count = data.commandId.Count;
            string commandId;
            HttpNetResultDelegate resultBack;

            for (int i = 0; i < count; i += 1)
            {
                commandId = data.commandId[i];

                if (onResponseDict.ContainsKey(commandId))
                {
                    onResponseDict[commandId](commandId, res, result);
                }

                if (!isError)
                {
                    resultBack = data.resultBack[i];
                    if (resultBack != null)
                    {
                        resultBack(commandId, res, result);
                    }
                }
            }

            if (serverErrorResponse != null && res != NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS)
            {
                Debug.LogWarning("HttpNetManager::TriggerResponse Error : commandId:[" + data.ToString() + "]error:" + errMsg);
                serverErrorResponse(errMsg, res, result);
            }
        }
コード例 #4
0
 public IPromise Post(IPostData _data)
 {
     return(Promise.Sequence(
                () => runCommand(new LoginFBCommand(eventProvider)),
                () => runCommand(new PostToFBCommand(eventProvider).SetData(_data))
                ));
 }
コード例 #5
0
ファイル: Index.cshtml.cs プロジェクト: eslam-fakhry/MyBlog
 public IndexModel(IPostData postData, IConfiguration config)
 {
     _postData = postData;
     if (!int.TryParse(config["PageSize"], out _pageSize))
     {
         _pageSize = DefaultPageSize;
     }
 }
コード例 #6
0
 public HomeController(IPostData postData, ICommentData commentData, IContactMessageData contactMessageData,
                       IAdministratorData administratorData)
 {
     _postData           = postData;
     _commentData        = commentData;
     _contactMessageData = contactMessageData;
     _administratorData  = administratorData;
 }
コード例 #7
0
ファイル: ScrapeRequest.cs プロジェクト: rettigcd/Outfish
        }                                                                         // GET/POST: ToUri

        /// <summary>Create a new GET or POST request</summary>
        /// <param name="uri">URI to retrieve</param>
        /// <param name="postData">null = GET, non-null = POST</param>
        public ScrapeRequest(Uri uri, IPostData postData, params Action <RequestSettings>[] adjustSettings)
        {
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }
            this.Uri            = uri;
            this.PostData       = postData;
            this.AdjustSettings = adjustSettings;
        }
コード例 #8
0
        /// <summary>
        /// 请求http
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        IEnumerator PostAsync(IPostData data, bool isReset = false)
        {
            if (netTimer.isTimeOut)
            {
                yield break;                        //超时退出请求
            }
            if (!isReset)
            {
                netTimer.StartTime();           //计时开始
            }
            string url = data.url;

            Debug.Log(">>:" + url);
            WWW www = new WWW(url);

            yield return(www);

            // yield break;    //测试超时

            Debug.Log("<< [" + data.ToString() + "]:" + www.text);
            netTimer.StopTime(); //计时停止

            if (netTimer.isTimeOut)
            {
                yield break;                        //超时退出请求,防止超时了还回来数据
            }
            string result = www.text;
            int    res    = -1;
            string errMsg = "";

            try
            {
                if (netParser == null)
                {
                    netParser = new NetworkDataParser();
                }
                res        = netParser.ParseData(result, out errMsg);
                serverTime = netParser.serverTime;
            }
            catch (Exception e)
            {
                Debug.LogWarning("HttpNetManager::PostAsync Error : commandId:[" + data.ToString() + "]error:" + e.Message + " Trace [" + e.StackTrace + "]");
                TriggerResponse(data, res, result, errMsg, true);
                yield break;
            }

            TriggerResponse(data, res, result, errMsg);

            if (res == NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS && queueDataGroup.NextSendRequest)
            { //进入下一组
                SendRequest();
            }
        }
コード例 #9
0
 public void AddPostData(IPostData data)
 {
     if (data == null)
     {
         return;
     }
     if (PostDataCollection == null)
     {
         PostDataCollection = new List <IPostData>();
     }
     PostDataCollection.Add(data);
 }
コード例 #10
0
        /// <summary>
        /// Add a new <see cref="IPostDataElement"/> that represents the specified file
        /// </summary>
        /// <param name="postData">post data instance</param>
        /// <param name="fileName">file name</param>
        public static void AddFile(this IPostData postData, string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            var element = postData.CreatePostDataElement();

            element.File = fileName;

            postData.AddElement(element);
        }
コード例 #11
0
        /// <summary>
        /// Add a new <see cref="IPostDataElement"/> that represents the key and value
        /// </summary>
        /// <param name="postData">Post Data</param>
        /// <param name="bytes">byte array that represents the post data</param>
        public static void AddData(this IPostData postData, byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }

            var element = postData.CreatePostDataElement();

            element.Bytes = bytes;

            postData.AddElement(element);
        }
コード例 #12
0
        void ResetSendRequest(bool isReset = true)
        {
            IPostData postData = queueDataGroup.currentPostData;

            if (postData == null)
            {
                Debug.LogWarning("HttpNetManager::ResetSend :Error:No data can be sent!");
                return;
            }

            Debug.LogWarning("HttpNetManager::ResetSend :reset send commandId:[" + postData.ToString() + "]" + isReset);
            StartCoroutine(PostAsync(postData, isReset));
        }
コード例 #13
0
        /// <summary>
        /// 发送请求
        /// </summary>
        void SendRequest()
        {
            if (!queueDataGroup.isCanSend)
            {
                return;                            //没有请求
            }
            IPostData postData = queueDataGroup.GroupPostDataPack(serverTime);

            if (postData == null)
            {
                return;
            }
            StartCoroutine(PostAsync(postData));
        }
コード例 #14
0
ファイル: WebScraper.cs プロジェクト: rettigcd/Outfish
        HttpWebRequest BuildHttpWebRequest(ScrapeRequest request)
        {
            // build next request
            HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(request.Uri);

            httpRequest.AllowAutoRedirect = this.UseFrameworkRedirect;              // we can do this manually
            httpRequest.CookieContainer   = this._cookieJar;
            httpRequest.CachePolicy       = this.CachePolicy;

            RequestSettings settings = ApplyCustomSettingsToDefaultSettings(request);

            httpRequest.Accept          = settings.Accept;
            httpRequest.UserAgent       = settings.UserAgent;
            httpRequest.ProtocolVersion = settings.ProtocolVersion;
            httpRequest.KeepAlive       = settings.KeepAlive;
            httpRequest.Timeout         = settings.Timeout;
            httpRequest.Credentials     = settings.Credentials;
            httpRequest.Referer         = settings.Referrer ?? this._lastPage;

            foreach (var pair in settings.Headers)
            {
                httpRequest.Headers[pair.Key] = pair.Value;
            }

            // httpRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
            // request.Headers["Accept-Encoding"] = "gzip,deflate"; // don't set this directly without using the above line(I guess)


            // convert it to a post message if needed
            IPostData postData = request.PostData;

            if (postData != null)
            {
                byte[] postBytes = postData.PostBytes;

                // set request headers as appropriat
                httpRequest.Method        = "POST";
                httpRequest.ContentLength = postBytes.Length;
                httpRequest.ContentType   = postData.ContentType;

                // feed post data into the request
                using (System.IO.Stream requestStream = httpRequest.GetRequestStream()) {
                    requestStream.Write(postBytes, 0, postBytes.Length);
                }
            }

            return(httpRequest);
        }
コード例 #15
0
        /// <summary>
        /// Add a new <see cref="IPostDataElement"/> that represents the key and value
        /// The data is encoded using
        /// </summary>
        /// <param name="postData">Post Data</param>
        /// <param name="data">Data to be encoded for the post data element</param>
        /// <param name="encoding">Specified Encoding. If null then <see cref="Encoding.Default"/> will be used</param>
        public static void AddData(this IPostData postData, string data, Encoding encoding = null)
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new ArgumentNullException("data");
            }

            if (encoding == null)
            {
                encoding = Encoding.Default;
            }

            var element = postData.CreatePostDataElement();

            element.Bytes = encoding.GetBytes(data);

            postData.AddElement(element);
        }
コード例 #16
0
 public CommentController(IPostData pd)
 {
     this.pd = pd;
 }
コード例 #17
0
 public HomeController(IPostData addUserDetails, AppDbContext db)
 {
     this.pd = addUserDetails;
     this.db = db;
 }
コード例 #18
0
 public PostToFBCommand SetData(IPostData _data)
 {
     postData = _data;
     return(this);
 }
コード例 #19
0
ファイル: Edit.cshtml.cs プロジェクト: G00ryl/MyBlog
 public EditModel(IPostData postData)
 {
     _postData = postData;
 }
コード例 #20
0
ファイル: HttpNetManager.cs プロジェクト: dengswing/network
        /// <summary>
        /// 触发回调委托
        /// </summary>
        /// <param name="data"></param>
        /// <param name="res"></param>
        /// <param name="result"></param>
        /// <param name="errMsg"></param>
        /// <param name="isError"></param>
        void TriggerResponse(IPostData data, int res, string result, string errMsg, bool isError = false)
        {
            int count = data.commandId.Count;
            string commandId;
            HttpNetResultDelegate resultBack;
            for (int i = 0; i < count; i += 1)
            {
                commandId = data.commandId[i];

                if (onResponseDict.ContainsKey(commandId))
                {
                    onResponseDict[commandId](commandId, res, result);
                }

                if (!isError)
                {
                    resultBack = data.resultBack[i];
                    if (resultBack != null)
                    {
                        resultBack(commandId, res, result);
                    }
                }
            }

            if (serverErrorResponse != null && res != NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS)
            {
                Debug.LogWarning("HttpNetManager::TriggerResponse Error : commandId:[" + data.ToString() + "]error:" + errMsg);
                serverErrorResponse(errMsg, res, result);
            }
        }
コード例 #21
0
 public PostsController(IPostData postData, IMapper mapper)
 {
     _postData = postData;
     _mapper   = mapper;
 }
コード例 #22
0
        /// <summary>
        /// 【setup2】提取cookie
        /// </summary>
        /// <param name="browserControl"></param>
        /// <param name="browser"></param>
        /// <param name="frame"></param>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="status"></param>
        /// <param name="receivedContentLength"></param>
        public override void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
        {
            if (response.StatusCode != 200)
            {
                return;
            }
            var url       = new Uri(request.Url);
            var extension = url.ToString().ToLower();

            if (SystemSetting.SystemSettingDict["OpenDebug"] == "true")
            {//开启debug模式
                extension.WriteLog(ELogType.Account, true);
                //输入写入到请求日志
                IPostData data = request.PostData;
                if (data != null)
                {
                    //请求内容被转换为了文件流
                    //输出有请求参数的URL
                    StringBuilder requestHead = new StringBuilder();
                    requestHead.AppendLine(string.Format("url hava request param-> {0} ", extension));
                    foreach (var item in request.Headers.AllKeys)
                    {
                        requestHead.Append(string.Format("{0} : {1};", item, request.Headers[item]));
                    }
                    requestHead.ToString().WriteLog(ELogType.HttpRequest, true);
                }
            }
            //if (!extension.Contains(SystemConfig.CookieDomain))
            //{
            //    return;
            //}
            if ((!SystemConfig.AnywhereGetCookie && extension != SystemConfig.InitCookeKey))
            {
                return;
            }
            //这是请求响应头
            ICookieManager cookie = Cef.GetGlobalCookieManager();

            if (SystemConfig.AnywhereGetCookie)
            {//无限制提取cookie
                cookie.VisitAllCookies(new CookieVisitor());
            }
            else
            {
                foreach (var urlFrom in SystemConfig.CookieFrom)
                {
                    cookie.VisitUrlCookies(urlFrom, false, new CookieVisitor());
                }
            }
            if (extension == SystemConfig.TockenAfterUrl)
            {//是否已经获取到了tocken
                ExistsTocken = true;
            }
            if (CookieHandle.GetCoreCookie(CookieVisitor.CookieDict))
            {  //从其他应用中获取到了cookie
                ExistsTocken = true;
            }
            if (ExistsTocken)
            {//提取到了完整的cookie
                StringBuilder cook = new StringBuilder();
                cook.AppendLine(CookieVisitor.OutputCookie(CookieVisitor.CookieDict).ToString());
                cook.ToString().WriteLog(ELogType.SessionOrCookieLog, true);
                //CookieContainer
                GetCookieResponse(CookieVisitor.CookieDict);
            }
            if (_requestHeandler != null)
            {
                _requestHeandler.OnResourceLoadComplete(browserControl, browser, frame, request, response, status, receivedContentLength);
            }

            if (SystemConfig.DownloadResource)
            {
                DownloadService.DownloadResource(extension, responseDictionary, request, response);
            }
            return;
        }
コード例 #23
0
 public UsersController(IPostData postData)
 {
     _postData = postData;
 }
コード例 #24
0
 public PostController(IPostData pd)
 {
     this.pd = pd;
     //Users = pd.GetUserByNameAndEmail(userDetails.Name, userDetails.Email).ToList();
     //Id = Users[0].UserId;
 }
コード例 #25
0
 public SqlCommentData(MyBlogDbContext context, IPostData postData)
 {
     _context  = context;
     _postData = postData;
 }
コード例 #26
0
 /// <summary>
 /// 添加Post表单数据
 /// </summary>
 /// <param name="data"></param>
 public HttpHelper AddPostData(IPostData data)
 {
     this._requestData.AddPostData(data);
     return(this);
 }
コード例 #27
0
ファイル: HttpNetManager.cs プロジェクト: dengswing/network
        /// <summary>
        /// 请求http
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        IEnumerator PostAsync(IPostData data, bool isReset = false)
        {
            if (netTimer.isTimeOut) yield break;    //超时退出请求

            if (!isReset) netTimer.StartTime(); //计时开始

            string url = data.url;
            Debug.Log(">>:" + url);
            WWW www = new WWW(url);
            yield return www;

            // yield break;    //测试超时

            Debug.Log("<< [" + data.ToString() + "]:" + www.text);
            netTimer.StopTime(); //计时停止

            if (netTimer.isTimeOut) yield break;    //超时退出请求,防止超时了还回来数据

            string result = www.text;
            int res = -1;
            string errMsg = "";
            try
            {
                if (netParser == null)
                {
                    netParser = new NetworkDataParser();
                }
                res = netParser.ParseData(result, out errMsg);
                serverTime = netParser.serverTime;
            }
            catch (Exception e)
            {
                Debug.LogWarning("HttpNetManager::PostAsync Error : commandId:[" + data.ToString() + "]error:" + e.Message + " Trace [" + e.StackTrace + "]");
                TriggerResponse(data, res, result, errMsg, true);
                yield break;
            }

            TriggerResponse(data, res, result, errMsg);

            if (res == NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS && queueDataGroup.NextSendRequest)
            { //进入下一组
                SendRequest();
            }
        }
コード例 #28
0
 public DeleteModel(IPostData postData)
 {
     this.postData = postData;
 }
コード例 #29
0
        /// <summary>
        /// 组装请求参数
        /// </summary>
        /// <param name="data"></param>
        /// <param name="time">服务器时间</param>
        /// <param name="userId">用户id</param>
        /// <param name="param">参数组装格式</param>
        /// <returns></returns>
        string PostParamGroup(IPostData data, long time, string userId, string param)
        {
            string urlValue = "";
            int count = (int)Mathf.Min((float)requestGroupMax, (float)groupData.Count);
            for (int i = 0; i < count; i += 1)
            {
                ArrayList tmpData = groupData.Dequeue() as ArrayList; //拉取一个
                List<object> args = tmpData[1] as List<object>;
                string commandId = tmpData[0] as string;
                urlValue += ParamtersPack(commandId, args, time, userId, param);  //参数组装

                if (!data.commandId.Contains(commandId))
                {
                    data.commandId.Add(commandId);
                    data.resultBack.Add((HttpNetResultDelegate)tmpData[2]);
                }

                if (i != count - 1)
                {
                    urlValue += ",";
                }
            }

            return urlValue;
        }
コード例 #30
0
ファイル: Details.cshtml.cs プロジェクト: eslam-fakhry/MyBlog
 public DetailsModel(IPostData postData)
 {
     _postData = postData;
 }
コード例 #31
0
 public AddUserModel(IPostData postdata)
 {
     this.postdata = postdata;
 }
コード例 #32
0
 public ShowPostModel(IPostData postData)
 {
     _postData = postData;
 }
コード例 #33
0
 public HomeModel(IPostData postdata)
 {
     this.postdata = postdata;
 }