프로젝트

일반

사용자정보

개정판 89dacbc6

ID89dacbc6bdeafa87b8e6431b551b17d1c99b3dd0
상위 ebe81079
하위 9bcb092b

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #1168 : SPPID Mapping 정보 Export기능 (Attribute Label)

Change-Id: I831e78e363e3cfce545e26d29304f78b1debab5c

차이점 보기:

DTI_PID/SPPIDConverter/Form/MappingForm.cs
608 608
                    workbook.Options.Culture = System.Globalization.CultureInfo.CurrentCulture;
609 609
                    workbook.CreateNewDocument();
610 610

  
611
                    Worksheet worksheet = workbook.Worksheets.Insert(0, "Mapping Information");
612
                    mappingSheet(worksheet);
611
                    Worksheet worksheet = workbook.Worksheets.Insert(0, "Symbol Mapping Information");
612
                    symbolMappingSheet(worksheet);
613
                    worksheet = workbook.Worksheets.Insert(1, "Label Mapping Information");
614
                    labelMappingSheet(worksheet);
615

  
616
                    workbook.Worksheets.RemoveAt(workbook.Worksheets.Count - 1);
617
                    workbook.Worksheets.ActiveWorksheet = workbook.Worksheets[0];
613 618

  
614 619
                    workbook.SaveDocument(dialog.FileName, DocumentFormat.Xlsx);
615 620
                    workbook.CreateNewDocument();
......
625 630
            }
626 631
        }
627 632

  
628
        private void mappingSheet(Worksheet worksheet)
633
        private void symbolMappingSheet(Worksheet worksheet)
629 634
        {
630 635
            List<string> columnNames = new List<string>() {
631
                "ID2 Name", "ChildSymbol(Actuator) Name", "ID2 Image",
636
                "ID2 Name", "Additional Symbol Name", "ID2 Image",
632 637
                "SPPID Name", "SPPID Image", "SPPID Path"};
633 638

  
634 639
            CreateExcelColumn(worksheet, columnNames);
635
            InsertMappingInfo(worksheet, columnNames);
640
            InsertSymbolMappingInfo(worksheet, columnNames);
636 641
        }
637 642

  
638 643
        private void CreateExcelColumn(Worksheet worksheet, List<string> columns)
......
640 645
            for (int i = 0; i < columns.Count; i++)
641 646
                worksheet[0, i].SetValue(columns[i]);
642 647
            worksheet.Rows[0].Height = 150;
648

  
649
            Range range = worksheet.Range[string.Format("A1:{0}1", worksheet.Columns[columns.Count - 1].Heading)];
650
            DevExpress.Spreadsheet.Formatting rangeFormatting = range.BeginUpdateFormatting();
651
            rangeFormatting.Font.Color = Color.Blue;
652
            rangeFormatting.Font.Bold = true;
653
            rangeFormatting.Fill.BackgroundColor = Color.LightBlue;
654
            range.EndUpdateFormatting(rangeFormatting);
643 655
        }
644 656

  
645
        private void InsertMappingInfo(Worksheet worksheet, List<string> columns)
657
        private void InsertSymbolMappingInfo(Worksheet worksheet, List<string> columns)
646 658
        {
647 659
            int rowIndex = 1;
648 660
            Project_Info info = Project_Info.GetInstance();
......
653 665
                foreach (var row in selectedRows)
654 666
                {
655 667
                    string id2Name = id2SymbolRow["Name"].ToString();
656
                    string additionalSymbol = DBNull.Value.Equals(id2SymbolRow["AdditionalSymbol"]) ? "" : id2SymbolRow["AdditionalSymbol"].ToString();
657
                    //string symbolType = _ID2SymbolTypeTable.Select(string.Format("UID = {0}", id2SymbolRow["SymbolType_UID"]))[0]["Type"].ToString();
668
                    string additionalSymbols = DBNull.Value.Equals(id2SymbolRow["AdditionalSymbol"]) ? "" : id2SymbolRow["AdditionalSymbol"].ToString();
658 669
                    string symbolType = row["Type"].ToString();
659
                    string id2ImagePath = info.ImageDirPath + symbolType + string.Format(@"\{0}.png", id2Name);                    //string id2ImagePath = 
670
                    string id2ImagePath = info.ImageDirPath + symbolType + string.Format(@"\{0}.png", id2Name);
660 671

  
661 672
                    string mappingPath = row["SPPID_SYMBOL_PATH"].ToString();
662 673
                    string mappingName = Path.GetFileNameWithoutExtension(mappingPath);
......
693 704
                        worksheet.Rows[rowIndex].Height = 120;
694 705
                        rowIndex++;
695 706

  
696
                        if (!string.IsNullOrEmpty(additionalSymbol))
707
                        if (!string.IsNullOrEmpty(additionalSymbols))
697 708
                        {
698
                            string childName = additionalSymbol.Split(new char[] { ',' })[2];
699
                            DataRow[] childRows = symbolDT.Select(string.Format("UID = '{0}'", childName));
700
                            foreach (DataRow childRow in childRows)
709
                            string[] arr = additionalSymbols.Split(new char[] { '/' });
710
                            foreach (var additionalSymbol in arr)
701 711
                            {
702
                                mappingPath = childRow["SPPID_SYMBOL_PATH"].ToString();
703
                                mappingName = Path.GetFileNameWithoutExtension(mappingPath);
704
                                mappingImagePath = info.SPPID_ImageDirPath + mappingPath + ".png";
705

  
706
                                worksheet[rowIndex, 1].Value = childName;
707
                                worksheet[rowIndex, 3].Value = mappingName;
708
                                worksheet[rowIndex, 5].Value = mappingPath;
709
                                if (File.Exists(mappingImagePath))
712
                                string childName = additionalSymbol.Split(new char[] { ',' })[2];
713
                                DataRow[] childRows = symbolDT.Select(string.Format("UID = '{0}'", childName));
714
                                foreach (DataRow childRow in childRows)
710 715
                                {
711
                                    try
716
                                    mappingPath = childRow["SPPID_SYMBOL_PATH"].ToString();
717
                                    mappingName = Path.GetFileNameWithoutExtension(mappingPath);
718
                                    mappingImagePath = info.SPPID_ImageDirPath + mappingPath + ".png";
719

  
720
                                    worksheet[rowIndex, 1].Value = childName;
721
                                    worksheet[rowIndex, 3].Value = mappingName;
722
                                    worksheet[rowIndex, 5].Value = mappingPath;
723
                                    if (File.Exists(mappingImagePath))
712 724
                                    {
713
                                        worksheet.Pictures.AddPicture(mappingImagePath, worksheet[rowIndex, 4]);
714
                                    }
715
                                    catch (Exception ex)
716
                                    {
717

  
725
                                        try
726
                                        {
727
                                            worksheet.Pictures.AddPicture(mappingImagePath, worksheet[rowIndex, 4]);
728
                                        }
729
                                        catch (Exception ex)
730
                                        {
731

  
732
                                        }
718 733
                                    }
734
                                    worksheet.Rows[rowIndex].Height = 120;
735
                                    rowIndex++;
719 736
                                }
720
                                worksheet.Rows[rowIndex].Height = 120;
721
                                rowIndex++;
722 737
                            }
723 738
                        }
724 739
                    }
725 740
                }
726 741
            }
727 742

  
728
            worksheet.Columns.AutoFit(0, 5);
743
            worksheet.Columns.AutoFit(0, columns.Count - 1);
744
        }
745

  
746
        private void labelMappingSheet(Worksheet worksheet)
747
        {
748
            List<string> columnNames = new List<string>() {
749
                "ID2 Name", 
750
                "SPPID Name", "SPPID Image", "SPPID Path"};
751

  
752
            CreateExcelColumn(worksheet, columnNames);
753
            InsertLabelMappingInfo(worksheet, columnNames);
754
        }
755

  
756
        private void InsertLabelMappingInfo(Worksheet worksheet, List<string> columns)
757
        {
758
            int rowIndex = 1;
759
            Project_Info info = Project_Info.GetInstance();
760
            foreach (DataRow row in attributeDT.Rows)
761
            {
762
                string mappingPath = DBNull.Value.Equals(row["SPPID_SYMBOL_PATH"]) ? "" : row["SPPID_SYMBOL_PATH"].ToString();
763
                if (!string.IsNullOrEmpty(mappingPath))
764
                {
765
                    string id2Name = row["DisplayAttribute"].ToString();
766
                    string mappingName = row["SPPID_ATTRIBUTE"].ToString();
767
                    string mappingImagePath = info.SPPID_ImageDirPath + mappingPath + ".png";
768

  
769
                    worksheet[rowIndex, 0].Value = id2Name;
770
                    worksheet[rowIndex, 1].Value = mappingName;
771
                    worksheet[rowIndex, 3].Value = mappingPath;
772
                    if (File.Exists(mappingImagePath))
773
                    {
774
                        try
775
                        {
776
                            worksheet.Pictures.AddPicture(mappingImagePath, worksheet[rowIndex, 2]);
777
                        }
778
                        catch (Exception ex)
779
                        {
780

  
781
                        }
782
                    }
783

  
784

  
785
                    worksheet.Rows[rowIndex].Height = 120;
786
                    rowIndex++;
787
                }
788
            }
789

  
790
            worksheet.Columns.AutoFit(0, columns.Count - 1);
729 791
        }
730 792

  
731 793
        public Image ResizeImage(string importPath, int targetX, int targetY)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)