Example #1
0
        /// <summary>
        /// Before add policies record into BOALedger database, we will try to update value from Workbook_SOA Table
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="sourceDatabase"></param>
        /// <param name="destinationDatabase"></param>
        /// <param name="record"></param>
        public override void BeforeMappingRecord(MappingManager manager, SourceDatabase sourceDatabase, DestinationDatabase destinationDatabase, object obj)
        {
            //
            // Cast type
            DatabaseConversion.CleanerTool.BOALedgerDataAccess.policies record = obj as DatabaseConversion.CleanerTool.BOALedgerDataAccess.policies;


            //
            // Check does this record reference to workbooks table or not ?
            // If it does, we need to check the value of
            if (record.pol_wor_id.HasValue)
            {
                DatabaseConversion.CleanerTool.EclipseDataAccess.EclipseDatabaseEntities sourceDbContext = sourceDatabase.GetNewDbContext() as DatabaseConversion.CleanerTool.EclipseDataAccess.EclipseDatabaseEntities;


                //
                // Get related workbook_SOA record
                DatabaseConversion.CleanerTool.EclipseDataAccess.Workbook_SOA workbook_SOARecord =
                    (from workbook_SOATable in sourceDbContext.Workbook_SOA
                     join workbooksTable in sourceDbContext.workbooks on workbook_SOATable.ws_parent_id equals workbooksTable.wor_id
                     where workbooksTable.wor_id == record.pol_wor_id.Value
                     select workbook_SOATable).FirstOrDefault();


                //
                // If not null, try to convert and assign new value to record
                if (workbook_SOARecord != null)
                {
                    if (workbook_SOARecord.ws_scopeofadvice != null)
                    {
                        record.pol_scope_of_advice = WordGenerator.ConvertRtfToHtml(WordGenerator.ConvertDocxToRTF(workbook_SOARecord.ws_scopeofadvice));
                    }
                    if (workbook_SOARecord.ws_recommendations != null)
                    {
                        record.pol_recommendations = WordGenerator.ConvertRtfToHtml(WordGenerator.ConvertDocxToRTF(workbook_SOARecord.ws_recommendations));
                    }
                    if (workbook_SOARecord.ws_notice1 != null)
                    {
                        record.pol_notice1 = WordGenerator.ConvertRtfToHtml(WordGenerator.ConvertDocxToRTF(workbook_SOARecord.ws_notice1));
                    }
                    if (workbook_SOARecord.ws_notice2 != null)
                    {
                        record.pol_notice2 = WordGenerator.ConvertRtfToHtml(WordGenerator.ConvertDocxToRTF(workbook_SOARecord.ws_notice2));
                    }
                    if (workbook_SOARecord.ws_notice3 != null)
                    {
                        record.pol_notice3 = WordGenerator.ConvertRtfToHtml(WordGenerator.ConvertDocxToRTF(workbook_SOARecord.ws_notice3));
                    }
                }
            }
        }
        /// <summary>
        /// Custom mapper function for policies table
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        protected DatabaseConversion.CleanerTool.BOALedgerDataAccess.policies CustomMapper_policies(DatabaseConversion.CleanerTool.EclipseDataAccess.policies source)
        {
            //
            // Initialize result
            DatabaseConversion.CleanerTool.BOALedgerDataAccess.policies destination = new DatabaseConversion.CleanerTool.BOALedgerDataAccess.policies();
            //
            // Set basic properties
            destination.pol_id = source.pol_id;
            destination.pol_parent_id = source.pol_parent_id;
            destination.pol_created_who = source.pol_created_who;
            destination.pol_created_when = source.pol_created_when;
            destination.pol_updated_who = source.pol_updated_who;
            destination.pol_updated_when = source.pol_updated_when;
            destination.pol_duration = source.pol_duration;
            destination.pol_closed = source.pol_closed;
            destination.pol_insurer = source.pol_insurer;
            destination.pol_date_from = source.pol_date_from;
            destination.pol_date_to = source.pol_date_to;
            destination.pol_date_effective = source.pol_date_effective;
            destination.pol_cover_note_number = source.pol_cover_note_number;
            destination.pol_policy_number = source.pol_policy_number;
            destination.pol_sum_insured = source.pol_sum_insured;
            destination.pol_sub_agent = source.pol_sub_agent;
            destination.pol_location = source.pol_location;
            destination.pol_total_base_premium = source.pol_total_base_premium;
            destination.pol_total_levies = source.pol_total_levies;
            destination.pol_total_duties = source.pol_total_duties;
            destination.pol_total_fees = source.pol_total_fees;
            destination.pol_total_gross_premium = source.pol_total_gross_premium;
            destination.pol_total_commission = source.pol_total_commission;
            destination.pol_other_parties = source.pol_other_parties;
            destination.pol_insured = source.pol_insured;
            destination.pol_total_net_premium = source.pol_total_net_premium;
            destination.pol_wor_id = source.pol_wor_id;
            destination.pol_locked = source.pol_locked;
            destination.pol_posted_when = source.pol_posted_when;
            destination.pol_billing_when = source.pol_billing_when;
            destination.pol_closing_when = source.pol_closing_when;
            destination.pol_transaction_type = source.pol_transaction_type;
            destination.pol_tran_id = source.pol_tran_id;
            destination.pol_sub_agent_comm_payable = source.pol_sub_agent_comm_payable;
            destination.pol_debtor = source.pol_debtor;
            destination.pol_insurer_gst = source.pol_insurer_gst;
            destination.pol_date_due = source.pol_date_due;
            destination.pol_sub_agent_fee_payable = source.pol_sub_agent_fee_payable;
            destination.pol_sub_agent_total_payable = source.pol_sub_agent_total_payable;
            destination.pol_date_remitted = source.pol_date_remitted;
            destination.pol_amount_remitted = source.pol_amount_remitted;
            destination.pol_date_remitted_sub = source.pol_date_remitted_sub;
            destination.pol_amount_remitted_sub = source.pol_amount_remitted_sub;
            destination.pol_fee_gst = source.pol_fee_gst;
            destination.pol_comm_gst = source.pol_comm_gst;
            destination.pol_sub_agent_fee_payable_gst = source.pol_sub_agent_fee_payable_gst;
            destination.pol_sub_agent_comm_payable_gst = source.pol_sub_agent_comm_payable_gst;
            destination.pol_total_gst = source.pol_total_gst;
            destination.pol_fee_net_gst = source.pol_fee_net_gst;
            destination.pol_comm_net_gst = source.pol_comm_net_gst;
            destination.pol_sub_agent_fee_pay_net_gst = source.pol_sub_agent_fee_pay_net_gst;
            destination.pol_sub_agent_comm_pay_net_gst = source.pol_sub_agent_comm_pay_net_gst;
            destination.pol_invoice_total = source.pol_invoice_total;
            destination.pol_base_premium = source.pol_base_premium;
            destination.pol_uw_fee_gst = source.pol_uw_fee_gst;
            destination.pol_uw_fee_net_gst = source.pol_uw_fee_net_gst;
            destination.pol_reversed = source.pol_reversed;
            destination.pol_br_net_com_writeoff = source.pol_br_net_com_writeoff;
            destination.pol_net_br_adjustment = source.pol_net_br_adjustment;
            destination.pol_hvi_value = source.pol_hvi_value;
            destination.pol_limited_exemption = source.pol_limited_exemption;
            destination.pol_exemption_type = source.pol_exemption_type;
            destination.pol_posted_who = source.pol_posted_who;
            destination.pol_step = null;

            //
            // Return result
            return destination;
        }