예제 #1
0
파일: Day.cs 프로젝트: shkumat/mgb_day
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    //	Подстановка дат ( [DayDate] и [NextDate] )
    static string DateSubstitution(string SrcStr)
    {
        if (SrcStr == null)
        {
            return(CAbc.EMPTY);
        }
        if (SrcStr.Trim() == "")
        {
            return(SrcStr);
        }
        string Result = SrcStr.Trim().ToUpper();

        if ((Result.IndexOf("[NEXTDATE]") >= 0) && (NextDate == 0))
        {
            // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            //	Запрос пользователю на ввод даты дня, который закрывается
            while (NextDate == 0)
            {
                CCommon.Write("Какой следующий рабочий день ? ( " + NEXT_STR.Replace("/", ".") + " ) ");
                Answer = CCommon.Input().Trim();
                if (Answer == "")
                {
                    NextDate = DefaultNextDate;
                }
                else
                {
                    NextDate = CCommon.GetDate(Answer);
                }
            }
        }
        Result = Result.Replace("[DAYDATE]", DayDate.ToString());
        Result = Result.Replace("[NEXTDATE]", NextDate.ToString());
        return(Result);
    }
예제 #2
0
    static void    Main()
    {
        const bool DEBUG = false
        ;
        string ScroogeDir  = CAbc.EMPTY
        , ServerName       = CAbc.EMPTY
        , DataBase         = CAbc.EMPTY
        , ConnectionString = CAbc.EMPTY
        ;
        int UserId = 0
        , GroupId  = 0
        , BranchId = 0
        , DateFrom = 0
        , DateInto = 0
        ;
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        CParam Param = new   CParam();

        if (!DEBUG)
        {
            if (__.ParamCount() < 2)
            {
                PrintAboutMe();
                return;
            }
        }
        if (!CCommon.IsEmpty(Param["UserId"]))
        {
            UserId = __.CInt(Param["UserId"]);
        }
        if (!CCommon.IsEmpty(Param["GroupId"]))
        {
            UserId = __.CInt(Param["GroupId"]);
        }
        if (!CCommon.IsEmpty(Param["BranchId"]))
        {
            BranchId = __.CInt(Param["BranchId"]);
        }
        if (!CCommon.IsEmpty(Param["DateInto"]))
        {
            DateInto = __.GetDate(Param["DateInto"]);
        }
        if (!CCommon.IsEmpty(Param["DateFrom"]))
        {
            DateFrom = CCommon.GetDate(Param["DateFrom"]);
        }
        if ((DateFrom == 0) && (DateInto != 0))
        {
            DateFrom = DateInto;
        }
        if (DateInto == 0)
        {
            __.Print("Ошибка : не задана отчетная дата !");
            return;
        }
        if ((BranchId == 0) && (UserId == 0) && (GroupId == 0))
        {
            __.Print("Ошибка : не заданы условия построения отчета !");
            return;
        }
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        CConsole.Color = CConsole.GRAY;
        CConsole.Clear();
        CCommon.Print("", " Построение выписок в формате Скрудж-2. Версия 1.01 от 13.10.2017г.", "");
        CScrooge2Config Scrooge2Config = new   CScrooge2Config();

        if (!Scrooge2Config.IsValid)
        {
            CCommon.Print(Scrooge2Config.ErrInfo);
            return;
        }
        ScroogeDir = (string)Scrooge2Config["Root"].Trim();
        ServerName = (string)Scrooge2Config["Server"];
        DataBase   = (string)Scrooge2Config["DataBase"];
        if (ScroogeDir == null)
        {
            CCommon.Print("  Не найдена переменная `Root` в настройках `Скрудж-2` ");
            return;
        }
        if (ServerName == null)
        {
            CCommon.Print("  Не найдена переменная `Server` в настройках `Скрудж-2` ");
            return;
        }
        if (DataBase == null)
        {
            CCommon.Print("  Не найдена переменная `Database` в настройках `Скрудж-2` ");
            return;
        }
        CCommon.Print("  Беру настройки `Скрудж-2` здесь :  " + ScroogeDir);
        __.Print("  Сервер        :  " + ServerName);
        __.Print("  База данных   :  " + DataBase + CAbc.CRLF);
        ConnectionString = "Server=" + ServerName
                           + ";Database=" + DataBase
                           + ";Integrated Security=TRUE;";
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        System.Console.Title = "  Выписка в формате Скрудж-2              |   " + ServerName + "." + DataBase;
        CSc2Extract Sc2Extract = new   CSc2Extract();

        if (Sc2Extract.Open(ConnectionString))
        {
            Sc2Extract.Path         = __.GetCurDir();
            Sc2Extract.DateFrom     = DateFrom;
            Sc2Extract.DateInto     = DateInto;
            Sc2Extract.CbMode       = false;
            Sc2Extract.CoolSum      = false;
            Sc2Extract.ApartFile    = true;
            Sc2Extract.NeedPrintMsg = true;
            Sc2Extract.OverMode     = 2;
            Sc2Extract.BranchId     = BranchId;
            Sc2Extract.GroupId      = GroupId;
            Sc2Extract.UserId       = UserId;
            Sc2Extract.Build();
            Sc2Extract.Close();
            __.Print("Выписки построены.", "Для продолжения нажмите Enter...");
            CConsole.ClearKeyboard();
            CConsole.Flash();
            CConsole.ReadChar();
        }
    }
예제 #3
0
    public static void Main()
    {
        const bool DEBUG            = false;
        int        WorkMode         = 0;                                 // 1 = выгружать B ; 2 = выгружать V
        const int  WORK_MODE_B      = 1;                                 // для WorkMode : 1 = выгружать B
        const int  WORK_MODE_V      = 2;                                 // для WorkMode : 2 = выгружать V
        int        DayStatus        = 0;                                 // &1 = стоп по B ; &2 = стоп по V
        int        ErcDate          = CCommon.Today();
        string     TmpDir           = null;
        string     StatDir          = null;
        string     TodayDir         = null;
        string     OutputDir        = null;
        string     DataBase         = null;
        string     ServerName       = null;
        string     ScroogeDir       = null;
        string     LogFileName      = null;
        string     SimpleFileName   = null;
        string     ConfigFileName   = null;
        string     ConnectionString = null;

        Err.LogToConsole();
        CCommon.Print("", " Создание файлов для ЕРЦ. Версия 3.02 от 23.05.2019г.");

        if (!DEBUG)
        {
            if (CCommon.ParamCount() < 2)
            {
                CCommon.Print(" Режим работы программы (задаются в строке запуска программы):");
                CCommon.Print("        /E      -  выполнить выгрузку файлов для ЕРЦ .");
                CCommon.Print(" Примеры запуска программы  : ");
                CCommon.Print("        ErcExport  /E");
                CCommon.Print("        ErcExport  /E  2019/05/20");
                return;
            }
            if (CCommon.Upper(CAbc.ParamStr[1]).Trim() != "/E")
            {
                CCommon.Print(" Ошибка ! Неправильный режим работы  - " + CAbc.ParamStr[1]);
                return;
            }
            if (CCommon.ParamCount() > 2)
            {
                ErcDate = CCommon.GetDate(CAbc.ParamStr[2].Trim());
                if (ErcDate < 10000)
                {
                    CCommon.Print(" Ошибка ! Неправильная дата - " + CAbc.ParamStr[2]);
                    return;
                }
            }
        }
        else
        {
            CCommon.Print("--- DEBUG ---");
        }
        CCommon.Print(" Рабочая дата " + CCommon.StrD(ErcDate, 10, 10));

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Scrooge2Config = new   CScrooge2Config();
        if (!Scrooge2Config.IsValid)
        {
            CCommon.Print(Scrooge2Config.ErrInfo);
            return;
        }

        ScroogeDir = (string)Scrooge2Config["Root"];
        ServerName = (string)Scrooge2Config["Server"];
        DataBase   = (string)Scrooge2Config["DataBase"];
        if (ScroogeDir == null)
        {
            CCommon.Print("  Не найдена переменная `Root` в настройках `Скрудж-2` ");
            return;
        }
        if (ServerName == null)
        {
            CCommon.Print("  Не найдена переменная `Server` в настройках `Скрудж-2` ");
            return;
        }
        if (DataBase == null)
        {
            CCommon.Print("  Не найдена переменная `Database` в настройках `Скрудж-2` ");
            return;
        }
        CCommon.Print("  Беру настройки `Скрудж-2` здесь :  " + ScroogeDir);

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ConnectionString = "Server=" + ServerName
                           + ";Database=" + DataBase
                           + ";Integrated Security=TRUE;"
        ;
        Connection1 = new CConnection(ConnectionString);
        Connection2 = new CConnection(ConnectionString);

        if (Connection1.IsOpen())
        {
            CCommon.Print("  Сервер        :  " + ServerName);
            CCommon.Print("  База данных   :  " + DataBase + CAbc.CRLF);
        }
        else
        {
            CCommon.Print(CAbc.CRLF + "  Ошибка подключения к серверу !");
            return;
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        CCommand Command = new   CCommand(Connection1);

        DayStatus = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;8 @TaskCode = 'ErcGate' , @DayDate = " + ErcDate.ToString()), (int)0);

        switch ((DayStatus & 3))
        {
        case  0: {                                      // разрешена отправка и B и V
            WorkMode = WORK_MODE_B;                     // отправлять B
            break;
        }

        case  1: {                                      // запрещена отправка B ; разрешена отправка V
            WorkMode = WORK_MODE_V;                     // отправлять V
            break;
        }

        case  2: {                                      // разрешена отправка B ; запрещена отправка V
            WorkMode = WORK_MODE_B;                     // отправлять B
            break;
        }

        case  3: {
            CCommon.Print(" На " + CCommon.StrD(ErcDate, 10, 10) + " отправка пачек B и V завершена (см. признак текущего дня).");
            Connection1.Close();
            Connection2.Close();
            return;

            break;
        }
        }

        SeanceNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4  @TaskCode = 'ErcGate' , @ParamCode = 'NumSeance'  , @DayDate = " + ErcDate.ToString()), (int)0);
        if (WorkMode == WORK_MODE_B)
        {
            BFileNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4  @TaskCode = 'ErcGate' , @ParamCode = 'NumOutFile' , @DayDate = " + ErcDate.ToString()), (int)0);
            CCommon.Print(" Выполняется формирование B-файлов ");
        }
        else
        {
            CCommon.Print(" Выполняется формирование V и W -файлов ");
        }

        Command.Close();
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ConfigFileName = ScroogeDir + CAbc.SLASH + "EXE" + CAbc.SLASH + "GLOBAL.ERC";
        ErcConfig      = new CErcConfig();
        ErcConfig.Open(ErcDate);
        if (!ErcConfig.IsValid())
        {
            CCommon.Print("  Ошибка чтения настроек из файла " + ConfigFileName);
            System.Console.WriteLine(ErcConfig.ErrInfo());
            Connection1.Close();
            Connection2.Close();
            return;
        }
        TodayDir  = (string)ErcConfig.TodayDir();
        StatDir   = (string)ErcConfig.StatDir();
        TmpDir    = (string)ErcConfig.TmpDir();
        OutputDir = (string)ErcConfig["OutputDir"];
        if ((TodayDir == null) || (OutputDir == null))
        {
            CCommon.Print("  Ошибка чтения настроек из файла " + ConfigFileName);
            Connection1.Close();
            Connection2.Close();
            return;
        }
        TodayDir  = TodayDir.Trim();
        OutputDir = OutputDir.Trim();
        StatDir   = StatDir.Trim();
        if ((TodayDir == "") || (OutputDir == "") || (StatDir == ""))
        {
            CCommon.Print("  Ошибка чтения настроек из файла " + ConfigFileName);
            Connection1.Close();
            Connection2.Close();
            return;
        }
        if (!CCommon.DirExists(StatDir))
        {
            CCommon.MkDir(StatDir);
        }
        if (!CCommon.SaveText(StatDir + "\\" + "test.dat", "test.dat", CAbc.CHARSET_DOS))
        {
            CCommon.Print(" Ошибка записи в каталог " + StatDir);
            Connection1.Close();
            Connection2.Close();
            return;
        }
        CCommon.DeleteFile(StatDir + "\\" + "test.dat");
        CCommon.Print("  Беру настройки шлюза здесь :  " + ConfigFileName);

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        TmpDir = TmpDir + "\\" + SeanceNum.ToString("000000");
        CCommon.MkDir(TmpDir);
        if (!CCommon.SaveText(TmpDir + "\\" + "test.dat", "test.dat", CAbc.CHARSET_DOS))
        {
            CCommon.Print("  Ошибка записи в каталог " + TmpDir);
            Connection1.Close();
            Connection2.Close();
        }
        LogFileName = ErcConfig.LogDir() + "\\SE" + SeanceNum.ToString("000000") + ".TXT";
        if (!CCommon.AppendText(LogFileName, CCommon.Now() + " , " + CCommon.Upper(CCommon.GetUserName()) + CAbc.CRLF, CAbc.CHARSET_DOS))
        {
            CCommon.Print("  Ошибка записи в файл " + LogFileName);
            Connection1.Close();
            Connection2.Close();
        }

        Err.LogTo(LogFileName);

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        //	Отправка B
        if (WorkMode == WORK_MODE_B)
        {
            if (!WriteBFiles(ErcDate, TmpDir))
            {
                CCommon.Print("  Ошибка записи B-файлов!");
            }
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        //	Отправка V
        if (WorkMode == WORK_MODE_V)
        {
            WriteVFiles(ErcDate, TmpDir, 0);
            WriteVFiles(ErcDate, TmpDir, 1);
            Command = new   CCommand(Connection1);
            if (!Command.Execute(" exec dbo.pMega_OpenGate_Days;9  @TaskCode = 'ErcGate' , @DayDate = " + ErcDate.ToString()))
            {
                CCommon.Print("  Ошибка установки запрета на отправку V-файла!");
                CCommon.AppendText(LogFileName, "  Ошибка установки запрета на отправку V-файла!", CAbc.CHARSET_DOS);
                CCommon.AppendText(LogFileName, CAbc.CRLF, CAbc.CHARSET_DOS);
                Connection1.Close();
                Connection2.Close();
                return;
            }
            Command.Close();
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        foreach (string ResultFile in CCommon.GetFileList(TmpDir + "\\" + "!*.*"))
        {
            if (ResultFile != null)
            {
                SimpleFileName = CCommon.GetFileName(ResultFile);
                CCommon.CopyFile(ResultFile, TodayDir + "\\" + SimpleFileName);
                CCommon.CopyFile(ResultFile, OutputDir + "\\" + SimpleFileName);
                CCommon.AppendText(LogFileName, "Записываю файл " + SimpleFileName, CAbc.CHARSET_DOS);
                CCommon.Print("  Записываю файл " + SimpleFileName);
            }
        }
        CCommon.AppendText(LogFileName, CAbc.CRLF, CAbc.CHARSET_DOS);
        Connection1.Close();
        Connection2.Close();
    }
예제 #4
0
파일: Day.cs 프로젝트: shkumat/mgb_day
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static void    Main()
    {
        const bool DEBUG                = false;
        CParam     Param                = new   CParam();
        int        Choice               = 0;
        bool       Result               = false;
        byte       SavedColor           = 7;
        string     OutputDir            = CAbc.EMPTY;
        string     ScroogeDir           = CAbc.EMPTY;
        string     ServerName           = CAbc.EMPTY;
        string     DataBase             = CAbc.EMPTY;
        string     LogFileName          = CAbc.EMPTY;
        string     UnsolverBillsCmdText = CAbc.EMPTY;
        int        UnsolvedBillsExists  = 0;

        string[] Titles       = { "ОТКРЫТИЕ ДНЯ", "ЗАКРЫТИЕ ДНЯ" };
        string[] LogFileNames = { "dayopen.log", "dayclose.log" };
        string   NOW_STR      = CCommon.StrD(CCommon.Today(), 10, 10).Substring(6)
                                + CCommon.StrD(CCommon.Today(), 10, 10).Substring(2, 4)
                                + CCommon.StrD(CCommon.Today(), 10, 10).Substring(0, 2);

        Err.LogToConsole();
        CConsole.Clear();
        CCommon.Print(" Оболочка открытия и закрытия дня в `Скрудже`. Версия 3.13 от 02.10.2018г.", "");
        if (DEBUG)
        {
            Mode = 1;
        }
        else
        if (CCommon.IsEmpty(Param["Mode"]))
        {
            CCommon.Print("Не указан режим работы программы !");
        }
        else
        {
            switch (Param["Mode"].ToUpper())
            {
            case    "OPEN": {
                Mode = 1;
                break;
            }

            case    "CLOSE": {
                Mode = 2;
                break;
            }

            default: {
                CCommon.Print("Неверно указан режим работы программы !");
                break;
            }
            }
        }
        if ((Mode != 1) && (Mode != 2))
        {
            return;
        }
        if ((Mode == 2) && (!CCommon.DirExists("Z:\\")))
        {
            SavedColor        = CConsole.BoxColor;
            CConsole.BoxColor = CConsole.RED * 16 + CConsole.WHITE;
            CConsole.ShowBox("", "Не подключен Z:\\", "");
            CConsole.ClearKeyboard();
            CConsole.ReadChar();
            CConsole.BoxColor = SavedColor;
            CConsole.Clear();
            CConsole.ShowCursor();
        }
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        //	Запрос пользователю на ввод даты дня, который открывается или закрывается
        while (DayDate == 0)
        {
            switch (Mode)
            {
            case 1: {
                CCommon.Write("Какую дату открываем ? ( " + NOW_STR.Replace("/", ".") + " ) ");
                break;
            }

            default: {
                CCommon.Write("Какую дату закрываем ? ( " + NOW_STR.Replace("/", ".") + " ) ");
                break;
            }
            }
            Answer = CCommon.Input().Trim();
            if (Answer == "")
            {
                DayDate = CCommon.Today();
            }
            else
            {
                DayDate = CCommon.GetDate(Answer);
            }
        }
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Scrooge2Config = new   CScrooge2Config();
        if (!Scrooge2Config.IsValid)
        {
            CCommon.Print(Scrooge2Config.ErrInfo);
            return;
        }
        ScroogeDir = (string)Scrooge2Config["Root"];
        OutputDir  = (string)Scrooge2Config["Output"];
        ServerName = (string)Scrooge2Config["Server"];
        DataBase   = (string)Scrooge2Config["DataBase"];
        if (ScroogeDir == null)
        {
            CCommon.Print("  Не найдена переменная `Root` в настройках `Скрудж-2` ");
            return;
        }
        if (ServerName == null)
        {
            CCommon.Print("  Не найдена переменная `Server` в настройках `Скрудж-2` ");
            return;
        }
        if (DataBase == null)
        {
            CCommon.Print("  Не найдена переменная `Database` в настройках `Скрудж-2` ");
            return;
        }
        CCommon.Print(" Беру настройки `Скрудж-2` здесь :  " + ScroogeDir);
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ConnectionString = "Server=" + ServerName
                           + ";Database=" + DataBase
                           + ";Integrated Security=TRUE;";
        Connection = new CConnection(ConnectionString);
        if (Connection.IsOpen())
        {
            CCommon.Print(" Сервер " + ServerName);
            CCommon.Print(" База   " + DataBase + CAbc.CRLF);
        }
        else
        {
            CCommon.Print(CAbc.CRLF + "  Ошибка подключения к серверу !");
            return;
        }
        System.Console.Title = "  " + Titles[Mode - 1] + "             |   " + ServerName + "." + DataBase;
        Command = new   CCommand(Connection);
        int    IsFullAccess   = ( int )CCommon.IsNull(Command.GetScalar(" select  dbo.Fn_IsFullAccess( DEFAULT ) "), (int)0);
        string InfNBU_OutPath = ( string )CCommon.IsNull(Command.GetScalar(" exec dbo.Mega_Day_Open;5  @Mode=2 ; "), (string)CAbc.EMPTY);

        if (Mode == 2)
        {
            // Записываю в историю логин пользователя, который закрывает день
            Command.Execute(" exec  dbo.Mega_Day_Close;12  @DayDate = " + DayDate.ToString() + " , @UserCode = '" + UserCode + "' ");
            // Проверка : имеются ли непроведенные документы ?
            UnsolverBillsCmdText = " If Exists ( select 1 from dbo.Mega_SV_WaitingBills with (NoLock) where  (DayDate=" + DayDate.ToString() + " )  and ((PermitFlag & 255 )!=255) and ((ProcessFlag & 3)!=3) ) select Convert(Integer,1) else select Convert(Integer,0) ";
            UnsolvedBillsExists  = ( int )CCommon.IsNull(Command.GetScalar(UnsolverBillsCmdText), (int)0);
        }
        Command.Close();
        Connection.Close();
        if (IsFullAccess < 1)
        {
            CCommon.Print(CAbc.CRLF + "  Для работы программы пользователю необходим полный доступ в Скрудже !");
            return;
        }
        InfNBU_OutPath = InfNBU_OutPath.Trim();
        if (InfNBU_OutPath.Length == 0)
        {
            Err.Print(CCommon.Now().ToString() + "Ошибка определения выходного каталога для ОДБ." + CAbc.CRLF + CAbc.CRLF);
        }
        if (UnsolvedBillsExists == 1)
        {
            SavedColor        = CConsole.BoxColor;
            CConsole.BoxColor = CConsole.RED * 16 + CConsole.WHITE;
            CConsole.ShowBox("", "Имеются непpоведенные документы", "", "  Пpоведите их или удалите !", "");
            CConsole.ClearKeyboard();
            CConsole.ReadChar();
            CConsole.BoxColor = SavedColor;
            CConsole.Clear();
            CConsole.ShowCursor();
        }
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if (OutputDir != null)
        {
            OutputDir = ScroogeDir + "\\" + OutputDir.Trim();
            if (!CCommon.DirExists(OutputDir))
            {
                CCommon.MkDir(OutputDir);
            }
            if (CCommon.DirExists(OutputDir))
            {
                OutputDir += "\\" + CCommon.StrD(DayDate, 8, 8).Replace("/", "").Replace(".", "");
                if (!CCommon.DirExists(OutputDir))
                {
                    CCommon.MkDir(OutputDir);
                }
                if (!CCommon.DirExists(OutputDir))
                {
                    OutputDir = ScroogeDir + "\\";
                }
            }
            LogFileName = OutputDir + "\\" + LogFileNames[Mode - 1];
        }
        else
        {
            LogFileName = ScroogeDir + "\\" + LogFileNames[Mode - 1];
        }
        Err.LogTo(LogFileName);
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        //	Основной цикл программы
        do
        {
            System.Console.Title = "  " + Titles[Mode - 1] + "  " + CCommon.StrD(DayDate, 8, 8) + "        |   " + ServerName + "." + DataBase;
            string[] FilesForMEDOC = CCommon.GetFileList(InfNBU_OutPath + "\\@*.*");
            if (FilesForMEDOC != null)
            {
                if (FilesForMEDOC.Length > 0)
                {
                    CConsole.GetBoxChoice(
                        ""
                        , "В каталоге " + InfNBU_OutPath
                        , "Найдены файлы для налоговой  @*.*"
                        , "Не забудьте их отправить!"
                        , ""
                        );
                }
            }
            if (!LoadHistory(Mode))
            {
                Err.Print(CCommon.Now().ToString() + "Ошибка получения с сервера истории работы программы !");
            }
            Choice = CConsole.GetMenuChoice(MenuNames);
            if (Choice > 0)
            {
                Err.Print(CCommon.Now().ToString() + "\t< " + MenuNames[Choice - 1] + "   ( " + UserCode + " ) " + CAbc.CRLF);
                if (!SaveHistory(Mode, Choice))
                {
                    Err.Print("Ошибка сохранения на сервере истории работы программы !");
                }
                switch (MenuKinds[Choice - 1].Trim().ToUpper())
                {
                case    "EXE.COPY": {
                    Result = StartExeCopy(
                        MacroSubstitution(MenuCommands[Choice - 1])
                        , MacroSubstitution(
                            DateSubstitution(
                                MenuParams[Choice - 1]
                                )
                            )
                        );
                    break;
                }

                case    "SQL.CMD": {
                    Result = StartSqlCmd(
                        DateSubstitution(
                            MenuCommands[Choice - 1]
                            )
                        );
                    break;
                }

                case    "SQL.RS": {
                    Result = StartSqlRS(
                        DateSubstitution(
                            MenuCommands[Choice - 1]
                            )
                        );
                    break;
                }

                case    "SQL.ROUTINE": {
                    Result = StartSqlRoutine(
                        DateSubstitution(
                            MenuCommands[Choice - 1]
                            )
                        );
                    break;
                }

                case    "EXC": {
                    Result = StartExc(ScroogeDir
                                      , MacroSubstitution(
                                          DateSubstitution(
                                              MenuCommands[Choice - 1]
                                              )
                                          )
                                      );
                    break;
                }

                case    "URL.IE": {
                    Result = StartUrl(
                        DateSubstitution(
                            MenuCommands[Choice - 1]
                            )
                        );
                    break;
                }

                default: {
                    break;
                }
                }
                Err.Print(CCommon.Now().ToString() + "\t " + MenuNames[Choice - 1] + "   ( " + Result.ToString() + " ) > " + CAbc.CRLF);
            }
        } while (Choice != 0);
    }