Esempio n. 1
0
 protected override Task OnReceivedAsync(IRequest request, string connectionId, string data)
 {
     string userName = HttpContext.Current.User != null ? HttpContext.Current.User.Identity.Name : string.Empty;
     ProgressState ps = new ProgressState();
     //try
     //{
         ActionData ad = jns.Parse<ActionData>(data);
         //start:开始分配;stop:停止分配
         switch (ad.ActionType)
         {
             case "start":
                 Execute(connectionId,data,ps,GetCancellationTokenSource(connectionId).Token,userName);
                 break;
             case "stop":
                 GetCancellationTokenSource(connectionId).Cancel();
                 ps.State = StateType.Stop;
                 return Connection.Send(connectionId, ps.Clone());
             default:
                 break;
         }
     //}
     //catch (Exception e)
     //{
     //    ps.State = StateType.Error;
     //    ps.Messages.Add(e.Message);
     //}
     if (GetCancellationTokenSource(connectionId).Token.IsCancellationRequested)
     {
         ps.Messages.Clear();
         ps.Errors.Clear();
         ps.Messages.Add("用户已中止当前处理!");
     }
     ps.State = StateType.Complete;
     return Connection.Send(connectionId, ps.Clone());
 }
 protected override void Execute(string connectionId, string data, ProgressState ps, CancellationToken cancellationToken,string userName)
 {
     ActionData ad = jns.Parse<ActionData>(data);
     OutBillAllotService.Allot(connectionId, ps, cancellationToken, ad.BillNo, ad.AreaCodes);
 }
Esempio n. 3
0
 protected virtual void Execute(string connectionId, string data, ProgressState ps, CancellationToken cancellationToken,string userName)
 {
     throw new NotImplementedException();
 }