示例#1
0
        private UnloadEntity GetUnloadEntity(DataBus dataBus, string unloadName)
        {
            JSCodeRunner codeRunner = new JSCodeRunner();

            codeRunner.Include("JSCode\\JsonEncode.js");
            codeRunner.Include("JSCode\\GetUnloadEntity.js");
            string       codeToRun    = " return GetUnloadEntity(\"" + unloadName + "\");";
            UnloadEntity unloadEntity = codeRunner.Run <UnloadEntity>(dataBus, codeToRun);

            return(unloadEntity);
        }
        private void TestDrawing_Paint(object sender, PaintEventArgs e)
        {
            UnloadEntity entity = new UnloadEntity();

            entity.Unload = true;
            entity.Name   = "MS.R3.5 QCR19248 - Electronic Signature Control";
            for (int i = 0; i < 3; i++)
            {
                UnloadItem item = new UnloadItem();
                item.ElementName = i.ToString();
                item.Query       = "activity=\"Item Verification Failed\" and notif.for.company=\"DEFAULT\" and language=\"en\" and module.identifier=\"SM\"";
                entity.Items.Add(item);
            }
            Image image = CreateUnloadImage(entity);

            image.Save("test.jpg");
            e.Graphics.DrawImage(image, 0, 0);
        }
        private Image CreateUnloadImage(UnloadEntity entity)
        {
            int width  = 1000;
            int height = 80 + 20 * (entity.Items.Count + 1);

            System.Drawing.Font textFont = new System.Drawing.Font("Helvetica", 10, FontStyle.Regular, GraphicsUnit.Pixel);
            System.Drawing.Font imgFont  = new System.Drawing.Font("Helvetica", 16, FontStyle.Bold, GraphicsUnit.Pixel);

            Image    image    = new Bitmap(width, height, PixelFormat.Format32bppRgb);
            Graphics graphics = Graphics.FromImage(image);

            graphics.CompositingQuality = CompositingQuality.AssumeLinear;
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
            graphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);

            Pen linePen = new Pen(Color.Black, 1);

            graphics.DrawRectangle(linePen, 0, 0, width - 2, height - 2);

            int        nameLabelX      = 40;
            int        nameLabelY      = 20;
            SolidBrush textBrush       = new SolidBrush(Color.Black);
            SolidBrush backgroundBrush = new SolidBrush(Color.SandyBrown);

            graphics.DrawString("Unload Script:", textFont, textBrush, nameLabelX, nameLabelY, new StringFormat());
            graphics.DrawString("Unload Script:", textFont, textBrush, nameLabelX, nameLabelY, new StringFormat());
            int nameTextX      = 150;
            int nameTextY      = nameLabelY - 4;
            int nameTextWidth  = 400;
            int nameTextHeight = 20;

            graphics.DrawRectangle(linePen, nameTextX, nameTextY, nameTextWidth, nameTextHeight);

            graphics.DrawString(entity.Name, textFont, textBrush, nameTextX + 5, nameLabelY, new StringFormat());

            string chooseStr = "√";

            int unloadCheckboxX     = 40;
            int unloadCheckboxY     = 50;
            int unloadCheckboxWidth = 15;

            graphics.DrawRectangle(linePen, unloadCheckboxX, unloadCheckboxY, unloadCheckboxWidth, unloadCheckboxWidth);

            if (entity.Unload)
            {
                graphics.DrawString(chooseStr, imgFont, textBrush, unloadCheckboxX, unloadCheckboxY);
                graphics.DrawString(chooseStr, imgFont, textBrush, unloadCheckboxX, unloadCheckboxY);
            }

            int unloadTextX = 60;
            int unloadTextY = 50;

            graphics.DrawString("Unload?", textFont, textBrush, unloadTextX, unloadTextY);

            int purgeCheckboxX = 150;
            int purgeCheckboxY = 50;

            graphics.DrawRectangle(linePen, purgeCheckboxX, purgeCheckboxY, unloadCheckboxWidth, unloadCheckboxWidth);

            if (entity.Purge)
            {
                graphics.DrawString(chooseStr, imgFont, textBrush, purgeCheckboxX, purgeCheckboxY);
                graphics.DrawString(chooseStr, imgFont, textBrush, purgeCheckboxX, purgeCheckboxY);
            }
            int purgeTextX = 180;
            int purgeTextY = 50;

            graphics.DrawString("Purge?", textFont, textBrush, purgeTextX, purgeTextY);


            //Draw the Table;
            int firstColumnWidth  = (int)((width - 2) * 0.25);
            int secondColumnWidth = (int)((width - 2) * 0.6);
            int thirdColumnWidth  = (int)((width - 2) * 0.15);

            int rowHeight = 20;


            int firstCellX = 2;
            int firstCellY = 80;

            int secondCellX = firstCellX + firstColumnWidth;
            int secondCellY = firstCellY;

            int thirdCellX = secondCellX + secondColumnWidth;
            int thirdCellY = firstCellY;

            //Draw header
            graphics.DrawRectangle(linePen, firstCellX, firstCellY, firstColumnWidth, rowHeight);
            graphics.FillRectangle(backgroundBrush, firstCellX, firstCellY, firstColumnWidth, rowHeight);
            graphics.DrawString("FileName", textFont, textBrush, firstCellX + 4, firstCellY + 4);

            graphics.DrawRectangle(linePen, secondCellX, secondCellY, secondColumnWidth, rowHeight);
            graphics.FillRectangle(backgroundBrush, secondCellX, secondCellY, secondColumnWidth, rowHeight);
            graphics.DrawString("Query", textFont, textBrush, secondCellX + 4, secondCellY + 4);

            graphics.DrawRectangle(linePen, thirdCellX, thirdCellY, thirdColumnWidth, rowHeight);
            graphics.FillRectangle(backgroundBrush, thirdCellX, thirdCellY, thirdColumnWidth, rowHeight);
            graphics.DrawString("Datamap", textFont, textBrush, thirdCellX + 4, thirdCellY + 4);

            for (int i = 0; i < entity.Items.Count; i++)
            {
                UnloadItem currentItem = entity.Items[i];

                firstCellX = 2;
                firstCellY = 80 + rowHeight * (i + 1);

                secondCellX = firstCellX + firstColumnWidth;
                secondCellY = firstCellY;

                thirdCellX = secondCellX + secondColumnWidth;
                thirdCellY = firstCellY;

                graphics.DrawRectangle(linePen, firstCellX, firstCellY, firstColumnWidth, rowHeight);
                graphics.DrawString(currentItem.ElementName, textFont, textBrush, firstCellX + 4, firstCellY + 4);

                graphics.DrawRectangle(linePen, secondCellX, secondCellY, secondColumnWidth, rowHeight);
                graphics.DrawString(currentItem.Query, textFont, textBrush, secondCellX + 4, secondCellY + 4);

                graphics.DrawRectangle(linePen, thirdCellX, thirdCellY, thirdColumnWidth, rowHeight);
            }

            graphics.Flush();
            graphics.Dispose();
            return(image);
        }
示例#4
0
        private string CreateHtmlForScreenShot(UnloadEntity entity)
        {
            //Params:
            //0: Unload Name
            //1: unload?
            //2: purge?
            //3: Show Unload Records
            //4: Show Protected Formats
            const string HeaderFormat = @"<label style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap;'>Unload Script:</label>
                    <input style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; width: 459px; height: 19px; ' value='{0}'/>
                    <p/>
                    <span>
                    <input sctype='CheckBox' style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ' type='checkbox' {1}  /><label style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap;'>
                    Unload?</label>
                    <input sctype='CheckBox' style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ' type='checkbox' {2} /><label style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap;'>Purge?</label>
                    </span>
                    <p>
                    <input checked='{3}' style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; top: 0px; left: 0px; ' type='radio' />
                    <label style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap;'> Show Unload Records</label>
                    <input checked='{4}' style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; top: 0px; left: 0px; ' type='radio' />
                    <label  style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap;'> Show Protected Formats</label>
                     <input type='checkbox'/>";

            const string TableHeader = @"
                    <table border='0' cellpadding='0' cellspacing='0' style='background-color: rgb(153, 153, 153); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(153, 187, 232); border-right-color: rgb(153, 187, 232); border-bottom-color: rgb(153, 187, 232); border-left-color: rgb(153, 187, 232); ' width='100%'>
                     <colgroup>
	                     <col width='204' />
	                     <col width='872' />
	                     <col width='171' />
                     </colgroup>	                
                    <tr>	
                    <th style='margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 8px; padding-bottom: 3px; padding-left: 8px; font-style: normal; font-weight: normal; text-align: left; border-left-color: rgb(201, 201, 201); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(201, 201, 201); border-bottom-width: 1px; border-bottom-style: solid;  background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(249, 249, 249); height: 20px; white-space: nowrap; background-position: 0% 0%; background-repeat: repeat no-repeat;'>
                        
		                <span style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap; '>Filename</span></th>
		                <th style='margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 8px; padding-bottom: 3px; padding-left: 8px; font-style: normal; font-weight: normal; text-align: left; border-left-color: rgb(201, 201, 201); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(201, 201, 201); border-bottom-width: 1px; border-bottom-style: solid;  background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(249, 249, 249); height: 20px; white-space: nowrap; background-position: 0% 0%; background-repeat: repeat no-repeat;'>
                        
		                <span style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap; '>
		                Query</span></th>
		                <th style='margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 8px; padding-bottom: 3px; padding-left: 8px; font-style: normal; font-weight: normal; text-align: left; border-left-color: rgb(201, 201, 201); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(201, 201, 201); border-bottom-width: 1px; border-bottom-style: solid;  background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(249, 249, 249); height: 20px; white-space: nowrap; background-position: 0% 0%; background-repeat: repeat no-repeat;'>
		                <span style='font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap; '>Datamap</span></th>
	                </tr>"    ;
            const string CellFormat  = @"<td style='margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 8px; padding-bottom: 3px; padding-left: 8px; font-style: normal; font-weight: normal; text-align: left; border-left-color: rgb(201, 201, 201); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(201, 201, 201); border-bottom-width: 1px; border-bottom-style: solid;  background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(249, 249, 249); height: 20px; white-space: nowrap; background-position: 0% 0%; background-repeat: repeat no-repeat; font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 11px; color: rgb(34, 34, 34); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2px; white-space: nowrap;'>{0}</td>";

            StringBuilder resultString = new StringBuilder();

            resultString.AppendFormat(HeaderFormat, entity.Name, entity.Unload ? "checked" : "", entity.Purge ? "checked" : "", true, false);

            resultString.Append("</p>");
            //Build table
            resultString.Append(TableHeader);
            foreach (UnloadItem item in entity.Items)
            {
                resultString.Append("<tr>");
                resultString.AppendFormat(CellFormat, item.ElementName);
                resultString.AppendFormat(CellFormat, item.Query);
                resultString.AppendFormat(CellFormat, string.Empty);
                resultString.Append("</tr>");
            }
            resultString.Append("</table>");
            return(resultString.ToString());
        }