Example #1
0
        // Add an Sql verification specification to the annotation at the batch.
        public static void AddSqlVerificationSpec(DataPool pool, SqlVerificationSepc spec)
        {
            // Read existing annotation from batch or create new one
            List <SqlVerificationSepc> specs;
            Annotation SqlVerificationSpecAnnotation = pool.RootNode.Annotations[SqlVerificationSpecsAnnotationName];

            if (SqlVerificationSpecAnnotation == null)
            {
                specs = new List <SqlVerificationSepc>();
            }
            else
            {
                specs = SIEESerializer.StringToObject(SqlVerificationSpecAnnotation.Value) as List <SqlVerificationSepc>;
            }

            // If this annotation does not already exists add the current one
            if (specs.Where(n => n.Name == spec.Name).Count() == 0)
            {
                specs.Add(spec);
                // Create new annotation if none had been there
                if (SqlVerificationSpecAnnotation == null)
                {
                    SqlVerificationSpecAnnotation = new Annotation(pool, SqlVerificationSpecsAnnotationName);
                    pool.RootNode.Annotations.Add(SqlVerificationSpecAnnotation);
                }
                // Store all SqlSpecs at the annotation
                SqlVerificationSpecAnnotation.Value = SIEESerializer.ObjectToString(specs);
            }
        }
Example #2
0
        private XmlDocument SqlVerification(DataPool pool)
        {
            Annotation verify = pool.RootNode.Annotations[ScriptingUtilities.SqlVerifyAnnotationName];

            if (verify != null)                           // is sql verification demanded?
            {
                pool.RootNode.Annotations.Remove(verify); // reset annotation, it should be done only for this step

                SqlVerificationSepc spec = specs.Where(n => n.Name == verify.Value).FirstOrDefault();
                if (spec == null) // do we have this SqlSpec not yet in cache?
                {
                    // Read SqlSpec from annotation
                    Annotation specsAnnotation = pool.RootNode.Annotations[ScriptingUtilities.SqlVerificationSpecsAnnotationName];
                    if (specsAnnotation == null)
                    {
                        throw new Exception("No SqlVerificationSpecs found");
                    }
                    specs = SIEESerializer.StringToObject(specsAnnotation.Value) as List <SqlVerificationSepc>;
                    spec  = specs.Where(n => n.Name == verify.Value).FirstOrDefault();
                    if (spec == null)
                    {
                        throw new Exception("SqlVerificationSpec " + verify.Value + " not found");
                    }
                }
                sqlVerify(pool, spec); // do it...
            }
            return(pool.XmlDocument);
        }
Example #3
0
        private XmlDocument tableColumnWise(DataPool pool)
        {
            loadSchema(pool);

            foreach (Document doc in pool.RootNode.Documents)
            {
                Annotation tcwAnnoation = doc.Annotations[ScriptingUtilities.TableColumnWise_AnnotationName];
                if (tcwAnnoation == null)
                {
                    continue;
                }
                string tableName = tcwAnnoation.Value;

                List <KeyValuePair <string, string> > mapping = null;
                Annotation tcwMappingAnnoation = doc.Annotations[ScriptingUtilities.TableColumnWiseMapping_AnnotationName];
                if (tcwMappingAnnoation != null)
                {
                    mapping = (List <KeyValuePair <string, string> >)SIEESerializer.StringToObject(tcwMappingAnnoation.Value);
                }

                Table table = doc.Fields[tableName] as Table;
                table.Rows.Add("row");
                int nofRows = getNofRows(doc, table, mapping);
                for (int i = 0; i < nofRows - 1; i++)
                {
                    table.Rows.Add("row");
                }

                foreach (string column in getColumnNames(table.Rows[0] as TableRow))
                {
                    string fieldName = tcwMap(column, mapping);
                    if (fieldName == null)
                    {
                        continue;
                    }

                    int i = 0;
                    foreach (Field f in getFieldAlternatives(doc, fieldName))
                    {
                        if (i++ < nofRows)
                        {
                            Field newField = f.Clone() as Field;
                            newField.Rename(column);
                            table.Rows[i - 1].Fields[column] = newField;
                        }
                    }
                }
            }
            return(pool.XmlDocument);
        }
        public static void TableColumnWise(DataPool pool, string tableName, Dictionary <string, string> nameMapping = null)
        {
            List <KeyValuePair <string, string> > mapping = null;

            if (nameMapping != null)
            {
                mapping = nameMapping.ToList();
            }

            foreach (Document doc in pool.RootNode.Documents)
            {
                doc.Annotations.Add(new Annotation(pool, TableColumnWise_AnnotationName, tableName));
                if (nameMapping != null)
                {
                    doc.Annotations.Add(new Annotation(pool,
                                                       TableColumnWiseMapping_AnnotationName,
                                                       SIEESerializer.ObjectToString(mapping)));
                }
            }
            //File.WriteAllText(@"c:\temp\tt.txt", TableColumnWiseMapping_AnnotationName + " -5- ");
        }
 public static object Clone(object o)
 {
     return(SIEESerializer.StringToObject(SIEESerializer.ObjectToString(o)));
 }