public void TestMessageSizeTooLarge() { var props = TestUtils.GetSyncProducerConfig(this.Configs[0].Port); var producer = new SyncProducer(props); AdminUtils.CreateTopic(this.ZkClient, "test", 1, 1, new Dictionary <string, string>()); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, "test", 0, 500); TestUtils.WaitUntilMetadataIsPropagated(Servers, "test", 0, 2000); var message1 = new Message(new byte[Configs[0].MessageMaxBytes + 1]); var messageSet1 = new ByteBufferMessageSet(CompressionCodecs.NoCompressionCodec, new List <Message> { message1 }); var response1 = producer.Send(TestUtils.ProduceRequest("test", 0, messageSet1, acks: 1)); Assert.Equal(1, response1.Status.Count(kvp => kvp.Value.Error != ErrorMapping.NoError)); Assert.Equal(ErrorMapping.MessageSizeTooLargeCode, response1.Status[new TopicAndPartition("test", 0)].Error); Assert.Equal(-1L, response1.Status[new TopicAndPartition("test", 0)].Offset); var safeSize = Configs[0].MessageMaxBytes - Message.MessageOverhead - MessageSet.LogOverhead - 1; var message2 = new Message(new byte[safeSize]); var messageSet2 = new ByteBufferMessageSet( CompressionCodecs.NoCompressionCodec, new List <Message> { message2 }); var response2 = producer.Send(TestUtils.ProduceRequest("test", 0, messageSet2, acks: 1)); Assert.Equal(0, response2.Status.Count(kvp => kvp.Value.Error != ErrorMapping.NoError)); Assert.Equal(ErrorMapping.NoError, response2.Status[new TopicAndPartition("test", 0)].Error); Assert.Equal(0, response2.Status[new TopicAndPartition("test", 0)].Offset); }
/// <summary> /// Validates the form controls. /// </summary> private bool ValidateControls() { // validate the name when creating a new instance if (!EditMode) { string name = InstanceName; if (name == "") { ScadaUiUtils.ShowError(AppPhrases.InstanceNameEmpty); return(false); } if (!AdminUtils.NameIsValid(name)) { ScadaUiUtils.ShowError(AppPhrases.InstanceNameInvalid); return(false); } } // validate the applications if (!(ServerAppEnabled || CommAppEnabled || WebAppEnabled)) { ScadaUiUtils.ShowError(AppPhrases.InstanceSelectApps); return(false); } return(true); }
public FetcherTest() { this.cluster = new Cluster(Configs.Select(c => new Broker(c.BrokerId, "localhost", c.Port))); this.topicInfos = this.Configs.Select( c => new PartitionTopicInfo( this.topic, 0, this.queue, new AtomicLong(0), new AtomicLong(0), new AtomicInteger(0), string.Empty)) .ToList(); AdminUtils.CreateOrUpdateTopicPartitionAssignmentPathInZK( this.ZkClient, this.topic, new Dictionary <int, List <int> > { { 0, new List <int> { Configs.First().BrokerId } } }, new Dictionary <string, string>()); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, this.topic, 0, 500); this.fetcher = new ConsumerFetcherManager("consumer1", new ConsumerConfig(string.Empty, 1234, string.Empty), ZkClient); this.fetcher.StopConnections(); this.fetcher.StartConnections(this.topicInfos, this.cluster); }
public async Task iluCmd() { double duration = DataUtils.rnd.Next(20, 40); AdminUtils.addRestriction(Context.User.ToString(), duration); await Context.Channel.SendMessageAsync("Well, I dont! lol " + Context.User.Mention + "\nIma restrain you for " + duration + "s\n"); }
private void GetResponse() { this.Response.Clear(); this.Response.Write(AdminUtils.StandardDateFormat(AdminUtils.EmployeeDate(DateTime.UtcNow, curEmployee), false)); //this.Response.End(); HttpContext.Current.ApplicationInstance.CompleteRequest(); }
/// <summary> /// Renames the instance. /// </summary> public bool Rename(string newName, out string errMsg) { try { if (string.IsNullOrEmpty(newName)) { throw new ArgumentException(AdminPhrases.InstanceNameEmpty, nameof(newName)); } if (!AdminUtils.NameIsValid(newName)) { throw new ArgumentException(AdminPhrases.InstanceNameInvalid, nameof(newName)); } DirectoryInfo directoryInfo = new(InstanceDir); string newInstanceDir = Path.Combine(directoryInfo.Parent.FullName, newName); directoryInfo.MoveTo(newInstanceDir); InstanceDir = newInstanceDir; Name = newName; errMsg = ""; return(true); } catch (Exception ex) { errMsg = ex.BuildErrorMessage(AdminPhrases.RenameInstanceError); return(false); } }
// to do - why is this firing twice? protected void odsFoundJobs_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { ClientControlPanel ccp = null; if (this.PreviousPage != null) { ccp = (ClientControlPanel)this.PreviousPage.FindControl("ccp1"); ClientControlPanel newCcp = (ClientControlPanel)this.FindControl("ccp1"); newCcp.SearchBox.Text = ccp.SearchBox.Text; } else { ccp = (ClientControlPanel)this.FindControl("ccp1"); } TextBox searchBox = ccp.SearchBox; string searchTerms = searchBox.Text.Trim(); searchList = searchTerms.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); // remove stop words searchList = AdminUtils.RemoveStopWords(searchList).ToList(); e.InputParameters.Add("client", curClient); e.InputParameters.Add("searchTerms", searchList); e.InputParameters.Add("isAdmin", isAdmin); }
public void TestGetAllTopicMetadata() { // create topic var topic1 = "testGetAllTopicMetadata1"; var topic2 = "testGetAllTopicMetadata2"; AdminUtils.CreateTopic(this.ZkClient, topic1, 1, 1, new Dictionary <string, string>()); AdminUtils.CreateTopic(this.ZkClient, topic2, 1, 1, new Dictionary <string, string>()); // wait for leader to be elected for both topics TestUtils.WaitUntilMetadataIsPropagated(this.Servers, topic1, 0, 1000); TestUtils.WaitUntilMetadataIsPropagated(this.Servers, topic2, 0, 1000); // issue metadata request with empty list of topics var topicsMetadata = ClientUtils.FetchTopicMetadata( new HashSet <string>(), this.Brokers, "TopicMetadataTest-testGetAllTopicMetadata", 2000).TopicsMetadata; Assert.Equal(ErrorMapping.NoError, topicsMetadata.First().ErrorCode); Assert.Equal(2, topicsMetadata.Count); Assert.Equal(ErrorMapping.NoError, topicsMetadata.First().PartitionsMetadata.First().ErrorCode); Assert.Equal(ErrorMapping.NoError, topicsMetadata.Last().PartitionsMetadata.First().ErrorCode); var partitionMetadataTopic1 = topicsMetadata.First().PartitionsMetadata; var partitionMetadataTopic2 = topicsMetadata.Last().PartitionsMetadata; Assert.Equal(1, partitionMetadataTopic1.Count); Assert.Equal(0, partitionMetadataTopic1.First().PartitionId); Assert.Equal(1, partitionMetadataTopic1.First().Replicas.Count()); Assert.Equal(1, partitionMetadataTopic2.Count); Assert.Equal(0, partitionMetadataTopic2.First().PartitionId); Assert.Equal(1, partitionMetadataTopic2.First().Replicas.Count()); }
public void TestSendNullMessage() { var config = new ProducerConfig { Serializer = typeof(StringEncoder).AssemblyQualifiedName, KeySerializer = typeof(StringEncoder).AssemblyQualifiedName, PartitionerClass = typeof(StaticPartitioner).AssemblyQualifiedName, Brokers = TestUtils.GetBrokerListFromConfigs( new List <TempKafkaConfig> { this.config1, this.config2 }), }; var producer = new Producer <string, string>(config); try { // create topic AdminUtils.CreateTopic(this.ZkClient, "new-topic", 2, 1, new Dictionary <string, string>()); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, "new-topic", 0, 500); producer.Send(new KeyedMessage <string, string>("new-topic", "key", null)); } finally { producer.Dispose(); } }
/// <summary> /// Validates the form fields. /// </summary> private bool ValidateFields() { // validate the name if (Mode == FormOperatingMode.New) { string name = InstanceName; if (name == "") { ScadaUiUtils.ShowError(AppPhrases.InstanceNameEmpty); return(false); } if (!AdminUtils.NameIsValid(name)) { ScadaUiUtils.ShowError(AppPhrases.InstanceNameInvalid); return(false); } } // validate the applications if (!(ServerAppEnabled || CommAppEnabled || WebAppEnabled)) { ScadaUiUtils.ShowError(AppPhrases.InstanceSelectApps); return(false); } return(true); }
/// <summary> /// Renames the instance. /// </summary> public bool Rename(string name, out string errMsg) { try { if (!AdminUtils.NameIsValid(name)) { throw new ArgumentException(AdminPhrases.IncorrectProjectName); } string projectDir = Path.GetDirectoryName(FileName); DirectoryInfo directoryInfo = new DirectoryInfo(projectDir); string newProjectDir = Path.Combine(directoryInfo.Parent.FullName, name); if (Directory.Exists(newProjectDir)) { throw new ScadaException(AdminPhrases.ProjectDirectoryExists); } File.Move(FileName, GetProjectFileName(projectDir, name)); Directory.Move(projectDir, newProjectDir); FileName = GetProjectFileName(newProjectDir, name); errMsg = ""; return(true); } catch (Exception ex) { errMsg = AdminPhrases.RenameProjectError + ": " + ex.Message; return(false); } }
public void CreateSimpleTopicsAndAwaitLeader(ZkClient zkClient, List <string> topics, int brokerId) { foreach (var topic in topics) { AdminUtils.CreateTopic(zkClient, topic, 1, 1, new Dictionary <string, string>()); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, topic, 0, 500); } }
private string SegmentsTable() { StringBuilder sb = new StringBuilder(); sb.Append("<table class=\"openJobs\">"); sb.Append("<tr>"); sb.Append("<th>Employee</th>"); sb.Append("<th>Start</th>"); sb.Append("<th>Stop</th>"); sb.Append("<th>Notes</th>"); sb.Append("<th></th>"); sb.Append("</tr>"); foreach (JobSegment segment in curSegments) { string segmentEmployee = segment.Employee.FirstName.Substring(0, 1) + ". " + segment.Employee.LastName; DateTime segmentStart = AdminUtils.EmployeeDate(segment.StartDate, curEmployee); bool isOpenSegment = segment.EndDate == DateTime.MinValue; DateTime segmentStop = DateTime.MinValue; if (!isOpenSegment) { segmentStop = AdminUtils.EmployeeDate(segment.EndDate, curEmployee); } sb.Append("<tr"); if (isOpenSegment) { sb.Append(" class=\"openJobSegment\""); } sb.Append(">"); sb.Append("<td>" + segmentEmployee + "</td>"); sb.Append("<td>" + AdminUtils.StandardDateFormat(segmentStart, true) + "</td>"); sb.Append("<td>"); if (!isOpenSegment) { sb.Append(AdminUtils.StandardDateFormat(segmentStop, true)); } sb.Append("</td>"); sb.Append("<td>" + SiteUtils.SurroundTextBlocksWithHtmlTags(segment.Notes, "div", null) + "</td>"); sb.Append("<td>"); if (isOpenSegment && segment.Employee.Equals(curEmployee)) { sb.Append("<a href=\"\" id=\"hlStopWork\">Stop</a>"); } sb.Append("</td>"); sb.Append("</tr>"); } sb.Append("</table>"); return(sb.ToString()); }
private void chkIsBound_CheckedChanged(object sender, EventArgs e) { if (!changing && GetSelectedItem(out ListViewItem item, out DeviceConfig deviceConfig)) { deviceConfig.IsBound = chkIsBound.Checked; item.SubItems[3].Text = AdminUtils.GetCheckedString(chkIsBound.Checked); OnConfigChanged(); } }
private void chkActive_CheckedChanged(object sender, EventArgs e) { if (!changing && GetSelectedItem(out ListViewItem item, out DataSourceConfig dataSourceConfig)) { dataSourceConfig.Active = chkActive.Checked; item.SubItems[1].Text = AdminUtils.GetCheckedString(chkActive.Checked); ChildFormTag.Modified = true; } }
/// <summary> /// Creates a new project with the specified parameters. /// </summary> public static bool Create(string name, string location, string template, out ScadaProject project, out string errMsg) { try { // validate argumants if (!AdminUtils.NameIsValid(name)) { throw new ArgumentException(AdminPhrases.IncorrectProjectName); } string projectDir = Path.Combine(location, name); if (Directory.Exists(projectDir)) { throw new ScadaException(AdminPhrases.ProjectDirectoryExists); } // copy template FileInfo templateFileInfo = new FileInfo(template); string projectFileName = GetProjectFileName(projectDir, name); if (templateFileInfo.Exists) { CopyDirectory(templateFileInfo.Directory, new DirectoryInfo(projectDir)); File.Move(Path.Combine(projectDir, templateFileInfo.Name), projectFileName); } // create project project = new ScadaProject { Name = name }; if (File.Exists(projectFileName)) { // load from template project.Load(projectFileName); project.Description = ""; } project.Save(project.FileName); // create the necessary directories Directory.CreateDirectory(projectDir); Directory.CreateDirectory(project.ConfigBase.BaseDir); Directory.CreateDirectory(project.Interface.InterfaceDir); errMsg = ""; return(true); } catch (Exception ex) { project = null; errMsg = AdminPhrases.CreateProjectError + ": " + ex.Message; return(false); } }
public void TestConsumerEmptyTopic() { var newTopic = "new-topic"; AdminUtils.CreateTopic(this.ZkClient, newTopic, 1, 1, new Dictionary <string, string>()); TestUtils.WaitUntilMetadataIsPropagated(this.Servers, newTopic, 0, 1000); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, newTopic, 0, 500); var fetchResponse = Consumer.Fetch(new FetchRequestBuilder().AddFetch(newTopic, 0, 0, 10000).Build()); Assert.False(fetchResponse.MessageSet(newTopic, 0).Iterator().HasNext()); }
public void TestProduceCorrectlyReceivesResponse() { var props = TestUtils.GetSyncProducerConfig(this.Configs[0].Port); var producer = new SyncProducer(props); var messages = new ByteBufferMessageSet( CompressionCodecs.NoCompressionCodec, new List <Message> { new Message(this.messageBytes) }); // #1 - test that we get an error when partition does not belong to broker in response var request = TestUtils.ProduceRequestWithAcks( new List <string> { "topic1", "topic2", "topic3" }, new List <int> { 0 }, messages, 1); var response = producer.Send(request); Assert.NotNull(response); Assert.Equal(request.CorrelationId, response.CorrelationId); Assert.Equal(3, response.Status.Count); foreach (var responseStatus in response.Status.Values) { Assert.Equal(ErrorMapping.UnknownTopicOrPartitionCode, responseStatus.Error); Assert.Equal(-1L, responseStatus.Offset); } // #2 - test that we get correct offsets when partition is owned by broker AdminUtils.CreateTopic(this.ZkClient, "topic1", 1, 1, new Dictionary <string, string>()); AdminUtils.CreateTopic(this.ZkClient, "topic3", 1, 1, new Dictionary <string, string>()); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, "topic3", 0, 5000); TestUtils.WaitUntilMetadataIsPropagated(Servers, "topic3", 0, 2000); var response2 = producer.Send(request); Assert.NotNull(response2); Assert.Equal(request.CorrelationId, response2.CorrelationId); Assert.Equal(3, response2.Status.Count); // the first and last message should have been accepted by broker Assert.Equal(ErrorMapping.NoError, response2.Status[new TopicAndPartition("topic1", 0)].Error); Assert.Equal(ErrorMapping.NoError, response2.Status[new TopicAndPartition("topic3", 0)].Error); Assert.Equal(0, response2.Status[new TopicAndPartition("topic1", 0)].Offset); Assert.Equal(0, response2.Status[new TopicAndPartition("topic3", 0)].Offset); // the middle message should have been rejected because broker doesn't lead partition Assert.Equal(ErrorMapping.UnknownTopicOrPartitionCode, response2.Status[new TopicAndPartition("topic2", 0)].Error); Assert.Equal(-1L, response2.Status[new TopicAndPartition("topic2", 0)].Offset); }
/// <summary> /// Creates a new list view item that represents the specified data source. /// </summary> private static ListViewItem CreateDataSourceItem(DataSourceConfig dataSourceConfig, ref int index) { return(new ListViewItem(new string[] { (++index).ToString(), AdminUtils.GetCheckedString(dataSourceConfig.Active), dataSourceConfig.Code, dataSourceConfig.Name, dataSourceConfig.Driver }) { Tag = dataSourceConfig }); }
public void TestLeaderSelectionForPartition() { var zkClient = new ZkClient(this.zookeeperConnect, 6000, 30000, new ZkStringSerializer()); // create topic topic1 with 1 partition on broker 0 AdminUtils.CreateTopic(zkClient, Topic, 1, 1, new Dictionary <string, string>()); TestUtils.WaitUntilMetadataIsPropagated(this.Servers, Topic, 0, 3000); var sentMessages1 = this.SendMessages( Configs.First(), nMessages, "batch1", CompressionCodecs.NoCompressionCodec, 1); TestUtils.WaitUntilMetadataIsPropagated(this.Servers, Topic, 0, 1000); // create a consuemr var consumerConfig1 = TestUtils.CreateConsumerProperties(ZkConnect, Group, Consumer1); var zkConsumerConnector1 = new ZookeeperConsumerConnector(consumerConfig1); var topicMessageStreams1 = zkConsumerConnector1.CreateMessageStreams( new Dictionary <string, int> { { Topic, 1 } }, new StringDecoder(), new StringDecoder()); var topicRegistry = zkConsumerConnector1.TopicRegistry; Assert.Equal(1, topicRegistry.Select(x => x.Key).Count()); Assert.Equal(Topic, topicRegistry.Select(x => x.Key).First()); var topicsAndPartitionsInRegistry = topicRegistry.Select(x => Tuple.Create(x.Key, x.Value.Select(p => p.Value))).ToList(); var brokerPartition = topicsAndPartitionsInRegistry.First().Item2.First(); Assert.Equal(0, brokerPartition.PartitionId); // also check partition ownership var actual_1 = this.GetZKChildrenValues(this.dirs.ConsumerOwnerDir); var expected_1 = new List <Tuple <string, string> > { Tuple.Create("0", "group1_consumer1-0"), }; Assert.Equal(expected_1, actual_1); var receivedMessages1 = this.GetMessages(nMessages, topicMessageStreams1); Assert.Equal(sentMessages1, receivedMessages1); zkConsumerConnector1.Shutdown(); zkClient.Dispose(); }
/// <summary> /// Creates a new list view item that represents the specified archive. /// </summary> private static ListViewItem CreateArchiveItem(ArchiveConfig archiveConfig, ref int index) { return(new ListViewItem(new string[] { (++index).ToString(), AdminUtils.GetCheckedString(archiveConfig.Active), archiveConfig.Code, archiveConfig.Name, TranslateArchiveKind(archiveConfig.Kind), archiveConfig.Module }) { Tag = archiveConfig }); }
public Invoice CreateCurrentInvoice(Client client, Employee curAdmin) { IList <Job> uninvoicedJobs = Job.UninvoicedJobsForClient(client); if (uninvoicedJobs.Count == 0) { return(null); } DateTime nowForAdmin = AdminUtils.EmployeeDate(DateTime.UtcNow, curAdmin); DateTime invoiceDate = new DateTime(nowForAdmin.Year, nowForAdmin.Month, 1, 0, 0, 0); // first day of month DateTime dueDate = invoiceDate.AddMonths(1); return(CreateInvoice(client, invoiceDate, dueDate, uninvoicedJobs)); }
/// <summary> /// Validates the form field. /// </summary> private bool ValidateFields() { string fileName = FileName; if (fileName == "") { ScadaUiUtils.ShowError(AppPhrases.FileNameEmpty); return(false); } if (!AdminUtils.NameIsValid(fileName)) { ScadaUiUtils.ShowError(AppPhrases.FileNameInvalid); return(false); } return(true); }
public IActionResult AddArticleCategory(ArticleCategory model) { //获取上级栏目 if (string.IsNullOrWhiteSpace(model.KindName)) { tip.Message = "文章栏目标题不能为空!"; return(Json(tip)); } if (string.IsNullOrEmpty(model.FilePath)) { tip.Message = "文章栏目路径不能为空!"; return(Json(tip)); } if (!model.FilePath.StartsWith("/")) { tip.Message = "栏目路径请以/开头!"; return(Json(tip)); } if (model.FilePath.EndsWith("/")) { tip.Message = "栏目路径结尾不用加上/"; return(Json(tip)); } if (model.FilePath.Count(x => x == '/') > 4) { tip.Message = "最多只能四级路径!"; return(Json(tip)); } if (!AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 0)) { tip.Message = "栏目路径不可用,请重新填写!"; return(Json(tip)); } model.Insert(); Core.Admin.WriteLogActions("添加文章栏目(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章栏目成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public async Task restrainCmd(string username, double timeInSeconds = 60) { username = AliasUtils.getNameFromAlias(username); if (username != "null") { if (MasterUtils.ContainsAny(Context.User.ToString(), GlobalVars.ADMINS)) { AdminUtils.addRestriction(username, timeInSeconds); await Context.Channel.SendMessageAsync(username + " is restrained for " + timeInSeconds + "s!"); } else { await Context.Channel.SendMessageAsync("\"Get Fukt Idiot\" - Nickalodeon 2017"); } } else { await Context.Channel.SendMessageAsync("Unregistered Username"); } }
public void TestTopicMetadataRequest() { // create topic var topic = "test"; AdminUtils.CreateTopic(this.ZkClient, topic, 1, 1, new Dictionary <string, string>()); // create a topic metadata request var topicMetadataRequest = new TopicMetadataRequest(new List <string> { topic }, 0); var serializedMetadataRequest = ByteBuffer.Allocate(topicMetadataRequest.SizeInBytes + 2); topicMetadataRequest.WriteTo(serializedMetadataRequest); serializedMetadataRequest.Rewind(); var deserializedMetadataRequest = TopicMetadataRequest.ReadFrom(serializedMetadataRequest); Assert.Equal(topicMetadataRequest, deserializedMetadataRequest); }
public void TestMessageSizeTooLargeWithAckZero() { var props = TestUtils.GetSyncProducerConfig(this.Configs[0].Port); props.RequestRequiredAcks = 0; var producer = new SyncProducer(props); AdminUtils.CreateTopic(this.ZkClient, "test", 1, 1, new Dictionary <string, string>()); TestUtils.WaitUntilLeaderIsElectedOrChanged(this.ZkClient, "test", 0, 500); // This message will be dropped silently since message size too large. producer.Send( TestUtils.ProduceRequest( "test", 0, new ByteBufferMessageSet( CompressionCodecs.NoCompressionCodec, new List <Message> { new Message(new byte[Configs[0].MessageMaxBytes + 1]) }))); // Send another message whose size is large enough to exceed the buffer size so // the socket buffer will be flushed immediately; // this send should fail since the socket has been closed try { producer.Send( TestUtils.ProduceRequest( "test", 0, new ByteBufferMessageSet( CompressionCodecs.NoCompressionCodec, new List <Message> { new Message(new byte[Configs[0].MessageMaxBytes + 1]) }))); } catch (IOException) { } }
private Panel FileDiv(JobFile file) { Panel pnlFile = new Panel(); if (!curJob.IsArchived) { // just url with qs LiteralControl hlFile = new LiteralControl(AdminUtils.LinkToGetFilePage_Image(file, "employees") + " " + AdminUtils.LinkToGetFilePage_Text(file, "employees")); pnlFile.Controls.Add(hlFile); } else // archived - no link { LiteralControl fileWithImg = new LiteralControl(AdminUtils.FileIcon() + " " + file.Name + " (archived)"); pnlFile.Controls.Add(fileWithImg); } return(pnlFile); }
public async Task RemoveRestrainCmd(string username) { username = AliasUtils.getNameFromAlias(username); if (username != "null") { string userName = Context.User.ToString(); if (MasterUtils.ContainsAny(Context.User.ToString(), GlobalVars.ADMINS)) { AdminUtils.RemoveRestrain(username); await Context.Channel.SendMessageAsync(username + " is no longer restrained!"); } else { await Context.Channel.SendMessageAsync("\"Get Fukt Idiot\" - Nickalodeon 2017"); } } else { await Context.Channel.SendMessageAsync("Unregistered Username"); } }
/// <summary> /// Renames the instance. /// </summary> public bool Rename(string name, out string errMsg) { try { if (!AdminUtils.NameIsValid(name)) { throw new ArgumentException("The specified name is incorrect."); } DirectoryInfo directoryInfo = new DirectoryInfo(InstanceDir); string newInstanceDir = Path.Combine(directoryInfo.Parent.FullName, name); directoryInfo.MoveTo(newInstanceDir); InstanceDir = newInstanceDir; Name = name; errMsg = ""; return(true); } catch (Exception ex) { errMsg = AdminPhrases.RenameInstanceError + ": " + ex.Message; return(false); } }