예제 #1
0
        public static void PackingStreamingAssetsFolder(string pathToSourceFolder, string pathToOutPackingFile)
        {
            List <string> filesInDirs = new List <string>();

            GetAllFileInFolderRecursive(filesInDirs, pathToSourceFolder, new[] { ".meta" });

            foreach (var filesInDir in filesInDirs)
            {
                Debug.Log(filesInDir);
            }

            PackingData packingData = new PackingData();

            foreach (var filePath in filesInDirs)
            {
                string finalPath = filePath.Replace(pathToSourceFolder + "\\", "").Replace("\\", "/");
                packingData.filesDictionary[finalPath] = File.ReadAllBytes(filePath);
            }

            string outString = PackingDataSerializer.SerializeToString(packingData);

            File.WriteAllText(pathToOutPackingFile, outString);

            AssetDatabase.Refresh();
        }
예제 #2
0
        public virtual async Task Should_Success_UpdateFromNextAreaInputPackingAsync()
        {
            string testName  = GetCurrentMethod() + "UpdateFromNextAreaInputPackingAsync";
            var    dbContext = DbContext(testName);

            var serviceProvider = GetServiceProviderMock(dbContext);

            var repo      = new DyeingPrintingAreaInputProductionOrderRepository(dbContext, serviceProvider.Object);
            var repo2     = new DyeingPrintingAreaInputProductionOrderRepository(dbContext, serviceProvider.Object);
            var emptyData = DataUtil(repo, dbContext).GetEmptyModel();

            emptyData.SetArea("PACKING", "", "");
            emptyData.SetBalanceRemains(4, "", "");
            emptyData.SetBalance(4, "", "");
            await repo.InsertAsync(emptyData);

            var packingData = new PackingData()
            {
                Id      = emptyData.Id,
                Balance = 4
            };
            var result = await repo2.UpdateFromNextAreaInputPackingAsync(new List <PackingData>() { packingData });

            Assert.NotEqual(0, result);
        }
예제 #3
0
        public virtual async Task Should_Success_RestorePacking()
        {
            string testName  = GetCurrentMethod() + "RestorePacking";
            var    dbContext = DbContext(testName);

            var serviceProvider = GetServiceProviderMock(dbContext);

            var repo      = new DyeingPrintingAreaInputProductionOrderRepository(dbContext, serviceProvider.Object);
            var repo2     = new DyeingPrintingAreaInputProductionOrderRepository(dbContext, serviceProvider.Object);
            var emptyData = DataUtil(repo, dbContext).GetEmptyModel();

            emptyData.SetArea("PACKING", "", "");
            emptyData.SetBalanceRemains(4, "", "");
            emptyData.SetBalance(4, "", "");
            emptyData.SetDateOut(DateTimeOffset.Now, "", "");
            emptyData.SetInputPackagingQty(5, "", "");
            await repo.InsertAsync(emptyData);

            var packingData = new PackingData()
            {
                Id      = emptyData.Id,
                Balance = 4
            };
            var result = await repo2.RestorePacking("INSPECTION MATERIAL", new List <PackingData>() { packingData });

            Assert.NotEqual(0, result);
        }
        public async Task <Tuple <int, List <PackingData> > > UpdatePackingFromOut(string destinationArea, string productionOrderNo, string grade, double balance)
        {
            var data = _dbSet.Where(s => s.Area == DyeingPrintingArea.PACKING && s.ProductionOrderNo == productionOrderNo && s.Grade == grade &&
                                    s.BalanceRemains > 0).Include(s => s.DyeingPrintingAreaInput).OrderBy(s => s.DyeingPrintingAreaInput.Date).ToList();

            int index       = 0;
            var packingData = new List <PackingData>();

            while (balance > 0)
            {
                var item = data.ElementAtOrDefault(index);

                if (item != null)
                {
                    var previousPacking = new PackingData()
                    {
                        Id = item.Id
                    };

                    double diffBalance        = 0;
                    var    tempBalanceRemains = item.BalanceRemains - balance;
                    var    tempBalance        = item.Balance - balance;

                    if (tempBalanceRemains < 0)
                    {
                        balance     = tempBalanceRemains * -1;
                        diffBalance = item.BalanceRemains;
                        item.SetBalanceRemains(0, _identityProvider.Username, UserAgent);
                        if (destinationArea == DyeingPrintingArea.INSPECTIONMATERIAL)
                        {
                            item.SetBalance(0, _identityProvider.Username, UserAgent);
                        }
                        item.SetHasOutputDocument(true, _identityProvider.Username, UserAgent);
                    }
                    else
                    {
                        diffBalance = balance;
                        item.SetBalanceRemains(tempBalanceRemains, _identityProvider.Username, UserAgent);
                        if (destinationArea == DyeingPrintingArea.INSPECTIONMATERIAL)
                        {
                            item.SetBalance(tempBalance, _identityProvider.Username, UserAgent);
                        }
                        if (tempBalanceRemains == 0)
                        {
                            item.SetHasOutputDocument(true, _identityProvider.Username, UserAgent);
                        }
                        else
                        {
                            item.SetHasOutputDocument(false, _identityProvider.Username, UserAgent);
                        }
                        balance = 0;
                    }

                    previousPacking.Balance = diffBalance;

                    packingData.Add(previousPacking);

                    index++;
                }
                else
                {
                    break;
                }
            }

            int result = await _dbContext.SaveChangesAsync();

            return(new Tuple <int, List <PackingData> >(result, packingData));
        }