Exemple #1
0
        public async Task StartAsync()
        {
            config = new DiscordSocketConfig()
            {
                MessageCacheSize = 1000000
            };                                        // initialize the config for the client, and set the message cache size
            Client = new DiscordSocketClient(config); // get the client with the configurations we want

            // Managers
            userDataManager = new UserDataManager(); // This sets up the user data files and loads them into memory
            fileManager     = new FileManager();     // initialize the file manager

            // Initialize Handlers
            _commands = new CommandHandler(Client);
            _logs     = new LogHandler();
            _reaction = new ReactionHandler(Client);
            _general  = new GeneralHandler(Client);

            Client.Ready += OnReady;   // Add the OnReady event

            BotUtils.SaveReady = true; // Tell the class that the autosave loop should start
            BotUtils.GCReady   = true;

            StartThreads();

            await Client.LoginAsync(TokenType.Bot, GetToken());

            await Client.StartAsync();

            KLog.Important("Logged in!");

            await Task.Delay(-1);  // Stop this method from exiting.
        }
        public ActionResult CreateOrEditDeliveryOrder()
        {
            var      lastprnumber = _context.DeliveryOrderPusats.OrderByDescending(x => x.CreatedDate).Select(a => a.donumber).FirstOrDefault();
            DateTime?getmonth     = _context.DeliveryOrderPusats.OrderByDescending(x => x.CreatedDate).Select(a => a.CreatedDate).FirstOrDefault();
            DateTime?month        = getmonth != null ? getmonth : DateTime.Now;
            string   prnumber     = lastprnumber != null?GeneralHandler.stringincrement(lastprnumber, Convert.ToDateTime(month)) : "00001";

            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();

            if (Request.QueryString["id"] != null)
            {
                var request = new DeliveryOrderPusatRequest
                {
                    Data = new DeliveryOrderPusatModel
                    {
                        Id = long.Parse(Request.QueryString["id"].ToString())
                    }
                };

                DeliveryOrderPusatResponse resp   = new DeliveryOrderPusatHandler(_unitOfWork).GetDetail(request);
                DeliveryOrderPusatModel    _model = resp.Entity;
                ViewBag.Response = _response;
                return(View(_model));
            }
            else
            {
                ViewBag.Response   = _response;
                ViewBag.ActionType = ClinicEnums.Action.Add;
                ViewBag.prnumber   = "DO" + ((AccountModel)Session["UserLogon"]).Organization + DateTime.Now.Year + DateTime.Now.Month + prnumber;
                return(View());
            }
        }
        public ActionResult GetPurchaseOrderData()
        {
            var _draw          = Request.Form.GetValues("draw").FirstOrDefault();
            var _start         = Request.Form.GetValues("start").FirstOrDefault();
            var _length        = Request.Form.GetValues("length").FirstOrDefault();
            var _sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var _sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
            var _searchValue   = Request.Form.GetValues("search[value]").FirstOrDefault();

            int _pageSize = _length != null?Convert.ToInt32(_length) : 0;

            int _skip = _start != null?Convert.ToInt32(_start) : 0;

            var request = new PurchaseOrderRequest
            {
                Draw          = _draw,
                SearchValue   = _searchValue,
                SortColumn    = _sortColumn,
                SortColumnDir = _sortColumnDir,
                PageSize      = _pageSize,
                Skip          = _skip
            };

            var response = new PurchaseOrderHandler(_unitOfWork).GetListData(request);
            var check    = GeneralHandler.authorized("VALIDATION_M_PURCHASEORDER");
            var check1   = GeneralHandler.authorized("APPROVE_M_PURCHASEORDER");

            return(Json(new { data = response.Data, recordsFiltered = response.RecordsFiltered, recordsTotal = response.RecordsTotal, draw = response.Draw }, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        /// <summary>
        /// 出现异常时
        /// </summary>
        /// <param name="filterContext">异常上下文</param>
        public void OnException(ExceptionContext filterContext)
        {
            if (!filterContext.ExceptionHandled)
            {
                //写操作日志文件
                if (null == this.FLogger)
                {
                    var logPath = System.IO.Path.Combine(FileHelper.AppPath, "logs", "Exception");
                    this.FLogger = new LogHelper(logPath, 2, LogType.Hour);
                }
                this.FLogger.Write(filterContext.Exception.Message, MessageType.Error);
                GeneralHandler.InsertByError(filterContext.Exception); //写入数据库
                var result = "Login";
                switch (TipsMode)
                {
                case 1:
                    result = "ErrorBody";
                    break;

                case 2:
                    result = "ErrorDialog";
                    break;

                case 3:
                    result = "ErrorContent";
                    break;
                }
                filterContext.HttpContext.Session["ErrorMessage"] = filterContext.Exception.Message;
                filterContext.Result           = new RedirectToRouteResult("Default", new RouteValueDictionary(new { controller = "Auth", action = result }));
                filterContext.ExceptionHandled = true;
            }
        }
        public string Synced(FormCollection form)
        {
            var stateInfo = GeneralHandler.StateSuccess;

            if (GetSyncDataByCheck(form, out stateInfo))
            {
                string txtSetCode        = form["txtSetCode"] as string;
                string txtSetName        = form["txtSetName"] as string;
                int    sltSyncItem       = TypeHelper.TypeToInt32(form["sltSyncItem"], 2);
                string txtFieldTable     = form["txtFieldTable"] as string;
                string txtFieldMark      = form["txtFieldMark"] as string;
                string txtFieldName      = form["txtFieldName"] as string;
                string txtFieldMemo      = form["txtFieldMemo"] as string;
                string txtFieldWhere     = form["txtFieldWhere"] as string;
                string txtConnSource     = form["txtConnSource"] as string;
                string txtConnData       = form["txtConnData"] as string;
                string txtConnUser       = form["txtConnUser"] as string;
                string txtConnPwd        = form["txtConnPwd"] as string;
                System.Data.DataTable dt = Session["ExtentSyncData"] as System.Data.DataTable;//直接获取会话数据
                try
                {
                    if (dt.Rows.Count > 0)
                    {
                        if (sltSyncItem == 2)
                        {
                            DawnAuthExtentBLL.DeleteWhere(string.Format("exte_status=2 and exte_code='{0}'", txtSetCode));
                        }
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        //DawnAuthExtentMDL dataInfo;
                        DawnAuthExtentMDL dataInfo = new DawnAuthExtentMDL();
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            //dataInfo = new DawnAuthExtentMDL();
                            dataInfo.ExteTime     = DateTime.Now;
                            dataInfo.ExteStatus   = 2;
                            dataInfo.ExteCode     = txtSetCode;
                            dataInfo.ExteCodeName = txtSetName;
                            dataInfo.ExteMark     = dr[txtFieldMark].ToString();
                            dataInfo.ExteMarkName = dr[txtFieldName].ToString();
                            dataInfo.ExteMemo     = txtFieldMemo == "null" ? "无" : dr[txtFieldMemo].ToString();
                            DawnAuthExtentBLL.Insert(dataInfo);
                        }
                        dataInfo = null;
                    }
                    else
                    {
                        stateInfo = "请先执行【获取数据】操作后,再执行【开始同步】操作。";
                    }
                    Session["ExtentSyncData"] = null;
                }
                catch (Exception ex)
                {
                    Session["ExtentSyncData"] = null;
                    stateInfo = ex.Message;
                    GeneralHandler.InsertByError(ex);
                }
            }
            return(stateInfo);
        }
 public void Register(int msgID, GeneralHandler handler)
 {
     if (this._generalHandlers.ContainsKey(msgID))
     {
         return;
     }
     this._generalHandlers[msgID] = handler;
 }
Exemple #7
0
        public async Task OnReady()
        {
            SetupGeneral();

            await GeneralHandler.UpdateRoleMessage();  // fix the role selection message on startup

            Ready = true;
            KLog.Important("Ready!");
        }
        public ActionResult CreateOrEditPurchaseRequest()
        {
            var      lastprnumber = _context.PurchaseRequests.OrderByDescending(x => x.CreatedDate).Select(a => a.prnumber).FirstOrDefault();
            DateTime?getmonth     = _context.PurchaseRequests.OrderByDescending(x => x.CreatedDate).Select(a => a.CreatedDate).FirstOrDefault();
            DateTime?month        = getmonth != null ? getmonth : DateTime.Now;
            string   prnumber     = lastprnumber != null?GeneralHandler.stringincrement(lastprnumber, Convert.ToDateTime(month)) : "00001";

            PurchaseRequestResponse _response = new PurchaseRequestResponse();

            if (Request.QueryString["id"] != null)
            {
                var request = new PurchaseRequestRequest
                {
                    Data = new PurchaseRequestModel
                    {
                        Id = long.Parse(Request.QueryString["id"].ToString())
                    }
                };

                PurchaseRequestResponse resp   = new PurchaseRequestHandler(_unitOfWork).GetDetail(request);
                PurchaseRequestModel    _model = resp.Entity;
                ViewBag.Response = _response;
                return(View(_model));
            }
            else
            {
                if ((GeneralHandler.authorized("ADD_M_PURCHASEREQUEST") == "false"))
                {
                    return(RedirectToAction("PurchaseRequestList"));
                }
                ViewBag.Response   = _response;
                ViewBag.ActionType = ClinicEnums.Action.Add;
                ViewBag.prnumber   = "PR" + ((AccountModel)Session["UserLogon"]).Organization + DateTime.Now.Year + DateTime.Now.Month + prnumber;
                return(View());
            }
        }
 //Methods
 #region
 private void picPhoneButton_Click(object sender, EventArgs e)
 {
     //Set timestamps here
     if (!callStatus)
     {
         string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         beginCallStamp = DateTime.Parse(time);
     }
     else
     {
         string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         endCallStamp = DateTime.Parse(time);
         bool tFlag = new GeneralHandler().CreateCallLog(client.ClientID, Globals.StaffID, beginCallStamp, endCallStamp);
         if (tFlag)
         {
             MessageBox.Show("The Call was logged", "Log Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("The Call was not logged", "Log Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     CallTest();
 }
        public JsonResult GetStatus(int?id)
        {
            var status = GeneralHandler.PurchaseRequestStatus(id);

            return(Json(new { data = status }, JsonRequestBehavior.AllowGet));
        }
        public string GetSyncData(FormCollection form)
        {
            var stateInfo = GeneralHandler.StateSuccess;

            if (GetSyncDataByCheck(form, out stateInfo))
            {
                string txtSetCode                = form["txtSetCode"] as string;
                string txtSetName                = form["txtSetName"] as string;
                int    sltSyncItem               = TypeHelper.TypeToInt32(form["sltSyncItem"], 2);
                string txtFieldTable             = form["txtFieldTable"] as string;
                string txtFieldMark              = form["txtFieldMark"] as string;
                string txtFieldName              = form["txtFieldName"] as string;
                string txtFieldMemo              = form["txtFieldMemo"] as string;
                string txtFieldWhere             = form["txtFieldWhere"] as string;
                string txtConnSource             = form["txtConnSource"] as string;
                string txtConnData               = form["txtConnData"] as string;
                string txtConnUser               = form["txtConnUser"] as string;
                string txtConnPwd                = form["txtConnPwd"] as string;
                string cmdConn                   = string.Format("Data Source={0};Initial Catalog={1};User Id={2};Password={3};", txtConnSource, txtConnData, txtConnUser, txtConnPwd);
                System.Text.StringBuilder cmdSql = new System.Text.StringBuilder();
                cmdSql.AppendFormat("select {0},{1}", txtFieldMark, txtFieldName);
                if (txtFieldMemo != "null")
                {
                    cmdSql.AppendFormat(",{0}", txtFieldMemo);
                }
                cmdSql.AppendFormat(" from {0}", txtFieldTable);
                if (txtFieldWhere != "null")
                {
                    cmdSql.AppendFormat(" where {0}", txtFieldWhere);
                }
                try
                {
                    System.Data.DataTable dt = DawnXZ.DBUtility.SqlHelper.ExecuteDataset(cmdConn, cmdSql.ToString()).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        Session["ExtentSyncData"] = dt;//存入会话中,以供直接使用
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            sb.Append("<tr>");
                            sb.AppendFormat("<td class=\"per15\">{0}</td>", txtSetCode);
                            sb.AppendFormat("<td class=\"per20\">{0}</td>", txtSetName);
                            sb.AppendFormat("<td class=\"per15\">{0}</td>", dr[txtFieldMark]);
                            sb.AppendFormat("<td class=\"per20\">{0}</td>", dr[txtFieldName]);
                            if (txtFieldMemo != "null")
                            {
                                sb.AppendFormat("<td class=\"per15\">{0}</td>", dr[txtFieldMemo]);
                            }
                            sb.Append("</tr>");
                        }
                        sb.AppendFormat("<tr><td colspan=\"5\"><span class=\"color-blue f14 margin-left-10\">共获取数据:{0}条。</span></td></tr>", dt.Rows.Count);
                        stateInfo = sb.ToString();
                    }
                }
                catch (Exception ex)
                {
                    Session["ExtentSyncData"] = null;
                    stateInfo = string.Format("<tr><td colspan=\"5\"><span class=\"color-red f14 margin-left-10\">{0}</span></td></tr>", ex.Message);
                    GeneralHandler.InsertByError(ex);
                }
            }
            else
            {
                Session["ExtentSyncData"] = null;
                System.Text.StringBuilder sbInfo = new System.Text.StringBuilder();
                sbInfo.Append("<tr><td colspan=\"5\"><span class=\"color-red f14 margin-left-10\">");
                sbInfo.Append(stateInfo);
                sbInfo.Append("</span></td></tr>");
                stateInfo = sbInfo.ToString();
            }
            return(stateInfo);
        }
        public override async Task PerformAction(SocketReaction option)
        {
            string opt = option.Emote.ToString();

            switch (opt)
            {
            case ReactionHandler.CHECK_STR:
                if (Emote == BotUtils.ZeroSpace || Emote == EmptyOrInvalidEmote)
                {
                    Emote = EmptyOrInvalidEmote;
                    await UpdateEmbed();

                    return;
                }

                if (ReactionHandler.RoleMap.ContainsKey(Emote))
                {
                    if (ServerData.Server.GetRole(ReactionHandler.RoleMap[Emote]) == null)
                    {
                        ulong id = ReactionHandler.RoleMap[Emote];

                        ReactionHandler.RoleMap.Remove(Emote);
                        ReactionHandler.SaveRoleMap();

                        EventQueueManager.RemoveEvent(this);
                        await ReactionHandler.CloseActionEmbedAsync(this);

                        await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Something went wrong! Please use the command again!"));

                        KLog.Info($"[REE] Role was null! ID: {id}");
                        return;
                    }

                    Emote = $"The role {ServerData.Server.GetRole(ReactionHandler.RoleMap[Emote]).Mention} already has that emote!";
                    await UpdateEmbed();

                    break;
                }

                if (ServerData.Server.GetRole(Role.Id) == null)
                {
                    ulong id = ReactionHandler.RoleMap[Emote];

                    EventQueueManager.RemoveEvent(this);
                    await ReactionHandler.CloseActionEmbedAsync(this);

                    await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Something went wrong! Please use the command again!"));

                    KLog.Info($"[REE] Role was null! ID: {id}");
                    return;
                }

                ReactionHandler.RoleMap.Add(Emote, Role.Id);
                ReactionHandler.SaveRoleMap();

                await GeneralHandler.UpdateRoleMessage();

                EventQueueManager.RemoveEvent(this);
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Emote Association Added."));

                await Message.DeleteAsync();

                break;

            case ReactionHandler.DECLINE_STR:
                EventQueueManager.RemoveEvent(this);
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Action Canceled."));

                await Message.DeleteAsync();

                break;

            default:
                Emote = option.Emote.ToString();
                await UpdateEmbed();

                break;
            }
        }
Exemple #13
0
        public JsonResult Logined(FormCollection form)
        {
            Hashtable ht = new Hashtable();

            ht.Add("Msg", GeneralHandler.FBaseInfo);
            ht.Add("Url", GeneralHandler.SiteLoginUrl);
            ht.Add("IsCode", false);
            try
            {
                string txtUname = form["txtUname"] as string;
                string txtUpwd  = form["txtUpwd"] as string;
                txtUpwd = CryptoHelper.MD5(txtUpwd, true);
                string txtCheckCode = form["txtCheckCode"] as string;
                txtCheckCode = txtCheckCode.ToLower();
                string strCheckCode = Session["CheckCode"] as string;
                strCheckCode = strCheckCode.ToLower();
                if (txtCheckCode.Length != 4 || !ValidHelper.EngIsEngAndNum(txtCheckCode) || txtCheckCode != strCheckCode)
                {
                    ht["Msg"]    = "您输入的验证码不正确[4个字符]。";
                    ht["IsCode"] = true;
                }
                else if (txtUname.Length < 4 || txtUname.Length > 16 || !ValidHelper.EngIsRegisters(txtUname))
                {
                    ht["Msg"] = "您输入的用户名不正确[4-16个字符]。";
                }
                else if (ValidHelper.IsSqlFilter(txtUname))
                {
                    ht["Msg"] = "您输入的用户名不正确[4-16个字符]。IsSqlFilter";
                }
                else if (!DawnAuthUserBLL.ExistsOfName(txtUname))
                {
                    ht["Msg"] = "您输入的用户名不存在!";
                }
                else
                {
                    var userIList = DawnAuthUserBLL.ISelect(string.Format("[user_name]='{0}' and [user_pwd]='{1}'", txtUname, txtUpwd));
                    if (userIList.Count == 0)
                    {
                        ht["Msg"] = "您输入的用户名与密码不匹配!";
                    }
                    else if (userIList.Count > 1)
                    {
                        ht["Msg"] = "您的账号存在异常,请联系管理员!";
                    }
                    else
                    {
                        var userInfo = userIList.First();
                        if (userInfo.UserStatus == 0)
                        {
                            ht["Msg"] = "您的账号存已禁用,请联系管理员!";
                        }
                        else if (userInfo.UserGrade < 2)
                        {
                            ht["Msg"] = "对不起,您的管理级别不符合!";
                        }
                        else
                        {
                            userIList.Clear();
                            Session["LoginName"] = txtUname;
                            Session[txtUname]    = CryptoHelper.Encrypt(JsonConvert.SerializeObject(userInfo), GeneralHandler.TokenKey);
                            var userAuth = DawnAuthUserBLL.GetUserAuthority(userInfo.UserId);
                            Session["LoginAuthority"] = CryptoHelper.Encrypt(JsonConvert.SerializeObject(userAuth), GeneralHandler.TokenKey);
                            var userStat = DawnAuthUserBLL.GetUserStatus(userInfo.UserId);
                            Session["LoginStatus"] = CryptoHelper.Encrypt(JsonConvert.SerializeObject(userStat), GeneralHandler.TokenKey);
                            var userExtent = DawnAuthUserExtentBLL.ISelect(string.Format("user_id='{0}'", userInfo.UserId));
                            Session["LoginExtent"] = CryptoHelper.Encrypt(JsonConvert.SerializeObject(userExtent), GeneralHandler.TokenKey);
                            FormsAuthentication.SetAuthCookie(CryptoHelper.Encrypt(txtUname, GeneralHandler.TokenKey), false);

                            #region 登录日志

                            DawnAuthUserLoginMDL dataInfo = new DawnAuthUserLoginMDL();
                            dataInfo.UserId      = userInfo.UserId;
                            dataInfo.LogTime     = DateTime.Now;
                            dataInfo.LogIp       = RequestHelper.GetIPAddress();
                            dataInfo.LogMac      = "Unknown";
                            dataInfo.LogComputer = "Unknown";
                            dataInfo.LogAttach   = null;
                            dataInfo.LogCount    = 1;
                            DawnAuthUserLoginBLL.Insert(dataInfo);

                            #endregion

                            ht["Msg"] = GeneralHandler.StateSuccess;
                            ht["Url"] = GeneralHandler.SiteLoginedUrl;
                            //var hidReturnUrl = form["hidReturnUrl"] as string;
                            //ht["Url"] = string.IsNullOrEmpty(hidReturnUrl) ? GeneralHandler.SiteLoginedUrl : hidReturnUrl;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ht["Msg"] = GeneralHandler.StateRefresh;
                ht["Msg"] = "对不起!无法与数据库建立连接!请联系管理员!";
                GeneralHandler.InsertByError(ex);
            }
            return(Json(ht));
        }
Exemple #14
0
        public async Task GenerateCrossBansAsync()
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // permissions checking
            }
            ScanInfoEmbed scan = new ScanInfoEmbed();

            await ReplyAsync(BotUtils.KamtroText("Scanning Kamexico for Bans..."));

            foreach (RestBan ban in await ServerData.Kamexico.GetBansAsync())
            {
                scan.KamexTotal++;
                scan.KamexUnique++;
                scan.Total++;

                GeneralHandler.CrossBan[ban.User.Id] = new CrossBanDataNode(1, ban.Reason);
            }

            await ReplyAsync(BotUtils.KamtroText("Scanning Kamexico for Bans..."));

            foreach (RestBan ban in await ServerData.Retropolis.GetBansAsync())
            {
                scan.RetroTotal++;
                scan.Total++;

                if (GeneralHandler.CrossBan.ContainsKey(ban.User.Id))
                {
                    // if it's a mutual ban
                    scan.Mutual++;
                    scan.KamexUnique--;
                }
                else
                {
                    // else if it's unique to retropolis
                    scan.RetroUnique++;
                }
            }

            int errcount = 0;

            foreach (ulong id in GeneralHandler.CrossBan.Keys)
            {
                if (BotUtils.GetGUser(id) != null)
                {
                    bool sent = await BotUtils.DMUserAsync(BotUtils.GetGUser(id), new BanNotifyEmbed($"You were banned on {GeneralHandler.CrossBan[id].GetServer()}, and therefore have been auto banned from Kamtro.\nOld ban reason:\n\n{GeneralHandler.CrossBan[id].Reason}").GetEmbed());

                    if (!sent)
                    {
                        errcount++;
                    }

                    await ServerData.Server.AddBanAsync(BotUtils.GetGUser(id));

                    scan.InKamtro++;
                }
            }

            if (errcount > 0)
            {
                await ReplyAsync(BotUtils.KamtroText($"{errcount} users could not be messaged."));
            }
            GeneralHandler.SaveList();

            await scan.Display(ServerData.AdminChannel);
        }
Exemple #15
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("Error: Missing arg.\n");
            Console.WriteLine("Usage: ./logging mw-id=<middleware>");
            return(-1);
        }

        Config config = new Config(args);

        //o Create and register custom log handlers
        ErrorHandler   eh = new ErrorHandler();
        WarningHandler wh = new WarningHandler();
        InfoHandler    ih = new InfoHandler();
        VerboseHandler vh = new VerboseHandler();
        DebugHandler   dh = new DebugHandler();
        GeneralHandler gh = new GeneralHandler();

        //  Note: Registration of VERBOSE and DEBUG custom log handlers will
        //        be ignored at the Core API level.
        //
        Log.Info("**** Registering all custom log handlers ****");
        Log.RegisterHandler(LogLevel.logERROR, eh);
        Log.RegisterHandler(LogLevel.logWARNING, wh);
        Log.RegisterHandler(LogLevel.logINFO, ih);
        Log.RegisterHandler(LogLevel.logVERBOSE, vh);
        Log.RegisterHandler(LogLevel.logDEBUG, dh);

        //o Set log reporting level
        Log.SetReportingLevel(LogLevel.logINFO);
        Log.Info("The log reporting level is now set to: " + Log.GetReportingLevel());

        //o Display the GMSEC API version
        Log.Info("API version: " + ConnectionManager.GetAPIVersion());

        try
        {
            //o Create a ConnectionManager
            using (ConnectionManager connMgr = new ConnectionManager(config))
            {
                //o Connect to the GMSEC Bus
                connMgr.Initialize();

                //o Disconnect from the GMSEC Bus
                connMgr.Cleanup();
            }
        }
        catch (GmsecException e)
        {
            Log.Error("Exception: " + e.ToString());
            return(-1);
        }

        //o Unregister all custom log handlers
        Log.Info("**** Un-registering all custom log handlers ****");
        Log.RegisterHandler(null);

        //o Examples of logging messages
        Log.Error("This is an ERROR message");
        Log.Warning("This is a WARNING message");
        Log.Info("This is an INFO message");
        Log.Verbose("This is a VERBOSE message");
        Log.Debug("This is a DEBUG message");              // This message will not be displayed

        //o Reset log reporting level so that all log message are displayed
        Log.SetReportingLevel(LogLevel.logDEBUG);

        //o Confirm logging level
        if (Log.GetReportingLevel() == LogLevel.logDEBUG)
        {
            Log.Info("The log reporting level is now set to: " + Log.GetReportingLevel());
        }
        else
        {
            Log.Error("The log reporting level was NOT changed to logDEBUG");
        }
        Log.Debug("A DEBUG message can now be displayed");

        //o Convert log level names to LogLevel enumerated values
        Log.Error("ERROR reporting level as enum value: " + Log.FromString("ERROR"));
        Log.Warning("WARNING reporting level as enum value: " + Log.FromString("WARNING"));
        Log.Info("INFO reporting level as enum value: " + Log.FromString("INFO"));
        Log.Verbose("VERBOSE reporting level as enum value: " + Log.FromString("VERBOSE"));
        Log.Debug("DEBUG reporting level as enum value: " + Log.FromString("DEBUG"));

        //o Reset log reporting level so that only INFO and below are displayed
        Log.SetReportingLevel(LogLevel.logINFO);

        //o Replace all custom log handlers with a general purpose custom log handler
        Log.Info("**** Registering all general purpose custom log handler ****");
        Log.RegisterHandler(gh);

        Log.Error("ERROR reporting level as string: " + Log.ToString(LogLevel.logERROR));
        Log.Warning("WARNING reporting level as string: " + Log.ToString(LogLevel.logWARNING));
        Log.Info("INFO reporting level as string: " + Log.ToString(LogLevel.logINFO));
        Log.Verbose("VERBOSE reporting level as string: " + Log.ToString(LogLevel.logVERBOSE));           // Not displayed
        Log.Debug("DEBUG reporting level as string: " + Log.ToString(LogLevel.logDEBUG));                 // Not displayed

        //o Unregister (all) custom log handler(s)
        Log.Info("**** Un-registering custom log handler ****");
        Log.RegisterHandler(null);

        Log.Error("This is an ERROR message");
        Log.Warning("This is a WARNING message");
        Log.Info("This is an INFO message");
        Log.Verbose("This is a VERBOSE message");          // Not displayed
        Log.Debug("This is a DEBUG message");              // Not displayed

        return(0);
    }
 public bool TryGetHandler(int msgID, out GeneralHandler handler)
 {
     return(this._generalHandlers.TryGetValue(msgID, out handler));
 }