public FieldProperty(Element element, MappingElement parent, string name, ClassName type, ClassName implementationClassName, bool nullable, ClassName foreignClass, SupportClass.SetSupport foreignKeys, MultiMap metaattribs) : base(element, parent) { InitWith(name, type, implementationClassName, nullable, id, false, foreignClass, foreignKeys, metaattribs); }
public MappingElement(Element element, MappingElement parentElement) { this.element = element; this.parentElement = parentElement; // merge with parent meta map /* * MultiMap inherited = null; if (parentModel != null) { inherited = * parentModel.getMetaMap(); } */ }
public SubclassMapping(string classPackage, MappingElement mappingElement, string superClass, Element clazz, MultiMap multiMap) { this.classPackage = classPackage; this.mappingElement = mappingElement; this.superClass = superClass; this.clazz = clazz; this.multiMap = multiMap; this.orphaned = true; }
public GameRiver() { InitializeComponent(); DialogResult = DialogResult.OK; chesses = new int[8]; lastChesses = new int[8] { 3, 3, 3, 3, 3, 3, 3, 3 }; InitChesses(); statue = GameRiverStatue.Waiting; isStepReady = false; OnClickChess1 = null; OnClickChess2 = null; cfg = GameConfig.GetCfgXml()["GameRiver"]; }
public SystemXmlMatcher( System.Xml.XmlElement n ) { node = n; }
public PostEvent(SIFHeaderType SIFHeader, System.Xml.XmlElement Event) { this.SIFHeader = SIFHeader; this.Event = Event; }
//Given a DataRow, update or Create the SalesForce Object //Assuming that we have just one row, easy to change to handle multiples public DataReturn Save(SForceEdit.SObjectDef sObj, DataRow dRow) { DataReturn dr = new DataReturn(); sObject s = new sObject(); s.type = sObj.Name; string id = ""; if (dRow["Id"] == null || dRow["Id"].ToString() == "") { //new int fldCount = dRow.Table.Columns.Count - 1; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount]; fldCount = 0; List<string> fieldsToNull = new List<string>(); foreach (DataColumn dc in dRow.Table.Columns) { //Get the field definition SForceEdit.SObjectDef.FieldGridCol f = sObj.GetField(dc.ColumnName); // this is a new record so do it even if it says its readonly but exclud any _Name or _Type if (!f.Create) { //nada ... } else if (dc.ColumnName == "Id") { //Nothing! } else if (dc.ColumnName == "type") { //don't do anything - this happens when we have the type field from a join } else { object val = dRow[dc.ColumnName]; if (dRow[dc.ColumnName] == DBNull.Value) { fieldsToNull.Add(dc.ColumnName); } else { o[fldCount] = doc.CreateElement(dc.ColumnName); string sval = ""; if (f.DataType == "datetime") { sval = ((DateTime)val).ToString("o"); } else if (f.DataType == "date") { sval = ((DateTime)val).ToString("yyyy-MM-dd"); } else { sval = CleanUpXML(val.ToString()); } o[fldCount].InnerText = sval; fldCount++; } } } try { // dont need to set the values to Null! this is a create so just don't tell them // s.fieldsToNull = fieldsToNull.ToArray(); s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount); sfPartner.SaveResult[] sr = _binding.create(new sObject[] { s }); Globals.Ribbons.Ribbon1.SFDebug("Save>" + s.type); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { dr.id = sr[j].id; } else { dr.success = false; for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message; } } } } catch (Exception ex) { dr.success = false; dr.errormessage = ex.Message; } } else { //update int fldCount = dRow.Table.Columns.Count; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount]; fldCount = 0; List<string> fieldsToNull = new List<string>(); foreach (DataColumn dc in dRow.Table.Columns) { //Get the field definition SForceEdit.SObjectDef.FieldGridCol f = sObj.GetField(dc.ColumnName); if (dc.ColumnName == "Id") { s.Id = dRow[dc.ColumnName].ToString(); } else if (!f.Update) { //not on the list ... } else if (dc.ColumnName == "type") { //don't do anything - this happens when we have the type field from a join } else { object val = dRow[dc.ColumnName]; if (dRow[dc.ColumnName] == DBNull.Value || ((f.DataType != "string") && dRow[dc.ColumnName].ToString() == "")) { fieldsToNull.Add(dc.ColumnName); } else { o[fldCount] = doc.CreateElement(dc.ColumnName); string sval = ""; if (f.DataType == "datetime") { sval = ((DateTime)val).ToString("o"); } else if (f.DataType == "date") { sval = ((DateTime)val).ToString("yyyy-MM-dd"); } else { sval = CleanUpXML(val.ToString()); } o[fldCount].InnerText = sval; fldCount++; } } } try { s.fieldsToNull = fieldsToNull.ToArray(); s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount); sfPartner.SaveResult[] sr = _binding.update(new sObject[] { s }); Globals.Ribbons.Ribbon1.SFDebug("Update>" + s.type); for (int j = 0; j < sr.Length; j++) { Console.WriteLine("\nItem: " + j); if (sr[j].success) { dr.id = sr[j].id; } else { dr.success = false; for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message; } } } } catch (Exception ex) { dr.success = false; dr.errormessage = ex.Message; } } return dr; }
/// <summary> /// Initialize the log4net system using the specified config /// </summary> /// <param name="element">the element containing the root of the config</param> void IXmlRepositoryConfigurator.Configure(System.Xml.XmlElement element) { XmlRepositoryConfigure(element); }
private void createLeadSample() { //Verify that we are already authenticated, if not //call the login function to do so if (!loggedIn) { if (!login()) return; } try { sObject[] leads = new sObject[1]; apex.sObject lead; lead = new apex.sObject(); int index = 0; System.Xml.XmlElement[] leadEls = new System.Xml.XmlElement[17]; leadEls[index++] = GetNewXmlElement("AnnualRevenue", System.Xml.XmlConvert.ToString(1000000.0)); leadEls[index++] = GetNewXmlElement("AnnualRevenueSpecified", System.Xml.XmlConvert.ToString(true)); leadEls[index++] = GetNewXmlElement("City", "San Francisco"); leadEls[index++] = GetNewXmlElement("Company", "Acme Anvils"); leadEls[index++] = GetNewXmlElement("Country", "United States"); leadEls[index++] = GetNewXmlElement("CurrencyIsoCode", "USD"); leadEls[index++] = GetNewXmlElement("Description", "This is a lead that can be converted."); leadEls[index++] = GetNewXmlElement("DoNotCall", System.Xml.XmlConvert.ToString(false)); leadEls[index++] = GetNewXmlElement("DoNotCallSpecified", System.Xml.XmlConvert.ToString(true)); Console.Write("\nPlease enter an email for the lead we are creating."); string email = Console.ReadLine(); if (email == null) leadEls[index++] = GetNewXmlElement("Email", "*****@*****.**"); else leadEls[index++] = GetNewXmlElement("Email", email); leadEls[index++] = GetNewXmlElement("Fax", "5555555555"); leadEls[index++] = GetNewXmlElement("FirstName", "Wiley"); leadEls[index++] = GetNewXmlElement("HasOptedOutOfEmail", System.Xml.XmlConvert.ToString(false)); leadEls[index++] = GetNewXmlElement("HasOptedOutOfEmailSpecified", System.Xml.XmlConvert.ToString(true)); leadEls[index++] = GetNewXmlElement("Industry", "Blacksmithery"); leadEls[index++] = GetNewXmlElement("LastName", "Coyote"); leadEls[index++] = GetNewXmlElement("LeadSource", "Web"); leadEls[index++] = GetNewXmlElement("MobilePhone", "4444444444"); leadEls[index++] = GetNewXmlElement("NumberOfEmployees", System.Xml.XmlConvert.ToString(30)); leadEls[index++] = GetNewXmlElement("NumberOfEmployeesSpecified", System.Xml.XmlConvert.ToString(true)); leadEls[index++] = GetNewXmlElement("NumberofLocations__c", System.Xml.XmlConvert.ToString(1.0)); leadEls[index++] = GetNewXmlElement("NumberofLocations__cSpecified", System.Xml.XmlConvert.ToString(true)); leadEls[index++] = GetNewXmlElement("Phone", "6666666666"); leadEls[index++] = GetNewXmlElement("PostalCode", "94105"); leadEls[index++] = GetNewXmlElement("Rating", "Hot"); leadEls[index++] = GetNewXmlElement("Salutation", "Mr."); leadEls[index++] = GetNewXmlElement("State", "California"); leadEls[index++] = GetNewXmlElement("Status", "Working"); leadEls[index++] = GetNewXmlElement("Street", "10 Downing Street"); leadEls[index++] = GetNewXmlElement("Title", "Director of Directors"); leadEls[index++] = GetNewXmlElement("Website", "www.acmeanvils.com"); lead.Any = leadEls; lead.type = "Lead"; leads[0] = lead; SaveResult[] sr = binding.create(leads); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { Console.WriteLine("A lead was create with an id of: " + sr[j].id); } else { //there were errors during the create call, go through the errors //array and write them to the screen for (int i = 0; i < sr[j].errors.Length; i++) { //get the next error Error err = sr[j].errors[i]; Console.WriteLine("Errors were found on item " + j.ToString()); Console.WriteLine("Error code is: " + err.statusCode.ToString()); Console.WriteLine("Error message: " + err.message); } } Console.Write("\nHit return to continue..."); Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine("\nFailed to execute query succesfully, error message was: \n" + ex.Message); Console.Write("\nHit return to continue..."); Console.ReadLine(); } }
public void AddConflictItemNode(Microsoft.Samples.FeedSync.FeedItemNode i_ConflictFeedItemNode) { // Create clone of item in case it's from different document Microsoft.Samples.FeedSync.FeedItemNode ImportedConflictFeedItemNode = m_FeedItemNode.Feed.ImportFeedItemNode(i_ConflictFeedItemNode); string Key = System.String.Format ( "{0}{1}{2}", ImportedConflictFeedItemNode.SyncNode.Updates, ImportedConflictFeedItemNode.SyncNode.TopMostHistoryNode.Sequence, ImportedConflictFeedItemNode.SyncNode.TopMostHistoryNode.By ); if (ImportedConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime != null) Key += ((System.DateTime)ImportedConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime); // Check if if item already exists in either list if (m_ConflictNodeList.ContainsKey(Key)) { if (m_ConflictNodeList.ContainsKey(Key)) throw new System.ArgumentException("SyncNode::AddConflictItemNode (" + Key + ") - item already exists as conflict"); } // Create "sx:conflicts" element if necessary if (m_ConflictsNodeXmlElement == null) { string ElementName = System.String.Format ( "{0}:{1}", m_FeedItemNode.Feed.FeedSyncNamespacePrefix, Microsoft.Samples.FeedSync.Constants.CONFLICTS_ELEMENT_NAME ); m_ConflictsNodeXmlElement = m_FeedItemNode.Feed.XmlDocument.CreateElement ( ElementName, Microsoft.Samples.FeedSync.Constants.FEEDSYNC_XML_NAMESPACE_URI ); m_XmlElement.AppendChild(m_ConflictsNodeXmlElement); } // Append conflict node's element to "sx:conflicts" element m_ConflictsNodeXmlElement.AppendChild(ImportedConflictFeedItemNode.XmlElement); // Add node to list m_ConflictNodeList.Add(Key, ImportedConflictFeedItemNode); }
/// <summary> Constructs a new Generator, configured from XML.</summary> public Generator(DirectoryInfo workingDirectory, Element generateElement) : this(workingDirectory) { string value_Renamed = null; // set rendererClass field if ( (Object) (this.rendererClass = (generateElement.Attributes["renderer"] == null ? null : generateElement.Attributes["renderer"].Value)) == null) { throw new Exception("attribute renderer is required."); } // set dirName field if ( (Object) (value_Renamed = (generateElement.Attributes["dir"] == null ? null : generateElement.Attributes["dir"].Value)) != null) { this.baseDirName = value_Renamed; } // set packageName field this.packageName = (generateElement.Attributes["package"] == null ? string.Empty : generateElement.Attributes["package"].Value); // set prefix if ( (Object) (value_Renamed = (generateElement.Attributes["prefix"] == null ? null : generateElement.Attributes["prefix"].Value)) != null) { this.prefix = value_Renamed; } // set suffix if ( (Object) (value_Renamed = (generateElement.Attributes["suffix"] == null ? null : generateElement.Attributes["suffix"].Value)) != null) { this.suffix = value_Renamed; } // set extension if ( (Object) (value_Renamed = (generateElement.Attributes["extension"] == null ? null : generateElement.Attributes["extension"].Value)) != null) { this.extension = value_Renamed; } // set lowerFirstLetter value_Renamed = (generateElement.Attributes["lowerFirstLetter"] == null ? null : generateElement.Attributes["lowerFirstLetter"].Value); try { this.lowerFirstLetter = Boolean.Parse(value_Renamed); } catch { } IEnumerator iter = generateElement.SelectNodes("param").GetEnumerator(); while (iter.MoveNext()) { Element childNode = (Element) iter.Current; params_Renamed[childNode.Attributes["name"].Value] = childNode.InnerText; } }
/// <summary> /// 向XML节点加载对象数据,该函数不会重置所有的数据 /// </summary> /// <param name="myElement">XML节点对象</param> /// <returns>加载是否成功</returns> public bool FromXMLWithoutClear(System.Xml.XmlElement myElement) { if (myElement != null) { // all if (myElement.HasAttribute(c_Border_Color)) { this.BorderColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Color), DefaultColor); } if (myElement.HasAttribute(c_Border_Width)) { this.BorderWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Width), DefaultWidth); } if (myElement.HasAttribute(c_Border_Style)) { this.BorderStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Style)); } // left if (myElement.HasAttribute(c_Border_Left_Color)) { leftColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Left_Color), DefaultColor); } if (myElement.HasAttribute(c_Border_Left_Width)) { leftWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Left_Width), DefaultWidth); } if (myElement.HasAttribute(c_Border_Left_Style)) { leftStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Left_Style)); } // top if (myElement.HasAttribute(c_Border_Top_Color)) { topColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Top_Color), DefaultColor); } if (myElement.HasAttribute(c_Border_Top_Width)) { topWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Top_Width), DefaultWidth); } if (myElement.HasAttribute(c_Border_Top_Style)) { topStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Top_Style)); } // right if (myElement.HasAttribute(c_Border_Right_Color)) { rightColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Right_Color), DefaultColor); } if (myElement.HasAttribute(c_Border_Right_Width)) { rightWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Right_Width), DefaultWidth); } if (myElement.HasAttribute(c_Border_Right_Style)) { rightStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Right_Style)); } // bottom if (myElement.HasAttribute(c_Border_Bottom_Color)) { bottomColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Bottom_Color), DefaultColor); } if (myElement.HasAttribute(c_Border_Bottom_Width)) { bottomWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Bottom_Width), DefaultWidth); } if (myElement.HasAttribute(c_Border_Bottom_Style)) { bottomStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Bottom_Style)); } // 背景色 hasBackGround = myElement.HasAttribute(c_BackGround_Color); if (hasBackGround) { backColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_BackGround_Color), DefaultBackColor); } else { backColor = DefaultBackColor; } return(true); } return(false); }
/// <summary> /// 从XML节点加载对象数据,在加载对象数据前将重置所有的数据 /// </summary> /// <param name="myElement">XML节点</param> /// <returns>加载是否成功</returns> public bool FromXML(System.Xml.XmlElement myElement) { Clear(); return(this.FromXMLWithoutClear(myElement)); }
/// <summary> /// Constructor. /// </summary> /// <param name="pName">the name of the parameter /// </param> public ParameterDescriptor(System.Xml.XmlElement parameterElement, IParameterHandle pHandle) : base(parameterElement) { this.handle = pHandle; }
public override void ParseXml(System.Xml.XmlElement aNode) { base.ParseXml(aNode); FTopText = aNode.Attributes["toptext"].Value; FBottomText = aNode.Attributes["bottomtext"].Value; }
public override void ToXml(System.Xml.XmlElement aNode) { base.ToXml(aNode); aNode.SetAttribute("toptext", FTopText); aNode.SetAttribute("bottomtext", FBottomText); }
public static void SaveTo(string path) { path = System.IO.Path.GetFullPath(path); FullPath = path; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); var element = Data.IO.SaveObjectToElement(doc, "Root", Core.Root, false); var behaviorElement = Data.IO.SaveObjectToElement(doc, "Behavior", EffectBehavior, false); var cullingElement = Data.IO.SaveObjectToElement(doc, "Culling", Culling, false); var globalElement = Data.IO.SaveObjectToElement(doc, "Global", Global, false); var dynamicElement = Data.IO.SaveObjectToElement(doc, "Dynamic", Dynamic, false); System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject"); project_root.AppendChild(element); if (behaviorElement != null) { project_root.AppendChild(behaviorElement); } if (cullingElement != null) { project_root.AppendChild(cullingElement); } if (globalElement != null) { project_root.AppendChild(globalElement); } if (dynamicElement != null) { project_root.AppendChild(dynamicElement); } // recording option (this option is stored in local or global) if (recording.RecordingStorageTarget.Value == Data.RecordingStorageTargetTyoe.Local) { var recordingElement = Data.IO.SaveObjectToElement(doc, "Recording", Recording, false); if (recordingElement != null) { project_root.AppendChild(recordingElement); } } project_root.AppendChild(doc.CreateTextElement("ToolVersion", Core.Version)); project_root.AppendChild(doc.CreateTextElement("Version", 3)); project_root.AppendChild(doc.CreateTextElement("StartFrame", StartFrame)); project_root.AppendChild(doc.CreateTextElement("EndFrame", EndFrame)); project_root.AppendChild(doc.CreateTextElement("IsLoop", IsLoop.ToString())); doc.AppendChild(project_root); var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.InsertBefore(dec, project_root); doc.Save(path); IsChanged = false; if (OnAfterSave != null) { OnAfterSave(null, null); } }
/// <summary> Method loadAndMergeMetaMap.</summary> /// <returns> MultiMap /// </returns> public static MultiMap LoadAndMergeMetaMap(Element classElement, MultiMap inheritedMeta) { return MergeMetaMaps(loadMetaMap(classElement), inheritedMeta); }
private static System.Collections.ICollection parseConfig(Element doc) { ArrayList servers = new ArrayList(); NodeList serverNodes = doc.ChildNodes; for (int i = 0; i < serverNodes.Count; ++i) { Node s = serverNodes[i]; if (s.NodeType != System.Xml.XmlNodeType.Element ) { continue; } if (s.Name.ToUpper().Equals("beepd".ToUpper()) == false) { continue; } servers.Add(new Beepd((Element) s)); } return servers; }
/// <summary> /// 向XML节点保存对象数据 /// </summary> /// <param name="myElement">XML节点对象</param> /// <returns>保存是否成功</returns> public bool ToXML(System.Xml.XmlElement myElement) { if (myElement != null) { // color if (leftColor.Equals(topColor) && topColor.Equals(rightColor) && rightColor.Equals(bottomColor)) { if (leftColor.Equals(DefaultColor) == false) { myElement.SetAttribute(c_Border_Color, StringCommon.ColorToHtml(leftColor)); } } else { if (!leftColor.Equals(DefaultColor)) { myElement.SetAttribute(c_Border_Left_Color, StringCommon.ColorToHtml(leftColor)); } if (!topColor.Equals(DefaultColor)) { myElement.SetAttribute(c_Border_Top_Color, StringCommon.ColorToHtml(topColor)); } if (!rightColor.Equals(DefaultColor)) { myElement.SetAttribute(c_Border_Right_Color, StringCommon.ColorToHtml(rightColor)); } if (!bottomColor.Equals(DefaultColor)) { myElement.SetAttribute(c_Border_Bottom_Color, StringCommon.ColorToHtml(bottomColor)); } } // width if (leftWidth == topWidth && topWidth == rightWidth && rightWidth == bottomWidth) { if (leftWidth != DefaultWidth) { myElement.SetAttribute(c_Border_Width, leftWidth.ToString()); } } else { if (leftWidth != DefaultWidth) { myElement.SetAttribute(c_Border_Left_Width, leftWidth.ToString()); } if (topWidth != DefaultWidth) { myElement.SetAttribute(c_Border_Top_Width, topWidth.ToString()); } if (rightWidth != DefaultWidth) { myElement.SetAttribute(c_Border_Right_Width, rightWidth.ToString()); } if (bottomWidth != DefaultWidth) { myElement.SetAttribute(c_Border_Bottom_Width, bottomWidth.ToString()); } } // style if (leftStyle == topStyle && topStyle == rightStyle && rightStyle == bottomStyle) { if (!leftStyle.Equals(DefaultStyle)) { myElement.SetAttribute(c_Border_Style, leftStyle.ToString().ToLower()); } } else { if (leftStyle != DefaultStyle) { myElement.SetAttribute(c_Border_Left_Style, leftStyle.ToString().ToLower()); } if (topStyle != DefaultStyle) { myElement.SetAttribute(c_Border_Top_Style, topStyle.ToString().ToLower()); } if (rightStyle != DefaultStyle) { myElement.SetAttribute(c_Border_Right_Style, rightStyle.ToString().ToLower()); } if (bottomStyle != DefaultStyle) { myElement.SetAttribute(c_Border_Bottom_Style, bottomStyle.ToString().ToLower()); } } if (hasBackGround) { myElement.SetAttribute(c_BackGround_Color, StringCommon.ColorToHtml(backColor)); } return(true); } return(false); }
private SyncNode(Microsoft.Samples.FeedSync.FeedItemNode i_FeedItemNode, System.Xml.XmlElement i_SyncNodeXmlElement) { m_FeedItemNode = i_FeedItemNode; m_XmlElement = i_SyncNodeXmlElement; m_ID = m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.ID_ATTRIBUTE); m_Updates = System.Convert.ToInt32(m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.UPDATES_ATTRIBUTE)); if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.DELETED_ATTRIBUTE)) m_Deleted = (m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.DELETED_ATTRIBUTE) == "true"); if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.NO_CONFLICTS_ATTRIBUTE)) m_NoConflicts = (m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.NO_CONFLICTS_ATTRIBUTE) == "true"); string XPathQuery = System.String.Format ( "{0}:{1}", m_FeedItemNode.Feed.FeedSyncNamespacePrefix, Microsoft.Samples.FeedSync.Constants.HISTORY_ELEMENT_NAME ); System.Xml.XmlNodeList HistoryNodeList = i_SyncNodeXmlElement.SelectNodes ( XPathQuery, i_FeedItemNode.Feed.XmlNamespaceManager ); foreach (System.Xml.XmlElement HistoryNodeXmlElement in HistoryNodeList) { Microsoft.Samples.FeedSync.HistoryNode HistoryNode = Microsoft.Samples.FeedSync.HistoryNode.CreateFromXmlElement ( this, HistoryNodeXmlElement ); m_HistoryNodeList.Add(HistoryNode); } if (!m_NoConflicts) { XPathQuery = System.String.Format ( "{0}:{1}", m_FeedItemNode.Feed.FeedSyncNamespacePrefix, Microsoft.Samples.FeedSync.Constants.CONFLICTS_ELEMENT_NAME ); m_ConflictsNodeXmlElement = (System.Xml.XmlElement)i_SyncNodeXmlElement.SelectSingleNode ( XPathQuery, m_FeedItemNode.Feed.XmlNamespaceManager ); if (m_ConflictsNodeXmlElement != null) { System.Xml.XmlNodeList FeedItemXmlNodeList = m_ConflictsNodeXmlElement.SelectNodes ( m_FeedItemNode.Feed.FeedItemXPathQuery, m_FeedItemNode.Feed.XmlNamespaceManager ); foreach (System.Xml.XmlElement ConflictFeedItemNodeXmlElement in FeedItemXmlNodeList) { Microsoft.Samples.FeedSync.FeedItemNode ConflictFeedItemNode = this.CreateConflictItemNodeFromXmlElement(ConflictFeedItemNodeXmlElement); string Key = System.String.Format ( "{0}{1}{2}", ConflictFeedItemNode.SyncNode.Updates, ConflictFeedItemNode.SyncNode.TopMostHistoryNode.Sequence, ConflictFeedItemNode.SyncNode.TopMostHistoryNode.By ); if (ConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime != null) Key += ((System.DateTime)ConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime); if (!m_ConflictNodeList.ContainsKey(Key)) m_ConflictNodeList.Add(Key, ConflictFeedItemNode); } } } }
/// <summary> /// 增量方式向XML节点,本函数只是向XML节点保存和另一个边框对象的不相同的参数设置 /// 以减少保存的数据量 /// </summary> /// <param name="myElement">XML节点</param> /// <param name="b">作为参照物的边框对象</param> /// <returns>保存是否成功</returns> public bool ToXMLEx(System.Xml.XmlElement myElement, ZYTextBorder b) { if (myElement != null && b != null && b != this) { // color if (leftColor.Equals(topColor) && topColor.Equals(rightColor) && rightColor.Equals(bottomColor)) { if (leftColor.Equals(DefaultColor) == false && leftColor.Equals(b.leftColor) == false) { myElement.SetAttribute(c_Border_Color, StringCommon.ColorToHtml(leftColor)); } } else { if (!(leftColor.Equals(DefaultColor) || leftColor.Equals(b.leftColor))) { myElement.SetAttribute(c_Border_Left_Color, StringCommon.ColorToHtml(leftColor)); } if (!(topColor.Equals(DefaultColor) || topColor.Equals(b.topColor))) { myElement.SetAttribute(c_Border_Top_Color, StringCommon.ColorToHtml(topColor)); } if (!(rightColor.Equals(DefaultColor) || rightColor.Equals(b.rightColor))) { myElement.SetAttribute(c_Border_Right_Color, StringCommon.ColorToHtml(rightColor)); } if (!(bottomColor.Equals(DefaultColor) || bottomColor.Equals(b.bottomColor))) { myElement.SetAttribute(c_Border_Bottom_Color, StringCommon.ColorToHtml(bottomColor)); } } // width if (leftWidth == topWidth && topWidth == rightWidth && rightWidth == bottomWidth) { if (leftWidth != DefaultWidth && leftWidth != b.leftWidth) { myElement.SetAttribute(c_Border_Width, leftWidth.ToString()); } } else { if (leftWidth != DefaultWidth && leftWidth != b.leftWidth) { myElement.SetAttribute(c_Border_Left_Width, leftWidth.ToString()); } if (topWidth != DefaultWidth && topWidth != b.topWidth) { myElement.SetAttribute(c_Border_Top_Width, topWidth.ToString()); } if (rightWidth != DefaultWidth && rightWidth != b.rightWidth) { myElement.SetAttribute(c_Border_Right_Width, rightWidth.ToString()); } if (bottomWidth != DefaultWidth && bottomWidth != b.bottomWidth) { myElement.SetAttribute(c_Border_Bottom_Width, bottomWidth.ToString()); } } // style if (leftStyle == topStyle && topStyle == rightStyle && rightStyle == bottomStyle) { if (!leftStyle.Equals(DefaultStyle) && !leftStyle.Equals(b.leftStyle)) { myElement.SetAttribute(c_Border_Style, leftStyle.ToString().ToLower()); } } else { if (leftStyle != DefaultStyle && leftStyle != b.leftStyle) { myElement.SetAttribute(c_Border_Left_Style, leftStyle.ToString().ToLower()); } if (topStyle != DefaultStyle && topStyle != b.topStyle) { myElement.SetAttribute(c_Border_Top_Style, topStyle.ToString().ToLower()); } if (rightStyle != DefaultStyle && rightStyle != b.rightStyle) { myElement.SetAttribute(c_Border_Right_Style, rightStyle.ToString().ToLower()); } if (bottomStyle != DefaultStyle && bottomStyle != b.bottomStyle) { myElement.SetAttribute(c_Border_Bottom_Style, bottomStyle.ToString().ToLower()); } } if (hasBackGround == true && hasBackGround != b.hasBackGround && backColor != b.backColor) { myElement.SetAttribute(c_BackGround_Color, StringCommon.ColorToHtml(backColor)); } return(true); } return(false); }
private void createAccountSample() { //Verify that we are already authenticated, if not //call the login function to do so if (!loggedIn) { if (!login()) return; } try { apex.sObject account; sObject[] accs = new sObject[2]; for (int j = 0; j < accs.Length; j++) { account = new apex.sObject(); System.Xml.XmlElement[] acct = new System.Xml.XmlElement[14]; int index = 0; if (accounts == null) acct[index++] = GetNewXmlElement("AccountNumber", "0000000"); else acct[index++] = GetNewXmlElement("AccountNumber", "000000" + (accounts.Length + 1)); //account.setAnnualRevenue(new java.lang.Double(4000000.0)); acct[index++] = GetNewXmlElement("BillingCity", "Wichita"); acct[index++] = GetNewXmlElement("BillingCountry", "US"); acct[index++] = GetNewXmlElement("BillingState", "KA"); acct[index++] = GetNewXmlElement("BillingStreet", "4322 Haystack Boulevard"); acct[index++] = GetNewXmlElement("BillingPostalCode", "87901"); acct[index++] = GetNewXmlElement("Description", "World class hay makers."); acct[index++] = GetNewXmlElement("Fax", "555.555.5555"); acct[index++] = GetNewXmlElement("Industry", "Farming"); acct[index++] = GetNewXmlElement("Name", "Golden Straw"); acct[index++] = GetNewXmlElement("NumberOfEmployees", "40"); acct[index++] = GetNewXmlElement("Ownership", "Privately Held"); acct[index++] = GetNewXmlElement("Phone", "666.666.6666"); acct[index++] = GetNewXmlElement("Website", "www.oz.com"); account.type = "Account"; account.Any = acct; accs[j] = account; } //create the object(s) by sending the array to the web service SaveResult[] sr = binding.create(accs); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { Console.Write(System.Environment.NewLine + "An account was create with an id of: " + sr[j].id); //save the account ids in a class array if (accounts == null) { accounts = new string[] { sr[j].id }; } else { string[] tempAccounts = null; tempAccounts = new string[accounts.Length + 1]; for (int i = 0; i < accounts.Length; i++) tempAccounts[i] = accounts[i]; tempAccounts[accounts.Length] = sr[j].id; accounts = tempAccounts; } } else { //there were errors during the create call, go through the errors //array and write them to the screen for (int i = 0; i < sr[j].errors.Length; i++) { //get the next error Error err = sr[j].errors[i]; Console.WriteLine("Errors were found on item " + j.ToString()); Console.WriteLine("Error code is: " + err.statusCode.ToString()); Console.WriteLine("Error message: " + err.message); } } } Console.WriteLine("\nHit return to continue..."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("\nFailed to create account, error message was: \n" + ex.Message); Console.Write("\nHit return to continue..."); Console.ReadLine(); } }
public bool LoadInertial(System.Xml.XmlElement element) { return(false); //TODO }
public FieldProperty(Element element, MappingElement parent, string name, ClassName type, bool nullable, bool id, bool generated, MultiMap metaattribs) : base(element, parent) { InitWith(name, type, type, nullable, id, generated, null, null, metaattribs); }
/// <summary> /// 创建FID表填充信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonXGenerateFID_Click(object sender, EventArgs e) { this._DesDSName = comboBoxEx2.Text; //构建FID if (comboBoxEx1.SelectedIndex == 0) //本地辅助库 { if (File.Exists(textBoxXServer.Text)) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据文件已存在!\n" + textBoxXServer.Text); return; } //创建mdb文件 ADOX.Catalog AdoxCatalog = new ADOX.Catalog(); AdoxCatalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + textBoxXServer.Text + ";"); ADOX.TableClass tbl = new ADOX.TableClass(); tbl.ParentCatalog = AdoxCatalog; tbl.Name = "FID记录表"; ADOX.ColumnClass col = new ADOX.ColumnClass(); col.ParentCatalog = AdoxCatalog; col.Type = ADOX.DataTypeEnum.adInteger; // 必须先设置字段类型 col.Name = "GOFID"; col.Properties["Jet OLEDB:Allow Zero Length"].Value = false; col.Properties["AutoIncrement"].Value = true; tbl.Columns.Append(col, ADOX.DataTypeEnum.adInteger, 0); col = new ADOX.ColumnClass(); col.ParentCatalog = AdoxCatalog; col.Type = ADOX.DataTypeEnum.adLongVarWChar; col.Name = "FCNAME"; col.Properties["Jet OLEDB:Allow Zero Length"].Value = false; tbl.Columns.Append(col, ADOX.DataTypeEnum.adInteger, 0); col = new ADOX.ColumnClass();//增加一个本地OID字段 col.ParentCatalog = AdoxCatalog; col.Type = ADOX.DataTypeEnum.adInteger; col.Name = "OID"; col.Properties["Jet OLEDB:Allow Zero Length"].Value = false; tbl.Columns.Append(col, ADOX.DataTypeEnum.adInteger, 0); AdoxCatalog.Tables.Append(tbl); string pConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + textBoxXServer.Text + ";Persist Security Info=False;"; GeoFIDCreator FIDCreator = new GeoFIDCreator(this._UpadateDesWorkspace, pConn, FIDDBType.access); FIDCreator.DatasetName = this._DesDSName; if (FIDCreator.CreateFID("FID记录表") == false) { SysCommon.Error.ErrorHandle.ShowInform("提示", "创建业务信息表失败!"); return; } } else if (comboBoxEx1.SelectedIndex == 1) //远程辅助库 { string Conn = "Data Source=" + textBoxXServer.Text + ";User Id=" + textBoxXUser.Text + ";Password="******";"; GeoFIDCreator FIDCreator = new GeoFIDCreator(this._UpadateDesWorkspace, Conn, FIDDBType.oracle); FIDCreator.DatasetName = this._DesDSName; if (FIDCreator.CreateFID("FID记录表") == false) { SysCommon.Error.ErrorHandle.ShowInform("提示", "创建业务信息表失败!"); return; } } ///将FID记录表的访问方式写入xml文档对象 /// DevComponents.AdvTree.Node pCurNode = m_Hook.ProjectTree.SelectedNode; ///获得树图上选择的工程节点 string pProjectname = pCurNode.Name; System.Xml.XmlNode Projectnode = m_Hook.DBXmlDocument.SelectSingleNode("工程管理/工程[@名称='" + pProjectname + "']"); System.Xml.XmlElement ProjectNodeElement = Projectnode as System.Xml.XmlElement; System.Xml.XmlElement ProjectConnEle = ProjectNodeElement.SelectSingleNode(".//FID记录表/连接信息") as System.Xml.XmlElement; System.Xml.XmlElement ProjectDBDSConnEle = ProjectNodeElement.SelectSingleNode(".//现势库/连接信息/库体") as System.Xml.XmlElement; ProjectDBDSConnEle.SetAttribute("名称", comboBoxEx2.Text); ///设置数据库连接类型 /// if (this.comboBoxEx1.SelectedIndex == 0) { ProjectConnEle.SetAttribute("类型", "Access"); } else if (this.comboBoxEx1.SelectedIndex == 1) { ProjectConnEle.SetAttribute("类型", "Oracle"); } ///设置具体连接方式 /// if (this.comboBoxEx1.SelectedIndex == 0) { string text = textBoxXServer.Text; ProjectConnEle.SetAttribute("数据库", text); } else if (this.comboBoxEx1.SelectedIndex == 1) { ProjectConnEle.SetAttribute("数据库", textBoxXServer.Text); ProjectConnEle.SetAttribute("用户", textBoxXUser.Text); ProjectConnEle.SetAttribute("密码", textBoxXPassword.Text); } m_Hook.DBXmlDocument.Save(ModData.v_projectXML); //释放类成员 if (_UpadateDesWorkspace != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(_UpadateDesWorkspace); } SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "业务维护信息初始化完成!"); this.Close(); }
public override void SaveToXml(System.Xml.XmlElement xmlEl, System.Xml.XmlDocument doc) { base.SaveToXml(xmlEl, doc); xmlEl.SetAttribute("T", TypeString); }
public void TestTasksListXmlGetAttributes() { string xml = @"<roar tick=""135577684654""> <tasks> <list status=""ok""> <task ikey=""dungeon_crawl""> <label>Dungeon crawl</label> <description>Go into the pits</description> <location>Australia</location> <tags> <tag value=""protect""/> <tag value=""monsters""/> </tags> <costs> <item_cost ikey=""mariner"" number_required=""3"" ok=""false"" reason=""requires mariner(3)""/> <stat_cost type=""currency"" ikey=""premium_currency"" value=""477"" ok=""true""/> </costs> <rewards> <grant_stat type=""currency"" ikey=""premium_currency"" value=""453""/> <grant_xp value=""234""/> <random_choice> <choice weight=""1""> <modifier> <grant_stat type=""currency"" ikey=""dragon_points"" value=""25""/> </modifier> </choice> <choice weight=""99""> <modifier> <grant_stat_range type=""currency"" ikey=""dragon_points"" min=""3"" max=""6""/> </modifier> </choice> </random_choice> </rewards> <mastery level=""2"" progress=""5""/> <requires> <item_requirement ikey=""talisman"" number_required=""2"" ok=""false"" reason=""requires talisman(2)""/> </requires> </task> <task ikey=""journey""> <label>Journey</label> <description>Travel there and back.</description> <location>Australia</location> <tags/> <mastery level=""3"" progress=""6""/> </task> </list> </tasks> </roar>" ; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Roar.DataConversion.Responses.Tasks.List list_parser = new Roar.DataConversion.Responses.Tasks.List(); ListResponse response = list_parser.Build(nn); Assert.IsNotNull(response); Assert.IsNotNull(response.tasks); Assert.AreEqual(response.tasks.Count, 2); Assert.IsNotNull(response.tasks[0]); Assert.AreEqual(response.tasks[0].ikey, "dungeon_crawl"); Assert.AreEqual(response.tasks[0].label, "Dungeon crawl"); Assert.AreEqual(response.tasks[0].description, "Go into the pits"); Assert.AreEqual(response.tasks[0].location, "Australia"); Assert.AreEqual(response.tasks[0].costs.Count, 2); Assert.AreEqual((response.tasks[0].costs[0] as Roar.DomainObjects.Costs.Item).reason, "requires mariner(3)"); Assert.AreEqual(response.tasks[0].rewards.Count, 3); Assert.AreEqual((response.tasks[0].rewards[1] as Roar.DomainObjects.Modifiers.GrantXp).value, 234); Assert.AreEqual(response.tasks[0].requirements.Count, 1); Assert.AreEqual((response.tasks[0].requirements[0] as Roar.DomainObjects.Requirements.Item).reason, "requires talisman(2)"); Assert.AreEqual(response.tasks[0].tags.Count, 2); Assert.AreEqual(response.tasks[0].tags[0], "protect"); Assert.AreEqual(response.tasks[0].tags[1], "monsters"); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices.Count, 2); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[0].weight, 1); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[0].modifiers.Count, 1); Assert.AreEqual(((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[0].modifiers[0] as Roar.DomainObjects.Modifiers.GrantStat).ikey, "dragon_points"); Assert.AreEqual(((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[0].modifiers[0] as Roar.DomainObjects.Modifiers.GrantStat).value, 25); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[0].requirements.Count, 0); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[1].weight, 99); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[1].modifiers.Count, 1); Assert.AreEqual((response.tasks[0].rewards[2] as Roar.DomainObjects.Modifiers.RandomChoice).choices[1].requirements.Count, 0); Assert.AreEqual(response.tasks[0].mastery_level, 2); Assert.AreEqual(response.tasks[0].mastery_progress, 5); Assert.IsNotNull(response.tasks[1]); Assert.AreEqual(response.tasks[1].costs.Count, 0); Assert.AreEqual(response.tasks[1].rewards.Count, 0); Assert.AreEqual(response.tasks[1].requirements.Count, 0); Assert.AreEqual(response.tasks[1].tags.Count, 0); }
//New PES public DataReturn CloneAttachmentFile(string ParentId, string AttachmentName, string Xml) { DataReturn dr = new DataReturn(); string id = ""; String soqlQuery = "SELECT Id FROM Attachment where ParentId='" + ParentId + "' and Name='" + AttachmentName + "' order by LastModifiedDate desc limit 1"; try { QueryResult qr = _binding.query(soqlQuery); if (qr.size > 0) { sObject[] records = qr.records; for (int i = 0; i < qr.records.Length; i++) { id = records[i].Any[0].InnerText; } } } catch (Exception ex) { dr.success = false; dr.errormessage = ex.Message; } sObject attach = new sObject(); attach.type = "Attachment"; System.Xml.XmlElement[] o; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); SaveResult[] sr; if (id == "") { // Create the attacchments fields o = new System.Xml.XmlElement[4]; doc = new System.Xml.XmlDocument(); o[0] = doc.CreateElement("Name"); o[0].InnerText = AttachmentName; o[1] = doc.CreateElement("isPrivate"); o[1].InnerText = "false"; o[2] = doc.CreateElement("ParentId"); o[2].InnerText = ParentId; o[3] = doc.CreateElement("Body"); byte[] data = Convert.FromBase64String(Xml); o[3].InnerText = Convert.ToBase64String(data); attach.Any = o; sr = _binding.create(new sObject[] { attach }); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { id = sr[j].id; } else { for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i]; } } } } else { // Update the attacchments fields doc = new System.Xml.XmlDocument(); o = new System.Xml.XmlElement[1]; o[0] = doc.CreateElement("Body"); // o[0].InnerText = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(Xml)); byte[] data = Convert.FromBase64String(Xml); o[0].InnerText = Convert.ToBase64String(data); attach.Any = o; attach.Id = id; sr = _binding.update(new sObject[] { attach }); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { id = sr[j].id; } else { for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i]; } } } } dr.id = id; return dr; }
public override void RestoreLayout(System.Xml.XmlElement contentElement) { base.RestoreLayout(contentElement); }
public static void ReplaceElement(System.Xml.XmlElement inputElement, System.Security.Cryptography.Xml.EncryptedData encryptedData, bool content) { }
internal XMLUtils(string filePath) { _doc = new System.Xml.XmlDocument(); _doc.Load(filePath); _root = _doc.DocumentElement; }
/// <summary> Load meta attributes from jdom element into a MultiMap. /// /// </summary> /// <returns> MultiMap /// </returns> protected internal static MultiMap loadMetaMap(Element element) { MultiMap result = new MultiHashMap(); SupportClass.ListCollectionSupport metaAttributeList = new SupportClass.ListCollectionSupport(); metaAttributeList.AddAll(element.SelectNodes("urn:meta", CodeGenerator.nsmgr)); for (IEnumerator iter = metaAttributeList.GetEnumerator(); iter.MoveNext();) { Element metaAttrib = (Element) iter.Current; // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs. string attribute = (metaAttrib.Attributes["attribute"] == null ? string.Empty : metaAttrib.Attributes["attribute"].Value); string value_Renamed = metaAttrib.InnerText; string inheritStr = (metaAttrib.Attributes["inherit"] == null ? null : metaAttrib.Attributes["inherit"].Value); bool inherit = true; if ((Object) inheritStr != null) { try { inherit = Boolean.Parse(inheritStr); } catch { } } MetaAttribute ma = new MetaAttribute(value_Renamed, inherit); if (result[attribute] == null) result[attribute] = new SupportClass.ListCollectionSupport(); ((SupportClass.ListCollectionSupport) result[attribute]).Add(ma); } return result; }
public System.Threading.Tasks.Task XmlMethodAsync(System.Xml.XmlElement xml) { return(base.Channel.XmlMethodAsync(xml)); }
private void button1_Click(object sender, EventArgs e) { try { mypartner.SforceService binding = new mypartner.SforceService(); mypartner.LoginResult lr = binding.login("*****@*****.**", "xyz6854XhuVzAcbHWENCYLHNQX41z943"); if (!lr.passwordExpired) { binding.Url = lr.serverUrl; binding.SessionHeaderValue = new mypartner.SessionHeader(); binding.SessionHeaderValue.sessionId = lr.sessionId; mypartner.sObject[] accs = new mypartner.sObject[1]; mypartner.sObject sObj = new mypartner.sObject(); System.Xml.XmlElement[] acct = new System.Xml.XmlElement[14]; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); acct[0] = doc.CreateElement("Name"); acct[0].InnerText = txtName.Text.Trim(); acct[1] = doc.CreateElement("FirstPlayer__c"); acct[1].InnerText = txtFirstPlayer.Text; acct[2] = doc.CreateElement("SecondPlayer__c"); acct[2].InnerText = txtSecondPlayer.Text; acct[3] = doc.CreateElement("MoveList__c"); acct[3].InnerText = txtMoveList.Text; acct[4] = doc.CreateElement("Description__c"); acct[4].InnerText = txtDescription.Text; acct[5] = doc.CreateElement("Event__c"); acct[5].InnerText = txtEvent.Text; acct[6] = doc.CreateElement("Round__c"); acct[6].InnerText = txtRound.Text; acct[7] = doc.CreateElement("PlayDate__c"); acct[7].InnerText = txtPlayDate.Text; acct[8] = doc.CreateElement("RedFirst__c"); acct[8].InnerText = txtRed.Text; acct[9] = doc.CreateElement("Result__c"); acct[9].InnerText = txtResult.Text; acct[10] = doc.CreateElement("SharedBy__c"); acct[10].InnerText = txtSharedBy.Text; acct[11] = doc.CreateElement("SharedToken__c"); acct[11].InnerText = txtSharedToken.Text; acct[12] = doc.CreateElement("Source__c"); acct[12].InnerText = txtSource.Text; acct[13] = doc.CreateElement("XiangqiType__c"); acct[13].InnerText = txtXiangqiType.Text; sObj.type = "Xiangqi__c"; sObj.Any = acct; accs[0] = sObj; mypartner.SaveResult[] sr = binding.create(accs); for (int k = 0; k < sr.Length; k++) { if (sr[k].success) { } else { } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void TestViewPlayerXmlGetAttributes() { string xml = @"<roar tick=""125555206993""> <admin> <view_player status=""ok""> <attribute ikey=""id"" value=""2059428086"" type=""special""/> <attribute ikey=""xp"" value=""0"" type=""special""/> <attribute ikey=""level"" value=""1"" type=""special""/> <attribute ikey=""facebook_uid"" value=""0"" type=""special""/> <attribute ikey=""name"" value=""foo"" type=""special""/> <attribute ikey=""attack"" value=""10"" type=""core"" label=""Attack""/> <attribute ikey=""defence"" value=""10"" type=""core"" label=""Core Defence""/> <attribute ikey=""hit"" value=""10"" type=""core"" label=""Hit Power""/> <attribute ikey=""avoid"" value=""10"" type=""core"" label=""avoid""/> <attribute ikey=""health"" value=""100"" type=""resource"" max=""123"" min=""0"" regen_every=""1000"" label=""Health""/> <attribute ikey=""energy"" value=""20"" type=""resource"" max=""123"" min=""0"" regen_every=""1000"" label=""Energy""/> <attribute ikey=""stamina"" value=""5"" type=""resource"" max=""123"" min=""0"" regen_every=""1000"" label=""Stamina""/> <attribute ikey=""profile_points"" value=""0"" type=""currency"" label=""Monkey Power Points""/> <attribute ikey=""cash"" value=""100"" type=""currency"" lable=""cash""/> <attribute ikey=""premium_currency"" value=""5"" type=""currency"" label=""Bear Dollars""/> <items> <item id=""1001"" ikey=""item_ikey"" count=""1"" label=""A Label"" type=""thing"" description=""A thing"" consumable=""false"" sellable=""true"" equipped=""false""> <stats> <equip_attribute ikey=""health_max"" value=""100""/> <grant_stat ikey=""cash"" value=""100""/> <grant_stat ikey=""energy"" value=""-5""/> </stats> <properties> <property ikey=""size"" value=""3""/> </properties> <tags> <tag value=""weapon""/> </tags> </item> </items> </view_player> </admin> </roar>" ; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Roar.DataConversion.Responses.Admin.ViewPlayer view_player_parser = new Roar.DataConversion.Responses.Admin.ViewPlayer(); ViewPlayerResponse response = view_player_parser.Build(nn); Assert.AreEqual(response.player.id, "2059428086"); Assert.AreEqual(response.player.name, "foo"); Assert.AreEqual(response.player.xp.value, 0); Assert.AreEqual(response.player.level, 1); Assert.AreEqual(response.player.attributes.Count, 11); Assert.AreEqual(response.player.attributes["facebook_uid"].value, "0"); Assert.AreEqual(response.player.attributes["facebook_uid"].type, "special"); Assert.AreEqual(response.player.attributes["hit"].label, "Hit Power"); Assert.AreEqual(response.items.Count, 1); Assert.AreEqual(response.items[0].stats.Count, 3); Assert.AreEqual(response.items[0].stats[0].ikey, "health_max"); Assert.AreEqual(response.items[0].stats[1].ikey, "cash"); Assert.AreEqual(response.items[0].stats[2].ikey, "energy"); Assert.AreEqual(response.items[0].properties.Count, 1); Assert.AreEqual(response.items[0].properties[0].ikey, "size"); Assert.AreEqual(response.items[0].tags.Count, 1); Assert.AreEqual(response.items[0].tags[0], "weapon"); }
/// <summary> Parses the beepd element in the configuration file and loads the /// classes for the specified profiles. /// /// </summary> /// <param name="serverConfig"><beepd> configuration element. /// </param> private Beepd(Element serverConfig) { reg = new ProfileRegistry(); if (serverConfig.HasAttribute("port") == false) { throw new System.Exception("Invalid configuration, no port specified"); } port = System.Int32.Parse(serverConfig.GetAttribute("port")); // Parse the list of profile elements. NodeList profiles = serverConfig.GetElementsByTagName("profile"); for (int i = 0; i < profiles.Count; ++i) { if (profiles[i].NodeType != System.Xml.XmlNodeType.Element) { continue; } Element profile = (Element) profiles[i]; if (profile.Name.ToUpper().Equals("profile".ToUpper()) == false) { continue; } string uri; string className; //string requiredProperites; //string tuningProperties; if (profile.HasAttribute("uri") == false) { throw new System.Exception("Invalid configuration, no uri specified"); } uri = profile.GetAttribute("uri"); if (profile.HasAttribute("class") == false) { throw new System.Exception("Invalid configuration, no class " + "specified for profile " + uri); } className = profile.GetAttribute("class"); // parse the parameter elements into a ProfileConfiguration ProfileConfiguration profileConfig = parseProfileConfig(profile.GetElementsByTagName("parameter")); // load the profile class IProfile p; try { p = (IProfile) new beepcore.beep.profile.echo.EchoProfile(); //SupportClass.CreateNewInstance(System.Type.GetType(className)); //p = (IProfile) Activator.CreateInstance(Type.GetType(className, true, true)); } catch (System.InvalidCastException) { throw new System.Exception("class " + className + " does not " + "implement the " + "beepcore.beep.profile.Profile " + "interface"); } catch (System.Exception e) { throw new System.Exception("Class " + className + " not found - " + e.ToString()); } SessionTuningProperties tuning = null; if (profile.HasAttribute("tuning")) { string tuningString = profile.GetAttribute("tuning"); System.Collections.Hashtable hash = new System.Collections.Hashtable(); string[] tokens = tuningString.Split(":=".ToCharArray()); for(int tki=0; tki+1<tokens.Length; tki+=2) { string parameter = tokens[tki]; string paramvalue = tokens[tki+1]; hash[parameter] = paramvalue; } tuning = new SessionTuningProperties(hash); } // Initialize the profile and add it to the advertised profiles reg.addStartChannelListener(uri, p.Init(uri, profileConfig), tuning); } thread = new Thread(new ThreadStart(this.ThreadProc)); }
public void TestViewPlayerParseMechanics() { string xml = @"<roar tick=""125555206993""> <admin> <view_player status=""ok""> <attribute ikey=""id"" value=""2059428086"" type=""special""/> <attribute ikey=""xp"" value=""0"" type=""special""/> <attribute ikey=""level"" value=""1"" type=""special""/> <attribute ikey=""facebook_uid"" value=""0"" type=""special""/> <attribute ikey=""name"" value=""foo"" type=""special""/> <attribute ikey=""attack"" value=""10"" type=""core"" label=""Attack""/> <attribute ikey=""defence"" value=""10"" type=""core"" label=""Core Defence""/> <attribute ikey=""hit"" value=""10"" type=""core"" label=""Hit Power""/> <attribute ikey=""avoid"" value=""10"" type=""core"" label=""avoid""/> <attribute ikey=""health"" value=""100"" type=""resource"" max=""123"" min=""0"" regen_every=""1000"" label=""Health""/> <attribute ikey=""energy"" value=""20"" type=""resource"" max=""123"" min=""0"" regen_every=""1000"" label=""Energy""/> <attribute ikey=""stamina"" value=""5"" type=""resource"" max=""123"" min=""0"" regen_every=""1000"" label=""Stamina""/> <attribute ikey=""profile_points"" value=""0"" type=""currency"" label=""Monkey Power Points""/> <attribute ikey=""cash"" value=""100"" type=""currency"" lable=""cash""/> <attribute ikey=""premium_currency"" value=""5"" type=""currency"" label=""Bear Dollars""/> <items> <item id=""1001"" ikey=""item_ikey"" count=""1"" label=""A Label"" type=""thing"" description=""A thing"" consumable=""false"" sellable=""true"" equipped=""false""> <stats> <equip_attribute ikey=""health_max"" value=""100""/> <grant_stat ikey=""cash"" value=""100""/> <grant_stat ikey=""energy"" value=""-5""/> </stats> <properties> <property ikey=""size"" value=""3""/> </properties> <tags> <tag value=""weapon""/> </tags> </item> </items> </view_player> </admin> </roar>" ; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Mockery mockery = new Mockery(); Roar.DataConversion.IXCRMParser ixcrm_parser = mockery.NewMock <Roar.DataConversion.IXCRMParser>(); Roar.DataConversion.Responses.Admin.ViewPlayer view_player_parser = new Roar.DataConversion.Responses.Admin.ViewPlayer(); view_player_parser.ixcrm_parser = ixcrm_parser; List <Roar.DomainObjects.ItemStat> stat_list = new List <Roar.DomainObjects.ItemStat>(); List <Roar.DomainObjects.Modifier> modifier_list = new List <Roar.DomainObjects.Modifier>(); List <string> tag_list = new List <string>(); Expect.Once.On(ixcrm_parser).Method("ParseItemStatList").With(nn.SelectSingleNode("./admin/view_player/items/item/stats")).Will(Return.Value(stat_list)); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(nn.SelectSingleNode("./amdin/view_player/items/item/price")).Will(Return.Value(modifier_list)); Expect.Once.On(ixcrm_parser).Method("ParseTagList").With(nn.SelectSingleNode("./admin/view_player/items/item/tags")).Will(Return.Value(tag_list)); ViewPlayerResponse response = view_player_parser.Build(nn); mockery.VerifyAllExpectationsHaveBeenMet(); Assert.AreEqual(response.player.id, "2059428086"); Assert.AreEqual(response.player.name, "foo"); Assert.AreEqual(response.player.xp.value, 0); Assert.AreEqual(response.player.level, 1); Assert.AreEqual(response.player.attributes.Count, 11); Assert.AreEqual(response.player.attributes["facebook_uid"].value, "0"); Assert.AreEqual(response.player.attributes["facebook_uid"].type, "special"); Assert.AreEqual(response.player.attributes["hit"].label, "Hit Power"); Assert.AreEqual(response.items.Count, 1); Assert.AreEqual(response.items[0].stats, stat_list); Assert.AreEqual(response.items[0].price, modifier_list); Assert.AreEqual(response.items[0].tags, tag_list); }
public void CreateFromXml(System.Xml.XmlElement element) { currentElement = element; foreach (System.Xml.XmlElement child in element.ChildNodes) { if (child.Name.Equals("shapeFile")) { provider.LoadShapeFile(child.InnerText); } } }
public SignedXml(System.Xml.XmlElement elem) { }
public void RemoveAllConflictItemNodes() { if (m_ConflictNodeList.Count == 0) return; // Delete "sx:conflicts" element m_ConflictsNodeXmlElement.ParentNode.RemoveChild(m_ConflictsNodeXmlElement); m_ConflictsNodeXmlElement = null; // Empty node list m_ConflictNodeList.Clear(); }
protected virtual bool IsTargetElement(System.Xml.XmlElement inputElement, string idValue) { throw null; }
public SerializeNodeEventArgs(Node node, System.Xml.XmlElement itemXmlElement, System.Xml.XmlElement customXmlElement) { this.Node = node; this.ItemXmlElement = itemXmlElement; this.CustomXmlElement = customXmlElement; }
public override void LoadXml(System.Xml.XmlElement value) { }
private void createContactSample() { //Verify that we are already authenticated, if not //call the login function to do so if (!loggedIn) { if (!login()) return; } try { sObject[] cons = new sObject[1]; apex.sObject contact; for (int j = 0; j < cons.Length; j++) { contact = new apex.sObject(); int index = 0; System.Xml.XmlElement[] cont = new System.Xml.XmlElement[17]; if (accounts != null) { cont = new System.Xml.XmlElement[cont.Length + 1]; cont[index++] = GetNewXmlElement("AccountId", accounts[0]); } cont[index++] = GetNewXmlElement("AssistantName", "Jane"); cont[index++] = GetNewXmlElement("AssistantPhone", "777.777.7777"); cont[index++] = GetNewXmlElement("Department", "Purchasing"); cont[index++] = GetNewXmlElement("Description", "International IT Purchaser"); cont[index++] = GetNewXmlElement("Email", "*****@*****.**"); cont[index++] = GetNewXmlElement("Fax", "555.555.5555"); cont[index++] = GetNewXmlElement("MailingCity", "San Mateo"); cont[index++] = GetNewXmlElement("MailingCountry", "US"); cont[index++] = GetNewXmlElement("MailingState", "CA"); cont[index++] = GetNewXmlElement("MailingStreet", "1129 B Street"); cont[index++] = GetNewXmlElement("MailingPostalCode", "94105"); cont[index++] = GetNewXmlElement("MobilePhone", "888.888.8888"); cont[index++] = GetNewXmlElement("FirstName", "Joe"); cont[index++] = GetNewXmlElement("LastName", "Blow"); cont[index++] = GetNewXmlElement("Salutation", "Mr."); cont[index++] = GetNewXmlElement("Phone", "999.999.9999"); cont[index++] = GetNewXmlElement("Title", "Purchasing Director"); contact.Any = cont; contact.type = "Contact"; cons[j] = contact; } SaveResult[] sr = binding.create(cons); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { Console.WriteLine("A contact was create with an id of: " + sr[j].id); if (accounts != null) Console.WriteLine(" - the contact was associated with the account you created with an id of " + accounts[0] + "."); if (contacts == null) { contacts = new string[] { sr[j].id }; } else { string[] tempContacts = null; tempContacts = new string[contacts.Length + 1]; for (int i = 0; i < contacts.Length; i++) tempContacts[i] = contacts[i]; tempContacts[contacts.Length] = sr[j].id; contacts = tempContacts; } } else { //there were errors during the create call, go through the errors //array and write them to the screen for (int i = 0; i < sr[j].errors.Length; i++) { //get the next error Error err = sr[j].errors[i]; Console.WriteLine("Errors were found on item " + j.ToString()); Console.WriteLine("Error code is: " + err.statusCode.ToString()); Console.WriteLine("Error message: " + err.message); } } Console.Write("\nHit return to continue..."); Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine("\nFailed to execute query succesfully, error message was: \n" + ex.Message); Console.Write("\nHit return to continue..."); Console.ReadLine(); } }
public RequestResult(System.Xml.XmlElement in_data, int in_code, string in_msg) { data = in_data; code = in_code; msg = in_msg; }
private void createTaskSample() { //Verify that we are already authenticated, if not //call the login function to do so if (!loggedIn) { if (!login()) return; } try { //create an array to create 4 items in one call sObject[] taskarray = new sObject[3]; for (int x = 0; x < taskarray.Length; x++) { //Declare a new task object to hold our values apex.sObject task = new apex.sObject(); int index = 0; System.Xml.XmlElement[] tsk = new System.Xml.XmlElement[5]; if (contacts != null) tsk = new System.Xml.XmlElement[tsk.Length + 1]; if (accounts != null) tsk = new System.Xml.XmlElement[tsk.Length + 1]; //make sure we get some errors on records 3 and 4 if (x > 1) { tsk = new System.Xml.XmlElement[tsk.Length + 1]; tsk[index++] = GetNewXmlElement("OwnerId", "DSF:LJKSDFLKJ"); } //Set the appropriate values on the task tsk[index++] = GetNewXmlElement("ActivityDate", GetDateTimeSerialized(DateTime.Now)); tsk[index++] = GetNewXmlElement("Description", "Get in touch with this person"); tsk[index++] = GetNewXmlElement("Priority", "Normal"); tsk[index++] = GetNewXmlElement("Status", "Not Started"); tsk[index++] = GetNewXmlElement("Subject", "Setup Call"); //The two lines below illustrate associating an object with another object. If //we have created an account and/or a contact prior to creating the task, we will //just grab the first account and/or contact id and place it in the appropriate //reference field. WhoId can be a reference to a contact or a lead or a user. //WhatId can be a reference to an account, campaign, case, contract or opportunity if (contacts != null) tsk[index++] = GetNewXmlElement("WhoId", contacts[0]); if (accounts != null) tsk[index++] = GetNewXmlElement("WhatId", accounts[0]); task.type = "Task"; taskarray[x] = task; } //call the create method passing the array of tasks as sobjects SaveResult[] sr = binding.create(taskarray); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { Console.WriteLine("A task was create with an id of: " + sr[j].id); if (accounts != null) Console.WriteLine(" - the task was associated with the account you created with an id of " + accounts[0] + "."); if (tasks == null) { tasks = new string[] { sr[j].id }; } else { string[] tempTasks = null; tempTasks = new string[tasks.Length + 1]; for (int i = 0; i < tasks.Length; i++) tempTasks[i] = tasks[i]; tempTasks[tasks.Length] = sr[j].id; tasks = tempTasks; } } else { //there were errors during the create call, go through the errors //array and write them to the screen for (int i = 0; i < sr[j].errors.Length; i++) { //get the next error Error err = sr[j].errors[i]; Console.WriteLine("Errors were found on item " + j.ToString()); Console.WriteLine("Error code is: " + err.statusCode.ToString()); Console.WriteLine("Error message: " + err.message); } } Console.WriteLine("\nCreate task successful."); } Console.Write("\nHit return to continue..."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("\nFailed to succesfully create a task, error message was: \n" + ex.Message); Console.Write("\nHit return to continue..."); Console.ReadLine(); } }
protected override void Execute(CodeActivityContext context) { { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string userName; string password; userName = Username.Get(context); //username from context password = Password.Get(context) + SecurityToken.Get(context); //password+token from context SforceService SfdcBinding = null; LoginResult CurrentLoginResult = null; SfdcBinding = new SforceService(); try { CurrentLoginResult = SfdcBinding.login(userName, password); } catch (System.Web.Services.Protocols.SoapException e) { // This is likley to be caused by bad username or password SfdcBinding = null; throw (e); } catch (Exception e) { // This is something else, probably comminication SfdcBinding = null; throw (e); } //Change the binding to the new endpoint SfdcBinding.Url = CurrentLoginResult.serverUrl; //Console.WriteLine(SfdcBinding.Url); //Console.ReadLine(); //Create a new session header object and set the session id to that returned by the login SfdcBinding.SessionHeaderValue = new SessionHeader(); SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; String[] fieldNames = FieldNames.Get(context); String[] fieldValues = FieldValues.Get(context); sObject obj = new sObject(); System.Xml.XmlElement[] objFields = new System.Xml.XmlElement[fieldNames.Length]; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); for (int i = 0; i < fieldNames.Length; i++) { objFields[i] = doc.CreateElement(fieldNames[i]); } for (int j = 0; j < fieldValues.Length; j++) { objFields[j].InnerText = fieldValues[j]; } obj.type = ObjectName.Get(context); obj.Any = objFields; obj.Id = ID.Get(context); sObject[] objList = new sObject[1]; objList[0] = obj; SaveResult[] results = SfdcBinding.update(objList); for (int j = 0; j < results.Length; j++) { if (results[j].success) { RecordID.Set(context, "Record Updated for ID: " + results[j].id); } else { // There were errors during the create call, // go through the errors array and write // them to the console String error; for (int i = 0; i < results[j].errors.Length; i++) { Error err = results[j].errors[i]; error = "Errors was found on item " + j.ToString() + Environment.NewLine + "Error code is: " + err.statusCode.ToString() + Environment.NewLine + "Error message: " + err.message; RecordID.Set(context, error); } } } } }
public abstract void LoadXml(System.Xml.XmlElement value);
/// <summary> /// Deserializes the specified element. /// </summary> /// <param name="element">The element.</param> public abstract void Deserialize(System.Xml.XmlElement element);
public System.Security.Cryptography.Xml.EncryptedData Encrypt(System.Xml.XmlElement inputElement, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { throw null; }
public System.Security.Cryptography.Xml.EncryptedData Encrypt(System.Xml.XmlElement inputElement, string keyName) { throw null; }
private void gameMenuItem_ChildClick(object sender, EventArgs e) { var sdr = (ToolStripMenuItem)sender; switch(sdr.Name) { case "startNewItem": if(statue != GameRiverStatue.Resulting && statue != GameRiverStatue.Waiting) return; bool isBlackFirst = Convert.ToInt32(cfg["isWhiteFirst"].InnerText) == 0; InitChesses(); lastChesses[0] = 3; lastChesses[1] = 3; lastChesses[2] = 3; lastChesses[3] = 3; lastChesses[4] = 3; lastChesses[5] = 3; lastChesses[6] = 3; lastChesses[7] = 3; ShowMessage("初始化完毕!"); InitPlayers(); player1.StartPlay(); player2.StartPlay(); if(isBlackFirst) { statue = GameRiverStatue.EnemyRound; player1.StepOn(); ShowMessage("游戏开始!轮到黑棋回合"); } else { statue = GameRiverStatue.OurRound; player2.StepOn(); ShowMessage("游戏开始!轮到白棋回合"); } break; case "configItem": if(GameConfig.ShowDialog(this) == DialogResult.OK) { cfg = GameConfig.GetCfgXml()["GameRiver"]; MessageBox.Show("配置保存成功!"); } break; case "exitItem": Close(); break; } }
public void LoadXml(System.Xml.XmlElement value) { }
public ControlContainerSerializationEventArgs(System.Xml.XmlElement xmlstorage) { this.xmlstore=xmlstorage; }
public byte[] EncryptData(System.Xml.XmlElement inputElement, System.Security.Cryptography.SymmetricAlgorithm symmetricAlgorithm, bool content) { throw null; }
public DataReturn UpdateAttachmentFile(string Id,string AttachmentName,string FileName) { DataReturn dr = new DataReturn(); byte[] b; try { b = System.IO.File.ReadAllBytes(FileName); } catch (Exception e) { dr.errormessage = e.Message; dr.success = false; return dr; } sObject attach = new sObject(); attach.type = "Attachment"; System.Xml.XmlElement[] o; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); SaveResult[] sr; // Update the attacchments fields doc = new System.Xml.XmlDocument(); o = new System.Xml.XmlElement[AttachmentName==""?1:2]; o[0] = doc.CreateElement("Body"); o[0].InnerText = Convert.ToBase64String(b); if (AttachmentName != "") { o[1] = doc.CreateElement("Name"); o[1].InnerText = AttachmentName; } attach.Any = o; attach.Id = Id; try { sr = _binding.update(new sObject[] { attach }); Globals.Ribbons.Ribbon1.SFDebug("Update Attachment"); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { Id = sr[j].id; } else { for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i]; } } } } catch (Exception e) { dr.errormessage = e.Message; dr.success = false; return dr; } dr.id = Id; return dr; }
public void ReplaceData(System.Xml.XmlElement inputElement, byte[] decryptedData) { }
//Given a DataRow, update or Create the SalesForce Object //Assuming that we have just one row, easy to change to handle multiples public DataReturn Save(string sObjectName, DataRow dRow) { DataReturn dr = new DataReturn(); sObject s = new sObject(); s.type = sObjectName; string id = ""; List<string> fieldsToNull = new List<string>(); if (dRow["Id"] == null || dRow["Id"].ToString() == "") { //new int fldCount = dRow.Table.Columns.Count - 1; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount]; fldCount = 0; foreach (DataColumn dc in dRow.Table.Columns) { if (dc.ColumnName == "Id") { //Nothing! } else if (dc.ColumnName == "type" || dc.ColumnName == "LastModifiedDate" || dc.ColumnName == "CreatedDate") { //don't do anything - this happens when we have the type field from a join } else { if (dc.ColumnName.Contains("__r_")) { if (dc.ColumnName.EndsWith("Id")) { string tn = dc.ColumnName; tn = tn.Substring(0, tn.IndexOf("__r_")); //Concept__r_Id becomes Concept__c tn += "__c"; o[fldCount] = doc.CreateElement(tn); o[fldCount].InnerText = CleanUpXML(dRow[dc.ColumnName].ToString()); fldCount++; } //Otherwise do nothing } else { o[fldCount] = doc.CreateElement(dc.ColumnName); o[fldCount].InnerText = CleanUpXML(dRow[dc.ColumnName].ToString()); fldCount++; } } } try { s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount); SaveResult[] sr = _binding.create(new sObject[] { s }); for (int j = 0; j < sr.Length; j++) { if (sr[j].success) { dr.id = sr[j].id; } else { dr.success = false; for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message; } } } } catch (Exception ex) { dr.success = false; dr.errormessage = ex.Message; } } else { //update int fldCount = dRow.Table.Columns.Count; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount]; fldCount = 0; foreach (DataColumn dc in dRow.Table.Columns) { if (dc.ColumnName == "Id") { s.Id = dRow[dc.ColumnName].ToString(); } else if (dc.ColumnName == "type" || dc.ColumnName == "LastModifiedDate" || dc.ColumnName == "CreatedDate") { //don't do anything - this happens when we have the type field from a join } else { //For relations - ignore all the other fields except the _Id one //e.g. "Concept__r_Name" "Concept__r_Id" - ignore all but Id //TODO: won't work Nested! need to try this out with a realation of a relation if (dc.ColumnName.Contains("__r_")) { if (dc.ColumnName.EndsWith("Id")) { string tn = dc.ColumnName; tn = tn.Substring(0, tn.IndexOf("__r_")); //Concept__r_Id becomes Concept__c tn += "__c"; string val = CleanUpXML(dRow[dc.ColumnName].ToString()); if (val == "") { fieldsToNull.Add(dc.ColumnName); } else { o[fldCount] = doc.CreateElement(tn); o[fldCount].InnerText = val; fldCount++; } } //Otherwise do nothing } else { string val = CleanUpXML(dRow[dc.ColumnName].ToString()); if(val==""){ fieldsToNull.Add(dc.ColumnName); } else{ o[fldCount] = doc.CreateElement(dc.ColumnName); o[fldCount].InnerText = val; fldCount++; } } } } try { s.fieldsToNull = fieldsToNull.ToArray(); s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount); SaveResult[] sr = _binding.update(new sObject[] { s }); for (int j = 0; j < sr.Length; j++) { Console.WriteLine("\nItem: " + j); if (sr[j].success) { dr.id = sr[j].id; } else { dr.success = false; for (int i = 0; i < sr[j].errors.Length; i++) { dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message; } } } } catch (Exception ex) { dr.success = false; dr.errormessage = ex.Message; } } return dr; }
public QueryResultsResponse(SIFHeaderType SIFHeader, System.Xml.XmlElement QueryResults) { this.SIFHeader = SIFHeader; this.QueryResults = QueryResults; }