Esempio n. 1
0
        public void InvokeTableCreate(Authentication authentication, string tableName, string categoryPath, CremaDataTable dataTable, Table sourceTable)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableCreate), tableName, categoryPath, sourceTable);
            this.ValidateCreate(authentication, categoryPath);

            var category   = this.GetCategory(categoryPath);
            var schemaPath = this.Context.GenerateTableSchemaPath(categoryPath, tableName);
            var xmlPath    = this.Context.GenerateTableXmlPath(categoryPath, tableName);

            try
            {
                if (sourceTable != null)
                {
                    if (dataTable.TemplateNamespace == string.Empty)
                    {
                        this.Repository.Copy(sourceTable.SchemaPath, schemaPath);
                        this.Repository.Modify(schemaPath, dataTable.GetXmlSchema());
                        this.Repository.Copy(sourceTable.XmlPath, xmlPath);
                        this.Repository.Modify(xmlPath, dataTable.GetXml());
                    }
                    else
                    {
                        this.Repository.Copy(sourceTable.XmlPath, xmlPath);
                        this.Repository.Modify(xmlPath, dataTable.GetXml());
                    }
                }
                else
                {
                    this.Repository.Add(schemaPath, dataTable.GetXmlSchema());
                    this.Repository.Add(xmlPath, dataTable.GetXml());
                }
                this.Context.InvokeTableItemCreate(authentication, categoryPath + tableName);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }
Esempio n. 2
0
 public static void CompareXml(CremaDataTable table1, CremaDataTable table2)
 {
     try
     {
         Assert.AreEqual(table1.GetXml(), table2.GetXml(), "Xml");
     }
     catch
     {
         File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "table1" + CremaSchema.SchemaExtension), table1.GetXmlSchema());
         File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "table2" + CremaSchema.SchemaExtension), table2.GetXmlSchema());
         File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "table1" + CremaSchema.XmlExtension), table1.GetXml());
         File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "table2" + CremaSchema.XmlExtension), table2.GetXml());
         throw;
     }
 }