当前位置: 首页>>代码示例>>C#>>正文


C# NorthwindConfig类代码示例

本文整理汇总了C#中NorthwindConfig的典型用法代码示例。如果您正苦于以下问题:C# NorthwindConfig类的具体用法?C# NorthwindConfig怎么用?C# NorthwindConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NorthwindConfig类属于命名空间,在下文中一共展示了NorthwindConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

        /// <summary>
        /// The Add verb inserts an account and all subentities  in the underlying data-store. On success, the
        /// identity of the newly inserted instances will added to the document and all subdocuments.
        /// </summary>
        /// <param name="doc">Document (without ID) containing the data to be stored</param>
        /// <param name="config">The configuration object</param>
        /// <returns>The transactionResult contais status information of the single transaction an also the nesed transactions of the subentities</returns>
        public override void Add(Document doc, NorthwindConfig config, ref List<TransactionResult> result)
        {
            #region Declarations
            AccountDocument accDoc;
            AccountDataset.AccountsRow row;
            #endregion

            // cast the given document to an account document
            accDoc = doc as AccountDocument;
            if (accDoc == null)
            {
                result.Add(doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_DocumentTypeNotSupported));
                return;
            }

            // get the account row from the given document
            row = GetRow(accDoc, config, true);

            // store as customer if the account type is set to customer
            if (CRMSelections.acc_type_Customer == (string)accDoc.customerSupplierFlag.Value)
                StoreCustomer(accDoc, row, config, ref result);

            // store as supplier if the account type is set to supplier
            else if (CRMSelections.acc_type_Supplier == (string)accDoc.customerSupplierFlag.Value)
                StoreSupplier(accDoc, row, config, ref result);

               // for any other account type, set the transactionstatus to not supported
            else
            {
                result.Add(accDoc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_AccountTypeNotSupported));
            }
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:39,代码来源:Account.cs

示例2: Add

        /* Add */
        public override void Add(Document doc, NorthwindConfig config, ref List<TransactionResult> result)
        {
            List<TransactionResult> transactionResult = new List<TransactionResult>();

            // cast the given document to an email document
            // return if fails
            EmailDocument emailDocument = doc as EmailDocument;
            if (emailDocument == null)
            {
                result.Add(doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_DocumentTypeNotSupported));
                return;
            }

            CustomerEmailsTableAdapter tableAdapter;
            Emails emailsDataset = new Emails();
            Emails.CustomerEmailsRow emailRow = emailsDataset.CustomerEmails.NewCustomerEmailsRow();

            #region fill dataset from document

            try
            {
                if (emailDocument.emailaddress.IsNull)
                    emailRow.SetEmailNull();
                else
                    emailRow.Email = (string)emailDocument.emailaddress.Value;

                emailRow.CreateID = config.SequenceNumber;
                emailRow.CreateUser = config.CrmUser;

                emailRow.ModifyID = config.SequenceNumber;
                emailRow.ModifyUser = config.CrmUser;
            }
            catch (Exception e)
            {
                emailDocument.Id = "";
            #warning Check error message
                result.Add(emailDocument.SetTransactionStatus(TransactionStatus.UnRecoverableError, e.ToString()));
                return;
            }

            #endregion

            #region Get the ID of the new row and set it to the document

            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                connection.Open();

                tableAdapter = new CustomerEmailsTableAdapter();
                tableAdapter.Connection = connection;

                emailsDataset.CustomerEmails.AddCustomerEmailsRow(emailRow);
                tableAdapter.Update(emailsDataset.CustomerEmails);
                OleDbCommand Cmd = new OleDbCommand("SELECT @@IDENTITY", connection);
                object lastid = Cmd.ExecuteScalar();
                emailDocument.Id = ((int)lastid).ToString();
            }

            #endregion
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:61,代码来源:Email.cs

示例3: FillChangeLog

 public override int FillChangeLog(out DataTable table, NorthwindConfig config, Token lastToken)
 {
     table = new DataTable("PriceingList");
     table.Columns.Add("ID", typeof(string));
     table.Columns.Add("Sequence", typeof(int));
     table.Rows.Add(new object[] { Constants.DefaultValues.PriceList.ID, 0 });
     //table.Rows.Add(new object[] { Constants.DefaultValues.PriceListSpecial.ID, 0 });
     return 1;
 }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:9,代码来源:PricingList.cs

示例4: GetDocument

        public override Document GetDocument(Identity identity, Token lastToken, NorthwindConfig config)
        {
            PricingListsDocument doc = new PricingListsDocument();
            if (identity.Id.Equals(Constants.DefaultValues.PriceList.ID))
            {
                doc.Id = Constants.DefaultValues.PriceList.ID;
                doc.description.Value = Constants.DefaultValues.PriceList.Name;
                doc.name.Value = Constants.DefaultValues.PriceList.Name;
            }
            else
            {
                doc.Id = Constants.DefaultValues.PriceListSpecial.ID;
                doc.description.Value = Constants.DefaultValues.PriceListSpecial.Name;
                doc.name.Value = Constants.DefaultValues.PriceListSpecial.Name;
            }
            doc.active.Value = "Y"; //Constants.DefaultValues.Active;
            #warning should be boolean, but as workaround this will filled with "Y"
            doc.erpdefaultvalue.Value = "Y";
            doc.defaultvalue.Value = false;

            return doc;
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:22,代码来源:PricingList.cs

示例5: GetUOMFamilyDocument

        private UnitOfMeasureFamilyDocument GetUOMFamilyDocument(Sage.Integration.Northwind.Application.Entities.Product.DataSets.Product.ProductsRow productRow, Token lastToken, NorthwindConfig config)
        {
            #region Declarations
            UnitOfMeasureFamilyDocument uomDoc;
            string identity;
            #endregion

            identity = productRow.ProductID.ToString();

            // create Account Doc
            uomDoc = new UnitOfMeasureFamilyDocument();
            uomDoc.Id = identity;

            if (lastToken.InitRequest)
                uomDoc.LogState = LogState.Created;

            else if (productRow.IsCreateIDNull() || productRow.IsModifyIDNull()
                || productRow.IsCreateUserNull() || productRow.IsModifyUserNull())
                uomDoc.LogState = LogState.Created;

            else if ((productRow.CreateID > lastToken.SequenceNumber)
                   && (productRow.CreateUser != config.CrmUser))
                uomDoc.LogState = LogState.Created;

            else if ((productRow.CreateID == lastToken.SequenceNumber)
               && (productRow.CreateUser != config.CrmUser)
                && (identity.CompareTo(lastToken.Id.Id) > 0))
                uomDoc.LogState = LogState.Created;
            else if ((productRow.ModifyID >= lastToken.SequenceNumber) && (productRow.ModifyUser != config.CrmUser))
                uomDoc.LogState = LogState.Updated;

            uomDoc.active.Value = Constants.DefaultValues.Active;
            uomDoc.defaultvalue.Value = true;

            uomDoc.name.Value = productRow.IsQuantityPerUnitNull() ? null : productRow.QuantityPerUnit.ToString(); ;
            uomDoc.description.Value = uomDoc.name.Value;
            return uomDoc;
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:38,代码来源:UnitOfMeasureFamily.cs

示例6: GetDocument

        public override Document GetDocument(Identity identity, Token lastToken, NorthwindConfig config)
        {
            int recordCount;
            DataSets.Product product = new DataSets.Product();
            int uomFamilyId;

            uomFamilyId = Identity.GetId(identity);

            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                Sage.Integration.Northwind.Application.Entities.Product.DataSets.ProductTableAdapters.ProductsTableAdapter tableAdapter;
                tableAdapter = new Sage.Integration.Northwind.Application.Entities.Product.DataSets.ProductTableAdapters.ProductsTableAdapter();
                tableAdapter.Connection = connection;
                recordCount = tableAdapter.FillBy(product.Products, uomFamilyId);
            }

            if (recordCount == 0)
                return GetDeletedDocument(identity);

            return GetUOMFamilyDocument((DataSets.Product.ProductsRow)product.Products[0], lastToken, config);
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:21,代码来源:UnitOfMeasureFamily.cs

示例7: GetAll

        /* Get */
        public override List<Identity> GetAll(NorthwindConfig config, string whereExpression, OleDbParameter[] oleDbParameters)
        {
            List<Identity> result = new List<Identity>();
            int recordCount = 0;
            DataSets.Product productsDataset = new DataSets.Product();

            // get the first 11 rows of the changelog
            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                DataSets.ProductTableAdapters.ProductsTableAdapter tableAdapter;

                tableAdapter = new DataSets.ProductTableAdapters.ProductsTableAdapter();

                tableAdapter.Connection = connection;

                if (string.IsNullOrEmpty(whereExpression))
                    recordCount = tableAdapter.Fill(productsDataset.Products);
                else
                    recordCount = tableAdapter.FillByWhereClause(productsDataset.Products, whereExpression, oleDbParameters);
            }

            foreach (DataSets.Product.ProductsRow row in productsDataset.Products.Rows)
            {
                // use where expression !!
                result.Add(new Identity(this.EntityName, row.ProductID.ToString()));
            }

            return result;
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:30,代码来源:UnitOfMeasureFamily.cs

示例8: Fill

        protected virtual int Fill(string sqlQuery, List<OleDbParameter> oleDbParameterList, NorthwindConfig config, out DataSet dataSet)
        {
            // declarations
            OleDbDataAdapter dataAdapter;
            int nOfRows;

            // initializations
            dataSet = null;
            nOfRows = 0;
            dataSet = new DataSet();

            // get the data base records using a table adapter.
            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                dataAdapter = new OleDbDataAdapter(sqlQuery, connection);
                dataAdapter.SelectCommand.Parameters.AddRange(oleDbParameterList.ToArray());
                nOfRows = dataAdapter.Fill(dataSet, _reportName);
            }

            return nOfRows;
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:21,代码来源:RTDVBase.cs

示例9: GetDocumentLineItem

        private Document GetDocumentLineItem(DataSets.Order.CalculatedOrderDetailsRow row, Token lastToken, NorthwindConfig config)
        {
            #region Declarations
            LineItemDocument doc;
            string id;
            decimal discountPercentage;
            #endregion

            id = row.OrderID.ToString() + "-" + row.ProductID.ToString();

            doc = new LineItemDocument();
            doc.Id = id;

            if (lastToken.InitRequest)
                doc.LogState = LogState.Created;
            else if ((row.CreateID >= lastToken.SequenceNumber) && (row.CreateUser != config.CrmUser))
                doc.LogState = LogState.Created;
            else if ((row.ModifyID >= lastToken.SequenceNumber) && (row.ModifyUser != config.CrmUser))
                doc.LogState = LogState.Updated;

            doc.productid.Value = row.ProductID;
            //doc.orderquouteid.Value = row.OrderID;
            doc.uomid.Value = row.ProductID;
            doc.quantity.Value = row.IsQuantityNull() ? Convert.ToInt16(0) : row.Quantity;
            doc.listprice.Value = row.IsUnitPriceNull() ? new decimal(0) : row.UnitPrice;
            discountPercentage = row.IsDiscountNull() ? (decimal)0 : Convert.ToDecimal(row.Discount);

            //doc.discountsum.Value = (decimal)(short)doc.Quantity.Value * (decimal)doc.ListPrice.Value * discountPercentage;
            doc.discountsum.Value = (decimal)doc.listprice.Value * discountPercentage;
            doc.quotedprice.Value = (decimal)doc.listprice.Value * (1 - discountPercentage);

            //doc.quotedprice.Value = row.IsQuotePriceNull() ? new decimal(0) : Convert.ToDecimal(row.QuotePrice);

            doc.taxrate.Value = "0";
            doc.tax.Value = new decimal(0);
            doc.quotedpricetotal.Value = Convert.ToDecimal(doc.quantity.Value) * Convert.ToDecimal(doc.quotedprice.Value);
            return doc;
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:38,代码来源:Order.cs

示例10: GetDocument

        public override Document GetDocument(Identity identity, Token lastToken, NorthwindConfig config)
        {
            int recordCount;
            DataSets.Order order = new DataSets.Order();
            CalculatedOrdersTableAdapter tableAdapter;
            tableAdapter = new CalculatedOrdersTableAdapter();
            CalculatedOrderDetailsTableAdapter detailTableAdapter;
            detailTableAdapter = new CalculatedOrderDetailsTableAdapter();
            DeletedOrderDetailsTableAdapter deletedDetailTableAdapter;
            deletedDetailTableAdapter = new DeletedOrderDetailsTableAdapter();

            int id;

            id = Identity.GetId(identity);

            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                tableAdapter.Connection = connection;
                recordCount = tableAdapter.FillBy(order.CalculatedOrders, id);
                if (recordCount == 0)
                    return GetDeletedDocument(identity);

                detailTableAdapter.Connection = connection;
                detailTableAdapter.FillBy(order.CalculatedOrderDetails, id);

                deletedDetailTableAdapter.Connection = connection;
                deletedDetailTableAdapter.Fill(order.DeletedOrderDetails, id.ToString(), lastToken.SequenceNumber, config.CrmUser);
            }

            return GetDocument((DataSets.Order.CalculatedOrdersRow)order.CalculatedOrders[0],
                order.CalculatedOrderDetails,
                order.DeletedOrderDetails,
                lastToken, config);
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:34,代码来源:Order.cs

示例11: GetAll

 public abstract List<Identity> GetAll(NorthwindConfig config, string whereExpression, OleDbParameter[] oleDbParameters);
开发者ID:estelleLeBouler,项目名称:SData-Contracts,代码行数:1,代码来源:EntityBase.cs

示例12: FillChangeLog

 /// <summary>
 /// get the next changes from an entity
 /// </summary>
 /// <param name="table">the datatable to fill</param>
 /// <param name="config">the configuration object</param>
 /// <param name="lastToken">the last token to get the next 10 changelog entries</param>
 /// <returns>retunrs a recordcount and a filled datatable</returns>
 public abstract int FillChangeLog(out DataTable table, NorthwindConfig config, Token lastToken);
开发者ID:estelleLeBouler,项目名称:SData-Contracts,代码行数:8,代码来源:EntityBase.cs

示例13: ExecuteTransactions

 /// <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();
 }
开发者ID:estelleLeBouler,项目名称:SData-Contracts,代码行数:28,代码来源:EntityBase.cs

示例14: StoreCustomer

        /// <summary>
        /// 
        /// </summary>
        /// <param name="accDoc"></param>
        /// <param name="accountRow"></param>
        /// <param name="config"></param>
        private void StoreCustomer(AccountDocument accDoc, AccountDataset.AccountsRow accountRow, NorthwindConfig config, ref List<TransactionResult> result)
        {
            #region declaration
            AccountDataset.CustomersRow customerRow;
            AccountDataset account;
            CustomersTableAdapter tableAdapter;
            string columnName;
            int recordCount;
            bool newCustomer;
            string customerId;
            #endregion

            newCustomer = ((accDoc.Id == null) || (accDoc.Id == ""));

            try
            {
                if (newCustomer)
                    customerId = GetNewCustomerID((string)accDoc.name.Value, config);
                else if (accDoc.Id.StartsWith(Constants.CustomerIdPrefix, StringComparison.InvariantCultureIgnoreCase))
                    customerId = accDoc.Id.Substring(Constants.CustomerIdPrefix.Length);
                else
                {
                    result.Add(accDoc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_AccountNotFound));
                    return;
                }
            }
            catch (Exception)
            {
                result.Add(accDoc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_AccountNotFound));
                return;
            }
            try
            {

                using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
                {
                    account = new AccountDataset();

                    tableAdapter = new CustomersTableAdapter();
                    tableAdapter.Connection = connection;
                    if (newCustomer)
                    {
                        customerRow = account.Customers.NewCustomersRow();
                        customerRow.CustomerID = customerId;
                    }
                    else
                    {
                        recordCount = tableAdapter.FillBy(account.Customers, customerId);
                        if (recordCount == 0)
                        {
                            accDoc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_AccountNotFound);
                            return;
                        }
                        customerRow = (AccountDataset.CustomersRow)account.Customers.Rows[0];

                    }

                    for (int index = 0; index < accountRow.Table.Columns.Count; index++)
                    {

                        columnName = accountRow.Table.Columns[index].ColumnName;

                        if (!customerRow.Table.Columns.Contains(columnName))
                            continue;

                        if (columnName.StartsWith("Create", StringComparison.InvariantCultureIgnoreCase))
                            if ((accountRow[columnName].GetType().Equals(typeof(DBNull))))
                                continue;

                        customerRow[columnName] = accountRow[columnName];
                    }

                    if (newCustomer)
                        account.Customers.AddCustomersRow(customerRow);

                    tableAdapter.Update(account.Customers);
                    accDoc.SetTransactionStatus(TransactionStatus.Success);

                    SetIdentitiesForAccounts(Constants.CustomerIdPrefix + customerId, accDoc);
                    accDoc.GetTransactionResult(ref result);
                }
            }
            catch (Exception addCustomerException)
            {
                result.Add(accDoc.SetTransactionStatus(TransactionStatus.FatalError, addCustomerException.ToString()));
                throw;
            }

            UpdateEmailsCollectionFromCustomer(customerId, accDoc.emails, config, ref result);
        }
开发者ID:Sage,项目名称:SData-Contracts,代码行数:96,代码来源:Account.cs

示例15: GetRow

        /// <summary>
        /// get a northwind account row, which is a union of customers and suppliers,
        /// from the given account document and set the transaction status on the documents
        /// </summary>
        /// <param name="accDoc">the crm Account document</param>
        /// <param name="config"></param>
        /// <returns>a filled northwind account row</returns>
        private AccountDataset.AccountsRow GetRow(AccountDocument accDoc, NorthwindConfig config, bool newAccount)
        {
            #region Declarations
            AccountDataset accDataset;
            AccountDataset.AccountsRow result;
            Address address;
            Phone phone;
            ContactName personName;
            int subentities = 4;
            #endregion

            accDataset = new AccountDataset();
            result = accDataset.Accounts.NewAccountsRow();

            // get the account name from the document
            if (!accDoc.name.IsNull)
                result.CompanyName =  (string)accDoc.name.Value;

            if (newAccount)
            {
                // set create user and id
                result.CreateID = config.SequenceNumber;
                result.CreateUser = config.CrmUser;
            }

            // set modify user and id
            result.ModifyID = config.SequenceNumber;
            result.ModifyUser = config.CrmUser;

            #region Address

            // go throuh all addresses to find the business address,
            // the rest of the adresses will ignored
            foreach (AddressDocument adrDoc in accDoc.addresses)
            {
                // check if the Address is from the supported type
                if ((adrDoc.primaryaddress.IsNull) ||
                    (!adrDoc.primaryaddress.Value.ToString().Equals("True", StringComparison.InvariantCultureIgnoreCase)))
                {
                    // set the transactionsstatus to none to remove this status from the result
                    adrDoc.ClearTransactionStatus();
                    continue;
                }

                // the first correct address found

                // get a new Address Object to convert beween the systems
                address = new Address();

                // fill the address object with the crm data
                address.SetCrmAdresses(adrDoc.address1, adrDoc.address2, adrDoc.address3, adrDoc.address4);

                // set the Northwind address
                result.Address = address.NorthwindAddress;

                // get the city from the Address document
                if (!adrDoc.City.IsNull)
                    result.City = (string)adrDoc.City.Value;

                // get the state from the Address document
                if (!adrDoc.state.IsNull)
                    result.Region = (string)adrDoc.state.Value;

                // get the state from the Address document
                if (!adrDoc.postcode.IsNull)
                    result.PostalCode = (string)adrDoc.postcode.Value;

                // get the country from the Address document
                if (!adrDoc.country.IsNull)
                    result.Country = (string)adrDoc.country.Value;

                // stop searching
                subentities--;
                adrDoc.SetTransactionStatus(TransactionStatus.Success);
                break;

            }
            #endregion

            #region Contact
            // go throuh all people to find the billing person,
            // the rest of the people will ignored
            foreach (PersonDocument persDoc in accDoc.people)
            {
                // check if the person is from the supported type
                if ((persDoc.primaryperson.IsNull) || (!persDoc.primaryperson.Value.ToString().Equals("True",StringComparison.InvariantCultureIgnoreCase)))
                {
                    // set the transactionsstatus to none to remove this status from the result
                    persDoc.ClearTransactionStatus();
                    continue;
                }
                // the first correct people found

//.........这里部分代码省略.........
开发者ID:Sage,项目名称:SData-Contracts,代码行数:101,代码来源:Account.cs


注:本文中的NorthwindConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。