private async void SetImportedInfo() { try { FormIsBusy(this, null); finalList = new List <TableImportItem>(); //List<TableImportItem> listNewNonSuspicious = new List<TableImportItem>(); if (bizTableDrivedEntity.ExistsEnabledEntitiesWithNullIndependentProperty(Database.ID)) { listAllEntitis = await GetOrginalEntities(); listAllEnabledRelationships = await GetEnabledRelationships(); foreach (var entity in listAllEntitis.Where(x => !x.IsDisabled && x.IndependentDataEntry == null)) { var relationships = new List <RelationshipDTO>(); foreach (var rel in listAllEnabledRelationships.Where(x => x.EntityID2 == entity.ID)) { // var oneSideEntity = listAllEntitis.First(x => x.ID == rel.EntityID1); // if (oneSideEntity.IndependentDataEntry == true) relationships.Add(rel); } var item = new TableImportItem(entity, false, ""); item.Relationships = relationships; SetInfo(item); finalList.Add(item); //if (IsSuspicious(entity)) //{ // item.Entity.IndependentDataEntry = true; // listNewSuspicious.Add(item); //} //else //{ // listNewNonSuspicious.Add(item); //} } await DecideProperties(finalList.ToList()); //finalList = listNewSuspicious.Union(listNewNonSuspicious).OrderByDescending(x => x.Entity.IndependentDataEntry).ToList(); //foreach (var item in listNewNonSuspicious) //{ // if (item.Relationships.Count == 1) // { // item.Relationships.First().Select = true; // SetRelatedEntityNames(item); // } //} } //if (listNewNonSuspicious.Any()) // tabNewTablesNonSuspicious.IsSelected = true; //else if (listNewSuspicious.Any()) // tabNewTablesSuspicious.IsSelected = true; dtgTables.ItemsSource = finalList.OrderByDescending(x => x.Entity.IndependentDataEntry).ToList(); //dtgNewTablesNonSuspicious.ItemsSource = listNewNonSuspicious; btnInsert.IsEnabled = finalList.Any(); } catch (Exception ex) { MessageBox.Show("خطا در پردازش اطلاعات" + Environment.NewLine + ex.Message); } finally { if (finalList.Any()) { FormIsFree(this, null); lblMessage.Visibility = Visibility.Collapsed; } else { lblMessage.Text = "موجودیتی به منظور تعیین مستقل بودن و یا نبودن موجود نمی باشد"; lblMessage.Visibility = Visibility.Visible; } } }