Exemple #1
0
        protected void LoadAdapter()
        {
            try
            {
                switch (Program.ConfigMgt.Config.AdapterDirection)
                {
                case DirectionType.INBOUND:
                    if (Program.InAdapter != null)
                    {
                        adapter          = Program.InAdapter.Instance;
                        adapterAttribute = Program.InAdapter.Attribute;
                    }
                    break;

                case DirectionType.OUTBOUND:
                    if (Program.OutAdapter != null)
                    {
                        adapter          = Program.OutAdapter.Instance;
                        adapterAttribute = Program.OutAdapter.Attribute;
                    }
                    break;

                case DirectionType.BIDIRECTIONAL:
                    if (Program.BiAdapter != null)
                    {
                        adapter          = Program.BiAdapter.Instance;
                        adapterAttribute = Program.BiAdapter.Attribute;
                    }
                    break;
                }

                if (adapter == null)
                {
                    Program.Log.Write(LogType.Error, "Cannot create adapter instance.");
                    Program.Log.Write(AssemblyHelper.LastError);
                    return;
                }

                Program.Log.Write("\r\nAdapter Loaded", false);
                Program.Log.Write("---------------------", false);
                if (adapterAttribute != null)
                {
                    Program.Log.Write("Name:" + adapterAttribute.Name);
                    Program.Log.Write("Direction:" + adapterAttribute.Direction.ToString());
                    Program.Log.Write("Description:" + adapterAttribute.Description);
                }
                Program.Log.Write("---------------------\r\n", false);

                if (adapter.Initialize(new string[] {
                    Program.ConfigMgt.Config.DataDBConnection,
                    Program.ConfigMgt.Config.ConfigDBConnection
                }))
                {
                    Program.Log.Write(LogType.Debug, "Adapter initialization succeeded.");
                }
                else
                {
                    Program.Log.Write(LogType.Warning, "Adapter initialization failed.");
                    Program.Log.Write(adapter.LastError);
                }
            }
            catch (Exception err)
            {
                Program.Log.Write(LogType.Error, "Error in loading adapter.");
                Program.Log.Write(err);
            }
        }