void Additem(int ictype) { ClassifyType ctype = (ClassifyType)Enum.Parse(typeof(ClassifyType), ictype.ToString()); count = 0; for (int i = 0; i < CellPool.Count; i++) { EquipitemCell bCell = CellPool[i].GetComponent <EquipitemCell>(); bCell.EquipshopData = null; grid.transform.DetachChildren(); CellPool[i].SetActive(false); } for (int i = 0; i < EquipData.Count; i++) { if (EquipData[i]._classifytype == ctype) { if (count < CellPool.Count) { CellPool[count].transform.parent = grid.transform; CellPool[count].gameObject.SetActive(true); EquipitemCell bCell = CellPool[count].GetComponent <EquipitemCell>(); bCell.EquipshopData = EquipData[i]; UIManager.SetButtonEventHandler(CellPool[count].gameObject, EnumButtonEvent.OnClick, OnClickShop, EquipData[i]._Id, 0); } else { GameObject o = GameObject.Instantiate(item) as GameObject; o.SetActive(true); EquipitemCell pCell = o.GetComponent <EquipitemCell>(); pCell.EquipshopData = EquipData[i]; o.transform.parent = grid.transform; o.transform.position = Vector3.zero; o.transform.localScale = Vector3.one; UIManager.SetButtonEventHandler(o, EnumButtonEvent.OnClick, OnClickShop, EquipData[i]._Id, 0); CellPool.Add(o); } count++; } } }
public ClassifyByImageUrlRequest(ClassifyType classifyType, string url, string loc = "0-0-1-1") : this(classifyType, loc) { this.Url = url; }
public ClassifyByImageUrlRequest(ClassifyType classifyType, string loc = "0-0-1-1") : base(_classifyServiceDicts[(int)classifyType].ServiceType, _classifyServiceDicts[(int)classifyType].ServiceId, loc) { }
private static double urlClassify(ClassifyType type, string url) { if (string.IsNullOrWhiteSpace(url)) { return(0); } var split = urlSplit(url.ToLower()); if (split == null || split.Length == 0) { return(0); } url = string.Join("", split); Dictionary <string, double> sdc0; Dictionary <string, double> sdc1; double corp0; double corp1; double sum0; double sum1; switch (type) { case ClassifyType.locations: sdc0 = Loc_SDC_0; sdc1 = Loc_SDC_1; corp0 = Loc_CorpusInfo["C_0"]; corp1 = Loc_CorpusInfo["C_1"]; sum0 = Loc_SDC_0_Sum; sum1 = Loc_SDC_1_Sum; break; case ClassifyType.people: sdc0 = Ppl_SDC_0; sdc1 = Ppl_SDC_1; corp0 = Ppl_CorpusInfo["C_0"]; corp1 = Ppl_CorpusInfo["C_1"]; sum0 = Ppl_SDC_0_Sum; sum1 = Ppl_SDC_1_Sum; break; case ClassifyType.services: sdc0 = Srv_SDC_0; sdc1 = Srv_SDC_1; corp0 = Srv_CorpusInfo["C_0"]; corp1 = Srv_CorpusInfo["C_1"]; sum0 = Srv_SDC_0_Sum; sum1 = Srv_SDC_1_Sum; break; default: return(0); } Tuple <double, double> rtn = Enumerable.Range(2, 7) .SelectMany(i => Enumerable.Range(0, url.Length).Where(x => x + i <= url.Length).Select(s => url.Substring(s, i))) .GroupBy(s => s) .Select(group => Tuple.Create( sdc0.ContainsKey(group.Key) ? sdc0[group.Key] * group.Count() : 0.0, sdc1.ContainsKey(group.Key) ? sdc1[group.Key] * group.Count() : 0.0 )) .Aggregate((sum, current) => Tuple.Create( (sum.Item1 + current.Item1) / sum0 * corp0, (sum.Item2 + current.Item2) / sum1 * corp1 )); double prob = rtn.Item2 / (rtn.Item1 + rtn.Item2); return(Double.IsNaN(prob) ? 0 : prob); }
public static double ClassifyUrl(string url, ClassifyType type, string linkText = "") => urlClassify(type, url + linkText);
/// <summary> /// 按设定的条件执行搜索。 /// </summary> /// <param name="pageNum">搜索指定页的分类。如果要搜索第2页及其之后页的数据,则应先设置 PageSize 属性。</param> /// <param name="isReverse">是否对排序信息 OrderInfos 中设定的排序条件执行倒序,如果该参数为 true 将导致整个搜索结果的先后顺序发生逆转,通常情况下应使用 false。</param> /// <param name="keepSource">是否保留所有分类至该搜索结果集合源的引用。当需要对分类进行进一步的数据查询操作,保留源引用可以提升查询性能。</param> /// <param name="reload">对于应用程序框架缓存的分类,是否重新载入分类属性。如果应用程序框架对分类进行了缓存用以保持引用分类的一致性,该参数为 true 时可以强制刷新分类档案,例如桌面应用程序通常需要对分类对象进行缓存;但是对于 WEB 应用程序通常不做分类对象缓存,所以将该参数设为 false。</param> /// <returns>符合条件的分类集合。</returns> public ClassifyCollection Search(int pageNum, bool isReverse, bool keepSource, bool reload) { base.PageNum = pageNum; ClassifyCollection classifys = new ClassifyCollection(keepSource); try { System.Data.IDataReader dr = base.GetDataReader(isReverse); if (dr != null) { while (dr.Read()) { int intClassifyId = Function.ToInt(dr[Tables.Classify.ClassifyId]); Classify classify = base.Application.GetClassifyInstance(intClassifyId); if (classify != null) { if (reload) { classify.SetDataReader(dr); } if (this.Found != null) { if (keepSource) { if (isReverse) { classifys.Insert(0, classify); } else { classifys.Add(classify); } } this.Found(classify); } else { if (isReverse) { classifys.Insert(0, classify); } else { classifys.Add(classify); } } } else { ClassifyType classifyType = base.Application.ClassifyTypes.GetClassifyType(Function.ToString(dr[Tables.Classify.ClassifyType])); if (classifyType != null) { classify = classifyType.CreateClassify(); classify.SetApplication(base.Application); classify.SetDataReader(dr); if (classifyType.NeedCache) { base.Application.SetClassifyInstance(classify); } if (this.Found != null) { if (keepSource) { if (isReverse) { classifys.Insert(0, classify); } else { classifys.Add(classify); } } this.Found(classify); } else { if (isReverse) { classifys.Insert(0, classify); } else { classifys.Add(classify); } } } else { throw new Exception("未发现类型为 " + Function.ToString(dr[Tables.Classify.ClassifyType]) + " 的分类。"); } } } dr.Close(); } } finally { base.DbConnection.Close(); } return(classifys); }
public ClassifyByImageFileRequest(ClassifyType classifyType, System.IO.FileInfo imageFile, string loc = "0-0-1-1") : this(classifyType, loc) { this.ImageFile = imageFile; }
private void btnAccept_Click(object sender, EventArgs e) { if (this.cmbClassifyType.SelectedItem == null || (this.cmbClassifyType.SelectedItem is ClassifyType) == false) { MessageBox.Show("必须选择机构类型。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.txtName.Text.Length == 0) { MessageBox.Show("请输入根节点名称。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.m_Organization == null) { if (MessageBox.Show("确定创建名为“" + this.txtName.Text + "”类型是“" + this.cmbClassifyType.SelectedItem + "”的根节点机构吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { ClassifyType _ClassifyType = this.cmbClassifyType.SelectedItem as ClassifyType; Organization _Organization = _ClassifyType.CreateClassify() as Organization; _Organization.Name = this.txtName.Text; _Organization.Save(); this.m_Organization = _Organization; MessageBox.Show("根节点机构“" + _Organization.Name + "”已创建。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (this.m_Organization.ClassifyType.Equals(this.cmbClassifyType.SelectedItem)) { if (this.m_Organization.Name.Equals(this.txtName.Text) == false) { if (MessageBox.Show("确定要将“" + this.m_Organization.Name + "”修改为“" + this.txtName.Text + "”吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { this.m_Organization.Name = this.txtName.Text; this.m_Organization.Save(); MessageBox.Show("根节点机构“" + this.m_Organization.Name + "”已改名。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); f.Close(); } } } else { if (MessageBox.Show("确定要将类型是“" + this.m_Organization.ClassifyType.Name + "”的根节点机构更改为“" + this.cmbClassifyType.SelectedItem + "”类型吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { if (MessageBox.Show("变更根节点机构的类型将删除现有机构数据及机构与设备的对应关系,是否继续?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { this.m_Organization.Delete(); this.m_Organization = null; ClassifyType _ClassifyType = this.cmbClassifyType.SelectedItem as ClassifyType; Organization _Organization = _ClassifyType.CreateClassify() as Organization; _Organization.Name = this.txtName.Text; _Organization.Save(); this.m_Organization = _Organization; MessageBox.Show("根节点机构“" + _Organization.Name + "”已重新创建。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); f.Close(); } } } } }