public void IfHasNoItemInfos_ThenHasWillEmpty() { var itemInfos = new ItemInfo[0]; var hash = ItemInfoHelper.GetHash(itemInfos); Assert.That(hash, Is.EqualTo(string.Empty)); }
public void IsHasItemInfos_ThenHashWillEnumerateOrderedItemsInfoHashed() { var itemInfos = new[] { new ItemInfo(0, new[] { 6, 1, 9, 7, 3 }), new ItemInfo(0, new[] { 1, 9, 3, 4 }), new ItemInfo(0, new[] { 9, 4, 3, 2, 6, 7 }), }; var hash = ItemInfoHelper.GetHash(itemInfos); Assert.That(hash, Is.EqualTo("{9;7;6;4;3;2}{9;7;6;3;1}{9;4;3;1}")); }
public void IfItemInfoIsEmpty_ThenHashWillEpmty() { var itemInfo = new ItemInfo(0, new int[0]); var hash = ItemInfoHelper.GetHash(itemInfo); Assert.That(hash, Is.EqualTo("{}")); }
protected virtual void Start() { //oldColor = GetComponent<SpriteRenderer>().color; hpBarPoint = transform.Find("HpBarPoint"); CurrentHp = maxHp; debris = Resources.Load<GameObject>("Prefabs/Debris"); ItemInfoHelper.SetNames(this); }
public void IfHasNoTargetItems_CanCalculateFreeLength() { var sourceItemLenght = 60; var targetItemLenghts = new int[0]; var outputDataItem = new ItemInfo(sourceItemLenght, targetItemLenghts); var actualSurplus = ItemInfoHelper.GetFreeLength(outputDataItem); Assert.That(() => actualSurplus, Is.EqualTo(sourceItemLenght)); }
protected override void Start() { base.Start(); //SetEnglishName("gun"); ItemInfoHelper.SetNames(this); MissionSystem1.UpdateMission("M1"); GetComponent <ZuHu>().zuheDic.Add("boat", "robot"); bulletPrefab = Resources.Load <GameObject>("Bullerts/gun_bullet"); }
protected override Task OnActivateAsync(bool active) { if (active == true) { var targetLayers = MappingModule.ActiveTOC.SelectedLayers; FeatureLayer targetLayer = targetLayers.First() as FeatureLayer; _linearDisplayUnit = DisplayUnitEnvironment.GetEnvironment.DefaultMapLinearUnit; List <Layer> layersToKeep = new List <Layer>(targetLayers.Count); foreach (var item in targetLayers) { layersToKeep.Add(item); } if (GeometryExercisesSolutionModule.Current.HasBeenAdded == false) { string layerTemplatesLocation = String.Empty; DirectoryInfo arcgisProDirectoryInfo = new DirectoryInfo(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName)); layerTemplatesLocation = Path.Combine(arcgisProDirectoryInfo.Parent.FullName, "Resources", "LayerTemplates", "en-US"); IEnumerable <FileInfo> fileInfos = new DirectoryInfo(layerTemplatesLocation).EnumerateFiles(); QueuingTaskFactory.StartNew(async() => { foreach (var templateFileInfo in fileInfos) { ItemInfoValue?packageItemInfo = await ItemInfoHelper.GetItemInfoValueAsync(templateFileInfo.FullName); PackageItem layerPackage = new PackageItem(packageItemInfo.Value); await layerPackage.AddToCurrentMapAsync(null); GeometryExercisesSolutionModule.Current.HasBeenAdded = true; break; } MappingModule.ActiveTOC.ClearSelection(); MappingModule.ActiveTOC.SelectLayers(layersToKeep); }); } } else { System.Diagnostics.Debug.WriteLine(""); } return(base.OnActivateAsync(active)); }
private void InitItemTypeButton() { string[] itemTypes = ItemInfoHelper.GroupByItemType(); if (itemTypeButtonPrefab != null) { foreach (string itemType in itemTypes) { GameObject itemTypeButtonIns = Instantiate(itemTypeButtonPrefab, typeSelectButtonGridTrans); TypeSelectButton itemTypeMark = itemTypeButtonIns.GetComponent <TypeSelectButton>(); if (itemTypeMark == null) { itemTypeMark = itemTypeButtonIns.AddComponent <TypeSelectButton>(); } itemTypeMark.itemType = itemType; itemTypeMark.iconPath = ItemInfoHelper.GetItemTypeIconPath(itemType); itemTypeMark.isChecked = false; } } }
private void StartCalculation() { IsBusy = true; Dictionary <int, int> targetItemCountsByLengths; try { targetItemCountsByLengths = GetTargetItemCountsByLengths(); } catch (Exception e) { ResultsString = $"Ошибка при считывании файла:\r\n\r\n{e.Message}"; IsBusy = false; return; } Task.Run(() => { IList <ItemInfo> itemInfos; try { itemInfos = _surplusCalculator.Calculate(SourceItemLength, targetItemCountsByLengths); } catch (Exception e) { ResultsString = $"Ошибка при расчёте:\r\n\r\n{e.Message}"; IsBusy = false; return; } int count = itemInfos.Count; var resultAsString = itemInfos.Select( (x, i) => $"{ItemInfoHelper.GetHash(x)}. Излишек: {ItemInfoHelper.GetFreeLength(x)}") .Aggregate(string.Empty, (x1, x2) => $"{x1}{Environment.NewLine}{x2}"); WriteResultToFile(itemInfos); ResultsString = $"Вычисления произведены успешно.\r\n\r\nТребуется {count} заготовок.{resultAsString}"; IsBusy = false; }); }
public void IfHasTargetItems_CanCalculateFreeLength() { var sourceItemLenght = 60; var targetItemLenghts = new[] { 10, 8, 14, 6, 1, 4, 3 }; var outputDataItem = new ItemInfo(sourceItemLenght, targetItemLenghts); var actualSurplus = ItemInfoHelper.GetFreeLength(outputDataItem); var expectedSurplus = sourceItemLenght - targetItemLenghts.Sum(); Assert.That(() => actualSurplus, Is.EqualTo(expectedSurplus)); }
private void WriteResultToFile(IList <ItemInfo> itemInfos) { var directoryName = Path.GetDirectoryName(SourceFilePath); if (directoryName == null) { return; } var fileName = Path.GetFileNameWithoutExtension(SourceFilePath); var targetFilePath = Path.Combine(directoryName, $"{fileName}. result {DateTime.Now:yyyy-MM-dd hh-mm-ss}.csv"); using (var csvWriter = new CsvWriter(targetFilePath)) { csvWriter.Write("Всего"); csvWriter.Write("Общие излишки"); csvWriter.AddNewLine(); csvWriter.Write(itemInfos.Count); var totalSurplus = itemInfos.Select(ItemInfoHelper.GetFreeLength) .Sum(); csvWriter.Write(totalSurplus); csvWriter.AddNewLine(); csvWriter.Write("Номер"); csvWriter.Write("Излишки"); csvWriter.AddNewLine(); for (int i = 0; i < itemInfos.Count; i++) { var itemInfo = itemInfos[i]; csvWriter.Write(i + 1); csvWriter.Write(ItemInfoHelper.GetFreeLength(itemInfo)); foreach (var itemLength in itemInfo.TargetItemLengths) { csvWriter.Write(itemLength); } csvWriter.AddNewLine(); } } }
public void IfItemInfoIsNotEmpty_ThenHashWillEnumerateOrderedLengths() { var targetItemLenghts = new[] { 5, 4, 9, 1, 3, 2, 5, 6, 7, }; var itemInfo = new ItemInfo(0, targetItemLenghts); var hash = ItemInfoHelper.GetHash(itemInfo); var orderedLengths = targetItemLenghts.OrderByDescending(x => x); var expectedHash = $"{{{string.Join(";", orderedLengths)}}}"; Assert.That(hash, Is.EqualTo(expectedHash)); }
/// <summary> /// 添加道具信息 /// </summary> /// <param name="newItem">需添加的道具实例</param> public static void FoundItemInfo(Item newItem) { if (newItem == null) { return; } ItemInfo newItemInfo = ItemInfoHelper.GetItemInfo(newItem); string formatToday = FormatToday(); if (DateInfosPairs.ContainsKey(formatToday)) { List <ItemInfo> newItemInfoList = new List <ItemInfo>(DateInfosPairs[formatToday]); if (!newItemInfoList.Contains(newItemInfo)) { newItemInfoList.Add(newItemInfo); DateInfosPairs[formatToday] = newItemInfoList.ToArray(); } } else { ItemInfo[] itemInfos = { newItemInfo }; DateInfosPairs.Add(formatToday, itemInfos); } }
public PlotSet errorBercutWithOther(DateTime startDate, int stepBacklogTime, int stepLeadTime) { #region Запрос номеров таск из TFS, удовлетворяющих запросу var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://tfs.tele2.ru/tfs/Main/Tele2/_apis/wit/wiql?api-version=3.0"); httpWebRequest.Method = "POST"; httpWebRequest.Credentials = new NetworkCredential("user", "password"); httpWebRequest.ContentType = "application/json; charset=utf-8; api-version=3.0"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string ErrorBercutWithOther = "{" + "\"query\":" + "\"" + "select[System.Id], " + "[System.CreatedDate], " + "[Microsoft.VSTS.Common.ActivatedDate], " + "[Microsoft.VSTS.Common.ClosedDate], " + "[System.WorkItemType], " + "[System.Title], " + "[System.State], " + "[System.AreaPath], " + "[System.IterationPath], " + "[System.Tags] from WorkItems where " + "[System.TeamProject] = @project and " + "([System.WorkItemType] = 'Ошибка' and " + "[System.CreatedBy] in " + @"('Гордеев Александр Валериевич <T2RU\\a.gordeev>', " + @"'Муратов Михаил Александрович <T2RU\\mikhail.muratov>', " + @"'Юренков Станислав Сергеевич <T2RU\\supp.Dynamics21>', " + @"'Евланов Сергей Леонидович <T2RU\\sergey.evlanov>', " + @"'Семенов Антон Юрьевич <T2RU\\anton.y.semenov>', " + @"'Кораблёва Екатерина Викторовна <T2RU\\supp.Dynamics11>', " + @"'Иванов Арсений Дмитриевич <T2RU\\Supp.Dynamics02>', " + @"'Анисимов Максим Александрович <T2RU\\supp.Dynamics12>', " + @"'Фокин Андрей Геннадьевич <T2RU\\supp.Dynamics19>', " + @"'Свидэрский Николай Сергеевич <T2RU\\nikolay.svidersky>', " + @"'Панфилова Наталья Геннадьевна <T2RU\\natalya.panfilova>', " + @"'Смирнов Фёдор Леонидович <T2RU\\supp.Dynamics20>', " + @"'Большакова Мария Владимировна <T2RU\\supp.Dynamics17>', " + @"'Чубукина Татьяна Сергеевна <T2RU\\Supp.Dynamics10>', " + @"'Нижников Виталий Сергеевич <T2RU\\vitaly.nizhnikov>', " + @"'Недоступ Александр Николаевич <T2RU\\alexander.nedostup>', " + @"'Курилюк Антон Викторович <T2RU\\anton.kurilyuk>', " + @"'Бондарчук Евгений Маркович <T2RU\\Supp.Dynamics08>', " + @"'Чистяков Максим Сергеевич <T2RU\\supp.Dynamics18>', " + @"'Манукян Ашот Каренович <T2RU\\ashot.manukyan>', " + @"'Моисеева Ольга Алексеевна <T2RU\\supp.DSuite29>', " + @"'Струнников Артем Сергеевич <T2RU\\supp.bercut120>', " + @"'Калашников Дмитрий Юрьевич <T2RU\\dmitry.y.kalashnikov>', " + @"'Полях Виктор Васильевич <T2RU\\victor.polyakh>', " + @"'Глушков Сергей Иванович <T2RU\\Supp.Dynamics05>', " + @"'Остапенко Сергей Сергеевич <T2RU\\sergey.ostapenko>', " + @"'Жиряков Дмитрий Владимирович <T2RU\\supp.Dynamics15>', " + @"'Тришечкин Евгений Владимирович <T2RU\\Supp.Dynamics06>', " + @"'Хромина Ольга Анатольевна <T2RU\\olga.khromina>', " + @"'Арсеньева Юлия Андреевна <T2RU\\supp.Dynamics16>', " + @"'Артюков Иван Алексеевич <T2RU\\Supp.Dynamics03>', " + @"'Сибакова Евгения Александровна <T2RU\\evgenia.sibakova>', " + @"'Хрупин Дмитрий Владимирович <T2RU\\dmitry.khrupin>', " + @"'Сологуб Николай Сергеевич <T2RU\\Supp.Dynamics24>') and " + @"[System.AreaPath] in ('Tele2\\Партнеры\\Беркут\\Product testing') and " + "[System.Reason] <> 'Не является ошибкой' and " + "[System.Reason] <> 'Отклонена' and " + "not [System.Tags] contains 'Техническое' and " + "[System.Tags] contains 'Other' or " + "([System.WorkItemType] = 'Ошибка' and " + @"[System.AreaPath] = 'Tele2\\CRM\\CRM Team Bercut' and " + "[System.Reason] <> 'Отклонена' and " + "[System.Reason] <> 'Не является ошибкой' and " + "[System.Tags] contains 'Other' and " + "not [System.Tags] contains 'Техническое')) " + "order by[Microsoft.VSTS.Common.ClosedDate] " + "\"" + "}"; streamWriter.Write(ErrorBercutWithOther); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); dynamic resultOfQuery; using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { resultOfQuery = streamReader.ReadToEnd(); } Report result = JsonConvert.DeserializeObject <Report>(resultOfQuery); #endregion FinalResult FINAL = new FinalResult(); FINAL.resultItems = new List <ResultItem>(); ResultItem finalResult = new ResultItem(); ItemInfoHelper itemInfoHelper = new ItemInfoHelper(); FINAL.resultItems = itemInfoHelper.getItemInfo(finalResult, result, FINAL); //Считаем LeadTime и BackLogTime для каждой таски foreach (ResultItem i in FINAL.resultItems) { if (i.value[0].fields.ActivatedDate != null && i.value[0].fields.CreatedDate != null) { i.value[0].backlogTime = (int)(DateTime.Parse(i.value[0].fields.ActivatedDate) - DateTime.Parse(i.value[0].fields.CreatedDate)).TotalDays; } if (i.value[0].fields.ClosedDate != null && i.value[0].fields.ActivatedDate != null) { i.value[0].leadTime = (int)(DateTime.Parse(i.value[0].fields.ClosedDate) - DateTime.Parse(i.value[0].fields.ActivatedDate)).TotalDays; } } TaskReportHelper taskReportHelper = new TaskReportHelper(); BacklogReportHelper backlogReportHelper = new BacklogReportHelper(); LeadReportHelper leadReportHelper = new LeadReportHelper(); PlotSet plotResult = new PlotSet(); plotResult.PlotList = new List <PlotData>(); plotResult.PlotList.Add(taskReportHelper.formTaskReport(FINAL, startDate)); plotResult.PlotList.Add(backlogReportHelper.fromBacklogReport(FINAL, stepBacklogTime, startDate)); plotResult.PlotList.Add(leadReportHelper.formLeadReport(FINAL, stepLeadTime, startDate)); return(plotResult); }
public PlotSet teamAS(DateTime startDate, int stepBacklogTime, int stepLeadTime) { #region Запрос номеров таск из TFS, удовлетворяющих запросу var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://tfs.tele2.ru/tfs/Main/Tele2/_apis/wit/wiql?api-version=3.0"); httpWebRequest.Method = "POST"; httpWebRequest.Credentials = new NetworkCredential("user", "password"); httpWebRequest.ContentType = "application/json; charset=utf-8; api-version=3.0"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string jsonTeamAS = "{" + "\"query\":" + "\"" + "SELECT[System.Id], " + "[System.CreatedDate], " + "[Microsoft.VSTS.Common.ActivatedDate], " + "[Microsoft.VSTS.Common.ClosedDate], " + "[System.State], " + "[System.IterationPath], " + "[System.WorkItemType], " + "[System.Title], " + "[System.AssignedTo], " + "[System.AreaPath], " + "[System.Tags] " + "FROM WorkItems WHERE[System.TeamProject] = @project and " + "[System.WorkItemType] = 'Требование' and " + @"[System.AreaPath] under 'Tele2\\CRM' and " + @"([System.AreaPath] = 'Tele2\\CRM\\CRM Team A' or " + @"[System.AreaPath] = 'Tele2\\CRM\\CRM Support') and " + @"not [System.IterationPath] under 'Tele2\\Партнеры\\CRM\\АРМ Troubleshooting' and " + @"[System.IterationPath] <> 'Tele2\\Партнеры\\CRM\\Отклоненные' and " + "not [System.Tags] contains 'Интеграция' and not[System.Tags] contains 'Биллинг' and " + "[System.State] <> 'New' and " + "not [System.Tags] contains 'Техническое' and " + "not [System.Tags] contains 'Без разработки' and " + "not [System.Tags] contains 'Орг вопросы' and " + "not [System.Tags] contains 'HLR' and " + "not [System.Tags] contains 'Trash' and " + "[System.Reason] <> 'Отклонено' and " + "not [System.Reason] contains 'Пропала необходимость' " + "ORDER BY [Microsoft.VSTS.Common.ClosedDate] " + "\"" + "}"; streamWriter.Write(jsonTeamAS); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); dynamic resultOfQuery; using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { resultOfQuery = streamReader.ReadToEnd(); } Report result = JsonConvert.DeserializeObject <Report>(resultOfQuery); #endregion FinalResult FINAL = new FinalResult(); FINAL.resultItems = new List <ResultItem>(); ResultItem finalResult = new ResultItem(); ItemInfoHelper itemInfoHelper = new ItemInfoHelper(); FINAL.resultItems = itemInfoHelper.getItemInfo(finalResult, result, FINAL); //Считаем LeadTime и BackLogTime для каждой таски foreach (ResultItem i in FINAL.resultItems) { if (i.value[0].fields.ActivatedDate != null && i.value[0].fields.CreatedDate != null) { i.value[0].fields.CreatedDate = i.value[0].fields.CreatedDate.Substring(0, 10); i.value[0].fields.ActivatedDate = i.value[0].fields.ActivatedDate.Substring(0, 10); i.value[0].backlogTime = (int)(DateTime.Parse(i.value[0].fields.ActivatedDate) - DateTime.Parse(i.value[0].fields.CreatedDate)).TotalDays; } if (i.value[0].fields.ClosedDate != null && i.value[0].fields.ActivatedDate != null) { i.value[0].fields.ActivatedDate = i.value[0].fields.ActivatedDate.Substring(0, 10); i.value[0].fields.ClosedDate = i.value[0].fields.ClosedDate.Substring(0, 10); i.value[0].leadTime = (int)(DateTime.Parse(i.value[0].fields.ClosedDate) - DateTime.Parse(i.value[0].fields.ActivatedDate)).TotalDays; } } TaskReportHelper taskReportHelper = new TaskReportHelper(); BacklogReportHelper backlogReportHelper = new BacklogReportHelper(); LeadReportHelper leadReportHelper = new LeadReportHelper(); PlotSet plotResult = new PlotSet(); plotResult.PlotList = new List <PlotData>(); plotResult.PlotList.Add(taskReportHelper.formTaskReport(FINAL, startDate)); plotResult.PlotList.Add(backlogReportHelper.fromBacklogReport(FINAL, stepBacklogTime, startDate)); plotResult.PlotList.Add(leadReportHelper.formLeadReport(FINAL, stepLeadTime, startDate)); return(plotResult); }
public PlotSet allTeam(DateTime startDate, int stepBacklogTime, int stepLeadTime) { #region Запрос номеров таск из TFS, удовлетворяющих запросу var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://tfs.tele2.ru/tfs/Main/Tele2/_apis/wit/wiql?api-version=3.0"); httpWebRequest.Method = "POST"; httpWebRequest.Credentials = new NetworkCredential("victor.polyakh", "Zxcvbn123$"); httpWebRequest.ContentType = "application/json; charset=utf-8; api-version=3.0"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string jsonAllTeam = "{" + "\"query\":" + "\"" + "select[System.Id], " + "[System.AssignedTo], " + "[System.Title], " + "[System.State], " + "[System.AreaPath], " + "[System.IterationPath], " + "[System.Tags], " + "[System.CreatedDate], " + "[Microsoft.VSTS.Common.ActivatedDate], " + "[Microsoft.VSTS.Common.ClosedDate], " + "[Microsoft.VSTS.Scheduling.Size] " + "from WorkItems where " + "[System.TeamProject] = @project and " + "[System.WorkItemType] = 'Требование' and " + @"([System.AreaPath] = 'Tele2\\CRM\\CRM Team DoC' or " + @"[System.AreaPath] = 'Tele2\\CRM\\CRM Team A' or " + @"[System.AreaPath] = 'Tele2\\CRM\\CRM Team B' or " + @"[System.AreaPath] = 'Tele2\\CRM\\CRM Support') and " + "[System.State] = 'Closed' and " + "[System.Reason] <> 'Отклонено' and " + "not [System.Tags] contains 'Техническое' and " + "not [System.Tags] contains 'Орг вопросы' and " + "not [System.Tags] contains 'Backend' and " + "not [System.Reason] contains 'Пропала необходимость' " + "order by [Microsoft.VSTS.Common.ClosedDate]" + "\"" + "}"; streamWriter.Write(jsonAllTeam); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); dynamic resultOfQuery; using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { resultOfQuery = streamReader.ReadToEnd(); } Report result = JsonConvert.DeserializeObject <Report>(resultOfQuery); #endregion FinalResult FINAL = new FinalResult(); FINAL.resultItems = new List <ResultItem>(); ResultItem finalResult = new ResultItem(); ItemInfoHelper itemInfoHelper = new ItemInfoHelper(); FINAL.resultItems = itemInfoHelper.getItemInfo(finalResult, result, FINAL); //Считаем LeadTime и BackLogTime для каждой таски foreach (ResultItem i in FINAL.resultItems) { if (i.value[0].fields.ActivatedDate != null && i.value[0].fields.CreatedDate != null) { i.value[0].backlogTime = (int)(DateTime.Parse(i.value[0].fields.ActivatedDate) - DateTime.Parse(i.value[0].fields.CreatedDate)).TotalDays; } if (i.value[0].fields.ClosedDate != null && i.value[0].fields.ActivatedDate != null) { i.value[0].leadTime = (int)(DateTime.Parse(i.value[0].fields.ClosedDate) - DateTime.Parse(i.value[0].fields.ActivatedDate)).TotalDays; } } TaskReportHelper taskReportHelper = new TaskReportHelper(); BacklogReportHelper backlogReportHelper = new BacklogReportHelper(); LeadReportHelper leadReportHelper = new LeadReportHelper(); PlotSet plotResult = new PlotSet(); plotResult.PlotList = new List <PlotData>(); plotResult.PlotList.Add(taskReportHelper.formTaskReport(FINAL, startDate)); plotResult.PlotList.Add(backlogReportHelper.fromBacklogReport(FINAL, stepBacklogTime, startDate)); plotResult.PlotList.Add(leadReportHelper.formLeadReport(FINAL, stepLeadTime, startDate)); return(plotResult); }