本文整理汇总了C#中System.Web.HttpContext.WriteJsonP方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.WriteJsonP方法的具体用法?C# HttpContext.WriteJsonP怎么用?C# HttpContext.WriteJsonP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContext
的用法示例。
在下文中一共展示了HttpContext.WriteJsonP方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAdImages
public void GetAdImages(HttpContext context)
{
var files = (from o in GetDataContext2.Ads
orderby o.Priority
select new
{
o.ID,
o.Priority,
o.Name,
o.Image_Height,
o.Image_Width,
o.Url,
cats = (from o1 in o.CategoryAdsMapping select new { o1.Category.Name, o1.Category.ID })
}).AsEnumerable().Select((o, i) => new
{
index = i,
o.Priority,
o.ID,
title = o.Name,
height = Math.Ceiling(190.00 * (Convert.ToDouble(o.Image_Height) / Convert.ToDouble(o.Image_Width))),
file = Common.UploadedImageRelPath + o.Url,
o.cats
});
context.WriteJsonP(Newtonsoft.Json.JsonConvert.SerializeObject(files, Formatting.Indented, Common.JsonSerializerSettings));
}
示例2: GetCategories
public void GetCategories(HttpContext context)
{
var categories = (from o in all
where o.ParentID == null
select new Category
{
ID = o.ID,
Name = o.Name,
ParentID = o.ParentID
}).AsEnumerable().Select((o, i) => new Category
{
index = i,
ID = o.ID,
Name = o.Name,
SubCategories = SubCategories(o, all)
});
context.WriteJsonP(JsonConvert.SerializeObject(categories, Formatting.Indented, Common.JsonSerializerSettings));
}
示例3: Default
private void Default(HttpContext context)
{
List<object> files = new List<object>();
string cat = context.Request.QueryString["cat"];
string q = context.Request.QueryString["q"];
int p = int.Parse(context.Request.QueryString["p"]);
string style = context.Request.QueryString["style"];
int ps = Common.PageSize;
if (cat != null)
{
List<int> cats = new List<int>();
Action<IEnumerable<Category>> addSubCats = null;
addSubCats = (subcats) =>
{
foreach (var category in subcats)
{
cats.Add(category.ID);
if (all.Any(o => o.ParentID == category.ID))
addSubCats(all.Where(o => o.ParentID == category.ID));
}
};
addSubCats(all.Where(o => o.Name == cat));
if (cats.Any())
{
var catimgs = Common.Compiled.CategoryImages(GetDataContext2, p, ps, string.Join(",", cats.ToArray()), style).Select((o, i) => new
{
o.ID,
editable = false,
o.BoardID,
title = o.Image_Title,
height = o.Image_Height,
PinID = o.PinID.ToString(),
imgsource = o.Source,
width = o.Image_Width,
comments = Common.XmlToJArray(o.Comments),
bimid = o.BIMID,
source = Common.GetAbsoluteUri(o.Source),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(catimgs, Formatting.Indented, Common.JsonSerializerSettings));
}
else context.WriteJsonP("[]");
return;
}
if (q != null)
{
var _q = Common.Compiled.Query(this.GetDataContext2, p, ps, q).Select((o, i) => new
{
o.ID,
editable = false,
o.BoardID,
title = o.Image_Title,
source = Common.GetAbsoluteUri(o.Source),
imgsource = o.Source,
width = o.Image_Width,
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
height = o.Image_Height,
PinID = o.PinID.ToString(),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(_q, Formatting.Indented, Common.JsonSerializerSettings));
return;
}
if (style != null)
{
context.WriteJsonP(JsonConvert.SerializeObject(Common.Compiled.ImagesStyle(this.GetDataContext2, style, p, ps).Select((o, i) => new
{
o.ID,
editable = false,
title = o.Image_Title,
o.liked,
o.BoardID,
imgsource = o.Source,
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
width = o.Image_Width,
source = Common.GetAbsoluteUri(o.Source),
height = o.Image_Height,
PinID = o.PinID.ToString(),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
}).Randomize(), Formatting.Indented, Common.JsonSerializerSettings));
return;
}
context.WriteJsonP(JsonConvert.SerializeObject(Common.Compiled.Images(this.GetDataContext2, p, ps).Randomize().Select((o, i) => new
{
o.ID,
editable = false,
title = o.Image_Title,
o.liked,
o.BoardID,
imgsource = o.Source,
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
width = o.Image_Width,
source = Common.GetAbsoluteUri(o.Source),
//.........这里部分代码省略.........
示例4: User
private void User(HttpContext context)
{
int? userId = Common.UserID;
int? vuserid = Common.VUserID;
List<object> files = new List<object>();
string cat = context.Request.QueryString["cat"];
string q = context.Request.QueryString["q"];
string filter = context.Request.QueryString["filter"];
string style = context.Request.QueryString["style"];
string board = context.Request.QueryString["board"];
int p = int.Parse(context.Request.QueryString["p"]);
int ps = Common.PageSize;
int adFreq = Common.AdFreq;
int adps = ps / adFreq;
int count, tmp = 0;
if (board != null)
{
var imgs = Common.Compiled.BoardImages(this.GetDataContext2, p, ps, userId, board, vuserid.HasValue).Select((o, i) => new
{
title = o.Image_Title,
editable = (!vuserid.HasValue) && (o.UserID == userId),
o.ID,
o.BoardID,
height = o.Image_Height,
PinID = o.PinID.ToString(),
o.liked,
width = o.Image_Width,
imgsource = o.Source,
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
source = Common.GetAbsoluteUri(o.Source),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(imgs, Formatting.Indented, Common.JsonSerializerSettings));
return;
}
if (filter != null)
{
if (filter == "likes")
{
var imgs = Common.Compiled.Likes(this.GetDataContext2, p, ps, userId, vuserid).Select((o, i) => new
{
title = o.Image_Title,
editable = (!vuserid.HasValue) && (o.UserID == userId),
o.ID,
o.BoardID,
height = o.Image_Height,
PinID = o.PinID.ToString(),
o.liked,
width = o.Image_Width,
imgsource = o.Source,
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
source = Common.GetAbsoluteUri(o.Source),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(imgs, Formatting.Indented, Common.JsonSerializerSettings));
return;
}
if (filter == "pins")
{
var imgs = Common.Compiled.Pins(this.GetDataContext2, p, ps, userId, vuserid).Select((o, i) => new
{
title = o.Image_Title,
editable = (!vuserid.HasValue) && (o.UserID == userId),
o.ID,
o.BoardID,
width = o.Image_Width,
height = o.Image_Height,
PinID = o.PinID.ToString(),
o.liked,
imgsource = o.Source,
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
source = Common.GetAbsoluteUri(o.Source),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(imgs, Formatting.Indented, Common.JsonSerializerSettings));
return;
}
}
if (cat != null)
{
List<int> cats = new List<int>();
Action<IEnumerable<Category>> addSubCats = null;
addSubCats = (subcats) =>
{
foreach (var category in subcats)
{
cats.Add(category.ID);
if (all.Any(o => o.ParentID == category.ID))
addSubCats(all.Where(o => o.ParentID == category.ID));
}
};
addSubCats(all.Where(o => o.Name == cat));
if (cats.Any())
{
//.........这里部分代码省略.........
示例5: GetQPeople
private void GetQPeople(HttpContext context)
{
string name = context.Request.QueryString["name"];
Func<JObject, JObject> proc = o1 =>
{
string path = Common.ContentUrl + (string)o1["RelativeImage_Path"];
o1["RelativeImage_Path"] = path;
return o1;
};
int cur_user = Convert.ToInt32(Common.UserID) > 0 ? Convert.ToInt32(Common.UserID) : 0;
var FgUsers = (from f in GetDataContext2.Vw_User
where f.Name.StartsWith(name) && (f.ID != cur_user)
select new
{
F_FullName = f.FirstName,
F_ID = f.ID,
F_UserName = f.Name,
F_Avatar = Common.FixAvatar(f.Avatar),
Fg_Count = f.Following_Count,
Fr_Count = f.Follower_Count,
F_Pin = Common.XmlToJArray(GetDataContext2.ForXML_vw_UserPins(f.ID), proc),
F_Status = GetDataContext2.FollowStatus(Common.UserID, f.ID)
});
context.WriteJsonP(JsonConvert.SerializeObject(FgUsers, Formatting.Indented, Common.JsonSerializerSettings));
}
示例6: GetPin
private void GetPin(HttpContext context)
{
string pin = context.Request.Params["pin"];
int? userID = Common.UserID;
if (userID.HasValue)
context.WriteJsonP(JsonConvert.SerializeObject((from o in GetDataContext2.Vw_Pin
where o.PinID.Value.ToString() == pin
select new
{
editable = o.UserID.HasValue && (o.UserID == userID),
title = o.Image_Title,
source = Common.GetAbsoluteUri(o.Source),
imgsource = o.Source,
Comments = Common.XmlToJArray(GetDataContext2.ForXML_vw_UserComments(o.BIMID)),
o.BIMID,
Contacts = Common.XmlToJArray(o.Contacts),
width = o.Image_Width,
height = o.Image_Height,
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
}).First(), Formatting.Indented, Common.JsonSerializerSettings));
else
context.WriteJsonP(JsonConvert.SerializeObject((from o in GetDataContext2.Vw_Pin
where o.PinID.Value.ToString() == pin
select new
{
title = o.Image_Title,
source = Common.GetAbsoluteUri(o.Source),
imgsource = o.Source,
Comments = Common.XmlToJArray(GetDataContext2.ForXML_vw_UserComments(o.BIMID)),
o.BIMID,
Contacts = Common.XmlToJArray(o.Contacts),
width = o.Image_Width,
height = o.Image_Height,
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
}).First(), Formatting.Indented, Common.JsonSerializerSettings));
}
示例7: GetImagesinUrl1
private void GetImagesinUrl1(HttpContext context)
{
string url = context.Request.QueryString["url"];
Regex img = new Regex("<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase);
Regex src = new Regex(@"src=(?:(['""])(?<src>(?:(?!\1).)*)\1|(?<src>[^\s>]+))", RegexOptions.IgnoreCase | RegexOptions.Singleline);
WebClient source = new WebClient();
string value = source.DownloadString(new Uri(url));
if (!string.IsNullOrEmpty(value))
{
MatchCollection matches = img.Matches(value);
if (matches.Count > 0)
{
string rpath = Common.RelTemp + Common.UserID;
string path = Common.Temp + Common.UserID;
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
else
{
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
File.Delete(file);
}
}
int i = 0;
Dictionary<int, bool> _dict = new Dictionary<int, bool>();
List<string> paths = new List<string>();
AsyncCompletedEventHandler callback = (sender, e) =>
{
dynamic dyn = (dynamic)e.UserState;
_dict[dyn.i] = true;
string rfn = rpath + dyn.i + ".jpg";
paths.Add(rfn);
};
foreach (Match match in matches)
{
string imgUrl = match.Groups[1].Value;
WebClient client = new WebClient();
client.DownloadFileCompleted += callback;
string fn = path + "\\" + i + ".jpg";
dynamic dyn = new ExpandoObject();
dyn.fn = fn;
dyn.i = i;
client.DownloadFileAsync(new Uri(imgUrl), fn, dyn);
_dict.Add(i, false);
i++;
}
while (_dict.ContainsValue(false)) Thread.Sleep(500);
context.WriteJsonP(JsonConvert.SerializeObject(paths, Formatting.Indented, Common.JsonSerializerSettings));
}
}
}
示例8: GetFollowing
private void GetFollowing(HttpContext context)
{
Func<JObject, JObject> proc = o1 =>
{
string path = Common.ContentUrl + (string)o1["RelativeImage_Path"];
o1["RelativeImage_Path"] = path;
return o1;
};
var FgUsers = (from f in GetDataContext2.Vw_FollowingUser
where f.UserID == (Common.VUserID ?? Common.UserID)
select new
{
F_FullName = f.FullName,
F_ID = f.FollowingID,
F_UserName = f.UserName,
F_Avatar = Common.FixAvatar(f.Avatar),
Fg_Count = f.Following_Count,
Fr_Count = f.Follower_Count,
F_Pin = Common.XmlToJArray(f.Pins_XML, proc),
F_Status = GetDataContext2.FollowStatus(Common.UserID, f.FollowingID),
});
context.WriteJsonP(JsonConvert.SerializeObject(FgUsers, Formatting.Indented, Common.JsonSerializerSettings));
}
示例9: ValidateContributor
private void ValidateContributor(HttpContext context)
{
string contributor = context.Request.Params["contributor"];
Data.dbml.AppUsers user = this.GetDataContext2.AppUsers.FirstOrDefault(o => o.Email == contributor || o.Name == contributor);
if (user != null)
{
if (user.ID == Common.UserID)
context.Response.WriteError(strings.Contributor_Warn);
else
{
context.WriteJsonP(JsonConvert.SerializeObject(new
{
user.Email,
user.Avatar,
Name = string.IsNullOrEmpty(user.FirstName) ? user.Name : user.FirstName,
UN = user.Name
}));
}
}
else
context.Response.WriteError(strings.User_Not_Exist);
}
示例10: Upload1
private void Upload1(HttpContext context)
{
string tpath = Common.Temp;
if (!Directory.Exists(tpath))
Directory.CreateDirectory(tpath);
HttpPostedFile file = context.Request.Files[0];
string nfn = Guid.NewGuid().ToString() + "." + file.FileName.Split('.')[1];
string fp = Common.RelTemp + "/" + nfn;
file.SaveAs(tpath + "\\" + nfn);
context.WriteJsonP(JsonConvert.SerializeObject(new { file = fp, fn = nfn }));
}
示例11: GetCategoriesandBoards
private void GetCategoriesandBoards(HttpContext context)
{
var categories = (from o in all where o.ParentID == null select o).AsEnumerable().Select((o, i) => new
{
index = i,
ID = o.ID,
Name = o.Name,
SubCategories = SubCategories(o, all)
});
//List<object> boards = new List<object>();
var boards = (from o in GetHairStyleContext2.Boards
where o.UserID == Common.UserID ||
(from o1 in this.GetHairStyleContext2.BoardContributor where o1.ContributorID == Common.UserID select o1.BoardID).Contains(o.ID)
select new
{
o.ID,
o.Name
}).Distinct();
int points = GetHairStyleContext2.AppUsers.Single(o => o.ID == Common.UserID).Points ?? 0;
context.WriteJsonP(JsonConvert.SerializeObject(new
{
categories,
boards,
points
}, Formatting.Indented, Common.JsonSerializerSettings));
}
示例12: Default
private void Default(HttpContext context)
{
List<object> files = new List<object>();
string cat = context.Request.QueryString["cat"];
string q = context.Request.QueryString["q"];
int p = int.Parse(context.Request.QueryString["p"]);
int ps = Common.PageSize;
if (cat != null)
{
var catimgs = Common.Compiled.CategoryImages(GetHairStyleContext2, p, ps, cat).Select((o, i) => new
{
o.ID,
editable = false,
o.BoardID,
title = o.Image_Title,
height = o.Image_Height,
PinID = o.PinID.ToString(),
imgsource = o.Source,
width = o.Image_Width,
cats = Common.XmlToJArray(o.Cats),
comments = Common.XmlToJArray(o.Comments),
bimid = o.BIMID,
source = Common.GetAbsoluteUri(o.Source),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(catimgs, Formatting.Indented, Common.JsonSerializerSettings));
return;
}
if (q != null)
{
var _q = Common.Compiled.Query(this.GetHairStyleContext2, p, ps, q).Select((o, i) => new
{
o.ID,
editable = false,
o.BoardID,
title = o.Image_Title,
source = Common.GetAbsoluteUri(o.Source),
imgsource = o.Source,
width = o.Image_Width,
cats = Common.XmlToJArray(o.Cats),
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
height = o.Image_Height,
PinID = o.PinID.ToString(),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
});
context.WriteJsonP(JsonConvert.SerializeObject(_q, Formatting.Indented, Common.JsonSerializerSettings));
return;
}
//CachedMashups(context, ps, p);
context.WriteJsonP(JsonConvert.SerializeObject(Common.Compiled.Images(this.GetHairStyleContext2, p, ps ).Select((o, i) => new
{
o.ID,
editable = false,
title = o.Image_Title,
o.liked,
o.BoardID,
imgsource = o.Source,
cats = Common.XmlToJArray(o.Cats),
comments = Common.XmlToJArray(o.Comments),
o.BIMID,
width = o.Image_Width,
source = Common.GetAbsoluteUri(o.Source),
height = o.Image_Height,
PinID = o.PinID.ToString(),
url = ((o.Uploaded ?? false) ? Common.UploadedImageRelPath : Common.ContentUrl) + o.RelativeImage_Path.Trim()
}).Randomize(), Formatting.Indented, Common.JsonSerializerSettings));
}
示例13: AddComment
private void AddComment(HttpContext context)
{
string comments = context.Request.Params["comments"];
int id = int.Parse(context.Request.Params["id"]);
Data.dbml.Comments c = new Data.dbml.Comments();
c.Comment = comments;
c.BoardsImagesMappingID = id;
c.UserID = Common.UserID.Value;
Data.dbml.AppUsers user = this.GetDataContext2.AppUsers.Single(o => o.ID == Common.UserID);
this.GetDataContext2.Comments.InsertOnSubmit(c);
this.GetDataContext2.SubmitChanges();
context.WriteJsonP(JsonConvert.SerializeObject(new
{
Comment = comments,
Name = user.FirstName,
Avatar = user.Avatar,
UN = user.Name
}));
}
示例14: GetBoards
private void GetBoards(HttpContext context)
{
var boards = Common.Compiled.Boards(GetDataContext2, (Common.VUserID ?? Common.UserID));
context.WriteJsonP(JsonConvert.SerializeObject(boards, Formatting.Indented, Common.JsonSerializerSettings));
}
示例15: Review
private void Review(HttpContext context)
{
string answer = context.Request.Params["ans"];
string question = context.Request.Params["ques"];
int bimid = int.Parse(context.Request.Params["bimid"]);
Data.dbml.Review review = GetDataContext2.Review.FirstOrDefault(o => o.BIMID == bimid && (o.UserID == Common.UserID || o.SessionID == Common.SessionID));
if (review == null)
{
review = new Data.dbml.Review();
review.Answer = answer;
review.BIMID = bimid;
review.Question = question;
review.UserID = Common.UserID;
review.SessionID = Common.SessionID;
GetDataContext2.Review.InsertOnSubmit(review);
if (Common.UserID.HasValue)
{
GetDataContext1.Update(new Data.POCOS.AppUser() { ID = Common.UserID.Value, Points = Common.Points }, new[] { "Points" });
}
}
else
{
review.Answer = answer;
review.Question = question;
}
GetDataContext2.SubmitChanges();
var q = from o in GetDataContext2.Review where (o.UserID == Common.UserID || o.SessionID == Common.SessionID) select o.BIMID;
context.WriteJsonP(JsonConvert.SerializeObject(q));
}