Exemple #1
0
		public RpcService Get(string name, int version, string plataform)
		{
			RpcService service = new RpcService();
			SQLiteConnection conn = OpenNewConnection();

			try
			{
				lock (mutex)
				{
					using (var cmdSelect = new SQLiteCommand(conn))
					{
						//TODO:
					}
				}
			}
			catch (Exception e)
			{
				logger.Error("Some error in SQL Execution", e);
			}
			finally
			{
				CloseConnection(conn);
			}

			return service;
		}
Exemple #2
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            RpcService rpcService = obj as RpcService;

            if (rpcService != null)
            {
                int strCmp = rpcService.Name.CompareTo(Name);
                if (strCmp == 0)
                {
                    return(rpcService.VersionApp.CompareTo(VersionApp));
                }
                else
                {
                    return(strCmp);
                }
            }
            else
            {
                throw new ArgumentException("Object is not a RpcService");
            }
        }
		public void StartServiceRpc(RpcService service) {
			lock (instance)
			{
				RpcTcpServer server = new RpcTcpServer(ip, service);
				server.Start();
				RpcServices.Add(server);
			}
		}
Exemple #4
0
		public void Add(RpcService service)
		{
			SQLiteConnection conn = OpenNewConnection();
			try
			{
				lock (mutex)
				{
					using (var cmdRpcService = new SQLiteCommand(conn))
					{
						using (var transaction = conn.BeginTransaction())
						{
							cmdRpcService.CommandText = @"INSERT INTO rpcservice (name,port,version_app,plataform) VALUES (@name, @port, @version_app, @plataform); SELECT last_insert_rowid();";
							cmdRpcService.Parameters.AddWithValue("@name", service.Name);
							cmdRpcService.Parameters.AddWithValue("@port", service.Port);
							cmdRpcService.Parameters.AddWithValue("@version_app", service.VersionApp);
							cmdRpcService.Parameters.AddWithValue("@plataform", "wp");

							int id = Convert.ToInt32(cmdRpcService.ExecuteScalar().ToString());

							using (var cmdDependence = new SQLiteCommand(conn))
							{
								foreach (DependencePath dep in service.Dependencies)
								{
									cmdDependence.CommandText = @"INSERT INTO dependency_app (id_service,path) VALUES (@id_service, @path);";
									cmdDependence.Parameters.AddWithValue("@id_service", id);
									cmdDependence.Parameters.AddWithValue("@path", dep.Path);
									cmdDependence.ExecuteNonQuery();
								}
							}
							transaction.Commit();
						}
					}
				}
			}
			catch (Exception e)
			{
				logger.Error("Some error in SQL Execution", e);
			}
			finally
			{
				CloseConnection(conn);
			}
		}
		public override void ClientRequest(object connection)
		{
			logger.Info("Starting deploy service!");
			RpcService service = new RpcService();

			TcpClient clientSocket = (TcpClient)connection;
			//tem que sinalizar quando chegar a mensagem...
			NetworkStream networkStream = clientSocket.GetStream();

			try
			{
				// e.g.: mpos_deploy_app:wp:<Name_App>:<Version_App>
				string clientMessage = null;
				if ((clientMessage = ReadMessage(networkStream, "mpos_deploy_app")) == null)
				{
					return;// finished a conex from side client
				}

				service.ProcessDeployMessage(clientMessage);
				string dir = "./app_dep/windowsphone/" + service.Name + "_" + service.VersionApp + "v";
				CheckDiretory(dir);

				if ((clientMessage = ReadMessage(networkStream, "mpos_dependence_size")) == null)
				{
					return;
				}

				service.Dependencies = ProcessDependence(networkStream, Convert.ToInt32(clientMessage.Split(':')[1]), dir);
				service.Port = GenerateServicePort();

				FachadeDao.Instance.RpcServiceDao.Add(service);
				SentMessage(networkStream, "mpos_dependence_port:" + service.Port);

				ServiceController.Instance.StartServiceRpc(service);
				logger.Info("Service: " + service.Name + ", deployed on port: " + service.Port);
			}
			finally
			{
				Close(ref clientSocket, ref networkStream);
			}
		}
Exemple #6
0
		public List<RpcService> GetAll()
		{
			List<RpcService> services = new List<RpcService>();

			SQLiteConnection conn = OpenNewConnection();
			try
			{
				lock (mutex)
				{
					using (var selectRpcService = new SQLiteCommand(conn))
					{
						selectRpcService.CommandText = @"SELECT * FROM rpcservice WHERE plataform = 'wp'";
						selectRpcService.CommandType = CommandType.Text;

						SQLiteDataReader rpcReader = selectRpcService.ExecuteReader();
						while (rpcReader.Read())
						{
							RpcService service = new RpcService();
							service.Id = Convert.ToInt32(rpcReader["id"]);
							service.Name = Convert.ToString(rpcReader["name"]);
							service.Port = Convert.ToInt32(rpcReader["port"]);
							service.VersionApp = Convert.ToString(rpcReader["version_app"]);

							using (var selectDep = new SQLiteCommand(conn))
							{
								selectDep.CommandText = @"SELECT * FROM dependency_app WHERE id_service = " + service.Id + "";
								selectDep.CommandType = CommandType.Text;

								SQLiteDataReader depReader = selectDep.ExecuteReader();
								while (depReader.Read())
								{
									DependencePath dep = new DependencePath();
									dep.Id = Convert.ToInt32(depReader["id"]);
									dep.IdService = Convert.ToInt32(depReader["id_service"]);
									dep.Path = Convert.ToString(depReader["path"]);

									service.Dependencies.Add(dep);
								}
							}

							services.Add(service);
						}
					}
				}
			}
			catch (Exception e)
			{
				logger.Error("Some error in SQL Execution", e);
			}
			finally
			{
				CloseConnection(conn);
				services.Sort();
			}

			return services;
		}
Exemple #7
0
		public RpcTcpServer(string ip, RpcService service)
			: base(ip, service, typeof(RpcTcpServer))
		{
			startMessage = "Service: " + service.Name + "_" + service.VersionApp + "v, was started on port: " + service.Port;
			assembly = new AssemblyLoader(Service.Dependencies);
		}