예제 #1
0
        public static (int tmCid, IntPtr stopEventHandle) InitializeAsTaskSimple(TmOikTaskOptions taskOptions,
                                                                                 TmInitializeOptions options)
        {
            Native.CfsInitLibrary();

            var taskArgs = Environment.GetCommandLineArgs();

            taskArgs[0] = Native.GetOikTaskExecutable(taskArgs[0]);

            var startEventHandle = new IntPtr();
            var stopEventHandle  = new IntPtr();

            Native.CfsPmonLocalRegisterProcess(taskArgs.Length,
                                               taskArgs,
                                               ref startEventHandle,
                                               ref stopEventHandle);
            Native.PlatformSetEvent(startEventHandle);

            SetUserCredentials(options.User,
                               options.Password);

            var tmCid = Native.TmcConnect(options.Host,
                                          options.TmServer,
                                          options.ApplicationName,
                                          options.TmCallback,
                                          options.TmCallbackParameters);

            if (tmCid == 0)
            {
                throw new Exception("Нет связи с ТМ-сервером (cid = 0), ошибка " + GetLastError());
            }

            return(tmCid, stopEventHandle);
        }
예제 #2
0
        InitializeWithoutSql(TmInitializeOptions options)
        {
            Native.CfsInitLibrary();

            SetUserCredentials(options.User,
                               options.Password);

            var tmCid = Connect(options.Host,
                                options.TmServer,
                                options.ApplicationName,
                                options.TmCallback,
                                options.TmCallbackParameters);

            if (tmCid == 0)
            {
                throw new Exception("Нет связи с ТМ-сервером, ошибка " + GetLastError());
            }

            return(tmCid, GetUserInfo(tmCid, options.TmServer), GetTmServerFeatures(tmCid));
        }
예제 #3
0
        InitializeAsTask(TmOikTaskOptions taskOptions, TmInitializeOptions options)
        {
            var(tmCid, userInfo, serverFeatures, stopEventHandle) = InitializeAsTaskWithoutSql(taskOptions, options);

            var rbCid = Connect(options.Host,
                                options.RbServer,
                                options.ApplicationName,
                                EmptyTmCallbackDelegate,
                                IntPtr.Zero);

            if (rbCid == 0)
            {
                throw new Exception("Нет связи с RB-сервером, ошибка " + GetLastError());
            }

            var rbPort = OpenSqlRedirector(rbCid);

            if (rbPort == 0)
            {
                throw new Exception("Ошибка при открытии редиректора к SQL");
            }

            return(tmCid, rbCid, rbPort, userInfo, serverFeatures, stopEventHandle);
        }