public IEnumerable <BomShell> GetBomShell(IEdmFile7 file, string bomConfiguration, IEdmVault7 vault)
        {
            try
            {
                var bomView = file.GetComputedBOM(22, file.CurrentVersion, bomConfiguration, (int)EdmBomFlag.EdmBf_ShowSelected);

                if (bomView == null)
                {
                    throw new Exception("Computed BOM it can not be null");
                }
                object[]       bomRows;
                EdmBomColumn[] bomColumns;
                bomView.GetRows(out bomRows);
                bomView.GetColumns(out bomColumns);


                DataTable bomTable = new DataTable();
                foreach (EdmBomColumn bomColumn in bomColumns)
                {
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = bomColumn.mbsCaption
                    });
                }
                for (var i = 0; i < bomRows.Length; i++)
                {
                    var cell = (IEdmBomCell)bomRows.GetValue(i);

                    bomTable.Rows.Add();

                    for (var j = 0; j < bomColumns.Length; j++)
                    {
                        EdmBomColumn column = (EdmBomColumn)bomColumns.GetValue(j);
                        object       value;
                        object       computedValue;
                        string       config;
                        bool         readOnly;
                        cell.GetVar(column.mlVariableID, column.meType, out value, out computedValue, out config, out readOnly);

                        if (value != null)
                        {
                            bomTable.Rows[i][j] = value;
                        }
                        else
                        {
                            bomTable.Rows[i][j] = null;
                        }
                    }
                }
                return(BomTableToBomList(bomTable));
            }
            catch (COMException ex)
            {
                MessageBox.Show("Failed get bom shell " + (EdmResultErrorCodes_e)ex.ErrorCode + ". Укажите вид PDM или тип спецификации");
                throw ex;
            }
        }
        public IEnumerable <BomShell> GetBomShell(string filePath, string bomConfiguration)
        {
            try
            {
                IEdmFolder5 oFolder;
                IEdmFile7   EdmFile7 = (IEdmFile7)PdmExemplar.GetFileFromPath(filePath, out oFolder);
                var         bomView  = EdmFile7.GetComputedBOM(BoomId, -1, bomConfiguration, (int)EdmBomFlag.EdmBf_ShowSelected);
                if (bomView == null)
                {
                    throw new Exception("Computed BOM it can not be null");
                }
                object[]       bomRows;
                EdmBomColumn[] bomColumns;
                bomView.GetRows(out bomRows);
                bomView.GetColumns(out bomColumns);
                DataTable bomTable = new DataTable();
                foreach (EdmBomColumn bomColumn in bomColumns)
                {
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = bomColumn.mbsCaption
                    });
                }
                for (var i = 0; i < bomRows.Length; i++)
                {
                    var cell = (IEdmBomCell)bomRows.GetValue(i);

                    bomTable.Rows.Add();

                    for (var j = 0; j < bomColumns.Length; j++)
                    {
                        EdmBomColumn column = (EdmBomColumn)bomColumns.GetValue(j);
                        object       value;
                        object       computedValue;
                        string       config;
                        bool         readOnly;
                        cell.GetVar(column.mlVariableID, column.meType, out value, out computedValue, out config, out readOnly);

                        if (value != null)
                        {
                            bomTable.Rows[i][j] = value;
                        }
                        else
                        {
                            bomTable.Rows[i][j] = null;
                        }
                    }
                }
                return(BomTableToBomList(bomTable));
            }
            catch (COMException ex)
            {
                MessageObserver.Instance.SetMessage("Failed get bom shell " + (EdmResultErrorCodes_e)ex.ErrorCode + ". Укажите вид PDM или тип спецификации");
                throw ex;
            }
        }
Esempio n. 3
0
        void Getbom(int bomId, string filePath,  string bomConfiguration, EdmBomFlag bomFlag, out Exception exception)
        {
            exception = null;

            try
            {
                IEdmFolder5 oFolder;
                CheckPdmVault();
                EdmFile7 = (IEdmFile7) _edmVault5.GetFileFromPath(filePath, out oFolder);

                var bomView = EdmFile7.GetComputedBOM(Convert.ToInt32(bomId), Convert.ToInt32(-1), bomConfiguration, (int) bomFlag); 

                if (bomView == null) return;
                Array bomRows;
                Array bomColumns;
                bomView.GetRows(out bomRows);
                bomView.GetColumns(out bomColumns);

                var bomTable = new DataTable();

                foreach (EdmBomColumn bomColumn in bomColumns)
                {
                    bomTable.Columns.Add(new DataColumn {ColumnName = bomColumn.mbsCaption});
                }

                //bomTable.Columns.Add(new DataColumn { ColumnName = "Путь" });
                bomTable.Columns.Add(new DataColumn {ColumnName = "Уровень"});
                bomTable.Columns.Add(new DataColumn {ColumnName = "КонфГлавнойСборки"});
                bomTable.Columns.Add(new DataColumn { ColumnName = "ТипОбъекта" });
                bomTable.Columns.Add(new DataColumn { ColumnName = "GetPathName" });

                for (var i = 0; i < bomRows.Length; i++)
                {
                    var cell = (IEdmBomCell) bomRows.GetValue(i);

                    bomTable.Rows.Add();

                    for (var j = 0; j < bomColumns.Length; j++)
                    {
                        var column = (EdmBomColumn) bomColumns.GetValue(j);                       

                        object value;
                        object computedValue;
                        string config;
                        bool readOnly;

                        cell.GetVar(column.mlVariableID, column.meType, out value, out computedValue, out config, out readOnly);

                        if (value != null)
                        {
                            bomTable.Rows[i][j] = value;
                        }
                        else
                        {
                            bomTable.Rows[i][j] = null;
                        }
                        bomTable.Rows[i][j + 1] = cell.GetTreeLevel();

                        bomTable.Rows[i][j + 2] = bomConfiguration;
                        bomTable.Rows[i][j + 3] = config;
                        bomTable.Rows[i][j + 4] = cell.GetPathName();
                    }
                }

                _bomList = BomTableToBomList(bomTable);
                exception = null;
            }
            catch (Exception ex)
            {
                exception = ex;
            }
        }
Esempio n. 4
0
            void Getbom(int bomId, string filePath, string bomConfiguration, EdmBomFlag bomFlag, out Exception exception)
            {
                exception = null;

                try
                {
                    IEdmFolder5 oFolder;
                    CheckPdmVault();
                    EdmFile7 = (IEdmFile7)_edmVault5.GetFileFromPath(filePath, out oFolder);

                    var bomView = EdmFile7.GetComputedBOM(Convert.ToInt32(bomId), Convert.ToInt32(-1), bomConfiguration, (int)bomFlag);

                    if (bomView == null)
                    {
                        return;
                    }
                    Array bomRows;
                    Array bomColumns;
                    bomView.GetRows(out bomRows);
                    bomView.GetColumns(out bomColumns);

                    var bomTable = new DataTable();

                    foreach (EdmBomColumn bomColumn in bomColumns)
                    {
                        bomTable.Columns.Add(new DataColumn {
                            ColumnName = bomColumn.mbsCaption
                        });
                    }

                    //bomTable.Columns.Add(new DataColumn { ColumnName = "Путь" });
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = "Уровень"
                    });
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = "КонфГлавнойСборки"
                    });
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = "ТипОбъекта"
                    });
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = "GetPathName"
                    });

                    for (var i = 0; i < bomRows.Length; i++)
                    {
                        var cell = (IEdmBomCell)bomRows.GetValue(i);

                        bomTable.Rows.Add();

                        for (var j = 0; j < bomColumns.Length; j++)
                        {
                            var column = (EdmBomColumn)bomColumns.GetValue(j);

                            object value;
                            object computedValue;
                            string config;
                            bool   readOnly;

                            cell.GetVar(column.mlVariableID, column.meType, out value, out computedValue, out config, out readOnly);

                            if (value != null)
                            {
                                bomTable.Rows[i][j] = value;
                            }
                            else
                            {
                                bomTable.Rows[i][j] = null;
                            }
                            bomTable.Rows[i][j + 1] = cell.GetTreeLevel();

                            bomTable.Rows[i][j + 2] = bomConfiguration;
                            bomTable.Rows[i][j + 3] = config;
                            bomTable.Rows[i][j + 4] = cell.GetPathName();
                        }
                    }

                    _bomList  = BomTableToBomList(bomTable);
                    exception = null;
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }
Esempio n. 5
0
        public void GetBOM_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                IEdmVault7 vault2 = null;
                if (vault1 == null)
                {
                    vault1 = new EdmVault5();
                }
                vault2 = (IEdmVault9)vault1;
                if (!vault1.IsLoggedIn)
                {
                    vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32());
                }

                if (aFile != null)
                {
                    // Get named BOMs and their versions for the selected file
                    EdmBomInfo[] derivedBOMs = null;
                    aFile.GetDerivedBOMs(out derivedBOMs);

                    int             arrSize     = 0;
                    EdmBomVersion[] ppoVersions = null;
                    int             i           = 0;
                    int             j           = 0;
                    int             id          = 0;
                    string          str         = "";
                    string          verstr      = "";
                    int             verArrSize  = 0;
                    arrSize = derivedBOMs.Length;

                    while (i < arrSize)
                    {
                        id  = derivedBOMs[i].mlBomID;
                        bom = (IEdmBom)vault2.GetObject(EdmObjectType.EdmObject_BOM, id);
                        str = "Named BOM: " + derivedBOMs[i].mbsBomName + Constants.vbLf + "Check-out user: "******"Current state: " + bom.CurrentState.Name + Constants.vbLf + "Current version: " + bom.CurrentVersion + Constants.vbLf + "ID: " + bom.FileID + Constants.vbLf + "Is checked out: " + bom.IsCheckedOut;
                        MessageBox.Show(str);
                        bom.GetVersions(out ppoVersions);
                        verArrSize = ppoVersions.Length;
                        while (j < verArrSize)
                        {
                            verstr = "BOM version: " + Constants.vbLf + "Type as defined in EdmBomVersionType: " + ppoVersions[j].meType + Constants.vbLf + "Version number: " + ppoVersions[j].mlVersion + Constants.vbLf + "Date: " + ppoVersions[j].moDate + Constants.vbLf + "Label: " + ppoVersions[j].mbsTag + Constants.vbLf + "Comment: " + ppoVersions[j].mbsComment;
                            MessageBox.Show(verstr);
                            j = j + 1;
                        }
                        i = i + 1;
                    }

                    // Get a BOM view with the specified layout
                    bomMgr = (IEdmBomMgr)vault2.CreateUtility(EdmUtility.EdmUtil_BomMgr);
                    EdmBomLayout[] ppoRetLayouts = null;
                    EdmBomLayout   ppoRetLayout  = default(EdmBomLayout);
                    bomMgr.GetBomLayouts(out ppoRetLayouts);
                    i       = 0;
                    arrSize = ppoRetLayouts.Length;
                    str     = "";
                    while (i < arrSize)
                    {
                        ppoRetLayout = ppoRetLayouts[i];
                        str          = "BOM Layout " + i + ": " + ppoRetLayout.mbsLayoutName + Constants.vbLf + "ID: " + ppoRetLayout.mlLayoutID;
                        if (ppoRetLayout.mbsLayoutName == "BOM")
                        {
                            bomView = aFile.GetComputedBOM(ppoRetLayout.mbsLayoutName, 0, "@", (int)EdmBomFlag.EdmBf_AsBuilt + (int)EdmBomFlag.EdmBf_ShowSelected);
                        }
                        MessageBox.Show(str);
                        i = i + 1;
                    }

                    // Display BOM view row and column information
                    object[]    ppoRows = null;
                    IEdmBomCell ppoRow  = default(IEdmBomCell);
                    bomView.GetRows(out ppoRows);
                    i       = 0;
                    arrSize = ppoRows.Length;
                    str     = "";
                    EdmBomColumn[] ppoColumns = null;
                    bomView.GetColumns(out ppoColumns);
                    while (i < arrSize)
                    {
                        ppoRow = (IEdmBomCell)ppoRows[i];
                        str    = "BOM Row " + i + ": " + Constants.vbLf + "Item ID: " + ppoRow.GetItemID() + Constants.vbLf + "Path name: " + ppoRow.GetPathName() + Constants.vbLf + "Tree level: " + ppoRow.GetTreeLevel() + Constants.vbLf + " Is locked? " + ppoRow.IsLocked();
                        MessageBox.Show(str);

                        int js       = 0;
                        int ararSize = ppoColumns.Length;
                        while (js < ararSize)
                        {
                            object poValue          = null;
                            object poComputedValue  = null;
                            string pbsConfiguration = "";
                            bool   pbReadOnly       = false;
                            int    plFocusNode      = 0;
                            ppoRow.GetVar(ppoColumns[js].mlVariableID, ppoColumns[js].meType, out poValue, out poComputedValue, out pbsConfiguration, out pbReadOnly);
                            str = "BOM Column " + js + ": " + Constants.vbLf + "Header: " + ppoColumns[js].mbsCaption +
                                  Constants.vbLf + "Value " + poValue.ToString() +
                                  Constants.vbLf + "ComputeValue " + poComputedValue.ToString() +
                                  Constants.vbLf + "Config: " + pbsConfiguration +
                                  Constants.vbLf + "ReadOnly: " + pbReadOnly.ToString();
                            MessageBox.Show(str);
                            js = js + 1;
                        }
                        i = i + 1;
                    }



                    //bomView.InsertRow((EdmBomCell)ppoRows[0], EdmBomInsertRowOption.EdmBomInsertRowOption_BelowRow, out ppoNewRow);
                    // ppoNewRow.SetVar(ppoColumns[0].mlVariableID, ppoColumns[0].meType, "vault_name\\temp", "", EdmBomSetVarOption.EdmBomSetVarOption_Both, out errMsg);
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 6
0
        public IEnumerable <BomShell> GetBomShell(string filePath, string bomConfiguration)
        {
            try
            {
                IEdmFolder5 oFolder;

                IEdmFile7 EdmFile7 = (IEdmFile7)PdmExemplar.GetFileFromPath(filePath, out oFolder);
                var       bomView  = EdmFile7.GetComputedBOM(BOM_ID, -1, bomConfiguration, (int)EdmBomFlag.EdmBf_ShowSelected);

                if (bomView == null)
                {
                    throw new Exception("Computed BOM it can not be null");
                }
                Array bomRows;
                Array bomColumns;
                bomView.GetRows(out bomRows);
                bomView.GetColumns(out bomColumns);
                var bomTable = new DataTable();

                foreach (EdmBomColumn bomColumn in bomColumns)
                {
                    bomTable.Columns.Add(new DataColumn {
                        ColumnName = bomColumn.mbsCaption
                    });
                }

                //bomTable.Columns.Add(new DataColumn { ColumnName = "Путь" });
                bomTable.Columns.Add(new DataColumn {
                    ColumnName = "Уровень"
                });
                bomTable.Columns.Add(new DataColumn {
                    ColumnName = "КонфГлавнойСборки"
                });
                bomTable.Columns.Add(new DataColumn {
                    ColumnName = "ТипОбъекта"
                });
                bomTable.Columns.Add(new DataColumn {
                    ColumnName = "GetPathName"
                });

                for (var i = 0; i < bomRows.Length; i++)
                {
                    var cell = (IEdmBomCell)bomRows.GetValue(i);

                    bomTable.Rows.Add();

                    for (var j = 0; j < bomColumns.Length; j++)
                    {
                        var column = (EdmBomColumn)bomColumns.GetValue(j);

                        object value;
                        object computedValue;
                        string config;
                        bool   readOnly;

                        cell.GetVar(column.mlVariableID, column.meType, out value, out computedValue, out config, out readOnly);

                        if (value != null)
                        {
                            bomTable.Rows[i][j] = value;
                        }
                        else
                        {
                            bomTable.Rows[i][j] = null;
                        }
                        bomTable.Rows[i][j + 1] = cell.GetTreeLevel();

                        bomTable.Rows[i][j + 2] = bomConfiguration;
                        bomTable.Rows[i][j + 3] = config;
                        bomTable.Rows[i][j + 4] = cell.GetPathName();
                    }
                }

                return(BomTableToBomList(bomTable));
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageObserver.Instance.SetMessage("Failed get bom shell " + (EdmResultErrorCodes_e)ex.ErrorCode);
                return(null);
            }
        }