private void SetCratesForSaving(ActivityDTO saveToFr8WarehouseActivity)
        {
            CrateStorageDTO crateStorageDTO = saveToFr8WarehouseActivity.CrateStorage;
            var             _crateManager   = ObjectFactory.GetInstance <ICrateManager>();
            var             crateStorage    = _crateManager.FromDto(crateStorageDTO);
            var             configControlCM = crateStorage
                                              .CrateContentsOfType <StandardConfigurationControlsCM>()
                                              .First();
            var upstreamCrateChooser    = (UpstreamCrateChooser)configControlCM.FindByName("UpstreamCrateChooser");
            var existingDdlbSource      = upstreamCrateChooser.SelectedCrates[0].ManifestType.Source;
            var existingLabelDdlb       = upstreamCrateChooser.SelectedCrates[0].Label;
            var standardPayloadManifest = new DropDownList
            {
                selectedKey = Fr8.Infrastructure.Data.Constants.MT.StandardEmailMessage.ToString(),
                Value       = ((int)Fr8.Infrastructure.Data.Constants.MT.StandardEmailMessage).ToString(),
                Name        = "UpstreamCrateChooser_mnfst_dropdown_0",
                Source      = existingDdlbSource
            };

            upstreamCrateChooser.SelectedCrates = new List <CrateDetails>
            {
                new CrateDetails {
                    ManifestType = standardPayloadManifest, Label = existingLabelDdlb
                }
            };

            saveToFr8WarehouseActivity.CrateStorage = _crateManager.ToDto(crateStorage);
        }
        public static ICrateStorage GetStorage(this ICrateManager crateManager, CrateStorageDTO crateStorageDTO)
        {
            if (crateStorageDTO == null)
            {
                return(new CrateStorage());
            }

            return(crateManager.FromDto(crateStorageDTO));
        }
示例#3
0
        public bool IsEmptyStorage(CrateStorageDTO rawStorage)
        {
            if (rawStorage == null)
            {
                return(true);
            }

            return(FromDto(rawStorage).Count == 0);
        }
 private static void CheckStorageDTOs(CrateStorageDTO a, CrateStorageDTO b)
 {
     foreach (var crateDto in a.Crates)
     {
         var dto = crateDto;
         Assert.NotNull(b.Crates.FirstOrDefault(x => x.Label == dto.Label &&
                                                x.Id == dto.Id &&
                                                x.ManifestType == dto.ManifestType &&
                                                x.ManifestId == dto.ManifestId &&
                                                JToken.DeepEquals(x.Contents, dto.Contents)));
     }
 }
示例#5
0
        private static CrateStorageDTO GetKnownManifestsStorageDto(string key = "value")
        {
            var storage = new CrateStorageDTO
            {
                Crates = new[]
                {
                    TestKnownCrateDto("id1", key + "1"),
                    TestKnownCrateDto("id2", key + "2"),
                }
            };

            return(storage);
        }
示例#6
0
        private static CrateStorageDTO GetUnknownManifestsStorageDto()
        {
            var storage = new CrateStorageDTO
            {
                Crates = new[]
                {
                    TestUnknownCrateDto("id1", "value1"),
                    TestUnknownCrateDto("id2", "value2"),
                }
            };

            return(storage);
        }
        /**********************************************************************************/
        /// <summary>
        /// Convert CrateStorageDTO to CrateStorage
        /// </summary>
        /// <param name="rawStorage"></param>
        /// <returns></returns>
        public ICrateStorage ConvertFromDto(CrateStorageDTO rawStorage)
        {
            var storage = new CrateStorage();

            if (rawStorage != null && rawStorage.Crates != null)
            {
                foreach (var crateDto in rawStorage.Crates)
                {
                    storage.Add(ConvertFromDto(crateDto));
                }
            }

            return(storage);
        }
        /**********************************************************************************/
        /// <summary>
        /// Convert CrateStorage to DTO
        /// </summary>
        /// <param name="storage"></param>
        /// <returns></returns>
        public CrateStorageDTO ConvertToDto(ICrateStorage storage)
        {
            var storageSerializationProxy = new CrateStorageDTO
            {
                Crates = new CrateDTO[storage.Count]
            };

            int id = 0;

            foreach (var crate in storage)
            {
                storageSerializationProxy.Crates[id] = ConvertToDto(crate);
                id++;
            }

            return(storageSerializationProxy);
        }
示例#9
0
        public IHttpActionResult Post(CrateStorageDTO crateStorageDto)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var crateStorage = CrateStorageSerializer.Default.ConvertFromDto(crateStorageDto);
                var userId       = User.Identity.GetUserId();

                foreach (var crate in crateStorage)
                {
                    if (crate.IsKnownManifest)
                    {
                        uow.MultiTenantObjectRepository.AddOrUpdate(userId, (Manifest)crate.Get());
                    }
                }

                uow.SaveChanges();
            }
            return(Ok());
        }
示例#10
0
        public string GetFieldByKey <T>(CrateStorageDTO curCrateStorage, string findKey) where T : Manifest
        {
            string key = string.Empty;

            if (curCrateStorage != null)
            {
                var crateStorage     = this.FromDto(curCrateStorage);
                var crateContentType = crateStorage.CrateContentsOfType <T>().FirstOrDefault();

                if (crateContentType != null)
                {
                    if (crateContentType is StandardPayloadDataCM)
                    {
                        (crateContentType as StandardPayloadDataCM).TryGetValue(findKey, true, false, out key);
                    }
                    else
                    {
                        throw new Exception("Manifest type GetFieldByKey implementation is missing");
                    }
                }
            }

            return(key);
        }
示例#11
0
 public string CrateStorageAsStr(CrateStorageDTO storageDTO)
 {
     return(JsonConvert.SerializeObject(storageDTO));
 }
示例#12
0
 public ICrateStorage FromDto(CrateStorageDTO crateStorage)
 {
     return(CrateStorageSerializer.Default.ConvertFromDto(crateStorage));
 }