AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 25.02.2010, 12:39   #6  
kashperuk is offline
kashperuk
Участник
Аватар для kashperuk
MCBMSS
Соотечественники
Сотрудники Microsoft Dynamics
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии 2011
Лучший по профессии 2009
 
4,361 / 2084 (78) +++++++++
Регистрация: 30.05.2004
Адрес: Atlanta, GA, USA
Цитата:
Сообщение от belugin Посмотреть сообщение
\Classes\SysCompareText\run
правда имеет смысл только со много тросными строками.

А в чем капец в СисКолмпейр?

А, да, то есть АПИ таки есть.
Капец - да просто туча кода и фиг поймешь че делает. нечитаемо. один из методов:

X++:
/// <summary>
///    Fits records in the <c>ref</c> table so lines are only claimed one time.
/// </summary>
/// <remarks>
///    After this operation, lines may be claimed by several records if the lines appear in several
///    locations. In that case, one of the start positions and the length will be identical.
/// </remarks>
protected void fitRefs()
{
    //Fit all the shorter ones
    //and the ones overlapping with same length

    TmpCompareText ref2;
;

    //
    // Example:
    //
    // #1   1 -  5 ;  2 -  6   -> This is longer than #2 and is kept
    // #2   3 -  4 ; 10 - 11   -> This is shadowed by #1 and is deleted
    // #3   7 -  7 ; 14 - 14   -> #3 and #4 are identical, and decision is deferred to refCleanup()
    // #4   7 -  7 ; 20 - 20   -> #3 and #4 are identical, and decision is deferred to refCleanup()
    // #5  10 - 15 ; 25 - 30   -> This is longer than #6 and is kept
    // #6  17 - 20 ; 29 - 32   -> This is partly shadowed by #2, and is trimmed to: 19 - 20 ; 31 - 32
    //

    ref2.setTmpData(ref);
    while select ref
        order by Length desc, Text1Start
    {
        while select forupdate ref2
            where ref2.Length   <= ref.Length &&
                  ref2.RecId    != ref.RecId  &&
                   ((ref2.Text1Start >= ref.Text1Start && ref2.Text1Start  <= ref.Text1End)  ||
                    (ref2.Text1End   >= ref.Text1Start && ref2.Text1End    <= ref.Text1End)  ||
                    (ref2.Text2Start >= ref.Text2Start && ref2.Text2Start  <= ref.Text2End)  ||
                    (ref2.Text2End   >= ref.Text2Start && ref2.Text2End    <= ref.Text2End))
        {
            if ( ref2.Length   < ref.Length ||
                (ref2.Text1Start != ref.Text1Start &&
                 ref2.Text2Start != ref.Text2Start ))
            {
                if (ref2.Text1Start >= ref.Text1Start && ref2.Text1Start  <= ref.Text1End)       //Cut start of text1 in ref2
                {
                    ref2.Length     = ref2.Length     - (ref.Text1End + 1 - ref2.Text1Start);
                    ref2.Text2Start = ref2.Text2Start + (ref.Text1End + 1 - ref2.Text1Start);
                    ref2.Text1Start = ref.Text1End    + 1;
                    ref2.Text1End   = ref2.Text1Start + ref2.Length - 1;
                    ref2.Text2End   = ref2.Text2Start + ref2.Length - 1;
                }
                if (ref2.Text1End   >= ref.Text1Start && ref2.Text1End    <= ref.Text1End)       //Cut end of text1 in ref2
                {
                    ref2.Length     = ref2.Length    - (ref2.Text1End - (ref.Text1Start - 1));
                    ref2.Text2End   = ref2.Text2End  - (ref2.Text1End - (ref.Text1Start - 1));
                    ref2.Text1End   = ref.Text1Start - 1;
                    ref2.Text2Start = ref2.Text2End  - (ref2.Length - 1);
                    ref2.Text1Start = ref2.Text1End  - (ref2.Length - 1);
                }
                if (ref2.Text2Start >= ref.Text2Start && ref2.Text2Start  <= ref.Text2End)       //Cut start of text2 in ref2
                {
                    ref2.Length     = ref2.Length     - (ref.Text2End + 1 - ref2.Text2Start);
                    ref2.Text1Start = ref2.Text1Start + (ref.Text2End + 1 - ref2.Text2Start);
                    ref2.Text2Start = ref.Text2End    + 1;
                    ref2.Text2End   = ref2.Text2Start + ref2.Length - 1;
                    ref2.Text1End   = ref2.Text1Start + ref2.Length - 1;
                }
                if (ref2.Text2End   >= ref.Text2Start && ref2.Text2End    <= ref.Text2End)       //Cut end of text2 in ref2
                {
                    ref2.Length     = ref2.Length    - (ref2.Text2End - (ref.Text2Start - 1));
                    ref2.Text1End   = ref2.Text1End  - (ref2.Text2End - (ref.Text2Start - 1));
                    ref2.Text2End   = ref.Text2Start - 1;
                    ref2.Text1Start = ref2.Text1End  - (ref2.Length - 1);
                    ref2.Text2Start = ref2.Text2End  - (ref2.Length - 1);
                }

                if (ref2.Length <= 0)
                    ref2.delete();
                else
                    ref2.update();
            }
        }
    }
}
Да и сам метод run() в SysCompareText тоже, мягко говоря, не описан. Возвращаемый контейнер у меня состоял либо из 0 (если строки равны), либо из 1,2, если не равны. Причем я сперва подумал - круто, говорит, где именно ошибка. Но нет - просто возвращает 1,2 всегда
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:08.