2using System.Collections.Generic;
3using System.Threading.Tasks;
22 : base(
"/SetContractState")
26 public override bool HandlesSubPaths =>
false;
27 public override bool UserSessions =>
true;
38 if (!(Obj is Dictionary<string, object> Form))
41 if (!Form.TryGetValue(
"contractId", out Obj) || !(Obj is
string ContractId) ||
42 !Form.TryGetValue(
"state", out Obj) || !(Obj is
string StateStr) ||
48 Dictionary<string, object> Result = await SetState(ContractId, State, User);
50 Response.StatusCode = 200;
56 internal static async Task<Dictionary<string, object>> SetState(
string ContractId,
ContractState State,
IUser User)
65 return new Dictionary<string, object>()
71 DateTime
Now = DateTime.
Now;
74 Contract.State = State;
80 Message =
"Contract deleted.";
85 Message =
"Contract state changed to " + State.ToString() +
".";
91 new KeyValuePair<string, object>(
"State", State));
93 return new Dictionary<string, object>()
95 {
"date",
Now.ToShortDateString() },
96 {
"time",
Now.ToLongTimeString() },
97 {
"type", EventType.Informational },
98 {
"object", ContractId },
99 {
"actor", User.UserName },
100 {
"message", Message },
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
const string DefaultContentType
application/json
Static class managing the application event log. Applications and services log events on this static ...
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
bool HasData
If the request has data.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static async Task Delete(object Object)
Deletes an object in the database.
This filter selects objects that have a named field equal to a given value.
Represents a named semaphore, i.e. an object, identified by a name, that allows single concurrent wri...
Static class of application-wide semaphores that can be used to order access to editable objects.
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...
Now()
Current date and time.
Contains the definition of a contract
byte[] DigitalSignature
Digital Signature
DateTime Timestamp
Timestamp of signature.
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
POST Interface for HTTP resources.
Basic interface for a user.
string UserName
User Name.
ContractState
Recognized contract states