Esempio n. 1
0
		public void UpClick(object o, System.EventArgs e)
		{
			//Find the two paras in this page that have lower orders...
			Query qLower = new Query();
			qLower.NoLock = false;
			qLower.QueryCondition = new And(
				new Q(Para.Columns.ArticleK, CurrentPara.ArticleK),
				new Q(Para.Columns.Page, CurrentPara.Page),
				new Q(Para.Columns.Order, QueryOperator.LessThan, CurrentPara.Order)
				);
			qLower.TopRecords = 2;
			qLower.OrderBy = new OrderBy(Para.Columns.Order, OrderBy.OrderDirection.Descending);
			ParaSet ps = new ParaSet(qLower);
			if (ps.Count == 2)
			{
				//put this para in between
				CurrentPara.Order = (ps[0].Order + ps[1].Order) / 2.0;
				CurrentPara.Update();
				CurrentPara.Article.ReOrder(CurrentPara.Page);
			}
			else if (ps.Count == 1)
			{
				CurrentPara.Order = ps[0].Order - 1.0;
				CurrentPara.Update();
				CurrentPara.Article.ReOrder(CurrentPara.Page);
			}
			else
			{
				if (CurrentPara.Page > 1)
				{
					CurrentPara.Page = CurrentPara.Page - 1;
					//find the greatest order in the previous page, and put this para after it.
					Query qPrev = new Query();
					qPrev.NoLock = false;
					qPrev.QueryCondition = new And(
						new Q(Para.Columns.ArticleK, CurrentPara.ArticleK),
						new Q(Para.Columns.Page, CurrentPara.Page)
						);
					qPrev.TopRecords = 1;
					qPrev.OrderBy = new OrderBy(Para.Columns.Order, OrderBy.OrderDirection.Descending);
					ParaSet psPrev = new ParaSet(qPrev);
					if (psPrev.Count == 1)
						CurrentPara.Order = psPrev[0].Order + 1.0;
					else
						CurrentPara.Order = 1.0;
					CurrentPara.Update();
					CurrentPara.Article.ReOrder(CurrentPara.Page + 1);
				}
			}
			MyArticlesPage.BindBodyPageRepeater();
			MyArticlesPage.AnchorSkip("ArticlePage" + CurrentPara.Page);
		}
Esempio n. 2
0
		public Para EditArticleParaSave()
		{
			Para p = null;
			if (ContainerPage.Url["New"] == 1)
			{
				p = new Para();

				p.ArticleK = CurrentPara.ArticleK;
				p.Page = CurrentPara.Page;

				Query qHigher = new Query();
				qHigher.QueryCondition = new And(
					new Q(Para.Columns.ArticleK, CurrentPara.ArticleK),
					new Q(Para.Columns.Page, CurrentPara.Page),
					new Q(Para.Columns.Order, QueryOperator.GreaterThanOrEqualTo, CurrentPara.Order)
				);
				qHigher.TopRecords = 2;
				qHigher.OrderBy = new OrderBy(Para.Columns.Order, OrderBy.OrderDirection.Ascending);
				ParaSet ps = new ParaSet(qHigher);
				if (ps.Count == 2)
				{
					//put this para in between
					p.Order = (ps[0].Order + ps[1].Order) / 2.0;
				}
				else if (ps.Count == 1)
				{
					p.Order = ps[0].Order + 1.0;
				}
				else
				{
					throw new Exception("Prror placing para sdfmhdsaljkhsdaflkjh. Contact support quoting this error.");
				}
			}
			else
			{
				p = CurrentPara;
			}

			if (EditArticleParaTypeTitle.Checked)
				p.Type = Para.TypeEnum.Title;
			else if (EditArticleParaTypePara.Checked)
				p.Type = Para.TypeEnum.Para;
			else
				p.Type = Para.TypeEnum.Photo;

			if (p.Type.Equals(Para.TypeEnum.Title))
				p.Text = EditArticleParaHtml.GetPlainText();
			else
				p.Text = EditArticleParaHtml.GetHtml();

			p.Update();

			if (ContainerPage.Url["New"] == 1)
			{
				p.Article.ReOrder(CurrentPara.Page);
			}
			return p;

		}
Esempio n. 3
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;

			this.ContentDisabled = false;
			this.Update(transaction);

			try
			{
				UsrSet usPhotoPic = new UsrSet(new Query(new Q(Usr.Columns.PicPhotoK, this.K)));
				foreach (Usr u in usPhotoPic)
				{
					try
					{
						Guid picToDelete = u.Pic;

						u.Pic = Guid.Empty;
						u.PicPhotoK = 0;
						u.PicState = "";
						u.Update(transaction);

						Storage.RemoveFromStore(Storage.Stores.Pix, picToDelete, "jpg");

					}
					catch { }
				}
			}
			catch { }


			try
			{
				if (this.Gallery.MainPhotoK == this.K)
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Photo.Columns.GalleryK, this.GalleryK),
						Photo.EnabledQueryCondition
					);
					q.OrderBy = new OrderBy(Photo.Columns.DateTime);
					q.Columns = new ColumnSet(Photo.Columns.K, Photo.Columns.Status);
					PhotoSet psMain = new PhotoSet(q);
			
					int firstDisabled = 0;
					foreach (Photo p in psMain)
					{
						if (p.K != this.K)
						{
							if (p.Status == StatusEnum.Enabled)
							{
								this.Gallery.MainPhotoK = p.K;
								break;
							}
							else if (firstDisabled == 0)
								firstDisabled = p.K;
						}
					}
					if (firstDisabled > 0)
						this.Gallery.MainPhotoK = firstDisabled;
					
					this.Gallery.Update(transaction);
					
					//PhotoSet psMain = new PhotoSet(
					//                            new Query(
					//                                new And(
					//                                new Q(Photo.Columns.K, QueryOperator.NotEqualTo, this.K),
					//                                new Q(Photo.Columns.GalleryK, this.GalleryK),
					//                                Photo.EnabledQueryCondition),
					//                                new OrderBy(Photo.Columns.DateTime),
					//                                1
					//                            )
					//                        );
					//if (psMain.Count > 0)
					//{
					//    this.Gallery.MainPhotoK = psMain[0].K;
					//}
					//else
					//{
					//    PhotoSet psMain1 = new PhotoSet(
					//        new Query(
					//            new And(
					//                new Q(Photo.Columns.K, QueryOperator.NotEqualTo, this.K),
					//                new Q(Photo.Columns.GalleryK, this.GalleryK)
					//            ),
					//            new OrderBy(Photo.Columns.DateTime),
					//            1
					//        )
					//    );
					//    if (psMain1.Count > 0)
					//    {
					//        this.Gallery.MainPhotoK = psMain1[0].K;
					//    }
					//    else
					//    {
					//        this.Gallery.MainPhotoK = 0;
					//    }
					//}
					//this.Gallery.Update(transaction);
				}
			}
			catch { }

			try
			{
				Delete UsrPhotoFavouriteDelete = new Delete(
					TablesEnum.UsrPhotoFavourite,
					new Q(UsrPhotoFavourite.Columns.PhotoK, this.K)
					);
				UsrPhotoFavouriteDelete.Run(transaction);
			}
			catch { }

			try
			{
				Delete UsrPhotoMeDelete = new Delete(
					TablesEnum.UsrPhotoMe,
					new Q(UsrPhotoMe.Columns.PhotoK, this.K)
					);
				UsrPhotoMeDelete.Run(transaction);
			}
			catch { }

			try
			{
				Delete CommentAlertDelete = new Delete(
					TablesEnum.CommentAlert,
					new And(
					new Q(CommentAlert.Columns.ParentObjectK, this.K),
					new Q(CommentAlert.Columns.ParentObjectType, Model.Entities.ObjectType.Photo)
					)
				);
				CommentAlertDelete.Run(transaction);
			}
			catch { }

			try
			{
				if (this.ThreadK.HasValue && this.ThreadK.Value > 0)
					this.Thread.DeleteAll(transaction);
			}
			catch { }

			try
			{
				ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.PhotoK, this.K)));
				foreach (Thread t in ts)
				{
					t.DeleteAll(transaction);
				}
			}
			catch { }

			try
			{
				Delete PhotoReviewDelete = new Delete(
					TablesEnum.PhotoReview,
					new Q(PhotoReview.Columns.PhotoK, this.K)
					);
				PhotoReviewDelete.Run(transaction);
			}
			catch { }

			try
			{
				ParaSet ps = new ParaSet(new Query(new Q(Para.Columns.PhotoK, this.K)));
				foreach (Para p in ps)
				{
					if (p.Type.Equals(Para.TypeEnum.Photo))
						p.DeleteAll(transaction);
					else
					{
						Guid oldPic = p.Pic;

						p.Pic = Guid.Empty;
						p.PhotoK = 0;
						p.Update(transaction);

						if (oldPic != Guid.Empty)
							Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");
					}
				}
			}
			catch { }

			try
			{
				foreach (var tagPhoto in this.ChildTagPhotos())
				{
					foreach (var tagPhotoHistory in tagPhoto.ChildTagPhotoHistorys())
					{
						tagPhotoHistory.Delete(transaction);
					}
					tagPhoto.Delete(transaction);
				}
			}
			catch { }

			Guid uploadTemporary = this.UploadTemporary;
			string uploadTemporaryExtention = this.UploadTemporaryExtention;
			Guid master = this.Master;
			Guid web = this.Web;
			Guid thumb = this.Thumb;
			Guid icon = this.Icon;
			bool isVideo = this.MediaType == MediaTypes.Video;
			Guid videoMaster = this.VideoMaster;
			string videoFileExtention = this.VideoFileExtention;
			Guid videoMed = this.VideoMed;
			bool hasCrop = this.HasCrop;
			Guid crop = this.HasCrop ? this.Crop : Guid.Empty;


			try
			{
				this.Delete(transaction);
			}
			catch { }

			try
			{

				Storage.RemoveFromStore(Storage.Stores.Temporary, uploadTemporary, uploadTemporaryExtention);
				Storage.RemoveFromStore(Storage.Stores.Master, master, "jpg");
				Storage.RemoveFromStore(Storage.Stores.Pix, web, "jpg");
				Storage.RemoveFromStore(Storage.Stores.Pix, thumb, "jpg");
				Storage.RemoveFromStore(Storage.Stores.Pix, icon, "jpg");
				if (isVideo)
				{
					Storage.RemoveFromStore(Storage.Stores.Master, videoMaster, videoFileExtention);
					Storage.RemoveFromStore(Storage.Stores.Pix, videoMed, "flv");
				}
				if (hasCrop)
					Storage.RemoveFromStore(Storage.Stores.Pix, crop, "jpg");
			}
			catch { }

			try
			{
				this.Usr.UpdateTotalPhotos(transaction);
			}
			catch { }

			try
			{
				this.Gallery.UpdateStats(transaction, true);
			}
			catch { }

			try
			{
				this.Gallery.UpdatePhotoOrder(transaction);
			}
			catch { }

			try
			{
				if (this.Event != null)
					this.Event.UpdateTotalPhotos(transaction);
			}
			catch { }

		}
Esempio n. 4
0
		public void ReOrder(int page)
		{
			Query q = new Query();
			q.QueryCondition=new And(
				new Q(Para.Columns.ArticleK,this.K),
				new Q(Para.Columns.Page,page)
			);
			q.OrderBy=new OrderBy(Para.Columns.Order);
			ParaSet ps = new ParaSet(q);
			double order = 1.0;
			foreach (Para p in ps)
			{
				p.Order=order;
				order = order + 1.0;
				p.Update();
			}
		}
Esempio n. 5
0
		public void DownClick(object o, System.EventArgs e)
		{
			//Find the two paras in this page that have higher orders...
			Query qHigher = new Query();
			qHigher.NoLock = false;
			qHigher.QueryCondition = new And(
				new Q(Para.Columns.ArticleK, CurrentPara.ArticleK),
				new Q(Para.Columns.Page, CurrentPara.Page),
				new Q(Para.Columns.Order, QueryOperator.GreaterThan, CurrentPara.Order)
				);
			qHigher.TopRecords = 2;
			qHigher.OrderBy = new OrderBy(Para.Columns.Order, OrderBy.OrderDirection.Ascending);
			ParaSet ps = new ParaSet(qHigher);
			if (ps.Count == 2)
			{
				//put this para in between
				CurrentPara.Order = (ps[0].Order + ps[1].Order) / 2.0;
				CurrentPara.Update();
				CurrentPara.Article.ReOrder(CurrentPara.Page);
			}
			else if (ps.Count == 1)
			{
				CurrentPara.Order = ps[0].Order + 1.0;
				CurrentPara.Update();
				CurrentPara.Article.ReOrder(CurrentPara.Page);
			}
			else
			{
				if (CurrentPara.Page < CurrentPara.Article.LastPage || (CurrentPara.Page == CurrentPara.Article.LastPage && CurrentPara.Article.GetParaInPage(CurrentPara.Article.LastPage).Count > 1))
				{
					CurrentPara.Page = CurrentPara.Page + 1;
					//find the lowest order in the next page, and put this para before it.
					Query qNext = new Query();
					qNext.NoLock = false;
					qNext.QueryCondition = new And(
						new Q(Para.Columns.ArticleK, CurrentPara.ArticleK),
						new Q(Para.Columns.Page, CurrentPara.Page)
						);
					qNext.TopRecords = 1;
					qNext.OrderBy = new OrderBy(Para.Columns.Order, OrderBy.OrderDirection.Ascending);
					ParaSet psNext = new ParaSet(qNext);
					if (psNext.Count == 1)
						CurrentPara.Order = psNext[0].Order - 1.0;
					else
						CurrentPara.Order = 1.0;
					CurrentPara.Update();
					CurrentPara.Article.ReOrder(CurrentPara.Page);
				}
			}
			MyArticlesPage.BindBodyPageRepeater();
			MyArticlesPage.AnchorSkip("ArticlePage" + CurrentPara.Page);
		}