MS's CRM business consulting for the same time, the log: integrating In the Great Plains
This article is targeted to programmers, we CRM -> GP reulwihan providing C # source code integration. This code Provided, however, rather than the "solution", which the Foundation and the # programmer GP eConnect C by the demands of the packaging product is not installed. What is integration:
1. If you contract line MS CRM for the operation of the timesheets to record - This work describes the GP to cut 100 sales order processing with Invoice line will be integrated into a symbol - the GP default rules lines Description is limited
2. The sales invoices automatically overnight GP Integration between the CRM, if you close when you created. You For the same customer to close a few examples of the quality, development, On-site consulting, in all cases and the actions of one per customer Let's combine the invoice would be
3. Add Master Dyna Possible mix of CRM. You discuss the case with the agreement attached to the line If you log the time, reports and project status reporting Consultants to track time, you can create very powerful.
4. Add comment. Microsoft Dynamics GP for the sales Demonstration projects to C # source code is not integrated invoicing 10.0 SDK and eConnect. We have a successful project is integrated into the code Demo C # Code provides a procedure, please refer: SerializeSalesOrderObject to
The following code example, see:
Using System;
Using System.IO;
Using System.Collections;
Using System.Data;
To System.Diagnostics To use;
Using System.Data.SqlClient;
Using System.Xml name;
Using System.Text;
Using System.Xml.Serialization;
Microsoft.Dynamics.GP.eConnect use;
Microsoft.Dynamics.GP.eConnect.Serialization use;
Use Microsoft.Dynamics.GP.eConnect.MiscRoutines;
Name Space integration
(
Public sealed class OrderApp
(
Public static String outerSelectString; / / = "Select DISTINCT SQLSERVER, DatabaseName from the ALBANEWTIMELOG";
00 Static string innerSelectString; / / = "Select AccountNumber, BillableTime, UnitPrice, LineTotalPrice, [Description] ItemNumber, SQLSERVER, DatabaseName, IncidentId ALBANEWTIMELOG from where DatabaseName = ";
Public static string ConnectionString,, / / = "Integrated Security = True; Data Source = CRMSERVER; initials Product = CRMCUSTOMIZATION; ";
Public static DataTable, TableLines; DataGrid called the DataLines / / data Source.
/ / Error handling parameters
Public static string sErrMsg;
00 Static int the lErrCode;
Public static int the lRetCode;
Static string sDatabaseName, sServerName, sUserName, sPassword;
Describes a static string, ItemNumber, accountNumber, sCustomerPO;
Static second Character char39 = (Catfish) 39; / / 'symbols to mimic
Static System.Data.SqlTypes.SqlGuid incidentId;
/ / ************************************************ ****************************
/ / This is the application entry
/ / ************************************************ ****************************
Public static void Main ()
(
String sCustomerDocument;
String sSalesOrder;
String sXsdSchema;
String sConnectionString;
String name = "";
String contact = "";
String address, a = "";
String Address 2 = "";
String City = "";
String Country = "";
String zip = "";
String currentCustomer = "";
sConnectionString = @ "Data Source = ALBASERVER; Initial Catalog = ALBA; Integrated Security = SSPI is; ongoing security info = false; Packet size = 4096 ";
Jaeeseoneun StreamReader = File.OpenText (the "C: _IntegrationGP of Integration Settings.txt ");
ConnectionString, = re.ReadLine ();
outerSelectString = re.ReadLine ();
innerSelectString = re.ReadLine ();
sUserName = re.ReadLine ();
sPassword = re.ReadLine ();
String crmConnectionString = re.ReadLine ();
String customerSelectString = re.ReadLine ();
String timeLogSelectString = re.ReadLine ();
re.Close ();
To make SqlConnection outerConnection = new SqlConnection ();
the outerConnection.ConnectionString = ConnectionString;
outerConnection.Open ();
That is a SqlCommand = New SqlCommand () outerCommand;
outerCommand.CommandType = System.Data.CommandType.Text;
outerCommand.CommandText = outerSelectString;
outerCommand.Connection = outerConnection;
When SqlDataReader outerReader = OuterCommand.ExecuteReader ();
(OuterReader.Read while ())
(
sServerName = "";
sDatabaseName = "";
/ / Read the database TimeLog - companie and the server name
sServerName = outerReader.GetSqlString (0). ToString ();
sDatabaseName = outerReader.GetSqlString (1). ToString ();
sServerName = sServerName.Trim ();
sDatabaseName = sDatabaseName.Trim ();
SqlConnection connection = to make a new SqlConnection ();
the connection.ConnectionString = ConnectionString;
connection.Open ();
To command a SqlCommand = New SqlCommand ();
command.CommandType = System.Data.CommandType.Text;
command.CommandText = + char39 + sDatabaseName the char39 + + innerSelectString "AccountNumber order";
command.Connection = connection;
When SqlDataReader = command.ExecuteReader reader ();
(Reader.Read during ())
(
Few billableTime, UnitPrice, lineTotal;
Double bTime, uPrice;
Description = "";
ItemNumber = "";
accountNumber = "";
sCustomerPO = "";
Console.WriteLine ("Record : ");
/ / Read in TimeLog
accountNumber = reader.GetSqlString (0). ToString ();
billableTime = Reader.GetSqlDecimal (1). Value;
UnitPrice = reader.GetSqlDecimal (2). Value;
lineTotal = reader.GetSqlDecimal (3). Value;
Explanation = Reader.GetSqlString (4). ToString ();
ItemNumber = reader.GetSqlString (5). ToString ();
incidentId a = (8) reader.GetSqlGuid;
sCustomerPO = Reader.GetSqlString (9). ToString ();
/ / Add field
bTime = (double) billableTime;
uPrice = (double) UnitPrice;
Console.WriteLine (billableTime);
Console.WriteLine (billableTime.ToString ());
Console.WriteLine (unitPrice.ToString ());
Console.WriteLine (lineTotal.ToString ());
Console.WriteLine (description.ToString ());
Console.WriteLine (itemnumber.ToString ());
Console.WriteLine (SCustomerPO.ToString ());
Console.WriteLine ();
Attempt
(
(CurrentCustomer, accountNumber) String.Compare (if! = 0)
(
(Using e = new eConnectMethods eConnectMethods ())
(
/ / - Update - Create your ------------------------------------------- ---- --------
//------------------------------------------------ --------------------------------
Attempt
(
CRM euleseo / / read more about the customer information
So that To SqlConnection crmConnection = new SqlConnection ();
crmConnection.ConnectionString = crmConnectionString;
crmConnection.Open ();
CommandCustomer to the SqlCommand = New SqlCommand ();
commandCustomer.CommandType = System.Data.CommandType.Text;
commandCustomer.CommandText = "+ Char39 + accountNumber by the a.AccountNumber + char39 +" order customerSelectString;
commandCustomer.Connection = crmConnection;
When SqlDataReader readerCustomer = commandCustomer.ExecuteReader ();
(If! ReaderCustomer.Read ()) return;
(0). ToString () readerCustomer.GetSqlString;
String sName = readerCustomer.GetSqlString (1). ToString ();
(String.Compare (corresponding If sName, "null") == 0) sName = "";
Name = sName;
String sContact = readerCustomer.GetSqlString (4). ToString ();
(String.Compare (if applicable sContact, "null") == 0) sContact a = "";
Contact = sContact;
String sLine1 = readerCustomer.GetSqlString (5). ToString ();
(SLine1, "you") String.Compare (if available == 0) sLine1 = "";
Address 1 = sLine1;
String sLine2 = readerCustomer.GetSqlString (6). ToString ();
(SLine2, "null") == 0) = "" sLine2 the String.Compare (corresponding If;
Address 2 = sLine2;
String sCity = readerCustomer.GetSqlString (7). ToString ();
(SCity the String.Compare (If applicable, "you") == 0) sCity = "";
City = sCity;
String sState = readerCustomer.GetSqlString (8). ToString ();
(String.Compare (if applicable sState, "null") == 0) sState a = "";
Country = sState;
String sZip = readerCustomer.GetSqlString (9). ToString ();
Zip = sZip;
("You") == 0) sZip sZip the String.Compare (if any = "";
String sCountry = readerCustomer.GetSqlString (10). ToString ();
("You") == 0) sCountry sCountry the String.Compare (If = "";
readerCustomer.Close ();
() CommandCustomer.Dispose;
crmConnection.Close ();
() CrmConnection.Dispose;
/ / Write your data files
SerializeCustomerObject ("Customer.xml", accountNumber that, sName, sContact, sLine1, sLine2, "main" is, sCity,,) sZip the sCountry sState;
/ / XML document Use to create a string representation of clients
Xmldoc = new XmlDocument of XmlDocument ();
xmldoc.Load ("Customer.xml");
sCustomerDocument = xmldoc.OuterXml;
/ / Create the schema The XML document object
The XsdDoc = new XmlDocument XmlDocument ();
/ / Create a string eConnect schema that represents
sXsdSchema = XsdDoc.OuterXml;
/ / XsdSchema on the path To validate.
e.eConnect_EntryPoint (sConnectionString, EnumTypes.ConnectionStringType.SqlClient, sCustomerDocument, EnumTypes.SchemaValidationType.None, sXsdSchema);
)
/ / EConnectException eConnect business class will be Catch logic errors.
/ / Console will display an error message
(EConnectException hold room)
(
Console.Write (exc.ToString ());
)
Syntax) / / End
/ / Update to create the final customer
//------------------------------------------------ -----------
/ / Start the sales invoice -----------------------
//--------------------------------------------
(Using e = new eConnectMethods eConnectMethods ())
(
Attempt
(
MySopNumber of GetSopNumber = New GetSopNumber ();
String SOPNUMBE = mySopNumber.GetNextSopNumber (3, "Inv", sConnectionString);
eConnect = new eConnectType () eConnectType;
CRM euleseo / / read more about the customer information
SqlConnection crmConnection = new to make SqlConnection ();
crmConnection.ConnectionString = crmConnectionString;
crmConnection.Open ();
CommandSalesOrder to the SqlCommand = New SqlCommand ();
commandSalesOrder.CommandType = System.Data.CommandType.Text;
commandSalesOrder.CommandText = "+ char39 + accountNumber by the a.AccountNumber + char39 +" order timeLogSelectString;
commandSalesOrder.Connection = crmConnection;
When SqlDataReader readerSalesOrder = commandSalesOrder.ExecuteReader ();
taSopLineIvcInsert_ItemsTaSopLineIvcInsert a = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert [0] item [;
10 hex Sub-total = 0;
int of the ISO = 0;
(ReaderSalesOrder.Read while ())
(
10 decimal hours = readerSalesOrder.GetSqlDecimal (0). Value;
String sDescription = readerSalesOrder.GetSqlString (1). ToString ();
(SDescription the String.Compare (corresponding If "you") == 0) sDescription = "Other";
10 = readerSalesOrder.GetSqlDecimal binary rates (2). Value;
taSopLineIvcInsert_ItemsTaSopLineIvcInsert item = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert ();
Time = Decimal.Round (time, 2);
Speed = Decimal.Round (speed, 2);
0.60 (ratings percentage = (10 decimal) if;
item.SOPNUMBE = SOPNUMBE;
item.SOPTYPE = 3;
item.CUSTNMBR = accountNumber;
item.DOCID = "Inv";
item.QUANTITY = time;
item.ITEMNMBR = "Service";
item.ITEMDESC = sDescription;
item.UNITPRCE = speed;
item.XTNDPRCE = hours * rate;
item.DOCDATE = System.DateTime.Today.Date.ToString ();
item.NONINVEN = 1;
/ / Item ISO] = item [;
Subtotal + = hours * rate;
ISO + +;
(Items.Length if any)
readerSalesOrder.Close ();
() CommandSalesOrder.Dispose;
crmConnection.Close ();
() crmConnection.Dispose;
SOPTransactionType the SopOrder = new SOPTransactionType ();
XmlSerializer serial Avenue The riser = new XmlSerializer (eConnect.GetType ());
SopOrder.taSopLineIvcInsert_Items = item;
taSopHdrIvcInsert header = new taSopHdrIvcInsert ();
header.SOPTYPE = 3;
header.SOPNUMBE = SOPNUMBE;
header.DOCID = "Inv";
header.BACHNUMB = "ECONNECT";
header.CUSTNMBR = accountNumber;
header.CUSTNAME = name;
/ / Header.ShipToName = "Archive";
header.ADDRESS1 = Address 1;
header.CNTCPRSN = contacts;
/ / Header.FAXNUMBR = "13125550150";
header.CITY = City;
header.STATE = state;
header.ZIPCODE = Zip Code;
/ / Header.COUNTRY = "USA";
header.SUBTOTAL = subtotal;
header.DOCAMNT = subtotal;
/ / Header.USINGHEADERLEVELTAXES = 0;
/ / Header.PYMTRMID = "Net 30";
header.DOCDATE = System.DateTime.Today.Date.ToString ();
SopOrder.taSopHdrIvcInsert = Header;
SOPTransactionType [] in the mySOPOrder SopOrder = ();
eConnect.SOPTransactionType = mySOPOrder;
Of FileStream FS = new FileStream ("SalesOrder.xml", FileMode.Create);
XmlTextWriter writer = new XmlTextWriter a (FS, New UTF8Encoding ());
(), Writer, eConnect serializer.Serialize;
writer.Close ();
XmlDocument xmldoc = new XmlDocument of ();
xmldoc.Load ("SalesOrder.xml");
sSalesOrder = xmldoc.OuterXml;
XmlDocument XsdDoc = new XmlDocument ();
sXsdSchema = XsdDoc.OuterXml;
e.eConnect_EntryPoint (sConnectionString, EnumTypes.ConnectionStringType.SqlClient, sSalesOrder, EnumTypes.SchemaValidationType.None, sXsdSchema);
)
(EConnectException of the room) to catch
(
Console.Write (exc.ToString ());
)
)
/ / Sales invoices Results -----------------------
//--------------------------------------------
)
In (/ / Mark the case number
To make SqlConnection updateConnection = new SqlConnection ();
the updateConnection.ConnectionString = ConnectionString;
updateConnection.Open ();
To the SqlCommand = New commandUpdate SqlCommand ();
commandUpdate.CommandType = System.Data.CommandType.StoredProcedure;
commandUpdate.CommandText = "sp_UpdateImportedCase";
commandUpdate.Parameters.Add ("@ IncidentId", SqlDbType.UniqueIdentifier);
commandUpdate.Parameters the "@". Value] incidentId [= incidentId;
commandUpdate.Connection = updateConnection;
commandUpdate.ExecuteNonQuery ();
() CommandUpdate.Dispose;
updateConnection.Close ();
() UpdateConnection.Dispose;
)
)
() To catch
currentCustomer = accountNumber;
)
reader.Close ();
() Command.Dispose;
connection.Close ();
() Connection.Dispose;
)
)
Public static void SerializeCustomerObject (string File name, string custnumbr, String name, String cntcprsn, string address 1, Address Line 2 string, string adrscode, string City, string State, string, String country)
(
Attempt
(
/ / Instance schema target eConnectType
eConnect = new eConnectType () eConnectType;
/ / Instance RMCustomerMasterType schema objects
RMCustomerMasterType customertype = new RMCustomerMasterType ();
/ / Instance taUpdateCreateCustomerRcd XML node Objects
taUpdateCreateCustomerRcd customer = new taUpdateCreateCustomerRcd ();
/ / Generate XML serializer object
Serializer = new XmlSerializer Avenue That XmlSerializer (eConnect.GetType ());
taUpdateCreateCustomerRcd XML node object / / fill elements
customer.CUSTNMBR = custnumbr;
customer.CUSTNAME = name;
customer.CNTCPRSN = cntcprsn;
customer.ADDRESS1 = Address 1;
customer.ADDRESS2 = Address 2;
customer.ADRSCODE = adrscode;
customer.CITY = city;
customer.STATE = state;
customer.ZIPCODE = Zip Code;
customer.COUNTRY = country;
customer.CUSTPRIORITY = 1;
= True customer.CUSTPRIORITYSpecified;
/ / Fill taUpdateCreateCustomerRcd XML Schema node and RMCustomerMasterType
customertype.taUpdateCreateCustomerRcd = Customer;
RMCustomerMasterType [] mySMCustomerMaster customertype = ();
RMCustomerMasterType schema objects / / Fill eConnectType object
eConnect.RMCustomerMasterType = mySMCustomerMaster;
/ / Create object creation The XML file and create a customer for
Of FileStream FS = new FileStream (file, Name, FileMode.Create);
XmlTextWriter writer = new XmlTextWriter a (FS, New UTF8Encoding ());
File using the XmlTextWriter that / / serialization eConnectType object.
(), Writer, eConnect serializer.Serialize;
writer.Close ();
)
/ / Generated and displayed on the console Get error
(System.Exception catch for example)
(
Console.Write (ex.ToString ());
)
)
/ / The following function is used for demonstration only, are not
Public static void SerializeSalesOrderObject (string filename)
(
Attempt
(
/ / Instance eConnectType schema objects
eConnect = new eConnectType () eConnectType;
taSopLineIvcInsert_ItemsTaSopLineIvcInsert a = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert [1] entry [;
taSopLineIvcInsert_ItemsTaSopLineIvcInsert items = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert ();
item.ADDRESS1 = "2345 Primary Castle ";
item.CUSTNMBR = "CONTOSOL0001";
item.SOPNUMBE = "000001";
item.CITY = "Aurora";
item.SOPTYPE = 3;
item.DOCID = "STDINV";
item.QUANTITY = 2;
item.ITEMNMBR = "ACCS - CRD - 12WH";
item.ITEMDESC = "Phone number code - 12 'White";
item.UNITPRCE = (10 decimal) 10.95;
item.XTNDPRCE = (10 decimal), 21.9;
item.LOCNCODE = "Archive";
item.DOCDATE = "2017 년 4 월 12th,"; / / 'Today
Items 0] = item [;
The SopOrder = new SOPTransactionType SOPTransactionType ();
XmlSerializer serializer = new XmlSerializer Avenue that (eConnect.GetType ());
SopOrder.taSopLineIvcInsert_Items = item;
taSopHdrIvcInsert header = new taSopHdrIvcInsert ();
header.SOPTYPE = 3;
header.SOPNUMBE = "000001";
header.DOCID = "STDINV";
header.BACHNUMB = "" ECONNECT;
header.TAXSCHID = "USASTCITY - 6 *";
header.FRTSCHID = "USASTCITY - 6 *";
header.MSCSCHID = "USASTCITY - 6 *";
header.LOCNCODE = "Archive";
header.DOCDATE = "2017 년 4 월 12th,";
header.CUSTNMBR = "CONTOSOL0001";
header.CUSTNAME = "Contoso, Inc.";
header.ShipToName = "Archive";
header.ADDRESS1 = "2345 Main St.";
header.CNTCPRSN = "Joe Healy";
header.FAXNUMBR = "13125550150";
header.CITY = "Aurora";
header.STATE = "Illinois";
header.ZIPCODE = "65700";
header.COUNTRY = "USA";
= (10 decimal) 21.9 header.SUBTOTAL;
header.DOCAMNT = (10 decimal), 21.9;
header.USINGHEADERLEVELTAXES = 0;
header.PYMTRMID = "Net 30";
SopOrder.taSopHdrIvcInsert = header;
taUpdateCreateCustomerRcd XML nodes and / / Fill the schema RMCustomerMasterType
/ / Customertype.taUpdateCreateCustomerRcd = customers;
/ / RMCustomerMasterType [] in the mySMCustomerMaster customertype = ();
SOPTransactionType [] in the mySOPOrder SopOrder = ();
eConnect.SOPTransactionType = MySOPOrder;
RMCustomerMasterType schema object and / / fill eConnectType object
/ / EConnect.RMCustomerMasterType = MySMCustomerMaster;
/ / Create an object file and for creating customer Create XML
Of FileStream FS = new FileStream (filename, FileMode.Create);
XmlTextWriter writer = New XmlTextWriter a (FS, New UTF8Encoding ());
File using the XmlTextWriter / / Create object serialization eConnectType.
(), Writer, eConnect serializer.Serialize;
writer.Close ();
)
/ / Get the error occurred, and displayed on the console
(System.Exception Catching cases)
(
Console.Write (ex.ToString ());
)
)
/ / This function in Paris Enabling us to increase the length of the array - we sell our N = line to read an invoice for its use
Public static Array ExpandArray (one kind of array object newElement)
(
Long int = 1;
System.Type type = newElement.GetType ();
(If one kind! = Null as)
(
Length + = arr.Length;
Type = arr.GetType (). GetElementType ();
)
Array results = Array.CreateInstance (type, length);
(If one kind! = to null)
(
arr.CopyTo (result, 0);
)
result.SetValue (newElement, result.Length - 1);
Return result;
)
)
)
About the Author
Andrew Karasev, Pegas Planet http://www.pegasplanet.com, subdivision or Alba Spectrum Group: http://www.albaspectrum.com , providing media publishing services: articles, press releases, video and photo blogs distributions services in USA and internationally. Taisia Karaseva is the author of Pegas Planet concept. You can submit your video article here: http://www.pegasplanet.com/SubmitNews/SubmitNews.aspx
CBS4 RTV4 WHBF Quad Cities, IL / IA News Weather SportsThis Web Site’s Privacy Policy
This Web Site (the "Web site") provides a variety of online services, from interactive entertainment to electronic commerce via its relationship with Gannaway Web Holdings, LLC d/b/a WorldNow ("WorldNow"). WorldNow is the host of this Web site.
Postcards are a wonderfully fast and efficient way of getting specific messages, like Zip Code Database Il, delivered in a permanent format to your own mailing list and other specific mailing lists you have purchased.