Exemplo n.º 1
0
        /// <summary>
        /// Build Record Composite Key
        /// </summary>
        /// <param name="pQueryPrimaryKeys"></param>
        /// <param name="pRecordInfo"></param>
        /// <returns></returns>
        private string BuildRecordCompositeKey(List <string> pQueryPrimaryKeys, DBRecordInfo pRecordInfo)
        {
            string recordCompositeKey = string.Empty;

            try
            {
                foreach (string primaryKey in pQueryPrimaryKeys)
                {
                    if (pRecordInfo.Row.Table.Columns.Contains(primaryKey))
                    {
                        string tempKeyValue = pRecordInfo.Row[primaryKey].SafeToString();

                        if (tempKeyValue.IsValidString())
                        {
                            if (recordCompositeKey.IsValidString())
                            {
                                recordCompositeKey += ",";
                            }

                            recordCompositeKey += tempKeyValue;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(recordCompositeKey);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Build NonFraction Number
 /// </summary>
 /// <param name="pDbRecordInfo"></param>
 /// <param name="pValueFieldName"></param>
 /// <param name="pMultiplierFieldName"></param>
 /// <returns></returns>
 internal static nonFractionNumber BuildNonFractionNumber(this DBRecordInfo pDbRecordInfo, string pValueFieldName, string pMultiplierFieldName = "")
 {
     return(new nonFractionNumber()
     {
         Value = pDbRecordInfo.GetFieldValue <String>(pValueFieldName),
         multiplier = pMultiplierFieldName.IsValidString() ?
                      pDbRecordInfo.GetFieldValue <String>(pMultiplierFieldName) : "1"
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// Build Material To Supplier Mapping List
        /// </summary>
        /// <param name="pDBRecord"></param>
        /// <param name="pWincashWSAdapterConfig"></param>
        /// <returns></returns>
        internal static materialToSupplier[] BuildMaterialToSupplierList(DBRecordInfo pDBRecord, WincashWSAdapterConfig pWincashWSAdapterConfig)
        {
            List <materialToSupplier> materialToSupplierMappings = null;

            try
            {
                string supplierName = pDBRecord.GetFieldValue <String>(QueryFields.supplierName);

                if (!supplierName.IsValidString())
                {
                    return(null);
                }

                materialToSupplierMappings = new List <materialToSupplier>();

                // Only one materialToSupplierMappings is considered
                materialToSupplierMappings.Add(new materialToSupplier()
                {
                    Item1            = pDBRecord.GetFieldValue <String>(QueryFields.supplierName), //[supplierID or supplierName]
                    Item1ElementName = Item1ChoiceType6.supplierName,
                    defaultSupplier  = pDBRecord.GetFieldValue <String>(QueryFields.defaultSupplier).ToFlag(),
                    deliveryTime     = pDBRecord.GetFieldValue <String>(QueryFields.deliveryTime),
                    priceSettings    = new supplierPriceSettings()
                    {
                        averageCostPrice = pDBRecord.BuildNonFractionNumber(QueryFields.averageCostPriceValue, QueryFields.averageCostPriceMultiplier),
                        costPrice        = pDBRecord.BuildNonFractionNumber(QueryFields.costPriceValue, QueryFields.costPriceMultiplier),
                        Item             = pDBRecord.GetFieldValue <String>(QueryFields.currencyName), //[currencyID or currencyName]
                        ItemElementName  = ItemChoiceType10.currencyName
                    },
                    quantitySettings = new supplierQuantitySettings()
                    {
                        maximumQuantity    = pDBRecord.BuildNonFractionNumber(QueryFields.maximumQuantityValue, QueryFields.maximumQuantityMultiplier),
                        minimumQuantity    = pDBRecord.BuildNonFractionNumber(QueryFields.minimumQuantityValue, QueryFields.minimumQuantityMultiplier),
                        quantityMultiplier = pDBRecord.BuildNonFractionNumber(QueryFields.quantityMultiplier, QueryFields.quantityMultiplierMultiplier),
                        Item            = pDBRecord.GetFieldValue <String>(QueryFields.unitName), //[unitID or unitName]
                        ItemElementName = ItemChoiceType11.unitName
                    }
                });
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(materialToSupplierMappings != null?materialToSupplierMappings.ToArray() : null);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Build Destination Record
        /// </summary>
        /// <param name="pDestinationTable"></param>
        /// <param name="pSourceRecord"></param>
        /// <param name="pMapping"></param>
        /// <returns></returns>
        public DBRecordInfo BuildDestinationRecord(DataTable pDestinationTable, DBRecordInfo pSourceRecord, List <FieldMappingInfo> pMapping)
        {
            DBRecordInfo destinationRecord = null;

            try
            {
                destinationRecord = new DBRecordInfo
                {
                    DbRecordID  = pSourceRecord.DbRecordID,
                    DbRecordKey = pSourceRecord.DbRecordKey,
                    Row         = pDestinationTable.NewRow(),
                };

                foreach (FieldMappingInfo fieldMapping in pMapping)
                {
                    destinationRecord.Row[fieldMapping.DestinationField.FieldName] =
                        this.GetMappedFieldResult(pSourceRecord, fieldMapping);
                }
            }
            catch { throw; }

            return(destinationRecord);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Build Material To Stock Mapping List
        /// </summary>
        /// <param name="pDBRecord"></param>
        /// <param name="pWincashWSAdapterConfig"></param>
        /// <returns></returns>
        internal static materialToStockMapping[] BuildMaterialToStockMappingList(DBRecordInfo pDBRecord, WincashWSAdapterConfig pWincashWSAdapterConfig)
        {
            List <materialToStockMapping> materialToStockMappings = null;

            try
            {
                string sStockMapping = pDBRecord.GetFieldValue <String>(QueryFields.stockMapping);

                if (!sStockMapping.IsValidString())
                {
                    return(null);
                }

                string[] stocksParts = sStockMapping.Split(pWincashWSAdapterConfig.StockMappingMainSplitter);

                foreach (string sStock in stocksParts)
                {
                    try
                    {
                        string[] stockItemParts = sStock.Split(pWincashWSAdapterConfig.StockMappingInnerSplitter);

                        if (stockItemParts != null && stockItemParts.Length == 8)
                        {
                            if (materialToStockMappings == null)
                            {
                                materialToStockMappings = new List <materialToStockMapping>();
                            }

                            materialToStockMappings.Add(new materialToStockMapping()
                            {
                                Item1              = stockItemParts[0],          //stockName
                                Item1ElementName   = Item1ChoiceType7.stockName,
                                isStandard         = stockItemParts[1].ToFlag(), //isStandard
                                masterDataSettings = new masterDataSettings()
                                {
                                    status          = stockItemParts[2].ToStatus(), //status
                                    statusSpecified = true
                                },
                                usageSettings = new stockUsageSettings()
                                {
                                    showSale              = stockItemParts[3].ToFlag(), //showSale
                                    showSaleSpecified     = true,
                                    showReturn            = stockItemParts[4].ToFlag(), //showReturn
                                    showReturnSpecified   = true,
                                    showOrder             = stockItemParts[5].ToFlag(), //showOrder
                                    showOrderSpecified    = true,
                                    showLeaseOut          = stockItemParts[6].ToFlag(), //showLeaseOut
                                    showLeaseOutSpecified = true,
                                    showLeaseIn           = stockItemParts[7].ToFlag(), //showLeaseIn
                                    showLeaseInSpecified  = true
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.LogException(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(materialToStockMappings != null?materialToStockMappings.ToArray() : null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Build Standard Material Object
        /// </summary>
        /// <param name="pDBRecord"></param>
        /// <returns></returns>
        internal static standardMaterial BuildStandardMaterialObject(DBRecordInfo pDBRecord, WincashWSAdapterConfig pWincashWSAdapterConfig)
        {
            standardMaterial material = null;

            try
            {
                if (pDBRecord == null || pDBRecord.Row == null)
                {
                    return(null);
                }

                material = new standardMaterial()
                {
                    materialNumber = pDBRecord.GetFieldValue <String>(QueryFields.materialNumber)
                };

                DateTime modificationStamp = WincashWSAdapterUtilities.ParseModificationStamp(
                    pDBRecord.GetFieldValue <String>(QueryFields.modificationStamp));

                if (modificationStamp != DateTime.MinValue)
                {
                    material.modificationStamp          = modificationStamp;
                    material.modificationStampSpecified = true;
                }

                if (!material.materialNumber.IsValidString())
                {
                    return(null);
                }

                #region Master Data Settings

                material.masterDataSettings = new masterDataSettings()
                {
                    status          = pDBRecord.GetFieldValue <String>(QueryFields.status).ToStatus(),
                    statusSpecified = true
                };

                #endregion

                #region Inheritance Settings

                material.inheritanceSettings = new inheritanceSettings()
                {
                    Item            = pDBRecord.GetFieldValue <String>(QueryFields.treeID), // [shopName or treeID]
                    ItemElementName = ItemChoiceType.treeID
                };

                #endregion

                #region General Settings

                // Material Name Translations
                List <translation> _materialNameTranslations = new List <translation>();
                _materialNameTranslations.Add(new translation()
                {
                    translatedLanguage = "EN",
                    translatedText     = pDBRecord.GetFieldValue <String>(QueryFields.materialName)
                });
                List <translation> _materialName2Translations = new List <translation>();
                _materialName2Translations.Add(new translation()
                {
                    translatedLanguage = "EN",
                    translatedText     = pDBRecord.GetFieldValue <String>(QueryFields.materialName2)
                });

                material.generalSettings = new generalSettings()
                {
                    materialName              = pDBRecord.GetFieldValue <String>(QueryFields.materialName),
                    materialNameTranslations  = _materialNameTranslations.ToArray(),
                    materialName2             = pDBRecord.GetFieldValue <String>(QueryFields.materialName2),
                    materialName2Translations = _materialName2Translations.ToArray(),
                    Item                   = pDBRecord.GetFieldValue <String>(QueryFields.goodsGroupName),
                    ItemElementName        = ItemChoiceType3.goodsGroupName,
                    Item1                  = pDBRecord.GetFieldValue <String>(QueryFields.materialGroupName),
                    Item1ElementName       = Item1ChoiceType2.materialGroupName,
                    Item2                  = pDBRecord.GetFieldValue <String>(QueryFields.unitName),
                    Item2ElementName       = Item2ChoiceType.unitName,
                    supplierMaterialNumber = pDBRecord.GetFieldValue <String>(QueryFields.supplierMaterialNumber)
                };

                #endregion

                #region Price Settings

                material.priceSettings = new priceSettings()
                {
                    price                              = pDBRecord.BuildNonFractionNumber(QueryFields.price, QueryFields.priceMultiplier),
                    Item                               = pDBRecord.GetFieldValue <String>(QueryFields.currencyName), // [currencyID or currencyName]
                    ItemElementName                    = ItemChoiceType4.currencyName,
                    Item1                              = pDBRecord.GetFieldValue <String>(QueryFields.taxNumber),    // [taxID or taxNumber]
                    Item1ElementName                   = Item1ChoiceType9.taxNumber,
                    denyPriceOverwriting               = pDBRecord.GetFieldValue <String>(QueryFields.denyPriceOverwriting).ToFlag(),
                    denyPriceOverwritingSpecified      = true,
                    denyReduction                      = pDBRecord.GetFieldValue <String>(QueryFields.denyReduction).ToFlag(),
                    denyReductionSpecified             = true,
                    allowNegativeReducedPrice          = pDBRecord.GetFieldValue <String>(QueryFields.allowNegativeReducedPrice).ToFlag(),
                    allowNegativeReducedPriceSpecified = true,
                    maximumPrice                       = pDBRecord.BuildNonFractionNumber(QueryFields.maximumPriceValue, QueryFields.maximumPriceMultiplier),
                    minimumPrice                       = pDBRecord.BuildNonFractionNumber(QueryFields.minimumPriceValue, QueryFields.minimumPriceMultiplier),
                    turnoverRelevancy                  = pDBRecord.BuildNonFractionNumber(QueryFields.turnoverRelevancyValue, QueryFields.turnoverRelevancyMultiplier),
                    priceListsAvailable                = pDBRecord.GetFieldValue <String>(QueryFields.priceListsAvailable).ToFlag(),
                    priceListsAvailableSpecified       = true
                };

                #endregion

                #region Serial Settings

                List <serialNumberDefinition> _serialNumberDefinitions = new List <serialNumberDefinition>();
                _serialNumberDefinitions.Add(new serialNumberDefinition()
                {
                    serialLength        = pDBRecord.GetFieldValue <String>(QueryFields.serialLength),
                    serialType          = pDBRecord.GetFieldValue <String>(QueryFields.serialType).ToSerialType(),
                    serialTypeSpecified = true
                });

                material.serialSettings = new serialSettings()
                {
                    forceSerial                = pDBRecord.GetFieldValue <String>(QueryFields.forceSerial).ToFlag(),
                    forceSerialSpecified       = true,
                    serialPoolTracked          = pDBRecord.GetFieldValue <String>(QueryFields.serialPoolTracked).ToFlag(),
                    serialPoolTrackedSpecified = true,
                    serialNumberDefinitions    = _serialNumberDefinitions.ToArray()
                };

                #endregion

                #region Inventory Handling

                material.inventoryHandling = new inventoryHandling()
                {
                    inventoryAssignments = WincashWSAdapterUtilities.BuildMaterialToStockMappingList(pDBRecord, pWincashWSAdapterConfig),
                    supplierAssignments  = WincashWSAdapterUtilities.BuildMaterialToSupplierList(pDBRecord, pWincashWSAdapterConfig),
                    valuationPrice       = pDBRecord.BuildNonFractionNumber(QueryFields.valuationPriceValue, QueryFields.valuationPriceMultiplier),
                    // Flags
                    stockControl                       = pDBRecord.GetFieldValue <String>(QueryFields.stockControl).ToFlag(),
                    stockControlSpecified              = true,
                    denyAutomaticOrder                 = pDBRecord.GetFieldValue <String>(QueryFields.denyAutomaticOrder).ToFlag(),
                    denyAutomaticOrderSpecified        = true,
                    denyNegativeStockQuantity          = pDBRecord.GetFieldValue <String>(QueryFields.denyNegativeStockQuantity).ToFlag(),
                    denyNegativeStockQuantitySpecified = true
                };

                #endregion

                #region Extended Settings

                List <translation> _materialDescriptionTranslations = new List <translation>();
                _materialDescriptionTranslations.Add(new translation()
                {
                    translatedLanguage = "EN",
                    translatedText     = pDBRecord.GetFieldValue <String>(QueryFields.materialDescription)
                });

                material.extendedSettings = new extendedSettings()
                {
                    usageSettings = new usageSettings()
                    {
                        allowQuantityOverwriting          = pDBRecord.GetFieldValue <String>(QueryFields.allowQuantityOverwriting).ToFlag(),
                        allowQuantityOverwritingSpecified = true,
                        rejectionReason                   = pDBRecord.GetFieldValue <String>(QueryFields.rejectionReason).ToFlag(),
                        rejectionReasonSpecified          = true,
                        isUseUserItemRestriction          = pDBRecord.GetFieldValue <String>(QueryFields.isUseUserItemRestriction).ToFlag(),
                        isUseUserItemRestrictionSpecified = true
                    },
                    extendedMaterialDescription = new extendedMaterialDescription()
                    {
                        materialDescription             = pDBRecord.GetFieldValue <String>(QueryFields.materialDescription),
                        materialDescriptionTranslations = _materialDescriptionTranslations.ToArray(),
                        hyperlink       = pDBRecord.GetFieldValue <String>(QueryFields.hyperlink),
                        materialPicture = pDBRecord.GetFieldValue <String>(QueryFields.materialPicture)
                    },
                    leaseSettings = new leaseSettings()
                    {
                        denyLeaseExchange          = pDBRecord.GetFieldValue <String>(QueryFields.denyLeaseExchange).ToFlag(),
                        denyLeaseExchangeSpecified = true
                    },
                    reservationSettings = new reservationSettings()
                    {
                        denyReservation          = pDBRecord.GetFieldValue <String>(QueryFields.denyReservation).ToFlag(),
                        denyReservationSpecified = true
                    }
                };

                #endregion
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }

            return(material);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Run Insert Query
 /// </summary>
 /// <param name="pApplicationDatabaseQuery"></param>
 /// <param name="pAdapterFields"></param>
 /// <param name="pDBRecord"></param>
 /// <returns></returns>
 public abstract RecordTransactionStatus RunInsertQuery(ApplicationDatabaseQuery pApplicationDatabaseQuery, ICollection <IntegrationAdapterField> pAdapterFields, DBRecordInfo pDBRecord);
Exemplo n.º 8
0
        /// <summary>
        /// Run Insert Query
        /// </summary>
        /// <param name="pApplicationDatabaseQuery"></param>
        /// <param name="pAdapterFields"></param>
        /// <param name="pDBRecord"></param>
        /// <returns></returns>
        public override RecordTransactionStatus RunInsertQuery(ApplicationDatabaseQuery pApplicationDatabaseQuery, ICollection <IntegrationAdapterField> pAdapterFields, DBRecordInfo pDBRecord)
        {
            RecordTransactionStatus recordTransactionStatus = RecordTransactionStatus.None;
            string lastParamName = string.Empty;

            try
            {
                using (OracleConnection connection = new OracleConnection(
                           pApplicationDatabaseQuery.ApplicationDatabas.ProviderConnectionString))
                {
                    using (OracleCommand command = new OracleCommand
                    {
                        Connection = connection,
                        CommandText = pApplicationDatabaseQuery.ApplicationDatabaseQueryCommand,
                        CommandType = CommandType.Text,
                        BindByName = true
                    })
                    {
                        foreach (IntegrationAdapterField field in pAdapterFields)
                        {
                            lastParamName = field.FieldName;
                            object paramValue = DataUtilities.GetFieldParameterValue(field, pDBRecord.Row, ApplicationDatabaseType.Oracle);

                            OracleParameter param = command.CreateParameter();
                            param.ParameterName = field.FieldName;
                            param.OracleDbType  = field.FieldOracleDbType;
                            param.Value         = paramValue;

                            command.Parameters.Add(param);
                        }

                        connection.Open();

                        if (command.ExecuteNonQuery() > 0)
                        {
                            recordTransactionStatus = RecordTransactionStatus.Succeeded;
                        }
                        else
                        {
                            recordTransactionStatus = RecordTransactionStatus.Failed;
                        }
                    }
                }
            }
            catch (OracleException dbException)
            {
                pDBRecord.ExceptionExtraMessage = lastParamName;

                if (dbException.Number == 2601) // Cannot insert duplicate keys //Or check ORA-00001: unique constraint (.) violated
                {
                    recordTransactionStatus = RecordTransactionStatus.Duplicated;
                    LogManager.LogException(dbException);
                }
                else
                {
                    recordTransactionStatus = RecordTransactionStatus.Failed;
                    throw dbException;
                }
            }
            catch (Exception ex)
            {
                pDBRecord.ExceptionExtraMessage = lastParamName;

                recordTransactionStatus = RecordTransactionStatus.Failed;
                throw ex;
            }
            finally
            {
            }

            return(recordTransactionStatus);
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Execute Integration Process
        /// </summary>
        /// <param name="pProcessExecutionRequest"></param>
        /// <returns></returns>
        public ProcessExecutionResponse ExecuteIntegrationProcess(ProcessExecutionRequest pProcessExecutionRequest)
        {
            ProcessExecutionResponse         response       = null;
            List <IntegrationProcessMapping> processMapping = null;
            DataTable destinationTable                        = null;
            List <FieldMappingInfo>  mappingInfos             = null;
            PushToDestinationRequest pushToDestinationRequest = null;
            string outputMessage = string.Empty;

            try
            {
                #region Integration Process Metadata

                LogManager.LogMessage(string.Format(ABATS.AppsTalk.Runtime.Properties.Resources.Message_Integration_Process_Execution_Start_Request,
                                                    pProcessExecutionRequest.ProcessCode));

                response = new ProcessExecutionResponse(pProcessExecutionRequest,
                                                        base.AppRuntime.MetadataService.GetIntegrationProcessMetatdata(pProcessExecutionRequest.ProcessCode));

                #endregion

                if (response != null && response.IntegrationProcessMetadata != null)
                {
                    LogManager.LogMessage(string.Format(ABATS.AppsTalk.Runtime.Properties.Resources.Message_Integration_Process_Execution_Started,
                                                        response.IntegrationProcessMetadata.IntegrationProcessCode,
                                                        response.IntegrationProcessMetadata.IntegrationProcessID,
                                                        response.IntegrationProcessMetadata.IntegrationProcessTitle));

                    if (this.ValidateIntegrationProcess(response.IntegrationProcessMetadata, out outputMessage))
                    {
                        LogManager.LogMessage(string.Format(ABATS.AppsTalk.Runtime.Properties.Resources.Message_Integration_Process_Validation_Succeeded,
                                                            response.IntegrationProcessMetadata.IntegrationProcessCode));

                        #region Consume Source

                        using (AbstractAdapter sourceAdapter = AdapterFactory.CreateAdapter(
                                   response.IntegrationProcessMetadata,
                                   response.IntegrationProcessMetadata.SourceIntegrationAdapter,
                                   base.AppRuntime))
                        {
                            response.SourceAdapterResponse = sourceAdapter.ConsumeSource();
                        }

                        #endregion

                        if (response.SourceAdapterResponse != null &&
                            response.SourceAdapterResponse.Status == OperationStatus.Succeeded)
                        {
                            LogManager.LogMessage(string.Format(ABATS.AppsTalk.Runtime.Properties.Resources.Message_Integration_Process_ConsumeSource_Succeeded,
                                                                response.IntegrationProcessMetadata.IntegrationProcessCode,
                                                                response.SourceAdapterResponse.Results.Count.SafeToString("0")));

                            #region Publish To Destination

                            pushToDestinationRequest = new PushToDestinationRequest(
                                pProcessExecutionRequest.RequestDate, pProcessExecutionRequest.RequestUser);

                            #region Mapping

                            processMapping = base.AppRuntime.DataService.GetAll(
                                DataUtilities.BuildIntegrationProcessMappingGetDataRequest(response.IntegrationProcessMetadata)).ToList();
                            destinationTable = new DataTable();
                            mappingInfos     = new List <FieldMappingInfo>();

                            foreach (IntegrationAdapterField destinationAdapterField in
                                     response.IntegrationProcessMetadata.DestinationIntegrationAdapter.IntegrationAdapterFields)
                            {
                                var mappingField = processMapping.FirstOrDefault(item =>
                                                                                 item.DestinationIntegrationAdapterFieldID == destinationAdapterField.IntegrationAdapterFieldID);

                                if (mappingField != null)
                                {
                                    mappingInfos.Add(new FieldMappingInfo()
                                    {
                                        SourceField      = mappingField.SourceIntegrationAdapterField,
                                        DestinationField = destinationAdapterField,
                                        MappingDetail    = mappingField
                                    });

                                    destinationTable.Columns.Add(destinationAdapterField.FieldName);
                                }
                            }

                            #endregion

                            #region Caching

                            // Handle the Integration Adapter Cahce
                            List <AdapterCacheResult> sourceQueryCahce = null;

                            using (AdapterCacheManager queryCacheManager = new AdapterCacheManager(base.AppRuntime))
                            {
                                sourceQueryCahce = queryCacheManager.BuildAdapterCacheResults(response.SourceAdapterResponse);
                            }

                            LogManager.LogMessage(string.Format(ABATS.AppsTalk.Runtime.Properties.Resources.Message_Integration_Process_Cache_Prepration_Completed,
                                                                sourceQueryCahce != null ? sourceQueryCahce.Count.ToString() : "0"));

                            foreach (AdapterCacheResult cacheItem in sourceQueryCahce)
                            {
                                try
                                {
                                    DBRecordInfo destinationRecord = this.FieldMappingManager.BuildDestinationRecord(
                                        destinationTable, cacheItem.DBRecord, mappingInfos);

                                    if (destinationRecord != null)
                                    {
                                        pushToDestinationRequest.AdapterCacheResults.Add(new AdapterCacheResult()
                                        {
                                            DBRecord      = destinationRecord,
                                            DBRecordCache = cacheItem.DBRecordCache
                                        });
                                    }
                                }
                                catch (Exception ex)
                                {
                                    string extraMessage = string.Format("Record Keys: {0} - Parameter: {1}",
                                                                        cacheItem.DBRecord != null ? cacheItem.DBRecord.DbRecordKey : "NO KEYS",
                                                                        cacheItem.DBRecord != null ? cacheItem.DBRecord.ExceptionExtraMessage : string.Empty);

                                    LogManager.LogException(ex, extraMessage);
                                }
                            }

                            #endregion

                            #region Destination Adapter Push Request

                            using (AbstractAdapter destinationAdapter = AdapterFactory.CreateAdapter(
                                       response.IntegrationProcessMetadata,
                                       response.IntegrationProcessMetadata.DestinationIntegrationAdapter,
                                       base.AppRuntime))
                            {
                                response.DestinationAdapterResponse = destinationAdapter.PublishToDestination(
                                    pushToDestinationRequest);

                                if (response.DestinationAdapterResponse != null &&
                                    response.DestinationAdapterResponse.Status == OperationStatus.Succeeded)
                                {
                                    response.Status  = OperationStatus.Succeeded;
                                    response.Message = string.Format(Properties.Resources.Message_Integration_Process_Execution_Succeeded,
                                                                     response.IntegrationProcessMetadata.IntegrationProcessCode);
                                }
                                else
                                {
                                    response.Status  = OperationStatus.Failed;
                                    response.Message = string.Format(Properties.Resources.Message_Integration_Process_Execution_Failed,
                                                                     response.IntegrationProcessMetadata.IntegrationProcessCode);
                                }
                            }

                            #endregion

                            #endregion
                        }
                        else
                        {
                            response.Status  = OperationStatus.Failed;
                            response.Message = string.Format(Properties.Resources.Message_Consume_Source_Failed,
                                                             response.IntegrationProcessMetadata.IntegrationProcessCode);
                        }
                    }
                    else
                    {
                        response.Status  = OperationStatus.Failed;
                        response.Message = string.Format(Properties.Resources.Message_Metadata_Validation_Failed,
                                                         response.IntegrationProcessMetadata.IntegrationProcessCode, Environment.NewLine, outputMessage);
                    }
                }
                else
                {
                    response.Status  = OperationStatus.Failed;
                    response.Message = string.Format(Properties.Resources.Message_Fetch_integration_Process_Metadata_Failed,
                                                     pProcessExecutionRequest.ProcessCode);
                }
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
            }
            finally
            {
                if (response != null && !string.IsNullOrEmpty(response.Message))
                {
                    LogManager.LogMessage(response.Message, response.Status);
                }

                if (response != null)
                {
                    //Log Integration Transaction
                    using (TransactionLogManager transactionLogManager = new TransactionLogManager(base.AppRuntime))
                    {
                        transactionLogManager.LogIntegrationProcessTransaction(response);
                    }
                }

                outputMessage = null;
            }

            return(response);
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Get Mapped Field Result
        /// </summary>
        /// <param name="pSourceRecord"></param>
        /// <param name="pMappingInfo"></param>
        /// <returns></returns>
        public object GetMappedFieldResult(DBRecordInfo pSourceRecord, FieldMappingInfo pMappingInfo)
        {
            object result = null;

            try
            {
                DataTypes sourceDataType      = (DataTypes)pMappingInfo.SourceField.FieldDataType;
                DataTypes destinationDataType = (DataTypes)pMappingInfo.DestinationField.FieldDataType;

                if (pSourceRecord.Row != null)
                {
                    if (pSourceRecord.Row.Table.Columns.Contains(pMappingInfo.SourceField.FieldName))
                    {
                        result = pSourceRecord.Row[pMappingInfo.SourceField.FieldName];

                        if (result != null && sourceDataType != destinationDataType)
                        {
                            #region Data Type Conversion

                            try
                            {
                                switch (destinationDataType)
                                {
                                case DataTypes.String:
                                {
                                    result = result.ToString();
                                }
                                break;

                                case DataTypes.Boolean:
                                {
                                    result = Convert.ToBoolean(result);
                                }
                                break;

                                case DataTypes.DateTime:
                                {
                                    result = Convert.ToDateTime(result);
                                }
                                break;

                                case DataTypes.Integer:
                                {
                                    result = Convert.ToInt32(result);
                                }
                                break;

                                case DataTypes.Enum:
                                {
                                    //Not Implemented
                                }
                                break;

                                case DataTypes.Double:
                                {
                                    result = Convert.ToDouble(result);
                                }
                                break;

                                case DataTypes.Decimal:
                                {
                                    result = Convert.ToDecimal(result);
                                }
                                break;

                                case DataTypes.None:
                                default:
                                { }
                                break;
                                }
                            }
                            catch
                            {
                                // Sallow the Data Conversion Exception
                            }

                            #endregion
                        }
                    }
                }
            }
            catch { throw; }

            return(result);
        }