Ejemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            OperationSource os = this.sourceAttachmentTasks.GetOperationSource(id);

            if (os != null)
            {
                OperationSourceViewModel vm = new OperationSourceViewModel(os);
                vm.PopulateDropDowns(this.sourceTasks.GetReliabilities());
                vm.PopulateSource(this.sourceTasks.GetSourceDTO(os.Source.Id));
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
Ejemplo n.º 2
0
 public VSActionsTelemetryEvent(
     string[] projectIds,
     NuGetOperationType operationType,
     OperationSource source,
     DateTimeOffset startTime,
     NuGetOperationStatus status,
     int packageCount,
     DateTimeOffset endTime,
     double duration) :
     base(projectIds, operationType, startTime, status, packageCount, endTime, duration)
 {
     base[nameof(Source)] = source;
 }
Ejemplo n.º 3
0
 public ActionsTelemetryEvent(
     string operationId,
     string[] projectIds,
     NuGetOperationType operationType,
     OperationSource source,
     DateTimeOffset startTime,
     NuGetOperationStatus status,
     int packageCount,
     DateTimeOffset endTime,
     double duration) : base(operationId, projectIds, startTime, status, packageCount, endTime, duration)
 {
     OperationType = operationType;
     Source        = source;
 }
Ejemplo n.º 4
0
 public OperationSourceViewModel(OperationSource os)
 {
     this.Id = os.Id;
     if (os.Operation != null)
     {
         this.OperationId   = os.Operation.Id;
         this.OperationName = os.Operation.Name;
     }
     if (os.Reliability != null)
     {
         this.ReliabilityId   = os.Reliability.Id;
         this.ReliabilityName = os.Reliability.ToString();
     }
     this.Commentary = os.Commentary;
     this.Notes      = os.Notes;
 }
Ejemplo n.º 5
0
 public VSActionsTelemetryEvent(
     string operationId,
     string[] projectIds,
     NuGetOperationType operationType,
     OperationSource source,
     DateTimeOffset startTime,
     NuGetOperationStatus status,
     int packageCount,
     DateTimeOffset endTime,
     double duration,
     bool isPackageSourceMappingEnabled) :
     base(operationId, projectIds, operationType, startTime, status, packageCount, endTime, duration)
 {
     base[nameof(Source)] = source;
     base[PackageSourceMappingIsMappingEnabled] = isPackageSourceMappingEnabled;
 }
Ejemplo n.º 6
0
        public NameIdClassModel GetCategoryWithCurrentName(string nameParam)
        {
            using (_unitOfWork = DIManager.UnitOfWork)
            {
                OperationSource contextSource = _unitOfWork.PersonalAccountantContext.Set <OperationSource>().FirstOrDefault(x => x.Name.ToUpper() == nameParam.ToUpper());
                if (contextSource == null)
                {
                    int Id = 0;
                    contextSource = Int32.TryParse(nameParam, out Id) ?
                                    _unitOfWork.PersonalAccountantContext.Set <OperationSource>().FirstOrDefault(x => x.Id == Id) :
                                    CreateNewInstance(nameParam);
                }

                return(_mapperManager.MapModel <OperationSource, NameIdClassModel>(contextSource));
            }
        }
Ejemplo n.º 7
0
        public JsonNetResult Delete(int id)
        {
            OperationSource os = this.sourceAttachmentTasks.GetOperationSource(id);

            if (os != null)
            {
                this.sourceAttachmentTasks.DeleteOperationSource(os.Id);
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(JsonNet("Source successfully detached from operation."));
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(JsonNet("Operation source not found."));
            }
        }
Ejemplo n.º 8
0
 public JsonNetResult Add(OperationSourceViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Source    s = this.sourceTasks.GetSource(vm.SourceId.Value);
         Operation o = this.orgTasks.GetOperation(vm.OperationId.Value);
         if (s != null && o != null)
         {
             if (s.GetOperationSource(o) == null)
             {
                 OperationSource os = new OperationSource()
                 {
                     Source     = s,
                     Operation  = o,
                     Commentary = vm.Commentary,
                     Notes      = vm.Notes
                 };
                 if (vm.ReliabilityId.HasValue)
                 {
                     os.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
                 }
                 this.sourceAttachmentTasks.SaveOperationSource(os);
                 return(JsonNet(string.Empty));
             }
             else
             {
                 Response.StatusCode = (int)HttpStatusCode.BadRequest;
                 return(JsonNet("Source already attached to this operation."));
             }
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Operation or source not found."));
         }
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
        public void ActionsTelemetryService_EmitActionEvent_OperationFailed(NuGetOperationType operationType, OperationSource source)
        {
            // Arrange
            var            telemetrySession   = new Mock <ITelemetrySession>();
            TelemetryEvent lastTelemetryEvent = null;

            telemetrySession
            .Setup(x => x.PostEvent(It.IsAny <TelemetryEvent>()))
            .Callback <TelemetryEvent>(x => lastTelemetryEvent = x);

            var operationId = Guid.NewGuid().ToString();

            var actionTelemetryData = new VSActionsTelemetryEvent(
                operationId,
                projectIds: new[] { Guid.NewGuid().ToString() },
                operationType: operationType,
                source: source,
                startTime: DateTimeOffset.Now.AddSeconds(-2),
                status: NuGetOperationStatus.Failed,
                packageCount: 1,
                endTime: DateTimeOffset.Now,
                duration: 1.30);
            var service = new NuGetVSTelemetryService(telemetrySession.Object);

            // Act
            service.EmitTelemetryEvent(actionTelemetryData);

            // Assert
            VerifyTelemetryEventData(operationId, actionTelemetryData, lastTelemetryEvent);
        }
Ejemplo n.º 10
0
 public OperationSource SaveOperationSource(OperationSource us)
 {
     us.Operation.AddOperationSource(us);
     us.Source.AddOperationSource(us);
     return(this.operationSourceRepo.SaveOrUpdate(us));
 }
Ejemplo n.º 11
0
 public virtual void RemoveOperationSource(OperationSource os)
 {
     this.OperationSources.Remove(os);
 }