//マイリスト一覧を取得 public async Task <List <NicoNicoMylistGroupEntry> > GetMylistGroupAsync() { try { var a = await App.ViewModelRoot.CurrentUser.Session.GetAsync(MylistGroupApi); dynamic json = DynamicJson.Parse(a); var ret = new List <NicoNicoMylistGroupEntry>(); foreach (var entry in json.mylistgroup) { var data = new NicoNicoMylistGroupEntry(); data.CreateTime = UnixTime.FromUnixTime((long)entry.create_time).ToString(); data.Description = data.DescriptionOriginal = HttpUtility.HtmlDecode(entry.description); data.Id = entry.id; data.Name = data.NameOriginal = HttpUtility.HtmlDecode(entry.name); data.IsPublic = entry.@public != "0"; data.SortOrder = int.Parse(entry.sort_order); ret.Add(data); } return(ret); } catch (RequestFailed) { Owner.Status = "マイリストグループの取得に失敗しました"; return(null); } }
private void Update() { if (_stateMachine.stamina != null) { if (_stateMachine.stamina.NextRecoverAt == 0) { nextRecoverCountDown.text = "--:--"; } else { var timeSpan = UnixTime.FromUnixTime(_stateMachine.stamina.NextRecoverAt) - DateTime.UtcNow; if (timeSpan.Ticks < 0) { if (_stateMachine.stamina.Value >= _stateMachine.stamina.MaxValue) { _stateMachine.stamina.Value = _stateMachine.stamina.MaxValue; _stateMachine.stamina.NextRecoverAt = 0; } else { _stateMachine.stamina.Value += _stateMachine.stamina.RecoverValue; _stateMachine.stamina.NextRecoverAt += _stateMachine.stamina.RecoverIntervalMinutes * 60 * 1000; timeSpan = UnixTime.FromUnixTime(_stateMachine.stamina.NextRecoverAt) - DateTime.UtcNow; } _stateMachine.controller.gs2StaminaSetting.onGetStamina.Invoke(_stateMachine.stamina); } nextRecoverCountDown.text = $"{timeSpan.Minutes:00}:{timeSpan.Seconds:00}"; } } }
//自分のマイリストを取得 public List <NicoNicoMylistGroupData> GetMylistGroup() { List <NicoNicoMylistGroupData> ret = new List <NicoNicoMylistGroupData>(); try { //マイリスト取得 var json = DynamicJson.Parse(NicoNicoWrapperMain.Session.GetAsync(MylistGroupAPI).Result); foreach (var entry in json.mylistgroup) { NicoNicoMylistGroupData data = new NicoNicoMylistGroupData(); data.CreateTime = UnixTime.FromUnixTime((long)entry.create_time).ToString(); data.Description = HttpUtility.HtmlDecode(entry.description); data.Id = entry.id; data.Name = HttpUtility.HtmlDecode(entry.name); data.IsPublic = entry.@public == "0" ? false : true; data.SortOrder = int.Parse(entry.sort_order); ret.Add(data); } return(ret); } catch (RequestTimeout) { return(null); } }
/// <summary> /// Connect to the given IP address using the port specified as part of the network parameters. Once construction /// is complete a functioning network channel is set up and running. /// </summary> /// <param name="peerAddress">IP address to connect to. IPv6 is not currently supported by BitCoin. If port is not positive the default port from params is used.</param> /// <param name="params">Defines which network to connect to and details of the protocol.</param> /// <param name="bestHeight">How many blocks are in our best chain</param> /// <param name="connectTimeout">Timeout in milliseconds when initially connecting to peer</param> /// <exception cref="IOException">If there is a network related failure.</exception> /// <exception cref="ProtocolException">If the version negotiation failed.</exception> public NetworkConnection(PeerAddress peerAddress, NetworkParameters @params, uint bestHeight, int connectTimeout) { _params = @params; _remoteIp = peerAddress.Addr; var port = (peerAddress.Port > 0) ? peerAddress.Port : @params.Port; var address = new IPEndPoint(_remoteIp, port); _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socket.Connect(address); _socket.SendTimeout = _socket.ReceiveTimeout = connectTimeout; _out = new NetworkStream(_socket, FileAccess.Write); _in = new NetworkStream(_socket, FileAccess.Read); // the version message never uses check-summing. Update check-summing property after version is read. _serializer = new BitcoinSerializer(@params, false); // Announce ourselves. This has to come first to connect to clients beyond v0.30.20.2 which wait to hear // from us until they send their version message back. WriteMessage(new VersionMessage(@params, bestHeight)); // When connecting, the remote peer sends us a version message with various bits of // useful data in it. We need to know the peer protocol version before we can talk to it. _versionMessage = (VersionMessage)ReadMessage(); // Now it's our turn ... // Send an ACK message stating we accept the peers protocol version. WriteMessage(new VersionAck()); // And get one back ... ReadMessage(); // Switch to the new protocol version. var peerVersion = _versionMessage.ClientVersion; _log.InfoFormat("Connected to peer: version={0}, subVer='{1}', services=0x{2:X}, time={3}, blocks={4}", peerVersion, _versionMessage.SubVer, _versionMessage.LocalServices, UnixTime.FromUnixTime(_versionMessage.Time), _versionMessage.BestHeight ); // BitCoinSharp is a client mode implementation. That means there's not much point in us talking to other client // mode nodes because we can't download the data from them we need to find/verify transactions. if (!_versionMessage.HasBlockChain()) { // Shut down the socket try { Shutdown(); } catch (IOException) { // ignore exceptions while aborting } throw new ProtocolException("Peer does not have a copy of the block chain."); } // newer clients use check-summing _serializer.UseChecksumming(peerVersion >= 209); // Handshake is done! }
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.Number) { if (reader.TryGetInt32(out int unixDateTime)) { return(UnixTime.FromUnixTime(unixDateTime)); } } throw new InvalidCastException($"Unable convert value {reader.GetString()} with type {reader.TokenType} to DateTime"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: void parse() throws ProtocolException protected override void Parse() { // Alerts are formatted in two levels. The top level contains two byte arrays: a signature, and a serialized // data structure containing the actual alert data. int startPos = Cursor; content = ReadByteArray(); signature = ReadByteArray(); // Now we need to parse out the contents of the embedded structure. Rewind back to the start of the message. Cursor = startPos; ReadVarInt(); // Skip the length field on the content array. // We're inside the embedded structure. Version = ReadUint32(); // Read the timestamps. Bitcoin uses seconds since the epoch. RelayUntil = UnixTime.FromUnixTime(ReadUint64()); Expiration = UnixTime.FromUnixTime(ReadUint64()); Id = ReadUint32(); Cancel = ReadUint32(); // Sets are serialized as <len><item><item><item>.... var cancelSetSize = ReadVarInt(); if (cancelSetSize < 0 || cancelSetSize > MaxSetSize) { throw new ProtocolException("Bad cancel set size: " + cancelSetSize); } cancelSet = new HashSet <long?>(); for (ulong i = 0; i < cancelSetSize; i++) { cancelSet.Add(ReadUint32()); } MinVer = ReadUint32(); MaxVer = ReadUint32(); // Read the subver matching set. var subverSetSize = ReadVarInt(); if (subverSetSize < 0 || subverSetSize > MaxSetSize) { throw new ProtocolException("Bad subver set size: " + subverSetSize); } matchingSubVers = new HashSet <string>(); for (ulong i = 0; i < subverSetSize; i++) { matchingSubVers.Add(ReadStr()); } Priority = ReadUint32(); Comment = ReadStr(); StatusBar = ReadStr(); Reserved = ReadStr(); }
public override void OnBlocksDownloaded(Peer peer, Block block, int blocksLeft) { if (blocksLeft == 0) { DoneDownload(); _done.Release(); } if (blocksLeft < 0 || _originalBlocksLeft <= 0) return; var pct = 100.0 - (100.0*(blocksLeft/(double) _originalBlocksLeft)); if ((int) pct != _lastPercent) { Progress(pct, UnixTime.FromUnixTime(block.TimeSeconds*1000)); _lastPercent = (int) pct; } }
private VersionMessage Handshake(NetworkParameters networkParams, uint bestHeight) { // Announce ourselves. This has to come first to connect to clients beyond v0.30.20.2 which wait to hear // from us until they send their version message back. WriteMessage(new VersionMessage(networkParams, bestHeight)); // When connecting, the remote peer sends us a version message with various bits of // useful data in it. We need to know the peer protocol version before we can talk to it. var versionMsg = (VersionMessage)ReadMessage(); // Now it's our turn ... // Send an ACK message stating we accept the peers protocol version. WriteMessage(new VersionAck()); // And get one back ... ReadMessage(); // Switch to the new protocol version. Log.InfoFormat("Connected to peer: version={0}, subVer='{1}', services=0x{2:X}, time={3}, blocks={4}", versionMsg.ClientVersion, versionMsg.SubVer, versionMsg.LocalServices, UnixTime.FromUnixTime(versionMsg.Time), versionMsg.BestHeight); // BitCoinSharp is a client mode implementation. That means there's not much point in us talking to other client // mode nodes because we can't download the data from them we need to find/verify transactions. if (!versionMsg.HasBlockChain()) { // Shut down the socket try { Shutdown(); } catch (IOException) { // ignore exceptions while aborting } throw new ProtocolException("Peer does not have a copy of the block chain."); } return(versionMsg); }
private void StoreEntry(HtmlDocument doc, List <NicoNicoCommentEntry> list) { var nodes = doc.DocumentNode.SelectNodes("/packet/chat"); if (nodes == null) { return; } foreach (var node in nodes) { var attr = node.Attributes; //削除されていたら登録しない もったいないしね if (attr.Contains("deleted")) { continue; } var entry = new NicoNicoCommentEntry(); entry.No = attr["no"].Value; entry.Vpos = attr["vpos"].Value; entry.RenderTime = NicoNicoUtil.GetTimeFromVpos(entry.Vpos); var unix = UnixTime.FromUnixTime(long.Parse(attr["date"].Value)); entry.Date = unix.ToLongDateString() + " " + unix.ToLongTimeString(); entry.UserId = attr.Contains("user_id") ? attr["user_id"].Value : "contributor"; entry.Mail = attr.Contains("mail") ? attr["mail"].Value : ""; entry.Content = HttpUtility.HtmlDecode(node.InnerText); entry.Score = attr.Contains("score") ? int.Parse(attr["score"].Value) : 0; if (!NicoNicoNGComment.Filter(entry)) { list.Add(entry); } } }
public void Update() { if (current == ServerTime.CurrentUnixTime) { return; } current = ServerTime.CurrentUnixTime; timeGauge.value = Mathf.Min(1, (current - hatch.startTime) / (float)hatch.timeRequired); var cur = UnixTime.FromUnixTime(current); var end = UnixTime.FromUnixTime(hatch.timeRequired + hatch.startTime); var remain = (end - cur); if (cur < end) { timeRemain.text = remain.ToString(@"hh\:mm\:ss"); } else { timeRemain.text = "完了"; } }
//jsonをパースしてリストにする private void StoreItem(dynamic json, List <NicoNicoMylistData> ret) { foreach (var entry in json.mylistitem) { NicoNicoMylistData data = new NicoNicoMylistData(); data.CreateTime = UnixTime.FromUnixTime((long)entry.create_time).ToString(); data.Description = entry.description; data.ItemId = entry.item_id; var item = entry.item_data; data.Title = HttpUtility.HtmlDecode(item.title); if (entry.item_type is string) { data.Type = int.Parse(entry.item_type); } else if (entry.item_type is double) { data.Type = (int)entry.item_type; } //動画 if (data.Type == 0) { data.UpdateTime = UnixTime.FromUnixTime((long)item.update_time).ToString(); data.FirstRetrieve = UnixTime.FromUnixTime((long)item.first_retrieve).ToString(); data.Length = NicoNicoUtil.ConvertTime(long.Parse(item.length_seconds)); data.Id = item.video_id; data.ViewCounter = int.Parse(item.view_counter); data.CommentCounter = int.Parse(item.num_res); data.MylistCounter = int.Parse(item.mylist_counter); data.ThumbNailUrl = item.thumbnail_url; } else if (data.Type == 5) //静画 { data.UpdateTime = UnixTime.FromUnixTime((long)item.update_time).ToString(); data.FirstRetrieve = UnixTime.FromUnixTime((long)item.create_time).ToString(); data.Id = item.id.ToString(); data.ViewCounter = (int)item.view_count; data.CommentCounter = (int)item.comment_count; data.MylistCounter = (int)item.mylist_count; data.ThumbNailUrl = item.thumbnail_url; } else if (data.Type == 6) //書籍 { data.UpdateTime = UnixTime.FromUnixTime((long)entry.update_time).ToString(); data.FirstRetrieve = UnixTime.FromUnixTime((long)item.released_at).ToString(); data.Id = "bk" + item.id; data.ViewCounter = (int)item.view_count; data.CommentCounter = (int)item.comment_count; data.MylistCounter = (int)item.mylist_count; data.ThumbNailUrl = item.thumbnail; } else if (data.Type == 13) //ブロマガ { data.UpdateTime = UnixTime.FromUnixTime((long)item.commented_time).ToString(); data.FirstRetrieve = UnixTime.FromUnixTime((long)item.create_time).ToString(); data.Id = "ar" + item.id; data.CommentCounter = (int)item.comment_count; data.MylistCounter = int.Parse(item.mylist_count); data.ThumbNailUrl = item.thumbnail_url; } ret.Add(data); } }
public override void OnInspectorGUI() { if (Context.ProjectToken == null) { GUILayout.Label("サインインしてプロジェクトを選択してください。"); if (GUILayout.Button("サインイン")) { EditorWindow.GetWindow(typeof(SigninWindow), true, "Sign-in to GS2").Show(); } return; } if (_manifest == null) { _manifest = Manifest.Load(this); } if (_installing || _updating || _uninstalling) { if (_installing) { EditorGUILayout.LabelField("インストール中..."); } else if (_updating) { EditorGUILayout.LabelField("アップデート中..."); } else if (_uninstalling) { EditorGUILayout.LabelField("アンインストール中..."); } if (GUILayout.Button("Back")) { _installing = false; _updating = false; _uninstalling = false; _status = null; Repaint(); } using (new GUILayout.VerticalScope(GUI.skin.box)) { if (events != null) { foreach (var e in events) { using (new GUILayout.HorizontalScope()) { if (e.eventAt != null) { GUILayout.Label(UnixTime.FromUnixTime(e.eventAt.Value).ToShortTimeString()); } GUILayout.Label(e.resourceName); GUILayout.Label(e.type); GUILayout.Label(e.message); } } } } return; } if (_postProcess == null) { _postProcess = PostProcess(); } if (_status == null) { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.GetStatus( _manifest, r => { _status = r.Result.status; Repaint(); } ) ); } else if (_status == "CREATE_COMPLETE" || _status == "UPDATE_COMPLETE") { if (GUILayout.Button("アンインストール")) { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.Uninstall( _manifest, e => { Repaint(); events = e; }, () => { Repaint(); _uninstalling = false; _status = null; } ) ); _uninstalling = true; Repaint(); } EditorGUILayout.LabelField(""); if (GUILayout.Button("設定値をサーバから取得")) { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.GetOutputs( _manifest, r => { if (r.Error != null) { EditorUtility.DisplayDialog("Error", r.Error.Message, "OK"); } else { Repaint(); outputs = r.Result.items; } } ) ); } if (_postProcess != null) { EditorGUILayout.LabelField(""); if (GUILayout.Button("設定変更を反映")) { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.Update( _manifest, e => { Repaint(); events = e; }, () => { Repaint(); _updating = false; _status = null; }, _postProcess ) ); _updating = true; Repaint(); } } } else if (_status == "DELETE_COMPLETE") { if (GUILayout.Button("インストール")) { if (Validate()) { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.Install( _manifest, e => { events = e; }, () => { _installing = false; _status = null; Repaint(); }, _postProcess ) ); _installing = true; void RunOutputCoroutine() { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.GetOutputs( _manifest, r => { if (_installing) { RunOutputCoroutine(); } if (r.Error == null) { Repaint(); outputs = r.Result.items; } } ) ); } RunOutputCoroutine(); Repaint(); } else { EditorUtility.DisplayDialog("Validation Error", "インストールパラメータの入力値に問題があります", "OK"); } } } else if (_status == "ROLLBACK_COMPLETE") { EditorGUILayout.LabelField("インストールに失敗しました"); using (new GUILayout.VerticalScope(GUI.skin.box)) { if (events != null) { foreach (var e in events) { using (new GUILayout.HorizontalScope()) { if (e.eventAt != null) { GUILayout.Label(UnixTime.FromUnixTime(e.eventAt.Value).ToShortTimeString()); } GUILayout.Label(e.resourceName); GUILayout.Label(e.type); GUILayout.Label(e.message); } } } } if (GUILayout.Button("アンインストール")) { EditorCoroutineUtility.StartCoroutineOwnerless( WeaveInstaller.Uninstall( _manifest, e => { Repaint(); events = e; }, () => { Repaint(); _uninstalling = false; _status = null; } ) ); _uninstalling = true; Repaint(); } } else { EditorGUILayout.LabelField("状態を取得中..."); _status = null; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return(UnixTime.FromUnixTime(System.Convert.ToInt64(value))); }
public static string ConvMMDDYYYY(long unixTime) { System.DateTime date = UnixTime.FromUnixTime(unixTime); return(String.Format("{0:00}", date.Month) + "/" + String.Format("{0:00}", date.Day) + "/" + String.Format("{0:0000}", date.Year)); }
// UnixTimeから年月日時分秒を取得 public static string ConvYYYYMMDD_HHMMSS(long unixTime) { System.DateTime date = UnixTime.FromUnixTime(unixTime); return(String.Format("{0:0000}", date.Year) + "/" + String.Format("{0:00}", date.Month) + "/" + String.Format("{0:00}", date.Day) + " " + String.Format("{0:00}", date.Hour) + ":" + String.Format("{0:00}", date.Minute) + ":" + String.Format("{0:00}", date.Second)); }
// UnixTimeから時分秒を取得 public static string ConvHHMMSS(long unixTime) { System.DateTime date = UnixTime.FromUnixTime(unixTime); return(String.Format("{0:00}", date.Hour) + ":" + String.Format("{0:00}", date.Minute) + ":" + String.Format("{0:00}", date.Second)); }