Beispiel #1
0
        private void btnSureReGoods_Click(object sender, EventArgs e)
        {
            if (listModel.Count <= 0)
            {
                MessageBox.Show("没有可用的数据!");
                return;
            }
            ResponseResultModel responseResult = InvokeWebApiHelper.PostReturnGoodsResult(listModel);

            if (responseResult.IsSuccess)
            {
                listModel.Clear();
                dgvList.Rows.Clear();
                MessageBox.Show(responseResult.Message);
                txtNumber.Text = string.Empty;
                txtWeight.Text = string.Empty;
                txtNumber.Focus();
                this.txtNumber.Text = string.Empty;
                this.txtWeight.Text = null;
                this.lblCount.Text  = this.dgvList.Rows.Count.ToString();
            }
            else
            {
                btnSureReGoods.Enabled = false;
                MessageBox.Show(responseResult.Message);
            }
            i = 1;
        }
        public ResponseResultModel Get(string username, string pwd)
        {
            Log.Information("CreateUser : "******"User logged";
                    response.outcome    = outcome;
                    response.result     = u;
                }
                else
                {
                    outcome.isSuccess   = false;
                    outcome.description = "Unauthorized user.";
                    response.outcome    = outcome;
                }
            }

            return(response);
        }
Beispiel #3
0
        public IActionResult List(UserRequestPayload payload)
        {
            using (_dbContext)
            {
                IQueryable <DncUser> query = _dbContext.DncUser.AsQueryable();
                if (!string.IsNullOrEmpty(payload.Kw))
                {
                    query = query.Where(x => x.LoginName.Contains(payload.Kw.Trim()) || x.DisplayName.Contains(payload.Kw.Trim()));
                }
                if (payload.IsDeleted > CommonEnum.IsDeleted.All)
                {
                    query = query.Where(x => x.IsDeleted == payload.IsDeleted);
                }
                if (payload.Status > UserStatus.All)
                {
                    query = query.Where(x => x.Status == payload.Status);
                }

                if (payload.FirstSort != null)
                {
                    query = query.OrderBy(payload.FirstSort.Field, payload.FirstSort.Direct == "DESC");
                }
                System.Collections.Generic.List <DncUser> list = query.Paged(payload.CurrentPage, payload.PageSize).ToList();
                int totalCount = query.Count();
                System.Collections.Generic.IEnumerable <UserJsonModel> data = list.Select(_mapper.Map <DncUser, UserJsonModel>);
                ResponseResultModel response = ResponseModelFactory.CreateResultInstance;
                response.SetData(data, totalCount);
                return(Ok(response));
            }
        }
        public String Get(String ID)
        {
            Guid incidentID;

            if (String.IsNullOrEmpty(ID) || !Guid.TryParse(ID, out incidentID))
            {
                var model = this.logError("Incident ID was invalid");
                return(this.serialisationService.serialise(model));
            }

            Incident incident;

            if ((incident = this.incidentService.Get(incidentID)) == null)
            {
                var model = this.logError("Incident does not exist");
                return(this.serialisationService.serialise(model));
            }

            var resultModel = new ResponseResultModel()
            {
                Status   = ResponseResultType.OK,
                Message  = "Incident found",
                Response = this.serialisationService.serialise(this.mapper.toDTO(incident))
            };

            return(this.serialisationService.serialise(resultModel));
        }
        public String Save(String serialisedIncident)
        {
            if (String.IsNullOrEmpty(serialisedIncident))
            {
                var model = this.logError("Serialised Incident was null or empty");
                return(this.serialisationService.serialise(model));
            }

            Incident incident;

            if ((incident = this.serialisationService.deserialise <Incident>(serialisedIncident)) == null)
            {
                var model = this.logError("Serialised Incident failed to deserialise");
                return(this.serialisationService.serialise(model));
            }

            if (!this.incidentService.validate(incident))
            {
                var model = this.logError("Incident failed to validation");
                return(this.serialisationService.serialise(model));
            }

            this.logger.info(String.Format("Adding Incident {0} to data store and backlog", incident.ID.ToString()));
            this.incidentService.Save(incident);
            this.incidentBacklogService.add(incident);

            var responseModel = new ResponseResultModel()
            {
                Status  = ResponseResultType.OK,
                Message = "Incident Added"
            };

            return(this.serialisationService.serialise(responseModel));
        }
        ///// <summary>
        ///// Gets data for officer with the identifier
        ///// GET: /Get
        ///// </summary>
        ///// <param name="ID">Identifier.</param>
        public String Get(String ID)
        {
            Guid officerID;

            if (String.IsNullOrEmpty(ID))
            {
                var model = this.logError("Officer: ID was null or Empty");
                return(this.serialisationService.serialise(model));
            }

            if (!Guid.TryParse(ID, out officerID))
            {
                var model = this.logError("Officer: Failed to parse Guid");
                return(this.serialisationService.serialise(model));
            }

            Officer officer = this.officerService.Get(officerID);

            if (officer == null)
            {
                var model = this.logError("Officer: Officer not found");
                return(this.serialisationService.serialise(model));
            }

            var responseResultModel = new ResponseResultModel()
            {
                Status   = ResponseResultType.OK,
                Message  = "Officer Retrieved",
                Response = this.serialisationService.serialise(this.mapper.toDTO(officer))
            };

            return(this.serialisationService.serialise(responseResultModel));
        }
Beispiel #7
0
        //Post: api/lms/PostBatchAddReturnGoods/
        public ResponseResultModel PostBatchAddReturnGoods(List <ReturnGoodsExt> list)
        {
            ResponseResultModel result = new ResponseResultModel()
            {
                IsSuccess = false, Message = "提交失败"
            };

            try
            {
                if (list != null && list.Count > 0)
                {
                    _returnGoodsService.BatchAddReturnGoods(list);
                    result.IsSuccess = true;
                    result.Message   = "提交成功";
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = "数据不可用或没有数据";
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return(result);
        }
        public String Save(String serialisedOfficer)
        {
            if (String.IsNullOrEmpty(serialisedOfficer))
            {
                var model = this.logError("Officer: Officer null or empty");
                return(this.serialisationService.serialise(model));
            }

            var officer = this.serialisationService.deserialise <Officer>(serialisedOfficer);

            if (officer == null)
            {
                var model = this.logError("Officer: Officer is wrong format");
                return(this.serialisationService.serialise(model));
            }

            if (!this.officerService.validate(officer))
            {
                var model = this.logError("Officer: Validation Failed");
                return(this.serialisationService.serialise(model));
            }

            this.logger.debug("Officer: Saved");
            this.officerService.Save(officer);

            var responseModel = new ResponseResultModel()
            {
                Status  = ResponseResultType.OK,
                Message = "Officer: Saved"
            };

            return(this.serialisationService.serialise(responseModel));
        }
Beispiel #9
0
        public IActionResult Logger()
        {
            _logger.LogDebug(message: "LogDebug()...");
            _logger.LogInformation(message: "LogInformation()...");
            _logger.LogWarning(message: "LogWarning()...");
            _logger.LogError(message: "LogError()...");
            ResponseResultModel response = ResponseModelFactory.CreateResultInstance;

            response.SetSuccess(message: "test logger success");
            return(Ok(value: response));
        }
Beispiel #10
0
        /// <summary>
        /// Logs the error and builds a response result model
        /// </summary>
        /// <returns>The response result model</returns>
        /// <param name="message">Message.</param>
        protected ResponseResultModel logError(String message)
        {
            this.logger.warn(message);

            var responseResultModel = new ResponseResultModel()
            {
                Status  = ResponseResultType.ERROR,
                Message = message
            };

            return(responseResultModel);
        }
Beispiel #11
0
        public bool ResponseHasErrors(ResponseResultModel responseResult)
        {
            if (responseResult == null || !responseResult.Errors.Messages.Any())
            {
                return(false);
            }

            foreach (var message in responseResult.Errors.Messages)
            {
                ModelState.AddModelError(string.Empty, message);
            }

            return(true);
        }
        public String SaveOutcome(String serialisedOutcome)
        {
            if (String.IsNullOrEmpty(serialisedOutcome))
            {
                var model = this.logError("Officer Save Outcome: serialised outcome was null or empty");
                return(this.serialisationService.serialise(model));
            }

            IncidentOutcome incidentOutcome;

            if ((incidentOutcome = this.serialisationService.deserialise <IncidentOutcome>(serialisedOutcome)) == null)
            {
                var model = this.logError("Officer Save Outcome: Deserialisation Failed");
                return(this.serialisationService.serialise(model));
            }

            Incident incident;

            if ((incident = this.incidentService.Get(incidentOutcome.Incident.ID)) == null)
            {
                var model = this.logError("Officer Save Outcome: Incident Not Found");
                return(this.serialisationService.serialise(model));
            }

            if (!this.outcomeService.validate(incidentOutcome))
            {
                var model = this.logError("Officer Save Outcome: IncidentOutcome failed validation");
                return(this.serialisationService.serialise(model));
            }

            if (incident.Outcome == null)
            {
                incident.Outcome = new List <IncidentOutcome>();
            }

            incident.Outcome.Add(incidentOutcome);
            this.incidentService.Update(incident);

            this.logger.info(String.Format("Saved Incident Outcome {0} to Incident {1}", incidentOutcome.ID.ToString(), incident.ID.ToString()));

            var responseResultModel = new ResponseResultModel()
            {
                Status  = ResponseResultType.OK,
                Message = "Saved Incident Outcome"
            };

            return(this.serialisationService.serialise <ResponseResultModel>(responseResultModel));
        }
        public String updateLocation(String ID, String serialisedLocation)
        {
            Guid officerID;

            if (String.IsNullOrEmpty(ID) || String.IsNullOrEmpty(serialisedLocation) || !Guid.TryParse(ID, out officerID))
            {
                var model = this.logError("Officer Update Location: invalid parameters");
                return(this.serialisationService.serialise(model));
            }

            Location location = null;

            if ((location = this.serialisationService.deserialise <Location>(serialisedLocation)) == null ||
                !this.locationService.validate(location))
            {
                var model = this.logError("Officer: location failed to serialise or did not validate");
                return(this.serialisationService.serialise(model));
            }

            Officer officer;

            if ((officer = this.officerService.Get(officerID)) == null)
            {
                var model = this.logError("Officer: officer could not be found");
                return(this.serialisationService.serialise(model));
            }

            this.logger.debug(String.Format("Updating Officer {0} location", officer.ID.ToString()));
            officer.Location = location;
            this.officerService.Update(officer);

            var resultReturnModel = new ResponseResultModel()
            {
                Status  = ResponseResultType.OK,
                Message = "Officer: Location Updated"
            };

            return(this.serialisationService.serialise(resultReturnModel));
        }
Beispiel #14
0
        /// <summary>
        /// 获取所有信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ResponseResultModel <UserPageOutput> > GetUserAsync(UserPageInput input)
        {
            ResponseResultModel <UserPageOutput> ReturnObj = new ResponseResultModel <UserPageOutput>()
            {
                ResultStatus = ResponseStatus.OK,
                Data         = new UserPageOutput()
            };

            try
            {
                if (ReturnObj.ResultStatus == ResponseStatus.OK)
                {
                    List <User> list = await _userRepository.GetAllListAsync();

                    if (!string.IsNullOrEmpty(input.Name))
                    {
                        list = list.Where(o => o.RealName.Contains(input.Name)).ToList();
                    }
                    //分页
                    int TotalCount = list.Count;
                    list = list.OrderByDescending(m => m.CreationTime).Take(input.Limit * input.Page).Skip(input.Limit * (input.Page - 1)).ToList();
                    List <UserDto> adminDtos = MapperHelper.ResultData <List <UserDto>, List <User> >(list);

                    UserPageOutput infoOutput = new UserPageOutput()
                    {
                        Data  = adminDtos,
                        Count = TotalCount
                    };
                    ReturnObj.Data = infoOutput;
                }
            }
            catch (Exception ex)
            {
                ReturnObj.ResponseErrorResult(null);
                return(ReturnObj);
            }
            return(ReturnObj.SetData());
        }