public void QueueRequest(MergeRequest mergeRequest) { // initially update the merge request with information from the POST request (or wherever it came from). // we might do another update later to make sure the data is still relevant. UpdateIssueDetails(mergeRequest, mergeRequest.IssueDetails); if (!ShouldTryToMerge(mergeRequest)) { return; } Task.Run(() => { bool shouldMerge; if (mergeRequest.IssueDetails == null) { Logger.Info(m => m("Got a merge request without associated Jira issue. Guess we should merge that one either way.")); shouldMerge = true; } else { Logger.Debug(m => m("Waiting a bit before queuing merge request for '{0}'", mergeRequest.IssueDetails.Key)); // wait a bit before actually queuing the request; someone might have accidentally closed the Jira issue Thread.Sleep(_gitSettings.MergeDelay); var issueDetails = _jira.GetIssueDetails(mergeRequest.IssueDetails.Key); if (issueDetails == null) { Logger.Warn(m => m("Jira didn't return any issue information while trying to check if we should still merge '{0}'; not doing a merge.", mergeRequest.IssueDetails.Key)); shouldMerge = false; } else if (!_jiraSettings.ClosedStatus.Contains(issueDetails.Status)) { Logger.Info(m => m("Related Jira issue is NOT closed; not doing a merge.")); shouldMerge = false; } else { shouldMerge = !ShouldPreventAutomerge(issueDetails); Logger.Info(m => m("Related Jira issue indicates it should {0}be merged, {0}preceding with merge.", shouldMerge ? "" : "not ")); if (shouldMerge) { UpdateIssueDetails(mergeRequest, issueDetails); } } } if (shouldMerge) { // HandleMergeRequests should only get valid ones, so check if the request is still valid _mergeRequests.Add(mergeRequest); } }); }
public string SetContactIntegrationShedule() { string result; try { UserConnection.DBSecurityEngine.CheckCanExecuteOperation("CanManageAdministration"); object interval = null; bool hasOldInterval = Terrasoft.Core.Configuration.SysSettings.TryGetValue(UserConnection, "LDAPSynchInterval", out interval); if (hasOldInterval && (int)interval != 0) { AppScheduler.ScheduleMinutelyProcessJob("NavAdProcessJob", "NavProcess", "NavAdStarterProcess", UserConnection.Workspace.Name, UserConnection.CurrentUser.Name, (int)interval * 60); global::Common.Logging.ILog _logger = global::Common.Logging.LogManager.GetLogger("ContactProcessLog"); _logger.Info("������������� ������������� ��������� ������ " + (int)interval + " �����"); } result = "Ok"; } catch (Exception ex) { result = ex.ToString(); } return(result); }
public static void DeployBundles() { lock (_lock) { if (!_done) { _Log.Info("Deploying native bundles..."); DeployBundlesTo(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location)); _done = true; } } }
public virtual void GetMessageText(out string message, out Udh udh) { message = null; udh = null; byte[] msgBytes = GetMessageBytes(); if (msgBytes == null) { return; } ByteBuffer buffer = new ByteBuffer(msgBytes); //Check if the UDH is set in the esm_class field if ((EsmClass & EsmClass.UdhiIndicator) == EsmClass.UdhiIndicator) { _Log.Info("200020:UDH field presense detected;"); if (vTraceSwitch.TraceInfo) { Trace.WriteLine("200020:UDH field presense detected;"); } try { udh = Udh.Parse(buffer, vSmppEncodingService); } catch (Exception ex) { _Log.ErrorFormat("20023:UDH field parsing error - {0}", ex, new ByteBuffer(msgBytes).DumpString()); if (vTraceSwitch.TraceError) { Trace.WriteLine(string.Format( "20023:UDH field parsing error - {0} {1};", new ByteBuffer(msgBytes).DumpString(), ex.Message)); } throw; } } //Check if we have something remaining in the buffer if (buffer.Length == 0) { return; } try { message = vSmppEncodingService.GetStringFromBytes(buffer.ToBytes(), DataCoding); } catch (Exception ex1) { _Log.ErrorFormat("200019:SMS message decoding failure - {0}", ex1, new ByteBuffer(msgBytes).DumpString()); if (vTraceSwitch.TraceError) { Trace.WriteLine(string.Format( "200019:SMS message decoding failure - {0} {1};", new ByteBuffer(msgBytes).DumpString(), ex1.Message)); } throw; } }
public void PostComment(string issueKey, string comment) { var baseUri = new Uri(_jiraSettings.BaseUrl); var requestUri = new Uri(baseUri, $"rest/api/2/issue/{issueKey}/comment"); var request = WebRequest.CreateHttp(requestUri); request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes($"{_jiraSettings.UserName}:{_jiraSettings.Password}")); request.ContentType = "application/json"; request.Method = "POST"; try { using (var requestStream = request.GetRequestStream()) { var postContent = new XDocument(new XElement("root", new XAttribute("type", "object"), new XElement("body", new XAttribute("type", "string"), comment))); JsonHelper.SerializeTo(postContent, requestStream); } var response = request.GetResponse(); using (var streamReader = new StreamReader(response.GetResponseStream())) { string responseString = streamReader.ReadToEnd(); Logger.Debug(m => m("Response for PostComment: {0}", responseString)); var httpResponse = response as HttpWebResponse; if (httpResponse?.StatusCode == HttpStatusCode.Created) { // TODO: maybe do something else too? Logger.Info(m => m("Comment successfully added to '{0}'.", issueKey)); } } } catch (WebException ex) { using (var streamReader = new StreamReader(ex.Response.GetResponseStream())) Logger.Error(m => m("Request to '{0}' apparently failed: {1}\r\n{2}", requestUri, ex.Message, streamReader.ReadToEnd()), ex); } }
public void Info(Object message, Exception exception) { _log.Info(message, exception); }
public IEnumerable <GitRepositoryBranch> FindBranch(string branchName, bool isExactBranchName) { Logger.Debug(m => m("Trying to find matching repositories for '{0}' (exact match: {1})", branchName, isExactBranchName)); foreach (var repositoryInfo in _gitSettings.Repositories) { var repository = Get(repositoryInfo); if (!repository.Exists()) { if (!repository.Initialize()) { // TODO: notify someone that the repository couldn't be initialized? continue; } } else { if (!repository.Fetch()) { // TODO: notify someone that the fetch failed? continue; } } string[] branches = repository.Branches(); Logger.Debug(m => m("Found {0} branches: {1}", branches.Length, string.Join(", ", branches))); if (isExactBranchName) { // assume an exact branch match is always intentional, and must never be ignored. // might happen that a review/testing/whatever branch supersedes the real one, // and the lazy developer simply inputs their branch name as source. if (branches.Contains(branchName)) { Logger.Info(m => m("Got an exact branch name match for '{0}' in '{1}'.", branchName, repository.RepositoryIdentifier)); yield return(new GitRepositoryBranch(repository, branchName)); } // else: no such branch. probably, nothing to do for this repository // TODO: maybe check if theres a matching branch of different casing? } else { // since its not an exact match, we can assume it is a Jira issue key. // they follow the pattern "<project key>-<issue number>", where the issue number is strictly numeric; // and the project key only contains letters, numbers or the underscore (always starting with a letter). // append a negative look-ahead for digits, which should prevent matching partial issue numbers. // we cannot use word-boundaries here, since it will not match names such as JRA-123b or JRA-123_fixed. // NOTE: this is mostly convention being used in practise; this might not match all configurations on all systems. // FIXME: this does not account for the beginning of the branch name; but in practise we do not have overlap // (and therefore don't need to check for it right now) var jiraIssueKey = new Regex(branchName + @"(?!\d)", RegexOptions.IgnoreCase); var matchingBranches = branches.Where(branch => jiraIssueKey.IsMatch(branch)); var nonIgnoredBranches = matchingBranches.Where(IsEligibleBranchForMerging).ToArray(); var ignoredBranches = matchingBranches.Except(nonIgnoredBranches).Select(b => $"{b} (ignored)").ToArray(); if (nonIgnoredBranches.Count() == 1) { Logger.Info(m => m("Found a branch name match for '{0}' (exact spelling is '{1}') in '{2}'.", branchName, matchingBranches.First(), repository.RepositoryIdentifier)); yield return(new GitRepositoryBranch(repository, matchingBranches.First())); } else if (nonIgnoredBranches.Count() + ignoredBranches.Count() > 0) { var branchesToLog = nonIgnoredBranches.Concat(ignoredBranches); Logger.Warn(m => m("Found {0} branches matching '{1}' in repository '{2}', cannot decide which one they wanted: {3}", matchingBranches.Count(), branchName, repository.RepositoryIdentifier, string.Join(", ", branchesToLog))); foreach (string matchingBranchName in nonIgnoredBranches) { yield return(new GitRepositoryBranch(repository, matchingBranchName)); } foreach (string matchingBranchName in ignoredBranches) { yield return new GitRepositoryBranch(repository, matchingBranchName) { IsIgnored = true } } ; } } } }
static void Main(string[] args) { Common.Logging.LogManager.Adapter = new Common.Logging.Simple.DebugLoggerFactoryAdapter(); var encSrv = new SmppEncodingService(); var hexBytes = "000000dd0000000500000000019182410001013334363439323836383039000501657669636572746961000400000000000000008569643a323533303932393134353232363637333732207375623a30303120646c7672643a303031207375626d697420646174653a3133303932393136353220646f6e6520646174653a3133303932393136353220737461743a44454c49565244206572723a3030303020746578743a1b3c657669534d531b3e0a534d532064652050727565042300030300000427000102001e001332353330393239313435323236363733373200"; var packet = StringToByteArray(hexBytes); var bodyBytes = packet.Skip(16).ToArray(); var pdu = PDU.CreatePDU(PDUHeader.Parse(new ByteBuffer(packet), encSrv), encSrv); pdu.SetBodyData(new ByteBuffer(bodyBytes)); var receiptedMessageId = pdu.GetOptionalParamString(JamaaTech.Smpp.Net.Lib.Protocol.Tlv.Tag.receipted_message_id); //Assert.AreEqual("253092914522667372", pdu.ReceiptedMessageId); _Log.Info("Start"); //Trace.Listeners.Add(new ConsoleTraceListener()); smppConfig = GetSmppConfiguration(); //SMPPEncodingUtil.UCS2Encoding = Encoding.UTF8; client = CreateSmppClient(smppConfig); client.Start(); // must wait until connected before start sending while (client.ConnectionState != SmppConnectionState.Connected) { Thread.Sleep(100); } // Accept command input bool bQuit = false; do { // Hit Enter in the terminal once the binds are up to see this prompt Console.WriteLine("Commands"); Console.WriteLine("send 123456 hello"); Console.WriteLine("quit"); Console.WriteLine(""); Console.Write("\n#>"); string command = Console.ReadLine(); if (command.Length == 0) { continue; } switch (command.Split(' ')[0].ToString()) { case "quit": case "exit": case "q": bQuit = true; break; default: ProcessCommand(command); break; } if (bQuit) { break; } } while (true); if (client != null) { client.Dispose(); } }