public ActionResult SetLikeState(int noteid, bool liked) { using (LikedManager likedManager = new LikedManager()) { using (SharingManager sharingManager = new SharingManager()) { int result = 0; Liked like = likedManager.Find(x => x.Shareing.Id == noteid && x.likedUser.Id == CurrentSession.shareBookUser.Id && !x.likedUser.isDeleted && !x.Shareing.isDelete); Sharing share = sharingManager.Find(x => x.Id == noteid && !x.Owner.isDeleted && !x.isDelete && !x.Owner.isDeleted); if (like != null && liked == false) { result = likedManager.Delete(like); } else if (like == null && liked == true) { result = likedManager.Insert(new Liked() { likedUser = CurrentSession.shareBookUser, Shareing = share }); } if (result > 0) { if (liked) { share.LikeCount++; } else { share.LikeCount--; } sharingManager.Update(share); return(Json(new { hasError = false, errorMessage = string.Empty, result = share.Likes.Where(x => !x.likedUser.isDeleted).ToList().Count })); } return(Json(new { hasError = true, errorMessage = "Beğenme işlemi gerçekleştirilemedi", result = share.Likes.Where(x => !x.likedUser.isDeleted).ToList().Count })); } } }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); //TODO: Save application state and stop any background activity deferral.Complete(); if (dispatcherTimer != null) { dispatcherTimer.Stop(); dispatcherTimer = null; } if (SharingMgr != null) { SharingMgr.Dispose(); SharingMgr = null; } }
public ActionResult ShowSharingDetail(int?id) { using (SharingManager sharingManager = new SharingManager()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sharing share = sharingManager.Find(x => x.Id == id && !x.isDelete); if (share == null) { return(HttpNotFound()); } return(PartialView("_PartialSharingDetail", share)); } }
public ActionResult Insert(Comment comment, int?note_id) { using (SharingManager sharingManager = new SharingManager()) { using (CommentManager commentManager = new CommentManager()) { if (ModelState.IsValid) { if (note_id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sharing sharing = sharingManager.Find(x => x.Id == note_id && !x.isDelete && !x.isDraft && !x.Owner.isDeleted); if (sharing == null) { return(new HttpNotFoundResult()); } if (comment != null) { comment.Sharing = sharing; comment.Owner = CurrentSession.shareBookUser; if (commentManager.Insert(comment) > 0) { return(Json(new { Result = true }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Result = false }, JsonRequestBehavior.AllowGet)); } return(Json(new { Result = false }, JsonRequestBehavior.AllowGet)); } } }
public XToolsApp(string[] args = null) { parsedArguments = ParseCommandLine(args); this.logWriter = new ConsoleLogWriter(); ClientConfig config = new ClientConfig(ClientRole.Primary); config.SetServerAddress(GetArgumentOrDefault("sessionserver", "localhost")); config.SetLogWriter(this.logWriter); this.Manager = SharingManager.Create(config); this.syncListener = new ConsoleSyncReporter(); this.viewerConnection = this.Manager.GetPairedConnection(); this.serverConnection = this.Manager.GetServerConnection(); this.SessionManager = this.Manager.GetSessionManager(); BeginPairing(); ViewerListener = new NetworkConnectionAdapter(); ViewerListener.ConnectedCallback += this.OnViewerConnected; ViewerListener.ConnectionFailedCallback += this.OnViewerConnectionFailed; ViewerListener.DisconnectedCallback += this.OnViewerDisconnected; viewerConnection.AddListener((byte)MessageID.StatusOnly, ViewerListener); ServerListener = new NetworkConnectionAdapter(); ServerListener.ConnectedCallback += this.OnSessionConnected; ServerListener.ConnectionFailedCallback += this.OnSessionConnectionFailed; ServerListener.DisconnectedCallback += this.OnSessionDisconnected; serverConnection.AddListener((byte)MessageID.StatusOnly, ServerListener); this.rootObject = this.Manager.GetRootSyncObject(); this.rootObject.AddListener(this.syncListener); // Listen for new sessions SessionManagerListener = new XToolsSessionManagerListener(); this.SessionManager.AddListener(SessionManagerListener); }
public void Connect(string server, string userName = "******", int port = 20602, ClientRole clientRole = ClientRole.Primary) { ClientConfig config = new ClientConfig(clientRole); config.SetServerAddress(server); config.SetServerPort(port); config.SetLogWriter(LogWriter); this.SharingManager = SharingManager.Create(config); this.SharingManager.SetUserName(userName); this.viewerConnection = this.SharingManager.GetPairedConnection(); this.serverConnection = this.SharingManager.GetServerConnection(); this.SessionManager = this.SharingManager.GetSessionManager(); BeginPairing(); ViewerListener = new NetworkConnectionAdapter(); ViewerListener.ConnectedCallback += this.OnViewerConnected; ViewerListener.ConnectionFailedCallback += this.OnViewerConnectionFailed; ViewerListener.DisconnectedCallback += this.OnViewerDisconnected; viewerConnection.AddListener((byte)MessageID.StatusOnly, ViewerListener); ServerListener = new NetworkConnectionAdapter(); ServerListener.ConnectedCallback += this.OnSessionConnected; ServerListener.ConnectionFailedCallback += this.OnSessionConnectionFailed; ServerListener.DisconnectedCallback += this.OnSessionDisconnected; serverConnection.AddListener((byte)MessageID.StatusOnly, ServerListener); this.syncListener = new ConsoleSyncReporter(); this.rootObject = this.SharingManager.GetRootSyncObject(); this.rootObject.AddListener(this.syncListener); SessionManagerListener = new XToolsSessionManagerListener(this.LogWriter); this.SessionManager.AddListener(SessionManagerListener); networkMessageLoop = new Timer(new TimerCallback((a) => Update()), null, 0, 1000); }
// GET: Comment public ActionResult ShowCommentsandLikes(int?id) { using (SharingManager sharingManager = new SharingManager()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sharing share = sharingManager.ListQueryable().Include(x => x.Comments).Where(x => x.Id == id && !x.isDelete && !x.isDraft && !x.Owner.isDeleted).FirstOrDefault(); if (share == null) { return(HttpNotFound()); } var modelComments = share.Comments.Where(x => !x.isDelete && !x.Owner.isDeleted).ToList(); var modelLikes = share.Likes.Where(x => !x.likedUser.isDeleted).ToList(); return(PartialView("_PartialComments", new LikeCommentViewModel <List <Liked>, List <Comment> >() { Comments = modelComments, Likes = modelLikes })); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SharingManager obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
// Pumps the network message loop public void Update() { SharingManager?.Update(); }
public ActionResult Search(string search) { using (SharingManager sharingManager = new SharingManager()) { using (SharebookUserManager sharebookUserManager = new SharebookUserManager()) { if (!string.IsNullOrEmpty(search)) { if (search.Length >= 3) { List <SharingViewModel> share = sharingManager.ListQueryable().Where(x => (x.ShareContent.Contains(search) || x.Title.Contains(search)) && !x.isDelete && !x.isDraft && !x.Owner.isDeleted || x.Owner.Username.Contains(search) || x.Owner.Name.Contains(search) || x.Owner.Surname.Contains(search)).Select(x => new SharingViewModel() { Title = x.Title, ShareContent = x.ShareContent, Owner = x.Owner, Category = x.Category, Comments = x.Comments, ModifiedOn = x.ModifiedOn, CreatedOn = x.CreatedOn, ImageUrl = x.ImageUrl, ModifiedBy = x.ModifiedBy, Likes = x.Likes, CategoryId = x.CategoryId, Id = x.Id }).ToList(); List <ShareBookUserViewModel> user = sharebookUserManager.ListQueryable().Where(x => (x.Username.Contains(search) || x.Name.Contains(search) || x.Surname.Contains(search)) && !x.isDeleted).Select(x => new ShareBookUserViewModel() { Comments = x.Comments, activatedGuid = x.activatedGuid, Email = x.Email, Name = x.Name, Username = x.Username, Notes = x.Notes, Password = x.Password, ProfilPhoto = x.ProfilPhoto, Surname = x.Surname, Id = x.Id, isActive = x.isActive, CreatedOn = x.CreatedOn, isAdmin = x.isAdmin, ModifiedOn = x.ModifiedOn, ModifiedBy = x.ModifiedBy, isDeleted = x.isDeleted, Likes = x.Likes }).ToList(); return(View(new SharingUserViewModel <List <ShareBookUserViewModel>, List <SharingViewModel> >() { s = share, sbu = user })); } return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Home")); } } } }
public ActionResult SaveDataInDatabase(Sharing sharing, HttpPostedFileBase file) { using (SharingManager sharingManager = new SharingManager()) { int result = -1; if (ModelState.IsValid) { if (sharing.Id > 0) { var currShare = sharingManager.ListQueryable().Where(a => a.Id == sharing.Id && !a.isDelete).Include(x => x.Category).FirstOrDefault(); if (currShare != null) { string oldPhoto = string.Empty; var oldPhotoRes = sharingManager.Find(x => x.Id == sharing.Id).ImageUrl; // oldPhoto = HttpContext.Server.MapPath("~" + oldPhotoRes); string defaultShareImage = oldPhotoRes.Split('/')[3]; if (defaultShareImage != "sitelogo.png") { oldPhoto = HttpContext.Server.MapPath("~" + oldPhotoRes); } if (file != null) { if (System.IO.File.Exists(oldPhoto)) { System.IO.File.Delete(oldPhoto); } FileHelper fileHelper = new FileHelper(); var imgPath = Server.MapPath("~/Images/SharingImage"); currShare.ImageUrl = fileHelper.SaveImage(file, imgPath, "/Images/SharingImage"); } currShare.isDraft = sharing.isDraft; currShare.CategoryId = sharing.CategoryId; currShare.ShareContent = sharing.ShareContent; currShare.Title = sharing.Title; sharingManager.Update(currShare); result = 1; } } else { if (file != null) { FileHelper fileHelper = new FileHelper(); var imgPath = Server.MapPath("~/Images/SharingImage"); sharing.ImageUrl = fileHelper.SaveImage(file, imgPath, "/Images/SharingImage"); } else { sharing.ImageUrl = "/Images/SharingImage/sitelogo.png"; } sharing.Owner = CurrentSession.shareBookUser; sharingManager.Insert(sharing); result = 2; } return(Json(result, JsonRequestBehavior.AllowGet)); } else { return(View(sharing)); } } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SharingManager obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }