public ActionResult ShowAddFolderOrBookmarkView(long folderID) { long uid = UILoginHelper.GetUIDFromHttpContext(HttpContext); if (folderID == 0) { var lst = BizUserWebFolder.LoadAllByUID(uid); if (lst != null && lst.Count > 0) { var firstFolder = lst.Where(folder => folder.ParentWebfolderID == 0); if (firstFolder == null || firstFolder.Count() == 0) { return(View()); } if (firstFolder.Count() == 1) { folderID = firstFolder.FirstOrDefault().UserWebFolderID; } else { BizUserWebFolder newFolderInfo = new BizUserWebFolder(); newFolderInfo.UserInfoID = uid; newFolderInfo.UserWebFolderID = 0; newFolderInfo.ParentWebfolderID = 0; newFolderInfo.ChildrenFolderList = firstFolder.ToList(); newFolderInfo.BizBookmarkInfoList = new List <BizBookmarkInfo>(); return(View("ShowAddFolderOrBookmarkView", new UIWebFolderInfo(newFolderInfo))); } } } var folderInfo = BizUserWebFolder.LoadContainsChirdrenAndBookmark(folderID); var model = new UIWebFolderInfo(folderInfo); return(View("ShowAddFolderOrBookmarkView", model)); }
private static long GetUserDefaultFolderID(long loginUID) { long folderID = 0; var folderConfiguration = BizUserConfiguration.LoadByKey(loginUID, "UserDefaultFolder"); if (folderConfiguration == null) { var userFolderList = BizUserWebFolder.LoadAllByUID(loginUID); if (userFolderList != null && userFolderList.Count > 0) { var firstFolder = userFolderList.Where(folder => folder.ParentWebfolderID == 0); if (firstFolder != null && firstFolder.Count() > 0) { NewFolderAndConfigurationHasParentFolderID(loginUID, ref folderID, ref folderConfiguration, firstFolder); } else { NewFolderAndConfigurationNoParentFolderID(loginUID, ref folderID, ref folderConfiguration); } } else { NewFolderAndConfigurationNoParentFolderID(loginUID, ref folderID, ref folderConfiguration); } } else { folderID = Convert.ToInt64(folderConfiguration.UserConfigurationValue); } return(folderID); }
public ActionResult ShowUserFolder(long showUserInfoID, long folderID = 0) { UIWebFolderInfo model = null; if (showUserInfoID != default(long)) { if (folderID == 0) { var lst = BizUserWebFolder.LoadAllByUID(showUserInfoID); if (lst != null) { var firstFolder = lst.Where(folder => folder.ParentWebfolderID == 0); if (firstFolder == null || firstFolder.Count() == 0) { return(View("ShowUserFolder", model)); } folderID = firstFolder.FirstOrDefault().UserWebFolderID; } } var folderInfo = BizUserWebFolder.LoadContainsChirdrenAndBookmark(folderID); model = new UIWebFolderInfo(folderInfo); } return(View("ShowUserFolder", model)); }
public ActionResult ShowUserAllFolder(long folderID) { long uid = UILoginHelper.GetUIDFromHttpContext(HttpContext); if (folderID == 0) { var lst = BizUserWebFolder.LoadAllByUID(uid); if (lst != null && lst.Count > 0) { var firstFolder = lst.Where(folder => folder.ParentWebfolderID == 0); if (firstFolder == null || firstFolder.Count() == 0) { return(View()); } folderID = firstFolder.FirstOrDefault().UserWebFolderID; } } var folderInfo = BizUserWebFolder.LoadContainsChirdrenAndBookmark(folderID); var model = new UIWebFolderInfo(folderInfo); return(View("ShowUserAllFolder", model)); }
public static BizResultInfo BatchAddUserWebfolder(List <BizUserWebFolder> lstBizWebfolder) { BizResultInfo result = new BizResultInfo(); if (lstBizWebfolder == null || lstBizWebfolder.Count == 0) { result.IsSuccess = false; result.ErrorMessage = "插入数据不能为空。"; } var lstModel = lstBizWebfolder.Select(biz => biz.ToModel()).ToList(); var isSuccess = webFolderDAL.BatchAdd(lstModel); if (isSuccess) { result.IsSuccess = isSuccess; result.SuccessMessage = "插入成功。"; Dictionary <int, int> dicHash = new Dictionary <int, int>(); foreach (var w in lstBizWebfolder) { if (!dicHash.ContainsKey(w.IElementHashcode)) { dicHash.Add(w.IElementHashcode, w.IElementHashcode); } } var uid = lstBizWebfolder.FirstOrDefault().UserInfoID; var lstDataInfo = BizUserWebFolder.LoadAllByUID(uid); var dicDataInfo = lstDataInfo.Where(datainfo => dicHash.ContainsKey(datainfo.IElementHashcode)).ToDictionary(model => model.IElementHashcode, model => model); result.Target = dicDataInfo; } else { result.IsSuccess = false; result.ErrorMessage = "插入数据失败,可能是外星人劫持了数据库了,也可能是海底电缆被可爱的鲨鱼咬断了....反正重试一下就是。"; } return(result); }
/// <summary> /// 加载书签夹数据 /// </summary> /// <param name="uid"></param> /// <returns></returns> public static BizResultInfo LoadWebfolderByUID(long uid) { var result = new BizResultInfo(); try { var lstWebFolder = BizUserWebFolder.LoadAllByUID(uid); var lstBookmark = BookmarkInfoBo.LoadByUID(uid); Dictionary <long, List <BizBookmarkInfo> > dicWebfolderIDToBookmarkList = new Dictionary <long, List <BizBookmarkInfo> >(); Dictionary <long, List <BizUserWebFolder> > dicParentWebfolderIDToWebfolder = new Dictionary <long, List <BizUserWebFolder> >(); FillDictionary(lstWebFolder, lstBookmark, dicWebfolderIDToBookmarkList, dicParentWebfolderIDToWebfolder); foreach (var webfolder in lstWebFolder) { if (dicWebfolderIDToBookmarkList.ContainsKey(webfolder.UserWebFolderID)) { webfolder.BizBookmarkInfoList = dicWebfolderIDToBookmarkList[webfolder.UserWebFolderID]; } if (dicParentWebfolderIDToWebfolder.ContainsKey(webfolder.UserWebFolderID)) { webfolder.ChildrenFolderList = dicParentWebfolderIDToWebfolder[webfolder.UserWebFolderID]; } } result.IsSuccess = true; result.Target = lstWebFolder; }catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "加载数据失败了,可能是网络挂了,可能这就是命吧。"; result.Target = null; LogHelper.WriteException("LoadWebfolderByUID Exception", ex, new { UID = uid }); } return(result); }