public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return false; } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.IGNORE_NOT_FOUND; return false; } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.IGNORE_SELF; return false; } //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type)) { relResult = RelationResult.IGNORE_ALREADY; return false; } relResult = RelationResult.IGNORE_ADDED; return true; }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } if (relatedCharInfo == null) { relResult = RelationResult.IGNORE_NOT_FOUND; return(false); } if ((int)charInfo.EntityLowId == (int)relatedCharInfo.EntityLowId) { relResult = RelationResult.IGNORE_SELF; return(false); } if (Singleton <RelationMgr> .Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type)) { relResult = RelationResult.IGNORE_ALREADY; return(false); } relResult = RelationResult.IGNORE_ADDED; return(true); }
void IXmlSerializable.ReadXml(XmlReader reader) { reader.MoveToContent(); this.Version = reader.GetAttributeDouble("version"); this.Generator = reader.GetAttribute("generator"); List <OsmGeoResult> results = null; while (reader.Read()) { var moveToContent = reader.MoveToContent(); if (moveToContent == XmlNodeType.None || moveToContent == XmlNodeType.EndElement) { break; } if (reader.Name == "node") { if (results == null) { results = new List <OsmGeoResult>(); } var nodeResult = new NodeResult(); (nodeResult as IXmlSerializable).ReadXml(reader); results.Add(nodeResult); } else if (reader.Name == "way") { if (results == null) { results = new List <OsmGeoResult>(); } var wayResult = new WayResult(); (wayResult as IXmlSerializable).ReadXml(reader); results.Add(wayResult); } else if (reader.Name == "relation") { if (results == null) { results = new List <OsmGeoResult>(); } var relationResult = new RelationResult(); (relationResult as IXmlSerializable).ReadXml(reader); results.Add(relationResult); } else { if (results == null) { results = new List <OsmGeoResult>(); } return; } } if (results != null) { this.Results = results.ToArray(); } }
public async Task <ActionResult <IResult> > Filter(string datastoreName, string name, string value) { RelationResult filterResult; if (string.IsNullOrWhiteSpace(datastoreName) || string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(value)) { filterResult = new RelationResult(false, "datastoreName, 属性名和属性值都不能为空"); } else { name = name.ToLower(); value = value.ToLower(); GraphExecutor executor = new GraphExecutor(datastoreName); (bool isDSExist, List <VisulizedVertex> vvs) = executor.FilterVertexesByProperty(name, value); if (!isDSExist) { filterResult = new RelationResult(false, "Datastore " + datastoreName + "不存在,或没有数据导入。"); } else { if (vvs == null || vvs.Count == 0) { filterResult = new RelationResult(true, "根据\"" + name + " = " + value + ",\"未能找到任何符合条件的节点。"); } else { VisulizedVertex propertyVV = KGUtility.GeneratePropertyVVertex("", name, value); filterResult = new RelationResult(true, "根据\"" + name + " = " + value + ",\"为您搜索到以下节点:"); List <VisulizedEdge> ves = new List <VisulizedEdge>(); foreach (VisulizedVertex vv in vvs) { VisulizedEdge ve = new VisulizedEdge(); ve.value = name; ve.sourceId = propertyVV.id; ve.targetId = vv.id; ves.Add(ve); } vvs.Insert(0, propertyVV); filterResult.nodes = vvs; filterResult.relations = ves; } } } log.Here().Information("[Response]: " + JsonConvert.SerializeObject(filterResult)); return(Ok(filterResult)); }
private void UpData(String boxGUID, QRBean boxBean) { DBOperation dBOperation = new DBOperation(); try { if (tbBoxID.Text == "") { throw new Exception("请先选择未上传的箱子的ID"); } DataSet dataSet = dBOperation.GetUploadCase(boxGUID); UploadData uploadData = new UploadData(); uploadData.tempDelId = BaseData.TempId; uploadData.parentCode = boxBean; foreach (DataRow Row in dataSet.Tables[0].Rows) { uploadData.childCodes.Add(QRanalyze.QRDecod(Row["FCapData"].ToString())); } String result = HttpRequest.UploadCapData(uploadData, Session.Id); RelationResult Result = JsonConvert.DeserializeObject <RelationResult>(result); if (Result.success) { dBOperation.UploadBoxTStatus(boxGUID); tbBoxID.Text = ""; tbBoxTag.Text = ""; boxGUID = ""; dgBox.DataSource = dBOperation.QueryNoUplaodBox().Tables[0]; dgBox.Columns["ID"].HeaderText = "未上传箱号ID"; dgBox.Columns["ID"].Width = 300; dgBox.Columns["FGuid"].HeaderText = "GUID编码"; dgBox.Columns["FGuid"].Width = 300; } else { throw new Exception(Result.message); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { dBOperation.Dispose(); } }
public async Task <ActionResult <IResult> > Get(string datastoreName, string scenarioName) { RelationResult relationResult; if (string.IsNullOrWhiteSpace(datastoreName) || string.IsNullOrWhiteSpace(scenarioName)) { relationResult = new RelationResult(false, "datastoreName 和 scenario 不能为空"); } else { int displayMax = dsManager.GetMaxDisplayedEntityNumber(); GraphExecutor executor = new GraphExecutor(datastoreName); (bool isDSExist, bool isScenarioExist, bool isDisplable, string message, List <VisulizedVertex> vvs, List <VisulizedEdge> ves) = executor.GetVertexesAndEdgesByScenarios(new List <string>() { scenarioName }, displayMax); if (!isDSExist) { relationResult = new RelationResult(false, "Datastore " + datastoreName + "不存在,或没有数据导入。"); } else { if (!isScenarioExist) { relationResult = new RelationResult(false, "Scenario " + scenarioName + "不存在,或没有数据导入。"); } else { if (!isDisplable) { relationResult = new RelationResult(false, "Scenario " + scenarioName + " 包含的实体数量超过了最大显示量的设置(最多显示 " + displayMax + " 个实体),无法显示完整图谱,请通过搜索查看部分图谱。"); } else { string scenarioStr = "scenario: " + scenarioName + " 的图谱如下:"; relationResult = new RelationResult(true, scenarioStr + " 的图谱如下:"); relationResult.nodes = vvs; relationResult.relations = ves; } } } } log.Information("[Response]: " + JsonConvert.SerializeObject(relationResult)); return(Ok(relationResult)); }
public List <long> GetPageids(DeviceModel model) { DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier = new DeviceApply_Data_Device_Identifiers() { device_id = long.Parse(model.device_id), major = long.Parse(model.major), minor = long.Parse(model.minor), uuid = model.uuid }; RelationResult relationResult = ShakeAroundApi.SearchPagesByDeviceId(_accessToken, 1, deviceApplyDataDeviceIdentifier, 10000); return(( from p in relationResult.data.relations select p.page_id).ToList()); }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return false; } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.FRIEND_NOT_FOUND; return false; } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.FRIEND_SELF; return false; } //Checks if both chars are in the same faction if (FactionMgr.GetFactionGroup(charInfo.Race) != FactionMgr.GetFactionGroup(relatedCharInfo.Race)) { relResult = RelationResult.FRIEND_ENEMY; return false; } //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, Type)) { relResult = RelationResult.FRIEND_ALREADY; return false; } //All checks are ok so check if the related char is online if (World.GetCharacter(relatedCharInfo.EntityLowId) != null) { relResult = RelationResult.FRIEND_ADDED_ONLINE; } else { relResult = RelationResult.FRIEND_ADDED_OFFLINE; } return true; }
public async Task <ActionResult <IResult> > GetRelations(string datastoreName, string id) { RelationResult relationResult; if (string.IsNullOrWhiteSpace(datastoreName) || string.IsNullOrWhiteSpace(id)) { relationResult = new RelationResult(false, "datastoreName 和 id 不能为空"); } else { GraphExecutor executor = new GraphExecutor(datastoreName); (bool isDSExist, VisulizedVertex theVVertex) = executor.GetVertexById(id); if (!isDSExist) { relationResult = new RelationResult(false, "Datastore " + datastoreName + "不存在,或没有数据导入。"); } else { if (theVVertex == null) { relationResult = new RelationResult(true, "无法找到节点 " + id + "。"); } else { (bool dsExist, List <VisulizedVertex> vvs, List <VisulizedEdge> ves) = executor.GetFirstLevelRelationships(id); relationResult = new RelationResult(true, "节点 id =" + id + " 的一阶关系如下:"); relationResult.nodes = vvs; if (relationResult.nodes == null) { relationResult.nodes = new List <VisulizedVertex> { theVVertex }; } else { relationResult.nodes.Add(theVVertex); } relationResult.relations = ves; } } } log.Here().Information("[Response]: " + JsonConvert.SerializeObject(relationResult)); return(Ok(relationResult)); }
//数据采集触发 private void tbCaseNumber_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == 13) { String result = HttpRequest.ConfirmLowerCodeRelation(QRanalyze.QRDecod(tbCaseNumber.Text.Substring(tbCaseNumber.Text.Length - 35, 35)), Session.Id); RelationResult Result = JsonConvert.DeserializeObject <RelationResult>(result); if (!Result.success) { throw new Exception(Result.message); } if (Datas.Add(tbCaseNumber.Text.Substring(tbCaseNumber.Text.Length - 35, 35))) { capsum++; tbCapSum.Text = capsum.ToString(); DataSource.Rows.Add(capsum.ToString(), tbCaseNumber.Text.Substring(tbCaseNumber.Text.Length - 35, 35), DateTime.Now.ToString()); } else { MessageBox.Show(tbCaseNumber.Text + "重复扫描"); } //一箱数据采集完毕 if (Datas.Count == BaseData.CapSum) { DBOperation dBOperation = new DBOperation(); Guid BoxId = Guid.NewGuid(); dBOperation.AddBoxs(BoxId); dBOperation.CreatBoxOrder(BoxId, Datas); dBOperation.Dispose(); Datas.Clear(); DataSource.Clear(); capsum = 0; tbCapSum.Text = capsum.ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { tbCaseNumber.Text = ""; } }
public async Task <ActionResult <IResult> > Get(string datastoreName, string scenarioName) { RelationResult relationResult; if (string.IsNullOrWhiteSpace(datastoreName) || string.IsNullOrWhiteSpace(scenarioName)) { relationResult = new RelationResult(false, "datastoreName 和 scenario 不能为空"); } else { GraphExecutor executor = new GraphExecutor(datastoreName); (bool isDSExist, bool isScenarioExist, List <VisulizedVertex> vvs, List <VisulizedEdge> ves) = executor.GetVertexesAndEdgesByScenarios(new List <string>() { scenarioName }); if (!isDSExist) { relationResult = new RelationResult(false, "Datastore " + datastoreName + "不存在,或没有数据导入。"); } else { if (!isScenarioExist) { relationResult = new RelationResult(false, "Scenario " + scenarioName + "不存在,或没有数据导入。"); } else { string scenarioStr = "scenario: " + scenarioName + " 的图谱如下:"; relationResult = new RelationResult(true, scenarioStr + " 的图谱如下:"); relationResult.nodes = vvs; relationResult.relations = ves; } } } log.Information("[Response]: " + JsonConvert.SerializeObject(relationResult)); return(Ok(relationResult)); }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return false; } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.MUTED_NOT_FOUND; return false; } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.MUTED_SELF; return false; } ////Checks if both chars are in the same faction //if (Factions.FactionMgr.GetFactionGroup(charInfo.Race) != Factions.FactionMgr.GetFactionGroup((RaceType)relatedCharInfo.Race)) //{ // relResult = RelationResult.MUTED_ENEMY; // return false; //} //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type)) { relResult = RelationResult.MUTED_ALREADY; return false; } relResult = RelationResult.MUTED_ADDED; return true; }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } if (relatedCharInfo == null) { relResult = RelationResult.FRIEND_NOT_FOUND; return(false); } if ((int)charInfo.EntityLowId == (int)relatedCharInfo.EntityLowId) { relResult = RelationResult.FRIEND_SELF; return(false); } if (FactionMgr.GetFactionGroup(charInfo.Race) != FactionMgr.GetFactionGroup(relatedCharInfo.Race)) { relResult = RelationResult.FRIEND_ENEMY; return(false); } if (Singleton <RelationMgr> .Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, Type)) { relResult = RelationResult.FRIEND_ALREADY; return(false); } relResult = World.GetCharacter(relatedCharInfo.EntityLowId) == null ? RelationResult.FRIEND_ADDED_OFFLINE : RelationResult.FRIEND_ADDED_ONLINE; return(true); }
private void tbBoxTag_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == 13) { String result = HttpRequest.ConfirmSuperCodeRelation(QRanalyze.QRDecod(tbBoxTag.Text.Substring(tbBoxTag.Text.Length - 35, 35)), Session.Id); RelationResult Result = JsonConvert.DeserializeObject <RelationResult>(result); if (Result.success) { AccessDB.UpDataOne(tbBoxTag.Text); } else { throw new Exception(Result.message); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void NotifyFriendRelations(uint friendLowId, RelationResult relResult) { m_lock.EnterReadLock(); try { HashSet <IBaseRelation> relations; if (m_passiveRelations[(int)CharacterRelationType.Friend].TryGetValue(friendLowId, out relations)) { foreach (var relation in relations) { var target = World.GetCharacter(relation.CharacterId); if (target != null) { SendFriendStatus(target, friendLowId, relation.Note, relResult); } } } } finally { m_lock.ExitReadLock(); } }
private void NotifyFriendRelations(uint friendLowId, RelationResult relResult) { m_lock.EnterReadLock(); try { HashSet <IBaseRelation> baseRelationSet; if (!m_passiveRelations[1].TryGetValue(friendLowId, out baseRelationSet)) { return; } foreach (IBaseRelation baseRelation in baseRelationSet) { Character character = World.GetCharacter(baseRelation.CharacterId); if (character != null) { SendFriendStatus(character, friendLowId, baseRelation.Note, relResult); } } } finally { m_lock.ExitReadLock(); } }
public async Task <ActionResult <IResult> > Get(string[] scenarios) { RelationResult relationResult; GraphExecutor executor = new GraphExecutor(); (List <VisulizedVertex> vvs, List <VisulizedEdge> ves) = executor.GetVertexesAndEdgesByScenarios(scenarios.ToList()); string scenarioStr = "所有 scenarios"; if (scenarios != null && scenarios.Length > 0) { scenarioStr = "scnearios: " + string.Join(", ", scenarios); } relationResult = new RelationResult(true, scenarioStr + " 的图谱如下:"); relationResult.nodes = vvs; relationResult.relations = ves; log.Information("[Response]: " + JsonConvert.SerializeObject(relationResult)); return(Ok(relationResult)); }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.MUTED_NOT_FOUND; return(false); } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.MUTED_SELF; return(false); } ////Checks if both chars are in the same faction //if (Factions.FactionMgr.GetFactionGroup(charInfo.Race) != Factions.FactionMgr.GetFactionGroup((RaceType)relatedCharInfo.Race)) //{ // relResult = RelationResult.MUTED_ENEMY; // return false; //} //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type)) { relResult = RelationResult.MUTED_ALREADY; return(false); } relResult = RelationResult.MUTED_ADDED; return(true); }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.FRIEND_NOT_FOUND; return(false); } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.FRIEND_SELF; return(false); } //Checks if both chars are in the same faction if (FactionMgr.GetFactionGroup(charInfo.Race) != FactionMgr.GetFactionGroup(relatedCharInfo.Race)) { relResult = RelationResult.FRIEND_ENEMY; return(false); } //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, Type)) { relResult = RelationResult.FRIEND_ALREADY; return(false); } //All checks are ok so check if the related char is online if (World.GetCharacter(relatedCharInfo.EntityLowId) != null) { relResult = RelationResult.FRIEND_ADDED_ONLINE; } else { relResult = RelationResult.FRIEND_ADDED_OFFLINE; } return(true); }
public virtual bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { relResult = RelationResult.FRIEND_DB_ERROR; return true; }
public virtual bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { relResult = RelationResult.FRIEND_DB_ERROR; return(true); }
public override bool Validate(CharacterRecord charInfo, CharacterRecord relatedCharInfo, out RelationResult relResult) { //Check if the character exists. This should always be true in theory if (charInfo == null) { relResult = RelationResult.FRIEND_DB_ERROR; return(false); } //Checks if the relation target char exist if (relatedCharInfo == null) { relResult = RelationResult.IGNORE_NOT_FOUND; return(false); } //Checks if the target char is the same as the related one if (charInfo.EntityLowId == relatedCharInfo.EntityLowId) { relResult = RelationResult.IGNORE_SELF; return(false); } //Checks if the relation currently exist if (RelationMgr.Instance.HasRelation(charInfo.EntityLowId, relatedCharInfo.EntityLowId, this.Type)) { relResult = RelationResult.IGNORE_ALREADY; return(false); } relResult = RelationResult.IGNORE_ADDED; return(true); }
/// <summary> /// 上传一个箱号 /// </summary> /// <param name="boxId">箱号</param> /// <returns></returns> public static String UpDataOne(String BoxNum) { QRBean BoxNumber = QRanalyze.QRDecod(BoxNum.Substring(BoxNum.Length - 35, 35)); OleDbConnection connection = GetConnectionOne(AccessDbHelp.GetConnectString()); OleDbTransaction transaction = connection.BeginTransaction(); try { //找出最小未装箱的最小箱号 OleDbCommand cmd = new OleDbCommand(); cmd.Connection = connection; cmd.Transaction = transaction; String sqlBox = String.Format("SELECT FGuid from BOX where ID = (select min(ID) from BOX Where FStatus = '{0}')", BoxStatusNoUp); cmd.CommandText = sqlBox; Object boxGuid = cmd.ExecuteScalar(); String BoxGuid; if (boxGuid == null) { throw new Exception("没有可以使用箱"); } else { BoxGuid = boxGuid.ToString(); } //生成装箱上传数据 DataSet dataSet = new DataSet(); String sql_box = String.Format("select [FCapData] from [Case] where [FBoxId] = '{0}'", BoxGuid); OleDbDataAdapter da = new OleDbDataAdapter(sql_box, connection); da.SelectCommand.Transaction = transaction; da.Fill(dataSet); UploadData uploadData = new UploadData(); uploadData.tempDelId = BaseData.TempId; uploadData.parentCode = BoxNumber; foreach (DataRow Row in dataSet.Tables[0].Rows) { String msg = Row["FCapData"].ToString(); uploadData.childCodes.Add(QRanalyze.QRDecod(msg.Substring(msg.Length - 35, 35))); } RelationResult result = JsonConvert.DeserializeObject <RelationResult>(HttpRequest.UploadCapData(uploadData, Session.Id)); //RelationResult result = new RelationResult(); //result.success = true; if (result.success) { String sqlUp = String.Format("Update [Box] set [FStatus] = '{0}',[FBoxNumber] = '{1}' where [FGuid] = '{2}'", BoxStatusHaveUp, BoxNum, BoxGuid); cmd.CommandText = sqlUp; cmd.ExecuteNonQuery(); } else { throw new Exception(result.message); } transaction.Commit(); return(BoxGuid); } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } }
public static void SendFriendStatus(Character target, uint friendId, string note, RelationResult relResult) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_FRIEND_STATUS)) { packet.WriteByte((byte)relResult); switch (relResult) { case RelationResult.FRIEND_DB_ERROR: case RelationResult.FRIEND_NOT_FOUND: case RelationResult.IGNORE_NOT_FOUND: case RelationResult.MUTED_NOT_FOUND: case RelationResult.FRIEND_ENEMY: case RelationResult.FRIEND_SELF: case RelationResult.FRIEND_ALREADY: case RelationResult.FRIEND_REMOVED: case RelationResult.IGNORE_SELF: case RelationResult.IGNORE_ALREADY: case RelationResult.IGNORE_ADDED: case RelationResult.IGNORE_REMOVED: case RelationResult.MUTED_SELF: case RelationResult.MUTED_ALREADY: case RelationResult.MUTED_ADDED: case RelationResult.MUTED_REMOVED: packet.Write(EntityId.GetPlayerId(friendId)); break; case RelationResult.FRIEND_ADDED_OFFLINE: packet.Write(EntityId.GetPlayerId(friendId)); packet.WriteCString(note); break; case RelationResult.FRIEND_OFFLINE: packet.Write(EntityId.GetPlayerId(friendId)); packet.WriteByte((byte)CharacterStatus.OFFLINE); break; } target.Client.Send(packet, addEnd: false); } }