Exemplo n.º 1
0
        public SetupWin(MasterServer server, bool canQuit)
        {
            InitializeComponent();
            _server = server;

            if (canQuit == false)
                btnCancel.Enabled = false;
            else
                tabs.TabPages.Remove(tabWeb);

            DialogResult = DialogResult.Cancel;
        }
Exemplo n.º 2
0
        public WebServer(MasterServer server,int port)
        {
            _server = server;

            try
            {
                _listener = new TcpListener(IPAddress.Any,port);
                _listener.Start(10);
                _needToStop = false;
                _threadListener = new Thread(StartAccepting);
                _threadListener.IsBackground = true;
                _threadListener.Start();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Cannot start web server: " + ex);
                ServerServices.AddMessage(1, "Cannot start web server on port " + port);
                return;
            }
            ServerServices.AddMessage(0, "Web server ready to accept connections on port " + port);
        }
Exemplo n.º 3
0
        public AddProject(MasterServer server)
        {
            _server = server;
            _settings = ServerSettings.LoadSettings();
            InitializeComponent();

            server.LoadFileFormats();
            foreach (string s in server.ImageFormats(0))
            {
                listImageFormat.Items.Add(s);
                AlphaImageFormat.Items.Add(s);
            }
            try
            {
                listImageFormat.SelectedIndex = 0;
                AlphaImageFormat.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error selecting image file format");
                MessageBox.Show("Error while selecting the image file format.");
            }

            foreach (string s in RenderProject.FileNameFormats)
                listOuputFormat.Items.Add(string.Format(s, "outputDir", "prefix", 1, ".ext"));
            try
            {
                listOuputFormat.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error selecting output name format");
                MessageBox.Show("Error while selecting the file output name format.");
            }

            foreach (string s in server.ConfigNames)
                listConfig.Items.Add(s);

            try
            {
                listConfig.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error selecting the config");
                MessageBox.Show("Error while selecting the config.");
            }

            try
            {
                renderMode.SelectedIndex = 2;
                classicAntialias.SelectedIndex = 0;
                reconFilter.SelectedIndex = 0;
                radiosityType.SelectedIndex = 0;
                samplingPattern.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error selcting defaults");
                MessageBox.Show("Error while selecting some defaults.");
            }

            emailNotify.Checked = _settings.SendEmail;
            emailTo.Text = _settings.ToEmail;
            emailSubjectOk.Text = _settings.SubjectOk;
            emailSubjectNotOk.Text = _settings.SubjectNotOk;
            renderBlock.Text = server.RenderBlocks.ToString();

            renderSetupTabs.TabPages.Remove(logTab);
            renderSetupTabs.TabPages.Remove(qualityTab);
            renderSetupTabs.TabPages.Remove(cameraTab);
            renderSetupTabs.TabPages.Remove(giTab);
        }
Exemplo n.º 4
0
 public AddProject(MasterServer server, string fname)
     : this(server)
 {
     textScene.Text = fname;
     UpdateSceneInfo();
 }
Exemplo n.º 5
0
        public AddProject(MasterServer server, RenderProject prj)
            : this(server)
        {
            Text = "Edit project";
            if (prj.IsFinished)
            {
                btnAdd.Text = "Restart";
                textViewLog.Text = prj.Log.Replace("\n", "\r\n");
                renderSetupTabs.TabPages.Add(logTab);
            }
            else
            {
                btnAdd.Text = "Save";
            }
            btnAdd.Enabled = true;
            btnLoadProject.Enabled = false;

            _projectId = prj.ProjectId;
            _project = prj;

            textScene.Enabled = false;
            btnSelectScene.Enabled = false;

            RestoreProjectInfo(_project);
        }
Exemplo n.º 6
0
        private void ServerWin_Shown(object sender, EventArgs e)
        {
            string version = Assembly.GetExecutingAssembly().GetName().Version.Major.ToString();
            version = version + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor;
            version = version + "." + Assembly.GetExecutingAssembly().GetName().Version.Build;

            Text = "Amleto Server " + version;

            BroadcastFinder findMaster = new BroadcastFinder();
            if (findMaster.Server != "") // Let's connect to the master
            {
                _isMaster = false;
                try
                {
                    // Find a free port for the callback...
                    for (int i = 10000; i < 60000; i++)
                    {
                        try
                        {
                            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
                            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
                            IDictionary props = new Hashtable();

                            props["port"] = i;
                            _channel = new TcpChannel(props, clientProv, serverProv);
                            break;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex, "Error creating TCP channel");
                        }
                    }

                    ChannelServices.RegisterChannel(_channel, false);
                    _masterServer = (MasterServer)Activator.CreateInstance(typeof(MasterServer),
                                                                            new object[] { Environment.UserName },
                                                                            new object[]
                                                                                {
                                                                                    new UrlAttribute("tcp://" +
                                                                                                     findMaster.Server +
                                                                                                     ":" +
                                                                                                     findMaster.Port)
                                                                                });

                    List<string> oldMessages = _masterServer.GetOldMessages();
                    foreach (string s in oldMessages)
                        DoConsumeMessage(s);
                    List<FinishedFrame> oldFrames = _masterServer.GetOldFrames();
                    DoAddFrames(oldFrames);

                    RepaintClientList();
                    RepaintProjectList();

                    Text = Text + " - Terminal";

                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Error initialising server");
                }
            }
            else // We should be master
            {
                _masterServer = new MasterServer(Environment.UserName);
                _isMaster = true;
                Text = Text + " - Master";
            }

            if (_masterServer.RestoreSettings() == false || _masterServer.NbConfigs == 0)
            {
                SetupWin dlg = new SetupWin(_masterServer, false);
                dlg.ScanAllConfigs();
                if (dlg.ShowDialog() != DialogResult.OK)
                    Application.Exit();
                _masterServer.Port = dlg.Port;
                _masterServer.AutoOfferPort = dlg.AutoPort;
                _masterServer.ReplaceConfigs(dlg.Configs);
                _masterServer.LogFile = dlg.LogFile;
                _masterServer.EmailFrom = dlg.EmailFrom;
                _masterServer.SmtpServer = dlg.SmtpServer;
                _masterServer.SmtpUsername = dlg.SmtpUsername;
                _masterServer.SmtpPassword = dlg.SmtpPassword;
                _masterServer.OfferWeb = dlg.OfferWeb;
                _masterServer.OfferWebPort = dlg.OfferWebPort;
                _masterServer.RenderBlocks = dlg.RenderBlocks;
                string res = _masterServer.SetMappedDrives(dlg.MappedDrives);
                if (res != "")
                    MessageBox.Show(res);
                _masterServer.SaveSettings();
            }

            _eventBridge = new EventBridge(RefreshClientList, RefreshProjectList, RefreshFinishedList, ShowImage, ConsumeMessage, ShowClientLog);

            _masterServer.AddClientStatus(_eventBridge.ClientRefresh);
            _masterServer.AddProjectStatus(_eventBridge.ProjectRefresh);
            _masterServer.AddFinishedStatus(_eventBridge.FinishedRefresh);
            _masterServer.AddImagePreview(_eventBridge.ImagePreview);
            _masterServer.AddMessageConsumer(_eventBridge.MessageConsume);

            if (_isMaster)
            {
                _masterServer.Startup();

                // Restore previously saved jobs
                string loadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Amleto");
                loadPath = Path.Combine(loadPath, "RenderJobs");
                if (Directory.Exists(loadPath))
                {
                    DirectoryInfo bufferPath = new DirectoryInfo(loadPath);
                    foreach (FileInfo file in bufferPath.GetFiles("*.xml"))
                    {
                        RenderProject project = new RenderProject();
                        project = project.Load(file.FullName);
                        _masterServer.AddProject(project);
                    }
                }
            }

            DoConsumeMessage("Clearing thumbnail cache");
            string thumbnailPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Amleto");
            thumbnailPath = Path.Combine(thumbnailPath, @"Cache\thumbnails");
            try
            {
                if (Directory.Exists(thumbnailPath))
                    Directory.Delete(thumbnailPath, true);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error clearing thumbnail cache");
            }
        }