private static void FillOutputGridRowWithTMSData(TMSItem item, DataRow r, string reason) { r["Reason"] = reason; r["TMS"] = item.TMS; r["TMS_Assigned"] = item.AssignedTo; r["TMS_Status"] = item.Status; if (IsAssignedToMe(item.AssignedTo)) { r["Me"] = "Y"; } }
private TMSDictionary GetTMSDataFromDB() { DataTable tmsTasksFromDBDataTable = new DataTable(); if (!Consts.TEST_MODE) { //sw.StartStopwatchAndPrintMessage("Getting TMS tasks from DB and making cache...", output); //Task<DataTable> execureQueryTask = DBService.ExecuteQueryAsync(DBService.GET_ALL_TMS_TASKS); tmsTasksFromDBDataTable = DBService.ExecuteQuery(DBService.GET_ALL_TMS_TASKS); tmsTasksFromDBDataTable.TableName = "TMS_DATA"; tmsTasksFromDBDataTable.WriteXml(Consts.FILE_NAMES.DB_TMS_CACHE); //sw.StopStopwatchAndPrintDoneMessageWithElapsedTime("Getting TMS tasks from DB and making cache...done", output); } else { //sw.StartStopwatchAndPrintMessage("Getting TMS tasks from cache...", output); DataSet ds = new DataSet(); ds.ReadXml(Consts.FILE_NAMES.DB_TMS_CACHE, XmlReadMode.InferSchema); tmsTasksFromDBDataTable = ds.Tables[0]; //sw.StopStopwatchAndPrintDoneMessageWithElapsedTime("Getting TMS tasks from cache...done", output); } //Dictionary<string, TMSItem> dbTMSDict = new Dictionary<string, TMSItem>(); TMSDictionary dbTMSDict = new TMSDictionary(); //List<string> team_members = TeamService.GetDEV1TeamMembersTMSLogins(); //sw.StartStopwatchAndPrintMessage("Conversion DB items to objects...", output); foreach (DataRow tmsTaskFromDB in tmsTasksFromDBDataTable.Rows) { TMSItem item = new TMSItem(); item.Source = Consts.SRC_DB; item.AssignedTo = Convert.ToString(tmsTaskFromDB["EMPLOYEE"]); item.TMS = Convert.ToString(tmsTaskFromDB["TMS_ID"]); item.Status = Convert.ToString(tmsTaskFromDB["STATUS"]); item.Urgency = Convert.ToString(tmsTaskFromDB["URG"]); item.LastActText = Convert.ToString(tmsTaskFromDB["LASTACTION_TXT"]); item.LastActDate = Convert.ToDateTime(tmsTaskFromDB["LASTACTION_DATE"]); item.Desctiption = Convert.ToString(tmsTaskFromDB["TASK_DESCRIPTION"]); item.SDId = Convert.ToString(tmsTaskFromDB["SOFTDEV_ID"]); dbTMSDict.Add(item); } //sw.StopStopwatchAndPrintDoneMessageWithElapsedTime("Conversion DB items to objects...done", output); return(dbTMSDict); }
public static void CreateTMSCache(IOutputable output) { output.Write("Cache creation..."); //NameValueCollection parameters = new NameValueCollection { { "status_id", "*" } }; // Task<List<Issue>> issuesListFromRemineTask = CommonTools.GetIssuesFromRedmine(Consts.PROJECT_NAMES.TMS.MACBI.PROBLEMS); List <Issue> issuesListFromRemine = CommonTools.GetIssuesFromRedmine(Consts.PROJECT_NAMES.TMS.MACBI.PROBLEMS); foreach (var issue in issuesListFromRemine) { string subject = issue.Subject; TMSItem itemFromRM = new TMSItem(); itemFromRM.Source = Consts.SRC_RM; itemFromRM.AssignedTo = issue.AssignedTo.TryGetName(); itemFromRM.Desctiption = issue.Description; string[] subjectSplitted = issue.Subject.Split('-'); itemFromRM.TMS = issue.Subject.Split('-')[0].Trim() + "-" + issue.Subject.Split('-')[1].Trim(); itemFromRM.Status = issue.Status.TryGetName(); } output.WriteLine("Cache creation...done!"); }
public void AddMissingTMSTasksToRedmine() { sw.StartStopwatchAndPrintMessage("Getting TMS tasks from DB and making cache...", output); GetherSyncData(); IdentifiableName p = IdentifiableName.Create <Project>(Consts.PROJECT_NAMES.TMS.MACBI.PROBLEMS); //to-be-changed //IdentifiableName u = IdentifiableName.Create<User>(USER_ID); //var user = RMManegerService.RMManager.GetObject<User>(USER_ID.ToString(), null); IdentifiableName u = IdentifiableName.Create <IdentifiableName>(USER_ID); IdentifiableName priority = IdentifiableName.Create <IdentifiableName>(PRIORITY_HIGH); //var newIssue = new Issue { Subject = subject, Project = p, Description = details }; //RMManegerService.RMManager.CreateObject(newIssue); int limit = 5; List <string> listOfAddedItems = new List <string>(); List <string> listOfNOTAddedItems = new List <string>(); foreach (TMSItem item in dbTMSDict.GetNotClosedNotUsedAssignedToDEV1ItemList(TeamService.UsersTMSLogin)) { string description = item.Desctiption; //check if really there is no such a TMS in RM (maybe it was already closed) TMSItem tmsItem = rmTMSDict.Get(item.TMS); //redMineTMSList.Contains() if (tmsItem == null) { string firstLine = null; if (description.Contains("\r\n") || description.Contains(".")) { firstLine = description.Substring(0, description.Contains("\r\n") ? description.IndexOf("\r\n") : description.IndexOf(".")); } else { firstLine = description; } if (firstLine.Length > 255) { firstLine = firstLine.Substring(0, 240);//255 is max lenght of subject. int lastDotIndex = firstLine.LastIndexOf("."); if (lastDotIndex > -1) { firstLine = firstLine.Substring(0, lastDotIndex); } } string subject = string.Format("{0} - {1}", item.TMS, firstLine); var newIssue = new Issue { Subject = subject, Project = p, Description = description, AssignedTo = u, Priority = priority }; RMManegerService.RMManager.CreateObject(newIssue); listOfAddedItems.Add(subject); } else { listOfNOTAddedItems.Add(string.Format("{0}", tmsItem)); //Console.WriteLine("Item can't be added as it already exists: {0}", tmsItem); } if (Consts.TEST_MODE) { if (--limit == 0) { return; } } } output.WriteLine("List of added items ({0})", listOfAddedItems.Count); output.WriteLine("List of NOT added items ({0})", listOfNOTAddedItems.Count); if (listOfAddedItems.Count > 0) { output.WriteLine("Cache needs to be refreshed!"); rmTMSDict = null; GetherSyncData(); } sw.StopStopwatchAndPrintDoneMessageWithElapsedTime(output); }
//reason + list of pairs <TMS task, RM TMS task> public void CreateSyncOutputList() { outputList = new Dictionary <string, List <TMS_TP> >(); foreach (TMSItem itemFromRM in rmTMSDict.GetItemList()) { bool isRedmineAssignedToMyTeam = TeamService.IsPersonFromMyTeam(itemFromRM.AssignedTo); bool isTMSAssignedtoMyTeam = false; TMSItem dbTMSItem = dbTMSDict.Get(itemFromRM.TMS); if (dbTMSItem != null) { isTMSAssignedtoMyTeam = TeamService.IsPersonFromMyTeam(dbTMSItem.AssignedTo); if (isRedmineAssignedToMyTeam || isTMSAssignedtoMyTeam) { //ommit closed tasks if (dbTMSItem.Status.StartsWith("C") || dbTMSItem.Status.StartsWith("c")) { if (itemFromRM.Status == Consts.RM_CLOSED) { //ignore closed in TMS and in RM TMS_TP tp = new TMS_TP(dbTMSItem, itemFromRM); outputList.UpdateDictionary(Consts.RFC_BOTH_CLOSED, tp); } else { TMS_TP tp = new TMS_TP(dbTMSItem, itemFromRM); outputList.UpdateDictionary(Consts.RFC_DIFFERENT_STATUSES, tp); } } else { /*TODO*/ //check if the task is assigned not to my team if (!TeamService.CheckIfSamePersonByTMSLoginAndFullName(dbTMSItem.AssignedTo, itemFromRM.AssignedTo)) { TMS_TP tp = new TMS_TP(dbTMSItem, itemFromRM); outputList.UpdateDictionary(Consts.RFC_ASSIGNED_TO_DIFFERENT_PERSON_IN_RM_AND_TMS, tp); } else { //Console.WriteLine("{0}\nRM: {1}", dbTMSItem, itemFromRM); TMS_TP tp = new TMS_TP(dbTMSItem, itemFromRM); outputList.UpdateDictionary(Consts.RFC_BOTH_OK, tp); } } } } else { if (isRedmineAssignedToMyTeam) { TMS_TP tp = new TMS_TP(null, itemFromRM); //if the problem is not related to client TMS (so its subject does not start with "client") if (itemFromRM.TMS != null && !itemFromRM.TMS.StartsWith(client)) { outputList.UpdateDictionary(Consts.RFC_NOT_CONNECTED_WITH_TMS, tp); //Console.WriteLine("Element not connected with !: {0}", itemFromRM); } else { outputList.UpdateDictionary(Consts.RFC_NOT_EXISTS_IN_TMS, tp); } } } } }