Exemplo n.º 1
0
        ThreadInterruptedException DoScan()
        {
            try{
                Thread.Sleep(0);
            } catch (ThreadInterruptedException e) {
                return(e);
            }


            // Set the initial BOM level
            int intLevel = 0;

            // Find the root node.  This is only done ONCE for the entire assembly structure
            SwComponentWrapper swRootComp = swMod.GetRootComponentWrapper();

            // Get name of configuration containing properties
            string strMainConfig = swMod.CurrentConfigName;
            string strMainPath   = swMod.PathName;

            // write custom properties for main model
            DbWriteConfig(strMainPath, strMainConfig, swModel: swMod);

            // Recursively traverse the assembly
            if (swRootComp != null)
            {
                TraverseAssy(swRootComp, strMainPath, strMainConfig, intLevel);
            }

            return(null);
        }
Exemplo n.º 2
0
        void DbWriteConfig(string strPathName, string strConfigName, SwComponentWrapper swComponent = null, SwModelWrapper swModel = null)
        {
            // Return if the config properties have already been written
            cmdCheckConfigs.Parameters["@filename"].Value   = strPathName;
            cmdCheckConfigs.Parameters["@configname"].Value = strConfigName;
            int intExists = Convert.ToInt32(cmdCheckConfigs.ExecuteScalar().ToString());

            if (intExists != 0)
            {
                return;
            }

            // Write status to form label
            MethodInvoker WriteLabelDelegate = new MethodInvoker(WriteLabel);
            string        strModelName       = this.statLabel;

            this.statLabel = strModelName + "(" + strConfigName + ")" + " ... getting custom properties";
            Invoke(WriteLabelDelegate);

            // Get model doc extension
            if (swModel == null)
            {
                swModel = swComponent.GetModelWrapper(strConfigName);
            }

            // Get custom properties
            //SwCustProp props = swModel.GetCustProp(strConfigName, cbxGetImages.Checked);
            DataRow props = swModel.GetCustomProp(strConfigName, withImage: cbxGetImages.Checked, merge: true);

            // Execute query
            foreach (DataColumn col in props.Table.Columns)
            {
                if (!scaffold.ScanFields.Contains(col.ColumnName))
                {
                    continue;
                }
                string param = "@" + col.ColumnName;
                object value = props[col.ColumnName];
                cmdInsertConfigs.Parameters[param].Value = value;
            }
            //foreach (KeyValuePair<string, object> prop in props.FieldValues)
            //    cmdInsertConfigs.Parameters["@" + prop.Key].Value = prop.Value;
            cmdInsertConfigs.ExecuteNonQuery();
        }
Exemplo n.º 3
0
        ThreadInterruptedException TraverseAssy(SwComponentWrapper swParentComp, string strParentPath, string strParentConfig, int intStartLevel)
        {
            // Check for cancel button
            try{
                Thread.Sleep(0);
            } catch (ThreadInterruptedException e) {
                return(e);
            }

            // If no component, then exit
            if (swParentComp == null)
            {
                return(null);
            }

            // Prepare to write status label
            MethodInvoker WriteLabelDelegate = new MethodInvoker(WriteLabel);

            // increment BOM level
            int intNextLevel = intStartLevel + 1;

            // Get the list of children (if any)
            List <SwComponentWrapper> children = swParentComp.GetComponents();

            // die if array contains no children
            if (children.Count == 0)
            {
                return(null);
            }

            // get children for each Child in this subassembly
            foreach (SwComponentWrapper swChildComp in children)
            {
                // Skip suppressed/excluded parts
                if (!swChildComp.Suppressed && !swChildComp.ExcludeFromBOM)
                {
                    // Get the model doc and info of the component
                    string strChildPath   = swChildComp.PathName;
                    string strChildConfig = swChildComp.ConfigName;

                    // write status to form label
                    string strModelName = swChildComp.FileName;
                    this.statLabel = strModelName;
                    Invoke(WriteLabelDelegate);

                    // Write custom properties for this config of this child
                    DbWriteConfig(strChildPath, strChildConfig, swComponent: swChildComp);

                    // Write BOM adjacency
                    DbWriteAdjacency(strParentPath, strParentConfig, strChildPath, strChildConfig);

                    // If this component not already traversed
                    cmdCheckAdjacency.Parameters["@PName"].Value   = strChildPath;
                    cmdCheckAdjacency.Parameters["@PConfig"].Value = strChildConfig;
                    long intExists = Convert.ToInt64(cmdCheckAdjacency.ExecuteScalar());
                    if (intExists == 0)
                    {
                        // If components not hidden from BOM
                        cmdShowChildren.Parameters["@filename"].Value   = strChildPath;
                        cmdShowChildren.Parameters["@configname"].Value = strChildConfig;
                        long intShow = Convert.ToInt64(cmdShowChildren.ExecuteScalar());
                        if (intShow != 0)
                        {
                            // Recurse into this child
                            TraverseAssy(swChildComp, strChildPath, strChildConfig, intNextLevel);
                        }
                    }
                }
            }

            return(null);
        }