Skip to content

Instantly share code, notes, and snippets.

View Microsofttechies's full-sized avatar

Venkat G Microsofttechies

View GitHub Profile
@Microsofttechies
Microsofttechies / gist:2c0706c69e98f5e84b13
Created March 24, 2015 21:34
Aras Innovator Action merge AML code
<AML>
<Item type="Part" action="merge" where="[part].item_number='I12112'">
<item_number>I12112</item_number>
<cost>1000</cost>
<name>My test</name>
<description>My Desc</description>
<classification>Assembly</classification>
</Item>
</AML>
@Microsofttechies
Microsofttechies / gist:994b3b58aecb41fece69
Created March 25, 2015 18:01
XML read all elements using C#
string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
if (File.Exists(strFilename))
{
XmlTextReader rdrXml = new XmlTextReader(strFilename);
do {
switch (rdrXml.NodeType)
{
@Microsofttechies
Microsofttechies / gist:5f1414dff2d31bb643de
Created March 25, 2015 18:22
C# Read xml Attributes
XMl file
<?xml version="1.0" encoding="utf-8" ?>
<Addresses>
<Address key="UK" City="London" Zip="9999"></Address>
<Address Key="US" City="Newyork" Zip="0000"></Address>
</Addresses>
C#
@Microsofttechies
Microsofttechies / gist:7092cd736798e2c79f34
Created March 27, 2015 20:18
An object reference is required for the nonstatic field, method, or property
It looks like you are calling a non static property from a static method. You will need to either make the property static, or create an instance of class
static void SetTextboxTextSafe(int result)
{
label1.Text = result.ToString();
}
@Microsofttechies
Microsofttechies / gist:078431e6e56ae6d92d72
Created March 29, 2015 18:57
Aras Innovator Item applyAML(string AML)
Innovator inn = this.getInnovator();
string AML = "<AML><Item type='Customer' action='get'/></AML>";
Item result = inn.applyAML(AML);
@Microsofttechies
Microsofttechies / gist:3286110b0c0989a1f918
Last active August 29, 2015 14:18
C# read excel OleDbConnection connection for .xls and .xlsx
using System.Threading.Tasks;
using System.Data.OleDb;
using System.Data;
using System.IO;
//Code
OleDbConnection oledbConn;
string path = "C:\\MyExcel.xlsx";
@Microsofttechies
Microsofttechies / gist:3b66b6e0007f3bf75ca8
Created April 2, 2015 23:42
c# convert excel to xml
OleDbConnection objConnection;
DataSet objDs;
OleDbDataAdapter objCommand;
string strExcelPath = "C:\\MyExcel.xlsm";
if (Path.GetExtension(strExcelPath) == ".xls")
{
objConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strExcelPath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"");
@Microsofttechies
Microsofttechies / gist:37b2dd3103f98fc3f490
Created April 3, 2015 17:13
C# XML read and remove namespace
XmlDocument xmlD = new XmlDocument();
xmlD.Load("C:\\a.xml");
string strxml = xmlD.OuterXml.ToString();
Regex regEx = new Regex(@"< \?xml.*?\?>");
strxml = regEx.Replace(strxml, " ");
@Microsofttechies
Microsofttechies / gist:15211be08573e256c47a
Last active August 29, 2015 14:18
{"<RootElementName xmlns=''> was not expected.} XML Deserialize in C#
XmlRootAttribute xRoot = new XmlRootAttribute();
xRoot.ElementName = "RootElementName";
xRoot.IsNullable = true;
XmlSerializer objSer = new XmlSerializer(typeof(Result), xRoot);
FileStream objF = new FileStream("C:\\a.xml", FileMode.Open);
Result varResult = (Result)serializer.Deserialize(objF);
@Microsofttechies
Microsofttechies / gist:1a48cd313775967253b8
Created April 6, 2015 04:52
dataSet.GetXml() doesn't return xml for null or blank columns
First clone the DataTable, make all columns of type string, replace all null values with string.empty, then call GetXml on a new DataSet.
//First bind XML data in to data set..objDataSet
DataTable dt = objDataSet.Tables[0];
DataTable dtCloned = dt.Clone();
foreach (DataColumn dc in dtCloned.Columns)