当前位置: 首页>>代码示例>>C#>>正文


C# TimeEntryModel.StartAsync方法代码示例

本文整理汇总了C#中TimeEntryModel.StartAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TimeEntryModel.StartAsync方法的具体用法?C# TimeEntryModel.StartAsync怎么用?C# TimeEntryModel.StartAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeEntryModel的用法示例。


在下文中一共展示了TimeEntryModel.StartAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartStopTimeEntry

        public async void StartStopTimeEntry()
        {
            if (isActing) {
                return;
            }
            isActing = true;

            try {
                if (currentTimeEntry != null && currentTimeEntry.State == TimeEntryState.Running) {
                    await currentTimeEntry.StopAsync ();

                    // Ping analytics
                    ServiceContainer.Resolve<ITracker>().SendTimerStopEvent (TimerStopSource.Widget);
                } else if (timeEntryManager != null) {
                    currentTimeEntry = (TimeEntryModel)timeEntryManager.Draft;
                    if (currentTimeEntry == null) {
                        return;
                    }
                    await currentTimeEntry.StartAsync ();

                    // Show new screen on platform
                    widgetUpdateService.ShowNewTimeEntryScreen (currentTimeEntry);

                    // Ping analytics
                    ServiceContainer.Resolve<ITracker>().SendTimerStartEvent (TimerStartSource.WidgetNew);
                }
            } finally {
                isActing = false;
            }
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:30,代码来源:WidgetSyncManager.cs

示例2: OnActionButtonTouchUpInside

        private async void OnActionButtonTouchUpInside (object sender, EventArgs e)
        {
            if (isActing)
                return;
            isActing = true;

            try {
                if (currentTimeEntry != null && currentTimeEntry.State == TimeEntryState.Running) {
                    await currentTimeEntry.StopAsync ();
                } else if (timeEntryManager != null) {
                    currentTimeEntry = (TimeEntryModel)timeEntryManager.Draft;
                    if (currentTimeEntry == null)
                        return;

                    await currentTimeEntry.StartAsync ();

                    var controllers = new List<UIViewController> (parentController.NavigationController.ViewControllers);
                    controllers.Add (new EditTimeEntryViewController (currentTimeEntry));
                    if (ServiceContainer.Resolve<SettingsStore> ().ChooseProjectForNew) {
                        controllers.Add (new ProjectSelectionViewController (currentTimeEntry));
                    }
                    parentController.NavigationController.SetViewControllers (controllers.ToArray (), true);
                }
            } finally {
                isActing = false;
            }
        }
开发者ID:readiescards,项目名称:mobile,代码行数:27,代码来源:TimerNavigationController.cs

示例3: StartStopTimeEntry

        public static async Task StartStopTimeEntry (Context ctx)
        {
            var manager = ServiceContainer.Resolve<ActiveTimeEntryManager> ();
            if (manager.Active == null) {
                return;
            }

            var active = new TimeEntryModel (manager.Active);
            if (manager.Active.State == TimeEntryState.Running) {
                await active.StopAsync ();
                ServiceContainer.Resolve<ITracker> ().SendTimerStopEvent (TimerStopSource.Watch);
            } else {
                active.Data.Description = ctx.Resources.GetString (Resource.String.WearEntryDefaultDescription);
                await active.StartAsync ();
                ServiceContainer.Resolve<ITracker> ().SendTimerStartEvent (TimerStartSource.WatchStart);
            }
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:17,代码来源:WearDataProvider.cs

示例4: ContinueTimeEntry

 public static async Task ContinueTimeEntry (Guid timeEntryId)
 {
     var entryModel = new TimeEntryModel (timeEntryId);
     await entryModel.StartAsync ();
     ServiceContainer.Resolve<ITracker> ().SendTimerStartEvent (TimerStartSource.WatchContinue);
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:6,代码来源:WearDataProvider.cs

示例5: OnActionButtonClicked

        private async void OnActionButtonClicked (object sender, EventArgs e)
        {
            // Protect from double clicks
            if (isProcessingAction)
                return;

            isProcessingAction = true;
            try {
                var entry = ActiveTimeEntry;
                if (entry == null)
                    return;

                // Make sure that we work on the copy of the entry to not affect the rest of the logic.
                entry = new TimeEntryModel (new TimeEntryData (entry.Data));

                var showProjectSelection = false;

                try {
                    if (entry.State == TimeEntryState.New && entry.StopTime.HasValue) {
                        await entry.StoreAsync ();
                    } else if (entry.State == TimeEntryState.Running) {
                        await entry.StopAsync ();
                    } else {
                        var startTask = entry.StartAsync ();

                        var userId = ServiceContainer.Resolve<AuthManager> ().GetUserId ();
                        if (userId.HasValue && ChooseProjectForNew && entry.Project == null) {
                            var store = ServiceContainer.Resolve<IDataStore> ();
                            var countTask = store.CountUserAccessibleProjects (userId.Value);

                            // Wait for the start and count to finish
                            await Task.WhenAll (startTask, countTask);

                            if (countTask.Result > 0)
                                showProjectSelection = true;
                        } else {
                            await startTask;
                        }
                    }
                } catch (Exception ex) {
                    var log = ServiceContainer.Resolve<Logger> ();
                    log.Warning (LogTag, ex, "Failed to change time entry state.");
                }

                if (showProjectSelection) {
                    new ChooseTimeEntryProjectDialogFragment (entry).Show (activity.SupportFragmentManager, "projects_dialog");
                }

                var bus = ServiceContainer.Resolve<MessageBus> ();
                bus.Send (new UserTimeEntryStateChangeMessage (this, entry));
            } finally {
                isProcessingAction = false;
            }
        }
开发者ID:jblj,项目名称:mobile,代码行数:54,代码来源:TimerComponent.cs

示例6: OnActionButtonTouchUpInside

        private async void OnActionButtonTouchUpInside (object sender, EventArgs e)
        {
            if (isActing) {
                return;
            }
            isActing = true;

            try {
                if (currentTimeEntry != null && currentTimeEntry.State == TimeEntryState.Running) {
                    await currentTimeEntry.StopAsync ();

                    // Ping analytics
                    ServiceContainer.Resolve<ITracker>().SendTimerStopEvent (TimerStopSource.App);
                } else if (timeEntryManager != null) {
                    currentTimeEntry = (TimeEntryModel)timeEntryManager.Draft;
                    if (currentTimeEntry == null) {
                        return;
                    }

                    OBMExperimentManager.Send (OBMExperimentManager.HomeEmptyState, "startButton", "click");
                    await currentTimeEntry.StartAsync ();

                    var controllers = new List<UIViewController> (parentController.NavigationController.ViewControllers);
                    controllers.Add (new EditTimeEntryViewController (currentTimeEntry));
                    if (ServiceContainer.Resolve<SettingsStore> ().ChooseProjectForNew) {
                        controllers.Add (new ProjectSelectionViewController (currentTimeEntry));
                    }
                    parentController.NavigationController.SetViewControllers (controllers.ToArray (), true);

                    // Ping analytics
                    ServiceContainer.Resolve<ITracker>().SendTimerStartEvent (TimerStartSource.AppNew);
                }
            } finally {
                isActing = false;
            }
        }
开发者ID:MrBloo63,项目名称:mobile,代码行数:36,代码来源:TimerNavigationController.cs


注:本文中的TimeEntryModel.StartAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。