コード例 #1
0
        /// <summary>
        /// of following entities:
        /// •	Account
        /// •	Order
        /// </summary>
        /// <param name="EntityName"></param>
        /// <param name="TransactionData"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public TransactionResult[] ExecuteTransactions(string EntityName, Transaction[] TransactionData, NorthwindConfig config)
        {
            int seqenceID;
            try
            {

                EntityBase entity = EntityFactory.GetEntity(EntityName);

                if (entity == null)
                    throw new Exception(string.Format(Resources.ErrorMessages_OperationNotImplementedForEntity, EntityName));

                seqenceID = config.SequenceNumber;
                return entity.ExecuteTransactions(TransactionData, config);
            }

            catch (Exception e)
            {

                TransactionResult[] results = new TransactionResult[1];

                results[0] = new TransactionResult();
                results[0].Status = TransactionStatus.FatalError;
                results[0].EntityName = EntityName;
                results[0].Message = e.ToString();

                return results;

            }
        }
コード例 #2
0
 /// <summary>
 /// ExecuteTransaction is for the CRM system to send all create, update, and delete information from CRM to the ERP system. 
 /// </summary>
 /// <param name="TransactionData"></param>
 /// <param name="config">the configuration object</param>
 /// <returns>ExecuteTransactionsReponse is the response 
 /// from the ERP system providing results of the attempted changes.   
 /// The method returns an ArrayofTransactionResults, 
 /// which contains a list of TransactionResults.</returns>
 public TransactionResult[] ExecuteTransactions(Transaction[] TransactionData, NorthwindConfig config)
 {
     Document doc = GetDocumentTemplate();
     List<TransactionResult> result = new List<TransactionResult>();
     try
     {
         for (int index = 0; index < TransactionData.Length; index++)
         {
             doc = GetDocumentTemplate();
             doc.ReadFromXmlNode(TransactionData[index].Instance);
             ExecuteTransaction(doc, config, ref result);
         }
     }
     catch(Exception e)
     {
         result.Add(doc.SetTransactionStatus(TransactionStatus.FatalError, e.Message));
     }
     return result.ToArray();
 }