Exemple #1
0
        /// <summary>Creates a new instance of the Tsort.PandA.PandaService class.</summary>
        /// <param name="databaseConnection">An ADO.Net database connection string.</param>
        /// <param name="enableUI">Set to true to have a task tray icon displayed that provides access to the Panda Service user interface.</param>
        /// <exceptions cref="ApplicationException">Thrown for unexpected errors.</exceptions>
        public PandaService(string databaseConnection, bool enableUI)
        {
            //Constructor
            try {
                //Configure user access
                if (enableUI)
                {
                    this.mTrayIcon = new TrayIcon("PandA Library", new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("Tsort.PandA.panda.ico")));
                    #region Tray Icon Menu Configuration
                    ctxOpen             = new MenuItem("Open", new System.EventHandler(this.OnIconMenuClicked));
                    ctxOpen.Index       = MNU_ICON_OPEN;
                    ctxOpen.Enabled     = true;
                    ctxOpen.DefaultItem = true;
                    this.mTrayIcon.MenuItems.AddRange(new MenuItem[] { ctxOpen });
                    #endregion
                    this.mTrayIcon.DoubleClick += new System.EventHandler(OnIconDoubleClicked);
                }

                //Get configuration
                PandaPacket.ValidateMessageLength = Convert.ToBoolean(DllConfig.AppSettings("ValidateMessageLength"));
                PandaPacket.CartonIDLength        = Convert.ToInt32(DllConfig.AppSettings("CartonIDLength"));
                PandaPacket.LabelDataLength       = Convert.ToInt32(DllConfig.AppSettings("LabelDataLength"));
                if (databaseConnection.Trim().Length == 0)
                {
                    databaseConnection = DllConfig.AppSettings("SQLConnection");
                }
                LogLevel level = (LogLevel)Convert.ToInt32(DllConfig.AppSettings("TraceLevel"));

                //Create objects
                ArgixTrace.AddListener(new ArgixEventLogTraceListener(level, AppLib.PRODUCTNAME));
                this.mOperator = new StationOperator(databaseConnection);
                if (enableUI)
                {
                    this.mPandaUI = new frmPanda(this, level);
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new PandaService instance.", ex); }
        }