Beispiel #1
0
 private string Similarity()
 {
     if (_migrationContainer.Destination != null && _migrationContainer.Source != null)
     {
         return(Levenstein.Percent(_migrationContainer.Source.CurrentWorksheetName,
                                   _migrationContainer.Destination.CurrentWorksheetName).ToString() + "%");
     }
     else
     {
         return("0%");
     }
 }
Beispiel #2
0
        private void MergeCheckTextMatch()
        {
            if (IsSecondKeyChecked() && IsKeyChecked())
            {
                var keycolumn = from el in columnParsers
                                where el.IsKey == true
                                select el;

                var matchcolumn = from el in columnParsers
                                  where el.LookupMatch == true
                                  select el;

                if (keycolumn.Count() != 1 || matchcolumn.Count() != 1)
                {
                    var msg = new MessageView("You cannot specify more than one first key!");
                    msg.Show();
                }
                else
                {
                    var keycol   = keycolumn.FirstOrDefault();
                    var matchcol = matchcolumn.FirstOrDefault();

                    Dictionary <string, int> sourceKeys      = new Dictionary <string, int>();
                    Dictionary <string, int> destinationKeys = new Dictionary <string, int>();

                    sourceKeys      = LoadColumn(_migration.Source, keycol.SourceColumnIndex);
                    destinationKeys = LoadColumn(_migration.Destination, keycol.DestinationColumnIndex);
                    SortedDictionary <string, int> sortedSourceKeys = new SortedDictionary <string, int>(sourceKeys);

                    Dictionary <string, int> sourceNames      = new Dictionary <string, int>();
                    Dictionary <string, int> destinationNames = new Dictionary <string, int>();

                    sourceNames      = LoadColumn(_migration.Source, matchcol.SourceColumnIndex);
                    destinationNames = LoadColumn(_migration.Destination, matchcol.DestinationColumnIndex);

                    int  ifNotFoundKeyRow = LastEmptyRow(_migration.Destination);
                    bool permission       = true;
                    int  row = 0;

                    int columncaptionsindex = _migration.Destination.ColumnCaptionRow;
                    foreach (var cl in sortedSourceKeys)
                    {
                        if (cl.Key != string.Empty)
                        {
                            if (destinationKeys.ContainsKey(cl.Key))
                            {
                                row = destinationKeys[cl.Key] + columncaptionsindex;
                                int     rowsource = sourceKeys[cl.Key] + columncaptionsindex;
                                decimal percent   = Levenstein.Percent(
                                    _migration.Source.ReadCell(rowsource, matchcol.SourceColumnIndex),
                                    _migration.Destination.ReadCell(row, matchcol.DestinationColumnIndex)
                                    );

                                if (percent < 80)
                                {
                                    var elements = from el in destinationNames
                                                   where Levenstein.NettoDistance(cl.Key, el.Key) <= 3 && el.Key != string.Empty
                                                   select el;

                                    if (elements.Count() > 0)
                                    {
                                        KeyValuePair <string, int> result = new KeyValuePair <string, int>();
                                        var comp = new SimilarNames(elements, result);
                                        comp.ShowDialog();
                                    }
                                }
                            }
                            else
                            {
                                row = ifNotFoundKeyRow++;
                            }

                            FromSource2DestinationWithRelationByRow(row,
                                                                    cl,
                                                                    sourceKeys,
                                                                    permission);
                        }
                    }

                    _migration.Destination.Save();
                    _migration.Source.Save();
                }
            }
        }