private void btnLoadProject_Click(object sender, EventArgs e) { _shouldClose = false; OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = "xprj"; dlg.Filter = "Amleto project file (*.xprj)|*.xprj"; if (dlg.ShowDialog() != DialogResult.OK || dlg.FileName == "") { _shouldClose = false; return; } try { RenderProject project = new RenderProject(); project = project.Load(dlg.FileName); RestoreProjectInfo(project); btnAdd.Enabled = true; FileInfo f = new FileInfo(dlg.FileName); Text = "Add project to the queue - " + f.Name; _currentFileName = f.Name; } catch (Exception ex) { logger.Error(ex, "Error loading project"); } dlg.Dispose(); _shouldClose = false; }
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"); } }