Ejemplo n.º 1
0
        /// <summary>
        /// Constructs a new Lumina object allowing access to game data.
        /// </summary>
        /// <param name="dataPath">Path to the sqpack directory</param>
        /// <param name="options">Options object to provide additional configuration</param>
        /// <exception cref="DirectoryNotFoundException">Thrown when the sqpack directory supplied is missing.</exception>
        public Lumina(string dataPath, LuminaOptions options = null)
        {
            Options = options ?? new LuminaOptions();

            DataPath = new DirectoryInfo(dataPath);

            if (!DataPath.Exists)
            {
                throw new DirectoryNotFoundException("DataPath provided is missing.");
            }

            if (DataPath.Name != "sqpack")
            {
                throw new ArgumentException("the data path arg must point to the sqpack directory", nameof(dataPath));
            }

            Repositories = new Dictionary <string, Repository>();
            foreach (var repo in DataPath.GetDirectories())
            {
                Repositories[repo.Name.ToLowerInvariant()] = new Repository(repo, this);
            }

            Excel             = new ExcelModule(this);
            FileHandleManager = new FileHandleManager(this);
        }
Ejemplo n.º 2
0
        private void ComboBoxSelectionChangedExecute()
        {
            string priviousTextile = SelectedTextile;

            TextileColorList = null;
            TextileList      = null;
            RaisePropertyChanged("TextileColorList");
            RaisePropertyChanged("TextileList");
            List <string> textileList = new List <string>();

            if (!_workbookDictionary.TryGetValue(FileName, out IWorkbook dictionaryWorkbook))
            {
                string fileNamePath = string.Concat(AppSettingConfig.InventoryHistoryRecordFilePath(), "/", FileName);
                Tuple <List <string>, IWorkbook> tuple = ExcelModule.GetExcelWorkbook(fileNamePath);
                TextileList = tuple.Item1;
                GetShippingDate(tuple.Item2.GetSheetAt(1));
                _workbookDictionary.Add(FileName, tuple.Item2);
            }
            else
            {
                for (int sheetCount = 1; sheetCount < dictionaryWorkbook.NumberOfSheets; sheetCount++)
                {
                    ISheet sheet = dictionaryWorkbook.GetSheetAt(sheetCount);  //獲取第i個工作表
                    textileList.Add(sheet.SheetName);
                }
                TextileList = textileList;
                GetShippingDate(dictionaryWorkbook.GetSheetAt(1));
            }
            RaisePropertyChanged("TextileList");
            SelectedTextile = priviousTextile;
            RaisePropertyChanged("SelectedTextile");
        }
Ejemplo n.º 3
0
        public List <StoreSearchData <StoreSearchColorDetail> > CreateStoreSearchListByShipped()
        {
            List <StoreSearchData <StoreSearchColorDetail> > storeSearchDatas = ExcelModule.GetExcelDailyShippedList(ShippingHistoryDate);

            foreach (StoreSearchData <StoreSearchColorDetail> item in storeSearchDatas)
            {
                if (item.StoreSearchColorDetails.Count() == 0)
                {
                    continue;
                }
                ShippingHistoryStoreDataList.Add(new StoreData
                {
                    TextileName = item.TextileName,
                });
                foreach (StoreSearchColorDetail color in item.StoreSearchColorDetails)
                {
                    ShippingHistoryStoreDataList.Add(new StoreData
                    {
                        ColorName      = color.ColorName,
                        FabricFactory  = color.FabricFactory,
                        ClearFactory   = color.ClearFactory,
                        ShippedCount   = color.ShippedCount,
                        CountInventory = color.CountInventory,
                        CheckDate      = color.CheckDate,
                    });
                }
            }
            return(storeSearchDatas);
        }
Ejemplo n.º 4
0
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox           checkBox           = (CheckBox)sender;
            ExternalDataHelper externalDataHelper = new ExternalDataHelper();

            TextileNameMappings = externalDataHelper.GetTextileNameMappings();
            if (checkBox.IsChecked ?? false)
            {
                string fileNamePath = string.Concat(AppSettingConfig.FilePath(), "/", AppSettingConfig.StoreManageFileName());
                Tuple <List <string>, IWorkbook> tuple = ExcelModule.GetExcelWorkbook(fileNamePath);
                TextileInventoryHeader           textileInventoryHeader = ExcelModule.GetShippingDate(tuple.Item2.GetSheetAt(1));
                Workbook = tuple.Item2;
                Window parentWindow = Window.GetWindow(this);

                var textileNameMapping = TextileNameMappings.ToList().Find(f => f.ProcessOrder.Contains(ProcessOrder == null ? string.Empty : ProcessOrder.Fabric));
                List <TextileColorInventory> selectedTextiles = new List <TextileColorInventory>();
                if (textileNameMapping != null)
                {
                    ExcelHelper excelHelper = new ExcelHelper();
                    foreach (var item in textileNameMapping.Inventory)
                    {
                        selectedTextiles.AddRange(excelHelper.GetInventoryData(Workbook, item));
                    }
                    textileInventoryHeader.Textile = ProcessOrder.Fabric;
                }

                InventoryListDialog = new InventoryListDialog(AppSettingConfig.StoreManageFileName(), textileInventoryHeader, selectedTextiles)
                {
                    Owner  = Window.GetWindow(this),
                    Top    = parentWindow.Top + parentWindow.Height,
                    Left   = parentWindow.Left,
                    Height = 300
                };
                InventoryListDialog.Show();
                InventoryListDialog.Closed += InventoryListDialog_Closed;


                InventoryUpdateTime.Content = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");
            }
            else
            {
                InventoryListDialog.Close();
            }
        }
Ejemplo n.º 5
0
        //private void OnComboBoxCustomerLoad()
        //{
        //    ComboBoxCustomer.Loaded += (ls, le) =>
        //    {
        //        TextBox targetTextBox = ComboBoxCustomer?.Template.FindName("PART_EditableTextBox", ComboBoxCustomer) as TextBox;

        //        if (targetTextBox == null) return;

        //        ComboBoxCustomer.Tag = "TextInput";
        //        ComboBoxCustomer.StaysOpenOnEdit = true;
        //        ComboBoxCustomer.IsEditable = true;
        //        ComboBoxCustomer.IsTextSearchEnabled = false;

        //        targetTextBox.TextChanged += (o, args) =>
        //        {
        //            if (ComboBoxCustomer.Tag.ToString() == "Selection")
        //            {
        //                ComboBoxCustomer.Tag = "TextInput";
        //                ComboBoxCustomer.IsDropDownOpen = true;
        //            }
        //            else
        //            {
        //                TextBox textBox = (TextBox)o;
        //                string searchText = textBox.Text;

        //                if (ComboBoxCustomer.SelectionBoxItem != null)
        //                {
        //                    //ComboBoxCustomer.SelectedItem = null;
        //                    targetTextBox.Text = searchText;
        //                    ComboBoxCustomer.IsDropDownOpen = true;
        //                    targetTextBox.SelectionStart = targetTextBox.Text.Length;
        //                }

        //                if (string.IsNullOrEmpty(searchText))
        //                {
        //                    ComboBoxCustomer.Items.Filter = item => true;
        //                    ComboBoxCustomer.SelectedItem = default(object);
        //                }
        //                else
        //                {
        //                    ComboBoxCustomer.Items.Filter = item =>
        //                            ((Customer)item).Name.Contains(searchText);
        //                }
        //                ComboBoxCustomer.IsDropDownOpen = true;
        //                targetTextBox.SelectionStart = targetTextBox.Text.Length;
        //            }
        //        };

        //        ComboBoxCustomer.SelectionChanged += (o, args) =>
        //        {
        //            ComboBox comboBox = o as ComboBox;
        //            if (comboBox?.SelectedItem == null) return;
        //            comboBox.Tag = "Selection";
        //        };
        //    };
        //}
        #endregion

        private void DataGridProcessOrder_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid dataGridProcessOrder = (DataGrid)sender;

            if (dataGridProcessOrder.SelectedIndex == -1)
            {
                return;
            }
            ProcessOrder = dataGridProcessOrder.SelectedItem as ProcessOrder;
            IEnumerable <ProcessOrderCustomerRelate> customerOrderRelate = ProcessModule.GetCustomerByOrderNo(ProcessOrder.OrderNo);

            DataGridCustomerOrder.ItemsSource = customerOrderRelate;

            TextRange remark = new TextRange(RichTextBoxProcessOrderRemark.Document.ContentStart, RichTextBoxProcessOrderRemark.Document.ContentEnd)
            {
                Text = ProcessOrder.Remark ?? ""
            };

            UpdateDataGridOrderColorFactoryShippingDetail(ProcessOrder.OrderNo);

            DataGridFactoryShipping.ItemsSource            = null;
            DataGridProcessOrderFlowDateDetail.ItemsSource = null;

            if (CheckboxDisplayInventory.IsChecked ?? false)
            {
                var textileNameMapping = TextileNameMappings.ToList().Find(f => f.ProcessOrder.Contains(ProcessOrder.Fabric));
                if (textileNameMapping == null)
                {
                    InventoryListDialog.ChangeDataContext(null, null);
                    return;
                }
                ExcelHelper excelHelper = new ExcelHelper();
                List <TextileColorInventory> selectedTextiles = new List <TextileColorInventory>();
                foreach (var item in textileNameMapping.Inventory)
                {
                    selectedTextiles.AddRange(excelHelper.GetInventoryData(Workbook, item));
                }
                TextileInventoryHeader textileInventoryHeader = ExcelModule.GetShippingDate(Workbook.GetSheetAt(1));
                textileInventoryHeader.Textile = ProcessOrder.Fabric;
                InventoryListDialog.ChangeDataContext(textileInventoryHeader, selectedTextiles);
            }
        }
Ejemplo n.º 6
0
 public void GetShippingDate(ISheet sheet)
 {
     TextileInventoryHeader = ExcelModule.GetShippingDate(sheet);
     RaisePropertyChanged("TextileInventoryHeader");
 }
Ejemplo n.º 7
0
 public ExcelModuleTests()
 {
     this.excelModule = new ExcelModule();
     this.filesPath   = $@"{Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName}{Path.DirectorySeparatorChar}SourceFiles";
 }
Ejemplo n.º 8
0
        private void ExportShippingCheckExecute()
        {
            List <StoreSearchData <StoreSearchColorDetail> > excelDailyShippedList = ExcelModule.GetExcelDailyShippedList(ShippingCheckDate);
            IEnumerable <TrashShipped>       trashShipped        = TrashModule.GetTrashShippedQuantitySum(ShippingCheckDate, ShippingCheckDate);
            ExternalDataHelper               externalDataHelper  = new ExternalDataHelper();
            IEnumerable <TextileNameMapping> textileNameMappings = externalDataHelper.GetTextileNameMappings();

            List <OriginalSource> trashItems = new List <OriginalSource>();

            foreach (TrashShipped shipped in trashShipped)
            {
                trashItems.Add(new OriginalSource
                {
                    DateTime         = shipped.IN_DATE,
                    TextileNo        = shipped.I_01,
                    TextileColorName = shipped.I_03,
                    Weight           = shipped.Quantity
                });
            }
            List <Container> trashPrimary = new List <Container>();

            foreach (OriginalSource trashItem in trashItems)
            {
                int    priviousDistance = 10;
                string textileName      = string.Empty;
                string textileColor     = string.Empty;
                int    shippedCount     = 0;
                foreach (StoreSearchData <StoreSearchColorDetail> excelDailyShippedItem in excelDailyShippedList)
                {
                    TextileNameMapping textileNameMapping = textileNameMappings.ToList().Find(f => f.Inventory.Contains(excelDailyShippedItem.TextileName)) ?? new TextileNameMapping();
                    foreach (StoreSearchColorDetail colorDetail in excelDailyShippedItem.StoreSearchColorDetails)
                    {
                        string accountMapping = textileNameMapping.Account == null ? string.Empty : textileNameMapping.Account.FirstOrDefault();
                        if (trashItem.TextileColorName == string.Concat(accountMapping.Split('*')[0], colorDetail.ColorName.Split('-')[0]))
                        {
                            textileColor     = colorDetail.ColorName;
                            textileName      = excelDailyShippedItem.TextileName;
                            priviousDistance = 0;
                            shippedCount     = colorDetail.ShippedCount;
                            break;
                        }
                    }
                }
                trashPrimary.Add(new Container()
                {
                    OriginalSource = trashItem,
                    TextileName    = textileName,
                    ColorName      = textileColor,
                    ShippedCount   = shippedCount,
                    Distance       = priviousDistance
                });
            }

            List <Container> excelPrimary = new List <Container>();

            foreach (StoreSearchData <StoreSearchColorDetail> excelDailyShippedItem in excelDailyShippedList)
            {
                var priviousDistance = 10;
                var textileName      = string.Empty;
                var textileColor     = string.Empty;
                foreach (var colorDetail in excelDailyShippedItem.StoreSearchColorDetails)
                {
                    TextileNameMapping textileNameMapping = textileNameMappings.ToList().Find(f => f.Inventory.Contains(excelDailyShippedItem.TextileName)) ?? new TextileNameMapping();
                    OriginalSource     originalSource     = new OriginalSource();
                    foreach (var trashItem in trashItems)
                    {
                        string accountMapping = textileNameMapping.Account == null ? string.Empty : textileNameMapping.Account.FirstOrDefault();
                        if (trashItem.TextileColorName == string.Concat(accountMapping.Split('*')[0], colorDetail.ColorName.Split('-')[0]))
                        {
                            originalSource.DateTime         = trashItem.DateTime;
                            originalSource.TextileColorName = trashItem.TextileColorName;
                            originalSource.Weight           = trashItem.Weight;
                            originalSource.TextileNo        = trashItem.TextileNo;
                            break;
                        }
                    }
                    excelPrimary.Add(new Container()
                    {
                        OriginalSource = originalSource,
                        TextileName    = excelDailyShippedItem.TextileName,
                        ColorName      = colorDetail.ColorName,
                        ShippedCount   = colorDetail.ShippedCount,
                        Distance       = priviousDistance
                    });
                }
            }


            ExcelHelper excelHelper = new ExcelHelper();

            IWorkbook wb = new XSSFWorkbook();

            ICellStyle positionStyle = wb.CreateCellStyle();

            positionStyle.WrapText          = true;
            positionStyle.Alignment         = HorizontalAlignment.Center;
            positionStyle.VerticalAlignment = VerticalAlignment.Center;

            ICellStyle estyle = wb.CreateCellStyle();

            estyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
            estyle.FillPattern         = FillPattern.SolidForeground;

            ICellStyle a2style = wb.CreateCellStyle();

            a2style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Coral.Index;
            a2style.FillPattern         = FillPattern.SolidForeground;

            List <ExcelRowContent> trashPrimaryExcelRowContent = new List <ExcelRowContent>();

            foreach (var item in trashPrimary.OrderByDescending(t => t.OriginalSource.TextileColorName == null).ThenBy(t => t.TextileName).ThenBy(o => o.ColorName))
            {
                var approximateNumber = item.OriginalSource.Weight / 20;
                var round             = Math.Round(approximateNumber, 0, MidpointRounding.AwayFromZero);

                var isEqual = round == item.ShippedCount;

                ExcelRowContent excelCellContents = new ExcelRowContent
                {
                    ExcelCellContents = new List <ExcelCellContent>
                    {
                        new ExcelCellContent {
                            CellValue = item.OriginalSource.TextileColorName, CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.OriginalSource.Weight.ToString(), CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = (approximateNumber).ToString(), CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.TextileName, CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.ColorName, CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.ShippedCount.ToString(), CellStyle = isEqual ? positionStyle : estyle
                        },
                    }
                };
                trashPrimaryExcelRowContent.Add(excelCellContents);
            }
            ;

            List <ExcelRowContent> excelPrimaryExcelRowContent = new List <ExcelRowContent>();

            foreach (var item in excelPrimary.OrderByDescending(t => t.OriginalSource.TextileColorName == null).ThenBy(t => t.TextileName).ThenBy(o => o.ColorName))
            {
                var approximateNumber = item.OriginalSource.Weight / 20;
                var round             = Math.Round(approximateNumber, 0, MidpointRounding.AwayFromZero);

                var isEqual = round == item.ShippedCount;

                ExcelRowContent excelCellContents = new ExcelRowContent
                {
                    ExcelCellContents = new List <ExcelCellContent>
                    {
                        new ExcelCellContent {
                            CellValue = item.OriginalSource.TextileColorName, CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.OriginalSource.Weight.ToString(), CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = (approximateNumber).ToString(), CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.TextileName, CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.ColorName, CellStyle = positionStyle
                        },
                        new ExcelCellContent {
                            CellValue = item.ShippedCount.ToString(), CellStyle = isEqual ? positionStyle : estyle
                        }
                    }
                };
                excelPrimaryExcelRowContent.Add(excelCellContents);
            }
            ;


            ExcelContent excelContent = new ExcelContent
            {
                FileName           = string.Concat("庫存對照清單", ShippingCheckDate.ToString("yyyy-MM-dd")),
                ExcelSheetContents = new List <ExcelSheetContent>
                {
                    new ExcelSheetContent
                    {
                        SheetName           = "Super為主",
                        ExcelColumnContents = new List <ExcelColumnContent>
                        {
                            new ExcelColumnContent
                            {
                                CellValue = "Super布種名稱顏色",
                                Width     = 6450
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "出貨重量",
                                Width     = 2800
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "約略出貨數",
                                Width     = 2000
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "布種名稱",
                                Width     = 4550
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "顏色",
                                Width     = 5550
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "出貨數量",
                                Width     = 1850
                            }
                        },
                        ExcelRowContents = trashPrimaryExcelRowContent
                    },
                    new ExcelSheetContent
                    {
                        SheetName           = "Excel為主",
                        ExcelColumnContents = new List <ExcelColumnContent>
                        {
                            new ExcelColumnContent
                            {
                                CellValue = "Super布種名稱顏色",
                                Width     = 6450
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "出貨重量",
                                Width     = 2800
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "約略出貨數",
                                Width     = 2000
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "布種名稱",
                                Width     = 4550
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "顏色",
                                Width     = 5550
                            },
                            new ExcelColumnContent
                            {
                                CellValue = "出貨數量",
                                Width     = 1850
                            }
                        },
                        ExcelRowContents = excelPrimaryExcelRowContent
                    }
                }
            };

            excelHelper.CreateExcelFile(wb, excelContent);
        }