/// Function - RunAllChecks
        /// <summary>
        /// Thread starts all checks.
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="pathes"></param>
        static void RunAllChecks(string filePath, string destPath, string [] pathes, ArrayList tools)
        {
            //variable declaration.
            Hashtable keywords = new Hashtable();
            Hashtable includes = new Hashtable();
            Dictionary <string, string>    defines       = new Dictionary <string, string>();
            Dictionary <string, ArrayList> funcVariables = new Dictionary <string, ArrayList>();
            ArrayList globalVariable = new ArrayList();

            //initialize
            try
            {
                GeneralCompilerFunctions.initializeKeywordsAndSyntext(ansiCFile, filePath, CSyntextFile, ignoreVariablesTypesPath, keywords, includes, defines, pathes);
            }
            catch (Exception e)
            {
                AddToLogString(filePath, "ERROR IN PREPROCESSOR");
                ConnectionServer.CloseConnection(threadNumber, "ERROR IN PREPROCESSOR " + e.ToString(), GeneralConsts.ERROR);
            }

            AddToLogString(filePath, keywords.Count.ToString());
            //Syntax Check.
            try
            {
                compileError = GeneralCompilerFunctions.SyntaxCheck(filePath, globalVariable, keywords, funcVariables, threadNumber);
            }
            catch (Exception e)
            {
                AddToLogString(filePath, "ERROR IN SyntaxCheck");
                ConnectionServer.CloseConnection(threadNumber, "ERROR IN SyntaxCheck " + e.ToString(), GeneralConsts.ERROR);
            }

            if (!compileError)
            {
                GeneralCompilerFunctions.printArrayList(filePath, keywords);
                AddToLogString(filePath, keywords.Count.ToString());
                //just tests.
                try
                {
                    GeneralRestApiServerMethods.CreateFinalJson(filePath, includes, globalVariable, funcVariables, defines, final_json);
                }
                catch (Exception e)
                {
                    AddToLogString(filePath, "ERROR Creating final json");
                    ConnectionServer.CloseConnection(threadNumber, "ERROR Creating final json " + e.ToString(), GeneralConsts.ERROR);
                }

                string dataJson = JsonConvert.SerializeObject(final_json[filePath]["codeInfo"]);
                AddToLogString(filePath, "new json " + dataJson);
                Thread threadOpenTools = new Thread(() => RunAllTasks(filePath, destPath, tools));
                threadOpenTools.Start();
                threadOpenTools.Join(GeneralConsts.TIMEOUT_JOIN);
                ConnectionServer.CloseConnection(threadNumber, FINISH_SUCCESFULL, GeneralConsts.FINISHED_SUCCESFULLY);
                AddToLogString(filePath, FINISH_SUCCESFULL);
                Console.WriteLine(logFiles[filePath]);
                Thread writeToFile = new Thread(() => File.AppendAllText(logFile, logFiles[filePath]));
                writeToFile.Start();
                writeToFile.Join(GeneralConsts.TIMEOUT_JOIN);
            }
        }
Exemple #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Name = textBox.Text;

            Name = Name.Trim();

            MainWindow mainWindow = new MainWindow(Name);

            var awayStorage = new ConnectionServer();

            MyProfilePresenter myProfile = new MyProfilePresenter(awayStorage, this, mainWindow);

            myProfile.Initialize();

            try
            {
                LoadProfile?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception)
            {
                MessageBox.Show("Нет соединения с сервером, попробуйте позже");
                mainWindow.Close();
                Close();
                return;
            }

            Hide();

            mainWindow.Show();

            Close();
        }
Exemple #3
0
 public void Disconnected(ConnectionServer connection)
 {
     if (m_RailConnections.ContainsKey(connection))
     {
         m_Instance.RemoveClient(m_RailConnections[connection]);
     }
 }
        public void ConsultarConceptos()
        {
            var conectionServer = new ConnectionServer
            {
                //miConnectionString = "mongodb://*****:*****@ds027325-a0.mongolab.com:27325,ds027325-a1.mongolab.com:27325/abaxxbrl?replicaSet=rs-ds027325",
                miConnectionString = "mongodb://*****:*****@172.16.235.123:27017/repositorioAbaxXbrl",
                miBaseDatos        = "repositorioAbaxXbrl"
                                     //miBaseDatos = "abaxxbrl"
            };

            conectionServer.init();

            var conexion           = new Conexion(conectionServer);
            var blockStoreDocIns   = new BlockStoreDocumentoInstancia(conexion);
            var blockStoreConsulta = new BlockStoreConsulta(conexion);

            var BlockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStoreDocIns,
                BlockStoreConsulta           = blockStoreConsulta,
                Collection          = "BlockStoreHecho",
                CollectionDimension = "BlockStoreDimension",
                CollectionEmpresas  = "BlockStoreEmpresa",
                CollectionUnidades  = "BlockStoreUnidad",
                CollectionConcepto  = "BlockStoreConcepto"
            };

            //var resultadoOperacion = BlockStoreHechoService.ConsultarConceptos("http://www.bmv.com.mx/fr/ics/2012-04-01/ifrs-mx-ics-entryPoint-all");
            var resultadoOperacion = BlockStoreHechoService.ConsultarConceptos("http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05");

            var valores = resultadoOperacion.InformacionExtra;

            Debug.WriteLine(valores.ToString());
        }
        public void ConsultarDimensiones()
        {
            var conectionServer = new ConnectionServer
            {
                //miConnectionString = "mongodb://*****:*****@ds027325-a0.mongolab.com:27325,ds027325-a1.mongolab.com:27325/abaxxbrl?replicaSet=rs-ds027325",
                miConnectionString = "mongodb://*****:*****@172.16.235.123:27017/repositorioAbaxXbrl",
                miBaseDatos        = "repositorioAbaxXbrl"
            };

            conectionServer.init();

            var conexion           = new Conexion(conectionServer);
            var blockStoreDocIns   = new BlockStoreDocumentoInstancia(conexion);
            var blockStoreConsulta = new BlockStoreConsulta(conexion);

            var BlockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStoreDocIns,
                BlockStoreConsulta           = blockStoreConsulta,
                Collection          = "BlockStoreHecho",
                CollectionDimension = "BlockStoreDimension",
                CollectionEmpresas  = "BlockStoreEmpresa",
                CollectionUnidades  = "BlockStoreUnidad",
                CollectionConcepto  = "BlockStoreConcepto"
            };

            var resultadoOperacion = BlockStoreHechoService.ConsultarDimensionesPorConcepto("ifrs-full_Equity", "");
            var valores            = resultadoOperacion.InformacionExtra;

            Debug.WriteLine(valores.ToString());
        }
Exemple #6
0
        public void ClientJoined(ConnectionServer connection)
        {
            RailNetPeerWrapper peer = connection.GameStatePersistence as RailNetPeerWrapper;

            m_RailConnections.Add(connection, peer);
            m_Instance.AddClient(peer, ""); // TODO: Name
        }
        public void generarDocumentoConHechosDocumentoInstancia()
        {
            var conectionServer = new ConnectionServer
            {
                miConnectionString = "mongodb://*****:*****@172.16.235.125:27017/repositorioAbaxXbrl",
                miBaseDatos        = "repositorioAbaxXbrl"
            };

            var conexion                     = new Conexion(conectionServer);
            var blockStore                   = new BlockStoreDocumentoInstancia(conexion);
            var blockStoreConsulta           = new BlockStoreConsulta(conexion);
            var ConsumerFactoryTaskHechoImpl = new ConsumerFactoryTaskHechoImpl {
                numeroMaximoConsumidores = 25, con = conexion
            };

            var blockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStore,
                BlockStoreConsulta           = blockStoreConsulta,
                Collection               = "BlockStoreHecho",
                CollectionDimension      = "BlockStoreDimension",
                CollectionEmpresas       = "BlockStoreEmpresa",
                CollectionUnidades       = "BlockStoreUnidad",
                CollectionConcepto       = "BlockStoreConcepto",
                ConsumerFactoryTaskHecho = ConsumerFactoryTaskHechoImpl
            };


            string line;

            LogUtil.LogDirPath = ".\\";
            LogUtil.Inicializa();

            var procesarList = new List <string> {
                //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/trac.json"
                //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/2015/ifrsxbrl_622986_2015-02_1_AUTLAN.json"
                "C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/2015/ifrsxbrl_636036_2015-01_1_ALPEK.json"
            };


            var targetDirectory = "C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/resultado";

            string[] fileEntries = Directory.GetFiles(targetDirectory);

            using (StreamWriter archivoSalida = new StreamWriter(@"C:\Users\Luis Angel\Documents\Workspace\informacionTaxonomia2012.json"))
            {
                foreach (var itemArchivo in fileEntries)
                //foreach (var itemArchivo in procesarList)
                {
                    using (var streamReader = new StreamReader(itemArchivo)) line = streamReader.ReadToEnd();
                    var settings = new JsonSerializerSettings {
                        NullValueHandling = NullValueHandling.Ignore
                    };
                    var documentoInstanciXbrlDto = JsonConvert.DeserializeObject <DocumentoInstanciaXbrlDto>(line, settings);

                    blockStoreHechoService.generarHechosDocumentoInstancia(documentoInstanciXbrlDto, archivoSalida);
                }
            }
        }
Exemple #8
0
 public virtual void Disconnected(ConnectionServer con, EDisconnectReason eReason)
 {
     Logger.Info("Connection closed: {connection}. {reason}.", con, eReason);
     con.Disconnect(eReason);
     if (!m_ActiveConnections.Remove(con))
     {
         Logger.Error("Unknown connection: {connection}.", con);
     }
 }
Exemple #9
0
 /// <summary>
 /// Обработчик старта программы.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     // Проверка на уже запущенный экземпляр программы.
     if (RunOnlyOne.CheckRunProgram("CartAccClient"))
     {
         return;
     }
     // Создать подключение к серверу.
     ConnectionServer.Create(JsonFileAppConfig.Config.GetConnectionString());
 }
Exemple #10
0
        public void OnPeerConnected(NetPeer peer)
        {
            LiteNetConnection  network     = new LiteNetConnection(peer);
            RailNetPeerWrapper persistence = new RailNetPeerWrapper(network);
            ConnectionServer   con         = new ConnectionServer(network, persistence, m_WorldData);

            con.PrepareForClientConnection();
            peer.Tag = con;
            m_Server.Connected(con);
        }
Exemple #11
0
        public void Test5()
        {
            ConnectionServer server = new ConnectionServer();

            server.LoadMessage("v", "v");

            Assert.True(server.Messages.Value != null);

            server.ContactsStatusUpdate("v", true);

            Assert.True(server.StatusUpdate.Key == new KeyValuePair <string, bool>("v", true).Key);
        }
Exemple #12
0
        public void Test7()
        {
            ConnectionServer server = new ConnectionServer();

            var mock = new Mock <IMessengerServerService>();

            server.Client = mock.Object;

            server.Save(null);

            mock.Verify(foo => foo.UploadingUserData(It.IsAny <User>()), Times.Never);
        }
Exemple #13
0
        public void Test6()
        {
            var student = new Contact
            {
                MessageHistory = "2412",
                Name           = "40",
                Online         = true
            };

            var student2 = new Contact
            {
                MessageHistory = "2412",
                Name           = "42",
                Online         = true
            };

            var contactList = new List <Contact> {
                student, student2
            };

            var profile = new MyProfile
            {
                MyContacts = contactList,
                MyName     = "i"
            };

            ConnectionServer server = new ConnectionServer();

            var mock = new Mock <IMessengerServerService>();

            var list = new[]
            {
                new Friend
                {
                    Name   = "Man",
                    Online = true
                },
                new Friend
                {
                    Name   = "LOL",
                    Online = true
                }
            };

            mock.Setup(foo => foo.FindUser("dsa")).Returns(list);

            server.Client = mock.Object;

            server.AddContact("dsa");

            mock.Verify(foo => foo.FindUser("dsa"), Times.Once);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            (new DeviceServer()).Go();

            var cs = new ConnectionServer(7009);

            cs.OnClientConnect += Cs_OnClientConnect;
            cs.Start();
            while (true)
            {
                Thread.Sleep(-1);
            }
        }
        //[TestMethod]
        public void SentMessageIsProcessed()
        {
            var       hostname = "127.0.0.1";
            const int port     = 10_000;

            var storage    = new InMemoryStorageEngine();
            var scheduler1 = ExecutionEngineFactory.StartNew(storage);

            scheduler1.Schedule(() =>
            {
                var msgHandler         = new MessageHandler();
                var connectionListener = new ConnectionServer(hostname, port, msgHandler.Handle);

                Roots.Entangle(msgHandler);
                Roots.Entangle(connectionListener);
            });

            var senderId  = Guid.Empty;
            var msgSender = new TestMessageSender(hostname, port, senderId);

            msgSender.Connect();
            msgSender.SendMessage("HELLO".GetUtf8Bytes(), 0);
            Thread.Sleep(1000);

            var messageHandler = scheduler1.Resolve <MessageHandler>().Result;
            var messages       = messageHandler.GetMessages();

            messages.Count.ShouldBe(1);
            messages[0].ShouldBe("HELLO");

            scheduler1.Do <ConnectionServer>(c => c.Shutdown());

            Thread.Sleep(1000);

            scheduler1.Dispose();
            scheduler1     = ExecutionEngineFactory.Continue(storage);
            messageHandler = scheduler1.Resolve <MessageHandler>().Result;
            Console.WriteLine(messageHandler);

            msgSender = new TestMessageSender(hostname, port, senderId);
            msgSender.Connect();
            msgSender.SendMessage("HELLO2".GetUtf8Bytes(), 1);
            Thread.Sleep(1000);

            messages = messageHandler.GetMessages();
            messages.Count.ShouldBe(2);
            messages[0].ShouldBe("HELLO");
            messages[1].ShouldBe("HELLO2");

            scheduler1.Dispose();
        }
Exemple #16
0
        private async Task ListenForConnectionsSSLAsync()
        {
            while (_isRunning)
            {
                try
                {
                    var client = await _server.AcceptTcpClientAsync();

                    var sslStream = new SslStream(client.GetStream());
                    await sslStream.AuthenticateAsServerAsync(new X509Certificate2(_certificate, _certificatePassword));

                    if (sslStream.IsAuthenticated && sslStream.IsEncrypted)
                    {
                        var reader = new StreamReader(sslStream);
                        var writer = new StreamWriter(sslStream)
                        {
                            AutoFlush = true,
                            NewLine   = _parameters.EndOfLineCharacters
                        };

                        var connection = new ConnectionServer
                        {
                            Client       = client,
                            Reader       = reader,
                            Writer       = writer,
                            ConnectionId = Guid.NewGuid().ToString()
                        };

                        await FireEventAsync(this, new TcpConnectionServerEventArgs
                        {
                            ConnectionEventType = ConnectionEventType.Connected,
                            Connection          = connection,
                        });

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        StartListeningForMessagesAsync(connection);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                        _numberOfConnections++;
                    }
                }
                catch (Exception ex)
                {
                    await FireEventAsync(this, new TcpErrorServerEventArgs
                    {
                        Exception = ex,
                        Message   = ex.Message,
                    });
                }
            }
        }
 /// Function - MainLoopToGetFiles
 /// <summary>
 /// The function that runs the whole loop of the program that gets new files from the server and
 /// take cares of them and runs RunAllChecks Function.
 /// </summary>
 static void MainLoopToGetFiles()
 {
     while (ConnectionServer.GetCloseAllBool() == false)
     {
         //checks if something got added to the server list by the gui. if it did
         //it copies it to the main current list and start to run all the checks on the paths
         //got by the gui (the data inside the List is the user paths.).
         ArrayList list = Server.ConnectionServer.GetThreadsData();
         if (list.Count > currentDataList.Count)
         {
             //adds to the current data list the original server data list last node.
             ArrayList tools = new ArrayList();
             currentDataList.Add(list[currentDataList.Count]);
             AddToLogString(MAIN_DICT_INDEX, currentDataList[currentDataList.Count - 1].ToString());
             string[] paths    = Regex.Split((string)currentDataList[currentDataList.Count - 1], ",");
             string   filePath = paths[FILE_PATH_INDEX];
             if (logFiles.ContainsKey(filePath))
             {
                 logFiles[filePath] = GeneralConsts.EMPTY_STRING;
             }
             else
             {
                 logFiles.Add(filePath, GeneralConsts.EMPTY_STRING);
             }
             AddToLogString(filePath, "FilePath - " + filePath);
             string[] pathes   = { paths[PROJECT_FOLDER_INDEX], paths[GCC_INCLUDE_FOLDER_INDEX], paths[EXTRA_INCLUDE_FOLDER_INDEX] };
             string   destPath = paths[DEST_PATH_INDEX];
             for (int i = START_TOOLS_INDEX; i < paths.Length; i++)
             {
                 tools.Add(paths[i]);
             }
             //because i still dont have a prefect checks for headers so im giving the thread a default null so the program can run.
             Thread runChecksThread = null;
             if (filePath.Substring(filePath.Length - 1) == "h")
             {
                 //Run header file checks.
             }
             else
             {
                 runChecksThread = new Thread(() => RunAllChecks(filePath, destPath, pathes, tools));
             }
             runChecksThread.Start();
         }
         else
         {
             Thread.Sleep(TIMEOUT_SLEEP);
         }
     }
 }
Exemple #18
0
 public ConnectionServer_Test()
 {
     m_NetworkConnection
     .Setup(
         con => con.SendRaw(It.IsAny <ArraySegment <byte> >(), It.IsAny <EDeliveryMethod>()))
     .Callback(
         (ArraySegment <byte> arg, EDeliveryMethod eMethod) => m_SendRawParams.Add(arg));
     m_GamePersistence = new Mock <IGameStatePersistence>();
     m_GamePersistence.Setup(per => per.Receive(It.IsAny <ArraySegment <byte> >()))
     .Callback(
         (ArraySegment <byte> arg) => m_PersistenceReceiveParam = arg);
     m_Connection = new ConnectionServer(
         m_NetworkConnection.Object,
         m_GamePersistence.Object,
         m_WorldData.Object);
 }
Exemple #19
0
        public void CargarInformacionFinancieraComprimidaEnMongoDB()
        {
            var conectionServer = new ConnectionServer
            {
                //connectionString = "mongodb://*****:*****@ds048878.mongolab.com:48878/abaxxbrl",
                miBaseDatos = "abaxxbrl"
            };

            conectionServer.init();

            var conexion   = new Conexion(conectionServer);
            var blockStore = new BlockStoreDocumentoInstancia(conexion);

            var BlockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStore,
                Collection = "InfFinanXbrl"
            };

            var streamReader = new StreamReader("d:/InformacionFinancieraJSON1.zip");

            var stream = streamReader.BaseStream;

            using (var zipFile = ZipFile.Read(stream))
            {
                var tmpDir = UtilAbax.ObtenerDirectorioTemporal();
                zipFile.ExtractAll("d:/TemporalesJson1", ExtractExistingFileAction.OverwriteSilently);

                foreach (var archivoInterno in zipFile)
                {
                    if (!archivoInterno.IsDirectory)
                    {
                        var json = "";
                        using (var streamReaderFile = new StreamReader("d:/TemporalesJson1" + Path.DirectorySeparatorChar + archivoInterno.FileName))
                            json = streamReaderFile.ReadToEnd();

                        var settings = new JsonSerializerSettings {
                            NullValueHandling = NullValueHandling.Ignore
                        };
                        var documentoInstanciXbrlDto = JsonConvert.DeserializeObject <DocumentoInstanciaXbrlDto>(json, settings);

                        var resultadoOperacion = BlockStoreHechoService.registrarHechosDocumentoInstancia(documentoInstanciXbrlDto, 1, 1);
                    }
                }
            }
        }
Exemple #20
0
        public void CargarInformacionFinancieraDirectorioEnMongoDB()
        {
            var conectionServer = new ConnectionServer
            {
                //connectionString = "mongodb://*****:*****@ds027325-a0.mongolab.com:27325,ds027325-a1.mongolab.com:27325/abaxxbrl?replicaSet=rs-ds027325",
                miBaseDatos = "abaxxbrl"
            };

            conectionServer.init();

            var conexion   = new Conexion(conectionServer);
            var blockStore = new BlockStoreDocumentoInstancia(conexion);

            var BlockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStore,
                Collection = "InfFinanXbrl"
            };

            string[] fileEntries     = Directory.GetFiles("D:/TemporalesJson/resultado");
            var      numeroRegistros = 0;

            foreach (var file in fileEntries)
            {
                var json = "";
                using (var streamReaderFile = new StreamReader(file))
                    json = streamReaderFile.ReadToEnd();
                var settings = new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                };
                var documentoInstanciXbrlDto = JsonConvert.DeserializeObject <DocumentoInstanciaXbrlDto>(json, settings);
                var resultadoOperacion       = BlockStoreHechoService.registrarHechosDocumentoInstancia(documentoInstanciXbrlDto, 1, 1);
                Debug.WriteLine("Registro del archivo: " + file + ": Numero de registro: " + numeroRegistros);

                numeroRegistros++;
            }
        }
Exemple #21
0
        public void Test1()
        {
            var student = new Contact
            {
                MessageHistory = "2412",
                Name           = "40",
                Online         = true
            };

            var student2 = new Contact
            {
                MessageHistory = "2412",
                Name           = "42",
                Online         = true
            };

            var contactList = new List <Contact> {
                student, student2
            };

            var profile = new MyProfile
            {
                MyContacts = contactList,
                MyName     = "Vova"
            };

            ConnectionServer server = new ConnectionServer();

            var mock = new Mock <IMessengerServerService>();

            server.Client = mock.Object;

            server.Save(profile);

            mock.Verify(foo => foo.UploadingUserData(It.IsAny <User>()), Times.Once);
        }
Exemple #22
0
        public void Test3()
        {
            var student = new Contact
            {
                MessageHistory = "2412",
                Name           = "40",
                Online         = true
            };

            var student2 = new Contact
            {
                MessageHistory = "2412",
                Name           = "42",
                Online         = true
            };

            var contactList = new List <Contact> {
                student, student2
            };

            var profile = new MyProfile
            {
                MyContacts = contactList,
                MyName     = "i"
            };

            ConnectionServer server = new ConnectionServer();

            var mock = new Mock <IMessengerServerService>();

            server.Client = mock.Object;

            server.AddContact("vally");

            mock.Verify(foo => foo.FindUser("vally"), Times.Once);
        }
Exemple #23
0
 private void OnClientConnected(ConnectionServer connection)
 {
     connection.OnClientJoined += Persistence.ClientJoined;
     connection.OnDisconnected += Persistence.Disconnected;
 }
        public void ConsultarRepositorioInformacion()
        {
            var conectionServer = new ConnectionServer
            {
                miConnectionString = "mongodb://*****:*****@ds035185-a0.mongolab.com:35185,ds035185-a1.mongolab.com:35185/repositorioabaxxbrl?replicaSet=rs-ds035185",
                //miConnectionString = "mongodb://*****:*****@172.16.235.123:27017/repositorioAbaxXbrl",
                //miBaseDatos = "repositorioAbaxXbrl"
                miBaseDatos = "repositorioabaxxbrl"
            };

            conectionServer.init();

            var conexion            = new Conexion(conectionServer);
            var blockStoreDocIns    = new BlockStoreDocumentoInstancia(conexion);
            var blockStoreConsulta  = new BlockStoreConsulta(conexion);
            var GrupoEmpresaService = new GrupoEmpresaService
            {
                EmpresaRepository           = new EmpresaRepository(),
                GrupoEmpresaRepository      = new GrupoEmpresaRepository(),
                RegistroAuditoriaRepository = new RegistroAuditoriaRepository()
            };

            var BlockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStoreDocIns,
                BlockStoreConsulta           = blockStoreConsulta,
                Collection          = "BlockStoreHecho",
                CollectionDimension = "BlockStoreDimension",
                CollectionEmpresas  = "BlockStoreEmpresa",
                CollectionUnidades  = "BlockStoreUnidad",
                CollectionConcepto  = "BlockStoreConcepto",
                GrupoEmpresaService = GrupoEmpresaService
            };

            var filtroConsulta = new EntFiltroConsultaHecho();

            filtroConsulta.filtros = new EntFiltrosAdicionales();

            filtroConsulta.filtros.entidadesId    = new string[2];
            filtroConsulta.filtros.entidadesId[0] = "DAIMLER";
            filtroConsulta.filtros.entidadesId[1] = "AEROMEX";

            filtroConsulta.filtros.unidades    = new string[2];
            filtroConsulta.filtros.unidades[0] = "MXN";
            filtroConsulta.filtros.unidades[1] = "USD";

            filtroConsulta.filtros.periodos = new EntPeriodo[3];

            filtroConsulta.filtros.periodos[0] = new EntPeriodo();
            filtroConsulta.filtros.periodos[1] = new EntPeriodo();
            filtroConsulta.filtros.periodos[2] = new EntPeriodo();

            filtroConsulta.filtros.periodos[0].FechaInicio = new DateTime(2015, 1, 1);
            filtroConsulta.filtros.periodos[0].FechaFin    = new DateTime(2015, 6, 30);

            filtroConsulta.filtros.periodos[1].FechaInicio = new DateTime(2015, 4, 1);
            filtroConsulta.filtros.periodos[1].FechaFin    = new DateTime(2015, 6, 30);

            filtroConsulta.filtros.periodos[2].FechaInicio = new DateTime(2014, 4, 1);
            filtroConsulta.filtros.periodos[2].FechaFin    = new DateTime(2014, 12, 31);


            filtroConsulta.idioma       = "es";
            filtroConsulta.conceptos    = new EntConcepto[6];
            filtroConsulta.conceptos[0] = new EntConcepto();
            filtroConsulta.conceptos[1] = new EntConcepto();
            filtroConsulta.conceptos[2] = new EntConcepto();
            filtroConsulta.conceptos[3] = new EntConcepto();
            filtroConsulta.conceptos[4] = new EntConcepto();
            filtroConsulta.conceptos[5] = new EntConcepto();


            filtroConsulta.conceptos[0].Id                      = "ifrs-full_AdministrativeExpense";
            filtroConsulta.conceptos[0].EsAbstracto             = false;
            filtroConsulta.conceptos[0].EspacioNombresTaxonomia = "http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05";
            filtroConsulta.conceptos[0].Indentacion             = 1;
            filtroConsulta.conceptos[0].orden                   = 1;



            filtroConsulta.conceptos[1].Id                      = "ifrs-full_DistributionCosts";
            filtroConsulta.conceptos[1].EsAbstracto             = false;
            filtroConsulta.conceptos[1].EspacioNombresTaxonomia = "http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05";
            filtroConsulta.conceptos[1].Indentacion             = 1;
            filtroConsulta.conceptos[1].orden                   = 2;

            filtroConsulta.conceptos[2].Id                      = "ifrs-full_Inventories";
            filtroConsulta.conceptos[2].EsAbstracto             = false;
            filtroConsulta.conceptos[2].EspacioNombresTaxonomia = "http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05";
            filtroConsulta.conceptos[2].Indentacion             = 1;
            filtroConsulta.conceptos[2].orden                   = 2;

            filtroConsulta.conceptos[3].Id                                         = "ifrs-full_Equity";
            filtroConsulta.conceptos[3].EsAbstracto                                = false;
            filtroConsulta.conceptos[3].EspacioNombresTaxonomia                    = "http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05";
            filtroConsulta.conceptos[3].Indentacion                                = 2;
            filtroConsulta.conceptos[3].orden                                      = 2;
            filtroConsulta.conceptos[3].InformacionDimensional                     = new EntInformacionDimensional[1];
            filtroConsulta.conceptos[3].InformacionDimensional[0]                  = new EntInformacionDimensional();
            filtroConsulta.conceptos[3].InformacionDimensional[0].Explicita        = true;
            filtroConsulta.conceptos[3].InformacionDimensional[0].IdDimension      = "ifrs-full_ComponentsOfEquityAxis";
            filtroConsulta.conceptos[3].InformacionDimensional[0].IdItemMiembro    = "ifrs-full_OtherReservesMember";
            filtroConsulta.conceptos[3].InformacionDimensional[0].QNameDimension   = "http://xbrl.ifrs.org/taxonomy/2014-03-05/ifrs-full:ComponentsOfEquityAxis";
            filtroConsulta.conceptos[3].InformacionDimensional[0].QNameItemMiembro = "http://xbrl.ifrs.org/taxonomy/2014-03-05/ifrs-full:OtherReservesMember";



            filtroConsulta.conceptos[4].Id                                       = "ifrs_mx-cor_20141205_ComercioExteriorBancarios";
            filtroConsulta.conceptos[4].EsAbstracto                              = false;
            filtroConsulta.conceptos[4].EspacioNombresTaxonomia                  = "http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05";
            filtroConsulta.conceptos[4].Indentacion                              = 2;
            filtroConsulta.conceptos[4].orden                                    = 5;
            filtroConsulta.conceptos[4].InformacionDimensional                   = new EntInformacionDimensional[1];
            filtroConsulta.conceptos[4].InformacionDimensional[0]                = new EntInformacionDimensional();
            filtroConsulta.conceptos[4].InformacionDimensional[0].Explicita      = false;
            filtroConsulta.conceptos[4].InformacionDimensional[0].IdDimension    = "ifrs_mx-cor_20141205_InstitucionEje";
            filtroConsulta.conceptos[4].InformacionDimensional[0].QNameDimension = "http://bmv.com.mx/ifrs_mx-cor_20141205/full_ifrs_mx-cor_2014-12-05:InstitucionEje";
            filtroConsulta.conceptos[4].InformacionDimensional[0].Filtro         = "TOTAL";


            filtroConsulta.conceptos[5].Id                      = "ifrs-mc_DisclosureOfResultsOfOperationsAndProspectsExplanatory";
            filtroConsulta.conceptos[5].EsAbstracto             = false;
            filtroConsulta.conceptos[5].EspacioNombresTaxonomia = "http://www.bmv.com.mx/taxonomy/ifrs_mx/full_ifrs_mc_mx_ics_entry_point_2014-12-05";
            filtroConsulta.conceptos[5].Indentacion             = 3;
            filtroConsulta.conceptos[5].orden                   = 6;



            var filtroJson = JsonConvert.SerializeObject(filtroConsulta);



            var resultado = BlockStoreHechoService.ConsultarRepositorio(filtroConsulta, 1, 100);

            Debug.WriteLine(resultado.ToString());
        }
Exemple #25
0
 public virtual void Connected(ConnectionServer con)
 {
     m_ActiveConnections.Add(con);
     OnClientConnected?.Invoke(con);
     Logger.Info("Connection established: {connection}.", con);
 }
Exemple #26
0
        /// Function - SyncServer
        /// <summary>
        /// Creation of the rest api server.
        /// </summary>
        /// <param name="filePath"> Path for the code file.</param>
        /// <param name="includes"> Hashtable for all of the includes in the code.</param>
        /// <param name="defines"> Dictionary that stores all of the defines in the code.</param>
        public SyncServer()
        {
            var listener = new HttpListener();

            //add prefixes.
            listener.Prefixes.Add("http://localhost:8081/");
            listener.Prefixes.Add("http://127.0.0.1:8081/");
            //start listening.
            listener.Start();

            while (ConnectionServer.GetCloseAllBool() == false)
            {
                try
                {
                    //if gets connection.
                    var context = listener.GetContext(); //Block until a connection comes in
                    context.Response.StatusCode  = 200;
                    context.Response.SendChunked = true;
                    context.Response.ContentType = "application/json";
                    string dataJson = GeneralConsts.EMPTY_STRING;
                    Dictionary <string, Dictionary <string, object> > final_json = MainProgram.GetFinalJson();
                    string filePath          = context.Request.QueryString["filePath"];
                    bool   not_found_pattern = false;
                    bool   not_found         = false;
                    char[] trimChars         = { '/', ' ' };
                    int    totalTime         = 0;
                    string path = GeneralConsts.EMPTY_STRING;
                    Regex  r;
                    //All GET commands.
                    if (context.Request.HttpMethod == "GET")
                    {
                        if (context.Request.QueryString["pattern"] != null)
                        {
                            MainProgram.AddToLogString(filePath, context.Request.QueryString["pattern"]);
                            MainProgram.AddToLogString(filePath, context.Request.QueryString["returnSize"]);
                            r = new Regex(context.Request.QueryString["pattern"]);
                            string    returnSize = context.Request.QueryString["returnSize"];
                            string [] result     = GeneralRestApiServerMethods.SearchPattern(r, returnSize, filePath);
                            dataJson = JsonConvert.SerializeObject(result);
                            MainProgram.AddToLogString(filePath, dataJson);
                        }
                        else if (context.Request.QueryString["readyPattern"] != null)
                        {
                            MainProgram.AddToLogString(filePath, context.Request.QueryString["readyPattern"]);
                            MainProgram.AddToLogString(filePath, context.Request.QueryString["returnSize"]);
                            if (GeneralRestApiServerMethods.TakePatternFromFile(context.Request.QueryString["readyPattern"]) == GeneralConsts.EMPTY_STRING)
                            {
                                not_found_pattern = true;
                            }
                            else
                            {
                                r = new Regex(GeneralRestApiServerMethods.TakePatternFromFile(context.Request.QueryString["readyPattern"]));
                                string   returnSize = context.Request.QueryString["returnSize"];
                                string[] result     = GeneralRestApiServerMethods.SearchPattern(r, returnSize, filePath);
                                dataJson = JsonConvert.SerializeObject(result);
                            }
                        }
                        else
                        {
                            path = context.Request.RawUrl;
                            path = path.Trim(trimChars);
                            path = path.Split('?')[0];
                            MainProgram.AddToLogString(filePath, path);
                            //switch case for get commands.
                            switch (path)
                            {
                            case "functions":
                                dataJson = JsonConvert.SerializeObject(final_json[filePath]["function"]);
                                MainProgram.AddToLogString(filePath, dataJson);
                                break;

                            case "codeInfo":
                                dataJson = JsonConvert.SerializeObject(final_json[filePath]["codeInfo"]);
                                MainProgram.AddToLogString(filePath, dataJson);
                                break;

                            default:
                                break;
                            }
                        }
                        byte [] bytes;
                        if (not_found)
                        {
                            bytes = Encoding.UTF8.GetBytes(NOT_FOUND_500);
                            context.Response.StatusCode = 500;
                        }
                        else
                        {
                            if (dataJson.Length < 0)
                            {
                                bytes = Encoding.UTF8.GetBytes(NOT_FOUND_404);
                                context.Response.StatusCode = 404;
                            }
                            else
                            {
                                bytes = Encoding.UTF8.GetBytes(dataJson);
                            }
                        }

                        Stream OutputStream = context.Response.OutputStream;
                        //sends the message back.
                        OutputStream.Write(bytes, 0, bytes.Length);
                        //Close connection.
                        OutputStream.Close();
                    }
                }


                catch (Exception)
                {
                    // Client disconnected or some other error - ignored for this example
                }
            }
        }
Exemple #27
0
 private void OnClientConnected(ConnectionServer connection)
 {
     connection.OnClientJoined += m_RailServer.ClientJoined;
     connection.OnDisconnected += m_RailServer.Disconnected;
 }
Exemple #28
0
        public void Test4()
        {
            var student = new Contact
            {
                MessageHistory = "42",
                Name           = "Man",
                Online         = true
            };

            var student2 = new Contact
            {
                MessageHistory = "42",
                Name           = "Man2",
                Online         = true
            };

            var contactList = new List <Contact> {
                student, student2
            };

            var profile = new MyProfile
            {
                MyContacts = contactList,
                MyName     = "i"
            };


            var fr1 = new Friend
            {
                Name   = "Man",
                Online = true
            };

            var fr2 = new Friend
            {
                Name   = "Man2",
                Online = true
            };

            Friend[] friends = new Friend[] { fr2, fr1 };

            KeyValuePair <string, string>[] mess = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("42", "Man") };

            var user = new User
            {
                Name            = "i",
                Contacts        = friends,
                MessageBySender = mess
            };

            ConnectionServer server = new ConnectionServer();

            var mock = new Mock <IMessengerServerService>();

            mock.Setup(foo => foo.UploadUserData("i")).Returns(user);

            server.Client = mock.Object;

            var prof = server.LogIn("i");

            mock.Verify(foo => foo.UploadUserData("i"), Times.Once);

            Assert.That(prof.MyName, Is.EqualTo(profile.MyName));
        }
 private void StartButton_OnClick(object sender, RoutedEventArgs e)
 {
     int port = int.Parse(portTextBox.Text);
     ConnectionServer conn = new ConnectionServer(port);
     Task.Run(() => {conn.StartListen(progressBar);});
 }
        public void registrarActualizarHechosBlockStoreDocumentoInstancia()
        {
            LogUtil.LogDirPath = @"..\..\TestOutput\";
            LogUtil.Inicializa();

            var conectionServer = new ConnectionServer
            {
                //miConnectionString = "mongodb://*****:*****@ds035185-a0.mongolab.com:35185,ds035185-a1.mongolab.com:35185/repositorioabaxxbrl?replicaSet=rs-ds035185",
                //miConnectionString = "mongodb://*****:*****@172.16.235.123:27017/repositorioAbaxXbrl",
                //miConnectionString = "mongodb://*****:*****@ds054298.mlab.com:54298/abaxxbrl",
                miConnectionString = "mongodb://localhost/abaxxbrl",

                miBaseDatos = "abaxxbrl"
                              //miBaseDatos = "repositorioabaxxbrl"
            };

            conectionServer.init();

            var conexion                     = new Conexion(conectionServer);
            var blockStore                   = new BlockStoreDocumentoInstancia(conexion);
            var blockStoreConsulta           = new BlockStoreConsulta(conexion);
            var ConsumerFactoryTaskHechoImpl = new ConsumerFactoryTaskHechoImpl {
                numeroMaximoConsumidores = 25, con = conexion
            };

            var blockStoreHechoService = new BlockStoreHechoService
            {
                BlockStoreDocumentoInstancia = blockStore,
                BlockStoreConsulta           = blockStoreConsulta,
                Collection               = "BlockStoreHecho",
                CollectionDimension      = "BlockStoreDimension",
                CollectionEmpresas       = "BlockStoreEmpresa",
                CollectionUnidades       = "BlockStoreUnidad",
                CollectionConcepto       = "BlockStoreConcepto",
                ConsumerFactoryTaskHecho = ConsumerFactoryTaskHechoImpl
            };



            string line;

            LogUtil.LogDirPath = ".\\";
            LogUtil.Inicializa();

            var procesarList = Directory.GetFiles("C:/TemporalesJson/jsons");

            //var procesarList = new List<string> {


            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_ASUR_2015-2.json"
            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_GICSA_2015-3.json"
            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_HCITY_2015-2.json"
            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_LAB_2015-2.json"
            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_OMA_2015-1.json"
            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_SIGMA_2015-1.json"
            //"C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/DocumentosErroneos/ifrsxbrl_VWLEASE_2015-3.json"


            //};


            //var targetDirectory = "C:/Users/Luis Angel/Documents/Workspace/DocumentosPrueba/resultado";
            //string[] fileEntries = Directory.GetFiles(targetDirectory);


            //foreach (var itemArchivo in fileEntries)
            var indexName = "C:/TemporalesJson/jsons/".Length;
            var index     = 0;

            foreach (var itemArchivo in procesarList)
            {
                using (var streamReader = new StreamReader(itemArchivo))
                {
                    try
                    {
                        line = streamReader.ReadToEnd();
                        var settings = new JsonSerializerSettings {
                            NullValueHandling = NullValueHandling.Ignore
                        };
                        var documentoInstanciXbrlDto = JsonConvert.DeserializeObject <DocumentoInstanciaXbrlDto>(line, settings);

                        blockStoreHechoService.registrarHechosDocumentoInstancia(documentoInstanciXbrlDto, 1, 1);
                        Debug.WriteLine("Registro del archivo: " + itemArchivo);
                        var nombre = itemArchivo.Substring(indexName);
                        //File.Move(itemArchivo, "C:/TemporalesJson/procesados/" + nombre);
                    }
                    catch (System.Exception ex)
                    {
                        System.Console.Out.Write(ex);
                        LogUtil.Error(ex);
                    }
                }
            }
            while (true)
            {
                Debug.WriteLine("Registro");
                Thread.Sleep(1000);
            }
        }
Exemple #31
0
        /// Function - VariableDeclarationHandler
        /// <summary>
        /// Handling the variable declaration part in the function "ChecksInSyntaxCheck" by
        /// checking the whole variable declaration syntax.. (Checks the keywords and if the variable is being equal so checks
        /// the types of both of variables are equal and adding the new variable to "blocksAndNames" ArrayList).
        /// </summary>
        /// <param name="codeLine"> refference of the string s (code line).</param>
        /// <param name="pos"></param>
        /// <param name="keywords"> Hashtable type that stores all keywords in the code.</param>
        /// <param name="blocksAndNames"> ArrayList Type that stores all variables in the scopes.</param>
        /// <param name="IsScope"> Variable that checks if the function is being called inside a scope or
        ///                        outside a scope.</param>
        /// <param name="sr"> buffer type MyStream.</param>
        /// <returns></returns>
        static bool VariableDeclarationHandler(ref string codeLine, ref int pos, Hashtable keywords, int threadNumber, ArrayList variables, ArrayList globalVariables, ArrayList blocksAndNames, bool IsScope, MyStream sr)
        {
            bool   DifferentTypes = true;
            int    loopCount;
            string parameterType = GeneralConsts.EMPTY_STRING;
            int    j;
            bool   found = true;

            char[] trimChars = { '\t', ' ', ';' };

            loopCount = KeywordsAmountOnVariableDeclaration(codeLine);
            for (j = 0; j < loopCount; j++)
            {
                //checks if the keywords in the declaration is exist.
                found = found && CheckIfStringInHash(keywords, codeLine.Substring(pos, codeLine.Substring(pos, codeLine.Length - pos).IndexOf(GeneralConsts.SPACEBAR)).Trim(CharsToTrim));
                pos   = codeLine.IndexOf(GeneralConsts.SPACEBAR, pos + 1) + 1;
            }
            if (loopCount == 0)
            {
                //gets in the if section only if there is only 1 keyword.
                found = found && CheckIfStringInHash(keywords, codeLine.Substring(pos, codeLine.Substring(pos, codeLine.Length - pos).IndexOf(GeneralConsts.SPACEBAR)).Trim(CharsToTrim));
            }
            if (codeLine.IndexOf("struct") != GeneralConsts.NOT_FOUND_STRING)
            {
                //gets in if the variable type includes a struct without a typedef.
                pos           = codeLine.IndexOf("struct");
                parameterType = codeLine.Substring(pos, codeLine.IndexOf(GeneralConsts.SPACEBAR, pos + 7) - pos);
                found         = CheckIfStringInHash(keywords, parameterType.Trim(CharsToTrim));
            }
            string         name;
            ParametersType result;

            //if the line has equation in the declaration.
            if (codeLine.IndexOf(GeneralConsts.EQUAL_SIGN) != -1)
            {
                parameterType = Regex.Split(codeLine, GeneralConsts.EQUAL_SIGN)[0];
                parameterType = parameterType.Trim(trimChars);
                result        = GetParameterNameFromLine(parameterType);
            }
            //only declaration.
            else
            {
                parameterType = codeLine;
                parameterType = parameterType.Trim(trimChars);
                result        = GetParameterNameFromLine(parameterType);
            }
            name          = result.parameterName;
            parameterType = result.parameterType;
            parameterType = parameterType.Replace(GeneralConsts.SPACEBAR, GeneralConsts.EMPTY_STRING);
            // checks if there is already the same name in the same scope.
            if (IsExistInArrayList(((ArrayList)blocksAndNames[blocksAndNames.Count - 1]), name) != null)
            {
                Server.ConnectionServer.CloseConnection(threadNumber, ("you have used the same name for multiple variables in row " + sr.curRow + ". name - " + name), GeneralConsts.ERROR);
                CompileError = true;
            }
            else
            {
                ((ArrayList)blocksAndNames[blocksAndNames.Count - 1]).Add(new ParametersType(name, parameterType));
                variables.Add(new ParametersType(name, parameterType));
                if (!IsScope)
                {
                    try
                    {
                        globalVariables.Add(new ParametersType(name, parameterType));
                    }
                    catch
                    {
                        ConnectionServer.CloseConnection(threadNumber, ("you have used the same name for multiple variables in row " + sr.curRow + ". name - " + name), GeneralConsts.ERROR);
                    }
                }
            }
            //if the declaration is also a equation.
            if (VariableEquation.IsMatch(codeLine))
            {
                DifferentTypes = VariableEquationHandler(sr, codeLine, blocksAndNames, threadNumber);
            }
            if (!DifferentTypes)
            {
                Server.ConnectionServer.CloseConnection(threadNumber, codeLine + " types of both variables are different in row : " + sr.curRow, GeneralConsts.ERROR);
                CompileError = true;
            }

            return(found);
        }