public bool TerminateMulticastProcesses(EntityActiveMulticastSession multicast)
        {
            try
            {
                var prs         = Process.GetProcessById(Convert.ToInt32(multicast.Pid));
                var processName = prs.ProcessName;
                if (Environment.OSVersion.ToString().Contains("Unix"))
                {
                    for (var x = 1; x <= 5; x++)
                    {
                        KillProcessLinux(Convert.ToInt32(multicast.Pid));
                        Thread.Sleep(200);
                    }
                }
                else
                {
                    if (processName == "cmd")
                    {
                        KillProcess(Convert.ToInt32(multicast.Pid));
                    }
                }
                //Message.Text = "Successfully Deleted Task";
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                return(false);
                //Message.Text = "Could Not Kill Process.  Check The Exception Log For More Info";
            }

            return(true);
        }
        public void SendMulticastCompletedEmail(EntityActiveMulticastSession session)
        {
            //Mail not enabled
            if (ServiceSetting.GetSettingValue(SettingStrings.SmtpEnabled) == "0")
            {
                return;
            }

            foreach (
                var user in
                _userServices.GetAll().Where(x => !string.IsNullOrEmpty(x.Email)))
            {
                var rights = new ServiceUser().GetUserRights(user.Id).Select(right => right.Right).ToList();
                if (rights.Any(right => right == AuthorizationStrings.EmailImagingTaskCompleted))
                {
                    if (session.UserId == user.Id)
                    {
                        var mail = new MailServices
                        {
                            MailTo  = user.Email,
                            Body    = session.Name + " Multicast Task Has Completed.",
                            Subject = "Multicast Completed"
                        };
                        mail.Send();
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public DtoApiBoolResponse TerminateMulticast(EntityActiveMulticastSession multicast)
 {
     return(new DtoApiBoolResponse()
     {
         Value = new Toems_Service.Entity.ServiceActiveMulticastSession().TerminateMulticastProcesses(multicast)
     });
 }
Ejemplo n.º 4
0
 //Constructor For Starting Multicast For Group
 public Multicast(int groupId, int userId)
 {
     _computers        = new List <EntityComputer>();
     _multicastSession = new EntityActiveMulticastSession();
     _isOnDemand       = false;
     _group            = new ServiceGroup().GetGroup(groupId);
     _userId           = userId;
     _computerServices = new ServiceComputer();
 }
Ejemplo n.º 5
0
 //Constructor For Starting Multicast For On Demand
 public Multicast(int imageProfileId, string clientCount, string sessionName, int userId, int comServerId)
 {
     _multicastSession = new EntityActiveMulticastSession();
     _isOnDemand       = true;
     _imageProfile     = new ServiceImageProfile().ReadProfile(imageProfileId);
     _clientCount      = clientCount;
     _group            = new EntityGroup {
         ImageProfileId = _imageProfile.Id
     };
     _userId = userId;
     _multicastSession.ImageProfileId = _imageProfile.Id;
     _computerServices      = new ServiceComputer();
     _comServerId           = comServerId;
     _multicastSession.Name = sessionName;
 }
 public bool AddActiveMulticastSession(EntityActiveMulticastSession activeMulticastSession)
 {
     _uow.ActiveMulticastSessionRepository.Insert(activeMulticastSession);
     _uow.Save();
     return(true);
 }
 public bool UpdateActiveMulticastSession(EntityActiveMulticastSession activeMulticastSession)
 {
     _uow.ActiveMulticastSessionRepository.Update(activeMulticastSession, activeMulticastSession.Id);
     _uow.Save();
     return(true);
 }
Ejemplo n.º 8
0
        public string Upload(int taskId, string fileName, int profileId, int userId, string hdNumber)
        {
            //no need to find and call com server, client should already be directly communicating with the correct imaging server
            var guid = ConfigurationManager.AppSettings["ComServerUniqueId"];

            _thisComServer = new ServiceClientComServer().GetServerByGuid(guid);

            if (_thisComServer == null)
            {
                log.Error($"Com Server With Guid {guid} Not Found");
                return("0");
            }

            var appPath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "private", "apps");

            var task = new ServiceActiveImagingTask().GetTask(taskId);

            if (task == null)
            {
                return("0");
            }

            var imageProfile = new ServiceImageProfile().ReadProfile(profileId);

            var uploadPort = new ServicePort().GetNextPort(task.ComServerId);

            var path = _thisComServer.LocalStoragePath;


            try
            {
                var dir = Path.Combine(path, "images", imageProfile.Image.Name, $"hd{ hdNumber}");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
            }
            catch (Exception ex)
            {
                log.Error("Could Not Create Directory");
                log.Error(ex.Message);
                return("0");
            }

            path = Path.Combine(path, "images", imageProfile.Image.Name, $"hd{hdNumber}", fileName);
            string arguments    = " /c \"";
            var    receiverPath = Path.Combine(appPath, "udp-receiver.exe");

            arguments += $"{receiverPath}\" --portbase {uploadPort}";
            arguments += $" --interface {_thisComServer.ImagingIp} --file {path}";

            var pid = StartReceiver(arguments, imageProfile.Image.Name);
            //use multicast session even though it's not a multicast, uploads still use udpcast
            var activeMulticast = new EntityActiveMulticastSession();

            if (pid != 0)
            {
                activeMulticast.ImageProfileId = imageProfile.Id;
                activeMulticast.Name           = imageProfile.Image.Name;
                activeMulticast.Pid            = pid;
                activeMulticast.Port           = uploadPort;
                activeMulticast.ComServerId    = _thisComServer.Id;
                activeMulticast.UserId         = userId;
                activeMulticast.UploadTaskId   = task.Id;

                var result = new ServiceActiveMulticastSession().AddActiveMulticastSession(activeMulticast);
                if (result)
                {
                    return(uploadPort.ToString());
                }
            }
            return("0");
        }
Ejemplo n.º 9
0
        public bool TerminateMulticast(string url, string serverName, string interComKey, EntityActiveMulticastSession multicast)
        {
            Request.Method   = Method.POST;
            Request.Resource = "Imaging/TerminateMulticast";
            Request.AddJsonBody(multicast);
            var responseData = new ApiRequest(new Uri(url)).ExecuteHMACInterCom <DtoApiBoolResponse>(Request, serverName, interComKey);

            return(responseData != null && responseData.Value);
        }