Exemple #1
0
 /// <summary>
 /// 加载数据
 /// </summary>
 public void Init()
 {
     try
     {
         this.DataRecords = DataDictionary.GetDataDictionary(this.textBox1.Text);
         var fromExcel = EntityModel.ConvertToEntityModel(this.DataRecords);
         if (File.Exists(this.textBox2.Text + "\\Sav.txt"))
         {
             lock (_lockObject)
             {
                 var             fs = new FileStream(this.textBox2.Text + "\\Sav.txt", FileMode.Open);
                 BinaryFormatter bf = new BinaryFormatter();
                 //People p = bf.Deserialize(fs) as People;
                 this.SaveBack = bf.Deserialize(fs) as SaveBack;
                 Reset(fromExcel, SaveBack.EntityModels);
                 fs.Close();
                 fs.Dispose();
             }
         }
         else
         {
             Reset(fromExcel, null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     if (this.tabControl1.Controls.Count > 0)
     {
         this.tabControl1.Controls.Clear();
     }
 }
Exemple #2
0
 void Reset(List <EntityModel> excel, List <EntityModel> bck)
 {
     if (bck != null && bck.Count > 0)
     {
         excel.ForEach(it => {
             var temp = bck.Where(b => b.ClassName == it.ClassName && b.DomainName == it.DomainName).FirstOrDefault();
             if (temp != null)
             {
                 it.ConfigurationQuoteNamespaces = temp.ConfigurationQuoteNamespaces;
                 it.EntityQuoteNamespaces        = temp.EntityQuoteNamespaces;
                 it.IRepositoryQuoteNamespaces   = temp.IRepositoryQuoteNamespaces;
                 it.RepositoryQuoteNamespaces    = temp.RepositoryQuoteNamespaces;
                 it.EntityPath                 = temp.EntityPath;
                 it.EntityNamespace            = temp.EntityNamespace;
                 it.IRepositoryNamespace       = temp.IRepositoryNamespace;
                 it.IRepositoryPath            = temp.IRepositoryPath;
                 it.RepositoryNamespace        = temp.RepositoryNamespace;
                 it.RepositoryPath             = temp.RepositoryPath;
                 it.ConfigurationNamespace     = temp.ConfigurationNamespace;
                 it.ConfigurationPath          = temp.ConfigurationPath;
                 it.DataContextNamespace       = temp.DataContextNamespace;
                 it.DataContextPath            = temp.DataContextPath;
                 it.DataContextQuoteNamespaces = temp.DataContextQuoteNamespaces;
             }
             else
             {
                 var first = bck.FirstOrDefault();
                 if (first != null)
                 {
                     it.ConfigurationQuoteNamespaces = first.ConfigurationQuoteNamespaces;
                     it.EntityQuoteNamespaces        = first.EntityQuoteNamespaces;
                     it.IRepositoryQuoteNamespaces   = first.IRepositoryQuoteNamespaces;
                     it.RepositoryQuoteNamespaces    = first.RepositoryQuoteNamespaces;
                     it.EntityPath                 = first.EntityPath;
                     it.EntityNamespace            = first.EntityNamespace;
                     it.IRepositoryNamespace       = first.IRepositoryNamespace;
                     it.IRepositoryPath            = first.IRepositoryPath;
                     it.RepositoryNamespace        = first.RepositoryNamespace;
                     it.RepositoryPath             = first.RepositoryPath;
                     it.ConfigurationNamespace     = first.ConfigurationNamespace;
                     it.ConfigurationPath          = first.ConfigurationPath;
                     it.DataContextNamespace       = first.DataContextNamespace;
                     it.DataContextPath            = first.DataContextPath;
                     it.DataContextQuoteNamespaces = first.DataContextQuoteNamespaces;
                 }
             }
         });
     }
     //this.EntityModels = excel;
     if (this.SaveBack == null)
     {
         this.SaveBack = new SaveBack();
     }
     this.SaveBack.EntityModels = excel;
 }