public static System.Xml.XmlDocument SetInfopathForm( System.Xml.XmlDocument part, string InfopathFormUrl) { // Delete existing processing instructions. foreach (System.Xml.XmlNode pi in part.SelectNodes( "processing-instruction()")) { pi.ParentNode.RemoveChild(pi); } // Add an xml declaration System.Xml.XmlDeclaration decl = part.CreateXmlDeclaration("1.0", null, null); part.InsertBefore(decl, part.DocumentElement); // Create the mso-application procesing instruction. System.Xml.XmlProcessingInstruction progid = part.CreateProcessingInstruction( "mso-application", "progid='InfoPath.Document'"); part.InsertBefore(progid, part.DocumentElement); // Create the mso-infoPathSolution processing instruction System.Xml.XmlProcessingInstruction form = part.CreateProcessingInstruction( "mso-infoPathSolution", "PIVersion='1.0.0.0' href='" + InfopathFormUrl + "'"); part.InsertBefore(form, part.DocumentElement); return(part); }
private static double MSXMLapproach(int numberOfElements, int numerOfAttributes, List <string> elemetNames, List <string> attributeNames, List <string> attributeValues) { DateTime now = DateTime.Now; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration header = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); System.Xml.XmlElement root = doc.DocumentElement; doc.InsertBefore(header, root); System.Xml.XmlElement rootElement = doc.CreateElement(string.Empty, "root", string.Empty); doc.AppendChild(rootElement); for (int i = 0; i < numberOfElements; i++) { System.Xml.XmlElement element = doc.CreateElement(string.Empty, elemetNames[i], string.Empty); for (int j = 0; j < numerOfAttributes; j++) { //element.SetAttribute(attributeNameTemplate + j, attributeValueTemplate); element.SetAttribute(attributeNames[j], attributeValues[j]); } rootElement.AppendChild(element); } string output = doc.OuterXml; TimeSpan t = DateTime.Now - now; return(t.TotalMilliseconds); }
Stream(System.Xml.XmlDeclaration decl) { m_dataObjs.Add(new Snoop.Data.ClassSeparator(typeof(System.Xml.XmlDeclaration))); m_dataObjs.Add(new Snoop.Data.String("Encoding", decl.Encoding)); m_dataObjs.Add(new Snoop.Data.String("Standalone", decl.Standalone)); m_dataObjs.Add(new Snoop.Data.String("Version", decl.Version)); }
/// <summary> /// Convertit un XmlNode en Linq To Xml /// </summary> /// <param name="oXmlNode"></param> /// <returns></returns> private string GetLinqToXml(System.Xml.XmlNode oXmlNode) { string result = string.Empty; // string LinqToXmlGenerated = string.Empty; if (!Options.IncludeLinqCompletePathNamespace) { LinqNamespace = string.Empty; } else { LinqNamespace = "System.Xml.Linq."; } currentNamespacePrefix = string.Empty; switch (oXmlNode.NodeType) { case System.Xml.XmlNodeType.Document: System.Xml.XmlDeclaration oXmlDeclaration = (System.Xml.XmlDeclaration)oXmlNode.FirstChild; result += LinqNamespace + "XDocument oXDocument = new " + LinqNamespace + "XDocument(new " + LinqNamespace + "XDeclaration(\"" + oXmlDeclaration.Version + "\",\"" + oXmlDeclaration.Encoding + "\",\"" + oXmlDeclaration.Standalone + "\"));\r"; break; case System.Xml.XmlNodeType.ProcessingInstruction: System.Xml.XmlProcessingInstruction oXmlProcessingInstruction = (System.Xml.XmlProcessingInstruction)oXmlNode; result += LinqNamespace + "XProcessingInstruction oXProcessingInstruction = new " + LinqNamespace + "XProcessingInstruction(\"" + oXmlProcessingInstruction.Name + "\", \"" + oXmlProcessingInstruction.Value + "\");\r"; break; case System.Xml.XmlNodeType.Comment: result += LinqNamespace + "XComment oXComment = new " + LinqNamespace + "XComment(\"" + oXmlNode.Value + "\");\r"; break; case System.Xml.XmlNodeType.Element: int nCount = 1; foreach (string Key in Namespaces.Keys) { result += LinqNamespace + "XNamespace " + Namespaces[Key] + " = \"" + Key + "\";" + Environment.NewLine; nCount += 1; } result += LinqNamespace + "XElement oXElement = \r"; result += BuildElement(oXmlNode, "\t\t\t"); result += "\r\t\t\t);\r"; break; case System.Xml.XmlNodeType.Attribute: result += LinqNamespace + "XAttribute oXAttribute = new " + LinqNamespace + "XAttribute(\"" + oXmlNode.Name + "\",\"" + oXmlNode.Value + "\");\r"; break; case System.Xml.XmlNodeType.Text: result += LinqNamespace + "XText oXText = new " + LinqNamespace + "XText(\"" + oXmlNode.Value + "\");\r"; break; } return(result); }
public static System.Xml.XmlDocument CreateNewDoc() { System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration xmlDeclaration = default(System.Xml.XmlDeclaration); xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); xmlDoc.AppendChild(xmlDeclaration); return(xmlDoc); }
/// <summary>prepare internal XmlDocument with basic Document-Root</summary> private void _initializeXML() { System.Xml.XmlDocument _tmpdoc = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration _tmpdec = _tmpdoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); System.Xml.XmlElement _tmproot = _tmpdoc.CreateElement("UserSettings"); _tmpdoc.AppendChild(_tmpdec); _tmpdoc.AppendChild(_tmproot); _intXml = _tmpdoc; }
public Xml(string rootName) { _xml = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration dec = _xml.CreateXmlDeclaration("1.0", null, null); _xml.AppendChild(dec); _root = _xml.CreateElement(rootName); _xml.AppendChild(_root); }
private System.Xml.XmlDocument XmlEmptyDocument() { System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", String.Empty); xmlDocument.InsertBefore(xmlDeclaration, xmlDocument.DocumentElement); return(xmlDocument); }
public VXmlHeader(VXmlDocument doc, System.Xml.XmlNode header) : this(doc) { if (header.NodeType == System.Xml.XmlNodeType.XmlDeclaration) { System.Xml.XmlDeclaration dec = header as System.Xml.XmlDeclaration; Version = dec.Version; Encoding = dec.Encoding; Standalone = dec.Standalone; CreateTextLine(); } }
Stream(System.Xml.XmlLinkedNode lnkNode) { m_dataObjs.Add(new Snoop.Data.ClassSeparator(typeof(System.Xml.XmlLinkedNode))); // No data to show at this level, but we want to explicitly // show that there is an intermediate class. System.Xml.XmlElement elem = lnkNode as System.Xml.XmlElement; if (elem != null) { Stream(elem); return; } System.Xml.XmlCharacterData charData = lnkNode as System.Xml.XmlCharacterData; if (charData != null) { Stream(charData); return; } System.Xml.XmlDeclaration decl = lnkNode as System.Xml.XmlDeclaration; if (decl != null) { Stream(decl); return; } System.Xml.XmlDocumentType dType = lnkNode as System.Xml.XmlDocumentType; if (dType != null) { Stream(dType); return; } System.Xml.XmlEntityReference entRef = lnkNode as System.Xml.XmlEntityReference; if (entRef != null) { Stream(entRef); return; } System.Xml.XmlProcessingInstruction pi = lnkNode as System.Xml.XmlProcessingInstruction; if (pi != null) { Stream(pi); return; } }
public static bool _CreateXmlDeclaration_System_Configuration_ConfigXmlDocument_System_String_System_String_System_String( ) { //Parameters System.String version = null; System.String encoding = null; System.String standalone = null; //ReturnType/Value System.Xml.XmlDeclaration returnVal_Real = null; System.Xml.XmlDeclaration returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.Configuration.ConfigXmlDocument.CreateXmlDeclaration(version, encoding, standalone); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.Configuration.ConfigXmlDocument.CreateXmlDeclaration(version, encoding, standalone); } catch (Exception e) { exception_Intercepted = e; } Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted)); }
/// <include file='doc\IFormatter.uex' path='docs/doc[@for="IFormatter.Serialize"]/*' /> public void Serialize(Stream serializationStream, Object graph) { AccuDataObjectFormatter = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration Declaration = AccuDataObjectFormatter.CreateXmlDeclaration("1.0", "", ""); System.Xml.XmlElement Element = AccuDataObjectFormatter.CreateElement("NewDataSet"); if (graph != null) { if (graph.GetType().Equals(typeof(System.String))) { Element.InnerText = graph.ToString(); } else if (graph.GetType().GetInterface("IEnumerable") != null) { Serialize(Element, graph); } else if (graph.GetType().IsArray) { Serialize(Element, graph); } else if (graph.GetType().IsClass) { Serialize(Element, graph); } else if (graph.GetType().IsPrimitive) { Element.InnerText = graph.ToString(); } else if (graph.GetType().IsValueType) { System.Xml.XmlElement ValueType = AccuDataObjectFormatter.CreateElement(graph.GetType().Name); Element.AppendChild(ValueType); } } AccuDataObjectFormatter.AppendChild(Declaration); AccuDataObjectFormatter.AppendChild(Element); System.IO.StreamWriter writer = new StreamWriter(serializationStream); writer.Write(AccuDataObjectFormatter.OuterXml); writer.Flush(); writer.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); }
internal PropertySet PsFromXml(string Xml) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(Xml); //System.Xml.XmlTextReader r =new System.Xml.XmlTextReader(Xml, PropertySet ps = new PropertySet(); //ps.PsValue = Xml; //System.Xml.XmlWriter w = System.Xml.XmlWriter.Create( //System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //doc.LoadXml(Xml); System.Xml.XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "UTF-8", ""); doc.InsertBefore(decl, doc.DocumentElement); ps.PsValue = doc.OuterXml; /* ps.PsValue = @"<?xml version='1.0' encoding='UTF-16'?><?Siebel-Property-Set EscapeNames='true'?><AAA>aaa</AAA>"; * ps.PsValue = @"<?xml version='1.0' encoding='UTF-16'?><AAA>aaa</AAA>"; */ ps = InvokeMethod(m_mainBsName, m_FuncXml2PsName, ps).FunctionResult; return(ps); }
private double MSXMLapproach(int elementCounter, int attributeCounter, string elementNameTemplate, string attributeNameTemplate, string attributeValueTemplate) { DateTime now = DateTime.Now; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration header = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); System.Xml.XmlElement root = doc.DocumentElement; doc.InsertBefore(header, root); System.Xml.XmlElement rootElement = doc.CreateElement(string.Empty, "root", string.Empty); doc.AppendChild(rootElement); for (int i = 0; i < elementCounter; i++) { System.Xml.XmlElement element = doc.CreateElement(string.Empty, elementNameTemplate, string.Empty); for (int j = 0; j < attributeCounter; j++) { element.SetAttribute(attributeNameTemplate + j, attributeValueTemplate); } rootElement.AppendChild(element); } string output = doc.OuterXml; TimeSpan t = DateTime.Now - now; return(t.TotalMilliseconds); }
public static string CreateSitemap(long siteID, string serverRootPath) { try { var SiteList = Models.DataAccess.SitesDAO.GetDatas(); Models.SitesModels SitesInfo = Models.DataAccess.SitesDAO.GetInfo(siteID); string applicationPath = "/" + HttpContext.Current.Request.ApplicationPath.Trim('/').Trim('/'); string siteUrlRoot = GetItem.appSet("WebUrl").ToString() + applicationPath + "/w/" + SitesInfo.SN; string xmlName = GetSitemapFileName(siteID); System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration xmldec = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", ""); xmldoc.AppendChild(xmldec); System.Xml.XmlElement root = xmldoc.CreateElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); var menuList = Areas.Backend.Models.DataAccess.StatisticConditionDAO.GetMenuORPages(siteID, null); if (menuList != null && menuList.Count() > 0) { CreateNode(siteUrlRoot, siteID, xmldoc, ref root, menuList.ToList()); } //List<Models.MenusModels> Menus = Models.DataAccess.MenusDAO.GetFrontMenus(siteID); //var MenuU = Menus.Where(dr => dr.AreaID == 1).ToList(); //CreateMenu(siteUrlRoot, xmldoc, ref root, MenuU, MenuU.Where(m => m.ParentID == 0)); //var MenuM = Menus.Where(dr => dr.AreaID == 2).ToList(); //CreateMenu(siteUrlRoot, xmldoc, ref root, MenuM, MenuM.Where(m => m.ParentID == 0)); xmldoc.AppendChild(root); xmldoc.Save(string.Format("{0}\\{1}", serverRootPath, xmlName)); if (siteID == 1) { xmldoc.Save(string.Format("{0}\\sitemap.xml", serverRootPath)); } return(xmlName); } catch (Exception ex) { return(""); } }
public void AddDeclaration(System.Xml.XmlDeclaration oXmlDeclaration) { XmlDocument.AppendChild(oXmlDeclaration); }
private void DataExplorerNodeResultsGrid_ExportToExcel() { if (DataExplorerTreeView.CheckedNodes.Count == 0) { return; } Boolean usesEntityCurrentMailingAddress = false; Boolean usesEntityCurrentContactInformation = false; Boolean usesMemberCurrentEnrollment = false; Boolean usesMemberCurrentEnrollmentCoverage = false; Boolean usesMemberCurrentEnrollmentPcp = false; System.Xml.XmlElement styleElement; System.Xml.XmlElement fontElement; System.Xml.XmlElement column; System.Xml.XmlElement row; System.Xml.XmlElement cell; System.Xml.XmlElement cellData; Int32 columnIndex = 0; System.Xml.XmlDocument excelDocument = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration xmlDeclaration = excelDocument.CreateXmlDeclaration("1.0", "utf-8", String.Empty); excelDocument.InsertBefore(xmlDeclaration, excelDocument.DocumentElement); excelDocument.AppendChild(excelDocument.CreateProcessingInstruction("mso-application", "progid=\"Excel.Sheet\"")); #region Create Workbook and Worksheet and Styles System.Xml.XmlElement workbookElement = excelDocument.CreateElement("Workbook"); workbookElement.SetAttribute("xmlns", "urn:schemas-microsoft-com:office:spreadsheet"); workbookElement.SetAttribute("xmlns:o", "urn:schemas-microsoft-com:office:office"); workbookElement.SetAttribute("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet"); workbookElement.SetAttribute("xmlns:x", "urn:schemas-microsoft-com:office:excel"); excelDocument.AppendChild(workbookElement); System.Xml.XmlElement stylesCollectionElement = excelDocument.CreateElement("Styles"); workbookElement.AppendChild(stylesCollectionElement); styleElement = excelDocument.CreateElement("Style"); styleElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "ID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleNormal")); stylesCollectionElement.AppendChild(styleElement); fontElement = excelDocument.CreateElement("Font"); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "FontName", "urn:schemas-microsoft-com:office:spreadsheet", "Arial")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "x", "Family", "urn:schemas-microsoft-com:office:excel", "Swiss")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Size", "urn:schemas-microsoft-com:office:spreadsheet", "8")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Color", "urn:schemas-microsoft-com:office:spreadsheet", "#000000")); styleElement.AppendChild(fontElement); styleElement = excelDocument.CreateElement("Style"); styleElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "ID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleBold")); stylesCollectionElement.AppendChild(styleElement); fontElement = excelDocument.CreateElement("Font"); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "FontName", "urn:schemas-microsoft-com:office:spreadsheet", "Arial")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "x", "Family", "urn:schemas-microsoft-com:office:excel", "Swiss")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Size", "urn:schemas-microsoft-com:office:spreadsheet", "8")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Color", "urn:schemas-microsoft-com:office:spreadsheet", "#000000")); fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Bold", "urn:schemas-microsoft-com:office:spreadsheet", "1")); styleElement.AppendChild(fontElement); System.Xml.XmlElement worksheetElement = excelDocument.CreateElement("Worksheet"); worksheetElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Name", "urn:schemas-microsoft-com:office:spreadsheet", "Data")); workbookElement.AppendChild(worksheetElement); System.Xml.XmlElement worksheetTableElement = excelDocument.CreateElement("Table"); worksheetTableElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "StyleID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleNormal")); worksheetTableElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "DefaultRowHeight", "urn:schemas-microsoft-com:office:spreadsheet", "15")); worksheetElement.AppendChild(worksheetTableElement); #endregion #region Create Header Row System.Xml.XmlElement headerRow = excelDocument.CreateElement("Row"); columnIndex = 0; foreach (Telerik.Web.UI.RadTreeNode currentCheckedNode in DataExplorerTreeView.CheckedNodes) { columnIndex = columnIndex + 1; column = excelDocument.CreateElement("Column"); column.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Width", "urn:schemas-microsoft-com:office:spreadsheet", "100")); column.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "StyleID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleNormal")); worksheetTableElement.AppendChild(column); cell = excelDocument.CreateElement("Cell"); cell.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "StyleID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleBold")); cell.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Index", "urn:schemas-microsoft-com:office:spreadsheet", columnIndex.ToString())); headerRow.AppendChild(cell); cellData = excelDocument.CreateElement("Data"); cellData.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Type", "urn:schemas-microsoft-com:office:spreadsheet", "String")); cellData.InnerText = currentCheckedNode.Text; cell.AppendChild(cellData); usesEntityCurrentMailingAddress |= currentCheckedNode.Value.StartsWith("Entity.CurrentMailingAddress."); usesEntityCurrentContactInformation |= currentCheckedNode.Value.StartsWith("Entity.CurrentContactInformation"); usesMemberCurrentEnrollment |= currentCheckedNode.Value.StartsWith("CurrentEnrollment."); usesMemberCurrentEnrollmentCoverage |= currentCheckedNode.Value.StartsWith("CurrentEnrollmentCoverage"); usesMemberCurrentEnrollmentPcp |= currentCheckedNode.Value.StartsWith("CurrentEnrollmentPcp"); } worksheetTableElement.AppendChild(headerRow); #endregion #region Create Data Rows // RETREIVE LIST OF MEMBERS AND PRE-CACHE RELATED DATA List <Client.Core.Member.Member> members = MercuryApplication.DataExplorerNodeResultsGetForMember(NodeInstanceId, 1, NodeInstanceCount); List <Client.Core.Member.MemberEnrollment> allMemberEnrollments = null; List <Client.Core.Member.MemberEnrollmentCoverage> allMemberEnrollmentCoverages = null; List <Client.Core.Member.MemberEnrollmentPcp> allMemberEnrollmentPcps = null; // THESE ITEMS ARE AUTOMATICALLY CACHED AND AVAILABLE if (usesEntityCurrentMailingAddress) { MercuryApplication.DataExplorerNodeResultsGetForMemberEntityCurrentAddress(NodeInstanceId, 1, NodeInstanceCount); } if (usesEntityCurrentContactInformation) { MercuryApplication.DataExplorerNodeResultsGetForMemberEntityCurrentContactInformation(NodeInstanceId, 1, NodeInstanceCount); } // THESE ITEMS MUST BE STORED AND USED LOCALLY (COULD BE LARG RESULT SETS!) if ((usesMemberCurrentEnrollment) || (usesMemberCurrentEnrollmentCoverage) || (usesMemberCurrentEnrollmentPcp)) { // MUST GET CURRENT ENROLLMENTS TO WALK TO CHILD OBJECTS COVERAGE AND PCP allMemberEnrollments = MercuryApplication.DataExplorerNodeResultsGetForMemberCurrentEnrollment(NodeInstanceId, 1, NodeInstanceCount); if (usesMemberCurrentEnrollmentCoverage) { allMemberEnrollmentCoverages = MercuryApplication.DataExplorerNodeResultsGetForMemberCurrentEnrollmentCoverage(NodeInstanceId, 1, NodeInstanceCount); } if (usesMemberCurrentEnrollmentPcp) { allMemberEnrollmentPcps = MercuryApplication.DataExplorerNodeResultsGetForMemberCurrentEnrollmentPcp(NodeInstanceId, 1, NodeInstanceCount); } } foreach (Client.Core.Member.Member currentMember in members) { row = excelDocument.CreateElement("Row"); columnIndex = 0; #region Precache Data Elements // PRECACHE CURRENT MEMBER ENROLLMENT FOR MULTI-PROPERTY ACCESS // MUST GET CURRENT ENROLLMENTS TO WALK TO CHILD OBJECTS COVERAGE AND PCP Client.Core.Member.MemberEnrollment currentMemberEnrollment = null; if ((usesMemberCurrentEnrollment) || (usesMemberCurrentEnrollmentCoverage) || (usesMemberCurrentEnrollmentPcp)) { List <Client.Core.Member.MemberEnrollment> filteredMemberEnrollment = (from memberEnrollment in allMemberEnrollments where memberEnrollment.MemberId == currentMember.Id select memberEnrollment).ToList(); if (filteredMemberEnrollment.Count > 0) { currentMemberEnrollment = filteredMemberEnrollment[0]; } } // PRECACHE CURRENT MEMBER ENROLLMENT COVERAGE FOR MULTI-PROPERTY ACCESS Client.Core.Member.MemberEnrollmentCoverage currentMemberEnrollmentCoverage = null; if ((usesMemberCurrentEnrollmentCoverage) && (currentMemberEnrollment != null)) { List <Client.Core.Member.MemberEnrollmentCoverage> filteredMemberEnrollmentCoverage = (from memberEnrollmentCoverage in allMemberEnrollmentCoverages where memberEnrollmentCoverage.MemberEnrollmentId == currentMemberEnrollment.Id select memberEnrollmentCoverage).ToList(); if (filteredMemberEnrollmentCoverage.Count > 0) { currentMemberEnrollmentCoverage = filteredMemberEnrollmentCoverage[0]; } } Client.Core.Member.MemberEnrollmentPcp currentMemberEnrollmentPcp = null; if ((usesMemberCurrentEnrollmentPcp) && (currentMemberEnrollment != null)) { List <Client.Core.Member.MemberEnrollmentPcp> filteredMemberEnrollmentPcp = (from memberEnrollmentPcp in allMemberEnrollmentPcps where memberEnrollmentPcp.MemberEnrollmentId == currentMemberEnrollment.Id select memberEnrollmentPcp).ToList(); if (filteredMemberEnrollmentPcp.Count > 0) { currentMemberEnrollmentPcp = filteredMemberEnrollmentPcp[0]; } } #endregion #region Create Cells and Data Values foreach (Telerik.Web.UI.RadTreeNode currentCheckedNode in DataExplorerTreeView.CheckedNodes) { columnIndex = columnIndex + 1; String contentProperty = String.Empty; Object contentValueObject = null; String contentValue = String.Empty; if (currentCheckedNode.Value.StartsWith("CurrentEnrollment.")) { if (currentMemberEnrollment != null) { contentProperty = currentCheckedNode.Value.Substring("CurrentEnrollment.".Length, currentCheckedNode.Value.Length - "CurrentEnrollment.".Length); contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMemberEnrollment, contentProperty); } } else if (currentCheckedNode.Value.StartsWith("CurrentEnrollmentCoverage.")) { if (currentMemberEnrollment != null) { contentProperty = currentCheckedNode.Value.Substring("CurrentEnrollmentCoverage.".Length, currentCheckedNode.Value.Length - "CurrentEnrollmentCoverage.".Length); contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMemberEnrollmentCoverage, contentProperty); } } else if (currentCheckedNode.Value.StartsWith("CurrentEnrollmentPcp.")) { if (currentMemberEnrollment != null) { contentProperty = currentCheckedNode.Value.Substring("CurrentEnrollmentPcp.".Length, currentCheckedNode.Value.Length - "CurrentEnrollmentPcp.".Length); contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMemberEnrollmentPcp, contentProperty); } } else { contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMember, currentCheckedNode.Value); } if (contentValueObject != null) { contentValue = contentValueObject.ToString(); } cell = excelDocument.CreateElement("Cell"); cell.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Index", "urn:schemas-microsoft-com:office:spreadsheet", columnIndex.ToString())); row.AppendChild(cell); cellData = excelDocument.CreateElement("Data"); cellData.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Type", "urn:schemas-microsoft-com:office:spreadsheet", "String")); cellData.InnerText = contentValue; cell.AppendChild(cellData); } #endregion worksheetTableElement.AppendChild(row); } #endregion System.Xml.XmlElement worksheetAutoFilterElement = excelDocument.CreateElement("AutoFilter"); worksheetAutoFilterElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "x", "Range", "urn:schemas-microsoft-com:office:excel", "R1C1:R1C1")); worksheetAutoFilterElement.SetAttribute("xmlns", "urn:schemas-microsoft-com:office:excel"); worksheetElement.AppendChild(worksheetAutoFilterElement); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=DataExplorerResults.xml"); Response.AddHeader("Content-Length", excelDocument.OuterXml.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(new System.Text.ASCIIEncoding().GetBytes(excelDocument.OuterXml.ToCharArray()), 0, excelDocument.OuterXml.Length); Response.End(); return; }
static void Main(string[] args) { int msgprocessthreads = 4; string pstfile = string.Empty; string pathtopstfiles = string.Empty; string pathtoemlfiles = string.Empty; string pathtoeidfile = string.Empty; string pathtofolderfile = string.Empty; string host = string.Empty; PSTMsgParser.PSTMsgParserData.SaveAsType saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Msg; string tracefile = string.Empty; uint offset = 0; uint count = Int32.MaxValue; bool isclient = false; bool isserver = true; bool docount = false; bool unicode = false; List <string> entryids = new List <string>(); List <FolderData> folderdata = new List <FolderData>(); string queuetype = ".netqueue"; Logger.NLogger.Info("Running: {0}", Environment.CommandLine); for (int i = 0; i < args.Length; i++) { switch (args[i].ToUpper()) { case "-OFFSET": offset = Convert.ToUInt32(args[i + 1]); break; case "-COUNT": count = Convert.ToUInt32(args[i + 1]); break; case "-HOST": host = args[i + 1]; break; case "-CLIENT": isclient = true; break; case "-SERVER": isserver = true; break; case "-MSGPROCESSTHREADS": msgprocessthreads = Convert.ToInt32(args[i + 1]); break; case "-INPUTDIR": pathtopstfiles = args[i + 1]; pathtopstfiles = pathtopstfiles + (pathtopstfiles.EndsWith("\\") ? string.Empty : "\\"); break; case "-OUTPUTDIR": pathtoemlfiles = args[i + 1]; pathtoemlfiles = pathtoemlfiles + (pathtoemlfiles.EndsWith("\\") ? string.Empty : "\\"); break; case "-QUEUETYPE": queuetype = args[i + 1]; break; } } // added this code to support old Pst2Msg command line parameters List <string> pst2msgparameters = new List <string>() { "-E", "-F", "-M", "-O", "-R", "-S", "-T", "-U" }; List <string> pst2msgargs = new List <string>(); string pst2msgargument = string.Empty; for (int i = 0; i < args.Length; i++) { if (args[i].Length >= 2 && pst2msgparameters.Contains(args[i].ToUpper().Substring(0, 2))) { if (pst2msgargument != string.Empty) { pst2msgargs.Add(pst2msgargument); pst2msgargument = args[i]; } else { pst2msgargument = args[i]; } } else { pst2msgargument += (" " + args[i]); } } if (pst2msgargument != string.Empty) { pst2msgargs.Add(pst2msgargument); } for (int i = 0; i < pst2msgargs.Count; i++) { if (pst2msgargs[i].Length > 2) { switch (pst2msgargs[i].ToUpper().Substring(0, 2)) { case "-E": if (pst2msgargs[i].Substring(0, 4).ToUpper() == "-EID") { pathtoeidfile = pst2msgargs[i].Substring(4); } break; case "-F": pstfile = pst2msgargs[i].Substring(2); break; case "-M": if (pst2msgargs[i].Substring(2).ToUpper() == "MSG") { saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Msg; } else if (pst2msgargs[i].Substring(2).ToUpper() == "META") { saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Xml; } else if (pst2msgargs[i].Substring(2).ToUpper() == "ALL") { saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Xml | PSTMsgParser.PSTMsgParserData.SaveAsType.Msg; // | PSTMsgParser.SaveAsType.Text; } else if (pst2msgargs[i].Substring(2).ToUpper() == "COUNT") { docount = true; } break; case "-O": if (pst2msgargs[i].ToUpper() != "-OFFSET" && pst2msgargs[i].ToUpper() != "-OUTPUTDIR") { pathtoemlfiles = pst2msgargs[i].Substring(2); } break; case "-R": if (pst2msgargs[i].ToUpper().Substring(0, 3) != "-RT") { pathtoemlfiles = pst2msgargs[i].Substring(2); pathtoemlfiles = pathtoemlfiles + (pathtoemlfiles.EndsWith("\\") ? string.Empty : "\\"); } break; case "-S": if (pst2msgargs[i].ToUpper() != "-SERVER") { pathtofolderfile = pst2msgargs[i].Substring(2); } break; case "-T": tracefile = pst2msgargs[i].Substring(2); break; case "-U": unicode = true; break; } } } if (docount) { offset = 0; count = Int32.MaxValue; msgprocessthreads = 0; pathtoeidfile = string.Empty; pathtofolderfile = string.Empty; } if (pathtoeidfile != string.Empty) { using (System.IO.StreamReader sr = new System.IO.StreamReader(pathtoeidfile)) { String line = string.Empty; while ((line = sr.ReadLine()) != null) { entryids.Add(line.Split(new char[] { '\t' })[1]); } } } if (pathtofolderfile != string.Empty) { if (System.IO.File.Exists(pathtofolderfile)) { using (System.IO.StreamReader sr = new System.IO.StreamReader(pathtofolderfile, true)) { String line = string.Empty; while ((line = sr.ReadLine()) != null) { folderdata.Add(new FolderData(line)); } } } } if (msgprocessthreads > 0) { isclient = true; } KRSrcWorkflow.Interfaces.IWFMessageQueue <PSTMsgParser.PSTMsgParser> msgqueue = null; if (queuetype == "rabbbitmq" || queuetype == "msmq") { if (host == string.Empty) { KRSrcWorkflow.WFUtilities.SetHostAndIPAddress(System.Net.Dns.GetHostName(), ref host); } // if (queuetype == "rabbbitmq") // msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_RabbitMQ<PSTMsgParser.PSTMsgParser>(host, 5672, "msgqueue", KRSrcWorkflow.Abstracts.WFMessageQueueType.Publisher); // else if (queuetype == "msmq") // msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_MessageQueue<PSTMsgParser.PSTMsgParser>(host, "msgqueue"); } // else // msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_Queue<PSTMsgParser.PSTMsgParser>(); List <ManualResetEvent> msgthreadevents = new List <ManualResetEvent>(); ManualResetEvent msgthreadinterrupt = null; if (isclient) { int threadid = 0; KRSrcWorkflow.WFGenericThread <PSTMsgParser.PSTMsgParser> iothread = null; if (msgprocessthreads > 0) { msgthreadinterrupt = new ManualResetEvent(false); for (int i = 0; i < msgprocessthreads; i++) { // ThreadPool.QueueUserWorkItem((iothread = new KRSrcWorkflow.WFThread<PSTMsgParser.PSTMsgParserData>(msgthreadinterrupt, msgqueue, null, threadid++)).Run); msgthreadevents.Add(iothread.ThreadExitEvent); } } } if (isserver) { string[] pstfiles = null; if (pathtopstfiles != string.Empty) { pstfiles = System.IO.Directory.GetFiles(pathtopstfiles, "*.pst", System.IO.SearchOption.TopDirectoryOnly); } else if (pstfile != string.Empty) { pstfiles = new string[1] { pstfile } } ; if (pstfiles.Length != 0) { foreach (string pfile in pstfiles) { bool append = false; Logger.NLogger.Info("Processing: {0}", pfile); string exportdir = pathtoemlfiles; if (pathtopstfiles != string.Empty) { exportdir = pathtoemlfiles + pfile.Substring((pfile.LastIndexOf("\\") == -1 ? 0 : pfile.LastIndexOf("\\")) + 1, pfile.Length - 5 - (pfile.LastIndexOf("\\") == -1 ? 0 : pfile.LastIndexOf("\\"))); } Logger.NLogger.Info("Export Directory: {0}", exportdir); if (docount) { if (System.IO.File.Exists(exportdir + "\\AllEntryID.txt")) { System.IO.File.Delete(exportdir + "\\AllEntryID.txt"); } if (System.IO.File.Exists(exportdir + "\\FolderInfo.xml")) { System.IO.File.Delete(exportdir + "\\FolderInfo.xml"); } } if (!System.IO.Directory.Exists(exportdir + @"MSG\")) { System.IO.Directory.CreateDirectory(exportdir + @"MSG\"); } if (!System.IO.Directory.Exists(exportdir + @"XML\")) { System.IO.Directory.CreateDirectory(exportdir + @"XML\"); } Logger.NLogger.Info("Logon to PST store: {0}", pfile); pstsdk.definition.pst.IPst rdopststore = null; try { rdopststore = new pstsdk.layer.pst.Pst(pfile); } catch (Exception ex) { Logger.NLogger.ErrorException("Pst constructor failed for " + pfile, ex); } if (rdopststore != null) { Logger.NLogger.Info("Successfully logged on to PST store: {0}", pfile); GetFolderData(rdopststore.OpenRootFolder(), string.Empty, folderdata.Count > 0 ? true : false, docount == true, ref folderdata); uint totmessages = (uint)folderdata.Sum(x => x.NumMessages); uint totattachments = (uint)folderdata.Sum(x => x.NumAttachments); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlNode foldersnode = null; if (docount == true) { doc = new System.Xml.XmlDocument(); // Create the XML Declaration, and append it to XML document System.Xml.XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "windows-1252", null); doc.AppendChild(dec); // create message element System.Xml.XmlElement folders = doc.CreateElement("Folders"); foldersnode = doc.AppendChild(folders); } // List<pstsdk.definition.util.primitives.NodeID> foldernodeids = docount == true ? folderdata.Where(x => x.NodeId != 0).Select(x => x.NodeId).ToList() : rdopststore.Folders.Where(x => x.Node != 0).Select(x => x.Node).ToList(); // foreach (pstsdk.definition.util.primitives.NodeID foldernodeid in foldernodeids) foreach (FolderData fd in folderdata) { pstsdk.definition.util.primitives.NodeID foldernodeid = fd.NodeId; pstsdk.definition.pst.folder.IFolder folder = null; try { folder = rdopststore.OpenFolder(foldernodeid); if (docount == true) { HandleFolder(folder, doc, foldersnode, fd.FolderPath, unicode); } uint idx = 0; foreach (pstsdk.definition.pst.message.IMessage msg in folder.Messages) { if (docount == true) { using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(exportdir + "\\AllEntryID.txt", append)) { outfile.WriteLine(folder.EntryID.ToString() + "\t" + msg.EntryID.ToString()); } append = true; } else { if (idx >= offset) { // if ((entryids.Count == 0) || entryids.Contains(msg.EntryID.ToString())) // msgqueue.Enqueue(new PSTMsgParser.PSTMsgParser(pfile, msg.Node, exportdir) { SaveAsTypes = PSTMsgParser.PSTMsgParser.SaveAsType.Msg | PSTMsgParser.PSTMsgParser.SaveAsType.Xml, SaveAttachments = false, FileToProcess = msg.Node.Value.ToString(), FolderPath = fd.FolderPath, ExportDirectory = exportdir, Pst2MsgCompatible = true }); } idx++; if (count != UInt32.MaxValue) { if (idx == (offset + count)) { break; } } } msg.Dispose(); } } catch (Exception ex) { Logger.NLogger.ErrorException("OpenFolder failed!" + " NodeId=" + foldernodeid + " FolderPath=" + folderdata.FirstOrDefault(x => x.NodeId == foldernodeid).FolderPath, ex); } finally { if (folder != null) { folder.Dispose(); } } } if (docount == true) { System.Xml.XmlElement numoffolders = doc.CreateElement("numOfFolders"); System.Xml.XmlNode numoffoldersnode = foldersnode.AppendChild(numoffolders); numoffoldersnode.InnerText = rdopststore.Folders.Count().ToString(); System.Xml.XmlElement numofmsgs = doc.CreateElement("numOfMsgs"); System.Xml.XmlNode numofmsgsnode = foldersnode.AppendChild(numofmsgs); numofmsgsnode.InnerText = totmessages.ToString(); System.Xml.XmlElement numoftotattachments = doc.CreateElement("numOfAttachments"); System.Xml.XmlNode numoftotattachmentsnode = foldersnode.AppendChild(numoftotattachments); numoftotattachmentsnode.InnerText = totattachments.ToString(); System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(exportdir + "\\FolderInfo.xml", System.Text.Encoding.GetEncoding("windows-1252")); writer.Formatting = System.Xml.Formatting.Indented; doc.Save(writer); writer.Close(); } rdopststore.Dispose(); } } } else { Console.WriteLine("ERROR: No pst files found in directory " + pathtopstfiles); } if (msgprocessthreads > 0) { do { Thread.Sleep(100); } while (msgqueue.Count > 0); System.Diagnostics.Debug.WriteLine("Setting msgthreadinterrupt"); msgthreadinterrupt.Set(); WaitHandle.WaitAll(msgthreadevents.ToArray()); System.Diagnostics.Debug.WriteLine("All message threads exited"); Thread.Sleep(5000); } } else { Thread.Sleep(Int32.MaxValue); } } }
public System.Xml.XmlDeclaration CreateDeclaration(string version, string encoding, string standalone) { System.Xml.XmlDeclaration oXmlDeclaration = XmlDocument.CreateXmlDeclaration(version, encoding, standalone); return(oXmlDeclaration); }
public void Fax(Public.Faxing.FaxServerConfiguration forFaxServerConfiguration, FaxSender forSender, FaxRecipient forRecipient, FaxDocument forDocument, Dictionary <String, String> extendedProperties) { faxServerConfiguration = forFaxServerConfiguration; sender = forSender; recipient = forRecipient; document = forDocument; String controlFileName = document.UniqueId + ".xml"; String attachmentFileName = document.UniqueId + "." + document.Attachment.Extension; String statusFileName = controlFileName + ".status"; System.Diagnostics.Debug.WriteLine("Source ID:" + document.UniqueId); // CREATE FAX CONTROL FILE System.Xml.XmlDocument controlDocument = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration xmlDeclaration = controlDocument.CreateXmlDeclaration("1.0", "utf-8", String.Empty); System.Xml.XmlElement controlElementNode = controlDocument.CreateElement("faxmakerdata"); System.Xml.XmlElement fieldsElementNode = controlDocument.CreateElement("fields"); System.Xml.XmlElement senderElementNode = controlDocument.CreateElement("sender"); System.Xml.XmlElement recipientsElementNode = controlDocument.CreateElement("recipients"); System.Xml.XmlElement recipientsFaxElementNode = controlDocument.CreateElement("fax"); System.Xml.XmlElement recipientElementNode = controlDocument.CreateElement("recipient"); #region Initialize Document Structure controlDocument.InsertBefore(xmlDeclaration, controlDocument.DocumentElement); controlDocument.AppendChild(controlElementNode); controlElementNode.AppendChild(fieldsElementNode); controlElementNode.AppendChild(senderElementNode); controlElementNode.AppendChild(recipientsElementNode); recipientsElementNode.AppendChild(recipientsFaxElementNode); recipientsFaxElementNode.AppendChild(recipientElementNode); // FAXMAKERDATA // +-- FIELDS // +-- SENDER // +-- RECIPIENTS // +-- +-- FAX // +-- +-- +-- RECIPIENT #endregion #region Sender Node if (!String.IsNullOrWhiteSpace(sender.Name)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "lastname", sender.Name); } if (!String.IsNullOrWhiteSpace(sender.Company)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "company", sender.Company); } if (!String.IsNullOrWhiteSpace(sender.Department)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "department", sender.Department); } if (!String.IsNullOrWhiteSpace(sender.FaxNumber)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "faxnumber", sender.FaxNumber); } if (!String.IsNullOrWhiteSpace(sender.VoiceNumber)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "voicenumber", sender.VoiceNumber); } // if (!String.IsNullOrWhiteSpace (sender.Email)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode (controlDocument, senderElementNode, "emailaddress", sender.Email); } Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "emailaddress", sender.Email); #endregion #region Recipient Node String faxNumber = recipient.FaxNumber; faxNumber = (faxNumber.Length == 7) ? faxNumber.Substring(0, 3) + "-" + faxNumber.Substring(3, 4) : faxNumber; faxNumber = (faxNumber.Length == 10) ? "1-" + faxNumber.Substring(0, 3) + "-" + faxNumber.Substring(3, 3) + "-" + faxNumber.Substring(6, 4) : faxNumber; if (!String.IsNullOrWhiteSpace(recipient.RecipientName)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "lastname", recipient.RecipientName); } if (!String.IsNullOrWhiteSpace(recipient.CompanyName)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "company", recipient.CompanyName); } if (!String.IsNullOrWhiteSpace(recipient.DepartmentName)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "department", recipient.DepartmentName); } Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "faxnumber", faxNumber); if (!String.IsNullOrWhiteSpace(recipient.RecipientEmail)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "emaladdress", recipient.RecipientEmail); } #endregion #region Fields Node if (!String.IsNullOrWhiteSpace(document.Subject)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "subject", document.Subject); } Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "resolution", "high"); Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "attachment", attachmentFileName); Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "uid", document.UniqueId); #endregion attachmentFileName = faxServerConfiguration.FaxUrl + @"\" + attachmentFileName; attachmentFileName = attachmentFileName.Replace(@"\\" + attachmentFileName, @"\" + attachmentFileName); System.IO.FileStream attachmentFile = new System.IO.FileStream(attachmentFileName, System.IO.FileMode.Create); document.Attachment.Image.Seek(0, System.IO.SeekOrigin.Begin); document.Attachment.Image.WriteTo(attachmentFile); attachmentFile.Flush(); attachmentFile.Close(); controlFileName = faxServerConfiguration.FaxUrl + @"\" + controlFileName; controlFileName = controlFileName.Replace(@"\\" + controlFileName, @"\" + controlFileName); controlDocument.Save(controlFileName); statusWatchStartTime = DateTime.Now; statusWatcher = new System.IO.FileSystemWatcher(); statusWatcher.Filter = "*.status"; statusWatcher.Created += new System.IO.FileSystemEventHandler(StatusWatcher_OnFileCreated); statusWatcher.Path = faxServerConfiguration.FaxUrl; statusWatcher.EnableRaisingEvents = true; return; }
private void guardarXML(Stream myStream) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //System.Xml.XmlAttribute atributo; System.Xml.XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", ""); doc.AppendChild(declaration); System.Xml.XmlNode pmml = doc.CreateElement("PMML"); /* * atributo = doc.CreateAttribute("version"); * atributo.InnerText = "3.0"; * pmml.Attributes.Append(atributo); * atributo = doc.CreateAttribute("xmlns"); * atributo.InnerText = "http://www.dmg.org/PMML-3-0"; * pmml.Attributes.Append(atributo); * atributo = doc.CreateAttribute("xmlns:xsi"); * atributo.InnerText = "http://www.w3.org/2001/XMLSchema_instance"; * pmml.Attributes.Append(atributo); */ pmml.Attributes.Append(setAtributo(doc, "version", "3.0")); pmml.Attributes.Append(setAtributo(doc, "xmlns", "http://www.dmg.org/PMML-3-0")); pmml.Attributes.Append(setAtributo(doc, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema_instance")); doc.AppendChild(pmml); System.Xml.XmlNode sprite = doc.CreateElement("TEXTURA"); if (textureName.Text.Equals("")) { sprite.Attributes.Append(setAtributo(doc, "Name", "none")); } else { sprite.Attributes.Append(setAtributo(doc, "Name", textureName.Text)); } if (useRelativePath.Checked && !relativeFileLoc.Equals("")) { sprite.Attributes.Append(setAtributo(doc, "TextureFile", relativeFileLoc.Insert(0, "..\\").Replace('\\', '/'))); } else { sprite.Attributes.Append(setAtributo(doc, "TextureFile", fileLoc)); } int colorR = color_click.BackColor.R; int colorG = color_click.BackColor.G; int colorB = color_click.BackColor.B; //sprite.Attributes.Append(setAtributo(doc, "ColorKey", "FF"+R+G+B)); System.Xml.XmlNode colorKey = doc.CreateElement("ColorKey"); colorKey.Attributes.Append(setAtributo(doc, "R", colorR.ToString())); colorKey.Attributes.Append(setAtributo(doc, "G", colorG.ToString())); colorKey.Attributes.Append(setAtributo(doc, "B", colorB.ToString())); sprite.AppendChild(colorKey); pmml.AppendChild(sprite); /* * doc.AppendChild(XClub); * System.Xml.XmlNode Pelicula = doc.CreateElement("Pelicula"); * XClub.AppendChild(Pelicula); * System.Xml.XmlNode Data = doc.CreateElement("Data"); * System.Xml.XmlAttribute atributo = doc.CreateAttribute("Titulo"); * atributo.InnerText = "Garganta Profunda(Deep Throat)"; * Data.Attributes.Append(atributo); * System.Xml.XmlAttribute atributo2 = doc.CreateAttribute("Director"); * atributo2.InnerText = ""; * Data.Attributes.Append(atributo2); * Pelicula.AppendChild(Data);*/ doc.Save(myStream); }
public ActionResult Sonuc() { var e = Request.Form.GetEnumerator(); while (e.MoveNext()) { String xkey = (String)e.Current; String xval = Request.Form.Get(xkey); Response.Write("<tr><td>" + xkey + "</td><td>" + xval + "</td></tr>"); } String hashparams = Request.Form.Get("HASHPARAMS"); String hashparamsval = Request.Form.Get("HASHPARAMSVAL"); String storekey = "XXXX"; //Sizin Storkey Adresiniz String paramsval = ""; int index1 = 0, index2 = 0; // hash hesaplamada kullanılacak değerler ayrıştırılıp değerleri birleştiriliyor. do { index2 = hashparams.IndexOf(":", index1); String val = Request.Form.Get(hashparams.Substring(index1, index2 - index1)) == null ? "" : Request.Form.Get(hashparams.Substring(index1, index2 - index1)); paramsval += val; index1 = index2 + 1; }while (index1 < hashparams.Length); //out.println("hashparams="+hashparams+"<br/>"); //out.println("hashparamsval="+hashparamsval+"<br/>"); //out.println("paramsval="+paramsval+"<br/>"); String hashval = paramsval + storekey; //elde edilecek hash değeri için paramsval e store key ekleniyor. (işyeri anahtarı) String hashparam = Request.Form.Get("HASH"); System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider(); byte[] hashbytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(hashval); byte[] inputbytes = sha.ComputeHash(hashbytes); String hash = Convert.ToBase64String(inputbytes); //Güvenlik ve kontrol amaçlı oluşturulan hash if (!paramsval.Equals(hashparamsval) || !hash.Equals(hashparam)) //oluşturulan hash ile gelen hash ve hash parametreleri değerleri ile ayrıştırılıp edilen edilen aynı olmalı. { Response.Write("<h4>Güvenlik Uyarısı. Sayısal İmza Geçerli Değil</h4>"); } // Ödeme için gerekli parametreler String nameval = "xxxx"; //İşyeri kullanıcı adı String passwordval = "xxxx"; //İşyeri şifresi String clientidval = Request.Form.Get("clientid"); // İşyeri numarası String modeval = "P"; //P olursa gerçek işlem, T olursa test işlemi yapar. String typeval = "Auth"; //Auth PreAuth PostAuth Credit Void olabilir. String expiresval = Request.Form.Get("Ecom_Payment_Card_ExpDate_Month") + "/" + Request.Form.Get("Ecom_Payment_Card_ExpDate_Year"); //Kredi Kartı son kullanım tarihi mm/yy formatından olmalı String cv2val = Request.Form.Get("cv2"); //Güvenlik Kodu String totalval = Request.Form.Get("amount"); //Tutar String numberval = Request.Form.Get("md"); //Kart numarası olarak 3d sonucu dönem md parametresi kullanılır. String taksitval = ""; //Taksit sayısı peşin satışlar da boş olarak gönderilmelidir. String currencyval = "949"; //ytl için String orderidval = ""; //Sipariş numarası String mdstatus = Request.Form.Get("mdStatus"); // mdStatus 3d işlemin sonucu ile ilgili bilgi verir. 1,2,3,4 başarılı, 5,6,7,8,9,0 başarısızdır. if (mdstatus.Equals("1") || mdstatus.Equals("2") || mdstatus.Equals("3") || mdstatus.Equals("4")) //3D Onayı alınmıştır. { Response.Write("<h5>3D İşlemi Başarılı</h5><br/>"); String cardholderpresentcodeval = "13"; String payersecuritylevelval = Request.Form.Get("eci"); String payertxnidval = Request.Form.Get("xid"); String payerauthenticationcodeval = Request.Form.Get("cavv"); String ipaddressval = ""; String emailval = ""; String groupidval = ""; String transidval = ""; String useridval = ""; //Fatura Bilgileri String billnameval = ""; //Fatur İsmi String billstreet1val = ""; //Fatura adres 1 String billstreet2val = ""; //Fatura adres 2 String billstreet3val = ""; //Fatura adres 3 String billcityval = ""; //Fatura şehir String billstateprovval = ""; //Fatura eyalet String billpostalcodeval = ""; //Fatura posta kodu //Teslimat Bilgileri String shipnameval = ""; //isim String shipstreet1val = ""; //adres 1 String shipstreet2val = ""; //adres 2 String shipstreet3val = ""; //adres 3 String shipcityval = ""; //şehir String shipstateprovval = ""; //eyalet String shippostalcodeval = ""; //posta kodu String extraval = ""; //Ödeme için gerekli xml yapısı oluşturuluyor System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "ISO-8859-9", "yes"); doc.AppendChild(dec); System.Xml.XmlElement cc5Request = doc.CreateElement("CC5Request"); doc.AppendChild(cc5Request); System.Xml.XmlElement name = doc.CreateElement("Name"); name.AppendChild(doc.CreateTextNode(nameval)); cc5Request.AppendChild(name); System.Xml.XmlElement password = doc.CreateElement("Password"); password.AppendChild(doc.CreateTextNode(passwordval)); cc5Request.AppendChild(password); System.Xml.XmlElement clientid = doc.CreateElement("ClientId"); clientid.AppendChild(doc.CreateTextNode(clientidval)); cc5Request.AppendChild(clientid); System.Xml.XmlElement ipaddress = doc.CreateElement("IPAddress"); ipaddress.AppendChild(doc.CreateTextNode(ipaddressval)); cc5Request.AppendChild(ipaddress); System.Xml.XmlElement email = doc.CreateElement("Email"); email.AppendChild(doc.CreateTextNode(emailval)); cc5Request.AppendChild(email); System.Xml.XmlElement mode = doc.CreateElement("Mode"); mode.AppendChild(doc.CreateTextNode(modeval)); cc5Request.AppendChild(mode); System.Xml.XmlElement orderid = doc.CreateElement("OrderId"); orderid.AppendChild(doc.CreateTextNode(orderidval)); cc5Request.AppendChild(orderid); System.Xml.XmlElement groupid = doc.CreateElement("GroupId"); groupid.AppendChild(doc.CreateTextNode(groupidval)); cc5Request.AppendChild(groupid); System.Xml.XmlElement transid = doc.CreateElement("TransId"); transid.AppendChild(doc.CreateTextNode(transidval)); cc5Request.AppendChild(transid); System.Xml.XmlElement userid = doc.CreateElement("UserId"); userid.AppendChild(doc.CreateTextNode(useridval)); cc5Request.AppendChild(userid); System.Xml.XmlElement type = doc.CreateElement("Type"); type.AppendChild(doc.CreateTextNode(typeval)); cc5Request.AppendChild(type); System.Xml.XmlElement number = doc.CreateElement("Number"); number.AppendChild(doc.CreateTextNode(numberval)); cc5Request.AppendChild(number); System.Xml.XmlElement expires = doc.CreateElement("Expires"); expires.AppendChild(doc.CreateTextNode(expiresval)); cc5Request.AppendChild(expires); System.Xml.XmlElement cvv2val = doc.CreateElement("Cvv2Val"); cvv2val.AppendChild(doc.CreateTextNode(cv2val)); cc5Request.AppendChild(cvv2val); System.Xml.XmlElement total = doc.CreateElement("Total"); total.AppendChild(doc.CreateTextNode(totalval)); cc5Request.AppendChild(total); System.Xml.XmlElement currency = doc.CreateElement("Currency"); currency.AppendChild(doc.CreateTextNode(currencyval)); cc5Request.AppendChild(currency); System.Xml.XmlElement taksit = doc.CreateElement("Taksit"); taksit.AppendChild(doc.CreateTextNode(taksitval)); cc5Request.AppendChild(taksit); System.Xml.XmlElement payertxnid = doc.CreateElement("PayerTxnId"); payertxnid.AppendChild(doc.CreateTextNode(payertxnidval)); cc5Request.AppendChild(payertxnid); System.Xml.XmlElement payersecuritylevel = doc.CreateElement("PayerSecurityLevel"); payersecuritylevel.AppendChild(doc.CreateTextNode(payersecuritylevelval)); cc5Request.AppendChild(payersecuritylevel); System.Xml.XmlElement payerauthenticationcode = doc.CreateElement("PayerAuthenticationCode"); payerauthenticationcode.AppendChild(doc.CreateTextNode(payerauthenticationcodeval)); cc5Request.AppendChild(payerauthenticationcode); System.Xml.XmlElement cardholderpresentcode = doc.CreateElement("CardholderPresentCode"); cardholderpresentcode.AppendChild(doc.CreateTextNode(cardholderpresentcodeval)); cc5Request.AppendChild(cardholderpresentcode); System.Xml.XmlElement billto = doc.CreateElement("BillTo"); cc5Request.AppendChild(billto); System.Xml.XmlElement billname = doc.CreateElement("Name"); billname.AppendChild(doc.CreateTextNode(billnameval)); billto.AppendChild(billname); System.Xml.XmlElement billstreet1 = doc.CreateElement("Street1"); billstreet1.AppendChild(doc.CreateTextNode(billstreet1val)); billto.AppendChild(billstreet1); System.Xml.XmlElement billstreet2 = doc.CreateElement("Street2"); billstreet2.AppendChild(doc.CreateTextNode(billstreet2val)); billto.AppendChild(billstreet2); System.Xml.XmlElement billstreet3 = doc.CreateElement("Street3"); billstreet3.AppendChild(doc.CreateTextNode(billstreet3val)); billto.AppendChild(billstreet3); System.Xml.XmlElement billcity = doc.CreateElement("City"); billcity.AppendChild(doc.CreateTextNode(billcityval)); billto.AppendChild(billcity); System.Xml.XmlElement billstateprov = doc.CreateElement("StateProv"); billstateprov.AppendChild(doc.CreateTextNode(billstateprovval)); billto.AppendChild(billstateprov); System.Xml.XmlElement billpostalcode = doc.CreateElement("PostalCode"); billpostalcode.AppendChild(doc.CreateTextNode(billpostalcodeval)); billto.AppendChild(billpostalcode); System.Xml.XmlElement shipto = doc.CreateElement("ShipTo"); cc5Request.AppendChild(shipto); System.Xml.XmlElement shipname = doc.CreateElement("Name"); shipname.AppendChild(doc.CreateTextNode(shipnameval)); shipto.AppendChild(shipname); System.Xml.XmlElement shipstreet1 = doc.CreateElement("Street1"); shipstreet1.AppendChild(doc.CreateTextNode(shipstreet1val)); shipto.AppendChild(shipstreet1); System.Xml.XmlElement shipstreet2 = doc.CreateElement("Street2"); shipstreet2.AppendChild(doc.CreateTextNode(shipstreet2val)); shipto.AppendChild(shipstreet2); System.Xml.XmlElement shipstreet3 = doc.CreateElement("Street3"); shipstreet3.AppendChild(doc.CreateTextNode(shipstreet3val)); shipto.AppendChild(shipstreet3); System.Xml.XmlElement shipcity = doc.CreateElement("City"); shipcity.AppendChild(doc.CreateTextNode(shipcityval)); shipto.AppendChild(shipcity); System.Xml.XmlElement shipstateprov = doc.CreateElement("StateProv"); shipstateprov.AppendChild(doc.CreateTextNode(shipstateprovval)); shipto.AppendChild(shipstateprov); System.Xml.XmlElement shippostalcode = doc.CreateElement("PostalCode"); shippostalcode.AppendChild(doc.CreateTextNode(shippostalcodeval)); shipto.AppendChild(shippostalcode); System.Xml.XmlElement extra = doc.CreateElement("Extra"); extra.AppendChild(doc.CreateTextNode(extraval)); cc5Request.AppendChild(extra); String xmlval = doc.OuterXml; //Oluşturulan xml string olarak alınıyor. // Ödeme için bağlantı kuruluyor. ve post ediliyor String url = "https://<DonusApiAdresi>/fim/api"; System.Net.HttpWebResponse resp = null; try { System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); string postdata = "DATA=" + xmlval.ToString(); byte[] postdatabytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(postdata); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = postdatabytes.Length; System.IO.Stream requeststream = request.GetRequestStream(); requeststream.Write(postdatabytes, 0, postdatabytes.Length); requeststream.Close(); resp = (System.Net.HttpWebResponse)request.GetResponse(); System.IO.StreamReader responsereader = new System.IO.StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding("ISO-8859-9")); String gelenXml = responsereader.ReadToEnd(); //Gelen xml string olarak alındı. System.Xml.XmlDocument gelen = new System.Xml.XmlDocument(); gelen.LoadXml(gelenXml); //string xml dökumanına çevrildi. System.Xml.XmlNodeList list = gelen.GetElementsByTagName("Response"); String xmlResponse = list[0].InnerText; list = gelen.GetElementsByTagName("AuthCode"); String xmlAuthCode = list[0].InnerText; list = gelen.GetElementsByTagName("HostRefNum"); String xmlHostRefNum = list[0].InnerText; list = gelen.GetElementsByTagName("ProcReturnCode"); String xmlProcReturnCode = list[0].InnerText; list = gelen.GetElementsByTagName("TransId"); String xmlTransId = list[0].InnerText; list = gelen.GetElementsByTagName("ErrMsg"); String xmlErrMsg = list[0].InnerText; if ("Approved".Equals(xmlResponse)) { Response.Write("Ödeme başarıyla gerçekleştirildi"); } else { Response.Write("Ödemede hata oluştu"); } resp.Close(); } catch (Exception ex) { Console.Write(ex.ToString()); } finally { if (resp != null) { resp.Close(); } } } else { Response.Write("3D Onayı alınamadı"); } return(View()); }
public System.Xml.XmlDeclaration CreateDeclaration() { System.Xml.XmlDeclaration oXmlDeclaration = XmlDocument.CreateXmlDeclaration("1.0", "utf-8", "yes"); return(oXmlDeclaration); }