Ejemplo n.º 1
0
        /// <summary>
        /// close recevied from client. we delete the handler by the given path and
        /// notify logger(withch will notify other clients)
        /// </summary>
        /// <param name="args">args for the command</param>
        /// <param name="result">reference to result flag to update</param>
        /// <returns>an *error message* / folder pathbeing closed</returns>
        public string Execute(string[] args, out bool result)
        {
            // The String Will Return the New Path if result = true, and will return the error message otherwise
            result = true;
            HanddlersController handlersList     = HanddlersController.Instance;
            MessageTypeEnum     resultOfDeleting = MessageTypeEnum.FAIL;
            string status = handlersList.DeleteHandller(args[1] + ":" + args[2]);

            //if(status != )
            m_service.Log("close handler:" + args[1] + ":" + args[2], MessageTypeEnum.WARNING);
            AppCongigSettings settings = AppCongigSettings.Instance;

            settings.Handlers = settings.Handlers.Replace(args[1] + ":" + args[2] + ";", "");
            if (handlersList.Handdlers.Count() == 0)
            {
                settings.Handlers = "";
            }
            if (status.Equals("deleted"))
            {
                resultOfDeleting = MessageTypeEnum.INFO;
            }
            ServerDataReciecedEventArgs a = new ServerDataReciecedEventArgs("Log", (int)resultOfDeleting + ":your reqest was:" + status);

            return(a.ToJSON());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// convart string to settings using json
        /// </summary>
        /// <param name="str"></param>
        /// <returns>AppCongigSettings</returns>
        public static AppCongigSettings FromJSON(string str)
        {
            AppCongigSettings settings    = new AppCongigSettings();
            JObject           settingsObj = JObject.Parse(str);

            settings.Handlers   = (string)settingsObj["Handler"];
            settings.ThumbNail  = (int)settingsObj["thumbNail"];
            settings.LogName    = (string)settingsObj["logName"];
            settings.SourceName = (string)settingsObj["sourceName"];
            settings.OutPutDir  = (string)settingsObj["OutPutDir"];
            return(settings);
        }