Пример #1
0
 protected void BindData()
 {
     ClassItem cObj = new ClassItem();
     PagerNavication.RecordsCount = DataBase.HEntityCommon.HEntity(cObj).EntityCount();
     ClassItem[] al = ClassItem.List("", "", PagerNavication.PageIndex, PagerNavication.PageSize);
     rptItems.DataSource = al;
     rptItems.DataBind();
 }
Пример #2
0
        public ActionResult Index(String no="")
        {
            var allClasses = _ClassManager.EnabledClasses.ToArray();
            var root = new ClassItem(allClasses, new Classes { no = FlhConfig.CLASSNO_CLASS_PREFIX,name=String.Empty});
            //左上全部,不过可以先查一级和二级
            //右上按后台排序一级
            //下面左边是一级,右边是对应的二级,是一个整体的。都是按排序展示,而且全部展示
            //下面的二级如果放不下就按他的两行,一级是全部展示的

            var model = new IndexPageClassModel();
            model.TopLeftItems = root.Children.OrderByDescending(d => d.Sort).ThenByDescending(d => d.UpdateTime).Take(12).ToArray();
            model.TopRightItems = root.Children.OrderByDescending(d=>d.Sort).ThenByDescending(d=>d.UpdateTime).Take(8).ToArray();
            model.BottomLeftItems = root.Children;
            model.BottomRightItems = root.Children.OrderByDescending(d => d.Sort).ThenByDescending(d => d.UpdateTime).ToArray();
            model.CurrentClassNo = no;
            return View(model);
        }
Пример #3
0
        /// <summary>
        /// Adds a new method (with a hard-coded name and empty body) to the selected class.
        /// </summary>
        /// <param name="c">The class to which the method will be added.</param>
        /// <remarks>
        /// The method is added to the underlying file, but not to the designer.
        /// Visual Studio will detect the change and asks the user if the file should be reloaded.
        /// Another approach is needed to update the designer directly.
        /// </remarks>
        void AddMethodToFile(ClassItem c)
        {
            AxClass axClass = (AxClass)c.GetMetadataType();

            // Add the method to the class
            axClass.AddMethod(BuildMethod());

            // Prepare objects needed for saving
            var metaModelProviders = ServiceLocator.GetService(typeof(IMetaModelProviders)) as IMetaModelProviders;
            var metaModelService = metaModelProviders.CurrentMetaModelService;
            // Getting the model will likely have to be more sophisticated, such as getting the model of the project and checking
            // if the object has the same model.
            // But this shold do for demonstration.
            ModelInfo model = DesignMetaModelService.Instance.CurrentMetadataProvider.Classes.GetModelInfo(axClass.Name).FirstOrDefault<ModelInfo>();

            // Update the file
            metaModelService.UpdateClass(axClass, new ModelSaveInfo(model));
        }
Пример #4
0
 public bool CreatPart()
 {
     if (File.Exists(this.directoryPath + EleModel.AssembleName + ".prt"))
     {
         ClassItem.MessageBox("电极重名!", NXMessageBox.DialogType.Error);
         return(false);
     }
     try
     {
         this.EleComp = this.EleModel.CreateCompPart(this.directoryPath);
         // this.EleModel.Info.SetAttribute(this.EleComp);
         return(true);
     }
     catch (NXException ex)
     {
         ClassItem.WriteLogFile("创建Part档错误!" + ex.Message);
         return(false);
     }
 }
Пример #5
0
        private bool CreateDatum()
        {
            Vector3d dir = new Vector3d(0, 0, -1);

            try
            {
                Body body1 = ExtrudeUtils.CreateExtrude(dir, "0", "DatumHeigth", null, sketch.LeiLine.ToArray()).GetBodies()[0];
                CreateChamfer(body1.Tag);
                SetDatumAttr(body1);
                Body body2 = ExtrudeUtils.CreateExtrude(dir, "DatumHeigth", "extrudePreparation", null, sketch.WaiLine.ToArray()).GetBodies()[0];
                this.DatumBody = BooleanUtils.CreateBooleanFeature(body1, false, false, NXOpen.Features.Feature.BooleanType.Unite, body2).GetBodies()[0];
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("创建基准台错误!" + ex.Message);
                return(false);
            }
        }
Пример #6
0
        /// <summary>
        /// Loads all classes according to the given namespace
        /// </summary>
        /// <param name="namespaceName">The name of the namespace</param>
        /// <param name="browseTab">true to load all classes, false to load only dynamic and static classes</param>
        /// <param name="cancellationToken">The token to cancel the execution</param>
        /// <returns>The list with the classes</returns>
        /// <exception cref="ArgumentNullException">Will be thrown when the namespace name is null or empty</exception>
        /// <exception cref="ManagementException">Will be thrown when an error occured in the management object searcher</exception>
        public static List <ClassItem> LoadClasses(string namespaceName, bool browseTab, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(namespaceName))
            {
                throw new ArgumentNullException(nameof(namespaceName));
            }

            var searcher = new ManagementObjectSearcher(new ManagementScope(namespaceName),
                                                        new WqlObjectQuery("SELECT * FROM meta_class"), null);

            var result = new List <ClassItem>();

            foreach (var wmiClass in searcher.Get())
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                }

                var name = wmiClass["__CLASS"].ToString();
                InfoEvent?.Invoke($"{result.Count,4} - current class: {name}");
                if (browseTab)
                {
                    var classItem = new ClassItem(name);
                    classItem.Description = LoadClassDescription(namespaceName, classItem.Name);
                    result.Add(classItem);
                }
                else
                {
                    foreach (var qualifier in wmiClass.Qualifiers)
                    {
                        if (qualifier.Name.EqualsIgnoreCase("dynamic") || qualifier.Name.EqualsIgnoreCase("static"))
                        {
                            var classItem = new ClassItem(name);
                            result.Add(classItem);
                        }
                    }
                }
            }

            return(result.OrderBy(o => o.Name).ToList());
        }
Пример #7
0
        /// <summary>
        /// 写入属性
        /// </summary>
        /// <param name="objs"></param>
        /// <returns></returns>
        public bool SetAttribute(params NXObject[] objs)
        {
            try
            {
                AttributeUtils.AttributeOperation("EleType", this.EleType, objs);
                AttributeUtils.AttributeOperation("Condition", this.Condition, objs);
                AttributeUtils.AttributeOperation("CH", this.Ch, objs);
                AttributeUtils.AttributeOperation("Remarks", this.Remarks, objs);
                AttributeUtils.AttributeOperation("Technology", this.Technology, objs);
                AttributeUtils.AttributeOperation("ElePresentation", this.ElePresentation, objs);


                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("写入属性错误!" + ex.Message);
                return(false);
            }
        }
Пример #8
0
        /// <summary>
        /// 以属性得到实体
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public new static WorkInfo GetAttribute(NXObject obj)
        {
            int num = 0;

            Matrix4 mat = new Matrix4();

            mat.Identity();
            try
            {
                num = AttributeUtils.GetAttrForInt(obj, "WorkNumber");
                WorkInfo info = new WorkInfo(MoldInfo.GetAttribute(obj), UserModel.GetAttribute(obj), num, Matrix4Info.GetAttribute(obj).Matr);
                info.Interference = AttributeUtils.GetAttrForBool(obj, "Interference");
                return(info);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("未获取到属性" + ex.Message);
                return(new WorkInfo(MoldInfo.GetAttribute(obj), UserModel.GetAttribute(obj), num, mat));
            }
        }
Пример #9
0
        public ActionResult Index(String no = "")
        {
            var allClasses = _ClassManager.EnabledClasses.ToArray();
            var root       = new ClassItem(allClasses, new Classes {
                no = FlhConfig.CLASSNO_CLASS_PREFIX, name = String.Empty
            });
            //左上全部,不过可以先查一级和二级
            //右上按后台排序一级
            //下面左边是一级,右边是对应的二级,是一个整体的。都是按排序展示,而且全部展示
            //下面的二级如果放不下就按他的两行,一级是全部展示的

            var model = new IndexPageClassModel();

            model.TopLeftItems     = root.Children.OrderByDescending(d => d.Sort).ThenByDescending(d => d.UpdateTime).Take(12).ToArray();
            model.TopRightItems    = root.Children.OrderByDescending(d => d.Sort).ThenByDescending(d => d.UpdateTime).Take(8).ToArray();
            model.BottomLeftItems  = root.Children;
            model.BottomRightItems = root.Children.OrderByDescending(d => d.Sort).ThenByDescending(d => d.UpdateTime).ToArray();
            model.CurrentClassNo   = no;
            return(View(model));
        }
Пример #10
0
        public bool CreateInterferenceBody()
        {
            List <string> info = new List <string>();

            foreach (ElectrodeModel ele in eles)
            {
                Interference  eleInter = new Interference(ele, this.work, this.assemble.Workpieces);
                List <string> temp     = eleInter.InterferenceOfBody();
                info.AddRange(temp);
            }
            if (info.Count > 0)
            {
                foreach (string str in info)
                {
                    ClassItem.Print(str);
                }
                return(false);
            }
            return(true);
        }
Пример #11
0
        /*
         * public void SlotDoubleClick (QListViewItem item) {
         *      if (item is MethodItem) {
         *              MethodItem method = (MethodItem)item;
         *
         *              ClassItem parent = method.parent;
         *
         *              if (parent.sourceBrowser != null) {
         *                      parent.sourceBrowser.ShowNormal ();
         *                      parent.sourceBrowser.Raise ();
         *              }
         *              else {
         *                      parent.sourceBrowser = new SourceWindow (this, parent);
         *                      parent.sourceBrowser.Show ();
         *              }
         *
         *              parent.sourceBrowser.CenterOnMethod (method);
         *      }
         * }
         */

        private void OnRowExpanded(object sender, RowExpandedArgs args)
        {
            ClassItem classItem = store.GetValue(args.Iter, 4) as ClassItem;

            if (classItem == null)
            {
                return;
            }

            foreach (MethodCoverageItem method in classItem.Model.Methods)
            {
                if (method.filtered)
                {
                    continue;
                }

                string title = method.Name;
                if (title.Length > 64)
                {
                    title = title.Substring(0, 63) + "...)";
                }

                new MethodItem(store, classItem, classItem, method, title);
            }

            TreeIter treeIter = classItem.iter;

            store.IterChildren(out treeIter, treeIter);

            while (store.IterIsValid(treeIter))
            {
                if (store.GetValue(treeIter, 4) is MethodItem)
                {
                    store.IterNext(ref treeIter);
                }
                else
                {
                    store.Remove(ref treeIter);
                }
            }
        }
Пример #12
0
        /// <summary>
        /// 读取模具属性
        /// </summary>
        /// <param name="part"></param>
        public static Matrix4Info GetAttribute(NXObject obj)
        {
            Matrix4 mat = new Matrix4();

            mat.Identity();
            try
            {
                string[] temp = new string[4];
                for (int i = 0; i < 4; i++)
                {
                    temp[i] = AttributeUtils.GetAttrForString(obj, "Matrx4", i);
                }
                mat = StringToMatrx4(temp);
                return(new Matrix4Info(mat));
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("未获取到属性" + ex.Message);
                return(new Matrix4Info(mat));
            }
        }
Пример #13
0
 /// <summary>
 /// 创建part档
 /// </summary>
 /// <param name="directoryPath">文件夹地址加\\</param>
 /// <returns></returns>
 public virtual bool CreatePart(string directoryPath)
 {
     this.WorkpieceDirectoryPath = directoryPath;
     this.WorkpiecePath          = directoryPath + this.AssembleName + ".prt";
     if (File.Exists(this.WorkpiecePath))
     {
         File.Delete(this.WorkpiecePath);
     }
     try
     {
         Part part = PartUtils.NewFile(this.WorkpiecePath) as Part;
         this.PartTag = part;
         SetAttribute(part);
         return(true);
     }
     catch (NXException ex)
     {
         ClassItem.WriteLogFile("创建" + this.AssembleName + "失败" + ex.Message);
         return(false);
     }
 }
Пример #14
0
 internal void DeleteTheClassInformation(ClassItem aClassitemObj)
 {
     try
     {
         connection.Open();
         string     selectQuery = @"DELETE  FROM [tbl_class_entry_information] WHERE [cls_id] ='" + aClassitemObj.Id + "'  ";
         SqlCommand command     = new SqlCommand(selectQuery, connection);
         command.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
         }
     }
 }
Пример #15
0
 /// <summary>
 /// 创建特征
 /// </summary>
 public bool CreateBuilder()
 {
     if (ParentBuilder != null && !ParentBuilder.IsCreateOk)
     {
         ParentBuilder.CreateBuilder();
     }
     try
     {
         if (!isok && ParentBuilder.IsCreateOk)
         {
             CreateEleSketch();
             isok = true;
         }
         return(isok);
     }
     catch (NXException ex)
     {
         ClassItem.WriteLogFile("创建草绘错误!" + ex.Message);
         return(false);
     }
 }
Пример #16
0
        /// <summary>
        /// Creates the csharp code
        /// </summary>
        /// <param name="namespaceItem">The namespace</param>
        /// <param name="classItem">The class</param>
        /// <param name="properties">The selected properties</param>
        /// <returns>The generated code</returns>
        public static string CreateCSharpCode(NamespaceItem namespaceItem, ClassItem classItem,
                                              List <PropertyItem> properties)
        {
            var template = LoadTemplate();

            if (string.IsNullOrEmpty(template))
            {
                return("");
            }

            // Step 1: Replace the namespace
            template = template.Replace("{NAMESPACE}", namespaceItem.Name.Replace("\\", "\\\\"));
            // Step 2: Replace the query
            template = template.Replace("{QUERY}", $"SELECT * FROM {classItem.Name}");
            // Step 3: Replace the class name
            template = template.Replace("{CLASS}", classItem.Name);
            // Step 4: Create the properties
            template = template.Replace("{PROPERTY}", CreateProperties(properties));

            return(template);
        }
Пример #17
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Initialize()
        {
            this.textBox_MoldNumber.Text    = asm.Info.MoldInfo.MoldNumber;
            this.textBox_EditionNumber.Text = asm.Info.MoldInfo.EditionNumber;
            EleType.Items.AddRange(GetContr("EleType").ToArray());
            Material.Items.AddRange(GetContr("Material").ToArray());
            Condition.Items.AddRange(GetContr("Condition").ToArray());
            dataGridView.Columns["EleX"].Visible                   = false; //隐藏列
            dataGridView.Columns["EleY"].Visible                   = false;
            dataGridView.Columns["EleZ"].Visible                   = false;
            dataGridView.Columns["EleName"].ReadOnly               = true;        //只读列
            dataGridView.RowsDefaultCellStyle.BackColor            = Color.Bisque;
            dataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige; //交替行不同颜色
            dataGridView.Columns[1].Frozen   = true;                              //冻结首列
            dataGridView.AutoGenerateColumns = false;

            DataTable table;

            try
            {
                table = ElectrodeAllInfo.CreateDataTable();
            }
            catch (Exception ex)
            {
                ClassItem.WriteLogFile("创建表列错误!" + ex.Message);
                return;
            }
            foreach (ElectrodeModel em in eleModels)
            {
                try
                {
                    em.Info.AllInfo.CreateDataRow(ref table);
                }
                catch (Exception ex)
                {
                    ClassItem.WriteLogFile(em.AssembleName + "          创建行错误!" + ex.Message);
                }
            }
            dataGridView.DataSource = table;
        }
        /// <summary>
        /// 设定视图竖直标注
        /// </summary>
        /// <param name="topView"></param>
        /// <param name="originPt"></param>
        /// <param name="scale"></param>
        /// <param name="workPoint"></param>
        /// <param name="elePoint"></param>
        private void ProViewDimension(DraftingView topView, double scale, Point3d originPt, Point workPoint, List <Point> elePoint)
        {
            string  err = "";
            Matrix4 mat = model.GetWorkMatr();

            // Point3d originPt = topView.GetDrawingReferencePoint();
            PointSort(ref elePoint, mat, "Z");
            double zTemmp = 0;
            int    z      = 0;

            for (int i = 0; i < elePoint.Count; i++)
            {
                Point3d zPt = elePoint[i].Coordinates;
                mat.ApplyPos(ref zPt);
                if (i == 0)
                {
                    zTemmp = zPt.Z;
                }
                if (UMathUtils.IsEqual(zTemmp, zPt.Z) && i != 0)
                {
                    continue;
                }
                Point3d dimPt = new Point3d(originPt.X - (disPt.X * scale + 8 * (z + 1)), originPt.Y + 10, 0);
                try
                {
                    NXOpen.Annotations.Dimension dim = Basic.DrawingUtils.DimensionVertical(topView, dimPt, workPoint, elePoint[0], ref err);
                    if (dim != null)
                    {
                        Basic.DrawingUtils.AppendedTextDim(dim, "EDM SETTING");
                        SetDimColor(dim);
                    }
                    z++;
                }

                catch (NXException ex)
                {
                    ClassItem.WriteLogFile(model.AssembleName + "设定视图竖直标注错误!" + ex.Message);
                }
            }
        }
Пример #19
0
        public async Task <IActionResult> UploadFile([FromForm] ClassImageItem obj)
        {
            if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
            {
                return(BadRequest($"Expected a multipart request, but got {Request.ContentType}"));
            }
            try
            {
                using (var stream = obj.Image.OpenReadStream())
                {
                    var cloudBlock = await UploadToBlob(obj.Image.FileName, null, stream);

                    //// Retrieve the filename of the file you have uploaded
                    //var filename = provider.FileData.FirstOrDefault()?.LocalFileName;
                    if (string.IsNullOrEmpty(cloudBlock.StorageUri.ToString()))
                    {
                        return(BadRequest("An error has occured while uploading your file. Please try again."));
                    }

                    ClassItem classItem = new ClassItem();
                    classItem.Title = obj.Title;
                    classItem.Tags  = obj.Tags;

                    System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
                    classItem.Height   = image.Height.ToString();
                    classItem.Width    = image.Width.ToString();
                    classItem.Url      = cloudBlock.SnapshotQualifiedUri.AbsoluteUri;
                    classItem.Uploaded = DateTime.Now.ToString();

                    _context.ClassItem.Add(classItem);
                    await _context.SaveChangesAsync();

                    return(Ok($"File: {obj.Title} has successfully uploaded"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest($"An error has occured. Details: {ex.Message}"));
            }
        }
Пример #20
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                if (this.seleEdm.GetSelectedObjects().Length > 0)
                {
                    Part workPart = theSession.Parts.Work;
                    NXOpen.Assemblies.Component ct = this.seleEdm.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                    Part          edmPart          = ct.Prototype as Part;
                    List <string> err = new List <string>();
                    if (partPaths.Count > 0)
                    {
                        List <WorkpieceModel> workpiece = CreateBulder(edmPart, partPaths, out err);
                        if (workpiece.Count != 0)
                        {
                            err.AddRange(this.Load(workpiece, edmPart));
                        }
                    }
                    if (err.Count != 0)
                    {
                        ClassItem.Print(err.ToArray());
                    }
                    PartUtils.SetPartDisplay(workPart);
                    bool anyPartsModified1;
                    NXOpen.PartSaveStatus partSaveStatus1;
                    Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1);
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
        private Dictionary <string, object> GetDictionaryWithValues(ClassItem classItem, int documentForeignKeyValue)
        {
            var dict = new Dictionary <string, object>();

            // Get all columns from coupled table
            var sql = $"select * from {classItem.TableName} where {classItem.PrimaryKeyName} = '{documentForeignKeyValue}'";

            var result = InstanceInfo.DBService.ExecuteAndGetDataSet(sql);

            if (result.Tables[0].Rows.Count > 0)
            {
                DataRow row = result.Tables[0].Rows[0];

                // Add each field to dictionary
                foreach (var col in result.Tables[0].Columns)
                {
                    dict.Add(col.ToString(), row[col.ToString()]);
                }
            }

            return(dict);
        }
 /// <summary>
 /// 查找选择电极Part
 /// </summary>
 /// <returns></returns>
 private Part FindSelectEle()
 {
     if (dataGridViewEle.SelectedCells.Count > 0)
     {
         int     intRow = dataGridViewEle.SelectedCells[0].RowIndex;
         DataRow dr     = (dataGridViewEle.Rows[intRow].DataBoundItem as DataRowView).Row;
         string  name   = dr["EleName"].ToString();
         if (name != null && !name.Equals(""))
         {
             Part pt = elePart.Find(a => a.Name.Equals(name));
             if (pt != null)
             {
                 return(pt);
             }
         }
     }
     else
     {
         ClassItem.MessageBox("请选择电极!", NXMessageBox.DialogType.Error);
     }
     return(null);
 }
Пример #23
0
        private void buttOK_Click(object sender, EventArgs e)
        {
            preveiw.DelePattern();
            if (comboBox_eleType.Text == null || comboBox_eleType.Text == "")
            {
                NXOpen.UI.GetUI().NXMessageBox.Show("错误!", NXMessageBox.DialogType.Error, "请选择电极类型!");
                return;
            }
            ElectrodeAllInfo all = GetEleInfo();

            GetERNumber(all.Pitch);
            CreateElectrode create = new CreateElectrode(all, parent, condition, this.checkBox1.Checked);
            List <string>   err    = create.CreateBuider();

            condition.Work.SetInterference(false);
            Session.GetSession().Parts.Work.ModelingViews.WorkView.Regenerate();
            this.Close();
            if (err.Count > 0)
            {
                ClassItem.Print(err.ToArray());
            }
        }
        /// <summary>
        /// 创建设定图
        /// </summary>
        public NXOpen.Drawings.DrawingSheet CreateSetValueView()
        {
            Matrix4 inv = model.GetWorkMatr().GetInversMatrix();

            inv.ApplyPos(ref centerPt);
            double scale = model.GetScale(130.0, 170.0, disPt);

            NXOpen.Drawings.DrawingSheet sheet = Basic.DrawingUtils.DrawingSheet(eleTemplate, 297, 420, model.AssembleName);
            Point3d origin      = GetSetValueViewOriginPt(scale);
            Point3d projectedPt = new Point3d(0, 0, 0);

            projectedPt.X = origin.X;
            projectedPt.Y = origin.Y - (disPt.Y + disPt.Z) * scale - 30;
            DraftingView topView = null;
            DraftingView proView = null;

            try
            {
                topView = Basic.DrawingUtils.CreateView("TOP", origin, scale, model.GetWorkMatr(), setValueHidden.ToArray());
                proView = Basic.DrawingUtils.CreateProjectedView(topView, projectedPt, scale);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile(model.AssembleName + "视图创建错误!" + ex.Message);
            }
            Point        workPt = model.CreateCenterPoint();
            List <Point> setPt  = model.GetEleSetPoint();

            if (topView != null || workPt == null || setPt.Count > 0)
            {
                TopDimension(topView, scale, origin, workPt, setPt);
            }
            if (proView != null || workPt == null || setPt.Count > 0)
            {
                ProViewDimension(proView, scale, projectedPt, workPt, setPt);
            }
            SetViewVisible(new DraftingView[] { topView, proView });
            return(sheet);
        }
Пример #25
0
        /// <summary>
        /// 投影视图标注
        /// </summary>
        /// <param name="topView"></param>
        /// <param name="originPt"></param>
        private void ProjectedDimension(DraftingView topView, Point3d originPt, double scale)
        {
            string err = "";

            Point3d minPt = drawModel.MinPt.Coordinates;
            Point3d maxPt = drawModel.MaxPt.Coordinates;

            this.workModel.Info.Matr.ApplyPos(ref minPt);
            this.workModel.Info.Matr.ApplyPos(ref maxPt);

            if (!UMathUtils.IsEqual(minPt.Z, 0))
            {
                Point3d dimPt = new Point3d(0, 0, 0);
                dimPt.X = originPt.X - this.drawModel.DisPt.X * scale - 10.0;
                dimPt.Y = originPt.Y - this.drawModel.DisPt.Z * scale - 10.0;
                try
                {
                    Basic.DrawingUtils.DimensionVertical(topView, dimPt, this.originPoint, drawModel.MinPt, ref err);
                }
                catch (NXException ex)
                {
                    ClassItem.WriteLogFile(this.drawModel.WorkpiecePart.Name + "投影标准错误!         " + ex.Message);
                }
            }
            if (!UMathUtils.IsEqual(maxPt.Z, 0))
            {
                Point3d dimPt = new Point3d(0, 0, 0);
                dimPt.X = originPt.X + this.drawModel.DisPt.X * scale + 10.0;
                dimPt.Y = originPt.Y + this.drawModel.DisPt.Z * scale + 10.0;
                try
                {
                    Basic.DrawingUtils.DimensionVertical(topView, dimPt, this.originPoint, drawModel.MaxPt, ref err);
                }
                catch (NXException ex)
                {
                    ClassItem.WriteLogFile(this.drawModel.WorkpiecePart.Name + "投影标准错误!         " + ex.Message);
                }
            }
        }
Пример #26
0
 /// <summary>
 /// 设置属性
 /// </summary>
 public bool SetAttribute(Part obj)
 {
     try
     {
         AttributeUtils.AttributeOperation("CrudeInter", this.CrudeInter, obj);
         AttributeUtils.AttributeOperation("CrudeNum", this.CrudeNum, obj);
         AttributeUtils.AttributeOperation("DuringInter", this.DuringInter, obj);
         AttributeUtils.AttributeOperation("DuringNum", this.DuringNum, obj);
         AttributeUtils.AttributeOperation("FineInter", this.FineInter, obj);
         AttributeUtils.AttributeOperation("FineNum", this.FineNum, obj);
         if (this.ERNum[0] != 0 || this.ERNum[1] != 0)
         {
             AttributeUtils.AttributeOperation("ERNum", this.ERNum, obj);
         }
         return(true);
     }
     catch (NXException ex)
     {
         ClassItem.WriteLogFile("写入属性错误!" + ex.Message);
         return(false);
     }
 }
        private void buttOk_Click(object sender, EventArgs e)
        {
            UserSingleton user = UserSingleton.Instance();
            List <string> err  = new List <string>();

            if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd())
            {
                List <ElectrodeModel> eleModels = asmColl.GetElectrodes();
                for (int i = 0; i < listView.Items.Count; i++)
                {
                    if (listView.Items[i].Checked)
                    {
                        string eleName = listView.Items[i].SubItems[2].Text.ToString();
                        List <ElectrodeModel> models = eleModels.FindAll(a => a.Info.AllInfo.Name.EleName.Equals(eleName, StringComparison.CurrentCultureIgnoreCase));
                        if (models.Count > 0)
                        {
                            try
                            {
                                ElectrodeDrawingModel   dra     = new ElectrodeDrawingModel(models, asm.PartTag, user.CreatorUser);
                                ElectrodeDrawingBuilder builder = new ElectrodeDrawingBuilder(dra, asm);
                                builder.CreateBulider();
                            }
                            catch (NXException ex)
                            {
                                err.Add(eleName + "电极出图错误!" + ex.Message);
                            }
                        }
                    }
                }
                PartUtils.SetPartDisplay(asm.PartTag);
                Session.GetSession().ApplicationSwitchImmediate("UG_APP_MODELING");
                if (err.Count > 0)
                {
                    ClassItem.Print(err.ToArray());
                }
            }
            this.Close();
        }
Пример #28
0
 //------------------------------------------------------------------------------
 //This method shows the dialog on the screen
 //------------------------------------------------------------------------------
 public NXOpen.UIStyler.DialogResponse Show()
 {
     try
     {
         Part   workPart = theSession.Parts.Work;
         string type     = AttributeUtils.GetAttrForString(workPart, "PartType");
         if (type != "ASM")
         {
             theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请切换ASM档为工作部件!");
             return(0);
         }
         MoldInfoModel mold = new MoldInfoModel(workPart);
         assemble = AssembleSingleton.Instance().GetAssemble(mold.MoldNumber + "-" + mold.WorkpieceNumber);
         theDialog.Show();
         if (err.Count != 0)
         {
             bool           anyPartsModified;
             PartSaveStatus saveStatus;
             Part           part = null;
             if ((part = ReplacePart.Replace(assemble.Asm, moldInfo)) != null)
             {
                 moldInfo.SetAttribute(part);
                 theSession.Parts.SaveAll(out anyPartsModified, out saveStatus);
                 err.Add("修改" + assemble.Asm.AssembleName + "成功!");
             }
             foreach (string st in err)
             {
                 ClassItem.Print(st);
             }
         }
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
     return(0);
 }
        private bool CreatWave()
        {
            Matrix4 mat = new Matrix4();

            mat.Identity();
            try
            {
                //  Body[] waveBodys = AssmbliesUtils.WaveAssociativeBodys(this.headBodys.ToArray()).GetBodies();
                PullFaceForWave(headBodys);
                NXOpen.Features.PatternGeometry patt = PatternUtils.CreatePattern(" xNCopies", "xPitchDistance", "yNCopies", " yPitchDistance"
                                                                                  , mat, headBodys.ToArray()); //创建阵列(就是绝对坐标的矩阵)
                AllBodys.AddRange(patt.GetAssociatedBodies());
                AllBodys.AddRange(headBodys);
                MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", null, AllBodys.ToArray());
                SetHeadColour();
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("创建Part档错误!" + ex.Message);
                return(false);
            }
        }
Пример #30
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                NXOpen.Assemblies.Component seleCt = this.seleWork.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                if (seleCt != null)
                {
                    Session.UndoMarkId markId;
                    markId = Session.GetSession().SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "复制电极");
                    List <string>  err = new List <string>();
                    AddWorkBuilder add = new AddWorkBuilder(asmModel, seleCt);
                    Part           pt  = GetWorkForName(this.eumWorkName.ValueAsString);
                    if (pt != null)
                    {
                        err.AddRange(add.CopyElectrodeToWork(pt));
                    }
                    else
                    {
                        err.Add("无法找到WORK!");
                    }
                    if (err.Count > 0)
                    {
                        ClassItem.Print(err.ToArray());
                    }
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
Пример #31
0
        private bool PartIsAsm()
        {
            UserSingleton user = UserSingleton.Instance();

            if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd())
            {
                Part workPart = Session.GetSession().Parts.Work;
                if (!ASMModel.IsAsm(workPart))
                {
                    asm = ASMCollection.GetAsmModel(workPart);
                    if (asm == null)
                    {
                        ClassItem.MessageBox("无法通过工作部件找到ASM!", NXMessageBox.DialogType.Error);
                        return(false);
                    }

                    //   PartUtils.SetPartDisplay(asm.PartTag);
                }
                asm     = new ASMModel(workPart);
                asmColl = new ASMCollection(asm);
                foreach (WorkModel wk in asmColl.GetWorks())
                {
                    bool isInter = AttributeUtils.GetAttrForBool(wk.PartTag, "Interference");
                    if (!isInter)
                    {
                        NXOpen.UI.GetUI().NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, wk.AssembleName + "没有检查电极");
                        return(false);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #32
0
        /// <summary>
        /// 移动体
        /// </summary>
        /// <param name="eleAsmComp"></param>
        /// <returns></returns>
        private bool UpdateMoveComp(NXOpen.Assemblies.Component eleAsmComp)
        {
            ElectrodeAllInfo      all          = newAllInfo.Clone() as ElectrodeAllInfo;
            ElectrodeSetValueInfo setValueInfo = ElectrodeSetValueInfo.GetAttribute(eleAsmComp);
            Part                 workPt        = eleAsmComp.Parent.Prototype as Part;
            WorkModel            work          = new WorkModel(workPt);
            ElectrodePitchUpdate pitchUpdate   = new ElectrodePitchUpdate(oldAllInfo.Pitch, newAllInfo.Pitch);
            Vector3d             temp          = pitchUpdate.GetIncrement();

            double[] setValue = pitchUpdate.GetNewSetValue(setValueInfo.EleSetValue);
            setValueInfo.EleSetValue = setValue;
            all.SetValue             = setValueInfo;
            try
            {
                PartUtils.SetPartDisplay(asm);
                AssmbliesUtils.MoveCompPart(eleAsmComp, temp, work.Info.Matr);
                NXObject obj = AssmbliesUtils.GetOccOfInstance(eleAsmComp.Tag);
                foreach (NXOpen.Assemblies.Component ct in AssmbliesUtils.GetPartComp(work.PartTag, eleModel.PartTag))
                {
                    NXObject tem = AssmbliesUtils.GetOccOfInstance(ct.Tag);
                    if (tem.Equals(obj))
                    {
                        PartUtils.SetPartDisplay(work.PartTag);
                        AssmbliesUtils.MoveCompPart(ct, temp, work.Info.Matr);
                    }
                }
                PartUtils.SetPartDisplay(asm);
                all.SetAttribute(obj);
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("移动组件错误!" + ex.Message);
                return(false);
            }
        }
Пример #33
0
 /// <summary>
 /// 创建装配
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public NXOpen.Assemblies.Component CreateCompPart(string directoryPath)
 {
     this.WorkpieceDirectoryPath = directoryPath;
     this.WorkpiecePath          = directoryPath + this.AssembleName + ".prt";
     CsysUtils.SetWcsToAbs();
     CsysUtils.SetWcsOfCenteAndMatr(this.Info.Matr.GetCenter(), this.Info.Matr.GetMatrix3());
     try
     {
         NXObject obj = AssmbliesUtils.CreateNew(this.AssembleName, WorkpiecePath);
         NXOpen.Assemblies.Component comp = obj as NXOpen.Assemblies.Component;
         this.PartTag = obj.Prototype as Part;
         if (this.PartTag != null)
         {
             SetAttribute(this.PartTag);
         }
         CsysUtils.SetWcsToAbs();
         return(comp);
     }
     catch (NXException ex)
     {
         ClassItem.WriteLogFile("创建装配档错误!" + ex.Message);
         throw ex;
     }
 }
Пример #34
0
		public MethodItem (TreeStore store, TreeItem parent, ClassItem parent_class, CoverageItem model, string title)
			: base (store, parent, model, title)
		{
			ParentClass = parent_class;
		}
Пример #35
0
        public CoverageView(string fileName, ProgressBar status)
        {
            store = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(string), typeof(object));
            tree = new TreeView (store);

            CellRendererText renderer = new CellRendererText ();
            CellRendererText coverageRenderer = new CellRendererText ();
            // LAME: Why is this property a float instead of a double ?
            renderer.Xalign = 0.5f;

            tree.AppendColumn ("Classes", new CellRendererText (), "text", 0);
            tree.AppendColumn ("Lines Hit", renderer, "text", 1);
            tree.AppendColumn ("Lines Missed", renderer, "text", 2);
            tree.AppendColumn ("Coverage", coverageRenderer, "text", 3);

            tree.GetColumn (0).Resizable = true;
            tree.GetColumn (1).Alignment = 0.0f;
            tree.GetColumn (1).Resizable = true;
            tree.GetColumn (2).Alignment = 0.0f;
            tree.GetColumn (2).Resizable = true;
            tree.GetColumn (3).Alignment = 0.0f;
            tree.GetColumn (3).Resizable = true;
            tree.GetColumn (3).SetCellDataFunc (coverageRenderer, new TreeCellDataFunc (RenderCoverage));

            tree.HeadersVisible = true;

            model = new CoverageModel ();
            foreach (string filter in DEFAULT_FILTERS) {
                model.AddFilter (filter);
            }
            this.status = status;
            model.Progress += Progress;
            model.ReadFromFile (fileName);

            TreeItem root = new TreeItem (store, null, model, "PROJECT");

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable ();
            string[] sorted_names = new string[classes2.Count];
            classes2.Keys.CopyTo (sorted_names, 0);
            Array.Sort (sorted_names);
            Progress ("Building tree", 0.95);
            foreach (string name in sorted_names) {
                ClassCoverageItem klass = (ClassCoverageItem)classes2[name];

                if (klass.filtered)
                    continue;

                string namespace2 = klass.name_space;
                TreeItem nsItem = (TreeItem)namespaces[namespace2];
                if (nsItem == null) {
                    nsItem = new TreeItem (store, root, (CoverageItem)model.Namespaces[namespace2], namespace2);
                    //				nsItem.SetPixmap (0, namespaceOpenPixmap);
                    namespaces[namespace2] = nsItem;
                }

                if (nsItem.model.filtered)
                    continue;

                ClassItem classItem = new ClassItem (store, nsItem, klass, klass.name);

                if (klass.ChildCount != 0) {
                    TreeIter treeIter = store.AppendNode (classItem.iter);
                    store.SetValues (treeIter, "<loading>");
                }
            }

            tree.ExpandRow (store.GetPath (root.Iter), false);

            // it becomes very hard to navigate if everything is expanded
            //foreach (string ns in namespaces.Keys)
            //	tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false);

            tree.RowExpanded += new RowExpandedHandler (OnRowExpanded);
            tree.RowCollapsed += new RowCollapsedHandler (OnRowCollapsed);
            tree.ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
            tree.Selection.Mode = SelectionMode.Single;

            Progress ("Done", 1.0);
            // LAME: Why doesn't widgets visible by default ???
            tree.Show ();
        }
Пример #36
0
 public ListModel()
 {
     ClassItems = new ClassItem[0];
 }
Пример #37
0
        private ClassItem ResolveClassItem(string classTitle, Dictionary<string, ClassItem> uniqueSortItemsDictionary)
        {
            ClassItem sortItem;
            string targetClassTitle = classTitle.Trim();
            if (uniqueSortItemsDictionary.ContainsKey(targetClassTitle))
            {
                sortItem = uniqueSortItemsDictionary[targetClassTitle];
            }
            else
            {
                sortItem = new ClassItem(targetClassTitle);
                uniqueSortItemsDictionary[targetClassTitle] = sortItem;
            }

            return sortItem;
        }
        private Dictionary<string, object> GetDictionaryWithValues(ClassItem classItem, int documentForeignKeyValue)
        {
            var dict = new Dictionary<string, object>();

            // Get all columns from coupled table
            var sql = $"select * from {classItem.TableName} where {classItem.PrimaryKeyName} = '{documentForeignKeyValue}'";

            var result = InstanceInfo.DBService.ExecuteAndGetDataSet(sql);

            if (result.Tables[0].Rows.Count > 0)
            {
                DataRow row = result.Tables[0].Rows[0];

                // Add each field to dictionary
                foreach (var col in result.Tables[0].Columns)
                {
                    dict.Add(col.ToString(), row[col.ToString()]);
                }
            }

            return dict;
        }
Пример #39
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strXmlClassDocument = hiddenClassXMLDocument.Value.Trim();
            if ("" == strXmlClassDocument)
            {
                PageUtil.PageAlert(this.Page, "请添加班级后保存");
                return;
            }
            XmlDocument xmlClass = new XmlDocument();
            try
            {
                xmlClass.LoadXml(string.Format("<Classes>{0}</Classes>" ,strXmlClassDocument));
            }
            catch(Exception ee)
            {
                PageUtil.PageAlert(this.Page, "保存失败!");
                return;
            }
            XmlNodeList classNodeList = xmlClass.GetElementsByTagName("Class");
            foreach (XmlNode classNode in classNodeList)
            {
                //添加主表记录——班级
                ClassItem classItem = new ClassItem();
                XmlNode nodeClassName = classNode.SelectSingleNode("ClassName");
                if (null == nodeClassName)
                    continue;
                string strClassName = nodeClassName.InnerText;
                if ("" == strClassName.Trim())
                    continue;
                classItem.ClassName = strClassName;

                XmlNode nodeNumber = classNode.SelectSingleNode("StudentNumber");
                if (null != nodeNumber)
                    classItem.StudentNumber = Util.ParseInt(nodeNumber.InnerText, 0);

                int nClassId = classItem.Save();
                if (nClassId <= 0)
                    continue;

                XmlNodeList studentNodeList = classNode.SelectNodes("Students/Student");
                foreach (XmlNode studentNode in studentNodeList)
                {
                    //添加字表记录——学生
                    StudentItem studentItem = new StudentItem();
                    studentItem.ClassItemId = nClassId;

                    XmlNode nodeStudentName = studentNode.SelectSingleNode("Name");
                    if (null == nodeStudentName)
                        continue;
                    string strStudentName = nodeStudentName.InnerText;
                    if ("" == strStudentName.Trim())
                        continue;
                    studentItem.Name = strStudentName;

                    XmlNode nodeAge = studentNode.SelectSingleNode("Age");
                    if (null != nodeAge)
                        studentItem.Age = Util.ParseInt(nodeAge.InnerText, 0);
                    studentItem.Save();
                }
            }

            PageUtil.PageAppendScript(this.Page, "alert('保存成功!');window.location.href = 'Window.aspx?value=FunctionControls/ClassManage/ClassManage.ascx'");
        }
Пример #40
0
 // Calling "Add" command creates a new method, but that's all. You can't set method
 // name, the body nort anything else.
 void CallAddMethodCommand(ClassItem c)
 {
     if (c.CanExecuteAdd(Method.DomainClassId))
     {
         c.ExecuteAdd(Method.DomainClassId);
     }
 }
Пример #41
0
	public CoverageView (string fileName, ProgressBar status)
	{
		TreeStore store = new TreeStore (typeof (string), typeof (string), typeof (string), typeof (string), typeof (object));
		tree = new TreeView (store);

		CellRendererText renderer = new CellRendererText ();
		// LAME: Why is this property a float instead of a double ?
		renderer.Xalign = 0.5f;

		tree.AppendColumn ("Classes", new CellRendererText (), "text", 0);
		tree.AppendColumn ("Lines Hit", renderer, "text", 1);
		tree.AppendColumn ("Lines Missed", renderer, "text", 2);
		tree.AppendColumn ("Coverage", renderer, "text", 3);

		tree.GetColumn (0).Resizable = true;
		tree.GetColumn (1).Alignment = 0.0f;
		tree.GetColumn (1).Resizable = true;
		tree.GetColumn (2).Alignment = 0.0f;
		tree.GetColumn (2).Resizable = true;
		tree.GetColumn (3).Alignment = 0.0f;
		tree.GetColumn (3).Resizable = true;

		tree.HeadersVisible = true;

		model = new CoverageModel ();
		foreach (string filter in DEFAULT_FILTERS) {
			model.AddFilter (filter);
		}
		this.status = status;
		model.Progress += Progress;
		model.ReadFromFile (fileName);

		TreeItem root = new TreeItem (store, null, model, "PROJECT");

		Hashtable classes2 = model.Classes;

		namespaces = new Hashtable ();
		string[] sorted_names = new string [classes2.Count];
		classes2.Keys.CopyTo (sorted_names, 0);
		Array.Sort (sorted_names);
		Progress ("Building tree", 0.95);
		foreach (string name in sorted_names) {
			ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

			if (klass.filtered)
				continue;

			string namespace2 = klass.name_space;
			TreeItem nsItem = (TreeItem)namespaces [namespace2];
			if (nsItem == null) {
				nsItem = new TreeItem (store, root, (CoverageItem)model.Namespaces [namespace2], namespace2);
				//				nsItem.SetPixmap (0, namespaceOpenPixmap);
				namespaces [namespace2] = nsItem;
			}

			if (nsItem.model.filtered)
				continue;

			ClassItem classItem = new ClassItem (store, nsItem, klass, klass.name);

			// We should create the method nodes only when the class item
			// is opened
			
			foreach (MethodCoverageItem method in klass.Methods) {
				if (method.filtered)
					continue;

				string title = method.Name;
				if (title.Length > 64)
					title = title.Substring (0, 63) + "...)";

				new MethodItem (store, classItem, classItem, method, title);
			}
		}

		tree.ExpandRow (store.GetPath (root.Iter), false);

		// it becomes very hard to navigate if everything is expanded
		//foreach (string ns in namespaces.Keys)
		//	tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false);

		tree.ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
		tree.Selection.Mode = SelectionMode.Single;

		source_views = new Hashtable ();
		window_maps = new Hashtable ();
		Progress ("Done", 1.0);
		// LAME: Why doesn't widgets visible by default ???
		tree.Show ();
	}
Пример #42
0
	SourceWindow ShowSourceFor (ClassItem item)
	{
		SourceWindow SourceView = (SourceWindow)source_views [item.Model.sourceFile];
		if (SourceView != null) {
			SourceView.Show ();
		} else {
			SourceView = new SourceWindow (item);
			source_views [item.Model.sourceFile] = SourceView;
			window_maps [SourceView] = item.Model.sourceFile;
			SourceView.Show ();
			SourceView.DeleteEvent += new DeleteEventHandler (OnDeleteEvent);
		}
		return SourceView;

	}
Пример #43
0
		void AddClass (ClassInfo class_info)
		{
			if (class_info.Id >= classes.Length) {
				ClassItem[] grow = new ClassItem [((class_info.Id / 10) + 1) * 10];
				classes.CopyTo (grow, 0);
				classes = grow;
			}
			classes [class_info.Id] = new ClassItem (class_info.Id, assemblies [class_info.AssemblyId], class_info.Name);
		}