Пример #1
0
        //swaps current source with its neighbour
        public bool swapWithNeib(bool withTopNeib, Source current)
        {
            if (current == null)
                return false;

            //there is no neighbour, nothing to do
            if (current.RichText.Source.Count <= 1)
                return false;

            //ensure strict ordering
            var orderNr = 0;
            foreach (var s in current.RichText.Source.OrderBy(s => s.OrderNumber))
            {
                s.OrderNumber = orderNr++;
            }

            if (withTopNeib)
            {
                Source topNeib = null;
                foreach (var s in current.RichText.Source.OrderBy(s => s.OrderNumber))
                {
                    if (s == current)
                        break;
                    else
                        topNeib = s;
                }
                //current source is topmost, nothing to do 
                if (topNeib == null)
                    return false;

                var tmp = topNeib.OrderNumber;
                topNeib.OrderNumber = current.OrderNumber;
                current.OrderNumber = tmp;

                return true;
            }
            else
            {
                Source botNeib = null;
                foreach (var s in current.RichText.Source.OrderBy(s => s.OrderNumber).Reverse())
                {
                    if (s == current)
                        break;
                    else
                        botNeib = s;
                }
                //current source is bottommost, nothing to do 
                if (botNeib == null)
                    return false;

                var tmp = botNeib.OrderNumber;
                botNeib.OrderNumber = current.OrderNumber;
                current.OrderNumber = tmp;

                return true;
            }
        }
Пример #2
0
	void EmitSourceCell(Source s, int i)
    {
		if(s==null)
			return;

		
        
        #line default
        #line hidden
        
        #line 254 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write("\t\t<div style=\"padding-top:40px\">\r\n\t\t   ");

        
        #line default
        #line hidden
        
        #line 256 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(i));

        
        #line default
        #line hidden
        
        #line 256 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write(". <a href=\"");

        
        #line default
        #line hidden
        
        #line 256 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(s.Text));

        
        #line default
        #line hidden
        
        #line 256 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write("\">");

        
        #line default
        #line hidden
        
        #line 256 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(s.Text));

        
        #line default
        #line hidden
        
        #line 256 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"
this.Write("</a>\r\n\t\t</div> \r\n\t\t");

        
        #line default
        #line hidden
        
        #line 258 "C:\Users\User\Documents\Visual Studio 2013\Projects\TDS4\discussions\DiscSvc2\Reporting\Report.tt"

    }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Source EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSource(Source source)
 {
     base.AddObject("Source", source);
 }
Пример #4
0
 /// <summary>
 /// Create a new Source object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 /// <param name="orderNumber">Initial value of the OrderNumber property.</param>
 public static Source CreateSource(global::System.Int32 id, global::System.String text, global::System.Int32 orderNumber)
 {
     Source source = new Source();
     source.Id = id;
     source.Text = text;
     source.OrderNumber = orderNumber;
     return source;
 }
        public Discussion cloneDiscussion(DiscCtx ctx, Discussion original, Person moderator, int i)
        {
            var d = new Discussion();
            d.Subject = injectNumber(original.Subject, i);

            //copy background
            d.Background = new RichText();
            d.Background.Text = original.Background.Text;
            foreach (var src in original.Background.Source)
            {
                var s = new Source();
                s.Text = src.Text;
                s.OrderNumber = src.OrderNumber;
                d.Background.Source.Add(s);
            }

            foreach (var media in original.Attachment)
            {
                var attach = new Attachment();
                attach.Discussion = d;
                attach.Format = media.Format;
                attach.Link = media.Link;
                attach.Name = media.Name;
                attach.Title = media.Title;
                attach.VideoEmbedURL = media.VideoEmbedURL;
                attach.VideoLinkURL = media.VideoLinkURL;
                attach.VideoThumbURL = media.VideoThumbURL;
                attach.OrderNumber = media.OrderNumber;

                if (media.Thumb != null)
                    attach.Thumb = (byte[]) media.Thumb.Clone();

                if (media.MediaData != null && media.MediaData.Data != null)
                {
                    var mediaClone = new MediaData();
                    mediaClone.Data = (byte[]) media.MediaData.Data.Clone();
                    attach.MediaData = mediaClone;
                }

                attach.Person = moderator;

                d.Attachment.Add(attach);
            }

            d.HtmlBackground = original.HtmlBackground;

            foreach (var topic in original.Topic)
            {
                var t = new Topic();
                t.Name = injectNumber(topic.Name, i);
                t.Person.Add(moderator);
                d.Topic.Add(t);
            }

            return d;
        }
Пример #6
0
 public void onSourceUpDown(object sender, RoutedEventArgs e)
 {
     try
     {
         _srcToReposition = ((SourceUC) e.OriginalSource).DataContext as Source;
         srcPopup.IsOpen = true;
         HwndSource hwndSource =
             (HwndSource) PresentationSource.FromVisual((Visual) VisualTreeHelper.GetParent(srcPopup.Child));
         hwndSource.EnableSurfaceInput();
     }
     catch (Exception)
     {
         _srcToReposition = null;
     }
 }
Пример #7
0
 public SSource(Source s)
 {
     Id = s.Id;
     Text = s.Text;
     OrderNumber = s.OrderNumber;
 }
Пример #8
0
        private void processSrcUpDown(bool up, Source current)
        {
            if (current == null)
                return;

            if (srcMover.swapWithNeib(up, current))
            {
                current.RichText.ArgPoint.ChangesPending = true;
                BeginSrcNumberInjection();
                UpdateOrderedSources();
            }
        }
Пример #9
0
        public void AddSourceArgPoint(int pointId, string text, int callerId)
        {
            using (var ctx = new DiscCtx(ConfigManager.ConnStr))
            {
                var point = ctx.ArgPoint.FirstOrDefault(ap => ap.Id == pointId);
                if (point == null)
                    return;

                var lastSrc = point.Description.Source.OrderBy(s => s.OrderNumber).LastOrDefault();

                int orderNumber = lastSrc != null ? lastSrc.OrderNumber + 1 : 1;

                var source = new Source
                {
                    OrderNumber = orderNumber, 
                    RichText = null, 
                    Text = text
                };
                point.Description.Source.Add(source);

                ctx.SaveChanges();
            }
        }
Пример #10
0
        private void processSrcUpDown(bool up, Source current)
        {
            if (current == null)
                return;

            if (srcMover.swapWithNeib(up, current))
            {
                BeginDeferredItemTemplateHandle();
                UpdateOrderedSources();
            }
        }
Пример #11
0
        public static ArgPoint clonePoint(DiscCtx ctx, ArgPoint ap, Topic topic, Person owner, String name)
        {
            var top = ctx.Topic.FirstOrDefault(t0 => t0.Id == topic.Id);
            if (top == null)
                return null;

            var ownPoints = top.ArgPoint.Where(p0 => p0.Person.Id == owner.Id);
            int orderNr = 1;
            foreach (var pt in ownPoints)
            {
                if (pt.OrderNumber > orderNr)
                    orderNr = pt.OrderNumber;
            }

            var pointCopy = DaoUtils.NewPoint(top, orderNr + 1);
            pointCopy.Point = name;
            pointCopy.Description.Text = ap.Description.Text;

            foreach (var src in ap.Description.Source)
            {
                var newSrc = new Source {Text = src.Text};
                pointCopy.Description.Source.Add(newSrc);
            }

            foreach (var cmt in ap.Comment)
            {
                if (cmt.Person == null)
                    continue;

                var comment = new Comment();
                comment.Text = cmt.Text;
                var commentPersonId = cmt.Person.Id;
                comment.Person = ctx.Person.FirstOrDefault(p0 => p0.Id == commentPersonId);
                pointCopy.Comment.Add(comment);
            }

            var ownId = SessionInfo.Get().person.Id;
            var self = ctx.Person.FirstOrDefault(p0 => p0.Id == ownId);
            foreach (var media in ap.Attachment)
            {
                var attach = new Attachment();
                attach.ArgPoint = pointCopy;
                attach.Format = media.Format;
                attach.Link = media.Link;
                attach.Name = media.Name;
                attach.Title = media.Title;
                attach.VideoEmbedURL = media.VideoEmbedURL;
                attach.VideoLinkURL = media.VideoLinkURL;
                attach.VideoThumbURL = media.VideoThumbURL;
                attach.OrderNumber = media.OrderNumber;

                if (media.Thumb != null)
                    attach.Thumb = (byte[])media.Thumb.Clone();

                if (media.MediaData != null && media.MediaData.Data != null)
                {
                    var mediaClone = new MediaData();
                    mediaClone.Data = (byte[])media.MediaData.Data.Clone();
                    attach.MediaData = mediaClone;
                }

                attach.Person = self;
            }

            pointCopy.Person = self;

            pointCopy.Topic = top;

            return pointCopy;
        }
Пример #12
0
        public static void AddSource(string newSrc, RichText richText)
        {
            if (richText == null)
                return;

            Source src = new Source();
            src.Text = newSrc;
            richText.Source.Add(src);
        }