Exemplo n.º 1
0
        private static void HandleSEWithoutAlias(Models.XformTransformationDetail transformationStepdetail, List <Models.SchemaColumnDetail> xformRawDbColumns, List <Models.SchemaColumnDetail> xformInterimDbColumns, Models.CSVBuilderTransformationListXML csvStrategyList)
        {
            var convertibleCSVStrategyList = csvStrategyList.MetaDataToStrategyList.Where(x => x.ExpressionButtonHeader.Equals("...")).ToList();

            List <string> columnadded = new List <string>();

            int nullcount    = 0;
            int correctCount = 0;
            var xformData    = new XformData();

            log.Info(" ");
            log.Info(" ");
            log.Info("----------------------------------------");
            log.Info("Handling of Simple Expression Starting");
            synth.Speak("Handling of Simple Expression Starting");

            foreach (var item in convertibleCSVStrategyList)
            {
                var csvrawdbColumn       = GetRequiredFieldName(item.Field.Name);
                var csvInterimColumnName = GetRequiredFieldName(item.Alias ?? item.Field.Name);

                var xformRawDBName = xformRawDbColumns.FirstOrDefault(x => x.ColumnName.Equals(csvrawdbColumn, StringComparison.InvariantCultureIgnoreCase));

                var xformInterimDBName = xformInterimDbColumns.FirstOrDefault(x => x.ColumnName.Equals(csvInterimColumnName, StringComparison.InvariantCultureIgnoreCase));
                if (xformRawDBName == null || xformInterimDBName == null)
                {
                    nullcount = nullcount + 1;
                }
                if (xformRawDBName != null && xformInterimDBName != null && !columnadded.Contains(xformInterimDBName.ColumnName))
                {
                    string expressionText = MakeExpressionText(xformRawDBName, xformInterimDBName);
                    int    xformMappingId = xformData.InsertInXformMappingTable(transformationStepdetail, expressionText);

                    int outputofRawColumn = xformData.InsertinXformMappingFieldTable(xformMappingId, xformRawDBName.Id, 1);
                    if (outputofRawColumn != 0)
                    {
                        Console.WriteLine(string.Format("Value inserted for RawColumn {0}", xformRawDBName.ColumnName));
                        log.InfoFormat("RawColumn: {0}", xformRawDBName.ColumnName);
                    }
                    int outputofintermColumn = xformData.InsertinXformMappingFieldTable(xformMappingId, xformInterimDBName.Id, 1);
                    if (outputofintermColumn != 0)
                    {
                        Console.WriteLine(string.Format("Value inserted for Interim {0}", xformInterimDBName.ColumnName));
                        log.InfoFormat("InterimColumn: {0}", xformInterimDBName.ColumnName);
                    }
                    correctCount = correctCount + 1;
                    columnadded.Add(xformInterimDBName.ColumnName);
                }
            }

            log.Info("Handling of Simple Expression Ending");
            log.Info("----------------------------------------");

            Console.WriteLine("Null Count={0}, Correct Count={1}", nullcount, correctCount);
            synth.Speak("Handling of Simple Expression Ending");
            columnadded = null;
        }
Exemplo n.º 2
0
        private static void HandleCEWithAlias(Models.XformTransformationDetail transformationStepdetail, List <Models.SchemaColumnDetail> xformRawDbColumns, List <Models.SchemaColumnDetail> xformInterimDbColumns, Models.CSVBuilderTransformationListXML csvStrategyList)
        {
            var convertibleCSVStrategyList = csvStrategyList.MetaDataToStrategyList.Where(x => x.ExpressionButtonHeader.Equals("E") && !x.Field.Expression.ToLower().Contains("portrecon.")).ToList();

            List <string> columnadded = new List <string>();

            int    nullcount      = 0;
            int    correctCount   = 0;
            string expressionText = string.Empty;
            int    xformMappingId = 0;
            bool   ifconvertible;

            var xformData = new XformData();

            log.Info("----------------------------------------");
            log.Info("Handling of Complex Expression starting");
            synth.Speak("Handling of Complex Expression Starting");


            foreach (var item in convertibleCSVStrategyList)
            {
                List <string> csvrawdbColumns      = MakeRawDbColumnFromExpression(item.Field.Expression, xformRawDbColumns);
                var           csvInterimColumnName = GetRequiredFieldName(item.Alias);
                var           xformInterimDBName   = xformInterimDbColumns.FirstOrDefault(x => x.ColumnName.Equals(csvInterimColumnName, StringComparison.InvariantCultureIgnoreCase));

                if (xformInterimDBName != null && !columnadded.Contains(xformInterimDBName.SchemaName.ToString() + xformInterimDBName.ColumnName.ToString()) && csvrawdbColumns.Count > 0)
                {
                    string rawdbexpressionText = MakeComplexExpression(item.Field.Expression, xformRawDbColumns.FirstOrDefault().SchemaName, csvrawdbColumns, xformRawDbColumns, out ifconvertible);
                    if (ifconvertible == true)
                    {
                        expressionText = MakeExpressionTextforCE(xformInterimDBName, ConvertToXformColumnsCase(rawdbexpressionText, csvrawdbColumns, xformRawDbColumns));
                        xformMappingId = xformData.InsertInXformMappingTable(transformationStepdetail, expressionText);

                        log.InfoFormat("Expression: {0}", expressionText);
                        int outputofintermColumn = xformData.InsertinXformMappingFieldTable(xformMappingId, xformInterimDBName.Id, 1);
                        if (outputofintermColumn != 0)
                        {
                            columnadded.Add(xformInterimDBName.SchemaName.ToString() + xformInterimDBName.ColumnName.ToString());

                            Console.WriteLine(string.Format("Value inserted for Interim {0}", xformInterimDBName.ColumnName));
                            log.InfoFormat("InterimColumn: {0}", xformInterimDBName.ColumnName);
                            correctCount = correctCount + 1;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                foreach (var csvrawcolumn in csvrawdbColumns)
                {
                    var xformRawDBName = xformRawDbColumns.FirstOrDefault(x => x.ColumnName.Equals(csvrawcolumn, StringComparison.InvariantCultureIgnoreCase));
                    if (xformRawDBName == null || xformInterimDBName == null)
                    {
                        nullcount = nullcount + 1;
                    }
                    if (xformRawDBName != null && xformInterimDBName != null &&
                        !columnadded.Contains(xformInterimDBName.SchemaName.ToString() + xformInterimDBName.ColumnName.ToString() + xformRawDBName.SchemaName.ToString() + xformRawDBName.ColumnName.ToString()))
                    {
                        int outputofRawColumn = xformData.InsertinXformMappingFieldTable(xformMappingId, xformRawDBName.Id, 1);
                        if (outputofRawColumn != 0)
                        {
                            columnadded.Add(xformInterimDBName.SchemaName.ToString() + xformInterimDBName.ColumnName.ToString() + xformRawDBName.SchemaName.ToString() + xformRawDBName.ColumnName.ToString());

                            Console.WriteLine(string.Format("Value inserted for RawColumn {0}", xformRawDBName.ColumnName));

                            log.InfoFormat("RawColumn: {0}", xformRawDBName.ColumnName);
                        }
                    }
                }
            }

            log.Info("Handling of Complex Expression Ending");
            log.Info("----------------------------------------");
            synth.Speak("Handling of Complex Expression Ending");

            Console.WriteLine("Null Count={0}, Correct Count={1}", nullcount, correctCount);
            columnadded = null;
        }