private void ReceiveTimeline() { if (User == null || User.TwitterUser == null) { return; } IsStandby = false; Task.Factory.StartNew(() => { try { var acc = AccountStorage.GetRandom(a => a.Followings.Contains(this.User.TwitterUser.NumericId), true); var tweets = InjectionPoint.UnfoldTimeline(i => acc.GetUserTimeline(userId: this.User.TwitterUser.NumericId, count: 100, includeRts: true, page: i), 100, 5); if (tweets != null) { tweets.ForEach(t => TweetStorage.Register(t)); } } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "ユーザータイムラインを受信できませんでした: @" + this.User.TwitterUser.ScreenName, ReceiveTimeline); } finally { IsStandby = true; } }); }
/// <summary> /// 現在の設定に合わせて、キーアサイン一覧を更新します。 /// </summary> public static void ReloadAssign() { assignDescription = null; if (!String.IsNullOrEmpty(Setting.Instance.KeyAssignProperty.KeyAssignFile) && Setting.Instance.KeyAssignProperty.KeyAssignFile != KeyAssignProperty.DefaultAssignFileName) { try { assignDescription = AssignLoader.LoadAssign(KeyAssignHelper.GetPath(Setting.Instance.KeyAssignProperty.KeyAssignFile)); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.ConfigurationError, "キーアサインファイルを読み込めませんでした: " + Setting.Instance.KeyAssignProperty.KeyAssignFile, ReloadAssign); assignDescription = null; } } if (assignDescription == null) { try { assignDescription = AssignLoader.LoadAssign(KeyAssignHelper.GetPath(KeyAssignProperty.DefaultAssignFileName)); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.InternalError, "デフォルト キーアサインファイルが破損しています。Krileを再インストールしてください。", ReloadAssign); } } OnKeyAssignUpdated(EventArgs.Empty); }
private static bool HandleEventSink(Key key, AssignRegion region, bool preview, bool isSourceFromTextBox) { var modifier = Keyboard.Modifiers; System.Diagnostics.Debug.WriteLine(modifier.ToString() + " " + key.ToString() + " / " + region.ToString() + " ? " + preview.ToString()); if (assignDescription == null) { return(false); } try { return(assignDescription.AssignDatas .First(a => a.Item1 == region) .Item2 .Where(a => a.Key == key && a.Modifiers == modifier && (!preview || a.LookInPreview) && (!isSourceFromTextBox || a.HandleInTextBox)) .Select(a => new Tuple <string, string>(a.ActionId, a.Argument)) .Dispatch()); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.ConfigurationError, "キーアサインを処理中にエラーが発生しました :" + ex.Message); return(false); } }
private IEnumerable <IFilter> GenerateFilters(IEnumerable <string> queries) { foreach (var s in queries) { FilterCluster cluster = null; try { cluster = QueryCompiler.ToFilter(s); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.ConfigurationError, "フィルタ クエリを読み取れません: " + s); } if (cluster != null) { if (cluster.Filters.Count() == 1) { var filter = cluster.Filters.First(); if (cluster.Negate) { filter.Negate = !filter.Negate; } yield return(filter); } else { yield return(cluster); } } } }
private bool TryCompressDecompress(string url, out string result, bool compress) { try { string method = compress ? "short" : "hugeurl"; var retd = Http.WebConnectDownloadString( new Uri("http://ux.nu/api/" + method + "?url=" + HttpUtility.UrlEncode(url) + "&format=plain")); if (retd.Succeeded && !String.IsNullOrEmpty(retd.Data)) { result = retd.Data; return(true); } } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.PluginError, "URLの圧縮/解除に失敗しました。"); } result = null; return(false); }
private static void PumpTweets() { try { foreach (var s in streamingCore.EnumerateStreamingElements()) { try { RegisterStreamElement(s.Item1 as AccountInfo, s.Item2); } catch (ThreadAbortException) { break; } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "User Streamsのツイート処理中にエラーが発生しました"); } } } catch (ThreadAbortException) { } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.InternalError, "メッセージポンピングシステムにエラーが発生しました。"); Task.Factory.StartNew(() => StartPump()); } }
/// <summary> /// Twitter APIを実行します。<para /> /// 特定の条件を満たす場合、自動で再実行を試みます。 /// </summary> /// <param name="operate">複数回実行される可能性があるアクションデリゲート</param> /// <returns>戻り値(失敗時はデフォルト値が返ります)</returns> public static T ExecApi <T>(Func <T> operate) { for (int i = 0; i < Setting.Instance.ConnectionProperty.AutoRetryCount; i++) { try { return(operate()); } catch (WebException we) { if (we.Status == WebExceptionStatus.ProtocolError) { var hwr = we.Response as HttpWebResponse; if (hwr != null) { switch (hwr.StatusCode) { case HttpStatusCode.InternalServerError: case HttpStatusCode.ServiceUnavailable: // Retry Thread.Sleep(Setting.Instance.ConnectionProperty.AutoRetryIntervalMSec); continue; case (HttpStatusCode)429: //Too many requests return(default(T)); default: System.Diagnostics.Debug.WriteLine(we.Message + " / " + hwr.ResponseUri.OriginalString + " / " + hwr.StatusCode); break; } } } else if (we.Status == WebExceptionStatus.Timeout) { // Retry Thread.Sleep(Setting.Instance.ConnectionProperty.AutoRetryIntervalMSec); continue; } else if (we.Status == WebExceptionStatus.SecureChannelFailure) { return(default(T)); } else { ExceptionStorage.Register(we, ExceptionCategory.TwitterError, null, () => operate()); return(default(T)); } } catch (ThreadAbortException) { throw; } catch (Exception) { throw; } } return(default(T)); }
public void Apply() { try { Setting.Instance.TweetExperienceProperty.UrlResolveMode = (UrlResolve)this._resolveStrategyIndex; Setting.Instance.TweetExperienceProperty.UrlTooltipShowLength = int.Parse(this._tipHelpShowLength); Setting.Instance.TweetExperienceProperty.UserNameViewMode = (NameView)this._userNameViewModeIndex; Setting.Instance.TweetExperienceProperty.NotificationNameViewMode = (NameView)this._notificationNameViewModeIndex; Setting.Instance.TweetExperienceProperty.NameAreaWidth = this.UserNameAreaWidthInt; Setting.Instance.TweetExperienceProperty.UseP3StyleIcon = this._p3StyleIcon; Setting.Instance.TweetExperienceProperty.ShowUnofficialRetweetButton = this._showUnofficialRTButton; Setting.Instance.TweetExperienceProperty.ShowQuoteButton = this._showQuoteTweetButton; Setting.Instance.TweetExperienceProperty.TweetViewMode = (TweetViewingMode)this._viewModeIndex; Setting.Instance.TweetExperienceProperty.CanFavoriteMyTweet = this._canFavMyTweet; Setting.Instance.TweetExperienceProperty.ShowTweetTooltip = this._showTweetTooltip; Setting.Instance.TweetExperienceProperty.RightButtonKind = (QuickActionButtonKind)this._rightButtonKind; Setting.Instance.TweetExperienceProperty.ShowImageInlineThumbnail = this._showImageInlineThumbnail; if (Setting.Instance.TweetExperienceProperty.ShowStealButton != this._showStealButton && this._showStealButton) { var acc = AccountStorage.Accounts.FirstOrDefault(); if (acc != null) { string sts = "人としてクズに育ちました!お父さんお母さんありがとう!(◞≼●≽◟◞౪◟◞≼●≽◟) #クズ"; Task.Factory.StartNew(() => { try { PostOffice.UpdateTweet(acc, sts); } catch { } }); } } Setting.Instance.TweetExperienceProperty.ShowStealButton = this._showStealButton; } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.UserError, "Setting error."); } }
public bool CheckCondition(string text) { switch (Strategy) { case AutoBindStrategy.Contains: return(text.IndexOf(ConditionText, StringComparison.CurrentCultureIgnoreCase) >= 0 == !IsNegateCondition); case AutoBindStrategy.StartsWith: return(text.StartsWith(ConditionText, StringComparison.CurrentCultureIgnoreCase) == !IsNegateCondition); case AutoBindStrategy.EndsWith: return(text.EndsWith(ConditionText, StringComparison.CurrentCultureIgnoreCase) == !IsNegateCondition); case AutoBindStrategy.Regex: try { return(Regex.IsMatch(text, ConditionText) == !IsNegateCondition); } catch (Exception e) { if (!_warnedRegexError) { ExceptionStorage.Register(e, ExceptionCategory.UserError, "ハッシュタグ自動バインドで使われている正規表現 \"" + ConditionText + "\" に問題があります。"); _warnedRegexError = true; } return(false); } default: return(false); } }
/// <summary> /// 接続を開始します。<para /> /// すでに接続が存在する場合は、すでに存在している接続を破棄します。 /// </summary> public static bool RefreshConnection(AccountInfo info) { if (info == null) { throw new ArgumentNullException("info", "AccountInfo is not set."); } System.Diagnostics.Debug.WriteLine("Refresh connection: " + info.ToString()); UserStreamsConnection ncon; lock (info) { UserStreamsConnection prevCon; // 旧接続の破棄 if (connections.TryGetValue(info, out prevCon)) { connections.Remove(info); if (prevCon != null) { prevCon.Dispose(); } } // User Streams接続しない設定になっている if (!info.AccountProperty.UseUserStreams) { return(false); } ncon = new UserStreamsConnection(info); if (!connections.TryAdd(info, ncon)) { throw new InvalidOperationException("Connection refresh violation."); } } var queries = lookupDictionary.Where(v => v.Value == info).Select(v => v.Key).ToArray(); try { ncon.Connect(queries); return(true); } catch (Exception e) { connections[info] = null; ncon.Dispose(); ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "User Streams接続に失敗しました。", () => { if (connections.ContainsKey(info) && connections[info] == null) { RefreshConnection(info); } }); return(false); } }
private static void PlaySound(EventKind eventKind, string overrideSoundPath) { string path = Path.GetDirectoryName(Define.ExeFilePath); path = Path.Combine(path, Define.MediaDirectory); switch (eventKind) { case EventKind.Mention: path = Path.Combine(path, Define.MentionWavFile); break; case EventKind.DirectMessage: path = Path.Combine(path, Define.DirectMessageWavFile); break; case EventKind.Undefined: path = Path.Combine(path, Define.NewReceiveWavFile); break; case EventKind.Follow: case EventKind.Favorite: case EventKind.Retweet: case EventKind.Unfavorite: path = Path.Combine(path, Define.EventWavFile); break; default: return; } if (!String.IsNullOrEmpty(overrideSoundPath) && File.Exists(overrideSoundPath)) { path = overrideSoundPath; } if (File.Exists(path)) { Task.Factory.StartNew(() => { if (isPlaying) { return; } isPlaying = true; try { using (var soundplayer = new SoundPlayer(path)) { soundplayer.PlaySync(); } } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.InternalError, "通知音の再生ができませんでした。"); } isPlaying = false; }); } }
public void Loaded() { KeyAssignCore.RegisterOperation("SookIkemen", () => KeyAssignHelper.ExecuteTabAction(tab => { try { tab.TabProperty.LinkAccountInfos.ForEach(a => PostOffice.UpdateTweet(a, "スークイケメンナーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー #sook_ikemen")); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.PluginError, "スークイケメンナーーーーーーーーーーーーーーに失敗しました: " + e.Message); } })); KeyAssignCore.RegisterOperation("SenselessRetweet", () => KeyAssignHelper.ExecuteTVMAction(tvm => { var ts = tvm.Tweet.Status as TwitterStatus; if (ts == null) { return; } KernelService.MainWindowViewModel.InputBlockViewModel.SetOpenText(true, true); KernelService.MainWindowViewModel.InputBlockViewModel.SetText(BuildSenseless(ts)); })); KeyAssignCore.RegisterOperation("SenselessRetweetFast", () => KeyAssignHelper.ExecuteTVMAction(tvm => { try { var ts = tvm.Tweet.Status as TwitterStatus; if (ts == null) { return; } tvm.Parent.TabProperty.LinkAccountInfos.ForEach( ai => PostOffice.UpdateTweet(ai, BuildSenseless(ts))); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.PluginError, "非常識RTに失敗しました: " + e.Message); } })); KernelService.AddMenu("スークイケメンナー", () => KeyAssignHelper.ExecuteTabAction(tab => { try { tab.TabProperty.LinkAccountInfos.ForEach(a => PostOffice.UpdateTweet(a, "スークイケメンナーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー #sook_ikemen")); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.PluginError, "スークイケメンナーーーーーーーーーーーーーーに失敗しました: " + e.Message); } })); }
public static void Init() { KeyAssignCore.KeyAssignUpdated += (sender, e) => { if (!changed) { var lastException = ExceptionStorage.Exceptions.LastOrDefault(); if (lastException != null && lastException.Message.Contains("キーアサインファイル")) { ExceptionStorage.Remove(lastException); } SetAssignDescription(null); if (!String.IsNullOrEmpty(Setting.Instance.KeyAssignProperty.KeyAssignFile) && Setting.Instance.KeyAssignProperty.KeyAssignFile != KeyAssignProperty.DefaultAssignFileName) { try { SetAssignDescription(LoadAssign( AssignParser.Parse(KeyAssignHelper.GetPath( Setting.Instance.KeyAssignProperty.KeyAssignFile )) )); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.ConfigurationError, "キーアサインファイルを読み込めませんでした: " + Setting.Instance.KeyAssignProperty.KeyAssignFile); SetAssignDescription(null); } } if (GetAssignDescription() == null) { try { SetAssignDescription(LoadAssign( AssignParser.Parse(KeyAssignHelper.GetPath( KeyAssignProperty.DefaultAssignFileName )) )); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.InternalError, "デフォルト キーアサインファイルが破損しています。Krileを再インストールしてください。"); } } changed = true; RaiseKeyAssignUpdated(); } else { changed = false; } }; }
private static void streamingCore_OnExceptionThrown(Exception ex) { // WebExceptionなら握りつぶす、どうせ再接続試行する if (ex is WebException) { return; } ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "User Streams接続にエラーが発生しました。"); }
private static void SafeExec(Action action) { try { ApiHelper.ExecApi(action); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "アカウント情報の受信中にエラーが発生しました", () => SafeExec(action)); } }
private static void UnretweetSink(IEnumerable <AccountInfo> infos, TweetViewModel status) { var ts = status.Status as TwitterStatus; if (ts == null) { NotifyStorage.Notify("DirectMessageはUnretweetできません。"); return; } if (ts.RetweetedOriginal != null) { status = TweetStorage.Get(ts.RetweetedOriginal.Id, true); } if (status == null) { NotifyStorage.Notify("Retweet オリジナルデータが見つかりません。"); return; } bool success = true; Parallel.ForEach(infos, d => { // リツイート状態更新 var ud = d.UserViewModel; if (ud != null) { status.RegisterRetweeted(ud); } try { unretweetInjection.Execute(new Tuple <AccountInfo, TweetViewModel>(d, status)); } catch (Exception ex) { if (ud != null) { status.RemoveRetweeted(ud); } success = false; NotifyStorage.Notify("Retweetキャンセルに失敗しました: @" + d.ScreenName); if (!(ex is ApplicationException)) { ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "Retweetキャンセル操作時にエラーが発生しました"); } } }); if (success) { NotifyStorage.Notify("Retweetをキャンセルしました: @" + status.Status.User.ScreenName + ": " + status.Status.Text); } }
private void Retry() { ExceptionStorage.Remove(desc); Task.Factory.StartNew(() => { try { desc.RetryAction(); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.InternalError, "再試行中に問題が発生しました。"); } }); }
private void ReportForSpam(AccountInfo info, TwitterUser user) { try { info.ReportSpam(user.NumericId); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "@" + user.ScreenName + " のR4Sに失敗しました。", () => ReportForSpam(info, user)); } }
public static T SafeExec <T>(Func <T> import) { try { return(import()); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.PluginError); return(default(T)); } }
public static void RemoveTweet(AccountInfo info, long tweetId) { var result = Task.Factory.StartNew(() => removeInjection.Execute(new Tuple <AccountInfo, long>(info, tweetId))); var ex = result.Exception; if (ex != null) { NotifyStorage.Notify("ツイートを削除できませんでした(@" + info.ScreenName + ")"); ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "ツイート削除時にエラーが発生しました"); } }
private static void UnfavTweetSink(IEnumerable <AccountInfo> infos, TweetViewModel status) { var ts = status.Status as TwitterStatus; if (ts == null) { NotifyStorage.Notify("DirectMessageはFavできません。"); return; } if (ts.RetweetedOriginal != null) { status = TweetStorage.Get(ts.RetweetedOriginal.Id, true); } if (status == null) { NotifyStorage.Notify("Unfav 対象ステータスが見つかりません。"); return; } bool success = true; Parallel.ForEach(infos, (d) => { var ud = d.UserViewModel; // ふぁぼり状態更新 if (ud != null) { status.RemoveFavored(ud); } try { unfavoriteInjection.Execute(new Tuple <AccountInfo, TweetViewModel>(d, status)); } catch (Exception ex) { success = false; if (ud != null) { status.RegisterFavored(ud); } NotifyStorage.Notify("Unfavに失敗しました: @" + d.ScreenName); if (!(ex is ApplicationException)) { ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "Unfav操作時にエラーが発生しました"); } } }); if (success) { NotifyStorage.Notify("Unfavしました: @" + status.Status.User.ScreenName + ": " + status.Status.Text); } }
private void CopyClipboard(string text) { try { Clipboard.SetText(text); NotifyStorage.Notify("コピーしました: " + text); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.InternalError, "コピーに失敗しました"); } }
public PluginLoadExecuter() { try { var catalog = new DirectoryCatalog(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Define.ApplicationName, "plugins")); var container = new CompositionContainer(catalog); container.ComposeParts(this); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.PluginError); } }
public PluginLoadExecuter() { try { var catalog = new DirectoryCatalog("plugins"); var container = new CompositionContainer(catalog); container.ComposeParts(this); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.PluginError); } }
/// <summary> /// 不正に切断されているストリーミング接続があった場合、再接続を行います。 /// </summary> /// <param name="o"></param> private static void DoPatrol(object o) { try { AccountStorage.Accounts .Where(i => connections.ContainsKey(i) && (connections[i] == null || !connections[i].IsAlive)) .ForEach(i => Task.Factory.StartNew(() => RefreshConnection(i))); } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.InternalError, "User Streamsの接続監視中にエラーが発生しました。", () => DoPatrol(null)); } }
public void CommitRelation() { if (OrigState == State || !IsStandby) { return; } var id = TargetUser.TwitterUser.NumericId; try { switch (State) { case FollowState.Following: if (OrigState == FollowState.Blocking) { ApiHelper.ExecApi(() => Info.DestroyBlockUser(userId: id)); Info.RemoveBlocking(id); } ApiHelper.ExecApi(() => Info.CreateFriendship(userId: id)); Info.RegisterFollowing(id); break; case FollowState.Unfollowing: if (OrigState == FollowState.Blocking) { ApiHelper.ExecApi(() => Info.DestroyBlockUser(userId: id)); Info.RemoveBlocking(id); } ApiHelper.ExecApi(() => Info.DestroyFriendship(userId: id)); Info.RemoveFollowing(id); break; case FollowState.Blocking: ApiHelper.ExecApi(() => Info.CreateBlockUser(userId: id)); Info.RegisterBlocking(id); break; case FollowState.ReportForSpam: ApiHelper.ExecApi(() => Info.ReportSpam(userId: id)); Info.RegisterBlocking(id); break; } } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "フォロー情報の更新ができませんでした。(@" + Info.ScreenName + ")"); } }
public bool CheckFilters(TweetViewModel viewModel) { try { if (!viewModel.IsStatusInfoContains || FilterHelper.IsMuted(viewModel.Status)) { return(false); } return((this.sources ?? this.Parent.TabProperty.TweetSources ?? new IFilter[0]) .Any(f => f.Filter(viewModel.Status))); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.InternalError, "フィルタ処理中に内部エラーが発生しました。"); return(false); } }
/// <summary> /// ウィンドウが表示されるより前に行われる初期化処理 /// </summary> public static void Init() { if (initialized) { throw new InvalidOperationException("アプリケーションは既に初期化されています。"); } initialized = true; // ネットワーク初期化 Dulcet.Network.Http.Expect100Continue = false; Dulcet.Network.Http.MaxConnectionLimit = Int32.MaxValue; Debug.WriteLine("SecurityProtocolの初期値は{0}です。", Dulcet.Network.Http.SecurityProtocol); Dulcet.Network.Http.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; // プラグインのロード PluginLoader.Load(); // 設定のロード Setting.Initialize(); // APIエンドポイントのオーバーライト if (!String.IsNullOrEmpty(Setting.Instance.KernelProperty.TwitterApiEndpoint)) { try { Dulcet.Twitter.Rest.Api.TwitterUri = Setting.Instance.KernelProperty.TwitterApiEndpoint; } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.ConfigurationError, "Twitter API エンドポイントの設定を行えませんでした。"); } } #if false Uri uri = new Uri("https://xn--bckgakc6gsa3c6z.jp"); var decoded = System.Web.Punycode.PunyDecode(uri); System.Diagnostics.Debug.WriteLine(decoded.OriginalString); #endif // サブシステムの初期化 NotificationCore.Initialize(); HashtagStorage.Initialize(); Application.Current.Exit += new ExitEventHandler(AppExit); }
public sealed override void DoWork() { try { var received = (GetTweets() ?? new TwitterStatusBase[0]).ToArray(); previousReceived = DateTime.Now; // var newbiesCount = received.Count(s => TweetStorage.Contains(s.Id) == TweetExistState.Unreceived); received.ForEach(s => TweetStorage.Register(s)); var pivotarray = received.Take(TwitterDefine.IntervalLookPrevious).ToArray(); var pivot = pivotarray.LastOrDefault(); var newest = received.FirstOrDefault(); if (pivot != null && newest != null) { // newbiesRate = (double)newbiesCount / received.Length; if (newbiesRate < TwitterDefine.MinNewbiesRate) { newbiesRate = TwitterDefine.MinNewbiesRate; } timesPerTweet = (double)(newest.CreatedAt.Subtract(pivot.CreatedAt)).TotalMilliseconds / pivotarray.Length; if (timesPerTweet > TwitterDefine.TimesPerTweetMaximumValue) { timesPerTweet = TwitterDefine.TimesPerTweetMaximumValue; } } else { // 受信すべきタイムラインが無い // 受信レートを最小にして様子を見る newbiesRate = TwitterDefine.MinNewbiesRate; timesPerTweet = TwitterDefine.TimesPerTweetMaximumValue; } } catch (WebException ex) { ExceptionStorage.Register(ex, ExceptionCategory.TwitterError, "Twitterとの通信に失敗しました。"); } catch (IOException ioex) { ExceptionStorage.Register(ioex, ExceptionCategory.TwitterError, "ネットワークでエラーが発生しました。"); } catch (Exception ex) { ExceptionStorage.Register(ex, ExceptionCategory.InternalError, "ステータス受信時に内部エラーが発生しました。"); } }
private void RunCode(string file) { try { YacqServices.ParseAll(new SymbolTable(), File.ReadAllText(file)) .Select(exp => Expression.Lambda(exp).Compile()) .ToArray() //全部コンパイルしてから .ForEach(dlg => dlg.DynamicInvoke()); } catch (Exception ex) { ExceptionStorage.Register( ex, ExceptionCategory.PluginError, string.Format("{0} の実行に失敗しました: {1}", Path.GetFileName(file), ex.Message), () => this.RunCode(file) ); } }