Exemplo n.º 1
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);
        }
Exemplo n.º 2
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}");
        }