private async Task AddAllToDos() { foreach (var sche in MyToDos) { var result = await PostHelper.AddSchedule(LocalSettingHelper.GetValue("sid"), sche.Content, sche.IsDone? "1" : "0", SelectedCate.ToString()); } }
// // GET: /Post/ public ActionResult Index(int id) { Post post = Post.GetPostById(id); PostHelper helper = new PostHelper(post); return(View(helper)); }
private async void LoadData() { this.listCategory = await PostHelper.GetCategories(); this.lv_Category.ItemsSource = this.listCategory; this.control_PageTitle.SubTitleContent = this.listCategory.Count.ToString(); }
public GrabTicketCancelResponseModel CancelGrabTicket(GrabTicketCancelRequestModel request) { try { string postData = JsonConvert.SerializeObject(request); postData = "jsonStr=" + postData; LogHelper.WriteLog("请求取消抢票接口:" + postData, "TraGrabTicketCallBack"); string responseData = PostHelper.PostUrl(Url, postData, Encoding.UTF8); LogHelper.WriteLog("取消抢票接口同步响应:" + responseData, "TraGrabTicketCallBack"); if (string.IsNullOrEmpty(responseData)) { return new GrabTicketCancelResponseModel() { msg = "请求接口失败", isSuccess = false, code = "-1" } } ; GrabTicketCancelResponseModel responseModel = JsonConvert.DeserializeObject <GrabTicketCancelResponseModel>(responseData); return(responseModel); } catch (Exception ex) { return(new GrabTicketCancelResponseModel() { msg = ex.Message, isSuccess = false, code = "-1" }); } }
public ActionResult AddClass(Class @class) { @class.students = new List <Student>(); PostHelper <Class> .PostEntity(Globals.CLASSES_API_LINK, @class); return(RedirectToAction("Index")); }
public void Index() { //OrderDomain domain2=new OrderDomain(); //string d = domain2.DoGetNumberIdentity(102132); LogHelper.WriteLog("B2T测试出票通知:" + PostHelper.ReceivePostInfo(), "CallBack"); }
public static ForwardResponseData Forward(string url, string message, CookieContainer weibocc) { if (string.IsNullOrEmpty(url)) { return(null); } try { PostHelper post = new PostHelper(url); post.Cookies = weibocc; string html = post.Post(); //html = HttpHelper1.SendDataByGET(url,ref weibocc); if (!string.IsNullOrEmpty(html)) { Regex rNum = new Regex(@"(\d+)"); Regex r = new Regex(@"mid=(\d+)&"); var mid = rNum.Match(r.Match(html).ToString()).ToString(); r = new Regex(@"\$CONFIG\['domain'\]='(\d+)'"); var domain = rNum.Match(r.Match(html).ToString()).ToString(); r = new Regex(@"uid=(\d+)&"); var uid = rNum.Match(r.Match(html).ToString()).ToString(); r = new Regex(@"\$CONFIG\['location'\]='(.+)'"); var location = r.Match(html).ToString().Replace("$CONFIG['location']=", "").Replace("'", ""); r = new Regex(@"\$CONFIG\['page_id'\]='(\d+)'"); string pdetail = rNum.Match(r.Match(html).ToString()).ToString(); Thread.Sleep(1000); return(Forward(url, message, mid, domain, uid, location, pdetail, weibocc)); } } catch { } return(null); }
public ActionResult AddAttraction(Attraction attraction) { City city = GetHelper <City> .GetById(Globals.CITIES_API_LINK, attraction.city.id); Country country = GetHelper <Country> .GetById(Globals.COUNTRIES_API_LINK, city.country.id); Attraction newAttraction = new Attraction() { name = attraction.name, address = attraction.address, type = attraction.type, city = new City { id = city.id, name = city.name, country = new Country { id = country.id, name = country.name } } }; PostHelper <Attraction> .PostEntity(Globals.ATTRACTION_API_LINK, newAttraction); return(RedirectToAction("Index")); }
/// <summary> /// 微博预登录 /// </summary> /// <param name="username">用户名</param> /// <returns></returns> public static PreLoginResponseData PreLogin(string username) { try { string userNameBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(HttpUtility.UrlEncode(username))); string url = "http://login.sina.com.cn/sso/prelogin.php"; PostHelper post = new PostHelper(url); post.Cookies = new CookieContainer(); post.PostItems = PreLoginData.Create(userNameBase64); string result = post.Post(); Regex re = new Regex("{.*}"); if (re.IsMatch(result)) { var data = re.Match(result).ToString(); var responseData = Newtonsoft.Json.JsonConvert.DeserializeObject <PreLoginResponseData>(data); if (responseData != null) { responseData.cookies = PostHelper.GetAllCookies(post.Cookies); return(responseData); } } } catch { } return(null); }
public static LoginResponseData Login(PreLoginResponseData data, string username, string password, string code, WebProxy proxy) { try { string userNameBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(HttpUtility.UrlEncode(username))); password = EncryptPassword(data, password); string url = "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.18)&_=" + DateTime.Now.TimeStamp(); PostHelper post = new PostHelper(url); post.Type = PostTypeEnum.Post; post.Cookies = new CookieContainer(); post.Cookies.SetCookies(new Uri("http://weibo.com"), data.cookies); post.Proxy = proxy; post.PostItems = LoginData.Create(data, userNameBase64, password, code); string result = post.Post(); var responseData = JsonConvert.DeserializeObject <LoginResponseData>(result); if (responseData != null) { responseData.cookies = PostHelper.GetAllCookies(post.Cookies); return(responseData); } } catch (Exception ex) { } return(null); }
public void GetRandomStringTest() { int length = 10; string str = PostHelper.GetRandomString(length); Assert.AreEqual(length, str.Length); }
public ActionResult AjaxPostCorssDomain([FromBody] AjaxPostParam postParam) { string url = postParam.url; string json = postParam.json; try { var _result = PostHelper.GetPostResult(url, json); var json_result = Json(_result); return(json_result); //var result = ApiJsonHelper.LargeJson(_result); //return result; } catch (Exception ex) { //用log4net记录日志 _Log4Net.Error("AjaxPostCorssDomain." + url + "." + json, ex); //Logger.Default.Error("AjaxPostCorssDomain异常:{0}", ex); return(Json(JsonConvert.SerializeObject(new ResultParam { IsSuccess = false, AlertMessage = JsonConvert.SerializeObject(ex), }))); } }
/// <summary> /// Fires when the user intends to delete his or her post. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void DeleteButton_Click(object sender, RoutedEventArgs e) { string tokenBuild = "Bearer " + Token; Button btn = sender as Button; ForumModel.Datum datum = (ForumModel.Datum)btn.DataContext; if (datum != null) { int id = datum.id; string endpoint = @"https://api.africoders.com/v1/del/post?id=" + id.ToString(); postHelper = new PostHelper(endpoint); loadingTextBlock.Text = "Deleting Post."; await postHelper.MakePostAsync(tokenBuild); if (postHelper.StatusPostSuccessful) { loadingTextBlock.Text = "Deleted Post Successfully."; Refresh(); } else { loadingTextBlock.Text = "Unable to delete post. Please try again."; } } }
private void HandleManualSubmission(Subreddit subreddit, Post post) { _log.Info($"Post was manually submitted \"{post.Title}\" to /r/{subreddit.Name}. Verifying."); var postUrl = PostHelper.Url(post); var posts = subreddit.Search($"url:{postUrl}"); var postSubmission = post.Integration.Reddit.GetPostSubmissionForSubreddit(subreddit.Name); if (posts.Any()) { _log.Info($"Post \"{post.Title}\" found in /r/{subreddit.Name}."); postSubmission.Status = SubmissionStatus.Submitted; return; } postSubmission.Attempts++; _log.Warn($"Post \"{post.Title}\" not found in /r/{subreddit.Name}."); if (postSubmission.Attempts >= 3) { postSubmission.Status = SubmissionStatus.ManualSubmissionFailure; postSubmission.Attempts = 0; } }
public static DataSet GetMobileInfo(int year, int month) { UserInfo user = (UserInfo)HttpContext.Current.Session["user"]; if (user == null) { return(null); } PostHelper postHelper = new PostHelper(user); if (postHelper.dpList == null) { return(null); } //集团本部的运营数据管理员有权限查看所有流向数据 string sql = ""; if (Privilege.checkPrivilege(user)) { sql = string.Format("select * from flow_statistics where Year={0} and Month={1} " , year, month); } else { sql = string.Format("select * from flow_statistics where Year={0} and Month={1} and " + "(Sales='{2}' or Supervisor='{3}' or Manager='{4}' or Director='{5}')" , year, month, user.userName, user.userName, user.userName, user.userName); } return(SqlHelper.Find(sql)); }
private async void LoadData() { this.listCategory = await PostHelper.GetCategories(); Categories.Source = this.listCategory; this.TitleControl.SetTopProgressBarVisibility(false); }
public void SearchPost_WithValidData_ShouldReturnValidItems() { IList <Post> posts = PostHelper.GetPosts(6); posts[0].Title = "Manage cookies using Web API"; posts[0].SearchContent = "In my last project, I’ve deeply used WebApi, both for the client side and server side. In fact my application must call several REST endpoints developed with java and, after a code elaboration, I have to expose the data to other clients (javascript into an html page in this case).One of the pillars request by the Java services (really is not a technology request but just from the implementation made by the external company) is to read all cookies from the response and then send them back to the next requests (like a proxy).To make more clear where my app is, I realized the following chart:"; posts[1].Title = "Different keys with RavenDb"; posts[1].SearchContent = "In last period, I am spending so times to learn document databases, in my case RavenDB and MongoDB. To be honest I am working only on Raven right now because it is friendlier for .NET developers but I promised myself to compare some features from these two awesome database engines. One of the big difficult I found, is to create the right model. I said big because I’m used to design the model for relation database and here is really different. For example we do not have the join and we also need to denormalize the references (http://ravendb.net/docs/faq/denormalized-references)."; posts[2].Title = "An amazing experience"; posts[2].SearchContent = "Yesterday something special is happened and I still cannot believe that the Web.Net European Conference is over. For me was the first conference as a promoter and it was an AMAZING experience. More than 160 people from 11 different countries in the same building speaking about the future of the web (how F*ing cool is that?)."; posts[3].Title = "Use Less, Sass and Compass with ASP.NET MVC"; posts[3].SearchContent = "In my last project, with my team, we chose to use Compass with SASS as CSS Authoring Framework. Initially we was unsecure about that, the choice was very hard, the classic CSS allows you to find several guys who know it and it doesn’t require compilation unlike with Sass and Less. I’m not a front end developer so my part in this adventure is to manage the project and to make easy the integration of Less/Sass with an ASP.NET MVC application."; posts[4].Title = "The best extensions for Visual Studio 2012"; posts[4].SearchContent = "Visual Studio 2012 is absolutely the best IDE in the world and, with the latest version, it has sorted most of the big problems (from my point of view the previous version was a bit slow). I’m not a big fan of extensions because they often make Visual Studio unstable and/or slow, but I’ll make an exception because it this case it’s incredibly cool!"; posts[5].Title = "How integrate Facebook, Twitter, LinkedIn, Yahoo, Google and Microsoft Account with your ASP.NET MVC application"; posts[5].SearchContent = "In the past week, 15 august, Microsoft released an incredible number of cool stuff, starting from Windows 8 and ending to Visual Studio 2012 including the new ASP.NET Stack. The version 4 of ASP.NET MVC introduces several cool features; most of them was available with the Beta and RC versions (Web API, Bundling, Mobile Projects Templates, etc.), but the RTM is not a “fixed version” of the RC, it has other interesting things."; foreach (Post post in posts) { this.SetupData(x => x.Store(post)); } this.WaitStaleIndexes(); IPagedResult <PostDto> result = this.sut.Search("Facebook", 1, 10, null); result.Result.Count().Should().Be.GreaterThan(0); }
public RequestHelper(CefServer server, CefRequest request) { this.request = request; this.server = server; this.Url = request.Url; this.FirstPartyForCookies = request.FirstPartyForCookies; this.Identifier = (int)request.Identifier; this.IsReadOnly = request.IsReadOnly; this.Method = request.Method; this.Options = request.Options.ToString(); var data = new PostHelper(); if (request.PostData != null) { foreach (var element in request.PostData.GetElements()) { data.Append(element); } } this.PostData = data.Raw; this.ReferrerPolicy = request.ReferrerPolicy.ToString(); this.ReferrerURL = request.ReferrerURL; this.ResourceType = request.ResourceType.ToString(); this.TransitionType = request.TransitionType.ToString(); this.Url = request.Url; }
public IActionResult CreateThread([FromBody] ThreadDTO thread) { if (thread?.Post == null || string.IsNullOrWhiteSpace(thread.Post.Content) && string.IsNullOrWhiteSpace(thread.Post.Image)) { return(BadRequest(new { message = "Post was empty" })); } using (_work.BeginTransaction()) { try { var returnThread = _work.ThreadRepository.CreateThread(thread); _work.Save(); thread.Post.ThreadId = returnThread.Id; thread.Post.IsOp = true; var board = PostHelper.CreatePost(_work, _env, this.Request, thread.Post); _work.Save(); _work.CommitTransaction(); return(Json(board)); } catch (PostException e) { _work.RollbackTransaction(); return(BadRequest(new { message = e.Message })); } catch { _work.RollbackTransaction(); return(BadRequest()); } } }
public void UploadLot() { new Task(new Action(() => { postInfo.type = PostType.Lot; SetCimResult[(int)postInfo.type]("Lot上报中...", false); SetLot(); //string returnValue = PostHelper.PostLot(PostParams.P_I.StrModelNo, out string key); if (PostParams.P_I.BlByPiece) { PostParams.P_I.StrLot = PostParams.P_I.StrTempLot; SetLot(); PostParams.P_I.WriteCimConfig(); SetCimResult[(int)postInfo.type]("Lot更新成功", false); return; } string returnValue = PostHelper.PostLot(PostParams.P_I.StrModelNo, xmlCreater, out string key); if (returnValue == CIM.ReturnOK) { SetCimResult[(int)postInfo.type]("Lot上报成功", false); postInfo.correlationID = key; Task.Factory.StartNew(FindReception, postInfo); } else { SetLotResult(returnValue + "-Lot上报失败", true); //TODO 通知plc? SendCIMResult(postInfo.type, NG); } })).Start(); }
public void UploadChipid(object chipid) { new Task(new Action(() => { string id = chipid as string; postInfo.type = PostType.ChipID; SetArmChipID(id); SetCimResult[(int)postInfo.type]("ChipID上报中...", false); //string returnValue = PostHelper.PostChipID(id, PostParams.P_I.StrModelNo, out string key); string returnValue = PostHelper.PostChipID(id, PostParams.P_I.StrModelNo, xmlCreater, out string key); if (returnValue == CIM.ReturnOK) { SetCimResult[(int)postInfo.type]("ChipID上报成功", false); postInfo.correlationID = key; Task.Factory.StartNew(FindReception, postInfo); //FindReception(postInfo); } else { SetChipIDResult(returnValue + "-ChipID上报失败:" + id, true); //TODO 通知plc?Bot? SendCIMResult(postInfo.type, NG); } })).Start(); }
public void UploadByPieces(string code) { new Task(new Action(() => { postInfo.type = PostType.TrackOut; SetCimResult[(int)postInfo.type]("Trackout上报中...", false); //CIM.LoadList(CIM.LotNum); //ShowState("当前卡塞统计账料数:" + CIM.GetChipIDCnt().ToString()); //if (CIM.ChipIDCount != CIM.LotNum) //{ // ShowAlarm("统计账料数与LotNum不符,无法过账,请重新确认"); // SendCIMResult(postInfo.type, NG); // return; //} //string returnValue = PostHelper.PostTrackOut(CIM.GetList(), PostParams.P_I.StrModelNo, out string key); string returnValue = PostHelper.PostTrackOut( code, PostParams.P_I.StrModelNo, xmlCreater, out string key); if (returnValue == CIM.ReturnOK) { SetCimResult[(int)postInfo.type]("Trackout上报成功", false); postInfo.correlationID = key; Task.Factory.StartNew(FindReception, postInfo); } else { SetTrackOutResult(returnValue + "-Trackout上报失败", true); //TODO 通知plc? SendCIMResult(postInfo.type, NG); } })).Start(); }
/// <summary> /// Make a comment to the provided endpoint. /// </summary> /// <param name="token"></param> /// <param name="postID"></param> /// <param name="comment"></param> /// <returns></returns> public async Task MakeAComment(string token, int postID, string comment) { CommentPostEndpoint = CommentPostEndpoint + "pid=" + postID + "&body=" + comment; postHelper = new PostHelper(CommentPostEndpoint); await postHelper.MakePostAsync(token); success = postHelper.StatusPostSuccessful; }
public ActionResult GetData() { var json = new JsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; json.Data = PostHelper.GetFromDisk(); return(json); }
public async Task getBodyArticleData() { if (BodyPosts.Count != 0) { return; } string htmlPage; try { using (var client = new HttpClient()) { htmlPage = await client.GetStringAsync("http://id.wikihow.com/Halaman-Utama").ConfigureAwait(false); } htmlDocument.LoadHtml(htmlPage); var innerText = htmlDocument.DocumentNode .Descendants("div") .Where(o => o.GetAttributeValue("id", "") == "fa_container").FirstOrDefault(); innerHtmlDocument.LoadHtml(innerText.OuterHtml); var td = innerHtmlDocument.DocumentNode .Descendants("td").ToList(); PostHelper ph = new PostHelper(); var bodyposts = ph.GetPostFromTd(td); BodyPosts.ReplaceRange(bodyposts); #region unused //foreach (var div in td) //{ // Post newPosts = new Post(); // string imageUrl = ""; // string title = ""; // string url = ""; // imageUrl = Regex.Match(div.OuterHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value; // title = div.InnerText; // url = Regex.Match(div.OuterHtml, "<a.+?href=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value; // newPosts.Title = title; // newPosts.ImageUrl = imageUrl; // if (!url.Contains("http:")) url = "http:" + url; // newPosts.Url = url; // BodyPosts.Add(newPosts); //} #endregion } catch (Exception) { } }
// GET: Thread public ActionResult Index(Guid id) { var thread = _repo.GetThreadById(id); ViewBag.threadTitle = thread.Title; ViewBag.Likes = thread.Likes; return(View(PostHelper.Transform(_repo.GetPosts(id)))); }
public ActionResult AddSubject(Subject subject) { Teacher teacher = GetHelper <Teacher> .GetById(Globals.TEACHERS_API_LINK, subject.teacher.id); subject.teacher = teacher; PostHelper <Subject> .PostEntity(Globals.SUBJECTS_API_LINK, subject); return(RedirectToAction("Index")); }
/// <summary> /// 修改待办事项 /// </summary> /// <returns></returns> private async Task ModifyToDo() { IsLoading = Visibility.Visible; //离线模式 if (App.isInOfflineMode) { //修改当前列表 MyToDos.ToList().Find(sche => { if (sche.ID == NewToDo.ID) { return(true); } else { return(false); } }).Content = NewToDo.Content; await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(MyToDos, SerializerFileNames.ToDoFileName, true); Messenger.Default.Send(new GenericMessage <string>(""), MessengerTokens.RemoveScheduleUI); NewToDo = new ToDo(); Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile); return; } //非离线模式 else { var resultUpdate = await PostHelper.UpdateContent(NewToDo.ID, NewToDo.Content, NewToDo.Category); if (resultUpdate) { MyToDos.ToList().Find(sche => { if (sche.ID == NewToDo.ID) { return(true); } else { return(false); } }).Content = NewToDo.Content; Messenger.Default.Send(new GenericMessage <string>(""), MessengerTokens.RemoveScheduleUI); NewToDo = new ToDo(); Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile); } } IsLoading = Visibility.Collapsed; }
public ActionResult FacebookAuth(string returnUrl) { string appId = ConfigurationManager.AppSettings["AppId"]; string facebookauth = ConfigurationManager.AppSettings["FacebookAuthURL"]; string appsecret = ConfigurationManager.AppSettings["AppSecret"]; // if code is not available, we should request some. if (Request.Params["code"] == null) { string code_url = @"https://www.facebook.com/dialog/oauth?client_id=" + appId + "&redirect_uri=" + Server.UrlEncode(facebookauth) + "&scope=email,read_stream"; Response.Redirect(code_url); } else { string token_url = @"https://graph.facebook.com/oauth/access_token?client_id=" + appId + "&redirect_uri=" + facebookauth + "&client_secret=" + appsecret + "&code=" + Request.Params["code"]; string tokenKeyValue = PostHelper.file_get_contents(token_url); string token = PostHelper.GetKeyValueFromString(tokenKeyValue, "access_token"); Facebook.FacebookAPI api = new Facebook.FacebookAPI(token); Facebook.JSONObject me = api.Get("/me"); UsersModels user = new UsersModels(); // NOTE: // api.AccessToken is temporary. It will be replaced to a // more proper ClaimedOpenId or public profile for facebook. e.g. http://www.facebook.com/robiboi user = user.GetUserByOpenId(api.AccessToken); // should be the identifier of the user in facebook, e.g. profile link. if (user == null) { RegisterOpenId roi = new RegisterOpenId(); roi.ClaimedOpenId = api.AccessToken; // same as above roi.FriendlyOpenId = api.AccessToken; // could be profile link. roi.ReturnUrl = returnUrl; roi.Email = null; return(View(roi)); } FormsAuthenticationService formAuth = new FormsAuthenticationService(); formAuth.SignIn(api.AccessToken, false); if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } return(new EmptyResult()); }
private async Task <bool> Login() { try { var loader = new ResourceLoader(); IsLoading = Visibility.Visible; var check = await PostHelper.CheckExist(TempEmail); if (check) { string salt = await PostHelper.GetSalt(TempEmail); if (!String.IsNullOrEmpty(salt)) { //尝试登录 var login = await PostHelper.Login(TempEmail, InputPassword, salt); if (login) { App.isInOfflineMode = false; LocalSettingHelper.AddValue("OfflineMode", "false"); return(true); } else { Messenger.Default.Send <GenericMessage <string> >(new GenericMessage <string>(loader.GetString("NotCorrectContent")), "toast"); IsLoading = Visibility.Collapsed; return(false); } } else { Messenger.Default.Send <GenericMessage <string> >(new GenericMessage <string>(loader.GetString("NotCorrectContent")), "toast"); IsLoading = Visibility.Collapsed; return(false); } } else { Messenger.Default.Send <GenericMessage <string> >(new GenericMessage <string>(loader.GetString("AccountNotExistContent")), "toast"); IsLoading = Visibility.Collapsed; return(false); } } catch (Exception e) { var task = ExceptionHelper.WriteRecord(e); return(false); } }