Exemplo n.º 1
0
		/// <summary>
		/// Push module to slave.
		/// </summary>
		/// <param name="slaveId">Guid of slave.</param>
		/// <param name="moduleVersion">Version of module to push.</param>
		public void PushModule(Guid slaveId, ModuleVersion moduleVersion)
		{
			SlaveProcessWorker slaveProcessWorker = SlaveConnections.Values.FirstOrDefault(s => s.SlaveId == slaveId);
			if (slaveProcessWorker == null)
				return;

			slaveProcessWorker.PushModule(moduleVersion);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Upload version of module package.
		/// </summary>
		/// <param name="module">Module ideintifier.</param>
		/// <param name="major">Major version.</param>
		/// <param name="minor">Minor version.</param>
		/// <param name="build">Build version.</param>
		/// <param name="revision">Revision.</param>
		/// <param name="packageStream">Stream with module package.</param>
		public void UploadModuleVersion(string module, string major, string minor, string build, string revision, Stream packageStream)
		{
			int moduleId;
			int majorNumber;
			int minorNumber = 0;
			int buildNumber = 0;
			int revisionNumber = 0;

			if (string.IsNullOrEmpty(module))
				return;

			if (!int.TryParse(module, out moduleId))
				return;

			if (string.IsNullOrEmpty(major))
				return;

			if (!int.TryParse(major, out majorNumber))
				return;

			if (!string.IsNullOrEmpty(minor))
			{
				if (!int.TryParse(minor, out minorNumber))
					return;
			}

			if (!string.IsNullOrEmpty(build))
			{
				if (!int.TryParse(build, out buildNumber))
					return;
			}

			if (!string.IsNullOrEmpty(revision))
			{
				if (!int.TryParse(revision, out revisionNumber))
					return;
			}

			ModuleVersion moduleVersion = new ModuleVersion
			{
				ModuleId = moduleId,
				Major = majorNumber,
				Minor = minorNumber,
				Build = buildNumber,
				Revision = revisionNumber
			};

			_orationiEngine.SaveModule(moduleVersion, packageStream);

			using (MasterContext masterDb = new MasterContext())
			{
				masterDb.ModuleVersions.Add(moduleVersion);
				masterDb.SaveChanges();
			}
		}
Exemplo n.º 3
0
		/// <summary>
		/// Save module to modules storage directory.
		/// </summary>
		/// <param name="version">Version of module.</param>
		/// <param name="stream">Module package stream.</param>
		public void SaveModule(ModuleVersion version, Stream stream)
		{
			string moduleFolder = Path.Combine(BaseModuleDirectory, version.ModuleId.ToString());
			if (!Directory.Exists(BaseModuleDirectory))
				Directory.CreateDirectory(BaseModuleDirectory);

			string modulePath = $"{moduleFolder}/{version.Major}.{version.Minor}.{version.Build}.{version.Revision}.zpg";
			using (FileStream fileStream = File.Create(modulePath))
			{
				stream.Seek(0, SeekOrigin.Begin);
				stream.CopyTo(fileStream);
			}

			version.Path = modulePath.Remove(0, BaseModuleDirectory.Length);
		}
Exemplo n.º 4
0
		public void PushModule(ModuleVersion moduleVersion)
		{
			using (FileStream stream = new FileStream(moduleVersion.Path, FileMode.Open, FileAccess.Read, FileShare.Read))
			{
				Callback.PushModule(stream);
			}
		}