private void generateFields() { string xmlItem = string.Empty; string objectType; int objectID; Dictionary <string, string> values = new Dictionary <string, string>(); if (Session["registryDefinition"] == null) { return; } int idPozycji = 0; if (Request.QueryString["itemId"] != null && int.TryParse(Request.QueryString["itemId"].ToString(), out idPozycji)) { xmlItem = new RegistryDAO().GetRegistryItem(idPozycji); new RegistryDAO().GetObjectIDRegistry(idPozycji, out objectType, out objectID); switch (objectType) { case "DOC": ObjectDetailsViewC.DocumentID = objectID; ObjectType = "dokumentu"; ScanPreviewControl1.DocumentID = objectID; break; case "CASE": ObjectDetailsViewC.CaseID = objectID; ObjectType = "sprawy"; break; } if (!string.IsNullOrEmpty(xmlItem)) { XPathDocument xmld = new XPathDocument(new StringReader(xmlItem)); XPathNavigator xmln = xmld.CreateNavigator(); XPathNodeIterator xmli = xmln.Select("/wpis//*"); while (xmli.MoveNext()) { values.Add(xmli.Current.Name, xmli.Current.Value); } } } else { int regID = 0; int.TryParse(Request["regid"].ToString(), out regID); RegistryDAO dao = new RegistryDAO(); objectType = dao.GetRegistryType(regID); objectID = CoreObject.GetId(Request); switch (objectType) { case "DOC": ObjectDetailsViewC.DocumentID = objectID; ObjectType = "dokumentu"; ScanPreviewControl1.DocumentID = objectID; break; case "CASE": ObjectDetailsViewC.CaseID = objectID; ObjectType = "sprawy"; break; } } XPathDocument xpd = new XPathDocument(new StringReader(Session["registryDefinition"].ToString())); XPathNavigator xpn = xpd.CreateNavigator(); XPathNodeIterator xpni = xpn.Select("//pole"); while (xpni.MoveNext()) { bool isHeader = xpni.Current.SelectDescendants("pole", "", false).Count > 0; int level = xpni.Current.SelectAncestors("pole", "", false).Count + 1; if (isHeader) { level -= 1; } if (level < 0) { level = 0; } string name = xpni.Current.SelectSingleNode("@nazwa").Value; string label = xpni.Current.SelectSingleNode("@etykieta").Value; if (isHeader) { fieldContainer.Controls.Add(RegistryHelper.CreateField(isHeader, "0", level, name, label, null, false, null)); } else { string dataType = xpni.Current.SelectSingleNode("@typ").Value; bool required = xpni.Current.SelectSingleNode("@wymagane").Value == "1" ? true : false; string position = xpni.CurrentPosition.ToString(); fieldContainer.Controls.Add(RegistryHelper.CreateField(isHeader, position, level, name, label, dataType, required, values.Count > 0?values[name]:null)); } } }