public void ShowBesideMonthCalendar(bool nextOrLast) { if (nextOrLast) { //跳至下一个月 DateTime nextCalendarDateTime = currentCalendarDateTime.AddMonths(1); DateTime firstDateOfNext = new DateTime(nextCalendarDateTime.Year, nextCalendarDateTime.Month, 1); if (firstDateOfNext > TimeUtil.getDateTimeByInt((int)(SignInMgr.GetInstance().MaxDay))) { //如果下一個月的第一天沒有配置 return; } //设置currentCalendarDateTime currentCalendarDateTime = currentCalendarDateTime.AddMonths(1); Debug.Log(currentCalendarDateTime.Year + " " + currentCalendarDateTime.Month + " " + currentCalendarDateTime.Day); nextCalendarDateTime = currentCalendarDateTime.AddMonths(1); //TODO:加入动画而非直接变换位置 StartCoroutine(moveRectTrans(rectTrans, rectTrans.anchoredPosition + Vector2.left * panelWidth, 0.2f, () => { // rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.left * panelWidth; //TODO:动画播完后,改变子节点的排序,即多个日历的排序,由于horizontalLayout的作用会改变每个日历的位置,将第一个日历放到最后时,当前展示的日历会往左移动,因此整个panel需要再往右移动 //TODO:原本的第一个子节点,即第一个日历放到最后之后,将第一个日历变为当前查看的日历的下一月份的日历 Transform firstCalendarTrans = rectTrans.GetChild(0); firstCalendarTrans.SetAsLastSibling(); CalendarTest firstCalendar = firstCalendarTrans.GetComponent <CalendarTest>(); firstCalendar.InitCalendar(nextCalendarDateTime.Month, nextCalendarDateTime.Year); Debug.Log("move back"); rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.right * panelWidth; })); } else { //跳至上一个月 DateTime lastCalendarDateTime = currentCalendarDateTime.AddMonths(-1); DateTime lastDateOfLast = new DateTime(currentCalendarDateTime.Year, currentCalendarDateTime.Month, 1).AddDays(-1); if (lastDateOfLast < TimeUtil.getDateTimeByInt((int)(SignInMgr.GetInstance().MinDay))) { //如果上一個月的最後一天也沒有配置 return; } //设置currentCalendarDateTime currentCalendarDateTime = currentCalendarDateTime.AddMonths(-1); Debug.Log(currentCalendarDateTime.Year + " " + currentCalendarDateTime.Month + " " + currentCalendarDateTime.Day); lastCalendarDateTime = currentCalendarDateTime.AddMonths(-1); //TODO:加入动画而非直接变换位置 StartCoroutine(moveRectTrans(rectTrans, rectTrans.anchoredPosition + Vector2.right * panelWidth, 0.2f, () => { //TODO:动画播完后,改变子节点的排序,即多个日历的排序,由于horizontalLayout的作用会改变每个日历的位置,将最后一个日历放到开头时,当前展示的日历会往右移动,因此整个panel需要再往左移动 //TODO:原本的最后一个子节点,即最后一个日历放到开头之后,将最后一个日历变为当前查看的日历的前一月份的日历 Transform lastCalendarTrans = rectTrans.GetChild(rectTrans.childCount - 1); lastCalendarTrans.SetAsFirstSibling(); CalendarTest lastCalendar = lastCalendarTrans.GetComponent <CalendarTest>(); lastCalendar.InitCalendar(lastCalendarDateTime.Month, lastCalendarDateTime.Year); rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.left * panelWidth; })); // rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.right * panelWidth; } }
/// <summary> /// 提升奉献值 /// </summary> public void UpdateMarriageGoodWill(GameClient client, int addGoodwillValue) { //功能未开启 if (!MarryLogic.IsVersionSystemOpenOfMarriage()) { return; } //看看是不是情侣 if (client.ClientData.MyMarriageData.byMarrytype == -1) { return; } //不加也不减直接无视吧 if (addGoodwillValue == 0) { return; } sbyte tmpGoodwilllv = client.ClientData.MyMarriageData.byGoodwilllevel; sbyte tmpGoodwillstar = client.ClientData.MyMarriageData.byGoodwillstar; //加值前先检查当前阶级是否已达上限 到达上限不加 if (tmpGoodwilllv == byMaxGoodwillLv && tmpGoodwillstar == byMaxGoodwillStar) { return; } //加值 client.ClientData.MyMarriageData.nGoodwillexp += addGoodwillValue; //用当前经验值增加上该阶级和星级应该有的经验 int nNowLvAddExp = GoodwillAllExpList[(tmpGoodwilllv - 1) * byMaxGoodwillStar + tmpGoodwillstar]; client.ClientData.MyMarriageData.nGoodwillexp += nNowLvAddExp; bool bUpdateLv = false; bool bUpdateStar = false; //看看当前经验达到哪一级 直接设上去 for (int i = 1; i < GoodwillAllExpList.Count; ++i) { //超过最后一项表示满级满星了 if (i == GoodwillAllExpList.Count - 1 && client.ClientData.MyMarriageData.nGoodwillexp >= GoodwillAllExpList[i]) { client.ClientData.MyMarriageData.byGoodwilllevel = byMaxGoodwillLv; client.ClientData.MyMarriageData.byGoodwillstar = byMaxGoodwillStar; bUpdateStar = true; //设定到最大经验 client.ClientData.MyMarriageData.nGoodwillexp = GoodwillAllExpList[i] - GoodwillAllExpList[i - 1]; } else if (client.ClientData.MyMarriageData.nGoodwillexp < GoodwillAllExpList[i]) { int nLv = 0; int nStar = 0; //1阶情况 if (i <= byMaxGoodwillStar + 1) { nLv = 1; nStar = i - 1; } else { nLv = (i - 2) / byMaxGoodwillStar + 1; nStar = (i - 1) % byMaxGoodwillStar; if (nStar == 0) { nStar = 10; } } if (nLv != tmpGoodwilllv) { bUpdateLv = true; } if (nStar != tmpGoodwillstar) { bUpdateStar = true; } client.ClientData.MyMarriageData.byGoodwilllevel = (sbyte)nLv; client.ClientData.MyMarriageData.byGoodwillstar = (sbyte)nStar; //发送客户端和记录数据库时清掉多余的经验部分 例如66点经验 - 当前阶级总共60点经验后剩 6 记录数据 client.ClientData.MyMarriageData.nGoodwillexp -= GoodwillAllExpList[i - 1]; break; } } //[bing] 更新时间 if (true == bUpdateLv || true == bUpdateStar) { client.ClientData.MyMarriageData.ChangTime = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss"); } //发送给DB update数据 MarryFuBenMgr.UpdateMarriageData2DB(client); //更新婚戒属性 if (true == bUpdateLv || true == bUpdateStar) { UpdateRingAttr(client, true); } //发送给客户端更新数据 SendMarriageDataToClient(client, (true == bUpdateLv || true == bUpdateStar)); if (true == bUpdateLv) { //[bing] 刷新客户端活动叹号 if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) == true || client._IconStateMgr.CheckSpecialActivity(client)) { client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } if (addGoodwillValue > 0) { string strHint = StringUtil.substitute(Global.GetLang("你获得了:{0}点奉献度"), addGoodwillValue); GameManager.ClientMgr.NotifyImportantMsg(client, strHint, GameInfoTypeIndexes.Normal, ShowGameInfoTypes.PiaoFuZi); } }
public static long GetTimeStamp() { long instanceId = TimeUtil.Now(); return(instanceId); }
/// <summary> /// This method is visible for testing! /// </summary> /// <returns></returns> internal virtual TimeSpan Ticks() => TimeUtil.GetSystemTime();
public void ISODateTimeParseWithNullArg() { TimeUtil.ParseISO8601DateTime(null); }
public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, StrUtil.Utf8, true); string strData = sr.ReadToEnd(); sr.Close(); CsvOptions opt = new CsvOptions(); opt.BackslashIsEscape = false; opt.TextQualifier = char.MinValue; opt.TrimFields = true; CsvStreamReaderEx csv = new CsvStreamReaderEx(strData, opt); string strMapIgnore = Guid.NewGuid().ToString(); string strMapGroup = Guid.NewGuid().ToString(); string strMapTags = Guid.NewGuid().ToString(); string strMapLastMod = Guid.NewGuid().ToString(); string strMapEMail = Guid.NewGuid().ToString(); Dictionary <string, string> dMaps = new Dictionary <string, string>( StrUtil.CaseIgnoreComparer); dMaps["title"] = PwDefs.TitleField; dMaps["type"] = strMapIgnore; dMaps["username_field"] = strMapIgnore; dMaps["username"] = PwDefs.UserNameField; dMaps["password_field"] = strMapIgnore; dMaps["password"] = PwDefs.PasswordField; dMaps["url"] = PwDefs.UrlField; dMaps["category"] = strMapGroup; dMaps["note"] = PwDefs.NotesField; dMaps["autofill"] = strMapIgnore; dMaps["autofillenabled"] = strMapIgnore; dMaps["last_password_change"] = strMapIgnore; dMaps["lastmodified"] = strMapLastMod; dMaps["iban"] = PwDefs.UserNameField; dMaps["bic"] = "BIC"; dMaps["banking_pin"] = PwDefs.PasswordField; dMaps["card_number"] = PwDefs.UserNameField; dMaps["card_holder"] = "Card Holder"; dMaps["card_pin"] = PwDefs.PasswordField; dMaps["card_verification_code"] = "Verification Code"; dMaps["valid_from"] = "Valid From"; dMaps["valid_thru"] = "Valid To"; dMaps["name"] = PwDefs.UserNameField; dMaps["firstname"] = PwDefs.UserNameField; dMaps["street"] = PwDefs.NotesField; dMaps["houseno"] = PwDefs.NotesField; dMaps["zip"] = PwDefs.NotesField; dMaps["city"] = PwDefs.NotesField; dMaps["mobile_phone"] = PwDefs.NotesField; dMaps["phone"] = PwDefs.NotesField; dMaps["email"] = strMapEMail; dMaps["birthday"] = "Birthday"; dMaps["tags"] = strMapTags; dMaps["keyword"] = strMapTags; string[] vNames = csv.ReadLine(); if ((vNames == null) || (vNames.Length == 0)) { Debug.Assert(false); return; } for (int i = 0; i < vNames.Length; ++i) { string str = vNames[i]; if (string.IsNullOrEmpty(str)) { Debug.Assert(false); str = strMapIgnore; } else { string strMapped = null; dMaps.TryGetValue(str, out strMapped); if (string.IsNullOrEmpty(strMapped)) { Debug.Assert(false); strMapped = ImportUtil.MapNameToStandardField(str, true); if (string.IsNullOrEmpty(strMapped)) { strMapped = PwDefs.NotesField; } } str = strMapped; } vNames[i] = str; } Dictionary <string, PwGroup> dGroups = new Dictionary <string, PwGroup>(); while (true) { string[] v = csv.ReadLine(); if (v == null) { break; } if (v.Length == 0) { continue; } PwEntry pe = new PwEntry(true, true); PwGroup pg = pwStorage.RootGroup; for (int i = 0; i < v.Length; ++i) { string strValue = v[i]; if (string.IsNullOrEmpty(strValue)) { continue; } strValue = strValue.Replace(@"<COMMA>", ","); strValue = strValue.Replace(@"<-N/L-/>", "\n"); strValue = StrUtil.NormalizeNewLines(strValue, true); string strName = ((i < vNames.Length) ? vNames[i] : PwDefs.NotesField); if (strName == strMapIgnore) { } else if (strName == strMapGroup) { dGroups.TryGetValue(strValue, out pg); if (pg == null) { pg = new PwGroup(true, true); pg.Name = strValue; pwStorage.RootGroup.AddGroup(pg, true); dGroups[strValue] = pg; } } else if (strName == strMapTags) { List <string> lTags = StrUtil.StringToTags(strValue); foreach (string strTag in lTags) { pe.AddTag(strTag); } } else if (strName == strMapLastMod) { double dUnix; if (double.TryParse(strValue, out dUnix)) { pe.LastModificationTime = TimeUtil.ConvertUnixTime(dUnix); } else { Debug.Assert(false); } } else if (strName == strMapEMail) { ImportUtil.AppendToField(pe, PwDefs.UrlField, "mailto:" + strValue, pwStorage); } else { ImportUtil.AppendToField(pe, strName, strValue, pwStorage); } } pg.AddEntry(pe, true); } }
public void StartInitialization() { //TODO send request to get server time _initializationStatus = EnumInitializationStatus.inProgress; SetTimer(TimeUtil.ConvertToTimestamp(DateTime.Now)); }
public void TicksToSecondsSince1970Conversion() { Assert.AreEqual((-1 * TimeUtil.TicksBefore1970 / ticksSecondsFactor), TimeUtil.TicksToSecondsSince1970(0)); Assert.AreEqual(0, TimeUtil.TicksToSecondsSince1970(TimeUtil.TicksBefore1970)); Assert.AreEqual(1324771200, TimeUtil.TicksToSecondsSince1970(new DateTime(2011, 12, 25).Ticks)); }
private void HandleWishEffect(CoupleWishNtfWishEffectData effectData) { if (effectData != null) { int dayFlag = TimeUtil.MakeYearMonthDay(TimeUtil.NowDateTime()); int index = 0; GameClient client; while ((client = GameManager.ClientMgr.GetNextClient(ref index, false)) != null) { if (!client.ClientData.FirstPlayStart) { if (this.CanEffectAwardMap.Contains(client.ClientData.MapCode)) { GameMap gameMap = null; if (GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap)) { if (gameMap.InSafeRegionList(client.CurrentGrid)) { effectData.GetBinJinBi = 0; effectData.GetBindZuanShi = 0; effectData.GetExp = 0; CoupleWishManager.EWishEffectAwardType awardType; int canGetMax; if (!this.GetNextCanEffectAward(client, dayFlag, out awardType, out canGetMax)) { client.sendCmd <CoupleWishNtfWishEffectData>(1393, effectData, false); } else { int calcKey = client.ClientData.ChangeLifeCount * 100 + client.ClientData.Level; int realGet; if (awardType == CoupleWishManager.EWishEffectAwardType.BangJin) { effectData.GetBinJinBi = Math.Max(0, Math.Min(400 * calcKey, canGetMax)); realGet = effectData.GetBinJinBi; } else if (awardType == CoupleWishManager.EWishEffectAwardType.BangZuan) { effectData.GetBindZuanShi = Math.Max(0, Math.Min((int)(0.08 * (double)calcKey), canGetMax)); realGet = effectData.GetBindZuanShi; } else { if (awardType != CoupleWishManager.EWishEffectAwardType.Exp) { continue; } effectData.GetExp = Math.Max(0, Math.Min(4000 * calcKey, canGetMax)); realGet = effectData.GetExp; } if (effectData.GetBinJinBi > 0) { GameManager.ClientMgr.AddMoney1(client, effectData.GetBinJinBi, "情侣祝福特效", true); string tip = string.Format(GLang.GetLang(481, new object[0]), effectData.From.RoleName, realGet); GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, tip); } if (effectData.GetBindZuanShi > 0) { GameManager.ClientMgr.AddUserGold(client, effectData.GetBindZuanShi, "情侣祝福特效"); string tip = string.Format(GLang.GetLang(482, new object[0]), effectData.From.RoleName, realGet); GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, tip); } if (effectData.GetExp > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, (long)effectData.GetExp, false, true, false, "none"); GameManager.ClientMgr.NotifyAddExpMsg(client, (long)effectData.GetExp); string tip = string.Format(GLang.GetLang(483, new object[0]), effectData.From.RoleName, realGet); GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, tip); } client.sendCmd <CoupleWishNtfWishEffectData>(1393, effectData, false); this.SaveGetNextEffectAward(client, dayFlag, awardType, realGet); } } } } } } } }
protected Pair <long, long> InsertMessageInbox(IncomingTextMessage message, long type) { // TODO : https://github.com/WhisperSystems/Signal-Android/blob/e9b53cc164d7ae2d838cc211dbd88b7fd4f5669e/src/org/thoughtcrime/securesms/database/SmsDatabase.java if (message.isPreKeyBundle()) { type |= MessageTypes.KEY_EXCHANGE_BIT | MessageTypes.KEY_EXCHANGE_BUNDLE_BIT; } else if (message.isSecureMessage()) { type |= MessageTypes.SECURE_MESSAGE_BIT; } /*else if (message.isGroup()) TODO: GROUP enable * { * type |= MessageTypes.SECURE_MESSAGE_BIT; * if (((IncomingGroupMessage)message).isUpdate()) type |= MessageTypes.GROUP_UPDATE_BIT; * else if (((IncomingGroupMessage)message).isQuit()) type |= MessageTypes.GROUP_QUIT_BIT; * }*/ else if (message.IsEndSession) { type |= MessageTypes.SECURE_MESSAGE_BIT; type |= MessageTypes.END_SESSION_BIT; } if (message.IsPush) { type |= MessageTypes.PUSH_MESSAGE_BIT; } Recipients recipients; if (message.getSender() != null) { recipients = RecipientFactory.getRecipientsFromString(message.getSender(), true); } else { //Log.w(TAG, "Sender is null, returning unknown recipient"); recipients = new Recipients(Recipient.getUnknownRecipient()); } Recipients groupRecipients; if (message.GroupId == null) { groupRecipients = null; } else { groupRecipients = RecipientFactory.getRecipientsFromString(message.GroupId, true); } bool unread = /*org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider() ||*/ message.isSecureMessage() || message.isPreKeyBundle(); long threadId; if (groupRecipients == null) { threadId = DatabaseFactory.getThreadDatabase().GetThreadIdForRecipients(recipients); // TODO CHECK } else { threadId = DatabaseFactory.getThreadDatabase().GetThreadIdForRecipients(groupRecipients); } /*ContentValues values = new ContentValues(6); * values.put(ADDRESS, message.getSender()); * values.put(ADDRESS_DEVICE_ID, message.getSenderDeviceId()); * values.put(DATE_RECEIVED, System.currentTimeMillis()); * values.put(DATE_SENT, message.getSentTimestampMillis()); * values.put(PROTOCOL, message.getProtocol()); * values.put(READ, unread ? 0 : 1); * * if (!TextUtils.isEmpty(message.getPseudoSubject())) * values.put(SUBJECT, message.getPseudoSubject()); * * values.put(REPLY_PATH_PRESENT, message.isReplyPathPresent()); * values.put(SERVICE_CENTER, message.getServiceCenterAddress()); * values.put(BODY, message.getMessageBody()); * values.put(TYPE, type); * values.put(THREAD_ID, threadId);*/ var insert = new Message() { Address = message.getSender(), AddressDeviceId = message.getSenderDeviceId(), DateReceived = TimeUtil.GetDateTimeMillis(), // force precision to millis not to ticks DateSent = TimeUtil.GetDateTime(message.SentTimestampMillis), Read = !unread, Body = message.getMessageBody(), Type = type, ThreadId = threadId }; long rows = conn.Insert(insert); long messageId = insert.MessageId; if (unread) { DatabaseFactory.getThreadDatabase().SetUnread(threadId); } DatabaseFactory.getThreadDatabase().Refresh(threadId); notifyConversationListeners(threadId); //jobManager.add(new TrimThreadJob(context, threadId)); // TODO return(new Pair <long, long>(messageId, threadId)); }
private int CheckGiveAward(GameClient client) { int result; if (client == null) { result = 0; } else { DateTime now = TimeUtil.NowDateTime(); int awardWeek; if (!this._Config.IsInAwardTime(now, out awardWeek)) { result = 0; } else { lock (this.Mutex) { string szAwardFlag = Global.GetRoleParamByName(client, "29"); string[] fields = string.IsNullOrEmpty(szAwardFlag) ? null : szAwardFlag.Split(new char[] { ',' }); int idx; if (fields != null && fields.Length == 2 && Convert.ToInt32(fields[0]) == awardWeek) { result = 0; } else if (awardWeek != this.SyncData.LastWeek.Week) { result = 0; } else if (!this.SyncData.LastWeek.RoleIndex.TryGetValue(client.ClientData.RoleID, out idx)) { result = 0; } else { CoupleWishCoupleDataK coupleData = this.SyncData.LastWeek.RankList[idx]; if (coupleData == null) { result = 0; } else if (coupleData.Man.RoleId != client.ClientData.RoleID && coupleData.Wife.RoleId != client.ClientData.RoleID) { result = 0; } else { CoupleWishRankAwardConfig wishAward = this._Config.RankAwardCfgList.Find((CoupleWishRankAwardConfig _r) => coupleData.Rank >= _r.StartRank && (_r.EndRank <= 0 || coupleData.Rank <= _r.EndRank)); if (wishAward == null) { result = 0; } else { List <GoodsData> goodsList = new List <GoodsData>(); goodsList.AddRange(wishAward.GoodsOneTag as List <GoodsData>); goodsList.AddRange((wishAward.GoodsTwoTag as List <GoodsData>).FindAll((GoodsData _g) => Global.IsCanGiveRewardByOccupation(client, _g.GoodsID))); if (Global.CanAddGoodsDataList(client, goodsList)) { foreach (GoodsData goodsData in goodsList) { Global.AddGoodsDBCommand_Hook(Global._TCPManager.TcpOutPacketPool, client, goodsData.GoodsID, goodsData.GCount, goodsData.Quality, goodsData.Props, goodsData.Forge_level, goodsData.Binding, 0, goodsData.Jewellist, true, 1, "情侣排行榜", false, goodsData.Endtime, goodsData.AddPropIndex, goodsData.BornIndex, goodsData.Lucky, goodsData.Strong, goodsData.ExcellenceInfo, goodsData.AppendPropLev, goodsData.ChangeLifeLevForEquip, true, null, null, "1900-01-01 12:00:00", 0, true); } } else { Global.UseMailGivePlayerAward3(client.ClientData.RoleID, goodsList, GLang.GetLang(479, new object[0]), string.Format(GLang.GetLang(480, new object[0]), coupleData.Rank), 0, 0, 0); } Global.SaveRoleParamsStringToDB(client, "29", string.Format("{0},{1}", awardWeek, wishAward.Id), true); this.CheckTipsIconState(client); result = wishAward.Id; } } } } } } return(result); }
private void HandleWishOtherRoleCommand(GameClient client, int nID, byte[] bytes, string[] cmdParams) { CoupleWishWishReqData cliReq = DataHelper.BytesToObject <CoupleWishWishReqData>(bytes, 0, bytes.Length); DateTime now = TimeUtil.NowDateTime(); int wishWeek; if (client.ClientSocket.IsKuaFuLogin) { client.sendCmd(nID, -12); } else if (cliReq.CostType != 1 && cliReq.CostType != 2) { client.sendCmd(nID, -18); } else if (!this._Config.IsInWishTime(now, out wishWeek)) { client.sendCmd(nID, -31); } else { CoupleWishTypeConfig wishCfg = this._Config.WishTypeCfgList.Find((CoupleWishTypeConfig _w) => _w.WishType == cliReq.WishType); if (wishCfg == null) { client.sendCmd(nID, -3); } else if (cliReq.CostType == 1 && wishCfg.CostGoodsId > 0 && wishCfg.CostGoodsNum > 0 && Global.GetTotalGoodsCountByID(client, wishCfg.CostGoodsId) < wishCfg.CostGoodsNum) { client.sendCmd(nID, -6, false); } else if (cliReq.CostType == 2 && wishCfg.CostZuanShi > 0 && client.ClientData.UserMoney < wishCfg.CostZuanShi) { client.sendCmd(nID, -10, false); } else { if (!string.IsNullOrEmpty(cliReq.WishTxt)) { if (wishCfg.CanHaveWishTxt != 1) { client.sendCmd(nID, -25, false); return; } if (cliReq.WishTxt.Length > CoupleWishConsts.MaxWishTxtLen) { client.sendCmd(nID, -26, false); return; } } CoupleWishWishRoleReq centerReq = new CoupleWishWishRoleReq(); centerReq.From.RoleId = client.ClientData.RoleID; centerReq.From.ZoneId = client.ClientData.ZoneID; centerReq.From.RoleName = client.ClientData.RoleName; centerReq.WishType = cliReq.WishType; centerReq.WishTxt = cliReq.WishTxt; RoleData4Selector toManSelector = null; RoleData4Selector toWifeSelector = null; CoupleWishCoupleDataK rankCoupleData = null; if (cliReq.IsWishRankRole) { centerReq.IsWishRank = true; lock (this.Mutex) { int coupleIdx; if (!this.SyncData.ThisWeek.CoupleIdex.TryGetValue(cliReq.ToRankCoupleId, out coupleIdx)) { client.sendCmd(nID, -12, false); return; } rankCoupleData = this.SyncData.ThisWeek.RankList[coupleIdx]; if (rankCoupleData == null || rankCoupleData.DbCoupleId != cliReq.ToRankCoupleId || rankCoupleData.Rank > CoupleWishConsts.MaxRankNum * 2) { client.sendCmd(nID, -12, false); return; } centerReq.ToCoupleId = cliReq.ToRankCoupleId; toManSelector = Global.sendToDB <RoleData4Selector, int>(10232, rankCoupleData.Man.RoleId, client.ServerId); toWifeSelector = Global.sendToDB <RoleData4Selector, int>(10232, rankCoupleData.Wife.RoleId, client.ServerId); if (toManSelector == null || toWifeSelector == null || toManSelector.RoleID <= 0 || toWifeSelector.RoleID <= 0) { toWifeSelector = (toManSelector = null); } } } else { int toRoleId = -1; if (!string.IsNullOrEmpty(cliReq.ToLocalRoleName)) { toRoleId = RoleName2IDs.FindRoleIDByName(cliReq.ToLocalRoleName, true); } if (toRoleId <= 0) { client.sendCmd(nID, -28, false); return; } if (toRoleId == client.ClientData.RoleID) { client.sendCmd(nID, -27, false); return; } int nSpouseId = MarryLogic.GetSpouseID(toRoleId); if (nSpouseId <= 0) { client.sendCmd(nID, -29, false); return; } toManSelector = Global.sendToDB <RoleData4Selector, int>(10232, toRoleId, client.ServerId); toWifeSelector = Global.sendToDB <RoleData4Selector, int>(10232, nSpouseId, client.ServerId); if (toManSelector == null || toWifeSelector == null) { client.sendCmd(nID, -15, false); return; } if (!MarryLogic.SameSexMarry(false)) { if (toManSelector.RoleSex == toWifeSelector.RoleSex) { client.sendCmd(nID, -15, false); return; } if (toManSelector.RoleSex == 1) { DataHelper2.Swap <RoleData4Selector>(ref toManSelector, ref toWifeSelector); } } } if (toManSelector != null && toWifeSelector != null) { centerReq.ToMan.RoleId = toManSelector.RoleID; centerReq.ToMan.ZoneId = toManSelector.ZoneId; centerReq.ToMan.RoleName = toManSelector.RoleName; centerReq.ToManSelector = DataHelper.ObjectToBytes <RoleData4Selector>(toManSelector); centerReq.ToWife.RoleId = toWifeSelector.RoleID; centerReq.ToWife.ZoneId = toWifeSelector.ZoneId; centerReq.ToWife.RoleName = toWifeSelector.RoleName; centerReq.ToWifeSelector = DataHelper.ObjectToBytes <RoleData4Selector>(toWifeSelector); } int ec = TianTiClient.getInstance().CoupleWishWishRole(centerReq); if (ec < 0) { client.sendCmd(nID, ec); } else { if (cliReq.CostType == 1 && wishCfg.CostGoodsId > 0 && wishCfg.CostGoodsNum > 0) { bool oneUseBind = false; bool oneUseTimeLimit = false; Global.UseGoodsBindOrNot(client, wishCfg.CostGoodsId, wishCfg.CostGoodsNum, true, out oneUseBind, out oneUseTimeLimit); } if (cliReq.CostType == 2 && wishCfg.CostZuanShi > 0) { GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, wishCfg.CostZuanShi, "情侣祝福", true, true, false, DaiBiSySType.None); } if (wishCfg.IsHaveEffect == 1) { CoupleWishNtfWishEffectData effectData = new CoupleWishNtfWishEffectData(); effectData.From = centerReq.From; effectData.WishType = cliReq.WishType; effectData.WishTxt = cliReq.WishTxt; effectData.To = new List <KuaFuRoleMiniData>(); if (cliReq.IsWishRankRole) { effectData.To.Add(rankCoupleData.Man); effectData.To.Add(rankCoupleData.Wife); } else if (centerReq.ToMan.RoleName == cliReq.ToLocalRoleName) { effectData.To.Add(centerReq.ToMan); } else { effectData.To.Add(centerReq.ToWife); } lock (this.Mutex) { this.HandleWishEffect(effectData); } } client.sendCmd(nID, 1); } } } }
private static Uri GetUri(Session session, Host host) { UriBuilder builder = new UriBuilder(); builder.Scheme = host.Connection.UriScheme; builder.Host = host.address; builder.Port = host.Connection.Port; builder.Path = RrdUpdatesPath; builder.Query = string.Format(RrdHostAndVmUpdatesQuery, Uri.EscapeDataString(session.uuid), TimeUtil.TicksToSecondsSince1970(DateTime.UtcNow.Ticks - (host.Connection.ServerTimeOffset.Ticks + TicksInTenSeconds)), RrdCFAverage, 5); return(builder.Uri); }
/// <summary> /// Updates the time measurement. /// </summary> protected void UpdateTime() { if (measureTime) { float endTime = Time.realtimeSinceStartup; playTime = TimeUtil.SecondsToTime(endTime - startTime); //playTime.ScaleBy(Time.timeScale); } }
public DateTime GetLocalTime() { return(TimeUtil.UnixTimeStampToLocalDateTime(_serverTimer + SyncTime)); }
/// <summary> /// 인형일괄제조 시작 /// ("Gun/developMultiGun") /// </summary> /// <param name="request_string"></param> /// <param name="response_string"></param> public static void StartMultiProduce(string request_string, string response_string) { #region Packet Example // request Gun/developMultiGun?uid={0}&outdatacode={1}&req_id={2} /* * { * "mp": 130, * "ammo": 130, * "mre": 130, * "part": 30, * "input_level": 0, * "build_quick": 0, * "build_multi": 2, * "build_heavy": 0 * } */ // response Gun/developMultiGun (단일 제조) /* * { * "gun_ids": [ * { * "id": "93", * "slot": 3 * }, * { * "id": "5", * "slot": 5 * } * ] * } */ // response Gun/developMultiGun (복수 제조) /* * [ * { * "gun_with_user_add": { * "gun_with_user_id": "383509177", * "gun_id": "9" * } * }, * { * "gun_with_user_add": { * "gun_with_user_id": "383509178", * "gun_id": "90" * } * }, * { * "gun_with_user_add": { * "gun_with_user_id": "383509179", * "gun_id": "2" * } * } * ] */ #endregion try { log.Debug("인형일괄제조 시작"); JObject request = Parser.Json.ParseJObject(request_string); if (request != null) { int mp = Parser.Json.ParseInt(request["mp"]); int ammo = Parser.Json.ParseInt(request["ammo"]); int mre = Parser.Json.ParseInt(request["mre"]); int part = Parser.Json.ParseInt(request["part"]); int inputLevel = Parser.Json.ParseInt(request["input_level"]); int buildQuick = Parser.Json.ParseInt(request["build_quick"]); // 0: 일반, 1: 소투입, 2: 중투입, 3: 고투입 log.Debug("투입자원 {0}/{1}/{2}/{3}", mp, ammo, mre, part); log.Debug("투입레벨 {0} (0: 일반, 1: 소투입, 2: 중투입, 3: 고투입)", inputLevel); // 복수 제조 if (buildQuick == 1) { JArray response = Parser.Json.ParseJArray(response_string); foreach (var item in response) { JObject gun_with_user_add = item["gun_with_user_add"].Value <JObject>(); long gunWithUserId = Parser.Json.ParseLong(gun_with_user_add["gun_with_user_id"]); int gunId = Parser.Json.ParseInt(gun_with_user_add["gun_id"]); UserData.Doll.Add(new DollWithUserInfo(gunWithUserId, gunId)); // 일반제조 if (inputLevel == 0) { // 임무 갱신 UserData.Quest.Daily.produceDoll += 1; UserData.Quest.Weekly.produceDoll += 1; } // 중형제조 else if (inputLevel > 0) { // 임무 갱신 UserData.Quest.Weekly.produceHeavyDoll += 1; } } } // 단수 제조 else { JObject response = Parser.Json.ParseJObject(response_string); if (response.ContainsKey("gun_ids") && response["gun_ids"] is JArray) { JArray items = response["gun_ids"].Value <JArray>(); foreach (var item in items) { int buildSlot = Parser.Json.ParseInt(item["slot"]); if (buildSlot > 0) { UserData.mp -= mp; UserData.ammo -= ammo; UserData.mre -= mre; UserData.part -= part; int gunId = Parser.Json.ParseInt(item["id"]); int startTime = TimeUtil.GetCurrentSec(); //log.Debug("제조슬롯 {0} | 인형 {1} | 제조시작 {2}", buildSlot, gunId, Parser.Time.GetDateTime(startTime).ToString("MM-dd HH:mm:ss")); JObject doll = GameData.Doll.GetDollData(gunId); string gunName = ""; string gunType = ""; int gunStar = 0; if (doll != null) { gunName = Parser.Json.ParseString(doll["name"]); gunType = Parser.Json.ParseString(doll["type"]); gunStar = Parser.Json.ParseInt(doll["star"]); log.Debug("병과 {0} | 레어도 {1} 성", gunType, gunStar); } // 알림 탭 추가 dashboardView.Add(new ProduceDollTemplate() { slot = buildSlot, gunId = gunId, startTime = startTime, inputLevel = inputLevel, spendResource = new int[] { mp, ammo, mre, part }, }); if ((Config.Alarm.notifyProduceDoll5Star && gunStar >= 5) || // 5성 인형제조 알림 (Config.Alarm.notifyProduceShotgun && gunType == "SG") || // 샷건 인형제조 알림 (Config.Alarm.notifyProduceDoll)) // 인형제조 알림 { Notifier.Manager.notifyQueue.Enqueue(new Message() { send = MessageSend.All, subject = LanguageResources.Instance["MESSAGE_PRODUCE_DOLL_SUBJECT"], content = string.Format(LanguageResources.Instance["MESSAGE_PRODUCE_DOLL_CONTENT"], gunStar, gunName, gunType), }); } // 일반제조 if (inputLevel == 0) { // 임무 갱신 UserData.Quest.Daily.produceDoll += 1; UserData.Quest.Weekly.produceDoll += 1; } // 중형제조 else if (inputLevel > 0) { // 임무 갱신 UserData.Quest.Weekly.produceHeavyDoll += 1; } } } } } } //if (request != null && response != null && response.ContainsKey("gun_ids") && response["gun_ids"] is JArray) //{ // int mp = Parser.Json.ParseInt(request["mp"]); // int ammo = Parser.Json.ParseInt(request["ammo"]); // int mre = Parser.Json.ParseInt(request["mre"]); // int part = Parser.Json.ParseInt(request["part"]); // int inputLevel = Parser.Json.ParseInt(request["input_level"]); // // 0: 일반, 1: 소투입, 2: 중투입, 3: 고투입 // log.Debug("투입자원 {0}/{1}/{2}/{3}", mp, ammo, mre, part); // log.Debug("투입레벨 {0} (0: 일반, 1: 소투입, 2: 중투입, 3: 고투입)", inputLevel); //} } catch (Exception ex) { log.Error(ex, "failed to get Gun/developMultiGun"); } }
public DateTime GetUtcTime() { return(TimeUtil.UnixTimeStampToUTCDateTime(_serverTimer + SyncTime)); }
public void ISODateTimeParseWithBadFormat() { TimeUtil.ParseISO8601DateTime("20111225T1020:37Z"); }
private IAllyService GetKuaFuService(bool noWait = false) { try { if (KuaFuManager.KuaFuWorldKuaFuGameServer) { return(null); } lock (this._Mutex) { if (string.IsNullOrEmpty(this._RemoteServiceUri)) { return(null); } if (this._KuaFuService == null && noWait) { return(null); } } lock (this._Mutex) { IAllyService kuaFuService; if (this._KuaFuService == null) { kuaFuService = (IAllyService)Activator.GetObject(typeof(IAllyService), this._RemoteServiceUri); if (null == kuaFuService) { return(null); } } else { kuaFuService = this._KuaFuService; } int clientId = this._ClientInfo.ClientId; long nowTicks = TimeUtil.NOW(); if (this._ClientInfo.ClientId <= 0 || Math.Abs(nowTicks - this._ClientInfo.LastInitClientTicks) > 12000L) { this._ClientInfo.LastInitClientTicks = nowTicks; clientId = kuaFuService.InitializeClient(this._ClientInfo); } if (kuaFuService != null && (clientId != this._ClientInfo.ClientId || this._KuaFuService != kuaFuService)) { lock (this._Mutex) { if (clientId > 0) { this._KuaFuService = kuaFuService; } else { this._KuaFuService = null; } this._ClientInfo.ClientId = clientId; return(kuaFuService); } } return(this._KuaFuService); } } catch (Exception ex) { this.ResetKuaFuService(); LogManager.WriteExceptionUseCache(ex.ToString()); } return(null); }
public void ToISODateTime() { string derived = TimeUtil.ToISO8601DateTime(new DateTime(2011, 12, 25, 10, 20, 37)); Assert.AreEqual("20111225T10:20:37Z", derived); }
static int Main(string[] args) { if (args.Length < 1) { Console.WriteLine("usage reply_async.exe mw-id=<middleware ID>"); return(-1); } //o Load the command-line input into a GMSEC Config object // A Config object is basically a key-value pair map which is used to // pass configuration options into objects such as Connections, // ConnectionManagers, Subscribe and Publish function calls, Messages, // etc. Config config = new Config(args); //o Since this example program uses an invalid message, we ensure the // validation check is disabled. config.AddValue("gmsec-msg-content-validate-all", "false"); // If it was not specified in the command-line arguments, set LOGLEVEL // to 'INFO' and LOGFILE to 'stdout' to allow the program report output // on the terminal/command line InitializeLogging(config); //o Output GMSEC API version Log.Info("API version: " + ConnectionManager.GetAPIVersion()); try { //o Create the Connection ConnectionManager connMgr = new ConnectionManager(config); //o Connect connMgr.Initialize(); //o Output middleware client library version Log.Info("Middleware version: " + connMgr.GetLibraryVersion()); //o Subscribe ExampleCallback cb = new ExampleCallback(); connMgr.Subscribe(DEFAULT_REQUEST_SUBJECT, cb); //o Start the AutoDispatcher to begin async message receipt connMgr.StartAutoDispatch(); //o Loop while waiting for the asynchronous response until done while (cb.ReplySent == false) { TimeUtil.Millisleep(100); } //o Wait for a few moments to ensure that the asynchronous reply // transaction went through with the middleware before closing // the connection and exiting the process for (int i = 0; i < 5; i++) { TimeUtil.Millisleep(100); } //o Clean up connMgr.StopAutoDispatch(); connMgr.Cleanup(); } catch (Exception e) { Log.Error(e.ToString()); return(-1); } return(0); }
public void UpdateMarriageGoodWill(GameClient client, int addGoodwillValue) { if (MarryLogic.IsVersionSystemOpenOfMarriage()) { if (client.ClientData.MyMarriageData.byMarrytype != -1) { if (addGoodwillValue != 0) { sbyte tmpGoodwilllv = client.ClientData.MyMarriageData.byGoodwilllevel; sbyte tmpGoodwillstar = client.ClientData.MyMarriageData.byGoodwillstar; if (tmpGoodwilllv != this.byMaxGoodwillLv || tmpGoodwillstar != this.byMaxGoodwillStar) { int oldLevel = (int)client.ClientData.MyMarriageData.byGoodwilllevel; int oldStart = (int)client.ClientData.MyMarriageData.byGoodwillstar; client.ClientData.MyMarriageData.nGoodwillexp += addGoodwillValue; int nNowLvAddExp = this.GoodwillAllExpList[(int)((tmpGoodwilllv - 1) * this.byMaxGoodwillStar + tmpGoodwillstar)]; client.ClientData.MyMarriageData.nGoodwillexp += nNowLvAddExp; bool bUpdateLv = false; bool bUpdateStar = false; for (int i = 1; i < this.GoodwillAllExpList.Count; i++) { if (i == this.GoodwillAllExpList.Count - 1 && client.ClientData.MyMarriageData.nGoodwillexp >= this.GoodwillAllExpList[i]) { client.ClientData.MyMarriageData.byGoodwilllevel = this.byMaxGoodwillLv; client.ClientData.MyMarriageData.byGoodwillstar = this.byMaxGoodwillStar; bUpdateStar = true; client.ClientData.MyMarriageData.nGoodwillexp = this.GoodwillAllExpList[i] - this.GoodwillAllExpList[i - 1]; } else if (client.ClientData.MyMarriageData.nGoodwillexp < this.GoodwillAllExpList[i]) { int nLv; int nStar; if (i <= (int)(this.byMaxGoodwillStar + 1)) { nLv = 1; nStar = i - 1; } else { nLv = (i - 2) / (int)this.byMaxGoodwillStar + 1; nStar = (i - 1) % (int)this.byMaxGoodwillStar; if (nStar == 0) { nStar = 10; } } if (nLv != (int)tmpGoodwilllv) { bUpdateLv = true; } if (nStar != (int)tmpGoodwillstar) { bUpdateStar = true; } client.ClientData.MyMarriageData.byGoodwilllevel = (sbyte)nLv; client.ClientData.MyMarriageData.byGoodwillstar = (sbyte)nStar; client.ClientData.MyMarriageData.nGoodwillexp -= this.GoodwillAllExpList[i - 1]; break; } } if (bUpdateLv || bUpdateStar) { client.ClientData.MyMarriageData.ChangTime = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss"); } MarryFuBenMgr.UpdateMarriageData2DB(client); if (bUpdateLv || bUpdateStar) { this.UpdateRingAttr(client, true, false); } this.SendMarriageDataToClient(client, bUpdateLv || bUpdateStar); if (bUpdateLv) { if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) || client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client)) { client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } if (addGoodwillValue > 0) { string strHint = StringUtil.substitute(GLang.GetLang(490, new object[0]), new object[] { addGoodwillValue }); GameManager.ClientMgr.NotifyImportantMsg(client, strHint, GameInfoTypeIndexes.Normal, ShowGameInfoTypes.PiaoFuZi, 0); } EventLogManager.AddRingStarSuitEvent(client, client.ClientData.MyMarriageData.nRingID, oldLevel, (int)client.ClientData.MyMarriageData.byGoodwilllevel, oldStart, (int)client.ClientData.MyMarriageData.byGoodwillstar, ""); } } } } }
public string ExecuteSuperInput(GameClient client) { DateTime now = TimeUtil.NowDateTime(); string cmdData = ""; int fullPur = 0; int fullPurReserve = 0; int hasGetTimes = 0; int result = 0; lock (JieriSuperInputActivity._SuperInputMutex) { if (!this.InActivityTime() || this.PlatformOpenStateVavle == 0) { result = -400; } else { JieriSuperInputData superInputData = this.GetJieriSuperInputDataByNowDateTime(now, false); if (superInputData == null || now < superInputData.BeginTime) { result = -400; } else { List <int> countList = this.GetFullPurchaseList(now); fullPur = countList[2]; fullPurReserve = countList[3]; if (fullPurReserve >= fullPur) { result = -16; } else { string beginStr = superInputData.BeginTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$'); string endStr = superInputData.EndTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$'); string keyHasStr = string.Format("has_{0}_{1}_{2}", beginStr, endStr, superInputData.ID); if (superInputData.PurchaseNum > 0) { string strcmd = string.Format("{0}:{1}:{2}:{3}", new object[] { client.ClientData.RoleID, keyHasStr, this.ActivityType, "0" }); string[] dbResult = Global.ExecuteDBCmd(10221, strcmd, 0); if (dbResult == null || dbResult.Length == 0) { return(cmdData); } hasGetTimes = Global.SafeConvertToInt32(dbResult[3]); } if (superInputData.PurchaseNum > 0 && hasGetTimes >= superInputData.PurchaseNum) { result = -16; } else { string keyResStr = string.Format("res_{0}_{1}_{2}", beginStr, endStr, superInputData.ID); string[] dbResult = Global.QeuryUserActivityInfo(client, keyResStr, this.ActivityType, "0"); if (dbResult == null || dbResult.Length == 0) { return(cmdData); } int reverseTimes = Global.SafeConvertToInt32(dbResult[3]); fullPurReserve++; List <int> list; (list = countList)[3] = list[3] + 1; this.SaveFullPurchaseList(countList); Global.UpdateUserActivityInfo(client, keyHasStr, 71, (long)(++hasGetTimes), now.ToString("yyyy-MM-dd HH$mm$ss")); Global.UpdateUserActivityInfo(client, keyResStr, 71, (long)(reverseTimes + 1), now.ToString("yyyy-MM-dd HH$mm$ss")); } } } } } return(string.Format("{0},{1},{2},{3}", new object[] { result, hasGetTimes, fullPur, fullPurReserve })); }
private static byte[] GetSystemData(Random rWeak) { MemoryStream ms = new MemoryStream(); byte[] pb; pb = MemUtil.UInt32ToBytes((uint)Environment.TickCount); ms.Write(pb, 0, pb.Length); pb = TimeUtil.PackTime(DateTime.Now); ms.Write(pb, 0, pb.Length); #if (!KeePassLibSD && !KeePassRT) // In try-catch for systems without GUI; // https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/ try { Point pt = Cursor.Position; pb = MemUtil.UInt32ToBytes((uint)pt.X); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)pt.Y); ms.Write(pb, 0, pb.Length); } catch (Exception) { } #endif pb = MemUtil.UInt32ToBytes((uint)rWeak.Next()); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)NativeLib.GetPlatformID()); ms.Write(pb, 0, pb.Length); #if (!KeePassLibSD && !KeePassRT) Process p = null; try { pb = MemUtil.UInt32ToBytes((uint)Environment.ProcessorCount); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)Environment.WorkingSet); ms.Write(pb, 0, pb.Length); Version v = Environment.OSVersion.Version; pb = MemUtil.UInt32ToBytes((uint)v.GetHashCode()); ms.Write(pb, 0, pb.Length); p = Process.GetCurrentProcess(); pb = MemUtil.UInt64ToBytes((ulong)p.Handle.ToInt64()); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)p.HandleCount); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)p.Id); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.NonpagedSystemMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PagedMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PagedSystemMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PeakPagedMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PeakVirtualMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PeakWorkingSet64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PrivateMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.StartTime.ToBinary()); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.VirtualMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.WorkingSet64); ms.Write(pb, 0, pb.Length); // Not supported in Mono 1.2.6: // pb = MemUtil.UInt32ToBytes((uint)p.SessionId); // ms.Write(pb, 0, pb.Length); } catch (Exception) { } finally { try { if (p != null) { p.Dispose(); } } catch (Exception) { Debug.Assert(false); } } #endif pb = Guid.NewGuid().ToByteArray(); ms.Write(pb, 0, pb.Length); byte[] pbAll = ms.ToArray(); ms.Close(); return(pbAll); }
public string BuildSuperInputFanLiActInfoForClient(GameClient client) { string cmdData = ""; string result2; if (!this.InActivityTime() || this.PlatformOpenStateVavle == 0) { cmdData = string.Format("{0},{1},{2}", 0, 0, 0); result2 = cmdData; } else { DateTime now = TimeUtil.NowDateTime(); JieriSuperInputData superInputData = this.GetJieriSuperInputDataByNowDateTime(now, false); if (null == superInputData) { cmdData = string.Format("{0},{1},{2}", 0, 0, 0); result2 = cmdData; } else if (now < superInputData.BeginTime) { cmdData = string.Format("{0},{1},{2}", 0, superInputData.FullPurchaseNum, 0); result2 = cmdData; } else { List <int> countList = this.GetFullPurchaseList(now); int fullPur = countList[2]; int fullPurReserve = countList[3]; int hasGetTimes = 0; string beginStr = superInputData.BeginTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$'); string endStr = superInputData.EndTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$'); string keyStr = string.Format("has_{0}_{1}_{2}", beginStr, endStr, superInputData.ID); if (superInputData.PurchaseNum > 0) { string strcmd = string.Format("{0}:{1}:{2}:{3}", new object[] { client.ClientData.RoleID, keyStr, this.ActivityType, "0" }); string[] result = Global.ExecuteDBCmd(10221, strcmd, 0); if (result == null || result.Length == 0) { return(cmdData); } hasGetTimes = Global.SafeConvertToInt32(result[3]); } if (countList[3] >= countList[2]) { JieriSuperInputData nextSuperInputData = this.GetJieriSuperInputDataByNowDateTime(now, true); if (null != nextSuperInputData) { return(string.Format("{0},{1},{2}", 0, nextSuperInputData.FullPurchaseNum, nextSuperInputData.FullPurchaseNum)); } } cmdData = string.Format("{0},{1},{2}", hasGetTimes, fullPur, fullPurReserve); result2 = cmdData; } } return(result2); }
private static void CreateFromDirectory(string strDirPath) { string strPlgx = strDirPath + "." + PlgxExtension; PlgxPluginInfo plgx = new PlgxPluginInfo(false, true, true); PlgxCsprojLoader.LoadDefault(strDirPath, plgx); FileStream fs = new FileStream(strPlgx, FileMode.Create, FileAccess.Write, FileShare.None); BinaryWriter bw = new BinaryWriter(fs); bw.Write(PlgxSignature1); bw.Write(PlgxSignature2); bw.Write(PlgxVersion); WriteObject(bw, PlgxFileUuid, (new PwUuid(true)).UuidBytes); WriteObject(bw, PlgxBaseFileName, StrUtil.Utf8.GetBytes( plgx.BaseFileName)); WriteObject(bw, PlgxCreationTime, StrUtil.Utf8.GetBytes( TimeUtil.SerializeUtc(DateTime.UtcNow))); WriteObject(bw, PlgxGeneratorName, StrUtil.Utf8.GetBytes( PwDefs.ShortProductName)); WriteObject(bw, PlgxGeneratorVersion, MemUtil.UInt64ToBytes( PwDefs.FileVersion64)); string strKP = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqKP]; if (!string.IsNullOrEmpty(strKP)) { ulong uKP = StrUtil.ParseVersion(strKP); if (uKP != 0) { WriteObject(bw, PlgxPrereqKP, MemUtil.UInt64ToBytes(uKP)); } } string strNet = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqNet]; if (!string.IsNullOrEmpty(strNet)) { ulong uNet = StrUtil.ParseVersion(strNet); if (uNet != 0) { WriteObject(bw, PlgxPrereqNet, MemUtil.UInt64ToBytes(uNet)); } } string strOS = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqOS]; if (!string.IsNullOrEmpty(strOS)) { WriteObject(bw, PlgxPrereqOS, StrUtil.Utf8.GetBytes(strOS)); } string strPtr = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxPrereqPtr]; if (!string.IsNullOrEmpty(strPtr)) { uint uPtr; if (uint.TryParse(strPtr, out uPtr)) { WriteObject(bw, PlgxPrereqPtr, MemUtil.UInt32ToBytes(uPtr)); } } string strBuildPre = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxBuildPre]; if (!string.IsNullOrEmpty(strBuildPre)) { WriteObject(bw, PlgxBuildPre, StrUtil.Utf8.GetBytes(strBuildPre)); } string strBuildPost = Program.CommandLineArgs[AppDefs.CommandLineOptions.PlgxBuildPost]; if (!string.IsNullOrEmpty(strBuildPost)) { WriteObject(bw, PlgxBuildPost, StrUtil.Utf8.GetBytes(strBuildPost)); } WriteObject(bw, PlgxBeginContent, null); RecursiveFileAdd(bw, strDirPath, new DirectoryInfo(strDirPath)); WriteObject(bw, PlgxEndContent, null); WriteObject(bw, PlgxEOF, null); bw.Close(); fs.Close(); // Test loading not possible, because MainForm not available // PlgxPlugin.Load(strPlgx); }
private void WriteObject(string name, DateTime value) { Debug.Assert(name != null); WriteObject(name, TimeUtil.SerializeUtc(value), false); }
public void InitAllCalendars() { calendarList = new List <CalendarTest>(); int selectedDateTimeInt = XPlayerPrefs.GetInt(ChallengeController.selectedDateTimeStr); Debug.Log("selectedDay:" + selectedDateTimeInt); if (selectedDateTimeInt != 0) { currentCalendarDateTime = TimeUtil.getDateTimeByInt(selectedDateTimeInt); } else { currentCalendarDateTime = DateTime.Today; X.Res.SignInConfig todaySignInConfig = SignInMgr.GetInstance().GetConfigByID((uint)TimeUtil.getIntByDateTime(currentCalendarDateTime)); if (todaySignInConfig != null && LevelMgr.GetInstance().GetLevelConfig(todaySignInConfig.LevelId).Config != null) { XPlayerPrefs.SetInt(ChallengeController.selectedDateTimeStr, TimeUtil.getIntByDateTime(currentCalendarDateTime)); } else { XPlayerPrefs.SetInt(ChallengeController.selectedDateTimeStr, (int)SignInMgr.GetInstance().MaxValidDay); } } selectedDateTimeInt = XPlayerPrefs.GetInt(ChallengeController.selectedDateTimeStr); Debug.Log("selectedDay:" + selectedDateTimeInt); int calendarCount = transform.childCount; int centerCalendar = calendarCount / 2; int offsetMonth = 0; for (int i = centerCalendar; i >= 0; i--) { Transform calendarTrans = transform.GetChild(i); CalendarTest calendar = calendarTrans.GetComponent <CalendarTest>(); calendarList.Add(calendar); DateTime calendarDateTime = currentCalendarDateTime.AddMonths(offsetMonth); calendar.InitCalendar(calendarDateTime.Month, calendarDateTime.Year); offsetMonth--; } offsetMonth = 1; for (int i = centerCalendar + 1; i < calendarCount; i++) { Transform calendarTrans = transform.GetChild(i); CalendarTest calendar = calendarTrans.GetComponent <CalendarTest>(); calendarList.Add(calendar); DateTime calendarDateTime = currentCalendarDateTime.AddMonths(offsetMonth); calendar.InitCalendar(calendarDateTime.Month, calendarDateTime.Year); offsetMonth++; } currentCalendarDateTime = new DateTime(currentCalendarDateTime.Year, currentCalendarDateTime.Month, 1); Debug.Log(currentCalendarDateTime.Year + " " + currentCalendarDateTime.Month + " " + currentCalendarDateTime.Day); }
/// <summary> /// Sends all requests which the (android-)client sends on startup /// </summary> internal bool Startup() { try { // Send GetPlayer to check if we're connected and authenticated GetPlayerResponse playerResponse; do { var response = SendRemoteProcedureCall(new Request { RequestType = RequestType.GetPlayer }); playerResponse = GetPlayerResponse.Parser.ParseFrom(response); if (!playerResponse.Success) { Thread.Sleep(1000); } } while (!playerResponse.Success); _session.Player.Data = playerResponse.PlayerData; // Get DownloadRemoteConfig var remoteConfigResponse = SendRemoteProcedureCall(new Request { RequestType = RequestType.DownloadRemoteConfigVersion, RequestMessage = new DownloadRemoteConfigVersionMessage { Platform = Platform.Android, AppVersion = 2903 }.ToByteString() }); var remoteConfigParsed = DownloadRemoteConfigVersionResponse.Parser.ParseFrom(remoteConfigResponse); var timestamp = (ulong)TimeUtil.GetCurrentTimestampInMilliseconds(); if (_session.Templates.AssetDigests == null || remoteConfigParsed.AssetDigestTimestampMs > timestamp) { // GetAssetDigest var assetDigestResponse = SendRemoteProcedureCall(new Request { RequestType = RequestType.GetAssetDigest, RequestMessage = new GetAssetDigestMessage { Platform = Platform.Android, AppVersion = 2903 }.ToByteString() }); _session.Templates.SetAssetDigests(GetAssetDigestResponse.Parser.ParseFrom(assetDigestResponse)); } if (_session.Templates.ItemTemplates == null || remoteConfigParsed.ItemTemplatesTimestampMs > timestamp) { // DownloadItemTemplates var itemTemplateResponse = SendRemoteProcedureCall(new Request { RequestType = RequestType.DownloadItemTemplates }); _session.Templates.SetItemTemplates( DownloadItemTemplatesResponse.Parser.ParseFrom(itemTemplateResponse)); } } catch (Exception) { return(false); } return(true); }
/// <summary> /// Initializes the time measurement. /// </summary> protected void InitializeTimeMeasurement() { playTime = new TimeUtil(); startTime = Time.realtimeSinceStartup; measureTime = true; }
public void TicksToSecondsConversion() { Assert.AreEqual(73, TimeUtil.TicksToSeconds(73 * ticksSecondsFactor)); Assert.AreEqual(0, TimeUtil.TicksToSeconds(0)); }
/// <summary> /// Writes into the xml file. /// </summary> /// <param name="time"></param> /// <param name="enemy"></param> /// <param name="player"></param> public void WriteData(TimeUtil time, NPCBreadcrumb enemy, GameObject player) { if (File.Exists(filePath)) { XmlDocument document = new XmlDocument(); document.Load(filePath); XmlElement root = document.DocumentElement; XmlElement entry = document.CreateElement("entry"); root.AppendChild(entry); XmlElement timeNode = document.CreateElement("time"); entry.AppendChild(timeNode); XmlElement hour = document.CreateElement("minute"); hour.InnerText = time.Minute.ToString(); timeNode.AppendChild(hour); XmlElement minute = document.CreateElement("second"); minute.InnerText = time.Second.ToString(); timeNode.AppendChild(minute); XmlElement second = document.CreateElement("millicseconds"); second.InnerText = time.Milliseconds.ToString(); timeNode.AppendChild(second); XmlElement breadcrumb = document.CreateElement("breadcrumb"); breadcrumb.InnerText = enemy.Breadcrumb.ToString(); entry.AppendChild(breadcrumb); XmlElement enemyNode = document.CreateElement("enemy"); entry.AppendChild(enemyNode); XmlElement enemyName = document.CreateElement("name"); enemyName.InnerText = enemy.name; enemyNode.AppendChild(enemyName); XmlElement enemyPos = document.CreateElement("position"); enemyNode.AppendChild(enemyPos); XmlElement enemyX = document.CreateElement("x"); enemyX.InnerText = enemy.transform.position.x.ToString(); enemyPos.AppendChild(enemyX); XmlElement enemyY = document.CreateElement("y"); enemyY.InnerText = enemy.transform.position.y.ToString(); enemyPos.AppendChild(enemyY); XmlElement enemyZ = document.CreateElement("z"); enemyZ.InnerText = enemy.transform.position.z.ToString(); enemyPos.AppendChild(enemyZ); XmlElement playerNode = document.CreateElement("player"); entry.AppendChild(playerNode); XmlElement playerName = document.CreateElement("name"); playerName.InnerText = player.name; playerNode.AppendChild(playerName); XmlElement playerPos = document.CreateElement("position"); playerNode.AppendChild(playerPos); XmlElement playerX = document.CreateElement("x"); playerX.InnerText = player.transform.position.x.ToString(); playerPos.AppendChild(playerX); XmlElement playerY = document.CreateElement("y"); playerY.InnerText = player.transform.position.y.ToString(); playerPos.AppendChild(playerY); XmlElement playerZ = document.CreateElement("z"); playerZ.InnerText = player.transform.position.z.ToString(); playerPos.AppendChild(playerZ); document.Save(filePath); } else Debug.LogError(filePath + " does not exist!"); }
/// <summary> /// 인형수복 시작 /// ("Gun/fixGuns") /// </summary> /// <param name="request_string"></param> /// <param name="response_string"></param> public static void StartRestore(string request_string, string response_string) { #region Packet Example // request Gun/fixGuns?uid={0}&outdatacode={1}&req_id={2} /* * { * "if_quick": 0, * "fix_guns": { * "6762038": 3, * "12131545": 2 * } * } */ #endregion try { log.Debug("인형수복 시작"); JObject request = Parser.Json.ParseJObject(request_string); if (request != null) { int if_quick = Parser.Json.ParseInt(request["if_quick"]); if (request["fix_guns"] != null && request["fix_guns"] is JObject) { Dictionary <string, string> fixGuns = Parser.Json.ParseItems(request["fix_guns"].Value <JObject>()); foreach (KeyValuePair <string, string> fixGun in fixGuns) { long gunWithUserId = Parser.String.ParseLong(fixGun.Key); int fixSlot = Parser.String.ParseInt(fixGun.Value); if (fixSlot > 0) { int startTime = TimeUtil.GetCurrentSec(); int[] restore = GameData.Doll.Restore.GetRestore(gunWithUserId); //UserData.Doll.GetRestoreRequireTime(gun_with_user_id, ref require_time, ref require_mp, ref require_part); int endTime = startTime + restore[0]; log.Debug("수복인형 {0} ({1})", UserData.Doll.GetName(gunWithUserId), gunWithUserId); log.Debug("필요시간 {0}", restore[0]); log.Debug("필요인력 {0}, 부품 {1}", restore[1], restore[2]); UserData.mp -= restore[1]; UserData.part -= restore[2]; if (if_quick == 1) // 쾌속수복 { UserData.Doll.Fix(gunWithUserId); } else { // 알림 탭 추가 dashboardView.Add(new RestoreDollTemplate() { slot = fixSlot, gunWithUserId = gunWithUserId, endTime = endTime, }); } // 임무 갱신 UserData.Quest.Daily.fixGun += 1; UserData.Quest.Weekly.fixGun += 1; } } } } } catch (Exception ex) { log.Error(ex, "failed to get Gun/fixGuns"); } }