簡體   English   中英

WP8上的自定義任務

[英]Custom Task on WP8

我想在我的應用程序上創建一個新任務,以便以后對其進行跟蹤...但是我認為我嘗試的方式並不理想。 這就是我正在嘗試的:

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有相同的問題(具有相同的錯誤)。

誰能幫我嗎?

非常感謝!

好吧,您需要編寫如下內容:

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

盡管我不熟悉您使用的那個庫。 那是整個清單嗎? 您甚至應該手動創建Client實例嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM