CreateStructuredDataStructure() публичный Метод

Creates a structured data structure StructuredDataStructure and persists the entity in the database.
public CreateStructuredDataStructure ( string name, string description, string xsdFileName, string xslFileName, DataStructureCategory indexerType, Variable indexer = null ) : StructuredDataStructure
name string The name of the data structure
description string A free text describing the purpose, usage, and/or the domain of the data structure usage.
xsdFileName string Not in use.
xslFileName string Not in use.
indexerType DataStructureCategory If the data structure is used as a matrix, The indexer type show what kind of column would be represented by the indexer variable.
indexer BExIS.Dlm.Entities.DataStructure.Variable The variable indicating the first indexing column of the matrix, if the data structure is representing a matrix.
Результат BExIS.Dlm.Entities.DataStructure.StructuredDataStructure
Пример #1
0
 public MessageModel storeDataStructure(long Id, string Name, bool isStructured, string Description ="", string cssId = "", bool inUse = false)
 {
     Name = Server.UrlDecode(Name);
     Description = Server.UrlDecode(Description);
     MessageModel DataStructureValidation = MessageModel.validateDataStructureInUse(Id);
     if (DataStructureValidation.hasMessage && inUse == false)
     {
         return DataStructureValidation;
     }
     else
     {
         DataStructureValidation = MessageModel.validateDataStructureName(Id, Name, cssId);
         if (DataStructureValidation.hasMessage)
         {
             return DataStructureValidation;
         }
         else
         {
             DataStructureManager dataStructureManager = new DataStructureManager();
             DataStructure dataStructure;
             if (isStructured)
             {
                 if (Id == 0)
                 {
                     dataStructure = dataStructureManager.CreateStructuredDataStructure(Name.Trim(), Description.Trim(), null, null, DataStructureCategory.Generic);
                     LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                     return new MessageModel()
                     {
                         Message = dataStructure.Id.ToString(),
                         hasMessage = false,
                         CssId = "redirect"
                     };
                 }
                 else
                 {
                     StructuredDataStructure StructuredDataStructure = dataStructureManager.StructuredDataStructureRepo.Get(Id);
                     StructuredDataStructure.Name = Name;
                     StructuredDataStructure.Description = Description;
                     dataStructure = dataStructureManager.UpdateStructuredDataStructure(StructuredDataStructure);
                     LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                     return new MessageModel()
                     {
                         Message = Id.ToString(),
                         hasMessage = false,
                         CssId = "redirect"
                     };
                 }
             }
             else
             {
                 if (Id == 0)
                 {
                     dataStructure = dataStructureManager.CreateUnStructuredDataStructure(Name.Trim(), Description.Trim());
                     LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                     return new MessageModel()
                     {
                         Message = "refresh DataStructureResultGrid",
                         hasMessage = false,
                         CssId = "refresh"
                     };
                 }
                 else
                 {
                     UnStructuredDataStructure unStructuredDataStructure = dataStructureManager.UnStructuredDataStructureRepo.Get(Id);
                     unStructuredDataStructure.Name = Name;
                     unStructuredDataStructure.Description = Description;
                     dataStructure = dataStructureManager.UpdateUnStructuredDataStructure(unStructuredDataStructure);
                     LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                     return new MessageModel()
                     {
                         Message = "refresh DataStructureResultGrid",
                         hasMessage = false,
                         CssId = "refresh"
                     };
                 }
             }
         }
     }
 }
Пример #2
0
        public DataStructure CreateDataStructure(string dataSetID, DataTable mapVariables, List<string> variableNames)
        {
            DataStructureManager dataStructureManager = new DataStructureManager();
            DataContainerManager attributeManager = new DataContainerManager();
            StructuredDataStructure dataStructure = new StructuredDataStructure();
            UnitManager unitManager = new UnitManager();

            // values of DataStructure
            ExcelTemplateProvider provider = new ExcelTemplateProvider();
            string name = "oldBExIS" + dataSetID;
            string description = "old BExIS datastructure, created for " + dataSetID + ", possibly used by other"; //metadata.Title;
            string xsdFileName = "";//"xsdFileName";
            string xslFileName = "";//"xslFileName";
            DataStructureCategory indexerType = DataStructureCategory.Generic;

            // if dataStructure not exists
            StructuredDataStructure existDS = existingDataStructures(mapVariables, dataSetID);
            if (existDS.Name == null)
            {
                // create dataStructure
                dataStructure = dataStructureManager.CreateStructuredDataStructure(name, description, xsdFileName, xslFileName, indexerType, null);

                foreach (string varName in variableNames)
                {
                    // values of variables
                    string attName = "";
                    string convFactor = "";
                    string varDescription = "";
                    int Block = -999;
                    long AttributeId = -999, UnitId = -999, VarUnitId = -999;
                    foreach (DataRow mapRow in mapVariables.Select("DatasetId = '" + dataSetID + "'"))
                    {
                        if (mapRow["Name"].ToString() == varName)
                        {
                            attName = mapRow["Attribute"].ToString();
                            convFactor = mapRow["ConvFactor"].ToString();
                            varDescription = mapRow["Description"].ToString();
                            Block = int.Parse(mapRow["Block"].ToString());
                            if (attName.Length > 1) // if not mapped yet
                            {
                                AttributeId = Convert.ToInt64(mapRow["AttributeId"].ToString());
                                UnitId = Convert.ToInt64(mapRow["UnitId"].ToString());
                                if (mapRow["Unit"].ToString().Length > 0)
                                    VarUnitId = Convert.ToInt64(mapRow["VarUnitId"].ToString());
                            }
                        }
                    }

                    if (AttributeId > 0 && Block == 0) // if not mapped yet AND variable is in block 0
                    {
                        // find existing attribute for each variable
                        DataAttribute attribute = attributeManager.DataAttributeRepo.Get(AttributeId);

                        Unit varUnit = null;
                        if (VarUnitId > 0)
                        {
                            varUnit = unitManager.Repo.Get(VarUnitId);
                        }

                        // add variables to dataStructure
                        Variable variable = dataStructureManager.AddVariableUsage(dataStructure, attribute, true, varName, null, null, varDescription, varUnit);
                        dataStructure.Variables.Add(variable);
                    }
                }
                provider.CreateTemplate(dataStructure);
                return dataStructure;
            }
            else
            {
                return existDS;
            }
        }