public void DeserializeFormDesignFromPath() { //string path = "C:\\SDC\\CCO Lung Surgery.xml"; string path = "C:\\Users\\rmoldwi\\OneDrive\\Desktop\\SDCLocal\\Breast.Invasive.Staging.359_.CTP9_sdcFDF.xml"; //string path = "C:\\SDC\\Adrenal.Bx.Res.129_3.004.001.REL_sdcFDF_test.xml"; string sdcFile = File.ReadAllText(path, System.Text.Encoding.UTF8); var FD = FormDesignType.DeserializeFromXmlPath(path); //SDC.Schema.FormDesignType FD = SDC.Schema.FormDesignType.DeserializeSdcFromFile(sdcFile); string myXML; //myXML = SdcSerializer<FormDesignType>.Serialize(FD); //Test adding and reading FD object model var Q = (QuestionItemType)FD.Nodes.Values.Where( t => t.GetType() == typeof(QuestionItemType)).Where( q => ((QuestionItemType)q).ID == "58218.100004300").FirstOrDefault(); var DI = Q.AddChildDisplayedItem("DDDDD"); //should add to end of the <List> DI.name = DI.ID; DI.title = DI.ID; var P = Q.AddProperty(); P.name = "PPPPP"; P.propName = "PPPPP"; var S = Q.AddChildSection("SSSSS", 0); S.name = "SSSSS"; //Q.Move(new SectionItemType(), -1); Q.AddComment(); Q.Remove(); //var li = new ListItemType(Q.ListField_Item.List,"abc" ); var b = li.SelectIf.returnVal; var rv = li.OnSelect[0].returnVal; DisplayedType DI1 = (DisplayedType)FD.Nodes.Values.Where(n => n.name == DI.ID).First(); DisplayedType DI2 = (DisplayedType)Q.ChildItemsNode.Items[0]; QuestionItemType Q1 = (QuestionItemType)DI2.ParentNode.ParentNode; myXML = SDCHelpers.XmlReorder(FD.GetXml()); myXML = SDCHelpers.XmlFormat(myXML); Debug.Print(myXML); FD.Clear(); //var myMP = FD.GetMsgPack(); //FD.SaveMsgPackToFile("C:\\MPfile"); //also support REST transactions, like sending packages to SDC endpoints; consider FHIR support //var myJson = FD.GetJson(); //Debug.Print(myJson); }
public void TreeComparer() { Setup.TimerStart($"==>{Setup.CallerName()} Started"); BaseType.ResetSdcImport(); string path = Path.Combine(".", "Test files", "Adrenal.Bx.Res.129_3.004.001.REL_sdcFDF_test.xml"); var FDbad = FormDesignType.DeserializeFromXmlPath(path); //used to compare nodes in another tree var adr = FDbad.Nodes.Values.ToArray(); //this creates shallow copies with do not retain ParentNode refs, etc. var tc = new TreeComparer(); var n = Setup.FD.Nodes.Values.ToArray(); //this creates shallow copies with do not retain ParentNode refs, etc. Stopwatch.StartNew(); var a = Stopwatch.GetTimestamp(); Debug.Print(tc.Compare(n[0], n[1]).ToString()); Debug.Print(tc.Compare(n[0], n[2]).ToString()); Debug.Print(tc.Compare(n[0], n[3]).ToString()); Debug.Print(tc.Compare(n[0], n[10]).ToString()); Debug.Print(tc.Compare(n[0], n[3]).ToString()); Debug.Print(tc.Compare(n[0], n[8]).ToString()); Debug.Print(tc.Compare(n[1], n[8]).ToString()); Debug.Print("\r\n"); Debug.Print(tc.Compare(n[1], n[1]).ToString()); Debug.Print(tc.Compare(n[2], n[2]).ToString()); Debug.Print(tc.Compare(n[3], n[3]).ToString()); Debug.Print(tc.Compare(n[10], n[10]).ToString()); Debug.Print(tc.Compare(n[20], n[20]).ToString()); Debug.Print(tc.Compare(n[30], n[30]).ToString()); Debug.Print(tc.Compare(n[50], n[50]).ToString()); Debug.Print("\r\n expected results: -1, 1, -1, 1, -1, 1, -1 "); Debug.Print(tc.Compare(n[1], n[2]).ToString()); // -1 Debug.Print(tc.Compare(n[2], n[1]).ToString()); // 1 Debug.Print(tc.Compare(n[33], n[34]).ToString()); // -1 Debug.Print(tc.Compare(n[20], n[10]).ToString()); // 1 Debug.Print(tc.Compare(n[199], n[201]).ToString()); // -1 Debug.Print(tc.Compare(n[201], n[200]).ToString()); // 1 Debug.Print(tc.Compare(n[29], n[32]).ToString()); // -1 Debug.Print("\r\n expected results: -1, 1, -1, 1, -1, 1, -1 "); Debug.Print(tc.Compare(n[299], n[301]).ToString()); // -1 Debug.Print(tc.Compare(n[401], n[300]).ToString()); // 1 Debug.Print(tc.Compare(n[39], n[42]).ToString()); // -1 Debug.Print(tc.Compare(n[21], n[11]).ToString()); // 1 Debug.Print(tc.Compare(n[11], n[12]).ToString()); // -1 Debug.Print(tc.Compare(n[341], n[133]).ToString()); // 1 Debug.Print(tc.Compare(n[101], n[120]).ToString()); // -1 Debug.Print("\r\n"); Debug.Print(tc.Compare(n[2], n[1]).ToString()); Debug.Print(tc.Compare(n[4], n[0]).ToString()); Debug.Print(tc.Compare(n[6], n[4]).ToString()); Debug.Print(tc.Compare(n[20], n[2]).ToString()); Debug.Print(tc.Compare(n[40], n[0]).ToString()); Debug.Print(tc.Compare(n[60], n[0]).ToString()); Debug.Print(tc.Compare(n[100], n[0]).ToString()); Debug.Print("\r\n"); try { Debug.Print(tc.Compare(n[100], adr[0]).ToString()); } catch { Debug.Print("error caught"); } try { Debug.Print(tc.Compare(adr[0], n[100]).ToString()); } catch { Debug.Print("error caught"); } try { Debug.Print(tc.Compare(n[10], adr[12]).ToString()); } catch { Debug.Print("error caught"); } try { Debug.Print(tc.Compare(adr[100], adr[100]).ToString()); } catch { Debug.Print("error caught"); } Debug.Print(((float)(Stopwatch.GetTimestamp() - a) / ((float)Stopwatch.Frequency)).ToString()); //Seconds per comparison: @ 0.0006 sec/comparison a = Stopwatch.GetTimestamp(); for (int i = 0; i < 100; i++) { tc.Compare(n[299], n[301]); tc.Compare(n[2101], n[120]); } Debug.Print(((float)(Stopwatch.GetTimestamp() - a) / ((float)Stopwatch.Frequency) / 200).ToString()); Setup.TimerPrintSeconds(" seconds: ", $"\r\n<=={Setup.CallerName()} Complete"); }