コード例 #1
0
 public bool CreatePdmsStructure(ImportToPdmsModel model, DbElement cur)
 {
     try
     {
         Tools.SetVersion(cur, this._version);
         Tools.CreateCommand(cur, "AUTOCOLOR OFF");
         int            num1           = 0;
         int            num2           = (int)Math.Floor(1000000.0 / (this._mapping.IfcObjectslist.Count > 0 ? (double)this._mapping.IfcObjectslist.Count : 0.0));
         StructuralItem structuralItem = new StructuralItem(this._mapping, this._version);
         int            num3           = 0;
         int            num4           = 0;
         int            num5           = 0;
         int            num6           = 0;
         int            num7           = 0;
         HierarchyItem.Log.Info((object)("Start processing ifc objects: " + DateTime.Now.ToLongTimeString()));
         foreach (IFCObjectsReader.Data.IfcObject ifcObj in this._mapping.IfcObjectslist)
         {
             try
             {
                 structuralItem.BeamCreated      = false;
                 structuralItem.PaneCreated      = false;
                 structuralItem.ArbitraryCreated = false;
                 structuralItem.GensecCreated    = false;
                 structuralItem.BrepCreated      = false;
                 ++num1;
                 this._progressBar.Value += num2;
                 this._progressBar.Update();
                 bool flag = !this._mapping.ModificationSet.Tables.Count.Equals(0);
                 this._mapping.IsAvevaObject = false;
                 DbElement element;
                 bool      updateElement = this._mapping.GetUpdateElement(ifcObj.SourceGuid, "IFC", out element);
                 if (this._mapping.AvevaSiteCanContainOneTeklaModelOnly & updateElement)
                 {
                     this._mapping.SiteElementList.Remove(element.GetAsString(DbAttribute.GetDbAttribute(":TEKLA_IFCGUID")));
                 }
                 if (!updateElement && this._mapping.UpdateAvevaObjects && this._mapping.GetUpdateElement(Tools.GetProperty(ifcObj, "Initial GUID"), "INITIAL", out element))
                 {
                     this._mapping.IsAvevaObject = true;
                 }
                 string str = string.Empty;
                 if (flag)
                 {
                     DataRow modificationRow = this.GetModificationRow(ifcObj.SourceGuid);
                     if (modificationRow != null)
                     {
                         str = modificationRow["ChangeType"].ToString();
                     }
                     if (DbElement.op_Equality(element, (DbElement)null) && !str.Equals("Added"))
                     {
                         if (this._mapping.RecreateDeletedObjects)
                         {
                             HierarchyItem.Log.Info((object)("Deleted PDMS element recreated: " + ifcObj.SourceGuid));
                             str = "Added";
                         }
                         else
                         {
                             HierarchyItem.Log.Info((object)("Deleted PDMS element not recreated: " + ifcObj.SourceGuid));
                             continue;
                         }
                     }
                     if (this._mapping.UpdateUnchangedObjects && str.Equals("Unchanged"))
                     {
                         HierarchyItem.Log.Info((object)("Updating unchanged PDMS element: " + ifcObj.SourceGuid));
                         str = "Modified";
                     }
                     if (str.Equals("Unchanged") || str.Equals("Deleted"))
                     {
                         continue;
                     }
                 }
                 string changeType;
                 if (DbElement.op_Inequality(element, (DbElement)null))
                 {
                     structuralItem.NewElement = element;
                     changeType = "Modified";
                 }
                 else
                 {
                     changeType = "Added";
                 }
                 structuralItem.CreatePdmsItem(cur, ifcObj, ref this._sectionMapping, changeType);
                 Tools.SetColor(structuralItem.NewElement, changeType.Equals("Added") ? "GREEN" : "YELLOW");
                 if (structuralItem.BeamCreated)
                 {
                     ++num3;
                 }
                 if (structuralItem.PaneCreated)
                 {
                     ++num4;
                 }
                 if (structuralItem.ArbitraryCreated)
                 {
                     ++num5;
                 }
                 if (structuralItem.GensecCreated)
                 {
                     ++num6;
                 }
                 if (structuralItem.BrepCreated)
                 {
                     ++num7;
                 }
             }
             catch (Exception ex)
             {
                 HierarchyItem.Log.Error((object)("Error updating: " + ifcObj.SourceGuid));
             }
         }
         HierarchyItem.Log.Info((object)("End processing ifc objects: " + DateTime.Now.ToLongTimeString()));
         HierarchyItem.Log.Info((object)("Total objects processed: " + (object)num1));
         HierarchyItem.Log.Info((object)("Beams (SCTN)           : " + (object)num3));
         HierarchyItem.Log.Info((object)("Plates (PANE)          : " + (object)num4));
         HierarchyItem.Log.Info((object)("Arbitrary (PANE)       : " + (object)num5));
         HierarchyItem.Log.Info((object)("Polybeams (GENSEC)     : " + (object)num6));
         HierarchyItem.Log.Info((object)("Surface model (BREP)   : " + (object)num7));
         this._progressBar.Value = 0;
         this._progressBar.Refresh();
         List <string> siteList = this._mapping.SiteList;
         // ISSUE: explicit non-virtual call
         if (siteList != null && __nonvirtual(siteList.Count) > 0)
         {
             Tools.SortMembers(this._mapping, this._mapping.SiteList, this._mapping.DeleteEmptyContainerElementsAfterImport);
         }
         Dictionary <string, DbElement> siteElementList = this._mapping.SiteElementList;
         // ISSUE: explicit non-virtual call
         if ((siteElementList != null ? (__nonvirtual(siteElementList.Count) > 0 ? 1 : 0) : 0) != 0 && this._mapping.AvevaSiteCanContainOneTeklaModelOnly)
         {
             using (Dictionary <string, DbElement> .Enumerator enumerator = this._mapping.SiteElementList.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     KeyValuePair <string, DbElement> current = enumerator.Current;
                     if (this._mapping.UpdateAvevaHierarchy && DbElement.op_Inequality(this._mapping.DeletedElements, (DbElement)null))
                     {
                         if (this._mapping.KeepDeletedObjects)
                         {
                             current.Value.InsertBeforeFirst(this._mapping.DeletedElements);
                         }
                         else
                         {
                             current.Value.Delete();
                         }
                     }
                     else
                     {
                         current.Value.Delete();
                     }
                 }
             }
             if (DbElement.op_Inequality(this._mapping.DeletedElements, (DbElement)null))
             {
                 Tools.SetColor(this._mapping.DeletedElements, "RED");
             }
         }
         this.DeleteElements(cur);
         if (DbElement.op_Inequality(this._mapping.UnplacedElements, (DbElement)null) && this._mapping.UnplacedElements.get_IsValid())
         {
             Tools.SetColor(this._mapping.UnplacedElements, "BLUE");
         }
         if (!this._mapping.UpdateAvevaHierarchy)
         {
             if (((object)CurrentElement.get_Element()).Equals((object)DbElement.GetElement("WORLD")))
             {
                 HierarchyItem.Log.Info((object)"Rendering skipped at WORLD level");
             }
             else
             {
                 Tools.CreateCommand(cur, "AUTO CE");
                 HierarchyItem.Log.Info((object)"View updated.");
             }
         }
         if (this._sectionMapping.Count.Equals(0))
         {
             HierarchyItem.Log.Info((object)"All profiles were mapped.");
         }
         else
         {
             HierarchyItem.Log.Info((object)"The following profiles were not mapped:");
             foreach (KeyValuePair <string, int> keyValuePair in this._sectionMapping)
             {
                 HierarchyItem.Log.Info((object)("   " + keyValuePair.Key + ": " + (object)keyValuePair.Value + " occurrences."));
             }
         }
         Tools.CreateCommand(cur, "AUTOCOLOR ON");
         Command.CreateCommand(this._unit).Run();
         CurrentElement.set_Element(cur);
         return(true);
     }
     catch (Exception ex)
     {
         HierarchyItem.Log.Error((object)("Error during update, aborting (" + ex.Message + ")."));
         int num = (int)MessageBox.Show("Error during update, aborting: " + ex.Message);
         Tools.CreateCommand(cur, "AUTOCOLOR ON");
         Command.CreateCommand(this._unit).Run();
         return(false);
     }
 }