コード例 #1
0
        public GetLongIdResponse ImportContainer(ImportContainerRequest request)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.ImportContainer(request);
            return(response);
        }
コード例 #2
0
        private void ImportContainer(KeyValuePair <int, List <ExcelRowData> > kvp, ExcelPicture img)
        {
            //check for presence of plantName - add if not present
            long containerNameId = 0;

            int column = columnIndicesAndNames.Where(a => a.Value == "CONTAINER NAME").Select(b => b.Key).First();

            string containerName = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            string result = Get("DoesContainerNameExist", "containerName=" + containerName);

            GetLongIdResponse r = JsonConvert.DeserializeObject <GetLongIdResponse>(result);

            containerNameId = r.returnedId;

            //check for presence of plantType - add if not present

            column = columnIndicesAndNames.Where(a => a.Value.ToUpper() == "SIZE").Select(b => b.Key).First();

            string containerSize = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            long containerTypeId = 0;

            column = columnIndicesAndNames.Where(a => a.Value == "TYPE").Select(b => b.Key).First();

            string containerType = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            result = Get("DoesContainerTypeExist", "containerType=" + containerType);

            r = JsonConvert.DeserializeObject <GetLongIdResponse>(result);
            containerTypeId = r.returnedId;

            ////using cost, retail, plantName and plant Type, check for presence of service code - add if not present

            //ServiceCodeDTO serviceCode = GetServiceCodeDTO(kvp);

            //string jsonData = JsonConvert.SerializeObject(serviceCode);
            //var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

            //result = Post("DoesServiceCodeExist", content);

            long serviceCodeId = 0;

            column = columnIndicesAndNames.Where(a => a.Value == "CODE").Select(b => b.Key).First();

            string serviceCode = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            result = Get("ServiceCodeIsNotUnique", "serviceCode=" + serviceCode);

            r             = JsonConvert.DeserializeObject <GetLongIdResponse>(result);
            serviceCodeId = r.returnedId;

            //check for presence of plant - add if not present

            long containerId = 0;

            ContainerDTO containerDTO = GetContainerDTO(kvp);

            string        jsonData = JsonConvert.SerializeObject(containerDTO);
            StringContent content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            result = Post("DoesContainerExist", content);

            r           = JsonConvert.DeserializeObject <GetLongIdResponse>(result);
            containerId = r.returnedId;

            //check for presence of inventory - add if not present

            ImportContainerRequest request = new ImportContainerRequest();

            //add image if present
            if (img != null)
            {
                ImageConverter imgCon = new ImageConverter();
                request.imageBytes = (byte[])imgCon.ConvertTo(img.Image, typeof(byte[]));
            }

            //create DTO - send to service - backend will do the hookup
            request.ContainerSize = containerSize;

            if (containerNameId == 0)
            {
                request.ContainerName = containerName;
            }
            else
            {
                request.AddContainerRequest.Container.ContainerNameId = containerNameId;
            }

            if (containerTypeId == 0)
            {
                request.ContainerType = containerType;
            }
            else
            {
                request.AddContainerRequest.Container.ContainerTypeId = containerTypeId;
            }


            request.ServiceCode = GetServiceCodeDTO(kvp);

            if (serviceCodeId > 0)
            {
                ServiceCodeDTO original = GetServiceCodeById(serviceCodeId);
                UpdateServiceCode(original, request.ServiceCode);
                request.ServiceCode = original;
                request.ServiceCode.ServiceCodeId = serviceCodeId;
                request.AddContainerRequest.Inventory.ServiceCodeId = serviceCodeId;
            }

            jsonData = JsonConvert.SerializeObject(request);
            content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            Post("ImportContainer", content);
        }
コード例 #3
0
 public long ImportContainer(ImportContainerRequest request)
 {
     return(persistence.ImportContainer(request));
 }