private void GetJsonForDatagrid(HttpContext context) { int totalRecords = 0; int pageIndex = 1; int pageSize = 10; int.TryParse(context.Request.QueryString["page"], out pageIndex); int.TryParse(context.Request.QueryString["rows"], out pageSize); ContentPicture bll = new ContentPicture(); var list = bll.GetList(pageIndex, pageSize, out totalRecords, "", null); if (list == null || list.Count == 0) { context.Response.Write("{\"total\":0,\"rows\":[]}"); return; } StringBuilder sb = new StringBuilder(); foreach (var model in list) { sb.Append("{\"Id\":\"" + model.Id + "\",\"OriginalPicture\":\"" + model.OriginalPicture.Replace("~", "") + "\",\"BPicture\":\"" + model.BPicture + "\",\"MPicture\":\"" + model.MPicture + "\",\"SPicture\":\"" + model.SPicture + "\",\"OtherPicture\":\"" + model.OtherPicture + "\",\"LastUpdatedDate\":\"" + model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm") + "\"},"); } context.Response.Write("{\"total\":" + totalRecords + ",\"rows\":[" + sb.ToString().Trim(',') + "]}"); }
private void Bind() { int totalRecords = 0; ContentPicture cpBll = new ContentPicture(); rpData.DataSource = cpBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); myDataAppend.Append("<div code=\"myDataForPage\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\"}]</div>"); }
private void Bind() { GetSearchItem(); int totalRecords = 0; ContentPicture bll = new ContentPicture(); rpData.DataSource = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); myDataAppend += "<div id=\"myDataForPage\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>"; }
private void Bind() { if (!string.IsNullOrEmpty(funName)) { int totalRecords = 0; switch (funName) { case "CategoryPicture": CategoryPicture categorypBll = new CategoryPicture(); rpData.DataSource = categorypBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); break; case "ProductPicture": ProductPicture ppBll = new ProductPicture(); rpData.DataSource = ppBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); break; case "SizePicture": SizePicture spBll = new SizePicture(); rpData.DataSource = spBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); break; case "ContentPicture": ContentPicture cpBll = new ContentPicture(); rpData.DataSource = cpBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); break; case "ServicePicture": ServicePicture servepBll = new ServicePicture(); rpData.DataSource = servepBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); break; default: break; } myDataAppend.Replace("{TotalRecord}", totalRecords.ToString()); myDataAppend.Replace("{PageIndex}", pageIndex.ToString()); myDataAppend.Replace("{PageSize}", pageSize.ToString()); //myDataAppend.Append("<div code=\"myDataForPage\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\"}]</div>"); //myDataAppend.Append("<div code=\"myDataForDlg\">[{\"DlgId\":\"" + dlgId + "\",\"DlgHref\":\"/a/tyy.html\",\"IsMutilSelect\":\"" + isMutilSelect + "\"}]</div>"); } }
private void createContentPicturesByUploadingPictures() { try { int contentId = 0; int.TryParse(context.Request["contentId"], out contentId); if (contentId <= 0) { throw new Exception("content belirsiz"); } Content c = currentDatabase.Read <Content>(contentId); string folderName = "/UserFiles/aktor/" + c.InsertDate.ToString("yyyyMM") + "/" + contentId; string path = Provider.MapPath(folderName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } for (int i = 0; i < context.Request.Files.Count; i++) { string fileName = Path.GetFileName(context.Request.Files[i].FileName).MakeFileName(); context.Request.Files[i].SaveAs(Path.Combine(path, fileName)); string imgUrl = folderName + "/" + fileName; var cp = new ContentPicture { ContentId = contentId, FileName = imgUrl }; cp.Save(); } context.Response.Write(@"<script>window.parent.location.reload();</script>"); } catch { context.Response.Write(@"<script>window.parent.alert('Yükleme başarısız.');</script>"); } }
public void AddContentPicture(ContentPicture contentPicture) { _contetPictuRepository.Insert(contentPicture); }
private void OnUpload(HttpContext context) { string errorMsg = ""; try { int effect = 0; bool isCreateThumbnail = ConfigHelper.GetValueByKey("IsCteateContentPictureThumbnail") == "1"; UploadFilesHelper ufh = new UploadFilesHelper(); HttpFileCollection files = context.Request.Files; foreach (string item in files.AllKeys) { if (files[item] == null || files[item].ContentLength == 0) { continue; } string[] paths = ufh.Upload(files[item], "ContentPictures", isCreateThumbnail); ContentPicture ppBll = new ContentPicture(); ContentPictureInfo ppModel = new ContentPictureInfo(); string originalPicturePath = ""; string bPicturePath = ""; string mPicturePath = ""; string sPicturePath = ""; string otherPicturePath = ""; for (int i = 0; i < paths.Length; i++) { switch (i) { case 0: originalPicturePath = paths[i].Replace("~", ""); break; case 1: bPicturePath = paths[i].Replace("~", ""); break; case 2: mPicturePath = paths[i].Replace("~", ""); break; case 3: sPicturePath = paths[i].Replace("~", ""); break; case 4: otherPicturePath = paths[i].Replace("~", ""); break; default: break; } } ppModel.OriginalPicture = originalPicturePath; ppModel.BPicture = bPicturePath; ppModel.MPicture = mPicturePath; ppModel.SPicture = sPicturePath; ppModel.OtherPicture = otherPicturePath; ppModel.LastUpdatedDate = DateTime.Now; ppBll.Insert(ppModel); effect++; } if (effect == 0) { context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}"); return; } context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}"); } catch (Exception ex) { errorMsg = ex.Message; } if (errorMsg != "") { context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}"); } }
public override void Dispose() { ContentPicture?.Dispose(); }