Export Fusionchart to PDF using iTextSharp - c#

I would like to export my FusionChart to PDF using iTextSharp. I am able to export to PDF by use of setting the charts exportEnabled = '1', but I want to be able to export the fusionchart from my controller.
I have my entire fusionchart in a str variable and tried the following :
public FileStreamResult ExportPDF(int ProjectID)
{
string exportData = String.Format("<html><body>{0}</body></html>", getGraphXMLData(ProjectID));//This Gets the chart and stores into string
var bytes = System.Text.Encoding.UTF8.GetBytes(exportData);
using (var input = new MemoryStream(bytes))
{
var output = new MemoryStream();
var document = new iTextSharp.text.Document(PageSize.A4, 50, 50, 50, 50);
var writer = PdfWriter.GetInstance(document, output);
Font headerFont = FontFactory.GetFont("Verdana", 10);
Font rowfont = FontFactory.GetFont("Verdana", 10);
writer.CloseStream = false;
document.Open();
var xmlWorker = iTextSharp.tool.xml.XMLWorkerHelper.GetInstance();
xmlWorker.ParseXHtml(writer, document, input, System.Text.Encoding.UTF8);
document.Close();
output.Position = 0;
return File(output, "application/pdf", "ProfileChart_Report.pdf");
//return new FileStreamResult(output, "application/pdf");
}
}
I however get an error on this line : document.Close();
The error im getting is :
An exception of type 'System.IO.IOException' occurred in iTextSharp.dll but was not handled in user code
Additional information: The document has no pages.
Below is the data in the exportData field:
<html>
<body>
<chart caption='Project Test' yaxisname='Elevation' xaxisname='Accumulated Length' xaxismaxvalue='1000' xaxisminvalue='100' yaxismaxvalue='200' xnumberprefix='' ynumberprefix='' showcanvasborder='1' canvasborderthickness='0.5' canvasborderalpha= '50' showXAxisLine= '0' showformbtn= '1' formAction='#' submitdataasxml='1' baseFontColor='#333333' baseFont='Helvetica Neue, Arial' captionFontSize='14' subcaptionFontSize='14' subcaptionFontBold='0' showBorder='0' bgColor='#ffffff' showValues='0' showShadow='0' canvasBgColor='#ffffff' divlineAlpha='100' divlineColor='#999999' divlineThickness='1' divLineIsDashed='1' divLineDashLen='1' divLineGapLen='1' usePlotGradientColor='0' showplotborder='0' showAlternateHGridColor='0' showAlternateVGridColor='0' legendBgAlpha='0' legendBorderAlpha='0' legendShadow='0' legendItemFontSize='10' legendItemFontColor='#666666' toolTipColor='#ffffff' toolTipBorderThickness='0' toolTipBgColor='#000000' toolTipBgAlpha='80' toolTipBorderRadius='2' toolTipPadding = '5' labeldisplay= 'rotate' slantlabels= '1' exportEnabled='1' > <categories verticallinecolor='666666' verticallinethickness='1' alpha='40' anchorsides='0' anchorradius='0'><category label='0' x='0' showverticalline='0'/>
<category label='46.17' x='46.17' showverticalline='0'/>
<category label='142.98' x='142.98' showverticalline='0'/>
<category label='543.88' x='543.88' showverticalline='0'/>
<category label='826.58' x='826.58' showverticalline='0'/>
<category label='1037.93' x='1037.93' showverticalline='0'/>
<category label='1106.1' x='1106.1' showverticalline='0'/>
<category label='1338.1' x='1338.1' showverticalline='0'/>
<category label='1838.5' x='1838.5' showverticalline='0'/>
<category label='1889.37' x='1889.37' showverticalline='0'/>
<category label='2538' x='2538' showverticalline='0'/>
<category label='2789.04' x='2789.04' showverticalline='0'/>
<category label='3154.34' x='3154.34' showverticalline='0'/>
<category label='3345.17' x='3345.17' showverticalline='0'/>
<category label='4220.75' x='4220.75' showverticalline='0'/>
<category label='4671.9' x='4671.9' showverticalline='0'/>
<category label='5057.74' x='5057.74' showverticalline='0'/>
<category label='5318.51' x='5318.51' showverticalline='0'/>
<category label='5576.18' x='5576.18' showverticalline='0'/>
<category label='5958.13' x='5958.13' showverticalline='0'/>
<category label='6537.92' x='6537.92' showverticalline='0'/>
<category label='7282.09' x='7282.09' showverticalline='0'/>
<category label='8178.84' x='8178.84' showverticalline='0'/>
<category label='8511.22' x='8511.22' showverticalline='0'/>
<category label='8989.59' x='8989.59' showverticalline='0'/>
<category label='9442.78' x='9442.78' showverticalline='0'/>
<category label='9862.78' x='9862.78' showverticalline='0'/>
<category label='9942.78' x='9942.78' showverticalline='0'/>
<category label='10402.78' x='10402.78' showverticalline='0'/>
<category label='10607.78' x='10607.78' showverticalline='0'/>
<category label='11052.78' x='11052.78' showverticalline='0'/>
<category label='11267.78' x='11267.78' showverticalline='0'/>
<category label='11797.78' x='11797.78' showverticalline='0'/>
<category label='12307.78' x='12307.78' showverticalline='0'/>
<category label='12572.78' x='12572.78' showverticalline='0'/>
<category label='13229.78' x='13229.78' showverticalline='0'/>
<category label='13369.78' x='13369.78' showverticalline='0'/>
</categories>
<dataset drawline= '1' seriesname= 'Elevation' color= '#0045ff' anchorsides= '0' anchorradius= '0' anchorbgcolor= '#0045ff' anchorbordercolor= '#0045ff'>
<set y='321' x='0'/>
<set y='322' x='46.17'/>
<set y='322.54' x='142.98'/>
<set y='309.12' x='543.88'/>
<set y='292.63' x='826.58'/>
<set y='299.12' x='1037.93'/>
<set y='298.68' x='1106.1'/>
<set y='303.49' x='1338.1'/>
<set y='294.23' x='1838.5'/>
<set y='295.77' x='1889.37'/>
<set y='269.98' x='2538'/>
<set y='274.17' x='2789.04'/>
<set y='261.71' x='3154.34'/>
<set y='267.01' x='3345.17'/>
<set y='243.04' x='4220.75'/>
<set y='247.05' x='4671.9'/>
<set y='250.81' x='5057.74'/>
<set y='246.4' x='5318.51'/>
<set y='249.62' x='5576.18'/>
<set y='238.03' x='5958.13'/>
<set y='253.08' x='6537.92'/>
<set y='235.53' x='7282.09'/>
<set y='173.53' x='8178.84'/>
<set y='189.91' x='8511.22'/>
<set y='224.23' x='8989.59'/>
<set y='250' x='9442.78'/>
<set y='250' x='9862.78'/>
<set y='253.45' x='9942.78'/>
<set y='240' x='10402.78'/>
<set y='235' x='10607.78'/>
<set y='210' x='11052.78'/>
<set y='210' x='11267.78'/>
<set y='195' x='11797.78'/>
<set y='170' x='12307.78'/>
<set y='160' x='12572.78'/>
<set y='150' x='13229.78'/>
<set y='141.36' x='13369.78'/>
</dataset>
<dataset drawline= '1' seriesname= 'HGL' color= '#198500' anchorsides= '0' anchorradius= '0' anchorbgcolor= '#198500' anchorbordercolor= '#198500'>
<set y='321' x='0'/>
<set y='320.87' x='46.17'/>
<set y='320.59' x='142.98'/>
<set y='319.46' x='543.88'/>
<set y='318.66' x='826.58'/>
<set y='318.06' x='1037.93'/>
<set y='317.87' x='1106.1'/>
<set y='317.22' x='1338.1'/>
<set y='315.81' x='1838.5'/>
<set y='315.67' x='1889.37'/>
<set y='313.84' x='2538'/>
<set y='313.1' x='2789.04'/>
<set y='312.02' x='3154.34'/>
<set y='311.38' x='3345.17'/>
<set y='308.46' x='4220.75'/>
<set y='306.96' x='4671.9'/>
<set y='305.68' x='5057.74'/>
<set y='304.81' x='5318.51'/>
<set y='303.95' x='5576.18'/>
<set y='302.68' x='5958.13'/>
<set y='300.75' x='6537.92'/>
<set y='298.27' x='7282.09'/>
<set y='294.88' x='8178.84'/>
<set y='293.39' x='8511.22'/>
<set y='291.25' x='8989.59'/>
<set y='285.78' x='9442.78'/>
<set y='281.31' x='9862.78'/>
<set y='280.46' x='9942.78'/>
<set y='275.55' x='10402.78'/>
<set y='273.37' x='10607.78'/>
<set y='256.15' x='11052.78'/>
<set y='247.84' x='11267.78'/>
<set y='227.36' x='11797.78'/>
<set y='204.03' x='12307.78'/>
<set y='191.92' x='12572.78'/>
<set y='156.49' x='13229.78'/>
<set y='148.94' x='13369.78'/>
</dataset>
<dataset drawline= '0' seriesname= 'Peak' color= '#ff0000' anchorsides= '3' anchorradius= '5' anchorbgcolor= '#ff0000' anchorbordercolor= '#ff0000'>
<set y='321' x='0'/>
<set y='322.54' x='142.98'/>
<set y='299.12' x='1037.93'/>
<set y='303.49' x='1338.1'/>
<set y='295.77' x='1889.37'/>
<set y='274.17' x='2789.04'/>
<set y='267.01' x='3345.17'/>
<set y='250.81' x='5057.74'/>
<set y='249.62' x='5576.18'/>
<set y='253.08' x='6537.92'/>
<set y='253.45' x='9942.78'/>
<set y='141.36' x='13369.78'/>
</dataset>
<dataset drawline= '0' seriesname= 'Valve - Change' color= '#198500' anchorsides= '4' anchorradius= '5' anchorbgcolor= '#198500' anchorbordercolor= '#198500'>
<set y='309.12' x='543.88'/>
<set y='235.53' x='7282.09'/>
<set y='235' x='10607.78'/>
<set y='195' x='11797.78'/>
<set y='150' x='13229.78'/>
</dataset>
<dataset drawline= '0' seriesname= 'Valve suggest - Long Node' color= '#fdff00' anchorsides= '4' anchorradius= '3' anchorbgcolor= '#fdff00' anchorbordercolor= '#fdff00'>
<set y='321' x='0'/>
<set y='309.12' x='543.88'/>
<set y='294.23' x='1838.5'/>
<set y='269.98' x='2538'/>
<set y='261.71' x='3154.34'/>
<set y='243.04' x='4220.75'/>
<set y='247.05' x='4671.9'/>
<set y='250.81' x='5057.74'/>
<set y='238.03' x='5958.13'/>
<set y='253.08' x='6537.92'/>
<set y='235.53' x='7282.09'/>
<set y='173.53' x='8178.84'/>
<set y='189.91' x='8511.22'/>
<set y='224.23' x='8989.59'/>
<set y='250' x='9442.78'/>
<set y='250' x='9862.78'/>
<set y='240' x='10402.78'/>
<set y='210' x='11052.78'/>
<set y='195' x='11797.78'/>
<set y='170' x='12307.78'/>
<set y='150' x='13229.78'/>
</dataset>
</chart>
</body>
</html>
I specifically want to do it in iTextSharp as I have other exports that im doing that is also using iTextSharp and ultimately want to combine everything into one PDF.
I would appreciate anyones help. Thanks.

Related

XML read and getting values

How can I get a this: val="icon.weapon_small_sword_i00"/> from XML file by giving a itemId. I managed to do something like this but besides of choosing right itemId from file I dont know how to get the value I mentioned above.
Thats a code I have:
int ItemId = 15;
XmlTextReader reader = new XmlTextReader(#"D:\L2Eq\xml\items");
XmlNodeType type;
while (reader.Read())
{
type = reader.NodeType;
if (type == XmlNodeType.Element)
{
if (reader.Name == "item")
{
if (Int32.Parse(reader.GetAttribute(0)) == ItemId)
{
Console.WriteLine(reader.GetAttribute(0));
}
}
}
}
And thats how XML file looks like:
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="items.xsd">
<item id="1" type="Weapon" name="Short Sword">
<set name="icon" val="icon.weapon_small_sword_i00" />
<set name="default_action" val="equip" />
<set name="weapon_type" val="sword" />
<set name="bodypart" val="rhand" />
<set name="random_damage" val="10" />
<set name="attack_range" val="40" />
<for>
<set order="0x08" stat="pAtk" val="8" />
<set order="0x08" stat="mAtk" val="6" />
<set order="0x08" stat="rCrit" val="8" />
<set order="0x08" stat="pAtkSpd" val="379" />
</for>
</item>
<item id="2" type="Weapon" name="Long Sword">
<set name="icon" val="icon.weapon_long_sword_i00" />
<set name="default_action" val="equip" />
<set name="weapon_type" val="sword" />
<set name="bodypart" val="rhand" />
<set name="random_damage" val="10" />
<set name="attack_range" val="40" />
<for>
<set order="0x08" stat="pAtk" val="24" />
<set order="0x08" stat="mAtk" val="17" />
<set order="0x08" stat="rCrit" val="8" />
<set order="0x08" stat="pAtkSpd" val="379" />
</for>
</item>
</list>
XmlTextReader is a very clumsy way to deal with XML; I'd never use it. The old System.Xml.XmlDocument API is a much better choice:
var findID = "1";
string iconValue = null;
var xdoc = new System.Xml.XmlDocument();
xdoc.Load(#"D:\L2Eq\xml\items");
iconValue = xdoc.SelectSingleNode("/list/item[#id=" + findID + "]/set[#name='icon']/#val")?.Value;
Or you could use the shiny new LINQ to XML classes:
var doc = XDocument.Load(#"D:\L2Eq\xml\items");
iconValue = doc.Descendants("item")
.Where(d => d.Attribute("id")?.Value == findID)
.Descendants("set")
.Where(x => x.Attribute("name")?.Value == "icon")
.FirstOrDefault()?.Attribute("val")?.Value;

Error in the document XML (2, 454) tryind to convert object to xml

I´m trying get data from a Web Service using c# my procedure is convert the object to a XML like this
private void btnLecturaBLur_Click(object sender, EventArgs e)
{
//get the web service method
recibodlxService service = new recibodlxService();
// Convert the Xml from object
string sXml = GetXMLFromObject(service.Controlrecibo());
this is how i get the XML from an Object..
public static string GetXMLFromObject(object o)
{
StringWriter sw = new StringWriter();
XmlTextWriter tw = null;
try
{
XmlSerializer serializer = new XmlSerializer(o.GetType());
tw = new XmlTextWriter(sw);
serializer.Serialize(tw, o);
}
catch (Exception ex)
{
//Handle Exception Code
}
finally
{
sw.Close();
if (tw != null)
{
tw.Close();
}
}
return sw.ToString();
}
and this is the XML from the web service
<SOAP-ENV:Envelope SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://blutest.blulogistics.net/LFA/confirmRcv3.php"
xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:ControlreciboResponse>
<return SOAP-ENC:arrayType="ns2:Map[6]" xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">OCN</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">39147</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">codigo</key>
<value xsi:type="xsd:string">17429</value>
</item>
<item>
<key xsi:type="xsd:string">Cantidad</key>
<value xsi:type="xsd:int">12</value>
</item>
<item>
<key xsi:type="xsd:string">Estatus</key>
<value xsi:type="xsd:string">Disponible</value>
</item>
</value>
</item>
</value>
</item>
</item>
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">OCN</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">39147</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">codigo</key>
<value xsi:type="xsd:string">32757</value>
</item>
<item>
<key xsi:type="xsd:string">Cantidad</key>
<value xsi:type="xsd:int">13</value>
</item>
<item>
<key xsi:type="xsd:string">Estatus</key>
<value xsi:type="xsd:string">Disponible</value>
</item>
</value>
</item>
</value>
</item>
</item>
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">OCN</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">39147</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">codigo</key>
<value xsi:type="xsd:string">48156</value>
</item>
<item>
<key xsi:type="xsd:string">Cantidad</key>
<value xsi:type="xsd:int">6</value>
</item>
<item>
<key xsi:type="xsd:string">Estatus</key>
<value xsi:type="xsd:string">Disponible</value>
</item>
</value>
</item>
</value>
</item>
</item>
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">OCN</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">39147</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">codigo</key>
<value xsi:type="xsd:string">52314</value>
</item>
<item>
<key xsi:type="xsd:string">Cantidad</key>
<value xsi:type="xsd:int">7</value>
</item>
<item>
<key xsi:type="xsd:string">Estatus</key>
<value xsi:type="xsd:string">Disponible</value>
</item>
</value>
</item>
</value>
</item>
</item>
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">OCN</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">39147</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">codigo</key>
<value xsi:type="xsd:string">55327</value>
</item>
<item>
<key xsi:type="xsd:string">Cantidad</key>
<value xsi:type="xsd:int">10</value>
</item>
<item>
<key xsi:type="xsd:string">Estatus</key>
<value xsi:type="xsd:string">Disponible</value>
</item>
</value>
</item>
</value>
</item>
</item>
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">OCN</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:int">39147</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">codigo</key>
<value xsi:type="xsd:string">57813</value>
</item>
<item>
<key xsi:type="xsd:string">Cantidad</key>
<value xsi:type="xsd:int">6</value>
</item>
<item>
<key xsi:type="xsd:string">Estatus</key>
<value xsi:type="xsd:string">Disponible</value>
</item>
</value>
</item>
</value>
</item>
</item>
</return>
</ns1:ControlreciboResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
the error that is shows me is Error in the document XML (2, 454)

c# parsing xml again with XDocument

I have looked at a lot of help files and a lot of similar questions to mine but I am not able to get further than returning the descendant collection.
What I want to achieve is to get an array that contains the values of all the id attributes of the tag elements that have ph or bpt children (not those that have st) in the XPath of xliff\file\header\tag-defs
Here is the xml. I stripped out other tags and it is truncated after the header element, for simplicity:
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns:sdl="http://sdl.com/FileTypes/SdlXliff/1.0" version="1.2" sdl:version="1.0" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="\\txl-app1\scncontent\AUDIO\en\Testing\SubtitleXML-FTS\13Mar16_Game.xml" source-language="en-US" datatype="x-sdlfilterframework2" target-language="da-DK">
<header>
<reference>
<internal-file form="base64"></internal-file>
</reference>
<sdl:ref-files>
<sdl:ref-file uid="0" id="http://www.sdl.com/Sdl.FileTypeSupport.Native.Xml/OriginalXmlFile" name="DF44_13Mar16_Speech_BirthdayGame.xml" o-path="\\txl-app1\scncontent\AUDIO\en\Testing\SubtitleXML-FTS\13Mar16_Speech_BirthdayGame.xml" date="04/25/2016 18:55:53" descr="The original XML file." expected-use="Generation" />
</sdl:ref-files>
<file-info xmlns="http://sdl.com/FileTypes/SdlXliff/1.0">
<value key="SDL:FileId">c6550fcb-8e69-428a-a0a8-6447918a97a2</value>
<value key="SDL:CreationDate">04/25/2016 16:16:55</value>
<value key="SDL:OriginalFilePath">\\txl-app1\content\Testing\SubtitleXML-FTS\13Mar16_Game.xml</value>
<value key="SDL:InputFilePath">\\txl-app1\content\en\Testing\SubtitleXML-FTS\13Mar16_Game.xml</value>
<value key="SDL:OriginalEncoding">utf-8</value>
<value key="HasUtf8Bom">true</value>
<value key="IsFragment">false</value>
<value key="SchemaLocation"></value>
<value key="SDL:AutoClonedFlagSupported">True</value>
<value key="xmlDeclaration">true</value>
<value key="SDLWS:AssetId">1489743</value>
<value key="SDLWS:DocId">3043144</value>
<value key="SDLWS:TaskId">1382715</value>
<value key="SDLWS:ScopingMode">0</value>
<value key="SDLWS:CreationDate">2016-04-26T00:16:55Z</value>
<value key="SDLWS:ProjectName">SubtitleXML-FTS_da_DK_20160425_111419</value>
<value key="SDLWS:UserName">BI</value>
<value key="ParagraphTextDirections"></value>
<sniff-info>
<detected-encoding detection-level="Certain" encoding="utf-8" />
<detected-source-lang detection-level="Guess" lang="en-US" />
<props>
<value key="HasUtf8Bom">true</value>
<value key="IsFragment">false</value>
<value key="SchemaLocation"></value>
<value key="xmlDeclaration">true</value>
</props>
</sniff-info>
</file-info>
<sdl:filetype-info>
<sdl:filetype-id>Custom XML v 1.2.0.0 (WS:SubtitleXML-FTS)</sdl:filetype-id>
</sdl:filetype-info>
<fmt-defs xmlns="http://sdl.com/FileTypes/SdlXliff/1.0">
<fmt-def id="1">
<value key="Italic">True</value>
<value key="TextColor">Black</value>
</fmt-def>
</fmt-defs>
<tag-defs xmlns="http://sdl.com/FileTypes/SdlXliff/1.0">
<tag id="7">
<bpt name="i" seg-hint="Include" word-end="false"><i></bpt>
<ept name="i" word-end="false"></i></ept>
<fmt id="1" />
</tag>
<tag id="3">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:00:08 01:05:04:26" WidthAllowed="75"/></ph>
</tag>
<tag id="4">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:05:00 01:05:08:24" WidthAllowed="60"/></ph>
</tag>
<tag id="5">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:08:28 01:05:13:04" WidthAllowed="60"/></ph>
</tag>
<tag id="6">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:13:08 01:05:17:22" WidthAllowed="60"/></ph>
</tag>
<tag id="8">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:17:26 01:05:22:11" WidthAllowed="60"/></ph>
</tag>
<tag id="9">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:21:21 01:05:27:13" WidthAllowed="90"/></ph>
</tag>
<tag id="10">
<ph name="Sub" seg-hint="Include"><Sub tc="01:05:27:17 01:05:33:02" WidthAllowed="75"/></ph>
</tag>
<tag id="13">
<ph name="zwnj" word-end="false" seg-hint="Include"><zwnj dir="1" spc="20"/></ph>
</tag>
<tag id="16">
<ph name="Sub" seg-hint="Include"><Sub tc="01:41:20:04 01:41:21:24" WidthAllowed="30"/></ph>
</tag>
<tag id="0">
<st><XMLsubtitlefile"></st>
</tag>
<tag id="1">
<st><Subtitles></st>
</tag>
<tag id="2">
<st><NonVOsubs></st>
</tag>
<tag id="11">
<st></NonVOsubs></st>
</tag>
<tag id="12">
<st><VOsub tc="01:41:01:17 01:41:09:27" WidthAllowed="120"></st>
</tag>
<tag id="14">
<st></VOsub></st>
</tag>
<tag id="15">
<st><NonVOsubs></st>
</tag>
<tag id="17">
<st></NonVOsubs></st>
</tag>
<tag id="18">
<st></Subtitles></st>
</tag>
<tag id="19">
<st></XMLsubtitlefile></st>
</tag>
</tag-defs>
</header>
<body>...
Code-wise I tried different versions, but this is where I am at:
private static XDocument xliff;
public static List<XElement> GetTagArray(string FilePath)
{
xliff = XDocument.Load(Path.GetFullPath(FilePath));
XNamespace ns = "http://sdl.com/FileTypes/SdlXliff/1.0";
var elements = xliff.Descendants().Elements(ns + "tag-defs").Elements().Select(e => e.Elements(ns + "ph")).ToList();
//and here I am stuck as not matter what I do above it returns empty...
}
Thank you for any help in advance.
Untested code, but try something like the following:
XNamespace sdl = #"http://sdl.com/FileTypes/SdlXliff/1.0";
XNamespace ns = #"urn:oasis:names:tc:xliff:document:1.2";
foreach (var tag in xliff.Descendants(sdl + "tag"))
{
foreach (var ph in tag.Elements(sdl + "ph"))
{
// Code here to process
}
}
The solution with help from Jesse Good is:
private static XDocument xliff;
public static int[] GetTagArray(string FilePath)
{
xliff = XDocument.Load(Path.GetFullPath(FilePath));
XNamespace ns = "http://sdl.com/FileTypes/SdlXliff/1.0";
int[] elements = xliff.Descendants().Elements(ns + "tag-defs").Elements(ns + "tag").Elements(ns + "ph").Select(e => Int32.Parse(e.Parent.Attribute("id").Value)).ToArray();
int[] elements2 = xliff.Descendants().Elements(ns + "tag-defs").Elements(ns + "tag").Elements(ns + "bpt").Select(e => Int32.Parse(e.Parent.Attribute("id").Value)).ToArray();
int[] intarray = elements.Concat(elements2).ToArray();
Array.Sort(intarray);
return intarray;
}

How to draw multi-series column chart in FusionCharts

I am developing a web application using asp.net c# and drawing graphs using FusionCharts. I need to draw a multi-series column chart for which i tries the following code, but in vain
<div id="chartContainer"></div>
<script type="text/javascript">
var myChart = new FusionCharts("Column3D", "myChartId", "400", "300");
myChart.setXMLUrl("Data8.xml");
myChart.render("chartContainer");
</script>
Data8.xml
----------
<chart caption='Sales by Product' numberPrefix='$' formatNumberScale='1' rotateValues='1' placeValuesInside='1' decimals='0' ><categories>
<category label='Product A' />
<category label='Product B' />
<category label='Product C' />
<category label='Product D' />
<category label='Product E' />
<category label='Product F' />
</categories><dataset seriesName='Current Year'>
<set value='567500' />
<set value='815300' />
<set value='556800' />
<set value='734500' />
<set value='676800' />
<set value='648500' />
</dataset><dataset seriesName='Previous Year'>
<set value='547300' />
<set value='584500' />
<set value='754000' />
<set value='456300' />
<set value='754500' />
<set value='437600' />
</dataset></chart>
Please help me to do this...
Try to modify:
var myChart = new FusionCharts("Column3D", "myChartId", "400", "300");
With:
var myChart = new FusionCharts("MSColumn3D", "myChartId", "400", "300");
Column3D is for a single serie, and MSColumn3D is for Multi-series.

How to add "BDC Wildcard Filter" to the ReadList method

Good Morning :)
Situtation: In SP2010, I've a customer list with a external data field. In the solution I have a BDC Model with an entity which contains a "ReadItem" and a "ReadList" method. When I deploy my feature and set the object permissions, I can read the Item without troubles. Now i have to search an item. I follow this instructions to create a Filter: http://msdn.microsoft.com/en-us/library/ee471425.aspx but it doesn't work, because I have always the same value in my parameter ("**") ..
Question:
1. How can I assign the search input to the parameter?
2. Is something other wrong?
Code
public IEnumerable<Oppertunity> ReadList(String inputParameter)
{
using (CRMDataClassesDataContext db = new CRMDataClassesDataContext("server=xxx;database=xxx; uid=xxx ;pwd=xxx"))
{
List<Oppertunity> oppertunities = new List<Oppertunity>();
var q = from c in db.Opportunities
where c.Name.Contains(inputParameter)
orderby c.Name ascending
select new Oppertunity
{
OppertunityId = c.OpportunityId,
Name = c.Name,
};
foreach (var o in q)
{
Oppertunity oppertunity = new Oppertunity();
oppertunity.OppertunityId = o.OppertunityId;
oppertunity.Name = o.Name;
oppertunities.Add(oppertunity);
}
}
return oppertunities;
}
The BDC part looks like the instructions of msdn:
<?xml version="1.0" encoding="utf-8"?>
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog" Name="BdcModel1">
<LobSystems>
<LobSystem Name="BdcModel1" Type="DotNetAssembly">
<LobSystemInstances>
<LobSystemInstance Name="BdcModel1" />
</LobSystemInstances>
<Entities>
<Properties>
<Property Name="Class" Type="System.String">NX.Intra.Bcs.BdcModel1.ContactService, BdcModel1</Property>
</Properties>
<Identifiers>
<Identifier Name="ContactId" TypeName="System.Guid" />
</Identifiers>
<Methods>
<Method Name="ReadList">
<Parameters>
<Parameter Name="returnParameter" Direction="Return">
<TypeDescriptor Name="ContactList" TypeName="System.Collections.Generic.IEnumerable`1[[NX.Intra.Bcs.BdcModel1.Contact, BdcModel1]]" IsCollection="true">
<TypeDescriptors>
<TypeDescriptor Name="Contact" TypeName="NX.Intra.Bcs.BdcModel1.Contact, BdcModel1">
<TypeDescriptors>
<TypeDescriptor Name="ContactId" TypeName="System.Guid" IdentifierName="ContactId" IsCollection="false" ReadOnly="true">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">false</Property>
</Properties></TypeDescriptor>
<TypeDescriptor Name="FirstName" TypeName="System.String">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>
<TypeDescriptor Name="LastName" TypeName="System.String">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>
<TypeDescriptor Name="AccountIdName" TypeName="System.String">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>
<TypeDescriptor Name="FullName" TypeName="System.String">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">false</Property>
</Properties>
</TypeDescriptor></TypeDescriptors></TypeDescriptor></TypeDescriptors></TypeDescriptor></Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Name="ReadList" Type="Finder" Default="true" DefaultDisplayName="Read List" ReturnParameterName="returnParameter" />
</MethodInstances></Method>
<Method Name="ReadItem">
<Parameters>
<Parameter Name="returnParameter" Direction="Return">
<TypeDescriptor Name="Contact" TypeName="NX.Intra.Bcs.BdcModel1.Contact, BdcModel1">
<TypeDescriptors>
<TypeDescriptor Name="ContactId" TypeName="System.Guid" IsCollection="false" IdentifierName="ContactId" />
<TypeDescriptor Name="LastName" TypeName="System.String" />
<TypeDescriptor Name="FirstName" TypeName="System.String" />
<TypeDescriptor Name="AccountIdName" TypeName="System.String" />
<TypeDescriptor Name="FullName" TypeName="System.String" /></TypeDescriptors>
</TypeDescriptor>
</Parameter>
<Parameter Name="id" Direction="In">
<TypeDescriptor Name="ContactId" TypeName="System.Guid" IdentifierName="ContactId" IsCollection="false" /></Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Name="ReadItem" Type="SpecificFinder" Default="true" DefaultDisplayName="Read Item" ReturnParameterName="returnParameter" />
</MethodInstances>
</Method>
</Methods></Entity>
<Entity Name="Oppertunity" Namespace="NX.Intra.Bcs.BdcModel1" Version="1.0.0.144">
<Properties>
<Property Name="Class" Type="System.String">NX.Intra.Bcs.BdcModel1.Oppertunity, BdcModel1</Property>
<Property Name="Title" Type="System.String">FirstName</Property>
</Properties>
<Identifiers>
<Identifier Name="OppertunityId" TypeName="System.Guid" />
</Identifiers>
<Methods>
<Method Name="ReadList" IsStatic="false">
<FilterDescriptors>
<FilterDescriptor Name="OppertunityNameFilter" Type="Wildcard" DefaultDisplayName="Suche nach Name" FilterField="Name">
<Properties>
<Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>
</Properties>
</FilterDescriptor>
</FilterDescriptors>
<Parameters>
<Parameter Name="returnParameter" Direction="Return">
<TypeDescriptor Name="OppertunityList" TypeName="System.Collections.Generic.IEnumerable`1[[NX.Intra.Bcs.BdcModel1.Oppertunity, BdcModel1]]" IsCollection="true">
<TypeDescriptors>
<TypeDescriptor Name="Oppertunity" TypeName="NX.Intra.Bcs.BdcModel1.Oppertunity, BdcModel1">
<TypeDescriptors>
<TypeDescriptor Name="OppertunityId" TypeName="System.Guid" IsCollection="false" IdentifierName="OppertunityId">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">false</Property>
</Properties></TypeDescriptor>
<TypeDescriptor Name="Name" TypeName="System.String">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">true</Property>
</Properties></TypeDescriptor></TypeDescriptors></TypeDescriptor></TypeDescriptors></TypeDescriptor></Parameter>
<Parameter Name="inputParameter" Direction="In">
<TypeDescriptor Name="OppertunityFinderTD" TypeName="System.String" AssociatedFilter="OppertunityNameFilter">
<TypeDescriptors>
<TypeDescriptor Name="Oppertunity" TypeName="NX.Intra.Bcs.BdcModel1.Oppertunity, BdcModel1">
<TypeDescriptors>
<TypeDescriptor Name="OppertunityId" TypeName="System.Guid" IdentifierName="OppertunityId" IsCollection="false">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">false</Property>
</Properties></TypeDescriptor>
<TypeDescriptor Name="Name" TypeName="System.String">
<Properties>
<Property Name="ShowInPicker" Type="System.Boolean">true</Property>
</Properties></TypeDescriptor></TypeDescriptors></TypeDescriptor></TypeDescriptors></TypeDescriptor></Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Name="ReadList" Type="Finder" ReturnParameterName="returnParameter" Default="true" DefaultDisplayName="Read List">
<Properties>
<Property Name="UseClientCachingForSearch" Type="System.String"></Property>
<Property Name="RootFinder" Type="System.String"></Property>
</Properties></MethodInstance>
</MethodInstances></Method>
<Method Name="ReadItem">
<Parameters>
<Parameter Name="returnParameter" Direction="Return">
<TypeDescriptor Name="Oppertunity" TypeName="NX.Intra.Bcs.BdcModel1.Oppertunity, BdcModel1">
<TypeDescriptors>
<TypeDescriptor Name="OppertunityId" TypeName="System.Guid" IdentifierName="OppertunityId" IsCollection="false" />
<TypeDescriptor Name="Name" TypeName="System.String" /></TypeDescriptors></TypeDescriptor>
</Parameter>
<Parameter Name="id" Direction="In">
<TypeDescriptor Name="OppertunityId" TypeName="System.Guid" IdentifierName="OppertunityId" IsCollection="false" /></Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Name="ReadItemList" Type="SpecificFinder" ReturnParameterName="returnParameter" Default="true" DefaultDisplayName="Read Item" />
</MethodInstances></Method>
</Methods></Entity>
</Entities>
</LobSystem>
</LobSystems>
</Model>
Ususally when you use an external list, you can configure value for your filter parameter by editing the default view of a list (or creating new view).
Hope this will help ;-)

Categories