Example #1
0
 public BlockInfo(DeliverResponse resp)
 {
     if (resp.TypeCase == DeliverResponse.TypeOneofCase.Block)
     {
         Block respBlock = resp.Block;
         filteredBlock = null;
         if (respBlock == null)
         {
             throw new ArgumentNullException("DeliverResponse type block but block is null");
         }
         block = new BlockDeserializer(respBlock);
     }
     else if (resp.TypeCase == DeliverResponse.TypeOneofCase.FilteredBlock)
     {
         filteredBlock = resp.FilteredBlock;
         block         = null;
         if (filteredBlock == null)
         {
             throw new ArgumentNullException("DeliverResponse type filter block but filter block is null");
         }
     }
     else
     {
         throw new ArgumentException($"DeliverResponse type has unexpected type");
     }
 }
Example #2
0
        public static IList <BlockBase> GetBlocks(this RequestMessage requestMessage)
        {
            var rawBlocks = requestMessage.GetParameterValueFromPostOrGet("blocks");

            var deserializer = new BlockDeserializer();

            var blocks = deserializer.Deserialize(rawBlocks);

            return(blocks.ToList());
        }
Example #3
0
        public bool DeepCompare()
        {
            bool   isIdentical = false;
            var    deepex      = new DeepEx();
            string workingDir  = @"E:\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder";            // company desktop
            //string workingDir = @"C:\Users\JANO\source\repos\jszomorCAD\jCAD.PID_Builder"; // home laptop
            //string workingDir = @"C:\Users\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder"; // company laptop

            var JsonCompareFile  = Path.Combine(workingDir, "JsonCompareResult.txt");
            var JsonPIDBuild     = Path.Combine(workingDir, "JsonPIDBuild.json");
            var JsonPIDBuildCopy = Path.Combine(workingDir, "JsonPIDBuildCopy.json");

            var blockDeserialize = new BlockDeserializer();
            var jsonPID1         = blockDeserialize.ReadJsonData(JsonPIDBuild);
            var jsonPID2         = blockDeserialize.ReadJsonData(JsonPIDBuildCopy);

            BlockCollector(jsonPID1, jsonPID2, deepex);
            LineCollector(jsonPID1, jsonPID2, deepex);

            if (jsonPID1.Blocks.Count != jsonPID2.Blocks.Count || jsonPID1.Lines.Count != jsonPID2.Lines.Count)
            {
                deepex.Comments.Insert(0, "Differences:");
                deepex.Comments.Add("Length is not equal!");
            }

            if (deepex.Comments.Count == 0)
            {
                deepex.Comments.Add("Files are eqvivalent!");
                isIdentical = true;
            }
            else
            {
                if (deepex.Comments.Contains("Differences:") == false)
                {
                    deepex.Comments.Insert(0, "Differences:");
                }

                deepex.Comments.Add("Files are not eqvivalent!");
            }
            CommentCollector(deepex.Comments, JsonCompareFile);
            return(isIdentical);
        }
Example #4
0
 public BlockInfo(Block block)
 {
     filteredBlock = null;
     this.block    = new BlockDeserializer(block);
 }
Example #5
0
        public void BlockSearch()
        {
            var    db = Application.DocumentManager.MdiActiveDocument.Database;
            var    blockDeserialize = new BlockDeserializer();
            string path             = @"E:\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder\Autocad PID blocks work in progress.dwg";
            // Copy blocks from sourcefile into opened file
            var copyBlock = new CopyBlock();

            #region btrNamesToCopy
            var eqType = new[] {
                "aeration diffuzer",
                "arrow",
                "alkalinity_chamber",
                "blower",
                "break",
                "chamber",
                "chamber circular",
                "chamber description",
                "channel",
                "channel gate",
                "channel2",
                "clarifier circular",
                "Clarifier Equipment",
                "clarifier longitudial",
                "collector",
                "controll tag e",
                "digester",
                "digester cap",
                "drum filter",
                "filter",
                "filter2",
                "Gas equipments",
                "gas flame",
                "gas holder",
                "grease_coll_chmbr",
                "heating",
                "instrumentairheaderarrow",
                "instrumentation tag",
                "leachet_coll_chmbr",
                "moister trap",
                "TWT",
                "ozone unit",
                //"PID-PS-FRAME",
                "pipe",
                "pipe2",
                "poli dosing",
                "pump",
                "mixer",
                "pr_cl_chmbr",
                "reactor",
                "RefALSewage",
                "RefALPoly",
                "RefALPotable",
                "RefALRecSludge",
                "RefARRecSludge",
                "RefALTransport",
                "RefARRawSludge",
                "RefARSewage",
                "RefARNaturalGas",
                "RefALRawSludge",
                "RefPIDEfluent",
                "RefPIDInfluent",
                "RefAL1AirToBiofilter",
                "RefAL1AirfromSludge",
                "RefAR1AirfromSludge",
                "RefAL2UtilityWater",
                "RefAR2UtilityWater",
                "RefAR3UtilityWater",
                "RefAL3UtilityWater",
                "RefAR4Leachate",
                "RefAL5Leachate",
                "RefAL6WasteSludge",
                "RefAR6WasteSludge",
                "RefAL7WasteAir",
                "RefAR7WasteAir",
                "RefAR10Sludge",
                "RefAR12Gas",
                "RefAR13Sludge",
                "RefAR14Water",
                "RefAL15Water",
                "RefAR16Water",
                "RefAL17Water",
                "RefAR18Water",
                "RefAL19Water",
                "RefAL22WasteSludge",
                "RefAR22WasteSludge",
                "RefAL23Leachate",
                "RefAR24UtilityWater",
                "RefAL25UtilityWater",
                "RefAR25UtilityWater",
                "RefAR26Leachate",
                "RefAL26Leachate",
                "sand trap",
                "screen",
                "screening press",
                "sst2_chmbr",
                "sst2Dig",
                "screening press",
                "sludge dewatering",
                "tank - vessel",
                "valve",
                "Vortex_grit_chamber",
                "Vortex_sand_chamber",
                "vortexEQ"
            };
            #endregion

            string[] btrNamesToCopy = eqType.Distinct().ToArray();

            copyBlock.CopyBlockTable(db, path, btr =>
            {
                System.Diagnostics.Debug.Print(btr.Name);
                return(btrNamesToCopy.Contains(btr.Name));
            });

            var defultLayers = new LayerCreator();
            defultLayers.Layers();

            var insertBlock = new InsertBlock(db);
            var filePath    = @"E:\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder\JsonPIDBuild.json";
            var jsonPID     = blockDeserialize.ReadJsonData(filePath);

            //var sBlockName = jsonPID.Blocks.Select(b => b.Misc.BlockName);
            var blockNames =
                from b in jsonPID.Blocks
                select b.Misc.BlockName;

            foreach (var blockName in btrNamesToCopy)
            {
                try
                {
                    insertBlock.PlaceBlocksByName(jsonPID, blockName);
                    //MoveToBottom.SendToBackBlock();
                }
                catch (ArgumentNullException)
                {
                    // ignore
                }
            }

            var    insertBlockTable = new BlockTableRead(db);
            string fileName         = "JsonPIDBuildCopy.json";
            insertBlockTable.ReadBtrForSeri(db, fileName);
            //var blockDeserialize = new BlockDeserialize();
            //var eqType = blockDeserialize.BlockSearch("Name");

            //System.Diagnostics.Debug.Print($"BlockName: {eqType}");
        }
Example #6
0
        public void WhenDeserializingMessageThenItWorks()
        {
            var deserializer = new BlockDeserializer();

            #region bigjson
            var json = @"[
	{
		""type"": ""section"",
		""text"": {
			""type"": ""mrkdwn"",
			""text"": ""Hi Laura, would you have some times to answer this question?""
		}
	},
	{
		""type"": ""divider""
	},
	{
		""type"": ""context"",
		""elements"": [
			{
				""type"": ""image"",
				""image_url"": ""https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"",
				""alt_text"": ""First name Last name | Job @Company""
			},
			{
				""type"": ""mrkdwn"",
				""text"": ""Alexandre Bousquet | CTO @ Comet""
			}
		]
	},
	{
		""type"": ""section"",
		""text"": {
			""type"": ""mrkdwn"",
			""text"": ""*Hi, do you have a good A/B testing tool to recommend to push features gradually to users?*""
		}
	},
	{
		""type"": ""section"",
		""text"": {
			""type"": ""mrkdwn"",
			""text"": ""Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Maecenas sed diam eget risus varius blandit sit amet non magna. ""
		}
	},
	{
		""type"": ""section"",
		""text"": {
			""type"": ""mrkdwn"",
			""text"": "" ""
		}
	},
	{
		""type"": ""context"",
		""elements"": [
			{
				""type"": ""mrkdwn"",
				""text"": ""Lion, Kima Ventures, The Family""
			}
		]
	},
	{
		""type"": ""section"",
		""text"": {
			""type"": ""mrkdwn"",
			""text"": ""Great, please respond using thread :speech_balloon:""
		},
		""accessory"": {
			""type"": ""button"",
			""text"": {
				""type"": ""plain_text"",
				""text"": ""Cancel"",
				""emoji"": true
			},
			""style"": ""danger"",
			""value"": ""click_me_123""
		}
	},
	{
		""type"": ""divider""
	},
	{
		""type"": ""context"",
		""elements"": [
			{
				""type"": ""image"",
				""image_url"": ""https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"",
				""alt_text"": ""First name Last name | Job @Company""
			},
			{
				""type"": ""image"",
				""image_url"": ""https://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"",
				""alt_text"": ""First name Last name | Job @Company""
			},
			{
				""type"": ""image"",
				""image_url"": ""https://images.pexels.com/photos/555790/pexels-photo-555790.png?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"",
				""alt_text"": ""First name Last name | Job @Company""
			},
			{
				""type"": ""image"",
				""image_url"": ""https://images.pexels.com/photos/1172784/pexels-photo-1172784.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"",
				""alt_text"": ""First name Last name | Job @Company""
			},
			{
				""type"": ""image"",
				""image_url"": ""https://images.pexels.com/photos/1674752/pexels-photo-1674752.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"",
				""alt_text"": ""First name Last name | Job @Company""
			},
			{
				""type"": ""mrkdwn"",
				""text"": ""and {x} people are insterested!""
			}
		]
	},
	{
		""type"": ""context"",
		""elements"": [
			{
				""type"": ""mrkdwn"",
				""text"": ""Discover what's going on in your communities by going to <https://app.whyse.co/|Whyse>""
			}
		]
	},
	{
		""type"": ""actions"",
		""elements"": [
			{
				""type"": ""button"",
				""text"": {
					""type"": ""plain_text"",
					""text"": ""Yes"",
					""emoji"": true
				}
			},
			{
				""type"": ""button"",
				""text"": {
					""type"": ""plain_text"",
					""text"": ""No"",
					""emoji"": true
				}
			},
			{
				""type"": ""button"",
				""text"": {
					""type"": ""plain_text"",
					""text"": ""Maybe"",
					""emoji"": true
				}
			},
			{
				""type"": ""static_select"",
				""placeholder"": {
					""type"": ""plain_text"",
					""text"": ""Select an item"",
					""emoji"": true
				},
				""options"": [
					{
						""text"": {
							""type"": ""plain_text"",
							""text"": ""Excellent item 1"",
							""emoji"": true
						},
						""value"": ""value-0""
					},
					{
						""text"": {
							""type"": ""plain_text"",
							""text"": ""Fantastic item 2"",
							""emoji"": true
						},
						""value"": ""value-1""
					},
					{
						""text"": {
							""type"": ""plain_text"",
							""text"": ""Nifty item 3"",
							""emoji"": true
						},
						""value"": ""value-2""
					},
					{
						""text"": {
							""type"": ""plain_text"",
							""text"": ""Pretty good item 4"",
							""emoji"": true
						},
						""value"": ""value-3""
					}
				]
			}
		]
	}
]";
            #endregion

            var blocks = deserializer.Deserialize(json).ToList();

            Assert.Equal(12, blocks.Count);
            var actionsBlock = blocks.OfType <ActionsBlock>();
            Assert.NotNull(actionsBlock);

            var sectionActionBlock = blocks[7] as SectionBlock;
            Assert.NotNull(sectionActionBlock);
            Assert.IsType <ButtonElement>(sectionActionBlock.Accessory);
        }