static IEnumerator ChangeNameTimeOutHandle(float _firstWaitTime, float _perWaitTime, byte _checkTimes, string _name) { yield return(new WaitForSeconds(_firstWaitTime)); byte checkTimes = _checkTimes; //經過_fristWaitTime時間後,每_perWaitTime檢查一次資料是否回傳了,若檢查checkTimes次數後還是沒回傳就重送資料 while (WaitCB_ChangeName && checkTimes > 0) { checkTimes--; yield return(new WaitForSeconds(_perWaitTime)); } if (WaitCB_ChangeName)//如果還沒接收到CB就重送需求 { //若重送要求的次數達到上限次數則代表連線有嚴重問題,直接報錯 if (ReSendQuestTimes_ChangeName > 0) { ReSendQuestTimes_ChangeName--; CaseLogManager.ShowCaseLog(30001);//連線逾時,嘗試重複連線請玩家稍待 //向Server重送要求 SendChangeNameQuest(_name); } else { WaitCB_ChangeName = false; //設定為false代表不接受回傳了 CaseLogManager.ShowCaseLog(40001);; //請玩家檢查網路狀況或一段時間再嘗試連線 //CaseLogManager.ShowCaseLog(11);//請玩家檢查網路狀況或一段時間再嘗試連線 PopupUI.HideLoading(); //隱藏Loading } } }
/// <summary> /// 註冊回傳 /// </summary> static IEnumerator Coroutine_ChangeNameCB(WWW w) { if (ReSendQuestTimes_ChangeName == MaxReSendQuestTimes_ChangeName) { CaseLogManager.ShowCaseLog(30003);//登入中 } yield return(w); Debug.LogWarning(w.text); if (WaitCB_ChangeName) { WaitCB_ChangeName = false; if (w.error == null) { try { string[] result = w.text.Split(':'); //////////////////成功//////////////// if (result[0] == "Success1")//db創帳號 { string[] data = result[1].Split(','); Player.ChangeName1(data); PopupUI.HideLoading(); //隱藏Loading } if (result[0] == "Success2") //db已經有帳號只更新名稱 { string[] data = result[1].Split(','); Player.ChangeName2(data); PopupUI.HideLoading();//隱藏Loading } //////////////////失敗/////////////// else if (result[0] == ServerCBCode.Fail.ToString()) { int caseID = int.Parse(result[1]); CaseLogManager.ShowCaseLog(caseID); PopupUI.HideLoading();//隱藏Loading } else { CaseLogManager.ShowCaseLog(2004); PopupUI.HideLoading();//隱藏Loading } } //////////////////例外////////////////// catch (Exception ex) { Debug.LogException(ex); CaseLogManager.ShowCaseLog(2003); //註冊例外 PopupUI.HideLoading(); //隱藏Loading } } //////////////////回傳null//////////////// else { Debug.LogWarning(w.error); CaseLogManager.ShowCaseLog(2);; //連線不到server PopupUI.HideLoading(); //隱藏Loading } } }
static IEnumerator LeaderboardTimeOutHandle(float _firstWaitTime, float _perWaitTime, byte _checkTimes) { yield return(new WaitForSeconds(_firstWaitTime)); byte checkTimes = _checkTimes; //經過_fristWaitTime時間後,每_perWaitTime檢查一次資料是否回傳了,若檢查checkTimes次數後還是沒回傳就重送資料 while (WaitCB_Leaderboard && checkTimes > 0) { checkTimes--; yield return(new WaitForSeconds(_perWaitTime)); } if (WaitCB_Leaderboard)//如果還沒接收到CB就重送需求 { //若重送要求的次數達到上限次數則代表連線有嚴重問題,直接報錯 if (ReSendQuestTimes_Leaderboard > 0) { ReSendQuestTimes_Leaderboard--; CaseLogManager.ShowCaseLog(30001);//連線逾時,嘗試重複連線請玩家稍待 //向Server重送要求 SendLeaderboardQuest(); } else { WaitCB_Leaderboard = false;//設定為false代表不接受回傳了 Debug.LogWarning("取得排行榜資料失敗"); LeaderboardUI.GetChampionData(Player.LeaderboardData); //CaseLogManager.ShowCaseLog(40001); ;//請玩家檢查網路狀況或一段時間再嘗試連線 //CaseLogManager.ShowCaseLog(11);//請玩家檢查網路狀況或一段時間再嘗試連線 PopupUI.HideLoading();//隱藏Loading } } }
static IEnumerator SettlementTimeOutHandle(float _firstWaitTime, float _perWaitTime, byte _checkTimes) { yield return(new WaitForSeconds(_firstWaitTime)); byte checkTimes = _checkTimes; //經過_fristWaitTime時間後,每_perWaitTime檢查一次資料是否回傳了,若檢查checkTimes次數後還是沒回傳就重送資料 while (WaitCB_Settlement && checkTimes > 0) { checkTimes--; yield return(new WaitForSeconds(_perWaitTime)); } if (WaitCB_Settlement)//如果還沒接收到CB就重送需求 { //若重送要求的次數達到上限次數則代表連線有嚴重問題,直接報錯 if (ReSendQuestTimes_Settlement > 0) { ReSendQuestTimes_Settlement--; if (ShowLoading) { CaseLogManager.ShowCaseLog(30001); //連線逾時,嘗試重複連線請玩家稍待 } //向Server重送要求 SendSettlementQuest(); } else { WaitCB_Settlement = false;//設定為false代表不接受回傳了 if (ShowLoading) { CaseLogManager.ShowCaseLog(40001); } ; //請玩家檢查網路狀況或一段時間再嘗試連線 //CaseLogManager.ShowCaseLog(11);//請玩家檢查網路狀況或一段時間再嘗試連線 PopupUI.HideLoading(); //隱藏Loading } } }
private void Upload() { //网站名称获取ID int webId = WebsiteManager.GetWebIdByWebName(this.网站名称); if (webId == 0) { log.Debug(string.Format("传入网站名称错误:(城市名称:所有,网站名称:{0})", this.网站名称 == null ? "null" : this.网站名称)); return; } //开始数据上传 while (true) { System.Threading.Thread.Sleep(this.频率); //查询需要整理的案例 log.Debug(string.Format("查询需要整理的案例数据:(城市名称:所有,网站名称:{0})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString())); List <VIEW_案例信息_城市表_网站表> list = CaseLogManager.获取当前要整理入库的案例(this.网站名称, this.一次上传个数); if (list == null || list.Count < 1) { log.Debug(string.Format("案例数据已整理发布完成:(城市名称:所有,网站名称:{0})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString())); continue; } //数据上传 log.Debug(string.Format("已查询到需要整理的案例数据{0}个,发布数据中:(城市名称:所有,网站名称:{1})", list.Count, this.网站名称 == null ? "null" : this.网站名称)); list.ForEach(delegate(VIEW_案例信息_城市表_网站表 _obj) { log.Debug(string.Format("发布数据中:(ID:{0},城市名称:{1},网站名称:{2})", _obj.ID, _obj.城市, _obj.网站)); }); #region 多个上传 List <案例库上传信息过滤表> 过滤案例List = null; Dictionary <long, int> dic = new Dictionary <long, int>(); if (!CaseApi.发布需要整理的数据到服务器(list, out 过滤案例List, out dic)) { log.Debug(string.Format("发布需要整理的数据到服务器_异常:(城市名称:所有,网站名称:{0},案例ID个数:{1})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), list.Count)); break; } //记录过滤掉的案例ID log.Debug(string.Format("获取到要过滤的案例ID:(城市名称:所有,网站名称:{0},案例ID个数:{1},过滤ID数组个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), list.Count, 过滤案例List == null ? 0 : 过滤案例List.Count)); if (过滤案例List != null && 过滤案例List.Count > 0) { 过滤案例List.ForEach(delegate(案例库上传信息过滤表 _obj) { log.Debug(string.Format("过滤掉的案例:(ID:{0},城市ID:{1},网站ID:{2})", _obj.案例ID, _obj.城市ID, _obj.网站ID.ToString2())); }); log.Debug(string.Format("将上传时被过滤的信息记录到表中:(城市名称:所有,网站名称:{0},案例ID个数:{1},过滤ID数组个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), list.Count, 过滤案例List.Count)); if (!CaseFilterLogManager.将上传时被过滤的信息记录到表中(webId, 过滤案例List)) { log.Debug(string.Format("将上传时被过滤的信息记录到表中_异常:(城市名称:所有,网站名称{0},案例ID个数{1},过滤ID数组个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), list.Count, 过滤案例List.Count)); break; } } //统计入库失败的案例个数 log.Debug(string.Format("统计入库失败的案例个数:(城市名称:所有,网站名称:{0},案例ID:{1},案例ID个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), Convert.ToInt64(list[list.Count - 1].ID), list.Count)); string message = ""; if (!ProjectCaseCountManager.UpdateNotImportCaseCount(list, 过滤案例List, out message)) { log.Debug(string.Format("统计入库失败的案例个数_系统异常:(案例ID个数{0})", list.Count)); break; } //记录上传成功的案例ID log.Debug(string.Format("将当前已经整理入库的案例记录表中:(城市名称:所有,网站名称:{0},案例ID:{1},案例ID个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), Convert.ToInt64(list[list.Count - 1].ID), list.Count)); if (!CaseLogManager.将当前已经整理入库的案例记录表中(list, dic)) { log.Debug(string.Format("将当前已经整理入库的案例记录表中_系统异常:(城市名称:所有,网站名称:{0},案例ID:{1},案例ID个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), Convert.ToInt64(list[list.Count - 1].ID), list.Count)); break; } log.Debug(string.Format("当前案例ID数据记录完成:(城市名称:所有,网站名称:{0},案例ID:{1},案例ID个数:{2})", (this.网站名称 == null ? "null" : this.网站名称) + "$" + webId.ToString(), Convert.ToInt64(list[list.Count - 1].ID), list.Count)); #endregion } }
/// <summary> /// 註冊回傳 /// </summary> static IEnumerator Coroutine_SettlementCB(WWW w) { if (ReSendQuestTimes_Settlement == MaxReSendQuestTimes_Settlement) { if (ShowLoading) { CaseLogManager.ShowCaseLog(30003); //登入中 } } yield return(w); Debug.LogWarning(w.text); if (WaitCB_Settlement) { WaitCB_Settlement = false; if (w.error == null) { try { string[] result = w.text.Split(':'); //////////////////成功//////////////// if (result[0] == ServerCBCode.Success.ToString()) { //string[] data = result[1].Split(','); PopupUI.HideLoading();//隱藏Loading } //////////////////失敗/////////////// else if (result[0] == ServerCBCode.Fail.ToString()) { int caseID = int.Parse(result[1]); if (ShowLoading) { CaseLogManager.ShowCaseLog(caseID); } PopupUI.HideLoading();//隱藏Loading } else { if (ShowLoading) { CaseLogManager.ShowCaseLog(2004); } PopupUI.HideLoading();//隱藏Loading } } //////////////////例外////////////////// catch (Exception ex) { Debug.LogException(ex); if (ShowLoading) { CaseLogManager.ShowCaseLog(2003); //註冊例外 } PopupUI.HideLoading(); //隱藏Loading } } //////////////////回傳null//////////////// else { Debug.LogWarning(w.error); if (ShowLoading) { CaseLogManager.ShowCaseLog(2); } ; //連線不到server PopupUI.HideLoading(); //隱藏Loading } } }
/// <summary> /// /// </summary> /// <param name="list"></param> /// <param name="failList">返回失败的案例</param> /// <returns></returns> public static bool ImportCase(List <VIEW_案例信息_城市表_网站表> list, out List <VIEW_案例信息_城市表_网站表> failList, out string message) { message = ""; failList = new List <VIEW_案例信息_城市表_网站表>(); List <案例库上传信息过滤表> 过滤案例List = null; Dictionary <long, int> dic = new Dictionary <long, int>(); if (!CaseApi.发布需要整理的数据到服务器(list, out 过滤案例List, out dic)) { message = "fxt服务异常"; log.Debug(string.Format("发布需要整理的数据到服务器_异常:(案例ID个数:{0})", list.Count)); return(false); } using (DataClassesDataContext db = new DataClassesDataContext()) { db.Connection.Open(); //开始事务 var tran = db.Connection.BeginTransaction(); try { db.Transaction = tran; //删除此次案例的滤记录 List <long> caseIdList = new List <long>(); if (list != null) { foreach (VIEW_案例信息_城市表_网站表 caseView in list) { caseIdList.Add(caseView.ID); } if (!CaseFilterLogManager.DeleteCaseFilterByCaseIds(caseIdList.ToArray(), db: db)) { message = "系统异常"; log.Debug(string.Format("删除此次案例的滤记录_异常:(案例ID个数:{0},过滤ID数组个数:{1})", list.Count, 过滤案例List.Count)); tran.Rollback(); return(false); } } //记录过滤掉的案例ID if (过滤案例List != null && 过滤案例List.Count > 0) { foreach (案例库上传信息过滤表 obj in 过滤案例List) { VIEW_案例信息_城市表_网站表 obj2 = list.Find(delegate(VIEW_案例信息_城市表_网站表 obj3) { return(obj3.ID == obj.案例ID); }); if (obj2 != null) { failList.Add(obj2); } } if (!CaseFilterLogManager.将上传时被过滤的信息记录到表中(过滤案例List, db)) { message = "将上传时被过滤的信息记录到表中_系统异常"; log.Debug(string.Format("将上传时被过滤的信息记录到表中_异常:(案例ID个数:{0},过滤ID数组个数:{1})", list.Count, 过滤案例List.Count)); tran.Rollback(); return(false); } } //统计入库失败的案例个数 if (!ProjectCaseCountManager.UpdateNotImportCaseCount(list, 过滤案例List, out message, new DAL.DB.DataClass(db))) { log.Debug(string.Format("统计入库失败的案例个数_系统异常:(案例ID个数{0})", list.Count)); tran.Rollback(); return(false); } //记录上传成功的案例ID if (!CaseLogManager.将当前已经整理入库的案例记录表中(list, dic, db)) { message = "将当前已经整理入库的案例记录表中_系统异常"; log.Debug(string.Format("将当前已经整理入库的案例记录表中_系统异常:(案例ID个数{0})", list.Count)); tran.Rollback(); return(false); } db.Transaction.Commit(); } catch (Exception ex) { message = "系统异常"; log.Error(string.Format("系统异常ImportCase(List<VIEW_案例信息_城市表_网站表> list, out List<VIEW_案例信息_城市表_网站表> failList)", list.Count), ex); tran.Rollback(); return(false); } } return(true); }
/// <summary> /// 註冊回傳 /// </summary> static IEnumerator Coroutine_LeaderboardCB(WWW w) { if (ReSendQuestTimes_Leaderboard == MaxReSendQuestTimes_Leaderboard) { CaseLogManager.ShowCaseLog(30003);//登入中 } yield return(w); Debug.LogWarning(w.text); if (WaitCB_Leaderboard) { WaitCB_Leaderboard = false; if (w.error == null) { try { string[] result = w.text.Split(':'); //////////////////成功//////////////// if (result[0] == ServerCBCode.Success.ToString()) { string rankStr = result[1]; LeaderboardUI.GetChampionData(rankStr); PopupUI.HideLoading();//隱藏Loading } //////////////////失敗/////////////// else if (result[0] == ServerCBCode.Fail.ToString()) { //int caseID = int.Parse(result[1]); //CaseLogManager.ShowCaseLog(caseID); Debug.LogWarning("取得排行榜資料失敗"); LeaderboardUI.GetChampionData(Player.LeaderboardData); PopupUI.HideLoading();//隱藏Loading } else { //CaseLogManager.ShowCaseLog(2004); Debug.LogWarning("取得排行榜資料失敗"); LeaderboardUI.GetChampionData(Player.LeaderboardData); PopupUI.HideLoading();//隱藏Loading } } //////////////////例外////////////////// catch (Exception ex) { Debug.LogException(ex); Debug.LogWarning("取得排行榜資料失敗"); LeaderboardUI.GetChampionData(Player.LeaderboardData); //CaseLogManager.ShowCaseLog(2003);//註冊例外 PopupUI.HideLoading();//隱藏Loading } } //////////////////回傳null//////////////// else { Debug.LogWarning(w.error); Debug.LogWarning("取得排行榜資料失敗"); LeaderboardUI.GetChampionData(Player.LeaderboardData); //CaseLogManager.ShowCaseLog(2); ;//連線不到server PopupUI.HideLoading();//隱藏Loading } } }