public ProgressObj(Guid requestId, DateTimeOffset created, ProgressObj lastProgress, RequestBase request) : this(requestId, created, lastProgress, request.RequesterId) { if (request.RequestDescription != null) { Description = request.RequestDescription; } if (request.SubmitTime != null) { Submitted = DateTimeOffset.Parse(request.SubmitTime); } }
public ProgressObj(Guid requestId, DateTimeOffset created, ProgressObj lastProgress, ResponseBase response) : this(requestId, created, lastProgress, response.RequesterId) { if (response.FaultDetail != null) { ExcpName = response.FaultDetail.ShortName; ExcpText = response.FaultDetail.Message; } // response subtypes HandlerResponse handlerResponse = response as HandlerResponse; if (handlerResponse != null) { if (response.Status == RequestStatusEnum.Undefined) { throw new ArgumentNullException("status"); } HandlerStatus = response.Status; if (handlerResponse.CommenceTime != null) { Commenced = DateTimeOffset.Parse(handlerResponse.CommenceTime); } ItemCount = handlerResponse.ItemCount; ItemsPassed = handlerResponse.ItemsPassed; ItemsFailed = handlerResponse.ItemsFailed; } WorkerResponse workerResponse = response as WorkerResponse; if (workerResponse != null) { if (response.Status == RequestStatusEnum.Undefined) { throw new ArgumentNullException("status"); } WorkerStatus = response.Status; WorkerHost = String.Format("{0}.{1}", workerResponse.WorkerHostComputer, workerResponse.WorkerHostInstance ?? "Default"); } ManagerResponse managerResponse = response as ManagerResponse; if (managerResponse != null) { if (response.Status == RequestStatusEnum.Undefined) { throw new ArgumentNullException("status"); } ManagerStatus = response.Status; } }
private ProgressObj(Guid requestId, DateTimeOffset created, ProgressObj lastProgress, UserIdentity userIdentity) { if (requestId.Equals(new Guid("7281fcfe-983f-42ab-8068-51d21b292b1e"))) { RequestId = requestId; } else { RequestId = requestId; } if (!Created.HasValue || (created < Created.Value)) { Created = created; } if (!Updated.HasValue || (created > Updated.Value)) { Updated = created; } if (lastProgress != null) { RequestId = lastProgress.RequestId; RequesterId = lastProgress.RequesterId; RequesterName = lastProgress.RequesterName; Description = lastProgress.Description; Submitted = lastProgress.Submitted; Commenced = lastProgress.Commenced; ManagerStatus = lastProgress.ManagerStatus; WorkerStatus = lastProgress.WorkerStatus; WorkerHost = lastProgress.WorkerHost; HandlerStatus = lastProgress.HandlerStatus; ItemCount = lastProgress.ItemCount; ItemsPassed = lastProgress.ItemsPassed; ItemsFailed = lastProgress.ItemsFailed; } if (userIdentity != null) { RequesterId = userIdentity.Name; RequesterName = userIdentity.DisplayName; } }
private void ProgressCallback(ISubscription subscription, ICoreItem item) { try { ProgressObj oldProgress = null; ProgressObj newProgress = null; if (item != null) { // get old request view object Guid requestId = item.AppProps.GetValue <Guid>(RequestBase.Prop.RequestId, true); oldProgress = _ProgressCache.Remove(requestId); // build the new request view object if (item.IsCurrent()) { if (item.DataType.IsSubclassOf(typeof(RequestBase))) { RequestBase request = item.Data as RequestBase; if (request != null) { newProgress = new ProgressObj(requestId, item.Created, oldProgress, request); } } else if (item.DataType.IsSubclassOf(typeof(ResponseBase))) { ResponseBase response = item.Data as ResponseBase; if (response != null) { newProgress = new ProgressObj(requestId, item.Created, oldProgress, response); } } else { throw new NotSupportedException(String.Format("Type: '{0}'", item.DataType.Name)); } } if (newProgress != null) { _ProgressCache.Set(requestId, newProgress); } } else { throw new ArgumentNullException("item"); } // determine the change type CacheChange change = CacheChange.Undefined; if (oldProgress != null) { // updated or deleted if (newProgress != null) { change = CacheChange.ItemUpdated; } else { change = CacheChange.ItemRemoved; } } else { // created or ??? if (newProgress != null) { change = CacheChange.ItemCreated; } } if (change != CacheChange.Undefined) { _ProgressView.UpdateData(new ViewChangeNotification <ProgressObj>() { Change = change, OldData = oldProgress, NewData = newProgress }); } } catch (Exception excp) { _MainLog.Log(excp); } }