Exemplo n.º 1
0
		private WorkClass GetWC(Report rpt)
		{
			if (!this.ConstantStyle)
				return null;

			WorkClass wc = rpt.Cache.Get(this, "wc") as WorkClass;
			if (wc == null)
			{
				wc = new WorkClass();
				rpt.Cache.Add(this, "wc", wc);
			}
			return wc;
		}
Exemplo n.º 2
0
 public SetWorkClass(WorkClass workClass)
     : this(workClass, false)
 {
 }
Exemplo n.º 3
0
Arquivo: List.cs Projeto: mnisl/OD
		private WorkClass GetValue(Report rpt)
		{
			WorkClass wc = rpt.Cache.Get(this, "wc") as WorkClass;
			if (wc == null)
			{
				wc = new WorkClass(this);
				rpt.Cache.Add(this, "wc", wc);
			}
			return wc;
		}
Exemplo n.º 4
0
        // 测试weibo.cn,抓取所有评论,包含目标微博上的所有评论,以及目标在所有评论者上的评论
        static void weiboCnGrabComments(List<CookieContainer> ccList, string uid, int startPage, int endPage)
        {
            // http://weibo.cn/u/uid?page=N
            string ulogin = "******" + uid + "?page=";

            // 获取博主自身的所有评论,以及所有在评论中出现过的好友数据
            WorkClass maincs = new WorkClass();
            maincs.cc0 = ccList[0];
            maincs.cc1 = ccList[1];
            maincs.startPage = startPage;
            maincs.endPage = endPage;
            maincs.threadName = "启动线程";
            maincs.selfuid = uid;
            WeiboData weiboData = maincs.getTotalComments(ulogin, uid, null);
            Console.WriteLine("1. 搜索到博主评论条数:" + weiboData.comments.Count + ", 评论过的好友个数:" + weiboData.friends.Count);

            // 计算每个线程能分到的好友数量
            int friendsCount = weiboData.friends.Count;
            int threadCount = ccList.Count / 2;
            int n = friendsCount / threadCount;
            bool haveExt = (friendsCount % (ccList.Count / 2)) > 0; // 检查最后一个线程是否有额外的好友数据需要处理
            List<WeiboUser> friends = weiboData.friends.Values.ToList();
            List<Thread> threads = new List<Thread>();
            List<WorkClass> works = new List<WorkClass>();

            // 启动线程,开始抓取好友中的评论
            for (int i = 0; i < threadCount; i++)
            {
                WorkClass wc = new WorkClass();
                wc.cc0 = ccList[2 * i];
                wc.cc1 = ccList[2 * i + 1];
                wc.threadName = "线程" + i;
                wc.startPage = startPage;
                wc.endPage = endPage;
                wc.selfuid = uid;
                int start = n * i;
                int end = (n == (threadCount - 1)) ? friendsCount : n * (i + 1);
                for (int m = start; m < end; m++)
                {
                    wc.friends.Add(friends[m]);
                }
                Thread t = new Thread(new ParameterizedThreadStart(wc.Run));
                t.Name = "线程" + i;
                t.Start();
                works.Add(wc);
                threads.Add(t);
            }

            // 等待线程结束
            while (true)
            {
                bool end = true;
                for (var i = 0; i < threads.Count; i++)
                {
                    if (threads[i].ThreadState == ThreadState.Running)
                    {
                        end = false;
                        continue;
                    }
                    if (!works[i].end)
                    {
                        weiboData.comments.AddRange(works[i].comments);
                        works[i].end = true;
                    }
                }
                if (end)
                {
                    break;
                }
            }

            Console.WriteLine("搜索完成,共 " + weiboData.comments.Count + " 评论.");

            var s = "";
            foreach (var m in weiboData.comments)
            {
                s += m.toString() + "\n";
            }
            File.WriteAllText(uid + "-comment-" + startPage + "-" + endPage + ".txt", s);
        }
Exemplo n.º 5
0
        private void PrepGroups(Report rpt, WorkClass wc)
        {
            if (_Grouping == null)
            {
                return;
            }

            int i = 0;
            // 1) Build array of all GroupExpression objects
            List <GroupExpression> gea = _Grouping.GroupExpressions.Items;

            GroupEntry[] currentGroups = new GroupEntry[1];
            _Grouping.SetIndex(rpt, 0);                 // set the index of this group (so we can find the GroupEntry)
            currentGroups[0] = new GroupEntry(_Grouping, _Sorting, 0);

            // Save the typecodes, and grouping by groupexpression; for later use
            TypeCode[] tcs = new TypeCode[gea.Count];
            Grouping[] grp = new Grouping[gea.Count];
            i = 0;
            foreach (GroupExpression ge in gea)
            {
                grp[i]   = (Grouping)(ge.Parent.Parent);                // remember the group
                tcs[i++] = ge.Expression.GetTypeCode();                 // remember type of expression
            }

            // 2) Loop thru the data, then loop thru the GroupExpression list
            wc.Groups = new List <GroupEntry>();
            object[] savValues  = null;
            object[] grpValues  = null;
            int      rowCurrent = 0;

            foreach (Row row in wc.Data.Data)
            {
                // Get the values for all the group expressions
                if (grpValues == null)
                {
                    grpValues = new object[gea.Count];
                }

                i = 0;
                foreach (GroupExpression ge in gea)                  // Could optimize to only calculate as needed in comparison loop below??
                {
                    grpValues[i++] = ge.Expression.Evaluate(rpt, row);
                }

                // For first row we just primed the pump; action starts on next row
                if (rowCurrent == 0)                                    // always start new group on first row
                {
                    rowCurrent++;
                    savValues = grpValues;
                    grpValues = null;
                    continue;
                }

                // compare the values; if change then we have a group break
                for (i = 0; i < savValues.Length; i++)
                {
                    if (Filter.ApplyCompare(tcs[i], savValues[i], grpValues[i]) != 0)
                    {
                        // start a new group; and force a break on every subgroup
                        GroupEntry saveGe = null;
                        for (int j = grp[i].GetIndex(rpt); j < currentGroups.Length; j++)
                        {
                            currentGroups[j].EndRow = rowCurrent - 1;
                            if (j == 0)
                            {
                                wc.Groups.Add(currentGroups[j]);                                                // top group
                            }
                            else if (saveGe == null)
                            {
                                currentGroups[j - 1].NestedGroup.Add(currentGroups[j]);
                            }
                            else
                            {
                                saveGe.NestedGroup.Add(currentGroups[j]);
                            }

                            saveGe           = currentGroups[j];                        // retain this GroupEntry
                            currentGroups[j] = new GroupEntry(currentGroups[j].Group, currentGroups[j].Sort, rowCurrent);
                        }
                        savValues = grpValues;
                        grpValues = null;
                        break;                                  // break out of the value comparison loop
                    }
                }
                rowCurrent++;
            }

            // End of all rows force break on end of rows
            for (i = 0; i < currentGroups.Length; i++)
            {
                currentGroups[i].EndRow = rowCurrent - 1;
                if (i == 0)
                {
                    wc.Groups.Add(currentGroups[i]);                                    // top group
                }
                else
                {
                    currentGroups[i - 1].NestedGroup.Add(currentGroups[i]);
                }
            }
            return;
        }
Exemplo n.º 6
0
Arquivo: List.cs Projeto: mnisl/OD
		private void PrepGroups(Report rpt, WorkClass wc)
		{
			if (_Grouping == null)
				return;

			int i=0;
			// 1) Build array of all GroupExpression objects
			List<GroupExpression> gea = _Grouping.GroupExpressions.Items;
			GroupEntry[] currentGroups = new GroupEntry[1];
			_Grouping.SetIndex(rpt, 0);	// set the index of this group (so we can find the GroupEntry)
			currentGroups[0] = new GroupEntry(_Grouping, _Sorting, 0);

			// Save the typecodes, and grouping by groupexpression; for later use
			TypeCode[] tcs = new TypeCode[gea.Count];
			Grouping[] grp = new Grouping[gea.Count];
			i=0;
			foreach (GroupExpression ge in gea)
			{
				grp[i] = (Grouping) (ge.Parent.Parent);			// remember the group
				tcs[i++] = ge.Expression.GetTypeCode();	// remember type of expression
			}

			// 2) Loop thru the data, then loop thru the GroupExpression list
			wc.Groups = new List<GroupEntry>();
			object[] savValues=null;
			object[] grpValues=null;
			int rowCurrent = 0;

			foreach (Row row in wc.Data.Data)
			{
				// Get the values for all the group expressions
				if (grpValues == null)
					grpValues = new object[gea.Count];

				i=0;
				foreach (GroupExpression ge in gea)  // Could optimize to only calculate as needed in comparison loop below??
				{
					grpValues[i++] = ge.Expression.Evaluate(rpt, row);
				}

				// For first row we just primed the pump; action starts on next row
				if (rowCurrent == 0)			// always start new group on first row
				{
					rowCurrent++;
					savValues = grpValues;
					grpValues = null;
					continue;
				}

				// compare the values; if change then we have a group break
				for (i = 0; i < savValues.Length; i++)
				{
					if (Filter.ApplyCompare(tcs[i], savValues[i], grpValues[i]) != 0)
					{
						// start a new group; and force a break on every subgroup
						GroupEntry saveGe=null;	
						for (int j = grp[i].GetIndex(rpt); j < currentGroups.Length; j++)
						{
							currentGroups[j].EndRow = rowCurrent-1;
							if (j == 0)
								wc.Groups.Add(currentGroups[j]);		// top group
							else if (saveGe == null)
								currentGroups[j-1].NestedGroup.Add(currentGroups[j]);
							else 
								saveGe.NestedGroup.Add(currentGroups[j]);

							saveGe = currentGroups[j];	// retain this GroupEntry
							currentGroups[j] = new GroupEntry(currentGroups[j].Group,currentGroups[j].Sort, rowCurrent);
						}
						savValues = grpValues;
						grpValues = null;
						break;		// break out of the value comparison loop
					}
				}
				rowCurrent++;
			}

			// End of all rows force break on end of rows
			for (i = 0; i < currentGroups.Length; i++)
			{
				currentGroups[i].EndRow = rowCurrent-1;
				if (i == 0)
					wc.Groups.Add(currentGroups[i]);		// top group
				else
					currentGroups[i-1].NestedGroup.Add(currentGroups[i]);
			}
			return;
		}
Exemplo n.º 7
0
        public float HeightCalc(Report rpt)
        {
            WorkClass wc = GetWC(rpt);

            return(wc.CalcHeight);
        }
Exemplo n.º 8
0
        internal int GetIndex(Report rpt)
        {
            WorkClass wc = GetValue(rpt);

            return(wc.index);
        }
Exemplo n.º 9
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r = pgs.Report;

            if (IsHidden(r, row))
            {
                return;
            }

            WorkClass wc    = GetWC(r);
            string    mtype = null;
            Stream    strm  = null;

            System.Drawing.Image im = null;

            SetPagePositionBegin(pgs);
            if (wc.PgImage != null)
            {                                // have we already generated this one
                                             // reuse most of the work; only position will likely change
                PageImage pi = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
                pi.Name   = wc.PgImage.Name; // this is name it will be shared under
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);
                pgs.CurrentPage.AddObject(pi);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

            try
            {
                strm = GetImageStream(r, row, out mtype);
                im   = System.Drawing.Image.FromStream(strm);
                int          height = im.Height;
                int          width  = im.Width;
                MemoryStream ostrm  = new MemoryStream();
                ImageFormat  imf;
                //				if (mtype.ToLower() == "image/jpeg")    //TODO: how do we get png to work
                //					imf = ImageFormat.Jpeg;
                //				else
                imf = ImageFormat.Jpeg;
                im.Save(ostrm, imf);
                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(imf, ba, width, height);
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);

                pgs.CurrentPage.AddObject(pi);
                if (_ConstantImage)
                {
                    wc.PgImage = pi;
                    // create unique name; PDF generation uses this to optimize the saving of the image only once
                    pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();                      // create unique name
                }

                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
            catch (Exception e)
            {
                // image failed to load, continue processing
                r.rl.LogError(4, "Image load failed.  " + e.Message);
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
            return;
        }
Exemplo n.º 10
0
 public void SetWorkClass(WorkClass workClass)
 {
     _client.Send(new SetWorkClass(workClass));
 }
Exemplo n.º 11
0
 public async Task <WorkClass> UpdateWorkClass(WorkClass updatedWorkClass)
 {
     return(await httpClient.PutJsonAsync <WorkClass>("api/workclasses", updatedWorkClass));
 }
Exemplo n.º 12
0
 public async Task <WorkClass> CreateWorkClass(WorkClass newWorkClass)
 {
     return(await httpClient.PostJsonAsync <WorkClass>("api/workclasses", newWorkClass));
 }
 public MyWorkContext()
 {
     Worker = new WorkClass();
 }
Exemplo n.º 14
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r       = pgs.Report;
            bool   bHidden = IsHidden(r, row);

            WorkClass wc    = GetWC(r);
            string    mtype = null;
            Stream    strm  = null;

            System.Drawing.Image im = null;

            SetPagePositionBegin(pgs);
            if (bHidden)
            {
                PageImage pi = new PageImage(ImageFormat.Jpeg, null, 0, 0);
                this.SetPagePositionAndStyle(r, pi, row);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

            if (wc.PgImage != null)
            {                                // have we already generated this one
                                             // reuse most of the work; only position will likely change
                PageImage pi = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
                pi.Name   = wc.PgImage.Name; // this is name it will be shared under
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);
                pgs.CurrentPage.AddObject(pi);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

            try
            {
                strm = GetImageStream(r, row, out mtype);
                if (strm == null)
                {
                    r.rl.LogError(4, string.Format("Unable to load image {0}.", this.Name.Nm));
                    return;
                }
                im = System.Drawing.Image.FromStream(strm);
                int          height = im.Height;
                int          width  = im.Width;
                MemoryStream ostrm  = new MemoryStream();
                strm.Position = 0;
                ImageFormat imf;
                switch (mtype.ToLower())
                {
                case "image/jpeg":
                    imf = ImageFormat.Jpeg;
                    CopyStream(strm, ostrm);
                    break;

                case "image/png":
                    imf = ImageFormat.Png;
                    CopyStream(strm, ostrm);
                    break;

                default:                         // from old code where all images convert to jpeg, i don't know why. May be need delete it and add all support formats.
                    imf = ImageFormat.Jpeg;
                    System.Drawing.Imaging.ImageCodecInfo[] info;
                    info = ImageCodecInfo.GetImageEncoders();
                    EncoderParameters encoderParameters;
                    encoderParameters          = new EncoderParameters(1);
                    encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.EmbeddedImageQuality);
                    System.Drawing.Imaging.ImageCodecInfo codec = null;
                    for (int i = 0; i < info.Length; i++)
                    {
                        if (info[i].FormatDescription == "JPEG")
                        {
                            codec = info[i];
                            break;
                        }
                    }
                    im.Save(ostrm, codec, encoderParameters);
                    break;
                }

                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(imf, ba, width, height);
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);

                pgs.CurrentPage.AddObject(pi);
                if (_ConstantImage)
                {
                    wc.PgImage = pi;
                    // create unique name; PDF generation uses this to optimize the saving of the image only once
                    pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();                      // create unique name
                }

                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
            catch (Exception e)
            {
                // image failed to load, continue processing
                r.rl.LogError(4, "Image load failed.  " + e.Message);
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
            return;
        }
Exemplo n.º 15
0
        internal MatrixEntry GetME(Report rpt)
        {
            WorkClass wc = GetWC(rpt);

            return(wc.ME);
        }
Exemplo n.º 16
0
        internal float GetXPosition(Report rpt)
        {
            WorkClass wc = GetWC(rpt);

            return(wc.XPosition);
        }
Exemplo n.º 17
0
        internal void SetME(Report rpt, MatrixEntry me)
        {
            WorkClass wc = GetWC(rpt);

            wc.ME = me;
        }
Exemplo n.º 18
0
        internal PageImage GetPageImage(Report rpt, Row row)
        {
            string mtype = null;
            Stream strm  = null;

            System.DrawingCore.Image im = null;
            PageImage pi = null;

            WorkClass wc = GetWC(rpt);

            if (wc.PgImage != null)
            {                              // have we already generated this one
                                           // reuse most of the work; only position will likely change
                pi      = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
                pi.Name = wc.PgImage.Name; // this is name it will be shared under
                return(pi);
            }

            try
            {
                strm = GetImageStream(rpt, row, out mtype);
                if (strm == null)
                {
                    rpt.rl.LogError(4, string.Format("Unable to load image {0}.",
                                                     this._Value == null?"": this._Value.EvaluateString(rpt, row)));
                    return(null);
                }
                im = System.DrawingCore.Image.FromStream(strm);
                int          height = im.Height;
                int          width  = im.Width;
                MemoryStream ostrm  = new MemoryStream();
                ImageFormat  imf;
                //				if (mtype.ToLower() == "image/jpeg")    //TODO: how do we get png to work
                //					imf = ImageFormat.Jpeg;
                //				else

                imf = ImageFormat.Jpeg;
                System.DrawingCore.Imaging.ImageCodecInfo[] info;
                info = ImageCodecInfo.GetImageEncoders();
                EncoderParameters encoderParameters;
                encoderParameters          = new EncoderParameters(1);
                encoderParameters.Param[0] = new EncoderParameter(System.DrawingCore.Imaging.Encoder.Quality, ImageQualityManager.EmbeddedImageQuality);
                System.DrawingCore.Imaging.ImageCodecInfo codec = null;
                for (int i = 0; i < info.Length; i++)
                {
                    if (info[i].FormatDescription == "JPEG")
                    {
                        codec = info[i];
                        break;
                    }
                }
                im.Save(ostrm, codec, encoderParameters);

                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                pi    = new PageImage(imf, ba, width, height);
                pi.SI = new StyleInfo();                        // this will just default everything
                if (_BackgroundRepeat != null)
                {
                    string r = _BackgroundRepeat.EvaluateString(rpt, row).ToLower();
                    switch (r)
                    {
                    case "repeat":
                        pi.Repeat = ImageRepeat.Repeat;
                        break;

                    case "repeatx":
                        pi.Repeat = ImageRepeat.RepeatX;
                        break;

                    case "repeaty":
                        pi.Repeat = ImageRepeat.RepeatY;
                        break;

                    case "norepeat":
                    default:
                        pi.Repeat = ImageRepeat.NoRepeat;
                        break;
                    }
                }
                else
                {
                    pi.Repeat = ImageRepeat.Repeat;
                }

                if (_ConstantImage)
                {
                    wc.PgImage = pi;
                    // create unique name; PDF generation uses this to optimize the saving of the image only once
                    pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();                      // create unique name
                }
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
            return(pi);
        }
Exemplo n.º 19
0
        internal PageImage GetPageImage(Report rpt, Row row)
        {
            string mtype = null;
            Stream strm  = null;

            System.Drawing.Image im = null;
            PageImage            pi = null;

            WorkClass wc = GetWC(rpt);

            if (wc.PgImage != null)
            {                              // have we already generated this one
                                           // reuse most of the work; only position will likely change
                pi      = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
                pi.Name = wc.PgImage.Name; // this is name it will be shared under
                return(pi);
            }

            try
            {
                strm = GetImageStream(rpt, row, out mtype);
                im   = System.Drawing.Image.FromStream(strm);
                int          height = im.Height;
                int          width  = im.Width;
                MemoryStream ostrm  = new MemoryStream();
                ImageFormat  imf;
                //				if (mtype.ToLower() == "image/jpeg")    //TODO: how do we get png to work
                //					imf = ImageFormat.Jpeg;
                //				else
                imf = ImageFormat.Jpeg;
                im.Save(ostrm, imf);
                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                pi    = new PageImage(imf, ba, width, height);
                pi.SI = new StyleInfo();                        // this will just default everything
                if (_BackgroundRepeat != null)
                {
                    string r = _BackgroundRepeat.EvaluateString(rpt, row).ToLower();
                    switch (r)
                    {
                    case "repeat":
                        pi.Repeat = ImageRepeat.Repeat;
                        break;

                    case "repeatx":
                        pi.Repeat = ImageRepeat.RepeatX;
                        break;

                    case "repeaty":
                        pi.Repeat = ImageRepeat.RepeatY;
                        break;

                    case "norepeat":
                    default:
                        pi.Repeat = ImageRepeat.NoRepeat;
                        break;
                    }
                }
                else
                {
                    pi.Repeat = ImageRepeat.Repeat;
                }

                if (_ConstantImage)
                {
                    wc.PgImage = pi;
                    // create unique name; PDF generation uses this to optimize the saving of the image only once
                    pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();                      // create unique name
                }
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
            return(pi);
        }
Exemplo n.º 20
0
		private void SetValue(Report rpt, WorkClass w)
		{
			rpt.Cache.AddReplace(this, "wc", w);
		}
Exemplo n.º 21
0
		void HandleRowGrouping(Report rpt, WorkClass wc, Rows rows, Row r, MatrixEntry m, int rgi, int iRow, ref int maxRows)
		{
			while (rgi < _RowGroupings.Items.Count)
			{
				RowGrouping rg = _RowGroupings.Items[rgi] as RowGrouping;
				Grouping grp=null;
				string result;
				
				if (rg.StaticRows != null)	// handle static rows
				{
					for (int sri=0; sri < rg.StaticRows.Items.Count; sri++)
					{
						result = Convert.ToChar(Convert.ToInt32('a')+sri).ToString() + terminal;	// static row; put all data in it
						StaticRow sr = rg.StaticRows.Items[sri] as StaticRow;
						MatrixEntry ame = (MatrixEntry) (m.HashData[result]);
						if (ame == null)
						{
							ame = new MatrixEntry(m, rows.Data.Count);
							ame.RowGroup = rg;
							ame.StaticRow = sri;
							m.HashData.Add(result, ame);
							if (rg == LastRg)		// Add a row when we add data at lowest level
								maxRows++;
						}
						ame.Rows.Set(iRow, true);
						// Logic in FirstRow and Last row determine whether value gets set
						ame.FirstRow = iRow;
						ame.LastRow = iRow;
						HandleRowGrouping(rpt, wc, rows, r, ame, rgi+1, iRow, ref maxRows);
					}
					break;	// handled ones below it recursively
				}
				else							// handle dynamic columns
				{
					grp = rg.DynamicRows.Grouping;

					StringBuilder sb = new StringBuilder();
					foreach (GroupExpression ge in grp.GroupExpressions.Items)
					{
						string temp = ge.Expression.EvaluateString(rpt, r);
						if (temp == null || temp == "")
							sb.Append(nullterminal);
						else
							sb.Append(temp);
						sb.Append(terminal);		// mark end of group 
					}
					result = sb.ToString();

					MatrixEntry ame = (MatrixEntry) (m.HashData[result]);
					if (ame == null)
					{
						ame = new MatrixEntry(m, rows.Data.Count);
						ame.RowGroup = rg;
						m.HashData.Add(result, ame);
						if (rg == LastRg)		// Add a row when we add data at lowest level
							maxRows++;
					}
					ame.Rows.Set(iRow, true);
					// Logic in FirstRow and Last row determine whether value gets set
					ame.FirstRow = iRow;
					ame.LastRow = iRow;
					m = ame;			// now go down a level
					rgi++;
				}
			}
		}
Exemplo n.º 22
0
Arquivo: List.cs Projeto: mnisl/OD
		private void RunPageGroups(Pages pgs, WorkClass wc, List<GroupEntry> groupEntries)
		{
			Report rpt = pgs.Report;
			Page p = pgs.CurrentPage;
			float pagebottom = OwnerReport.BottomOfPage;
			p.YOffset += (Top == null? 0: this.Top.Points); 
			float listoffset = GetOffsetCalc(pgs.Report)+LeftCalc(pgs.Report);

			float height;	
			Row row;

			foreach (GroupEntry ge in groupEntries)
			{
				// set the group entry value
				int index;
				if (ge.Group != null)	// groups?
				{
					ge.Group.ResetHideDuplicates(rpt);	// reset duplicate checking
					index = ge.Group.GetIndex(rpt);	// yes
				}
				else					// no; must be main dataset
					index = 0;
				wc.Data.CurrentGroups[index] = ge;
				if (ge.NestedGroup.Count > 0)
					RunGroupsSetGroups(rpt, wc, ge.NestedGroup);

				if (ge.Group == null)
				{	// need to run all the rows since no group defined
					for (int r=ge.StartRow; r <= ge.EndRow; r++)
					{
						row = wc.Data.Data[r];
						height = HeightOfList(rpt, pgs.G, row);
                        float saveYoffset = p.YOffset;              // this can be affected by other page items
						_ReportItems.RunPage(pgs, row, listoffset);
                        p.YOffset = saveYoffset + height;
						if (p.YOffset + height > pagebottom)		// need another page for next row?
						{
							p = RunPageNew(pgs, p);					// yes; if at end this page is empty
						}											// and will be cleaned up later				
					}
				}
				else
				{	// need to process just whole group as a List entry
					if (ge.Group.PageBreakAtStart && !p.IsEmpty())
						p = RunPageNew(pgs, p);

					// pass the first row of the group
					row = wc.Data.Data[ge.StartRow];
					height = HeightOfList(rpt, pgs.G, row);
                    float saveYoffset = p.YOffset;              // this can be affected by other page items
                    _ReportItems.RunPage(pgs, row, listoffset);
					p.YOffset = saveYoffset + height;
					if (ge.Group.PageBreakAtEnd ||					// need another page for next group?
						p.YOffset + height > pagebottom)
					{
						p = RunPageNew(pgs, p);						// yes; if at end empty page will be cleaned up later
					}
				}
			}
		}
Exemplo n.º 23
0
		int RunCountSubtotalColumns(WorkClass wc, MatrixEntry m, int level)
		{
			// Get the number of static columns
			int scCount = Math.Max(1, this._ColumnGroupings.StaticCount);

			int count = 0;
			// Increase the column count when subtotal is requested at this level
			ColumnGrouping cg = (ColumnGrouping) (_ColumnGroupings.Items[level]);
			if (cg.DynamicColumns != null &&
				cg.DynamicColumns.Subtotal != null)
				count = scCount;

			if (m.SortedData == null || level+1 >= _ColumnGroupings.Items.Count)		   
				return count;

			// Now dive into the data
			foreach (MatrixEntry ame in m.SortedData.Values)
			{
				count += RunCountSubtotalColumns(wc, ame, level+1);
			}

			return count;
		}
Exemplo n.º 24
0
 private void SetValue(Report rpt, WorkClass w)
 {
     rpt.Cache.AddReplace(_key, w);
 }
Exemplo n.º 25
0
        internal bool IsTableOrMatrixCell(Report rpt)
        {
            WorkClass wc = GetWC(rpt);

            return(_TC != null || wc.MC != null || this._InMatrix);
        }
Exemplo n.º 26
0
		void RunRowHeaders(Report rpt, WorkClass wc, MatrixEntry m, MatrixCellEntry[,] matrix, Rows _Data, ref int iRow, int iColumn, int level)
		{
			foreach (MatrixEntry ame in m.GetSortedData(rpt))
			{
				matrix[iRow, iColumn] = RunGetRowHeader(rpt, ame, _Data);
				matrix[iRow, iColumn].Height = RunRowHeight(iRow);
				matrix[iRow, iColumn].Width = ame.RowGroup.Width == null? 0: ame.RowGroup.Width.Points;
				if (ame.GetSortedData(rpt) != null)
				{
					RunRowHeaders(rpt, wc, ame, matrix, _Data, ref iRow, iColumn+1, level+1);
				}
				else
					iRow++;
			}

			RowGrouping rg = (RowGrouping) (_RowGroupings.Items[level]);
			// do we need to subtotal this
			if (rg.DynamicRows != null &&
				rg.DynamicRows.Subtotal != null)
			{					   // TODO need to loop thru static??
				ReportItem ri = rg.DynamicRows.Subtotal.ReportItems.Items[0];	
				matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri);
				matrix[iRow, iColumn].Width = rg.Width.Points;
				matrix[iRow, iColumn].Height = RunRowHeight(iRow);
				RunRowStaticHeaders(rpt, wc, matrix, _Data, iRow, level);
				iRow += Math.Max(1,this.RowGroupings.StaticCount);
			}
		}
Exemplo n.º 27
0
        internal void SetPagePositionAndStyle(Report rpt, PageItem pi, Row row)
        {
            WorkClass wc = GetWC(rpt);

            pi.X = GetOffsetCalc(rpt) + LeftCalc(rpt);
            if (this._TC != null)
            {                   // must be part of a table
                Table t        = _TC.OwnerTable;
                int   colindex = _TC.ColIndex;

                // Calculate width: add up all columns within the column span
                float       width = 0;
                TableColumn tc;
                for (int ci = colindex; ci < colindex + _TC.ColSpan; ci++)
                {
                    tc     = (TableColumn)(t.TableColumns.Items[ci]);
                    width += tc.Width.Points;
                }
                pi.W = width;
                pi.Y = 0;

                TableRow tr = (TableRow)(_TC.Parent.Parent);
                pi.H = tr.HeightCalc(rpt);                      // this is a cached item; note tr.HeightOfRow must already be called on row
            }
            else if (wc.MC != null)
            {                   // must be part of a matrix
                pi.W = wc.MC.Width;
                pi.Y = 0;
                pi.H = wc.MC.Height;
            }
            else if (pi is PageLine)
            {   // don't really handle if line is part of table???  TODO
                PageLine pl = (PageLine)pi;
                if (Top != null)
                {
                    pl.Y = this.Gap(rpt);                //  y will get adjusted when pageitem added to page
                }
                float y2 = pl.Y;
                if (Height != null)
                {
                    y2 += Height.Points;
                }
                pl.Y2 = y2;
                pl.X2 = pl.X;
                if (Width != null)
                {
                    pl.X2 += Width.Points;
                }
            }
            else
            {   // not part of a table or matrix
                if (Top != null)
                {
                    pi.Y = this.Gap(rpt);                //  y will get adjusted when pageitem added to page
                }
                if (Height != null)
                {
                    pi.H = Height.Points;
                }
                else
                {
                    pi.H = this.HeightOrOwnerHeight;
                }
                if (Width != null)
                {
                    pi.W = Width.Points;
                }
                else
                {
                    pi.W = this.WidthOrOwnerWidth(rpt);
                }
            }
            if (Style != null)
            {
                pi.SI = Style.GetStyleInfo(rpt, row);
            }
            else
            {
                pi.SI = new StyleInfo();    // this will just default everything
            }
            pi.ZIndex = this.ZIndex;        // retain the zindex of the object

            // Catch any action needed
            if (this._Action != null)
            {
                pi.BookmarkLink = _Action.BookmarkLinkValue(rpt, row);
                pi.HyperLink    = _Action.HyperLinkValue(rpt, row);
            }

            if (this._ToolTip != null)
            {
                pi.Tooltip = _ToolTip.EvaluateString(rpt, row);
            }
        }
Exemplo n.º 28
0
 private void SetValue(Report rpt, WorkClass w)
 {
     rpt.Cache.AddReplace(this, "wc", w);
 }
Exemplo n.º 29
0
        internal MatrixCellEntry GetMC(Report rpt)
        {
            WorkClass wc = GetWC(rpt);

            return(wc.MC);
        }
Exemplo n.º 30
0
 public SetWorkClass(WorkClass workClass, bool cacheRawMessage)
     : base(COMMAND, MessageType.Command, cacheRawMessage, ((char)workClass).ToString())
 {
 }
Exemplo n.º 31
0
        internal void SetMC(Report rpt, MatrixCellEntry mce)
        {
            WorkClass wc = GetWC(rpt);

            wc.MC = mce;
        }
Exemplo n.º 32
0
        internal void SetXPosition(Report rpt, float xp)
        {
            WorkClass wc = GetWC(rpt);

            wc.XPosition = xp;
        }
Exemplo n.º 33
0
        public void SetData(List <LemHeader> headerList)
        {
            tableLabour.Clear();

            var table = LemHeader.GetCostCodeSummary(headerList.Select(x => x.Id).ToList());
            var list  = table.Select().Select(r => new
            {
                EmpNum        = Convert.ToInt32(r["EmpNum"]),
                WorkClassCode = Convert.ToString(r["WorkClassCode"]),
                Billable      = Convert.ToBoolean(r["Billable"]),
                ProjectId     = Convert.ToInt32(r["ProjectId"]),
                ChangeOrderId = ConvertEx.ToNullable <int>(r["ChangeOrderId"]),
                Level1Id      = ConvertEx.ToNullable <int>(r["Level1Id"]),
                Level2Id      = ConvertEx.ToNullable <int>(r["Level2Id"]),
                Level3Id      = ConvertEx.ToNullable <int>(r["Level3Id"]),
                Level4Id      = ConvertEx.ToNullable <int>(r["Level4Id"]),
                TimeCodeId    = Convert.ToInt32(r["TimeCodeId"]),
                SumWorkHour   = ConvertEx.ToNullable <decimal>(r["SumWorkHour"]),
                SumAmount     = ConvertEx.ToNullable <decimal>(r["SumAmount"]),
            });

            var groupList = list.ToLookup(x => new
            {
                x.EmpNum,
                x.WorkClassCode,
                x.Billable,
                x.ProjectId,
                x.ChangeOrderId,
                x.Level1Id,
                x.Level2Id,
                x.Level3Id,
                x.Level4Id,
                EmpName     = Employee.GetEmployee(x.EmpNum)?.DisplayName,
                WorkClass   = WorkClass.GetWorkClass(x.WorkClassCode).DisplayName,
                Project     = Project.GetProject(x.ProjectId),
                ChangeOrder = ChangeOrder.GetChangeOrder(x.ProjectId, x.ChangeOrderId)?.DisplayName,
                Level1      = LevelOneCode.GetLevelCode(x.Level1Id)?.DisplayName,
                Level2      = LevelTwoCode.GetLevelCode(x.Level2Id)?.DisplayName,
                Level3      = LevelThreeCode.GetLevelCode(x.Level3Id)?.DisplayName,
                Level4      = LevelFourCode.GetLevelCode(x.Level4Id)?.DisplayName
            }).OrderBy(x => x.Key.Level1).ThenBy(x => x.Key.Level2).ThenBy(x => x.Key.Level3).ThenBy(x => x.Key.Level4).ThenBy(x => x.Key.EmpName).ThenBy(x => x.Key.Project).ThenBy(x => x.Key.ChangeOrder).ThenBy(x => x.Key.WorkClass).ThenBy(x => x.Key.Billable).ToList();

            groupList.ForEach(g =>
            {
                DataRow row = tableLabour.Rows.Add(
                    g.Key.EmpNum,
                    g.Key.EmpName,
                    g.Key.WorkClass,
                    g.Key.Project,
                    g.Key.ChangeOrder,
                    g.Key.Level1,
                    g.Key.Level2,
                    g.Key.Level3,
                    g.Key.Level4,
                    g.Key.Billable,
                    null,
                    null);

                decimal?billRate;
                decimal totalHours  = 0;
                decimal billAmounts = 0;
                foreach (var timecode in TimeCode.ListForCompany())
                {
                    if (timecode.ValueType == EnumValueType.Hours)
                    {
                        billRate = ProjectWorkClass.GetBillRate(g.Key.ProjectId, timecode.MatchId, g.Key.WorkClassCode);
                        row[ColName.BillRateI(timecode)] = (object)billRate ?? DBNull.Value;

                        decimal hours = g.Where(x => x.TimeCodeId == timecode.MatchId).Sum(x => x.SumWorkHour) ?? 0;
                        row[ColName.EnterValueI(timecode)] = hours != 0 ? (object)hours : DBNull.Value;

                        totalHours  += hours;
                        billAmounts += (billRate ?? 0) * hours;
                    }
                    else
                    {
                        decimal amount = g.Where(x => x.TimeCodeId == timecode.MatchId).Sum(x => x.SumAmount) ?? 0;
                        row[ColName.EnterValueI(timecode)] = amount != 0 ? (object)amount : DBNull.Value;
                        billAmounts += amount;
                    }

                    row[ColName.TotalHours] = totalHours != 0 ? (object)totalHours : DBNull.Value;
                    row[ColName.BillAmount] = billAmounts != 0 ? (object)billAmounts : DBNull.Value;
                }
            });
        }
Exemplo n.º 34
0
        public void SetCurrent(LemHeader header)
        {
            _headerRecord = header;

            tableLabour.Clear();

            var table = LemHeader.GetEmployeeSummary(new List <int> {
                header.Id
            });
            var list = table.Select().Select(r => new
            {
                EmpNum        = Convert.ToInt32(r["EmpNum"]),
                WorkClassCode = Convert.ToString(r["WorkClassCode"]),
                ProjectId     = Convert.ToInt32(r["ProjectId"]),
                TimeCodeId    = Convert.ToInt32(r["TimeCodeId"]),
                SumWorkHour   = ConvertEx.ToNullable <decimal>(r["SumWorkHour"]),
                SumAmount     = ConvertEx.ToNullable <decimal>(r["SumAmount"]),
            });

            var groupList = list.ToLookup(x => new
            {
                x.EmpNum,
                x.WorkClassCode,
                x.ProjectId,
                EmpName   = Employee.GetEmployee(x.EmpNum)?.DisplayName,
                WorkClass = WorkClass.GetWorkClass(x.WorkClassCode).DisplayName
            }).OrderBy(x => x.Key.EmpName).ThenBy(x => x.Key.WorkClass).ToList();

            groupList.ForEach(g =>
            {
                var row = tableLabour.Rows.Add(
                    g.Key.EmpNum,
                    g.Key.EmpName,
                    g.Key.WorkClass,
                    null,
                    null);

                decimal?billRate;
                decimal totalHours  = 0;
                decimal billAmounts = 0;
                foreach (var timecode in TimeCode.ListForCompany())
                {
                    if (timecode.ValueType == EnumValueType.Hours)
                    {
                        billRate = ProjectWorkClass.GetBillRate(g.Key.ProjectId, timecode.MatchId, g.Key.WorkClassCode);
                        row[BillRateI(timecode)] = (object)billRate ?? DBNull.Value;

                        decimal hours = g.Where(x => x.TimeCodeId == timecode.MatchId).Sum(x => x.SumWorkHour) ?? 0;
                        row[EnterValueI(timecode)] = hours != 0 ? (object)hours : DBNull.Value;

                        totalHours  += hours;
                        billAmounts += (billRate ?? 0) * hours;
                    }
                    else
                    {
                        decimal amount             = g.Where(x => x.TimeCodeId == timecode.MatchId).Sum(x => x.SumAmount) ?? 0;
                        row[EnterValueI(timecode)] = amount != 0 ? (object)amount : DBNull.Value;
                        billAmounts += amount;
                    }

                    row[colTotalHours.FieldName] = totalHours != 0 ? (object)totalHours : DBNull.Value;
                    row[colBillAmount.FieldName] = billAmounts != 0 ? (object)billAmounts : DBNull.Value;
                }
            });
        }
Exemplo n.º 35
0
		void RunRowStaticHeaders(Report rpt, WorkClass wc, MatrixCellEntry[,] matrix, Rows _Data, int iRow, int level)
		{
			RowGrouping rg=null;
			int i;
			int iColumn=0;
			for (i=level+1; i < _RowGroupings.Items.Count; i++)
			{
				iColumn++;				// Column for the row static headers
				rg = (RowGrouping) (_RowGroupings.Items[i]);
				if (rg.StaticRows != null)
					break;
			} 
			if (rg == null || rg.StaticRows == null)
				return;

			i=0;
			foreach (StaticRow sr in rg.StaticRows.Items)
			{
				ReportItem ri = sr.ReportItems.Items[0];
				matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri);
				matrix[iRow, iColumn].Width = rg.Width.Points;
				MatrixRow mr = this.MatrixRows.Items[i++] as MatrixRow;
				float height = mr.Height == null? 0: mr.Height.Points;
				matrix[iRow, iColumn].Height = height;

				iRow++;
			}
			return;
		}
Exemplo n.º 36
0
        internal Rows GetRows(Report rpt)
        {
            WorkClass wc = GetValue(rpt);

            return(wc.rows);
        }
Exemplo n.º 37
0
		void RunPageColumns(Pages pgs, WorkClass wc, MatrixCellEntry[,] matrix, int iRow, int maxColumns)
		{
			Report rpt = pgs.Report;

			float xpos = GetOffsetCalc(pgs.Report) + LeftCalc(rpt);
			for (int iColumn = 0; iColumn < maxColumns; iColumn++)
			{
				MatrixCellEntry mce = matrix[iRow, iColumn];
					
				if (mce == null)
				{	// have a null column but we need to fill column space
					xpos += WidthOfColumn(matrix, iColumn);
					continue;
				}
				wc.Data = mce.Data;		// Must set this for evaluation

				Row lrow = wc.Data.Data.Count > 0? wc.Data.Data[0]:null;
				SetGroupingValues(rpt, mce);
				mce.DisplayItem.SetMC(rpt, mce);	// set for use by the display item
				mce.XPosition = xpos;
				mce.DisplayItem.RunPage(pgs, lrow);
				xpos += mce.Width;
				iColumn += (mce.ColSpan-1);			// skip columns already accounted for
			}
		}
Exemplo n.º 38
0
 private void SetValue(Report rpt, WorkClass w)
 {
     rpt.Cache.AddReplace(_key, w);
 }
Exemplo n.º 39
0
		void HandleColumnGrouping(Report rpt, WorkClass wc, Rows rows, Row r, MatrixEntry m, int cgi, int iRow, ref int maxColumns)
		{
			while (cgi < _ColumnGroupings.Items.Count)
			{
				ColumnGrouping cg = _ColumnGroupings.Items[cgi] as ColumnGrouping;
				Grouping grp=null;
				string result;
				
				if (cg.StaticColumns != null)	// handle static columns
				{
					for (int sci=0; sci < cg.StaticColumns.Items.Count; sci++)
					{
						result = Convert.ToChar(Convert.ToInt32('a')+sci).ToString() + terminal;	// static column; put all data in it
						StaticColumn sc = cg.StaticColumns.Items[sci] as StaticColumn;
						MatrixEntry ame;
                        m.HashData.TryGetValue(result, out ame);
                        if (ame == null)
						{
							ame = new MatrixEntry(r, result, m, rows.Data.Count);
							ame.ColumnGroup = cg;
							ame.StaticColumn = sci;
							m.HashData.Add(result, ame);
							if (cg == LastCg)		// Add a column when we add data at lowest level
								maxColumns++;
						}
						ame.Rows.Set(iRow, true);
						// Logic in FirstRow and Last row determine whether value gets set
						ame.FirstRow = iRow;
						ame.LastRow = iRow;
						HandleColumnGrouping(rpt, wc, rows, r, ame, cgi+1, iRow, ref maxColumns);
					}
					break;	// handled ones below it recursively
				}
				else							// handle dynamic columns
				{
					grp = cg.DynamicColumns.Grouping;

					StringBuilder sb = new StringBuilder();
					foreach (GroupExpression ge in grp.GroupExpressions.Items)
					{
						string temp = ge.Expression.EvaluateString(rpt, r);
						if (temp == null || temp == "")
							sb.Append(nullterminal);
						else
							sb.Append(temp);
						sb.Append(terminal);		// mark end of group 
					}
					result = sb.ToString();

					MatrixEntry ame;
                    m.HashData.TryGetValue(result, out ame);
					if (ame == null)
					{
						ame = new MatrixEntry(r, result, m, rows.Data.Count);
						ame.ColumnGroup = cg;
						m.HashData.Add(result, ame);
						if (cg == LastCg)		// Add a column when we add data at lowest level
							maxColumns++;
					}
					ame.Rows.Set(iRow, true);
					// Logic in FirstRow and Last row determine whether value gets set
					ame.FirstRow = iRow;
					ame.LastRow = iRow;
					m = ame;			// now go down a level
					cgi++;
				}
			}
		}
Exemplo n.º 40
0
        private void RunPageGroups(Pages pgs, WorkClass wc, List <GroupEntry> groupEntries)
        {
            Report rpt        = pgs.Report;
            Page   p          = pgs.CurrentPage;
            float  pagebottom = OwnerReport.BottomOfPage;

//			p.YOffset += (Top == null? 0: this.Top.Points);
            p.YOffset += this.RelativeY(rpt);
            float listoffset = GetOffsetCalc(pgs.Report) + LeftCalc(pgs.Report);

            float height;
            Row   row;

            foreach (GroupEntry ge in groupEntries)
            {
                // set the group entry value
                int index;
                if (ge.Group != null)                   // groups?
                {
                    ge.Group.ResetHideDuplicates(rpt);  // reset duplicate checking
                    index = ge.Group.GetIndex(rpt);     // yes
                }
                else                                    // no; must be main dataset
                {
                    index = 0;
                }
                wc.Data.CurrentGroups[index] = ge;
                if (ge.NestedGroup.Count > 0)
                {
                    RunGroupsSetGroups(rpt, wc, ge.NestedGroup);
                }

                if (ge.Group == null)
                {                       // need to run all the rows since no group defined
                    for (int r = ge.StartRow; r <= ge.EndRow; r++)
                    {
                        row    = wc.Data.Data[r];
                        height = HeightOfList(rpt, pgs.G, row);

                        if (p.YOffset + height > pagebottom && !p.IsEmpty()) // need another page for this row?
                        {
                            p = RunPageNew(pgs, p);                          // yes; if at end this page is empty
                        }
                        float saveYoffset = p.YOffset;                       // this can be affected by other page items

                        if (_ReportItems != null)
                        {
                            _ReportItems.RunPage(pgs, row, listoffset);
                        }

                        if (p == pgs.CurrentPage) // did subitems force new page?
                        {                         // no use the height of the list
                            p.YOffset = saveYoffset + height;
                        }
                        else
                        {                        // got forced to new page; just add the padding on
                            p = pgs.CurrentPage; // set to new page
                            if (this.Style != null)
                            {
                                p.YOffset += this.Style.EvalPaddingBottom(rpt, row);
                            }
                        }
                    }
                }
                else
                {                       // need to process just whole group as a List entry
                    if (ge.Group.PageBreakAtStart && !p.IsEmpty())
                    {
                        p = RunPageNew(pgs, p);
                    }

                    // pass the first row of the group
                    row    = wc.Data.Data[ge.StartRow];
                    height = HeightOfList(rpt, pgs.G, row);

                    if (p.YOffset + height > pagebottom && !p.IsEmpty()) // need another page for this row?
                    {
                        p = RunPageNew(pgs, p);                          // yes; if at end this page is empty
                    }
                    float saveYoffset = p.YOffset;                       // this can be affected by other page items

                    if (_ReportItems != null)
                    {
                        _ReportItems.RunPage(pgs, row, listoffset);
                    }


                    if (p == pgs.CurrentPage) // did subitems force new page?
                    {                         // no use the height of the list
                        p.YOffset = saveYoffset + height;
                    }
                    else
                    {                        // got forced to new page; just add the padding on
                        p = pgs.CurrentPage; // set to new page
                        if (this.Style != null)
                        {
                            p.YOffset += this.Style.EvalPaddingBottom(rpt, row);
                        }
                    }

                    if (ge.Group.PageBreakAtEnd ||                                      // need another page for next group?
                        p.YOffset + height > pagebottom)
                    {
                        p = RunPageNew(pgs, p);                                                                 // yes; if at end empty page will be cleaned up later
                    }
                }
                RemoveWC(rpt);
            }
        }
Exemplo n.º 41
0
		int RunCountSubtotalRows(Report rpt, WorkClass wc, MatrixEntry m, int level)
		{
			// Get the number of static columns
			int srCount = Math.Max(1, this._RowGroupings.StaticCount);

			int count = 0;
			// Increase the row count when subtotal is requested at this level
			RowGrouping rg = (RowGrouping) (_RowGroupings.Items[level]);
			if (rg.DynamicRows != null &&
				rg.DynamicRows.Subtotal != null)
				count = srCount;

			if (m.GetSortedData(rpt) == null || level+1 >= _RowGroupings.Items.Count)		   
				return count;

			// Now dive into the data
			foreach (MatrixEntry ame in m.GetSortedData(rpt))
			{
				count += RunCountSubtotalRows(rpt, wc, ame, level+1);
			}

			return count;
		}
Exemplo n.º 42
0
Arquivo: List.cs Projeto: mnisl/OD
		private void RunSetGrouping(Report rpt, WorkClass wc)
		{
			GroupEntry[] currentGroups; 

			// We have some data
			if (_Grouping != null || 
				_Sorting != null)		// fix up the data
			{
				Rows saveData = wc.Data;
				wc.Data = new Rows(rpt, null, _Grouping, _Sorting);
				wc.Data.Data = saveData.Data;
				wc.Data.Sort();
				PrepGroups(rpt, wc);
			}
			// If we haven't formed any groups then form one with all rows
			if (wc.Groups == null)
			{
                wc.Groups = new List<GroupEntry>();
				GroupEntry ge = new GroupEntry(null, null, 0);
				if (wc.Data.Data != null)		// Do we have any data?
					ge.EndRow = wc.Data.Data.Count-1;	// yes
				else
					ge.EndRow = -1;					// no
				wc.Groups.Add(ge);			// top group
				currentGroups = new GroupEntry[1];
			}
			else
				currentGroups = new GroupEntry[1];

			wc.Data.CurrentGroups = currentGroups;

			return;
		}
Exemplo n.º 43
0
		void RunColumnHeaders(Report rpt, WorkClass wc, MatrixEntry m, MatrixCellEntry[,] matrix, Rows _Data, int iRow, ref int iColumn, int level)
		{
			foreach (MatrixEntry ame in m.GetSortedData(rpt))
			{
				matrix[iRow, iColumn] = RunGetColumnHeader(rpt, ame, _Data);
				matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]);
				matrix[iRow, iColumn].Height = ame.ColumnGroup.Height == null? 0: ame.ColumnGroup.Height.Points;
				if (ame.GetSortedData(rpt) != null)
				{
					RunColumnHeaders(rpt, wc, ame, matrix, _Data, iRow+1, ref iColumn, level+1);
				}
				else
					iColumn++;
			}

			ColumnGrouping cg = (ColumnGrouping) (_ColumnGroupings.Items[level]);

			// if we need subtotal on the group
			if (cg.DynamicColumns != null &&
				cg.DynamicColumns.Subtotal != null)
			{
				ReportItem ri =  cg.DynamicColumns.Subtotal.ReportItems.Items[0];	
				matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri);
				matrix[iRow, iColumn].Height = cg.Height.Points;
				matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]);
				RunColumnStaticHeaders(rpt, wc, matrix, _Data, iRow, iColumn, level);
				iColumn += this.CountMatrixCells;
			}
		}
Exemplo n.º 44
0
Arquivo: List.cs Projeto: mnisl/OD
		private void RunGroups(IPresent ip, WorkClass wc, List<GroupEntry> groupEntries)
		{
			foreach (GroupEntry ge in groupEntries)
			{
				// set the group entry value
				int index;
				if (ge.Group != null)	// groups?
				{
					ge.Group.ResetHideDuplicates(ip.Report());	// reset duplicate checking
					index = ge.Group.GetIndex(ip.Report());	// yes
				}
				else					// no; must be main dataset
					index = 0;
				wc.Data.CurrentGroups[index] = ge;
				if (ge.NestedGroup.Count > 0)
					RunGroupsSetGroups(ip.Report(), wc, ge.NestedGroup);

				if (ge.Group == null)
				{	// need to run all the rows since no group defined
					for (int r=ge.StartRow; r <= ge.EndRow; r++)
					{
						ip.ListEntryBegin(this,  wc.Data.Data[r]);
						_ReportItems.Run(ip, wc.Data.Data[r]);
						ip.ListEntryEnd(this, wc.Data.Data[r]);
					}
				}
				else
				{	// need to process just whole group as a List entry
					ip.ListEntryBegin(this,  wc.Data.Data[ge.StartRow]);

					// pass the first row of the group
					_ReportItems.Run(ip, wc.Data.Data[ge.StartRow]);

					ip.ListEntryEnd(this, wc.Data.Data[ge.StartRow]);
				}
			}
		}
Exemplo n.º 45
0
		void RunColumnStaticHeaders(Report rpt, WorkClass wc, MatrixCellEntry[,] matrix, Rows _Data, int iRow, int iColumn, int level)
		{
			ColumnGrouping cg=null;
			for (int i=level+1; i < _ColumnGroupings.Items.Count; i++)
			{
				iRow++;				// the row will below the headers
				cg = (ColumnGrouping) (_ColumnGroupings.Items[i]);
				if (cg.StaticColumns != null)
					break;
			} 
			if (cg == null || cg.StaticColumns == null)
				return;

			foreach (StaticColumn sc in cg.StaticColumns.Items)
			{
				ReportItem ri = sc.ReportItems.Items[0];
				matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri);
				matrix[iRow, iColumn].Height = cg.Height.Points;
				matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]);

				iColumn++;
			}
			return;
		}
Exemplo n.º 46
0
Arquivo: List.cs Projeto: mnisl/OD
		private void RunGroupsSetGroups(Report rpt, WorkClass wc, List<GroupEntry> groupEntries)
		{
			// set the group entry value
			GroupEntry ge = groupEntries[0];
			wc.Data.CurrentGroups[ge.Group.GetIndex(rpt)] = ge;

			if (ge.NestedGroup.Count > 0)
				RunGroupsSetGroups(rpt, wc, ge.NestedGroup);
		}
Exemplo n.º 47
0
		void RunDataColumn(Report rpt, WorkClass wc, MatrixEntry rm, MatrixEntry cm, MatrixCellEntry[,] matrix, Rows _Data, int iRow, ref int iColumn, int level, int rowcell)
		{
			BitArray andData;
			MatrixRow mr = this.MatrixRows.Items[rowcell] as MatrixRow;
			float height = mr.Height == null? 0: mr.Height.Points;

			foreach (MatrixEntry ame in cm.GetSortedData(rpt))
			{
				if (ame.ColumnGroup != LastCg)
				{
					RunDataColumn(rpt, wc, rm, ame, matrix, _Data, iRow, ref iColumn, level+1, rowcell);
					continue;
				}
				andData = new BitArray(ame.Rows);	// copy the data
				andData.And(rm.Rows);				//  because And is destructive
				matrix[iRow, iColumn] = RunGetMatrixCell(rpt, ame, iRow, _Data, andData, 
						Math.Max(rm.FirstRow, ame.FirstRow),
						Math.Min(rm.LastRow, ame.LastRow));
				matrix[iRow, iColumn].Height = height;
				matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]);
				matrix[iRow, iColumn].ColumnME = ame;
				matrix[iRow, iColumn].RowME = rm;
				
				iColumn++;
			}
			// do we need to subtotal this?
			ColumnGrouping cg = (ColumnGrouping) (_ColumnGroupings.Items[level]);
			if (cg.DynamicColumns != null &&
				cg.DynamicColumns.Subtotal != null)
			{
				andData = new BitArray(cm.Rows);	// copy the data
				andData.And(rm.Rows);				//  because And is destructive
				for (int i=0; i < this.CountMatrixCells; i++)
				{
					matrix[iRow, iColumn] = RunGetMatrixCell(rpt, cm, rowcell, i, _Data, andData, 
						Math.Max(rm.FirstRow, cm.FirstRow),
						Math.Min(rm.LastRow, cm.LastRow));
					matrix[iRow, iColumn].Height = height;
					matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]);
					matrix[iRow, iColumn].ColumnME = cm;
					matrix[iRow, iColumn].RowME = rm;
					iColumn++;
				}
			}
		}
Exemplo n.º 48
0
 private WorkClass GetValue(Report rpt)
 {
     WorkClass wc = rpt.Cache.Get(_key) as WorkClass;
     if (wc == null)
     {
         wc = new WorkClass();
         rpt.Cache.Add(_key, wc);
     }
     return wc;
 }
Exemplo n.º 49
0
		void RunDataRow(Report rpt, WorkClass wc, MatrixEntry rm, MatrixEntry cm, MatrixCellEntry[,] matrix, Rows _Data, ref int iRow, int iColumn, int level)
		{
			int saveColumn;
			int headerRows = _ColumnGroupings.Items.Count;	// number of column headers we have
			int rgsCount = this.RowGroupings.StaticCount;	// count of static row groups
			foreach (MatrixEntry ame in rm.GetSortedData(rpt))
			{
				if (ame.RowGroup != LastRg)
				{
					RunDataRow(rpt, wc, ame, cm, matrix, _Data, ref iRow, iColumn, level+1);
					continue;
				}
				saveColumn = iColumn;
				int rowcell = rgsCount == 0? 0: (iRow - headerRows) % rgsCount;
				RunDataColumn(rpt, wc, ame, cm, matrix, _Data, iRow, ref saveColumn, 0, rowcell);
				iRow++;
			}
			// do we need to subtotal this?
			RowGrouping rg = (RowGrouping) (_RowGroupings.Items[level]);
			if (rg.DynamicRows != null &&
				rg.DynamicRows.Subtotal != null)
			{
				for (int i=0; i < this.CountMatrixRows; i++)
				{
					saveColumn = iColumn;
					RunDataColumn(rpt, wc, rm, cm, matrix, _Data, iRow, ref saveColumn, 0, i);
					iRow++;
				}
			}
		}
Exemplo n.º 50
0
		private WorkClass GetWC(Report rpt)
		{
			if (rpt == null)	
				return new WorkClass();

			WorkClass wc = rpt.Cache.Get(this, "wc") as WorkClass;
			if (wc == null)
			{
				wc = new WorkClass();
				rpt.Cache.Add(this, "wc", wc);
			}
			return wc;
		}
Exemplo n.º 51
0
 public testCommand2(WorkClass wc)
 {
     _wc = wc;
 }