예제 #1
0
        public static async Task LoadExcel(string filename)
        {
            ExcelEngine    excelEngine = new ExcelEngine();
            IApplication   application = excelEngine.Excel;
            OpenFileDialog dlg         = new OpenFileDialog();
            IWorkbook      workbook    = application.Workbooks.Open(filename);

            //Sets workbook version.
            workbook.Version = ExcelVersion.Excel2016;
            IWorksheet worksheet = workbook.Worksheets[0];

            ProgectData.CrossSystemsLimitation_data = new BindingList <CrossSystemsLimitation>();
            ProgectData.UniClassGroup_data          = new BindingList <UniClassGroup>();
            ProgectData.GlobalGroup_data            = new BindingList <GlobalGroup>();
            ProgectData.Limitation_functions_data   = new BindingList <Limitation_functions>();
            ProgectData.GroupsSs       = new BindingList <GroupsUC>();
            ProgectData.GroupsPr       = new BindingList <GroupsUC>();
            ProgectData.OntologyGroups = new BindingList <OntologyGroups>();

            for (int i = 2; i < worksheet.Rows.Count <IRange>(); i++)
            {
                if (worksheet.GetValueRowCol(i, 9) != null && worksheet.GetValueRowCol(i, 9) != "")
                {
                    CrossSystemsLimitation newLimit = new CrossSystemsLimitation();
                    newLimit.N           = i;
                    newLimit.SsSource    = worksheet.GetValueRowCol(i, 1).ToString();
                    newLimit.PrSource    = worksheet.GetValueRowCol(i, 2).ToString();
                    newLimit.GroupSource = worksheet.GetValueRowCol(i, 3).ToString();
                    newLimit.SsTarget    = worksheet.GetValueRowCol(i, 4).ToString();
                    newLimit.PrTarget    = worksheet.GetValueRowCol(i, 5).ToString();
                    newLimit.GroupTarget = worksheet.GetValueRowCol(i, 6).ToString();
                    newLimit.Description = worksheet.GetValueRowCol(i, 7).ToString();
                    //string descr = ""/*Utils.CreateDescrLimitation(newLimit, ProgectData.uniClassGroups_key, ProgectData.UniSystemTable, ProgectData.UniProductTable)*/;
                    //newLimit.Description = descr;
                    newLimit.PointSource      = worksheet.GetValueRowCol(i, 8).ToString();
                    newLimit.IDLimitation     = worksheet.GetValueRowCol(i, 9).ToString();
                    newLimit.ConnectionWeight = worksheet.GetValueRowCol(i, 10).ToString();
                    newLimit.StrSource        = worksheet.GetValueRowCol(i, 11).ToString();
                    newLimit.Category         = worksheet.GetValueRowCol(i, 12).ToString();
                    ProgectData.CrossSystemsLimitation_data.Add(newLimit);
                    //colLimitation.Add(newLimit);
                }
                else
                {
                    break;
                }
            }

            ProgectData.UniclassGroupDescription = new Dictionary <int, string>();

            worksheet = workbook.Worksheets[1];
            for (int i = 2; i <= worksheet.Rows.Count <IRange>(); i++)
            {
                try {
                    if (worksheet.GetValueRowCol(i, 1) != null && worksheet.GetValueRowCol(i, 1) != "")
                    {
                        int key = Convert.ToInt32(worksheet.GetValueRowCol(i, 1).ToString());
                        if (ProgectData.UniclassGroupDescription.ContainsKey(key) == false)
                        {
                            ProgectData.UniclassGroupDescription.Add(key, worksheet.GetValueRowCol(i, 8).ToString());
                        }
                        if (worksheet.GetValueRowCol(i, 1) != null && worksheet.GetValueRowCol(i, 1) != "")
                        {
                            UniClassGroup newData = new UniClassGroup();
                            newData.GroupID               = Convert.ToInt32(worksheet.GetValueRowCol(i, 1).ToString());
                            newData.Exclude               = worksheet.GetValueRowCol(i, 2).ToString();
                            newData.SystemsID             = worksheet.GetValueRowCol(i, 3).ToString();
                            newData.ProductID             = worksheet.GetValueRowCol(i, 4).ToString();
                            newData.GroupDescription      = Utils.CreateDescrGroups(newData.SystemsID, newData.ProductID);
                            newData.GroupDescription_Note = worksheet.GetValueRowCol(i, 8).ToString();
                            newData.Function_layer        = worksheet.GetValueRowCol(i, 7).ToString();
                            newData.AnalyticalModel       = worksheet.GetValueRowCol(i, 6).ToString();
                            ProgectData.UniClassGroup_data.Add(newData);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                catch {
                    MessageBox.Show("Ошибка при чтении UniClassGroups");
                }
            }

            worksheet = workbook.Worksheets[2];
            for (int i = 1; i < worksheet.Rows.Count <IRange>(); i++)
            {
                if (worksheet.GetValueRowCol(i, 1) != null && worksheet.GetValueRowCol(i, 1) != "")
                {
                    Limitation_functions newLimitFunc = new Limitation_functions();
                    newLimitFunc.IDLimitation       = worksheet.GetValueRowCol(i, 1).ToString();
                    newLimitFunc.IDLimitDescription = worksheet.GetValueRowCol(i, 2).ToString();
                    ProgectData.Limitation_functions_data.Add(newLimitFunc);
                }
            }

            worksheet = workbook.Worksheets[3];
            for (int i = 2; i < worksheet.Rows.Count <IRange>(); i++)
            {
                var IDGlobalGroup = worksheet.GetValueRowCol(i, 1).ToString();
                if (IDGlobalGroup != null && IDGlobalGroup != "")
                {
                    GlobalGroup newGroup = new GlobalGroup();
                    newGroup.IDGlobalGroup           = Convert.ToInt32(worksheet.GetValueRowCol(i, 1).ToString());
                    newGroup.SystemID                = worksheet.GetValueRowCol(i, 2).ToString();
                    newGroup.ProductID               = worksheet.GetValueRowCol(i, 3).ToString();
                    newGroup.LocGroups               = worksheet.GetValueRowCol(i, 4).ToString();
                    newGroup.ZCoord                  = worksheet.GetValueRowCol(i, 5).ToString();
                    newGroup.GlobalGroupsDescription = worksheet.GetValueRowCol(i, 6).ToString();
                    ProgectData.GlobalGroup_data.Add(newGroup);
                }
            }

            worksheet = workbook.Worksheets[6];
            for (int i = 2; i <= worksheet.Rows.Count <IRange>(); i++)
            {
                if (worksheet.GetValueRowCol(i, 1) != null && worksheet.GetValueRowCol(i, 1).ToString() != "")
                {
                    var uc = new GroupsUC();
                    uc.Group            = worksheet.GetValueRowCol(i, 1).ToString();
                    uc.UC_Id            = worksheet.GetValueRowCol(i, 3).ToString();
                    uc.UC_Description   = worksheet.GetValueRowCol(i, 4).ToString();
                    uc.GroupDescription = worksheet.GetValueRowCol(i, 2).ToString();
                    ProgectData.GroupsSs.Add(uc);
                }
            }

            worksheet = workbook.Worksheets[7];
            for (int i = 2; i <= worksheet.Rows.Count <IRange>(); i++)
            {
                if (worksheet.GetValueRowCol(i, 1) != null && worksheet.GetValueRowCol(i, 1).ToString() != "")
                {
                    var up = new GroupsUC();
                    up.Group            = worksheet.GetValueRowCol(i, 1).ToString();
                    up.UC_Id            = worksheet.GetValueRowCol(i, 3).ToString();
                    up.UC_Description   = worksheet.GetValueRowCol(i, 4).ToString();
                    up.GroupDescription = worksheet.GetValueRowCol(i, 2).ToString();
                    ProgectData.GroupsPr.Add(up);
                }
            }

            OntologyGroups og = new OntologyGroups();

            og.keyValuePairs = new Dictionary <string, string>();
            worksheet        = workbook.Worksheets[8];
            for (int i = 2; i <= worksheet.Rows.Count <IRange>(); i++)
            {
                if (worksheet.GetValueRowCol(i, 1) != null && worksheet.GetValueRowCol(i, 1).ToString() != "")
                {
                    string group    = worksheet.GetValueRowCol(i, 2).ToString();
                    string ontology = worksheet.GetValueRowCol(i, 1).ToString();
                    og.keyValuePairs.Add(group, ontology);
                }
            }
            ProgectData.OntologyGroups.Add(og);
        }
예제 #2
0
        //public static void CorrectErrorUcGroups(List<Error> errorList, Dictionary<int, UniPairs> uniPair)
        //{
        //    ProgectData.uniPair_Correct = new Dictionary<int, UniPairs>();
        //    ProgectData.uniPair_Correct = uniPair;
        //    foreach (var error in errorList) {
        //        bool canfix = false;
        //        if (error.group1 != null && error.group2 != null) {

        //        }
        //    }
        //}
        public static void CorrectError(List <Error> errorList, Dictionary <int, UniPairs> uniPair, string metod)
        {
            ProgectData.uniPair_Correct = new Dictionary <int, UniPairs>();
            ProgectData.uniPair_Correct = uniPair;
            foreach (var error in errorList)
            {
                bool canfix = false;
                if (error.group1 != null && error.group2 != null)
                {
                    foreach (var excl in uniPair[Convert.ToInt32(error.group2)].Exclude)
                    {
                        bool Ss1 = Utils.Ss_equals_exclude(error.Ss1, excl.Ss);
                        bool Ss2 = Utils.Ss_equals_exclude(error.Ss2, excl.Ss);
                        bool Pr1 = Utils.Pr_equals_exclude(error.Pr1, excl.Pr);
                        bool Pr2 = Utils.Pr_equals_exclude(error.Pr2, excl.Pr);
                        if (Ss1 == true &&
                            Pr1 == true &&
                            error.Analitic_1 == excl.Analitic &&
                            error.Function_layer_1 == excl.Function_layer)
                        {
                            canfix = true;
                            break;
                        }
                        if (Ss2 == true &&
                            Pr2 == true &&
                            error.Analitic_2 == excl.Analitic &&
                            error.Function_layer_2 == excl.Function_layer)
                        {
                            canfix = true;
                            break;
                        }
                    }
                    foreach (var excl in uniPair[Convert.ToInt32(error.group1)].Exclude)
                    {
                        bool Ss1 = Utils.Ss_equals_exclude(error.Ss1, excl.Ss);
                        bool Ss2 = Utils.Ss_equals_exclude(error.Ss2, excl.Ss);
                        bool Pr1 = Utils.Pr_equals_exclude(error.Pr1, excl.Pr);
                        bool Pr2 = Utils.Pr_equals_exclude(error.Pr2, excl.Pr);
                        if (Ss1 == true &&
                            Pr1 == true &&
                            error.Analitic_1 == excl.Analitic &&
                            error.Function_layer_1 == excl.Function_layer)
                        {
                            canfix = true;
                            break;
                        }
                        if (Ss2 == true &&
                            Pr2 == true &&
                            error.Analitic_2 == excl.Analitic &&
                            error.Function_layer_2 == excl.Function_layer)
                        {
                            canfix = true;
                            break;
                        }
                    }
                }

                if (canfix == false)
                {
                    if (error.Pr1.Length > error.Pr2.Length)
                    {
                        CreateUniPaerExclude(ProgectData.uniPair_Correct, "2", error);
                    }
                    else if (error.Pr1.Length < error.Pr2.Length)
                    {
                        CreateUniPaerExclude(ProgectData.uniPair_Correct, "1", error);
                    }
                    else
                    {
                        if (error.Ss1.Length > error.Ss2.Length)
                        {
                            CreateUniPaerExclude(ProgectData.uniPair_Correct, "2", error);
                        }
                        else if (error.Ss1.Length < error.Ss2.Length)
                        {
                            CreateUniPaerExclude(ProgectData.uniPair_Correct, "1", error);
                        }
                        else
                        {
                            if (error.Analitic_1 != "" && error.Analitic_1 != error.Analitic_2 ||
                                error.Function_layer_1 != "" && error.Function_layer_1 != error.Function_layer_2)
                            {
                                CreateUniPaerExclude(ProgectData.uniPair_Correct, "2", error);
                            }
                            else if (error.Analitic_2 != "" && error.Analitic_2 != error.Analitic_1 ||
                                     error.Function_layer_2 != "" && error.Function_layer_2 != error.Function_layer_1)
                            {
                                CreateUniPaerExclude(ProgectData.uniPair_Correct, "1", error);
                            }
                        }
                    }
                }
            }
            string sMessageBoxText = "";

            switch (metod)
            {
            case "UC_Groups":
                sMessageBoxText = "Внести изменения в CrossSystemsLimitation добавив exclude? Исправление по UniClassGroups";
                break;

            case "MetaGroups":
                sMessageBoxText = "Внести изменения в CrossSystemsLimitation добавив exclude? Исправление по MetaGroups";
                break;
            }
            string sCaption = "CrossSystemsLimitationEditor";

            MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
            MessageBoxImage  icnMessageBox = MessageBoxImage.Warning;

            MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

            switch (rsltMessageBox)
            {
            case MessageBoxResult.Yes:
                ProgectData.UniClassGroup_data.Clear();
                foreach (var key in ProgectData.uniPair_Correct.Keys)
                {
                    if (ProgectData.uniPair_Correct[key].Exclude.Count != 0)
                    {
                        foreach (var exclude in ProgectData.uniPair_Correct[key].Exclude)
                        {
                            UniClassGroup newData = new UniClassGroup();
                            newData.GroupID               = key;
                            newData.Exclude               = "exclude";
                            newData.SystemsID             = exclude.Ss;
                            newData.ProductID             = exclude.Pr;
                            newData.GroupDescription      = Utils.CreateDescrGroups(newData.SystemsID, newData.ProductID);
                            newData.Function_layer        = exclude.Function_layer;
                            newData.AnalyticalModel       = exclude.Analitic;
                            newData.GroupDescription_Note = ProgectData.UniclassGroupDescription[key];
                            ProgectData.UniClassGroup_data.Add(newData);
                        }
                    }
                    if (ProgectData.uniPair_Correct[key].uniPair.Count != 0)
                    {
                        foreach (var unipaer in ProgectData.uniPair_Correct[key].uniPair)
                        {
                            if (key == 33)
                            {
                            }
                            UniClassGroup newData = new UniClassGroup();
                            newData.GroupID               = key;
                            newData.Exclude               = "";
                            newData.SystemsID             = unipaer.Ss;
                            newData.ProductID             = unipaer.Pr;
                            newData.GroupDescription      = Utils.CreateDescrGroups(newData.SystemsID, newData.ProductID);
                            newData.Function_layer        = unipaer.Function_layer;
                            newData.AnalyticalModel       = unipaer.Analitic;
                            newData.GroupDescription_Note = ProgectData.UniclassGroupDescription[key];
                            ProgectData.UniClassGroup_data.Add(newData);
                        }
                    }
                }
                break;

            case MessageBoxResult.No:
                /* ... */
                break;
            }
        }
예제 #3
0
        private static void CreateNewGroup(int id,
                                           BindingList <UniClassGroup> listUC_group,
                                           List <string> listSs,
                                           List <string> listPr,
                                           List <string> prop,
                                           string group_description
                                           )
        {
            string analitic = "";
            string layer    = "";

            foreach (var item in prop)
            {
                if (item.Contains("has_object_bearing_function"))
                {
                    switch (item.Split(new[] { '|' })[2])
                    {
                    case "structure":
                        analitic = "1";
                        break;

                    case "non_structure":
                        analitic = "0";
                        break;
                    }
                }
                else if (item.Contains("has_location"))
                {
                    switch (item.Split(new[] { '|' })[2])
                    {
                    case "external":
                        layer = "ext";
                        break;

                    case "internal":
                        layer = "int";
                        break;
                    }
                }
            }
            foreach (var pr in listPr)
            {
                foreach (var ss in listSs)
                {
                    var ug = new UniClassGroup()
                    {
                        GroupID               = id,
                        Exclude               = "",
                        SystemsID             = ss,
                        ProductID             = pr,
                        Function_layer        = layer,
                        AnalyticalModel       = analitic,
                        GroupDescription_Note = group_description
                    };
                    if (ProgectData.UniSystemTable.ContainsKey(ss) && ProgectData.UniProductTable.ContainsKey(pr))
                    {
                        ug.GroupDescription = ProgectData.UniSystemTable[ss] + "---" + ProgectData.UniProductTable[pr];
                    }
                    listUC_group.Add(ug);
                }
            }
        }