示例#1
0
        } // End Sub ChangeParameterPrompt

        public static void ChangeStichtag(string strFilename)
        {
            System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
            System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);

            System.Xml.XmlNode xnStichtag    = doc.SelectSingleNode("/dft:Report/dft:ReportParameters/dft:ReportParameter[@Name=\"in_stichtag\"]/dft:DefaultValue/dft:Values/dft:Value", nsmgr);
            string             strReportName = System.IO.Path.GetFileNameWithoutExtension(strFilename);

            if (!HasParameter(doc, "in_stichtag"))
            {
                return;
            }


            if (xnStichtag != null)
            {
                xnStichtag.FirstChild.Value = "=System.DateTime.Now.ToString(\"dd.MM.yyyy\")";
                string strStichTag = xnStichtag.FirstChild.Value;
                Logging.LogMessage("{0}\t{1}", strReportName, strStichTag);
                // =System.DateTime.Today.ToString("dd.MM.yyyy")
            } // End if (xnStichtag != null)
            else
            {
                Logging.LogMessage("{0}\tKein Parameter Stichtag", strReportName);
            }
            // =System.DateTime.Today.ToString("dd.MM.yyyy")
            // stichtagvalue.FirstChild.Value = "=System.DateTime.Today.ToString(\"dd.MMMM.yyyy\")";

            XmlTools.SaveDocument(doc, strFilename);
        } // End Sub ChangeStichtag
示例#2
0
        } // End Function GetParameterPrompt

        // ChangeParameterPrompt(strFileName, "in_standortkategorie", "Liegenschaftskategorie / Catégorie d'immeuble / Categoria di patrimonio immobiliare / Estate category");
        // ChangeParameterPrompt(strFileName, "in_standortkategorie", "Standortkategorie / Catégorie site / Categoria sito / Site category");
        // ChangeParameterPrompt(strFileName, "in_standort", "Standort / Site / Sito / Site");
        // ChangeParameterPrompt(strFileName, "in_standort", "Liegenschaft / Immeuble / Patrimonio immobiliare / Estate");
        // ChangeParameterPrompt(strFileName, "in_gebaeude", "Gebäude / Bâtiment / Edificio / Building");
        public static void ChangeParameterPrompt(string strFilename, string strReportParameterName, string strReplacementText)
        {
            System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
            System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);

            if (!HasParameter(doc, strReportParameterName))
            {
                return;
            }


            System.Xml.XmlNode xnParameterPrompt = GetParameterPrompt(doc, strReportParameterName);
            string             strReportName     = System.IO.Path.GetFileNameWithoutExtension(strFilename);

            if (xnParameterPrompt != null)
            {
                string strParameterValue = xnParameterPrompt.FirstChild.Value;
                xnParameterPrompt.FirstChild.Value = strReplacementText;
                Logging.LogMessage("Old value in {0}:\t{1}", strReportName, strParameterValue);
            } // End if (xnParameterPrompt != null)
            else
            {
                Logging.LogMessage("{0}\tKein Parameter " + strReportParameterName, strReportName);
            }


            XmlTools.SaveDocument(doc, strFilename);
        } // End Sub ChangeParameterPrompt
示例#3
0
        } // End Sub AddOrReplaceParameter

        public static void AddCustomParameter(string strFilename, System.Xml.XmlNode xnInsertHere, bool bFirst, bool bLast, string strXmlFragment)
        {
            string strReportName = System.IO.Path.GetFileNameWithoutExtension(strFilename);


            if (xnInsertHere != null)
            {
                Logging.LogMessage("{0}\t{1}", strReportName, "hasParameters");

                System.Xml.XmlDocument         doc        = xnInsertHere.OwnerDocument;
                System.Xml.XmlDocumentFragment xmlDocFrag = doc.CreateDocumentFragment();
                xmlDocFrag.InnerXml = strXmlFragment;


                bool bDoNotFechParameter = bFirst || bLast;

                if (bDoNotFechParameter)
                {
                    if (bFirst)
                    {
                        xnInsertHere.PrependChild(xmlDocFrag);
                    }
                    else
                    {
                        xnInsertHere.AppendChild(xmlDocFrag);
                    }
                }
                else
                {
                    if (StringComparer.InvariantCultureIgnoreCase.Equals(xnInsertHere.LocalName, "ReportParameters"))
                    {
                        xnInsertHere.AppendChild(xmlDocFrag);
                    }
                    else
                    {
                        xnInsertHere.ParentNode.InsertAfter(xmlDocFrag, xnInsertHere);
                    }
                } // End else of if (bDoNotFechParameter)

                XmlTools.SaveDocument(doc, strFilename, true);
            } // End if (xn
            else
            {
                Logging.LogMessage("{0}\tKeine Parameter in Report.", strReportName);
            }
        } // End Sub AddCustomParameter
示例#4
0
        public static void AddOrReplaceParameter(string strFilename, string parameterName, string strAppendAfterParameter, string fragment)
        {
            string strName = GetNameFromFragment(fragment);

            if (!StringComparer.InvariantCultureIgnoreCase.Equals(strName, parameterName))
            {
                throw new Exception("Parameter name mismatch - \"" + parameterName + "\" != \"" + strName + "\"");
            }

            System.Xml.XmlNode xnPrevious = null;
            System.Xml.XmlNode xn         = GetParameter(strFilename, parameterName);
            bool bFirst = false;


            if (xn != null)
            {
                xnPrevious = xn.PreviousSibling;
                xn.ParentNode.RemoveChild(xn);
                XmlTools.SaveDocument(xn.OwnerDocument, strFilename, true);
            } // End if (xn != null)

            if (xnPrevious == null)
            {
                xnPrevious = GetParameter(strFilename, strAppendAfterParameter);
            } // End if (xnPrevious == null)

            if (xnPrevious == null)
            {
                System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
                System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);
                xnPrevious = doc.SelectSingleNode("/dft:Report/dft:ReportParameters", nsmgr);
                bFirst     = true;


                if (xnPrevious == null)
                {
                    return;
                }
            } // End if (xnPrevious == null)

            AddCustomParameter(strFilename, xnPrevious, bFirst, false, fragment);
        } // End Sub AddOrReplaceParameter
示例#5
0
        } // End Function GetDataSetDefinition

        public static void AddMainParametersNode(string strFilename)
        {
            if (HasParameters(strFilename))
            {
                return;
            }

            System.Xml.XmlNode xnDataSets = GetDataSetsNode(strFilename);
            if (xnDataSets == null)
            {
                return;
            }

            System.Xml.XmlDocument         doc        = xnDataSets.OwnerDocument;
            System.Xml.XmlDocumentFragment xmlDocFrag = doc.CreateDocumentFragment();
            xmlDocFrag.InnerXml = "<ReportParameters></ReportParameters>";

            xnDataSets.ParentNode.InsertAfter(xmlDocFrag, xnDataSets);
            XmlTools.SaveDocument(doc, strFilename, true);
        }
示例#6
0
        }     // End Sub AddCustomDataSet

        public static void AddCustomDataSet(string strFilename, string strDataSetName, string strXmlFragment)
        {
            System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
            System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);

            if (HasDataSet(doc, strDataSetName))
            {
                return;
            }

            string strReportName = System.IO.Path.GetFileNameWithoutExtension(strFilename);

            System.Xml.XmlNode xnDataSets = doc.SelectSingleNode("/dft:Report/dft:DataSets", nsmgr);

            if (xnDataSets != null)
            {
                System.Xml.XmlNode xnAppendAfterThis = null;

                // bool bFirst = StringComparer.OrdinalIgnoreCase.Equals(strAppendAfterParameter, "first");
                // bool bLast = StringComparer.OrdinalIgnoreCase.Equals(strAppendAfterParameter, "last");

                // bool bDoNotFechParameter = bFirst || bLast;

                // if (!bDoNotFechParameter)
                // xnAppendAfterThis = GetParameter(doc, strAppendAfterParameter);
                xnAppendAfterThis = xnDataSets;

                if (xnAppendAfterThis != null) // || bDoNotFechParameter)
                {
                    Logging.LogMessage("{0}\t{1}", strReportName, "Has DataSets");



                    System.Xml.XmlDocument doc2 = new System.Xml.XmlDocument();
                    doc2.LoadXml(CreateFragmentString(strFilename, strXmlFragment));
                    System.Xml.XmlNode fragmentToInsert = doc2.DocumentElement.FirstChild;
                    doc2 = null;

                    // System.Xml.XmlDocumentFragment xmlDocFrag = doc.CreateDocumentFragment();
                    // xmlDocFrag.InnerXml = strXmlFragment;
                    // // xmlDocFrag.AppendChild(doc.ImportNode(fragmentToInsert, true));


                    // employeeNode.AppendChild(employeeNode.OwnerDocument.ImportNode(otherXmlDocument.DocumentElement, true));
                    // xnAppendAfterThis.ParentNode.InsertAfter(fragmentToInsert, xnAppendAfterThis);
                    // xnAppendAfterThis.ParentNode.InsertAfter(doc.ImportNode(fragmentToInsert, true), xnAppendAfterThis);
                    xnAppendAfterThis.AppendChild(doc.ImportNode(fragmentToInsert, true));

                    // xnAppendAfterThis.ParentNode.InsertAfter(xmlDocFrag, xnAppendAfterThis);

                    //if (bDoNotFechParameter)
                    //{
                    //    if (bFirst)
                    //        xnDataSets.PrependChild(xmlDocFrag);
                    //    else
                    //        xnDataSets.AppendChild(xmlDocFrag);
                    //}
                    //else
                    //{
                    //    xnAppendAfterThis.ParentNode.InsertAfter(xmlDocFrag, xnAppendAfterThis);
                    //} // End else of if (bDoNotFechParameter)
                } // End if (xnAppendAfterThis != null || string.IsNullOrEmpty(strAppendAfterParameter))
                else
                {
                    Logging.LogMessage("{0}\tKeine Parameter in Report.", strReportName);
                }
            } // End if (xnParameters != null)

            XmlTools.SaveDocument(doc, strFilename, true);
            //XmlTools.SaveDocument(doc, strFilename, "<ReportParameter Name=\"proc\" xmlns=\"\">", "<ReportParameter Name=\"proc\">");
        } // End Sub AddCustomDataSet
示例#7
0
        } // End Function GetImageTag

        // AlterImage(strFileName, "in_gebaeude", "Gebäude / Bâtiment / Edificio / Building");
        public static void AlterImage(string strFilename, string strReportParameterName)
        {
            System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
            System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);


            string strReportName = System.IO.Path.GetFileNameWithoutExtension(strFilename);

            System.Xml.XmlNode xnImageTag = GetImageTag(doc, strReportParameterName);
            // System.Console.WriteLine(xnImageTag);

            if (xnImageTag == null)
            {
                Logging.LogMessage("{0}\tKein Image in " + strReportParameterName, strReportName);
                return;
            } // End if (xnImageTag == null)

            // http://www.w3schools.com/xpath/xpath_syntax.asp
            // http://www.bennadel.com/blog/2142-using-and-expressions-in-xpath-xml-search-directives-in-coldfusion.htm

            System.Xml.XmlNode xnSource = xnImageTag.SelectSingleNode("./dft:Source", nsmgr);
            xnSource.InnerText = "External";

            System.Xml.XmlNode xnValue = xnImageTag.SelectSingleNode("./dft:Value", nsmgr);
            xnValue.InnerText = "logo_immo.png";

            System.Xml.XmlNode xnSizing = xnImageTag.SelectSingleNode("./dft:Sizing", nsmgr);
            xnSizing.InnerText = "FitProportional";


            System.Xml.XmlNode xnLeft = xnImageTag.SelectSingleNode("./dft:Left", nsmgr);
            // System.Xml.XmlNode xnPageWidth = doc.SelectSingleNode("/dft:Report/dft:Page/dft:PageWidth", nsmgr);
            // System.Xml.XmlNode xnPageHeight = doc.SelectSingleNode("/dft:Report/dft:Page/dft:PageHeight", nsmgr);

            if (xnLeft != null)
            {
                double strLeft = ConvertToCm(xnLeft.InnerText);
                // double strPageWidth = ConvertToCm(xnPageWidth.InnerText);
                // double strPageHeight = ConvertToCm(xnPageHeight.InnerText);



                if (strLeft > 10) // Right aligned logo
                {
                    System.Xml.XmlNode xnStyle = xnImageTag.SelectSingleNode("./dft:Style", nsmgr);

                    if (xnStyle != null)
                    {
                        System.Xml.XmlNode xnPadding = xnStyle.SelectSingleNode("./dft:PaddingLeft", nsmgr);

                        if (xnPadding == null)
                        {
                            var ele = doc.CreateElement("PaddingLeft", doc.DocumentElement.NamespaceURI);
                            ele.InnerText = "45pt";
                            System.Xml.XmlNode xnCrap = xnStyle.AppendChild(ele);
                            // xnCrap.Attributes.Remove(xnCrap.Attributes["xmlns"]);
                        } // End if (xnPadding == null)
                    }     // End if (xnStyle != null)
                }         // End if (strLeft > 10)
            }             // End if (xnLeft != null)
              // else System.Console.WriteLine("Null left " + strFilename);

            ///dft:Report/dft:Page/dft:PageHeader/dft:ReportItems/dft:Image/dft:Style/dft:PaddingLeft

            XmlTools.SaveDocument(doc, strFilename);
        } // End Sub ChangeParameterPrompt