WP8上的自定义任务

本文关键字:任务 自定义 WP8 | 更新日期: 2023-09-27 18:30:05

我想在我的应用程序上创建一个新任务,以便稍后对其进行跟踪……但我认为我尝试的方式不好。这就是我正在尝试的:

public async Task NombreEvento(string json)
    {
        var c = new Jumper.Core.Client.Client();
        var item2 = await c.CreateDefaultItem();
        Jumper.Core.Model.TrackingItem item = item2;
        item.Type = Jumper.Core.Model.TrackingTypeEnum.Custom;
        item.Json = json;
        item.RunningSeconds = 0;
        var t = new Jumper.Core.Services.ServiceFactory();
        var service = await t.serviceFactory.TrackingService.AddItem(item);
    }

我的问题是我不能使用函数CreateDefaultItem。。。Client()上的错误为:使用泛型类型Jumper.Core.Client.Client需要4个类型参数。

以下是函数CreateDefaultItem:

namespace Jumper.Core.Client
{
public sealed class Client
     <TBaseSaveData,
    TDeviceServiceHelper,
    TGeoLocationService,
    TNetworkService>
    where TBaseSaveData : BaseSaveDataService, new()
    where TDeviceServiceHelper : IDeviceServiceHelper, new()
    where TGeoLocationService : IGeoLocationService, new()
    where TNetworkService : INetworkService, new()
{
    private readonly int appId;
    private readonly string appVersion;
    private readonly ServiceFactory<TBaseSaveData,
        TDeviceServiceHelper,
        TGeoLocationService,
        TNetworkService> serviceFactory;
    #region Constructors
    internal Client
        (int appId, string appVersion)
    {
        this.appId = appId;
        this.appVersion = appVersion;
        this.serviceFactory = new ServiceFactory<TBaseSaveData,
        TDeviceServiceHelper,
        TGeoLocationService,
        TNetworkService>();
    }
    #endregion
    #region Private Methods
    public async Task SendItem(TrackingTypeEnum trackingType, bool flush)
    {
        TrackingItem item = await CreateDefaultItem();
        item.Type = trackingType;
        if (trackingType != TrackingTypeEnum.Background)
        {
            item.RunningSeconds = 0;
        }
        await this.serviceFactory.TrackingService.AddItem(item, flush);
    }
    public async Task<TrackingItem> CreateDefaultItem()
    {
        Tuple<double, double> location = await this.serviceFactory.GeoLocationService
            .GetUnifiedGeoLocation();
        var assemblyService = this.serviceFactory.AssemblyInfoService;
        var deviceService = this.serviceFactory.DeviceServiceHelper;
        var seconds = (DateTime.UtcNow - this.serviceFactory.TrackingService.StartTime).TotalSeconds;
        TrackingItem item = new TrackingItem()
        {
            //APP
            AppId = this.appId,
            RunningSeconds = (int)seconds,
            AppVersion = this.appVersion,
            Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName,
            Country = CultureInfo.CurrentCulture.Name.Substring(3, 2),
            //Navigation
            Json = TrackingItem.NULL
        };
        return item;
    }
}

我对函数serviceFactory也有同样的问题(有同样的错误)。

有人能帮我吗?

非常感谢!

WP8上的自定义任务

好吧,你需要写一些类似的东西:

var c = new Jumper.Core.Client.Client<Type1, Type2, Type3, Type4>();

虽然我不熟悉你正在使用的那个图书馆。这就是整个清单吗?您甚至应该手动创建Client的实例吗?