public static void AddRequestByTask(int ttid, string notes, BuildType type) { var defect = new Defect(ttid); var settings = Settings.CurrentSettings; var emial = MPSUser.FindUserbyPhone(settings.AUTOBOTPHONE).EMAIL; var urlBase = new UriBuilder(settings.BUILDMICROSEVICE) { Scheme = Uri.UriSchemeHttps, Port = -1, }; var url = new Uri(urlBase.ToString().TrimEnd('/') + "/addBuild"); var Client = new RestClient(url.ToString()); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "ApiKey " + settings.BUILDMICROSEVICEKEY); request.AddParameter("id", ttid, ParameterType.QueryString); request.AddParameter("summary", defect.SUMMARY, ParameterType.QueryString); request.AddParameter("mail", emial, ParameterType.QueryString); request.AddParameter("branch", defect.BRANCH, ParameterType.QueryString); request.AddParameter("notes", notes, ParameterType.QueryString); request.AddParameter("type", (int)type, ParameterType.QueryString); request.AddParameter("batches", string.Join(",", defect.BSTBATCHES.Split('\n')), ParameterType.QueryString); request.AddParameter("commands", string.Join(",", defect.BSTCOMMANDS.Split('\n')), ParameterType.QueryString); request.AddParameter("priority", defect.TESTPRIORITY, ParameterType.QueryString); request.AddParameter("owner", emial, ParameterType.QueryString); var response = Client.Execute(request); //AddObject(_Tabl, new string[] { _par, _not, _User, _dateB, _type }, new object[] { Defect.GetIDbyTT(ttid), notes, CurrentContext.User.TTUSERID, DateTime.Now, (int)type }, _pid); }
private static async void BotOnUpdateReceived(object sender, UpdateEventArgs e) { var message = e.Update.Message; if (Settings.CurrentSettings.TELEGRAMCOMPANYCHANNEL == message.Chat.Id.ToString()) { //ignore company chats return; } if (message == null || message.Type != MessageType.Text) { return; } string text = message.Text.ToUpper(); if (text == "/START") { await _client.SendTextMessageAsync(message.Chat.Id, $"Hi, {message.Chat.FirstName}, type /subscribe:xxx"); await _client.SendTextMessageAsync(message.Chat.Id, "where xxx is the your phone number in intentional format: +375..."); return; } else if (text.StartsWith(_comSubs)) { string num = Regex.Replace(text.Remove(0, "_comSubs".Length), "[^0-9]", ""); await _client.SendTextMessageAsync(message.Chat.Id, $"Your number is: {num}"); MPSUser u = MPSUser.FindUserbyPhone(num); if (u == null) { await _client.SendTextMessageAsync(message.Chat.Id, $"User no found, phone: {num}"); return; } await _client.SendTextMessageAsync(message.Chat.Id, $"User {u.PERSON_NAME} was found! Subscribing..."); u.CHATID = message.Chat.Id.ToString(); u.Store(); await _client.SendTextMessageAsync(message.Chat.Id, $"User {u.PERSON_NAME} has been subscribed!"); return; } await _client.SendTextMessageAsync(message.Chat.Id, "Wrong command. Press /start to see more information"); }
public string scheduledBuild() { if (HttpContext.Current.Request.Url.Host.ToUpper() != "LOCALHOST") { return("Rejected: Schedule can be run only locally."); } MPSUser u = MPSUser.FindUserbyPhone(Settings.CurrentSettings.AUTOBOTPHONE); if (u == null || !u.ISADMIN) { return("No auto bot users found with admin rights."); } CurrentContext.User = u; VersionBuilder.PrepareGit(); VersionBuilder.VersionIncrement(); VersionBuilder.PushRelease(); VersionBuilder.SendVersionAlarm(); addBuildByTask(Settings.CurrentSettings.RELEASETTID, "Automated Build", btboth); return("OK"); }
public void NotifyDefectWorker(string ttid, string message, string userphone) { try { MPSUser bsu = MPSUser.FindUserbyPhone(userphone); if (bsu == null) { Logger.Log($"Cannot update task {ttid} by testing system. User was not found by phone number: {userphone}"); return; } Defect d = new Defect(ttid); DefectUser du = new DefectUser(d.AUSER); if (du.TRID > -1) { MPSUser worker = new MPSUser(du.TRID); TasksBot.SendMessage(worker.CHATID, message); } } catch (Exception e) { Logger.Log(e); } }
public void SetTaskTestStatus(string ttid, string failed, string userphone) { try { MPSUser bsu = MPSUser.FindUserbyPhone(userphone); if (bsu == null) { Logger.Log($"Cannot update task {ttid} by testing system. User was not found by phone number: {userphone}"); return; } Defect d = new Defect(ttid); d.SetUpdater(bsu); string lockguid = Guid.NewGuid().ToString(); var lt = Defect.Locktask(ttid.ToString(), lockguid, bsu.ID.ToString()); bool locked = lt.globallock != lockguid; bool testFail; bool testcancel = false; if (!bool.TryParse(failed, out testFail)) { testcancel = true; } if (locked) { MPSUser lu = new MPSUser(lt.lockedby); TasksBot.SendMessage(lu.CHATID, $"You was disconnected from the task by the testing system to update task status!{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), "disconnect.png")}"); NotifyHub.lockTaskForceUpdatePages(int.Parse(ttid), lockguid, bsu.ID); lt = Defect.Locktask(ttid.ToString(), lockguid, bsu.ID.ToString()); } List <DefectDispo> disp = (testcancel || testFail) ? DefectDispo.EnumTestsFailed() : DefectDispo.EnumTestsPassed(); if (disp.Count > 0) { if (!testcancel) { d.DISPO = disp[0].ID.ToString(); } else { d.AddMessage("Test request have been ignored", bsu.ID); } d.Store(); Defect.UnLocktask(ttid, lt.globallock); if (!testcancel) { DefectUser du = new DefectUser(d.AUSER); if (du.TRID > -1) { MPSUser worker = new MPSUser(du.TRID); string result = "Succeeded!"; string img = "taskokay.png"; if (testcancel) { result = "Cancelled!"; img = "bin.png"; } else if (testFail) { result = "Failed!"; img = "taskfail.png"; } TasksBot.SendMessage(worker.CHATID, $"The task tests have been marked as BST {result} by {bsu.PERSON_NAME}{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), img)}"); } } } } catch (Exception e) { Logger.Log(e); } }
private static async void BotOnUpdateReceived(object sender, UpdateEventArgs e) { var message = e.Update.Message; if (message != null && Settings.CurrentSettings.TELEGRAMSUPPORTGROUP == message.Chat.Id.ToString()) { //ignore company chats return; } if (message == null || message.Type != MessageType.Text) { return; } string text = message.Text.ToUpper(); if (text == "/START") { await _client.SendTextMessageAsync(message.Chat.Id, $"Hi, {message.Chat.FirstName}, type /subscribe:xxx"); await _client.SendTextMessageAsync(message.Chat.Id, "where xxx is the your phone number in intentional format: +375..."); return; } else if (text.StartsWith(_comSubs)) { string num = Regex.Replace(text.Remove(0, "_comSubs".Length), "[^0-9]", ""); await _client.SendTextMessageAsync(message.Chat.Id, $"Your number is: {num}"); MPSUser u = MPSUser.FindUserbyPhone(num); if (u == null) { await _client.SendTextMessageAsync(message.Chat.Id, $"User no found, phone: {num}"); return; } await _client.SendTextMessageAsync(message.Chat.Id, $"User {u.PERSON_NAME} was found! Subscribing..."); u.SUPCHATID = message.Chat.Id.ToString(); u.Store(); await _client.SendTextMessageAsync(message.Chat.Id, $"User {u.PERSON_NAME} has been subscribed!"); return; } List <MPSUser> ls = MPSUser.EnumAllSupporters(); foreach (var user in ls) { if (user.SUPCHATCLIENTID == message.Chat.Id.ToString()) { await _client.SendTextMessageAsync(user.SUPCHATID, message.Text); return; } if (user.SUPCHATID == message.Chat.Id.ToString()) { if (!string.IsNullOrEmpty(user.SUPCHATCLIENTID)) { await _client.SendTextMessageAsync(user.SUPCHATCLIENTID, message.Text); return; } else { await _client.SendTextMessageAsync(user.SUPCHATID, "type /select to select user to answer"); return; } } } foreach (var user in ls) { await _client.SendTextMessageAsync(message.Chat.Id, $"{message.From.FirstName} {message.From.LastName} Sent the message:"); await _client.SendTextMessageAsync(user.SUPCHATID, message.Text); } await _client.SendTextMessageAsync(message.Chat.Id, "Hi! Response to your message is pending..."); }