public async Task <IActionResult> OnGet(string id, int?sprintId, DateTime?targetDate) { // Validation if (!string.IsNullOrEmpty(id) && userManager.GetUserId(User) != id && !await AllowedToEditTimeTracksOfAnother()) { return(new ChallengeResult()); } var sprint = await sprintsService.GetTargetSprint(sprintId); TimeTrack = new TimeTrack(); if (targetDate.HasValue) { TimeTrack.TrackingDate = targetDate.Value; // If log date is passed, set logging date } else { TimeTrack.TrackingDate = DateTime.Now.AddDays(-1); // Log time fow tomorrow by default } // Set data for creation return(await PopulateDropdownsAndShowPage(id, sprintId)); }
public async Task <IActionResult> OnGetAsync(int timeTrackId) { // Validation TimeTrack = await timeTrackQuery .AsNoTracking() .FirstOrDefaultAsync(t => t.ID == timeTrackId); if (TimeTrack == null) { throw new ApplicationException($"There is no suitable time track with ID={timeTrackId} in database!"); } if (userManager.GetUserId(User) != TimeTrack.OwnerID) { TargetUserId = TimeTrack.OwnerID; if (!await AllowedToEditTimeTracksOfAnother()) { return(new ChallengeResult()); } } // Set data for editing return(await PopulateDropdownsAndShowPage(TimeTrack.OwnerID, TimeTrack.Issue.Sprint?.ID, TimeTrack.IssueID)); }
public async Task <IActionResult> OnPostAsync(string id, int?sprintId) { // Validation if (!string.IsNullOrEmpty(id) && userManager.GetUserId(User) != id && !await AllowedToEditTimeTracksOfAnother()) { return(new ChallengeResult()); } var sprint = await sprintsService.GetTargetSprint(sprintId); if (!ModelState.IsValid) { return(await PopulateDropdownsAndShowPage(id, sprintId, TimeTrack.IssueID)); } Issue targetIssue = await issueService.GetTargetIssue(TimeTrack.IssueID); if (targetIssue == null) { throw new ApplicationException($"There is no suitable issue ID={TimeTrack.IssueID} in database!"); } var targetUserId = string.IsNullOrEmpty(id) ? userManager.GetUserId(User) : id; if (targetIssue.TimeTracks.Any(t => t.OwnerID == targetUserId && t.TrackingDate == TimeTrack.TrackingDate)) { ModelState.AddModelError("TimeTrack.TrackingDate", $"Time for task '{targetIssue.TaskNumber}' is already set for date '{TimeTrack.TrackingDate.ToShortDateString()}'"); return(await PopulateDropdownsAndShowPage(id, sprintId, TimeTrack.IssueID)); } // Create new track var emptyTrack = new TimeTrack(); emptyTrack.OwnerID = targetUserId; if (await TryUpdateModelAsync <TimeTrack>( emptyTrack, "TimeTrack", // Prefix for form value. s => s.IssueID, s => s.SpentHours, s => s.TrackingDate, s => s.Description)) { context.TimeTrack.Add(emptyTrack); await context.SaveChangesAsync(); return(RedirectToPage("./Index", null, new { id = id, sprintId = sprintId })); } ModelState.AddModelError(string.Empty, $"Can't set time for task '{targetIssue.TaskNumber}' for date '{TimeTrack.TrackingDate}'"); return(await PopulateDropdownsAndShowPage(id, sprintId, TimeTrack.IssueID)); }
public void Update() { DbSet <TimeTrack> timeTracksList = intimeDb.TimeTracks; TimeTrack record = (from TimeTrack in timeTracksList where TimeTrack.Id == trackerId select TimeTrack).First(); record.WorkTime += stopwatch.Elapsed.Ticks; intimeDb.SaveChanges(); }
public static string GetStartingTime(Assignment assignment) { int projectId = assignment.ProjectId; int personId = assignment.PersonId; DbSet <TimeTrack> timeTracksList = intimeDb.TimeTracks; DateTime?trackingDate = (from TimeTrack in timeTracksList orderby TimeTrack.Id descending where TimeTrack.ProjectId == projectId where TimeTrack.PersonId == personId select TimeTrack.WorkDate).FirstOrDefault(); startingTime = new TimeSpan(0, 0, 0); if (trackingDate != DateTime.Now.Date) // data non presente in database: nuova data, startingtime = 0 { DateTime newDate = DateTime.Now.Date; TimeTrack newRecord = new TimeTrack(); newRecord.WorkDate = newDate; newRecord.WorkTime = startingTime.Ticks; newRecord.PersonId = personId; newRecord.ProjectId = projectId; intimeDb.TimeTracks.Add(newRecord); intimeDb.SaveChanges(); trackerId = newRecord.Id; } else // data già presente: query sul tempo già tracciato { TimeTrack record = (from TimeTrack in timeTracksList orderby TimeTrack.Id descending where TimeTrack.ProjectId == projectId where TimeTrack.PersonId == personId where TimeTrack.WorkDate == trackingDate select TimeTrack).First(); // tempo relativo alla data 'trackingDate' startingTime = new TimeSpan((long)record.WorkTime); trackerId = record.Id; } return(TimeTracker.ToString(startingTime)); }
/// <summary> /// 初始化窗口 /// </summary> void Initializtion() { int min, sec; timerBind = new TimerBind(); SetClock(); GetInfo(); TimeTrack.Minimum = 0; TimeTrack.Maximum = info.Length; ConvertMin(out min, out sec, info.Length); stream = Bass.BASS_StreamCreateFile(info.Path, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT); LengthBox.Text = min + ":" + sec; Play(); if (Setting.Default.IsTryQuarter) { PositionButton_OnClick(PositionButton, new RoutedEventArgs()); } Binding bind = new Binding(); bind.Source = timerBind; bind.Path = new PropertyPath("Nowtime"); TimeTrack.SetBinding(Slider.ValueProperty, bind); }
static void Main(string[] args) { Issue[] issueList; var query = "Labels=RunGroup"; int argType = 0; int monthOffset = -1; bool verbose = false; foreach (var arg in args) { if (arg == "-q" || arg == "/q") { argType = 1; // Specify query } else if (arg == "-o" || arg == "/o") { argType = 2; // Month offset } else if (arg == "-v" || arg == "/v") { verbose = true; } else if (arg == "-h" || arg == "--help" || arg == "/h" || arg == "/help" || arg == "/?" || arg == "-?") { Console.WriteLine("JWorkLog [-q \"<JIRA query>\"] [-o <month offset>] [-h]\n" + " -q Specifies a JIRA query the same as JIRA's advanced view.\n" + " The default query is Labels=RunGroups.\n" + " -o Specified month offset from current month. Default is -1.\n" + " -h Displays this help page.\n" + " -v Verbose includes query string and other info in output.\n\n" + " Example: JWorkLog -q \"updated>=-8w AND project=HCM AND type=Bug AND component=\\\"GHR- Core HR\\\"\" -o -2 > output.csv"); return; } else if (argType == 1) { query = arg; } else if (argType == 2) { monthOffset = int.Parse(arg); } } if (verbose) { Console.WriteLine($"Query=\"{query}\""); } issueList = GetIssueList(query); if (verbose) { Console.WriteLine($"{issueList.Length} issues queried."); } var startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(monthOffset); var endDate = startDate.AddMonths(1); var hours = new TimeTrack(); Regex reworkexp = new Regex(@"^rework\s*\(\s*(\d+)\s*\)", RegexOptions.IgnoreCase); foreach (var issue in issueList) { if (issue.Fields.Worklog == null) { continue; } foreach (var workEntry in issue.Fields.Worklog.Worklogs) { if (workEntry.Started < startDate || workEntry.Started >= endDate) { continue; } if (!hours.TryGetValue(workEntry.Author.DisplayName, out IssueEntries userIssues)) { hours.Add(workEntry.Author.DisplayName, userIssues = new IssueEntries()); } if (!userIssues.TryGetValue(issue.Key, out IssueEntry issueTimes)) { userIssues.Add(issue.Key, issueTimes = new IssueEntry() { Key = issue.Key, Summary = issue.Fields.Summary, Remarks = issue.Fields.Status.Name, EstimatedTime = TimeSpan.FromSeconds(issue.Fields.Timetracking.OriginalEstimateSeconds.GetValueOrDefault()) }); } var reworkSpec = reworkexp.Match(workEntry.Comment); int reworkCount = 0; bool IsRework = true; if (reworkSpec.Success) { reworkCount = int.Parse(reworkSpec.Groups[1].Captures[0].Value); } else if (workEntry.Comment.StartsWith("rework", StringComparison.InvariantCultureIgnoreCase)) { reworkCount = 1; } else if (workEntry.Comment.IndexOf("rework", StringComparison.InvariantCultureIgnoreCase) >= 0) { } else { IsRework = false; } issueTimes.Add(new TimeEntry() { AddReworks = reworkCount, IsRework = IsRework, Start = workEntry.Started, Length = TimeSpan.FromSeconds(workEntry.TimeSpentSeconds) }); } } Console.WriteLine("Sequence,Developer Name,Deliverable Name,Summary,No. of Peer Review Defects," + "No. of Customer Review Defects,Planned Effort (Hrs.),Actual Effort (Hrs.) in {0}," + "Rework Effort To Fix Peer Review Comments (Hrs.)," + "Rework Effort To Fix Customer Review Comments (Hrs.),Remarks", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(startDate.Month)); int sequence = 0; foreach (var userIssue in hours) { foreach (var issueTime in userIssue.Value) { Console.Write($"{++sequence},{userIssue.Key},{issueTime.Key},{issueTime.Value.Summary}"); TimeEntry normal = new TimeEntry(), rework = new TimeEntry(); int reworkCount = 0; foreach (var entry in issueTime.Value) { if (entry.IsRework) { rework.Length += entry.Length; } else { normal.Length += entry.Length; } reworkCount += entry.AddReworks; } Console.Write($",{reworkCount},0,{issueTime.Value.EstimatedTime.TotalHours}"); Console.Write($",{normal.Length.TotalHours},{rework.Length.TotalHours}"); Console.WriteLine($",0,{issueTime.Value.Remarks}"); } } }
public virtual void CreateFlyParticle() { bool isCreate = false; foreach (SkillEffectData.SkillFlyParticleData flyParticleData in _mSkillDataSlot._skillEffectData._skillFlyParticleList) { if (_mCurrentTrackTime >= flyParticleData._delayTime) { // tzz added for null if (_mSkillUser.U3DGameObject == null) { continue; } // Play fly sound if (null != flyParticleData._skillSound) { Debug.Log("_mSkillUser " + _mSkillUser.U3DGameObject.name + "Sound " + flyParticleData._skillSound._soundName); Globals.Instance.MSoundManager.PlaySoundEffect(flyParticleData._skillSound._soundName); } Vector3 startPosition = _mSkillUser.U3DGameObject.transform.position; // Create multiple missile effects foreach (SkillDataSlot.AttackTargetData attackTargetData in _mSkillDataSlot._attackTargetDataList.Values) { UnityEngine.Object obj = Resources.Load(flyParticleData._particleName); if (null == obj) { isCreate = true; Debug.Log("[Skill]: Cann't find the fly effect name " + flyParticleData._particleName); continue; } // Calculate the Projectile ParticleEffect information GameObject go = GameObject.Instantiate(obj, Vector3.zero, Quaternion.identity) as GameObject; WarshipL target = Globals.Instance.MPlayerManager.GetWarship(attackTargetData._targetID); Vector3 endPosition = target.U3DGameObject.transform.position; float missileHorzSpeed = flyParticleData.speed; float targetHorzSpeed = target.MoveSpeed; if (attackTargetData._moveState == (int)GameData.BattleGameData.MoveState.STOP) { targetHorzSpeed = 0.0f; } MotionTrack motionTrack = null; // Lihaojie 2012.09.26 Add a time track model, solve the problem which caused by the cure skill and damage skill order if (_mSkillDataSlot.IsCureSkill()) { motionTrack = new TimeTrack(GameDefines.BATTLE_STEP_TIME - flyParticleData._delayTime - 0.05f); } else { switch ((EWarshipType)_mSkillUser.Property.WarshipType) { case EWarshipType.CARRIER: { startPosition.y += 50.0f; endPosition.y += 50.0f; // missileHorzSpeed = 150; motionTrack = new AirCraftTrack(startPosition, endPosition, missileHorzSpeed, targetHorzSpeed); break; } case EWarshipType.SUBMARINE: { motionTrack = new LineTrack(startPosition, endPosition, missileHorzSpeed, targetHorzSpeed); break; } case EWarshipType.SURFACE_SHIP: { // Assume the two speed is in x axis float gravityAcceleration = -100.0f; // MotionTrack motionTrack = new ParabolicTrack(startPosition, endPosition, horzSpeed); motionTrack = new ParabolicTrack(startPosition, endPosition, missileHorzSpeed, targetHorzSpeed, gravityAcceleration); break; } } } MissileL missile = new MissileL(go, motionTrack); _mMissileEffectList.Add(missile); _mFlyEffectObjs.Add(go); isCreate = true; _mSkillState = SkillState.FLY; } // End foreach } } _mIsFlyParticleCreated = isCreate; }
public TimeTrackErrorViewModel(TimeTrack timeTrack, string errorMessage) { TimeTrack = timeTrack; ErrorMessage = errorMessage; }