Beispiel #1
0
        public ReturnInfo Addteam(string name, string dealman)
        {
            //验证
            ReturnInfo    rInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();

            try
            {
                var assbo = new cmdb_team
                {
                    name = name
                };
                _unitOfWork.RegisterNew(assbo);

                var pr = new cmdb_modityhistory
                {
                    username = dealman,
                    m_time   = DateTime.Now,
                    //content = HttpUtility.UrlEncode("添加--->团队" + "--->" + name, Encoding.UTF8),
                    content = "添加--->团队" + "--->" + name,
                };
                _unitOfWork.RegisterNew(pr);

                bool result = _unitOfWork.Commit();
                rInfo.IsSuccess = result;
                rInfo.ErrorInfo = sb.ToString();
                return(rInfo);
            }
            catch (Exception ex)
            {
                _unitOfWork.Rollback();
                sb.Append(ex.Message);
                rInfo.IsSuccess = false;
                rInfo.ErrorInfo = sb.ToString();
                return(rInfo);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新资产信息
        /// </summary>
        /// <param name="entity">资产信息</param>
        /// <returns></returns>
        public ReturnInfo UpdateAssets(AssetsInputDto entity, string username)
        {
            ReturnInfo    RInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();

            //产生资产编号
            //string ValidateInfo = Helper.BasicValidate(entity).ToString();
            //sb.Append(ValidateInfo);
            if (sb.Length == 0)
            {
                try
                {
                    cmdb_asset assets = _AssetsRepository.GetByID(entity.SN).AsNoTracking().FirstOrDefault();
                    //var originAss = Mapper.Map<cmdb_asset, AssetsOutputDto>(assets);
                    if (assets != null)
                    {
                        //assets.id = entity.id;
                        assets.uuid         = entity.uuid;
                        assets.IP           = entity.IP;
                        assets.sn           = entity.SN;
                        assets.asset_number = entity.asset_number;
                        assets.position     = entity.Position;
                        assets.status       = (short)entity.Status;

                        //assets.give_time = entity.BorrowDate;
                        //assets.return_time = entity.BorrowDate;

                        if (entity.give_time.HasValue)
                        {
                            assets.give_time = entity.give_time;
                        }
                        else
                        {
                            assets.give_time = null;
                        }

                        if (entity.return_time.HasValue)
                        {
                            assets.return_time = entity.return_time;
                        }
                        else
                        {
                            assets.return_time = null;
                        }


                        assets.remark = entity.remark;

                        assets.modify_date     = DateTime.Now;
                        assets.asset_type_id   = entity.asset_type_id;
                        assets.brand_id        = entity.brand_id;
                        assets.machine_room_id = entity.machine_room_id;
                        assets.pay_man_id      = entity.pay_man_id;
                        assets.project_id      = entity.project_id;
                        assets.role_id         = entity.role_id;
                        assets.team_id         = entity.team_id;
                        assets.use_man_id      = entity.use_man_id;

                        _unitOfWork.RegisterDirty(assets);
                    }

                    cmdb_assettype type      = _assetsTypeRepository.GetByID(entity.asset_type_id).AsNoTracking().FirstOrDefault();
                    string         type_name = type.name;
                    var            pr        = new cmdb_modityhistory
                    {
                        username = username,
                        m_time   = DateTime.Now,
                        content  = "修改--> 资产-->" + type_name + "--> 唯一号:" + assets.uuid,
                    };
                    _unitOfWork.RegisterNew(pr);

                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = sb.ToString();

                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 添加资产
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ReturnInfo AddAssets(AssetsInputDto entity, string dealman)
        {
            ReturnInfo    RInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();
            //if (entity.id == 0)
            //{
            //    int MaxId = _AssetsRepository.GetMaxID();
            //    int id = MaxId + 1;
            //    //string AssId = Helper.GenerateID("ASS", MaxId);
            //    //产生资产编号
            //    entity.id = id;
            //}

            string ValidateInfo = Helper.ValidateAssets(entity).ToString();

            sb.Append(ValidateInfo);
            if (sb.Length == 0)
            {
                try
                {
                    cmdb_asset assets = Mapper.Map <AssetsInputDto, cmdb_asset>(entity);
                    //Console.WriteLine(assets.IP);
                    //Console.WriteLine(assets.asset_number);
                    //Console.WriteLine(assets.sn);
                    //Console.WriteLine(assets.position);
                    //Console.WriteLine(assets.status);
                    //Console.WriteLine(assets.give_time);
                    //Console.WriteLine(assets.return_time);
                    //Console.WriteLine(assets.remark);
                    //Console.WriteLine(assets.asset_type_id);

                    //Console.WriteLine(assets.brand_id);
                    //Console.WriteLine(assets.machine_room_id);
                    //Console.WriteLine(assets.pay_man_id);
                    //Console.WriteLine(assets.project_id);
                    //Console.WriteLine(assets.role_id);
                    //Console.WriteLine(assets.use_man_id);
                    //Console.WriteLine(assets.team_id);
                    //Console.WriteLine(assets.modify_date);

                    //assets.status = (int)status.闲置;
                    //assets.MODIFYDATE=DateTime.Now;
                    _unitOfWork.RegisterNew(assets);

                    cmdb_assettype type      = _assetsTypeRepository.GetByID(entity.asset_type_id).AsNoTracking().FirstOrDefault();
                    string         type_name = type.name;

                    var pr = new cmdb_modityhistory
                    {
                        username = dealman,
                        m_time   = DateTime.Now,
                        content  = "添加--> 资产-->" + type_name + "--> 唯一号:" + assets.uuid,
                    };
                    _unitOfWork.RegisterNew(pr);

                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = entity.uuid;
                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }