Exemplo n.º 1
0
        public static (IList <BehaviourIncident>, int startRow) ReadUnresolved(ValueRange valueRange, IList <PropertyInfo> columns, int startRow)
        {
            var unresolvedIncidents = new List <BehaviourIncident>();
            var newStartRow         = startRow;

            for (var r = 1; r < valueRange.Values.Count; r++) // Skip first row because we fetched (startRow - 1)
            {
                var row      = valueRange.Values[r];
                var incident = new BehaviourIncident {
                    SpreadsheetRow = startRow + r
                };
                for (var c = 0; c < row.Count; c++)
                {
                    if (c >= columns.Count || columns[c] == null)
                    {
                        continue;
                    }
                    columns[c].SetValue(incident, PropertyMapper.InterpretValue(row[c].ToString(), columns[c].PropertyType));
                }
                if (incident.Status != Status.Resolved)
                {
                    unresolvedIncidents.Add(incident);
                }
                if (incident.Status == Status.Resolved || incident.Status == Status.Escalate)
                {
                    newStartRow++;
                }
            }
            return(unresolvedIncidents, newStartRow);
        }
Exemplo n.º 2
0
        private async Task AddDetentionAsync(BehaviourIncident incident)
        {
            var ev = new Event()
            {
                Summary = DETENTION_TITLE,
                Start   = new EventDateTime()
                {
                    DateTimeRaw = ConvertToDateTimeRaw(incident.DetentionDate.Value.Add(DetentionStart))
                },
                End = new EventDateTime()
                {
                    DateTimeRaw = ConvertToDateTimeRaw(incident.DetentionDate.Value.Add(DetentionEnd))
                },
                Description = $"Reason: {incident.Incident}\nIncident date: {incident.Date.ToString("d/M/yyyy")} {incident.Period}\nSubject: {incident.Subject}\nStaff: {incident.Staff}",
                Reminders   = new Event.RemindersData
                {
                    UseDefault = false,
                    Overrides  = new List <EventReminder> {
                        new EventReminder {
                            Minutes = 10,
                            Method  = NOTIFY_POPUP
                        }
                    }
                },
                ColorId = COLOUR_RED
            };

            await Service.Events.Insert(ev, PRIMARY_CALENDAR).ExecuteAsync();
        }
Exemplo n.º 3
0
        private static string ReplaceTemplateFields(string template, BehaviourIncident incident)
        {
            var rtn = template;

            foreach (var property in typeof(BehaviourIncident).GetProperties())
            {
                rtn = rtn.Replace($"{{{{{property.Name}}}}}", PropertyMapper.DisplayValue(property.GetValue(incident), property.Name, true)?.ToString() ?? string.Empty);
            }
            return(rtn.Replace("\n", "<br />"));
        }