Ejemplo n.º 1
0
        public async Task <ActionResult> Save(EquipmentStateEventViewModel model)
        {
            using (EquipmentStateEventServiceClient client = new EquipmentStateEventServiceClient())
            {
                EquipmentStateEvent obj = new EquipmentStateEvent()
                {
                    Key = Guid.NewGuid().ToString(),
                    EquipmentChangeStateName = model.ChangeStateName,
                    EquipmentCode            = model.EquipmentCode,
                    EquipmentFromStateName   = model.FromStateName,
                    EquipmentToStateName     = model.ToStateName,
                    Description            = model.Description,
                    ReasonCodeCategoryName = model.ReasonCodeCategoryName,
                    ReasonCodeName         = model.ReasonCodeName,
                    IsCurrent  = true,
                    Creator    = User.Identity.Name,
                    CreateTime = DateTime.Now,
                    Editor     = User.Identity.Name,
                    EditTime   = DateTime.Now
                };

                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(EMSResources.StringResource.EquipmentStateEvent_Save_Success
                                                , model.ChangeStateName);
                }
                return(Json(rst));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Save(EquipmentStateEventViewModel model)
        {
            MethodReturnResult rs = new MethodReturnResult();

            try
            {
                DateTime now = DateTime.Now;

                //新增设备事件
                using (EquipmentStateEventServiceClient client = new EquipmentStateEventServiceClient())
                {
                    //设备事件
                    EquipmentStateEvent newEquipmentStateEvent = new EquipmentStateEvent()
                    {
                        Key                      = "",                           //设备事件主键
                        EquipmentCode            = model.EquipmentCode,          //设备代码
                        EquipmentChangeStateName = model.ChangeStateName,        //设备状态切换名称
                        EquipmentFromStateName   = model.FromStateName,          //来源状态
                        EquipmentToStateName     = model.ToStateName,            //目标状态
                        ReasonCodeCategoryName   = model.ReasonCodeCategoryName, //原因类型
                        ReasonCodeName           = model.ReasonCodeName,         //原因代码
                        Description              = model.Description,            //描述
                        IsCurrent                = true,                         //当前状态
                        Creator                  = User.Identity.Name,           //创建人
                        CreateTime               = now,                          //创建时间
                        Editor                   = User.Identity.Name,           //编辑人
                        EditTime                 = now                           //编辑时间
                    };

                    rs = await client.AddAsync(newEquipmentStateEvent);

                    if (rs.Code > 0)
                    {
                        return(Json(rs));
                    }

                    rs.Message = "设备状态设置成功!";

                    return(Json(rs));
                }
            }
            catch (Exception ex)
            {
                rs.Code    = 1000;
                rs.Message = ex.Message;
                rs.Detail  = ex.ToString();

                return(Json(rs));
            }
        }