void CustomerViewer_New(object sender, EventArgs e) { Customer customer = new Customer(RhspDataID.Generate()); CustomerEditorForm editor = new CustomerEditorForm(); editor.SetCreateMode(customer); ShowEditorAsync(editor); }
private DnsZone convertToDnsZone(MsDnsZone mdz) { DnsZone dnsZone = new DnsZone(RhspDataID.Generate()); dnsZone.DefaultTtl = defaultTtl; dnsZone.Name = mdz.Name; dnsZone.RecordArray = convertToDnsRecords(mdz.MixedReords).ToArray(); return(dnsZone); }
public WebsiteWizardForm(WebsiteViewer viewer) { InitializeComponent(); this.Viewer = viewer; this.Website = new Website(RhspDataID.Generate()); AddPage(new WelcomePage()); AddPage(new CustomerPage()); AddPage(new SettingsPage()); AddPage(new FinishPage()); }
private void recordAddButton_Click(object sender, EventArgs e) { DnsRecord record = new DnsRecord(RhspDataID.Generate()); record.PendingAction = ChildPendingAction.Create; recordResultList.Add(record); recordBindingList.Add(record); recordBindingList.ResetBindings(); selectGridViewRow(recordDataGridView.Rows.Cast <DataGridViewRow>().Last().Index); recordDataGridView.BeginEdit(false); }
private IEnumerable <DnsRecord> convertToDnsRecords(IEnumerable <MsDnsRecord> mdrList) { List <DnsRecord> recordList = new List <DnsRecord>(); foreach (MsDnsRecord mdr in mdrList.Where(mdr => (mdr.DnsType != MsDnsRecordType.Soa))) { DnsRecord record = new DnsRecord(RhspDataID.Generate()); record.Name = mdr.Name; record.Value = getRecordValue(mdr); record.RecordType = convertToRecordType(mdr.DnsType); record.Ttl = (mdr.TTL != 0) ? mdr.TTL.ToString() : null; recordList.Add(record); } return(recordList); }
private void addButton_Click(object sender, EventArgs e) { SecurityTemplate rule = new SecurityTemplate(RhspDataID.Generate()); rule.PendingAction = ChildPendingAction.Create; //rule.Username = usernameBindingList.FirstOrDefault(); ruleResultList.Add(rule); ruleBindingList.Add(rule); ruleBindingList.ResetBindings(); ChangeMade(); selectGridViewRow(dataGridView.Rows.Cast <DataGridViewRow>().Last().Index); dataGridView.BeginEdit(false); }
private void addButton_Click(object sender, EventArgs e) { WebsiteHost host = new WebsiteHost(RhspDataID.Generate()); host.PendingAction = ChildPendingAction.Create; host.Port = WebsiteHost.DefaultHttpPort; host.IpAddress = IpAddressArray.FirstOrDefault(); hostList.Add(host); hostBindingList.Add(host); hostBindingList.ResetBindings(); ChangeMade(); selectGridViewRow(dataGridView.Rows.Cast <DataGridViewRow>().Last().Index); dataGridView.BeginEdit(false); }
private void addbutton_Click(object sender, EventArgs e) { DnsZone zone = new DnsZone(RhspDataID.Generate()); zone.PendingAction = ChildPendingAction.Create; DnsZoneEditor editor = new DnsZoneEditor(); editor.ReflectDataToForm(zone); DialogResult result = editor.ShowDialog(); if (result == DialogResult.OK) { editor.ReflectFormToData(zone); resultList.Add(zone); bindingList.Add(zone); bindingList.ResetBindings(); ChangeMade(); } }
public void CrudTest() { DnsZoneManager manager = LocalContext.Default.CreateManager <DnsZoneManager>(); DnsRecord r1 = new DnsRecord(RhspDataID.Generate()); r1.PendingAction = ChildPendingAction.Create; r1.Name = "@"; r1.RecordType = DnsRecordType.NS; r1.Value = "ns1.rensoft.net."; DnsRecord r2 = new DnsRecord(RhspDataID.Generate()); r2.PendingAction = ChildPendingAction.Create; r2.Name = "@"; r2.RecordType = DnsRecordType.A; r2.Value = "127.0.0.1"; DnsZone zone1 = new DnsZone(RhspDataID.Generate()); zone1.Name = "test.rensoft.net"; zone1.RecordArray = new DnsRecord[] { r1, r2 }; manager.Create(zone1); r2.Ttl = "100"; r2.PendingAction = ChildPendingAction.Update; DnsRecord r3 = new DnsRecord(RhspDataID.Generate()); r3.PendingAction = ChildPendingAction.Create; r3.Name = "a"; r3.RecordType = DnsRecordType.CNAME; r3.Value = "@"; zone1.RecordArray = new DnsRecord[] { r1, r2, r3 }; manager.Update(zone1); manager.Delete(zone1.DataID); }
public void CrudTest() { Customer c = new Customer(RhspDataID.Generate()) { Code = "TEST", Name = "Test Company" }; adapter.Create(c); Customer c2 = adapter.Get(c.DataID); c2.Name += " TEST"; adapter.Update(c2); Customer c3 = adapter.Get(c.DataID); Assert.AreEqual(c2.Name, c3.Name); adapter.Delete(c.DataID); }
public void CrudTest() { Website w = new Website(RhspDataID.Generate()) { HostArray = new WebsiteHost[] { new WebsiteHost(RhspDataID.Generate()) { Name = "www.test.com", Port = WebsiteHost.DefaultHttpPort }, new WebsiteHost(RhspDataID.Generate()) { Name = "test.com", Port = WebsiteHost.DefaultHttpPort }, } }; adapter.Create(w); Website w2 = adapter.Get(w.DataID); w2.HostArray = new WebsiteHost[] { new WebsiteHost(RhspDataID.Generate()) { Name = "foobar", Port = WebsiteHost.DefaultHttpPort } }; adapter.Update(w2); Website w3 = adapter.Get(w.DataID); Assert.AreEqual(w2.HostArray.Length, w3.HostArray.Length); Assert.AreEqual(w2.HostArray[0].Name, w3.HostArray[0].Name); adapter.Delete(w.DataID); }
void SettingsPage_AfterNextAsync(object sender, RunWorkerCompletedEventArgs e) { List <SecurityTemplate> stList = new List <SecurityTemplate>(); List <WebsiteHost> hostList = new List <WebsiteHost>(); List <DnsZone> dnsZoneList = new List <DnsZone>(); string iisRedirectUrl = string.Empty; //Website.Name = hostNameTextBox.Text; if (iisEnableCheckBox.Checked) { if (iisStandardRadioButton.Checked) { Website.IisSite.Mode = WebsiteIisMode.Standard; } if (iisRedirectRadioButton.Checked) { Website.IisSite.Mode = WebsiteIisMode.Redirect; iisRedirectUrl = iisRedirectTextBox.Text; } // Only create security template when there will be a directory to use. SecurityTemplate securityTemplate = new SecurityTemplate(RhspDataID.Generate()); securityTemplate.PendingAction = ChildPendingAction.Create; securityTemplate.RelativePath = "\\"; securityTemplate.Read = true; securityTemplate.Access = SecurityTemplateAccess.Allow; securityTemplate.UseIisIdentity = true; stList.Add(securityTemplate); } else { Website.IisSite.Mode = WebsiteIisMode.Disabled; } WebsiteHost primaryHost = new WebsiteHost(RhspDataID.Generate()); primaryHost.PendingAction = ChildPendingAction.Create; primaryHost.Port = getIisPort(); primaryHost.Name = hostNameTextBox.Text; primaryHost.IpAddress = (string)iisIpBindingSource.Current; //primaryHost.Primary = true; Website.PrimaryHostID = primaryHost.DataID; hostList.Add(primaryHost); if (wwwHostNameCheckBox.Checked) { WebsiteHost wwwHost = new WebsiteHost(RhspDataID.Generate()); wwwHost.PendingAction = ChildPendingAction.Create; wwwHost.Port = getIisPort(); wwwHost.Name = "www." + primaryHost.Name; wwwHost.IpAddress = primaryHost.IpAddress; hostList.Add(wwwHost); } if (dnsCreateRadioButton.Checked) { List <DnsRecord> recordList = new List <DnsRecord>(); DnsZone zone = new DnsZone(RhspDataID.Generate()); zone.PendingAction = ChildPendingAction.Create; zone.Name = hostNameTextBox.Text; zone.DefaultTtl = "1h"; dnsZoneList.Add(zone); foreach (string dnsServer in dnsServerArray) { DnsRecord nsRecord = new DnsRecord(RhspDataID.Generate()); nsRecord.PendingAction = ChildPendingAction.Create; nsRecord.Name = "@"; nsRecord.RecordType = DnsRecordType.NS; nsRecord.Value = dnsServer; recordList.Add(nsRecord); } DnsRecord rootRecord = new DnsRecord(RhspDataID.Generate()); rootRecord.PendingAction = ChildPendingAction.Create; rootRecord.Name = "@"; rootRecord.RecordType = DnsRecordType.A; rootRecord.Value = (string)dnsIpBindingSource.Current; recordList.Add(rootRecord); if (wwwHostNameCheckBox.Checked) { DnsRecord wwwRecord = new DnsRecord(RhspDataID.Generate()); wwwRecord.PendingAction = ChildPendingAction.Create; wwwRecord.Name = "www"; wwwRecord.RecordType = DnsRecordType.CNAME; wwwRecord.Value = "@"; recordList.Add(wwwRecord); } zone.RecordArray = recordList.ToArray(); } Website.HostArray = hostList.ToArray(); Website.SecurityArray = stList.ToArray(); Website.DnsZoneArray = dnsZoneList.ToArray(); Website.IisSite.RedirectUrl = iisRedirectUrl; }
private static void upgradeVersion1Host(WebsiteHost h) { h.DataID = RhspDataID.Generate(); h.PendingAction = ChildPendingAction.Create; }
public void CrudGroupAndUser() { FileZillaManager manager = LocalContext.Default.CreateManager <FileZillaManager>(); string homePath = Path.Combine(@"C:\Websites", RhspDataID.Generate().ToString()); string group = "test-group-" + Guid.NewGuid().ToString(); string userName = "******" + Guid.NewGuid().ToString(); string password = "******"; string uploadText = "Hello world!"; string ftpServer = "192.168.10.10"; // FileZilla doesn't like localhost or 127.0.0.1 string uploadFileName = "Test.txt"; string downloadText = string.Empty; string websiteDirectory = "test-website.com"; string websitePath = Path.Combine(homePath, websiteDirectory); manager.CreateGroup(group, new DirectoryInfo(homePath)); manager.CreateUser(userName, password, true, group); // Ensure that FTP test has something to write to. Directory.CreateDirectory(homePath); Directory.CreateDirectory(websitePath); // Don't allow users to create anything in base directory. FtpPermissions basePerms = new FtpPermissions(); basePerms.DirectoryOpen = true; basePerms.DirectoryList = true; manager.SetGroupPermissions(group, new DirectoryInfo(homePath), basePerms); // Allow user to do anything in the website directory. manager.SetGroupPermissions(group, new DirectoryInfo(websitePath), FtpPermissions.AllowAll); bool ftpFailed = false; string ftpError = null; try { FtpClient client = new FtpClient(ftpServer, userName, password); client.Open(); // Upload to mock website directory as no access is granted on root. client.ChangeWorkingDirectory(websiteDirectory); MemoryStream uploadStream = new MemoryStream(); uploadStream.Write(Encoding.UTF8.GetBytes(uploadText), 0, uploadText.Length); client.Upload(uploadStream, uploadFileName, false); MemoryStream downloadStream = new MemoryStream(); client.Download(uploadFileName, downloadStream); downloadText = Encoding.UTF8.GetString(downloadStream.ToArray()); client.DeleteFile(uploadFileName); client.Close(); } catch (Exception ex) { ftpFailed = true; ftpError = ex.Message; } // Clean up first before asserting. manager.DeleteGroup(group, true); // Delete now we're finished. Directory.Delete(homePath, true); if (ftpFailed) { Assert.Fail("FTP test failed: " + ftpError); } else { // Ensure that user can write to home directory. Assert.AreEqual(uploadText, downloadText); } }