コード例 #1
0
ファイル: ProfileWindow.xaml.cs プロジェクト: NaolShow/Wolfy
        /// <summary>
        /// Adds a command to the list of commands
        /// </summary>
        public void AddCommand(JsonCommand _Command)
        {
            // Item
            ListBoxItem _Item = new ListBoxItem()
            {
                Content = _Command.CommandName,
                Tag     = _Command
            };

            // Event
            _Item.Selected += delegate {
                // Prevent crashing
                if (Directory.Exists(_Command.CommandPath))
                {
                    // Edit title
                    this.Title = string.Format(Langs.Get("profile_window_title"), Profile, _Command.CommandName);

                    // Save selected command
                    if (CurrentBoard != null)
                    {
                        CurrentBoard.SaveCommand();
                    }

                    // Set
                    CurrentBoard = new CommandBoard(_Command, _Item);
                    Utils.EmbedUserControl(CurrentBoard, Grid);
                }
            };

            // Add
            CommandsBox.Items.Add(_Item);
        }
コード例 #2
0
        private void btn_Execute_Click(object sender, RoutedEventArgs e)
        {
            var initialCommand = new JsonCommand <BsonDocument>(tbx_command.Text);

            try
            {
                StringBuilder resultText = new StringBuilder();
                var           result     = App._IMongoDB.RunCommand(initialCommand).ToJson(new JsonWriterSettings {
                    OutputMode = JsonOutputMode.Strict
                });

                var firstResultStructure = new { cursor = new { firstBatch = "", id = "", ns = "" }, ok = "" };
                //var firstResObject = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(result.ToString(),firstResultStructure);
                var resultObject = Newtonsoft.Json.Linq.JObject.Parse(result.ToString());
                resultText.Append(resultObject["cursor"]["firstBatch"]);

                while (cbx_getAll.IsChecked == true && (resultObject["cursor"]["id"].ToString() != "0"))
                {
                    resultText.Remove(resultText.Length - 1, 1);
                    resultText.Append(",");
                    var getMoreCommand = new JsonCommand <BsonDocument>("{getMore : NumberLong(\"" + resultObject["cursor"]["id"].ToString() + "\"), collection : \"" + resultObject["cursor"]["ns"].ToString().Replace(Config.Configuration.mongoDatabaseName + ".", "") + "\" }");
                    var nextResult     = App._IMongoDB.RunCommand(getMoreCommand).ToJson(new JsonWriterSettings {
                        OutputMode = JsonOutputMode.Strict
                    });
                    resultObject = Newtonsoft.Json.Linq.JObject.Parse(nextResult.ToString());
                    resultText.Append(resultObject["cursor"]["nextBatch"].ToString().Remove(0, 3));
                }
                var prettyResult = Newtonsoft.Json.Linq.JToken.Parse(result.ToString()).ToString(Formatting.Indented);
                tbx_Results.Text = resultText.ToString();
            }
            catch (Exception ex)
            {
                tbx_Results.Text = ex.ToString();
            }
        }
コード例 #3
0
        public IDataAdapter RunCommand(string command, out string result)
        {
            var jsonCommand = new JsonCommand <BsonDocument>(command);

            result = _db.RunCommand(jsonCommand).ToJson();
            return(this);
        }
コード例 #4
0
        /// <summary>
        /// Execute a command by name
        /// </summary>
        public static void ExecuteCommand(string _CommandName)
        {
            // Start the command in another thread (prevent app from freezing)
            JsonCommand _Command = GetCommand(_CommandName);

            Task.Run(() => ExecCommand(_Command));
        }
コード例 #5
0
        public static JsonCommand CreateGetUserByPINCommand(string pin)
        {
            JsonCommand retval = new JsonCommand("GinkgoDataFoxLib.Service.GinkgoDataFoxService", "GetUserByPIN");

            retval.SetParameter("PIN", pin);
            return(retval);
        }
コード例 #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            ImageWebModel      model  = ImageWebModel.GetModel();
            CommandsController cc     = new CommandsController(model);
            ComunicationClient client = ComunicationClient.GetClient(8000);

            client.CommandReceived += delegate(object senderObj, CommandReceivedEventArgs args)
            {
                JsonCommand jCommand = args.JsonCommand;
                cc.ExecuteCommand(jCommand.CommandID, jCommand.Args, jCommand.JsonData);
            };
            try
            {
                client.ConnectToServer();
                client.sendCommand((int)CommandsEnum.GetConfigCommand, null);
                client.sendCommand((int)CommandsEnum.LogsCommand, null);
            }
            catch
            {
                Console.WriteLine("failed to connect to server");
            }
        }
コード例 #7
0
        //Tipo add(Tipo item);
        public override BDEmpresas add(BDEmpresas bDEmpresas)
        {
            try
            {
                UsuarioContext bd = new UsuarioContext();

                //Genera la empresa
                //BDEmpresas empresa = base.add(bDEmpresas, "Usuarios");
                BDEmpresas empresa = bd.BDEmpresas.add(bDEmpresas, bd);

                //Clona la base de datos principal
                MongoClient    client = new MongoClient(getConnection());
                IMongoDatabase db     = client.GetDatabase("admin");

                var cadena  = String.Format(@"{{ copydb: 1, fromdb: '{0}', todb: '{1}'}}", "AAA010101AAA", empresa.RFC);
                var command = new JsonCommand <BsonDocument>(cadena);
                db.RunCommand(command);

                return(empresa);
            }
            catch (Exception ex)
            {
                Error(ex, "");
                return(null);
            }
        }
コード例 #8
0
        public async Task <(bool success, string message)> AddStempelzeit(bool kommend)
        {
            if (_CurrentUser == null)
            {
                return(false, "Es ist kein Benutzer eingeloggt!");
            }
            Stempelzeit sz = new Stempelzeit();

            sz.IDKontakt     = _CurrentUser.MitarbeiterkontaktIDGinkgo;
            sz.Datum         = DateTime.Now;
            sz.Grund         = kommend ? "K" : "G";
            sz.Manual        = false;
            sz.UserIDCreated = _CurrentUser.ID;
            sz.TimeCreated   = DateTime.Now;
            JsonCommand         cmd      = DataFoxServiceCommands.CreateAddOrUpdateStempelzeitCommand(sz);
            JsonCommandRetValue retValue = await ModulesClientEnvironment.Default.JsonCommandClient.DoCommand(cmd);

            if (retValue.ReturnCode == 200)
            {
                // in diesem Fall die Stempeltag-Tabelle updaten
                this.RefreshStempelTagInfos();
                return(true, retValue.ReturnMessage);
            }
            return(false, retValue.ReturnMessage);
        }
コード例 #9
0
        public static JsonCommand CreateAddOrUpdateStempelzeitCommand(Stempelzeit stempelzeit)
        {
            JsonCommand retval = new JsonCommand("GinkgoDataFoxLib.Service.GinkgoDataFoxService", "AddOrUpdateStempelzeit");

            retval.SetParameter("Stempelzeit", JsonConvert.SerializeObject(stempelzeit));
            return(retval);
        }
コード例 #10
0
        private async void CreateStempelzeit(bool delete)
        {
            Stempelzeit sz = new Stempelzeit();

            sz.Datum         = _StempelTagInfo.Datum.ResetTimePart() + _TimePicker.Time;
            sz.Datum         = sz.Datum.ResetTimePartToMinute();
            sz.Grund         = "G";
            sz.IDKontakt     = _StempelTagInfo.IDKontakt;
            sz.Manual        = true;
            sz.TimeCreated   = DateTime.Now;
            sz.UserIDCreated = _UserID;
            sz.ShouldDeleted = delete;
            sz.UserIDCreated = _UserID;
            JsonCommand         cmd      = DataFoxServiceCommands.CreateAddOrUpdateStempelzeitCommand(sz);
            JsonCommandRetValue retValue = await ModulesClientEnvironment.Default.JsonCommandClient.DoCommand(cmd);

            if (retValue.ReturnCode == 200)
            {
                await Navigation.PopModalAsync();
            }
            else
            {
                DisplayAlert("Fehler", retValue.ReturnMessage, "OK");
            }
        }
コード例 #11
0
ファイル: CommandFactory.cs プロジェクト: trestoh/Wasatch.NET
        public static SortedDictionary <string, Command> loadCommands(string pathname)
        {
            string text = File.ReadAllText(pathname);
            SortedDictionary <string, JsonCommand> jsonCommands = JsonConvert.DeserializeObject <SortedDictionary <string, JsonCommand> >(text);

            if (jsonCommands == null)
            {
                logger.error("could not deserialize {0}", pathname);
                return(null);
            }

            SortedDictionary <string, Command> commands = new SortedDictionary <string, Command>();

            foreach (KeyValuePair <string, JsonCommand> pair in jsonCommands)
            {
                string      name = pair.Key;
                JsonCommand jcmd = pair.Value;
                logger.debug("loaded {0} (opcode {1}, type {2})", name, jcmd.Opcode, jcmd.Type);

                try
                {
                    Command cmd = createCommand(name, jcmd);
                    commands[name] = cmd;
                }
                catch (Exception ex)
                {
                    logger.error("Couldn't parse JSON command {0}: {1}", name, ex);
                }
            }
            return(commands);
        }
コード例 #12
0
        //important!!!!!!!!!!!!
        //we are sorry we didn't implement the mvvm for the main window as we should, we didn't have enough time to fix it.
        //we are aware of this mistake
        //but we implemented the mvvm for the other modules
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new ViewModels.MainWindowViewModel();

            ComunicationClient client     = ComunicationClient.GetClient(8000);
            Controller         controller = new Controller(LogModel.getModel(), SettingsModel.getModel());

            try
            {
                client.ConnectToServer();
                string[] strs = { };
                client.CommandReceived += delegate(object senderObj, CommandReceivedEventArgs args)
                {
                    App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE
                    {
                        JsonCommand jCommand = args.JsonCommand;
                        controller.ExecuteCommand(jCommand.CommandID, jCommand.Args, jCommand.JsonData);
                    });
                };
                client.sendCommand((int)CommandsEnum.GetConfigCommand, strs);
                client.sendCommand((int)CommandsEnum.LogsCommand, strs);
            }
            catch
            {
                this.Background = Brushes.Gray;
                this.IsEnabled  = false;
            }
        }
コード例 #13
0
        public async Task <List <DocumentModel> > ExecuteSearch(IndexModel indexModel, SearchModel searchModel)
        {
            var docs = await DatabaseService.GetAll(indexModel);

            var result = new List <DocumentModel>();

            foreach (var doc in docs)
            {
                var value = JsonCommand.GetValueForKey(doc.Value, searchModel.Key)?.ToString();
                if (value is null)
                {
                    continue;
                }
                var data = await _analyzer.Anal(value);

                var tokens = await _analyzer.Anal(searchModel.Term);

                var flag = new List <bool>();
                foreach (var dat in data)
                {
                    foreach (var token in tokens)
                    {
                        flag.Add(token == dat);
                    }
                }
                if (flag.Contains(true))
                {
                    continue;
                }
                result.Add(doc);
            }

            return(result.Distinct().ToList());
        }
コード例 #14
0
        public static void cacheManagerSetUpsertForProceduce(string key, DateTime cacheTime,
                                                             JsonCommand <BsonDocument> JsonCommand, IMongoDatabase database, string type = "upsert")
        {
            try
            {
                //System.Threading.Tasks.Task.Factory.StartNew(() =>
                //{
                lock (lockobj)
                {
                    ConcurrentBag <Dictionary <string, object> > lst = new ConcurrentBag <Dictionary <string, object> >();
                    lst = (ConcurrentBag <Dictionary <string, object> >)_cache.Get(key);
                    if (lst == null)
                    {
                        lst = new ConcurrentBag <Dictionary <string, object> >();
                    }

                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("key", key);
                    dic.Add("cacheTime", cacheTime);
                    dic.Add("JsonCommand", JsonCommand);
                    dic.Add("database", database);
                    dic.Add("type", type);

                    lst.Add(dic);
                    //_cache.Remove(key);
                    _cache.Set(key, lst, cacheTime);
                }
                // });
                GC.Collect();
            }
            catch (Exception ex)
            { }
        }
コード例 #15
0
        public int executeCommand(string text)
        {
            var command = new JsonCommand <BsonDocument>(text);
            var result  = db.RunCommand(command);

            return((int)result["ok"].AsDouble);
        }
コード例 #16
0
        private async void _ButtGetStempelzeiten_Click(object sender, EventArgs e)
        {
            JsonCommand         cmd    = DataFoxServiceCommands.CreateGetStempelzeitenCommand(45310, DateTime.Today.AddDays(-7), DateTime.Today.MaximizeTimePart(), true);
            JsonCommandRetValue retval = await ModulesClientEnvironment.Default.JsonCommandClient.DoCommand(cmd);

            this._Ausgabe.Text = retval.ReturnCode + "\r\n" + retval.ReturnMessage + "\r\n" + retval.ReturnValue;
        }
コード例 #17
0
        /*
         * Drop a Database
         */
        private static void DropDatabase(IMongoDatabase mdb)
        {
            var cmd = new JsonCommand <BsonDocument>("{dropDatabase: 1}");

            mdb.RunCommand(cmd);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Database is dropped");
        }
コード例 #18
0
        public static JsonCommand CreateGetUserCommand(int userID = 0)
        {
            JsonCommand retval = new JsonCommand("Modules.Users.Service.UserService", "GetUserViewModel");

            if (userID > 0)
            {
                retval.SetParameter("UserID", userID);
            }
            return(retval);
        }
コード例 #19
0
ファイル: GetLogs.cs プロジェクト: muhammedikinci/FuzzyCore
        public string GetAll_WithCommand()
        {
            Logger      L    = new Logger();
            string      logs = L.GetLogs();
            JsonCommand Com  = new JsonCommand();

            Com.CommandType = "get_logs";
            Com.Text        = logs;
            return(JsonConvert.SerializeObject(Com));
        }
コード例 #20
0
        public static JsonCommand CreateGetStempelzeitenCommand(int idKontakt, DateTime datum1, DateTime datum2, bool groupedByDay)
        {
            JsonCommand retval = new JsonCommand("GinkgoDataFoxLib.Service.GinkgoDataFoxService", "GetStempelzeiten");

            retval.SetParameter("IDKontakt", idKontakt);
            retval.SetParameter("Datum1", datum1);
            retval.SetParameter("Datum2", datum2);
            retval.SetParameter("GroupedByDay", groupedByDay);
            return(retval);
        }
コード例 #21
0
        public ConfigInfo GetConfig()
        {
            var settings = _mongoClient.Settings;

            var command  = new JsonCommand <ConfigInfo>("{ connectionStatus: 1, showPrivileges: true }");
            var authInfo = _commentsCollection.Database.RunCommand(command);

            authInfo.Settings = settings;
            return(authInfo);
        }
コード例 #22
0
ファイル: CommandBoard.xaml.cs プロジェクト: NaolShow/Wolfy
        public CommandBoard(JsonCommand _Command, ListBoxItem _Item)
        {
            InitializeComponent();

            // Save
            Command = _Command;
            Item    = _Item;

            #region Events

            // Command name
            CommandNameBox.Text = Command.CommandName;

            CommandNameBox.LostFocus += delegate {
                // Name is valid
                string _Name  = Utils.GetSafeFilename(CommandNameBox.Text.Trim());
                string _Path  = Path.Combine(Profiles.GetProfilePath(), _Name);
                bool   _Valid = (_Name == Command.CommandName || !Directory.Exists(_Path));

                // Apply
                NameCheckIcon.Kind       = _Valid ? PackIconKind.CheckCircleOutline : PackIconKind.CloseOutline;
                NameCheckIcon.Foreground = _Valid ? new SolidColorBrush(Colors.DarkGreen) : new SolidColorBrush(Colors.DarkRed);;

                NewPath = (!Directory.Exists(_Path)) ? _Path : null;
            };

            // Add command variable
            CommandAddBtn.Click += delegate {
                // Key is not null & Key doesn't exist
                string _Key = KeyVariableBox.Text.Replace(" ", "");
                if (!string.IsNullOrEmpty(_Key) && !Command.Command_vars.Keys.Contains(_Key))
                {
                    KeyValuePair <string, string> _Pair = new KeyValuePair <string, string>(_Key, ValueVariableBox.Text);
                    Command.Command_vars.Add(_Pair.Key, _Pair.Value);
                    AddVariable(_Pair);
                }
                else
                {
                    Utils.ErrorLabel(CommandAddError, Langs.Get("variable_already_exist"), 5);
                }
            };

            #endregion

            #region Variables

            // Add variables
            foreach (KeyValuePair <string, string> _Pair in Command.Command_vars)
            {
                AddVariable(_Pair);
            }

            #endregion
        }
コード例 #23
0
        public IEnumerable <JObject> Indexs()
        {
            var command = new JsonCommand <BsonDocument>("{'listIndexes':'Book'}");
            IEnumerable <BsonValue> bsonValues =
                BookCollection.Database.RunCommand(command).AsBsonDocument["cursor"]["firstBatch"].AsBsonArray.Values;

            foreach (BsonValue item in bsonValues)
            {
                yield return(JObject.Parse(item.ToString()));
            }
        }
コード例 #24
0
        public async Task <Dictionary <string, Guid> > AddDocuments(DocumentModel document, int index = 0, params string[] keys)
        {
            var result = new Dictionary <string, Guid>();

            JToken obj = document.Value;

            if (keys.Length > 0)
            {
                foreach (var key in keys)
                {
                    obj = obj?[key];
                }
            }

            if (JsonCommand.CheckIsString(obj))
            {
                foreach (var str in await _analyzer.Anal(obj.ToString()))
                {
                    if (result.ContainsKey(str))
                    {
                        if (result[str] == document.Id)
                        {
                            continue;
                        }
                        result[str] = document.Id;
                    }
                    else
                    {
                        result.Add(str, document.Id);
                    }
                }
            }
            else if (obj.Type == JTokenType.Array)
            {
                var tmp = (JArray)obj;
                foreach (var str in await _analyzer.Anal(tmp[index].ToString()))
                {
                    if (result.ContainsKey(str))
                    {
                        if (result[str] == document.Id)
                        {
                            continue;
                        }
                        result[str] = document.Id;
                    }
                    else
                    {
                        result.Add(str, document.Id);
                    }
                }
            }

            return(result);
        }
コード例 #25
0
        private List <Partner> GetObjects(string filterCmd)
        {
            var mongoClient = _settings.GetMongoClient();
            var db          = mongoClient.GetDatabase(_settings.DatabaseName);
            var cmd         = new JsonCommand <BsonDocument>(filterCmd);
            var response    = db.RunCommand(cmd);

            var obj = response[0]["firstBatch"];

            return(JsonConvert.DeserializeObject <List <Partner> >(obj.ToJson()));
        }
コード例 #26
0
ファイル: MILaunchOptions.cs プロジェクト: Trass3r/MIEngine
 private static string FormatCommand(JsonCommand command)
 {
     return(String.Concat(
                "        <Command IgnoreFailures='",
                command.IgnoreFailures ? "true" : "false",
                "' Description='",
                XmlSingleQuotedAttributeEncode(command.Description),
                "'>",
                command.Text,
                "</Command>\n"
                ));
 }
コード例 #27
0
        private async void _ButtLoginUser_Click(object sender, EventArgs e)
        {
            JsonCommand         cmd    = DataFoxServiceCommands.CreateGetUserByPINCommand("01055854");
            JsonCommandRetValue retval = await ModulesClientEnvironment.Default.JsonCommandClient.DoCommand(cmd);

            this._Ausgabe.Text = retval.ReturnCode + "\r\n" + retval.ReturnMessage + "\r\n" + retval.ReturnValue;
            User usr = JsonConvert.DeserializeObject <User>(retval.ReturnValue);

            this._Ausgabe.Text += "\r\nUrl: " + UserModule.Default.GetUserImageUrl(usr.ID);

            this.pictureEdit1.LoadAsync(UserModule.Default.GetUserImageUrl(usr.ID));
        }
コード例 #28
0
        public static JsonCommand ParseAsCommandRequest(int clientNo, string command)
        {
            JsonCommand req = Jsons.FromJson <JsonCommand>(command);

            if (clientNo > -1)
            {
                req.clientNo = clientNo;
            }


            return(req);
        }
コード例 #29
0
        public Command RunMongoCommand(Command command)
        {
            var com    = new JsonCommand <BsonDocument>(command.JCommand);
            var result = _db.RunCommand(com);

            if (result["ok"].ToString() != "1")
            {
                return(command);
            }

            command.IsSynced = BsonBoolean.True;
            return(command);
        }
コード例 #30
0
        public override void Execute()
        {
            OpenProgram Program = new OpenProgram(Comm);

            string[] list = Program.getProgramList();
            foreach (string item in list)
            {
                JsonCommand CurrentCommand = new JsonCommand();
                CurrentCommand.CommandType = "program_name";
                CurrentCommand.Text        = item;
                Comm.Client_Socket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(CurrentCommand)));
            }
        }
コード例 #31
0
 private static void WriteCommand(JsonCommand cmd)
 {
     try
     {
         string json = new JavaScriptSerializer().Serialize(cmd);
         //First 4 bytes is length
         int DataLength = json.Length;
         Stream stdout = Console.OpenStandardOutput();
         stdout.WriteByte((byte)((DataLength >> 0) & 0xFF));
         stdout.WriteByte((byte)((DataLength >> 8) & 0xFF));
         stdout.WriteByte((byte)((DataLength >> 16) & 0xFF));
         stdout.WriteByte((byte)((DataLength >> 24) & 0xFF));
         Console.Write(json);
     }
     catch { }
 }