コード例 #1
0
        public static void Init(ApparatusStatus InitialStatus)
        {
            PersonnelCount = InitialStatus.PersonnelCount;
            MedicalLevel   = InitialStatus.MedicalLevel;
            OnDutyTime     = InitialStatus.OnDutyTime.ToUniversalTime();
            OffDutyTime    = InitialStatus.OffDutyTime.ToUniversalTime();
            DutyStatus     = InitialStatus.DutyStatus;
            Post           = InitialStatus.Post;

            NeedsCommit = false;
        }
コード例 #2
0
        private ApparatusStatus ProcessStatus(JToken jStatus)
        {
            ApparatusStatus status = new ApparatusStatus();

            status.MedicalLevel   = jStatus["medicalLevel"].ToString();
            status.PersonnelCount = jStatus["personnelCount"].ToObject <int>();
            status.Post           = jStatus["post"].ToString();
            status.OnDutyTime     = GetDateTimeFromJToken(jStatus["onDutyTime"]);
            status.OffDutyTime    = GetDateTimeFromJToken(jStatus["offDutyTime"]);
            status.DutyStatus     = ConversionHelper.StringToDutyStatus(jStatus["dutyStatus"].ToString());

            return(status);
        }
コード例 #3
0
        private ApparatusStatus GetStatusObject(string JsonStatus)
        {
            var StatusToken = Parse(JsonStatus);

            ApparatusStatus status = new ApparatusStatus();

            status.PersonnelCount = StatusToken["personnelCount"].ToObject <int>();
            status.DutyStatus     = ConversionHelper.StringToDutyStatus(StatusToken["dutyStatus"].ToString());
            status.MedicalLevel   = StatusToken["medicalLevel"].ToString();
            status.OnDutyTime     = DateTime.Parse(StatusToken["onDutyTime"].ToString(), CultureInfo.CurrentCulture, DateTimeStyles.None);
            status.OffDutyTime    = DateTime.Parse(StatusToken["offDutyTime"].ToString(), CultureInfo.CurrentCulture, DateTimeStyles.None);
            status.Post           = StatusToken["post"].ToString();
            status.OOSReason      = StatusToken["oosReason"].ToString();
            return(status);
        }
コード例 #4
0
        /** Update status of indicated apparatus **/
        public async Task <HttpResult> UpdateStatus(int id, ApparatusStatus newStatus)
        {
            EventBus.Dispatch("api.update.vehicle.status.before");

            var encodedStatus = new FormUrlEncodedContent(new[] {
                new KeyValuePair <string, string>("personnel", newStatus.PersonnelCount.ToString()),
                new KeyValuePair <string, string>("level", newStatus.MedicalLevel),
                new KeyValuePair <string, string>("post", newStatus.Post),
                new KeyValuePair <string, string>("offduty", newStatus.OffDutyTime.ToString("yyyy-MM-ddTHH\\:mm\\:sszzz")),
                new KeyValuePair <string, string>("onduty", newStatus.OnDutyTime.ToString("yyyy-MM-ddTHH\\:mm\\:sszzz")),
                new KeyValuePair <string, string>("status", newStatus.DutyStatus == DutyStatus.ON_DUTY ? "onduty" : "offduty")
            });

            var result = await Server.PostAsync(ApiPath + "status/" + id.ToString(), encodedStatus);

            var HttpResponseMessage = await result.Content.ReadAsStringAsync();

            var rObject = JObject.Parse(HttpResponseMessage);

            EventBus.Dispatch("api.update.vehicle.status.after");
            return(rObject["status"].Value <string>() == "ok" ? HttpResult.SUCCESS : HttpResult.FAIL);
        }
コード例 #5
0
 public static void Clear()
 {
     NewApparatusStatus = new ApparatusStatus();
     Apparatus          = default(Apparatus);
     NeedsCommit        = false;
 }