Exemplo n.º 1
0
 public void Data2DataBase(DataSet dataSet, StandardDef standard)
 {
     try
     {
         foreach (DataTable table in dataSet.Tables)
         {
             DGObjectDef dGObject   = standard.GetDGObjectDefByName(table.TableName);
             string      typeName   = "iS3_DataManager.ObjectModels." + dGObject.Code;
             Type        type       = Type.GetType(typeName);
             var         properties = type.GetProperties();
             int         count      = properties.Length;
             foreach (DataRow row in table.Rows)
             {
                 object[] project = new object[35];
                 int      index   = 0;
                 foreach (PropertyMeta meta in dGObject.PropertyContainer)
                 {
                     project[index++] = row[meta.LangStr];
                 }
                 var instance = Activator.CreateInstance(type, project);
             }
         }
     }
     catch (Exception x)
     {
         throw x;
     }
 }
        public DataSet Import(string path, StandardDef standard)
        {
            try
            {
                string    domainName = Path.GetFileNameWithoutExtension(path);
                DomainDef domain     = standard.DomainContainer.Find(x => x.Code == domainName | x.LangStr == domainName);
                DataSet   ds         = new DataSet(domainName);

                IWorkbook wb = ReadWorkbook(path);

                List <string> sheetNames = GetSheetNames(wb);
                //sheetNames equal to objectName
                foreach (string sheetName in sheetNames)
                {
                    DGObjectDef objectDef = standard.GetDGObjectDefByName(sheetName);
                    DataTable   dt        = ReadSheet(wb.GetSheet(sheetName), objectDef);
                    if (dt != null)
                    {
                        ds.Tables.Add(dt);
                    }
                }

                return(ds);
            }

            catch (Exception)
            {
                System.Windows.MessageBox.Show("Check if the Standard adapt to data");
                return(null);
            }
        }
Exemplo n.º 3
0
        public DataSet Import(string path, StandardDef standard)
        {
            //try
            //{
            string domainName = Path.GetFileNameWithoutExtension(path);
            //  StageDef domain = standard.StageContainer.Find(x => x.Code == domainName | x.LangStr == domainName);
            DataSet ds = new DataSet()
            {
                DataSetName = domainName
            };

            try
            {
                IWorkbook wb = ReadWorkbook(path);

                List <string> sheetNames = GetSheetNames(wb);
                //sheetNames equal to objectName
                foreach (string sheetName in sheetNames)
                {
                    DGObjectDef objectDef = standard.GetDGObjectDefByName(sheetName);

                    DataTable dt = ReadSheet(wb.GetSheet(sheetName), objectDef);
                    if (dt != null)
                    {
                        ds.Tables.Add(dt);
                    }
                }

                return(ds);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }