示例#1
0
        public virtual IActionResult SendDutyToAgencies([FromBody] DutyRequest dutyRequest)
        {
            //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(200, default(string));
            //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(400);
            //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(401);
            //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(404);
            string exampleJson = null;

            exampleJson = "";

            var example = exampleJson != null
            ? JsonConvert.DeserializeObject <string>(exampleJson)
            : default(string);

            //TODO: Change the data returned
            return(new ObjectResult(example));
        }
示例#2
0
        /// <summary>
        ///  Immediately forward a request for a duty to be filled by a specific agency. If the request also specifies a worker Identity, this will be a direct booking.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="agencyId">ID of the agency to send the request to.</param>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>Task of ApiResponse (string)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <string> > SendDutyToAgencyAsyncWithHttpInfo(string agencyId, DutyRequest dutyRequest)
        {
            // verify the required parameter 'agencyId' is set
            if (agencyId == null)
            {
                throw new ApiException(400, "Missing required parameter 'agencyId' when calling AgenciesApi->SendDutyToAgency");
            }
            // verify the required parameter 'dutyRequest' is set
            if (dutyRequest == null)
            {
                throw new ApiException(400, "Missing required parameter 'dutyRequest' when calling AgenciesApi->SendDutyToAgency");
            }

            var    localVarPath         = "/agencies/{agencyId}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "text/plain"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (agencyId != null)
            {
                localVarPathParams.Add("agencyId", this.Configuration.ApiClient.ParameterToString(agencyId));                   // path parameter
            }
            if (dutyRequest != null && dutyRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(dutyRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = dutyRequest; // byte array
            }

            // authentication (bearerAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("SendDutyToAgency", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <string>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
                                            (string)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(string))));
        }
示例#3
0
        /// <summary>
        ///  Immediately forward a request for a duty to be filled by a specific agency. If the request also specifies a worker Identity, this will be a direct booking.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="agencyId">ID of the agency to send the request to.</param>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>Task of string</returns>
        public async System.Threading.Tasks.Task <string> SendDutyToAgencyAsync(string agencyId, DutyRequest dutyRequest)
        {
            ApiResponse <string> localVarResponse = await SendDutyToAgencyAsyncWithHttpInfo(agencyId, dutyRequest);

            return(localVarResponse.Data);
        }
示例#4
0
        /// <summary>
        ///  Immediately forward a request for a duty to be filled by a specific agency. If the request also specifies a worker Identity, this will be a direct booking.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="agencyId">ID of the agency to send the request to.</param>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>string</returns>
        public string SendDutyToAgency(string agencyId, DutyRequest dutyRequest)
        {
            ApiResponse <string> localVarResponse = SendDutyToAgencyWithHttpInfo(agencyId, dutyRequest);

            return(localVarResponse.Data);
        }
示例#5
0
        /// <summary>
        ///  Forward a request for a duty to be filled by agency. Dependent upon the rules specified within the VMS, this will cascade to the appropriate agencies.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>string</returns>
        public string SendDutyToAgencies(DutyRequest dutyRequest)
        {
            ApiResponse <string> localVarResponse = SendDutyToAgenciesWithHttpInfo(dutyRequest);

            return(localVarResponse.Data);
        }
示例#6
0
        /// <summary>
        ///  Immediately forward a request for a duty to be filled by a specific agency. If the request also specifies a worker Identity, this will be a direct booking.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="agencyId">ID of the agency to send the request to.</param>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>Task of ApiResponse (string)</returns>
        public async System.Threading.Tasks.Task <ASW.APIServices.VMS.Client.ApiResponse <string> > SendDutyToAgencyAsyncWithHttpInfo(string agencyId, DutyRequest dutyRequest)
        {
            // verify the required parameter 'agencyId' is set
            if (agencyId == null)
            {
                throw new ASW.APIServices.VMS.Client.ApiException(400, "Missing required parameter 'agencyId' when calling AgenciesApi->SendDutyToAgency");
            }

            // verify the required parameter 'dutyRequest' is set
            if (dutyRequest == null)
            {
                throw new ASW.APIServices.VMS.Client.ApiException(400, "Missing required parameter 'dutyRequest' when calling AgenciesApi->SendDutyToAgency");
            }


            ASW.APIServices.VMS.Client.RequestOptions localVarRequestOptions = new ASW.APIServices.VMS.Client.RequestOptions();

            String[] _contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "text/plain"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            if (agencyId != null)
            {
                localVarRequestOptions.PathParameters.Add("agencyId", ASW.APIServices.VMS.Client.ClientUtils.ParameterToString(agencyId)); // path parameter
            }
            localVarRequestOptions.Data = dutyRequest;

            // authentication (bearerAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + ASW.APIServices.VMS.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
            }

            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.PostAsync <string>("/agencies/{agencyId}", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("SendDutyToAgency", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
示例#7
0
 /// <summary>
 ///  Immediately forward a request for a duty to be filled by a specific agency. If the request also specifies a worker Identity, this will be a direct booking.
 /// </summary>
 /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="agencyId">ID of the agency to send the request to.</param>
 /// <param name="dutyRequest">Duty to be sent to agency</param>
 /// <returns>string</returns>
 public string SendDutyToAgency(string agencyId, DutyRequest dutyRequest)
 {
     ASW.APIServices.VMS.Client.ApiResponse <string> localVarResponse = SendDutyToAgencyWithHttpInfo(agencyId, dutyRequest);
     return(localVarResponse.Data);
 }
示例#8
0
        /// <summary>
        ///  Forward a request for a duty to be filled by agency. Dependent upon the rules specified within the VMS, this will cascade to the appropriate agencies.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>Task of string</returns>
        public async System.Threading.Tasks.Task <string> SendDutyToAgenciesAsync(DutyRequest dutyRequest)
        {
            ASW.APIServices.VMS.Client.ApiResponse <string> localVarResponse = await SendDutyToAgenciesAsyncWithHttpInfo(dutyRequest);

            return(localVarResponse.Data);
        }
示例#9
0
        /// <summary>
        ///  Forward a request for a duty to be filled by agency. Dependent upon the rules specified within the VMS, this will cascade to the appropriate agencies.
        /// </summary>
        /// <exception cref="ASW.APIServices.VMS.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="dutyRequest">Duty to be sent to agency</param>
        /// <returns>ApiResponse of string</returns>
        public ASW.APIServices.VMS.Client.ApiResponse <string> SendDutyToAgenciesWithHttpInfo(DutyRequest dutyRequest)
        {
            // verify the required parameter 'dutyRequest' is set
            if (dutyRequest == null)
            {
                throw new ASW.APIServices.VMS.Client.ApiException(400, "Missing required parameter 'dutyRequest' when calling AgenciesApi->SendDutyToAgencies");
            }

            ASW.APIServices.VMS.Client.RequestOptions localVarRequestOptions = new ASW.APIServices.VMS.Client.RequestOptions();

            String[] _contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "text/plain"
            };

            var localVarContentType = ASW.APIServices.VMS.Client.ClientUtils.SelectHeaderContentType(_contentTypes);

            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = ASW.APIServices.VMS.Client.ClientUtils.SelectHeaderAccept(_accepts);

            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            localVarRequestOptions.Data = dutyRequest;

            // authentication (bearerAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + ASW.APIServices.VMS.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
            }

            // make the HTTP request
            var localVarResponse = this.Client.Post <string>("/agencies", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("SendDutyToAgencies", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
示例#10
0
        private Duty GenerateSingleDuty(List <Person> persons, List <DaysOfWeekWeight> daysOfWeekWeights, DutyRequest request, List <ExcludeDates> excludes, List <ChangeOnDateWeigth> changeOnDateWeigths)
        {
            Duty duty = new Duty()
            {
                Date = request.Date
            };
            // for each position:
            Person person;

            for (int i = 0; i < request.Positions.Count; i++)
            {
                // Get all person who cound be in this duty
                person = persons.Where(a => a.Positions.Contains(request.Positions[i]))
                         // Sort that persons
                         .OrderBy(a => a.Score)
                         // Exclude person hwo has exclude in this day
                         .Where(a => !excludes.
                                Where(b => b.DateTimes.
                                      Contains(request.Date)).
                                Select(b => b.Person).
                                Contains(a)).
                         First()
                ;

                //Person can`t be in two or more duty on a single day and it can`t be in a duty two days incommon
                var excludeDatesWithChosenPerson = excludes.Where(a => a.Person.Equals(person));
                if (excludeDatesWithChosenPerson.Count() == 0)
                {
                    excludes.Add(new ExcludeDates(person, new HashSet <DateTime> {
                        request.Date, request.Date.AddDays(1)
                    }));
                }
                else
                {
                    excludeDatesWithChosenPerson.First().DateTimes.Add(request.Date);
                    excludeDatesWithChosenPerson.First().DateTimes.Add(request.Date.AddDays(1));
                }
                // Adding new executer with this person
                duty.Executors.Add(new Executor()
                {
                    Person = person, Position = request.Positions[i]
                });
                //Adding new score to person
                if (changeOnDateWeigths.Select(a => a.ChangedDateTime).Contains(request.Date))
                {
                    person.Score += person.Factor * (request.AdditionalWeight + changeOnDateWeigths.Find(a => a.ChangedDateTime.DayOfWeek.Equals(request.Date.DayOfWeek)).NewWeigth);
                }
                else
                {
                    person.Score += person.Factor * (request.AdditionalWeight + daysOfWeekWeights.Find(a => a.Day.Equals(request.Date.DayOfWeek)).Weight);
                }
                MessageBox.Show(person.Score + "");
            }
            // ret
            return(duty);
        }