Esempio n. 1
0
        /// <summary>
        /// Set the ServicesLog to write to the proper file
        /// </summary>

        static void InitializeServicesLogFileName()
        {
            try
            {
                string iniFilePath = NativeSessionInitializer.GetMobiusServicesIniFileLocation();
                if (Lex.IsUndefined(iniFilePath) || !File.Exists(iniFilePath))
                {
                    return;
                }

                IniFile iniFile = new IniFile(iniFilePath, "Mobius");
                string  logDir  = iniFile.Read("LogDirectory");
                if (!Lex.IsDefined(logDir))
                {
                    return;
                }

                string logFile = logDir + @"\" + CommonConfigInfo.ServicesLogFileName; // log file name
                ServicesLog.Initialize(logFile);                                       // initialize for logging
            }

            catch (Exception ex)
            {
                ServicesLog.Message(DebugLog.FormatExceptionMessage(ex));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize the Mobius internals and command routing table
        /// </summary>

        public static void Initialize()
        {
            string servicesIniFileName = NativeSessionInitializer.GetMobiusServicesIniFileLocation();

            ServicesIniFile.IniFilePath = servicesIniFileName;
            Mobius.UAL.UalUtil.Initialize(servicesIniFileName);

            NativeDebugMode          = ServicesIniFile.IniFile.ReadBool("NativeDebugMode", NativeDebugMode);
            LogServiceCalls          = ServicesIniFile.IniFile.ReadBool("LogServiceCalls", LogServiceCalls);
            ServicesLog.LogToConsole = ServicesIniFile.IniFile.ReadBool("LogToConsole", ServicesLog.LogToConsole);

            NativeSessionInitializer.Instance.InitializeUAL();             // Initialize the UAL to where we can do basic Oracle operations

            Mobius.QueryEngineLibrary.QueryEngine.InitializeForSession();  // Need to initialize the QE on the UI thread

            // Create and populate the command routing table

            Mobius.ServiceFacade.ServiceFacade.UseRemoteServices = false;             // we are the Mobius services, don't want to try to call out for them

            string[] serviceNames = Enum.GetNames(typeof(ServiceCodes));
            OpInvokers = new Dictionary <int, IInvokeServiceOps>(serviceNames.Length);
            Assembly opInvokerAssembly = Assembly.GetAssembly(typeof(IInvokeServiceOps));

            foreach (string serviceName in serviceNames)
            {
                //if (Lex.Eq(serviceName, "MobiusDynamicWebServceDao")) serviceNames = serviceNames; // debug (note typo)

                if (Lex.Contains(serviceName, "Obsolete"))
                {
                    continue;
                }
                try
                {
                    string typeName = "Mobius.Services.Native.OpInvokers." + serviceName + "OpInvoker";
                    Type   iInvokeServiceOpsType = opInvokerAssembly.GetType(typeName);
                    if (iInvokeServiceOpsType == null)
                    {
                        throw new Exception("Service OpInvoker type not found: " + typeName);
                    }
                    ConstructorInfo   iInvokeServiceOpsConstructor = iInvokeServiceOpsType.GetConstructor(Type.EmptyTypes);
                    IInvokeServiceOps serviceOpInvoker             = iInvokeServiceOpsConstructor.Invoke(null) as IInvokeServiceOps;
                    OpInvokers.Add(
                        (int)Enum.Parse(typeof(ServiceCodes), serviceName),
                        serviceOpInvoker);
                }
                catch (Exception ex)
                {
                    DebugLog.Message("Error initializing service: " + serviceName + "\r\n" +
                                     DebugLog.FormatExceptionMessage(ex));            // debug
                }
            }

            return;
        }