Exemplo n.º 1
0
        public async Task <DataRes <bool> > EditAsync([FromBody] ResPermission model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };
            var sid = this.User.FindFirst(ClaimTypes.Sid);

            model.WriteDate = DateTime.Now;
            model.WriteUid  = Convert.ToInt32(sid.Value);
            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResPermission>();
                try
                {
                    model = repository.Update(model);
                    int i = await uow.SaveChangesAsync();

                    if (i < 0)
                    {
                        res.code = ResCode.Error;
                        res.data = false;
                        res.msg  = "保存失败";
                    }
                }
                catch (Exception ex)
                {
                    res.code = ResCode.Error;
                    res.data = false;
                    res.msg  = "保存失败," + ex.Message;
                }

                return(res);
            }
        }
Exemplo n.º 2
0
        public async Task <DataRes <bool> > DeleteAsync(int id)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResPermission>();
                var model      = await repository.GetAsync(id);

                var sid = this.User.FindFirst(ClaimTypes.Sid);
                model.WriteDate = DateTime.Now;
                model.WriteUid  = Convert.ToInt32(sid.Value);
                model.StopFlag  = true;
                model           = repository.Update(model);
                int i = await uow.SaveChangesAsync();

                if (i < 0)
                {
                    res.code = ResCode.Error;
                    res.data = false;
                    res.msg  = "删除失败";
                }

                return(res);
            }
        }
Exemplo n.º 3
0
        public DataRes <bool> SavePermissions(int id, [FromBody] List <int> permissionIds)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            List <ResRolePermission> list = new List <ResRolePermission>();

            permissionIds.ForEach(p => { list.Add(new ResRolePermission()
                {
                    RoleId = id, PermissionId = p
                }); });
            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResRole>(); try
                {
                    var role = repository.Get(id, x => x.Include(p => p.ResRolePermissions));
                    role.ResRolePermissions = list;
                    repository.UpdateWithNavigationProperties(role);
                    uow.SaveChanges();
                }
                catch (Exception ex)
                {
                    res.code = ResCode.Error;
                    res.data = false;
                    res.msg  = "保存失败,失败原因:" + ex.Message;
                }

                return(res);
            }
        }
Exemplo n.º 4
0
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
        {
            var    reqTask    = request.Content.ReadAsStringAsync();
            string reqContent = reqTask.Result;
            var    task       = new Task <HttpResponseMessage>(() =>
            {
                var resMsg       = new HttpResponseMessage();
                string dateStamp = GetTimeStamp();

                CommonReq crq = new CommonReq
                {
                    timestamp    = dateStamp,
                    version      = "1.0",
                    method       = TypesModel.Operation.ArticleCrawl.ToString(),
                    requesttoken = Guid.NewGuid().ToString()
                };
                DataRes dr = new DataRes
                {
                    result_code = "1",
                    result_msg  = "success"
                };
                crq.data        = JsonConvert.SerializeObject(dr);
                var sendContent = JsonConvert.SerializeObject(crq);
                resMsg.Content  = new StringContent(sendContent, System.Text.Encoding.UTF8, "application/json");
                return(resMsg);
            });

            task.Start();
            Console.WriteLine("------------------------------------------------------------------------");
            Console.WriteLine(reqContent);
            return(task);
        }
Exemplo n.º 5
0
        public virtual async Task <ActionResult <DataRes <TEntity> > > Get([FromBody] IdentityReq req)
        {
            DataRes <TEntity> res = new DataRes <TEntity>()
            {
                code = ResCode.Success
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                bool cp = await CheckPermission("Read", uow);

                if (cp)
                {
                    try
                    {
                        var repository = uow.GetRepository <TEntity>();
                        var models     = await repository.NGetAsync(req.Id, req.navPropertyPaths);

                        res.data = models;
                        return(res);
                    }
                    catch (Exception ex)
                    {
                        res.code = ResCode.ServerError;
                        res.msg  = ex.Message;
                        return(res);
                    }
                }
                else
                {
                    return(Unauthorized());
                }
            }
        }
Exemplo n.º 6
0
        public virtual async Task <ActionResult <DataRes <List <TEntity> > > > GetList(NavigateOrderReq req)
        {
            var result = new DataRes <List <TEntity> >()
            {
                code = ResCode.Success
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                try
                {
                    OrderBy <TEntity> order = null;
                    if (req.order != null)
                    {
                        order = new OrderBy <TEntity>(req.order.columnName, req.order.reverse);
                    }
                    var repository = uow.GetRepository <TEntity>();
                    var models     = await repository.NGetAllAsync(order != null?order.Expression : null, req.navPropertyPaths);

                    result.data = models.ToList();

                    return(result);
                }
                catch (Exception ex)
                {
                    result.code = ResCode.ServerError;
                    result.msg  = ex.Message;
                    return(result);
                }
            }
        }
Exemplo n.º 7
0
        public DataRes <bool> Resume(int id)
        {
            var res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResSchedule>();
                //根据任务编号获取任务详情
                var model = repository.Get(id);
                //恢复指定任务
                var result = QuartzHelper.ResumeScheduleAsync(model);
                if (result.Result.Code == 1000)
                {
                    model.JobStatus = 1;
                    model.WriteDate = DateTime.Now;
                    var t10 = repository.Update(model);
                    res.msg = result.Result.Msg;
                    logger.Info($"任务已恢复:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
                else
                {
                    res.code = ResCode.Error;
                    res.msg  = result.Result.Msg;
                    logger.Error($"任务恢复异常:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
            }
            return(res);
        }
Exemplo n.º 8
0
        public DataRes <bool> DeleteSchedule(int id)
        {
            var res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResSchedule>();
                //根据任务编号获取任务详情
                var model = repository.Get(id);
                //恢复指定任务
                var result = QuartzHelper.StopScheduleAsync(model);
                if (result.Result.Code == 1000)
                {
                    repository.Remove(model);
                    res.msg = result.Result.Msg;
                    logger.Info($"任务已删除:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
                else
                {
                    res.code = ResCode.Error;
                    res.msg  = result.Result.Msg;
                    logger.Error($"任务停止异常,删除失败:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
            }
            return(res);
        }
Exemplo n.º 9
0
        public DataRes <bool> EditCourse([FromBody] Pub_course model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            if (model.id == 0)
            {
                res.code = ResCode.Error;
                res.data = false;
                res.msg  = "参数错误";
                return(res);
            }
            var preModel = courseBll.Get(model.id);

            //用来遍历model
            preModel = GetUpdateModel <Pub_course>(model, preModel);

            var r = courseBll.Edit(preModel);

            if (!r.Item1)
            {
                res.code = ResCode.Error;
                res.data = false;
                res.msg  = "修改失败";
            }
            return(res);
        }
Exemplo n.º 10
0
        public DataRes <bool> Edit([FromBody] ResSchedule model)
        {
            var res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            try
            {
                using (var uow = _uowProvider.CreateUnitOfWork())
                {
                    var    repository = uow.GetRepository <ResSchedule>();
                    string us         = User.Claims.FirstOrDefault(p => p.Type.Equals(ClaimTypes.Sid)).Value;
                    int    userid     = Convert.ToInt32(us);
                    model.WriteUid  = userid;
                    model.WriteDate = DateTime.Now;
                    repository.Update(model);
                    uow.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                res.code = ResCode.Error;
                res.msg  = $"{ex.Message}:{ex.InnerException.Message}";
            }
            return(res);
        }
Exemplo n.º 11
0
        public ActionResult <DataRes <ECAsn> > GetAnsDetail(int id)
        {
            var res = new DataRes <ECAsn>()
            {
                code = ResCode.Success
            };

            try
            {
                using (var uow = _uowProvider.CreateUnitOfWork())
                {
                    var repository    = uow.GetRepository <BnsOmsReceivingCodeRecord>();
                    var ansRepository = uow.GetRepository <ECAsn>();
                    BnsOmsReceivingCodeRecord model = repository.Get(id);
                    var ansModel = ansRepository.Query(x => x.ReceiveCode == model.OmsReceivingCode, null,
                                                       x => x.Include(a => a.Items)
                                                       .Include(a => a.ReceivingCost))
                                   .FirstOrDefault();
                    res.data = ansModel;
                    if (ansModel == null)
                    {
                        res.code = ResCode.NotFound;
                        res.msg  = "此Id数据还未拉取";
                    }
                }
            }
            catch (Exception ex)
            {
                res.code = ResCode.ServerError;
                res.msg  = ex.Message;
            }
            return(res);
        }
Exemplo n.º 12
0
        public ActionResult <DataRes <List <SingleProductSell> > > GetList(OrderReq req)
        {
            var res = new DataRes <List <SingleProductSell> >()
            {
                code = ResCode.Success
            };

            if (req != null)
            {
                using (var uow = _uowProvider.CreateUnitOfWork())
                {
                    string sql = "select x.Plateform,x.UserAccount,x.SaleOrderCode," +
                                 "x.ShippingMethodPlatform, x.ShippingMethod, x.WarehouseCode," +
                                 "x.DatePaidPlatform, x.PlatformShipTime, x.DateLatestShip, x.Currency," +
                                 "x.CountryCode, ProductCount,a.ProductSku, a.Qty,c.pcrProductSku SubProductSku," +
                                 " a.Qty * c.PcrQuantity SubQty, b.WarehouseId " +
                                 "from EC_SalesOrder x join EC_SalesOrderDetail a on x.OrderId = a.OrderId " +
                                 "join EC_SkuRelation b on a.ProductSku = b.ProductSku " +
                                 "join EC_SkuRelationItems c on b.relationid = c.relationid " +
                                 "order by x.SaleOrderCode";
                    var    repository = uow.GetRepository <SingleProductSell>();
                    string orderStr   = req.order + (req.order.reverse ? " desc" : "");
                    res.data = repository.ListFromSql(sql, FilterNode.ListToString(req.query), orderStr).ToList();
                }
            }
            else
            {
                res.code = ResCode.NoValidate;
                res.msg  = ResMsg.ParameterIsNull;
            }
            return(res);
        }
Exemplo n.º 13
0
        public DataRes <List <Menu> > GetMenu()
        {
            List <Menu> menus = new List <Menu>();

            DataRes <List <Menu> > res = new DataRes <List <Menu> >()
            {
                code = ResCode.Success, data = menus
            };
            // List<Pub_Function> functions= bll.GetMenu(User.GetZXYLUser().UserCode);
            List <Pub_Function> functions     = bll.GetMenu(User.GetZXYLUser().UserCode);
            List <Pub_Function> functionsRoot = functions.Where(p => p.FunctionCode.Length == 5).ToList();

            foreach (var item in functionsRoot)
            {
                Menu menu     = GetMenuItem(item);
                var  children = GetMenuChild(functions, item.FunctionCode);
                if (children != null && children.Count > 0)
                {
                    menu.children = children;
                }
                menus.Add(menu);
            }

            return(res);
        }
Exemplo n.º 14
0
        public async Task <ActionResult <DataRes <bool> > > Import([FromForm] IFormFile excelFile)
        {
            DataRes <bool> result = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            //IFormFile excelFile = files["excelfile"];
            if (excelFile == null || excelFile.Length <= 0)
            {
                result.code = ResCode.Error;
                result.data = false;
                result.msg  = ResMsg.FileNotNull;
            }
            else if (!Path.GetExtension(excelFile.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
            {
                result.code = ResCode.NoValidate;
                result.msg  = ResMsg.ExcelNotValidate;
                result.data = false;
            }
            List <TEntity> list = null;

            using (var stream = excelFile.OpenReadStream())
            {
                using (var package = new ExcelPackage(stream))
                {
                    try
                    {
                        StringBuilder  sb        = new StringBuilder();
                        ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
                        list = GetEntitiesFromExcel(worksheet);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <TEntity>();
                if (_init)
                {
                    await repository.DeleteAll();

                    uow.BulkSaveChanges();
                }
                await repository.BulkInsertAsync(list).ConfigureAwait(false);

                uow.SaveChanges();
            }
            return(result);
        }
Exemplo n.º 15
0
        public DataRes <IEnumerable <string> > GetFunctions(string code)
        {
            DataRes <IEnumerable <string> > res = new DataRes <IEnumerable <string> >()
            {
                code = ResCode.Success
            };

            var list = roleFunctionBLL.GetList(string.Format("roleCode='{0}'", code));

            res.data = list.Select(p => p.FunctionCode);

            return(res);
        }
Exemplo n.º 16
0
 public async Task <DataRes <List <ResPermission> > > GetUserPermissionsAsync(int userId)
 {
     using (var uow = _uowProvider.CreateUnitOfWork())
     {
         var cr   = uow.GetCustomRepository <Service.IResUserRepository>();
         var list = (await cr.GetAllPermissions(userId)).ToList();
         var dr   = new DataRes <List <ResPermission> >()
         {
             data = list
         };
         return(dr);
     }
 }
Exemplo n.º 17
0
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            DataRes <object> rto = new DataRes <object>();
            var response         = HttpContext.Current.Response;
            var request          = HttpContext.Current.Request;

            rto.code = ResCode.Error;
            rto.msg  = "[WEB.API]服务器异常!异常信息:" + actionExecutedContext.Exception.Message;
            response.Write(JsonConvert.SerializeObject(rto));
            response.End();
            Task.Run(() => WriteLog(actionExecutedContext));
            base.OnException(actionExecutedContext);
        }
Exemplo n.º 18
0
        public DataRes <IEnumerable <string> > GetFunctions(string code)
        {
            DataRes <IEnumerable <string> > res = new DataRes <IEnumerable <string> >()
            {
                code = ResCode.Success
            };

            var list = userFunctionBLL.GetList($"userCode='{code}'");

            res.data = list.Select(p => p.FunctionCode);

            return(res);
        }
Exemplo n.º 19
0
        public ActionResult <DataRes <List <string> > > GetProductCategoryList()
        {
            var result = new DataRes <List <string> >()
            {
                code = ResCode.Success
            };

            string[] arr = { "生发发帘",    "生发小发块", "生发大发块", "360发块",    "透明蕾丝发块", "老接发", "新接发",
                             "高质量接发",   "化纤接发",  "顺发",    "UNICE新幅度", "压色",     "辫发",  "老发帘","人发头套-自产",
                             "人发头套-组合", "老头套",   "化纤头套" };
            result.data = arr.ToList();
            return(result);
        }
Exemplo n.º 20
0
        public virtual async Task <ActionResult <DataRes <bool> > > Add([FromBody] TEntity model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                bool cp = await CheckPermission("Add", uow);

                if (cp)
                {
                    try
                    {
                        var    repository = uow.GetCustomRepository <IXinRepository <TEntity> >();
                        string us         = User.Claims.FirstOrDefault(p => p.Type.Equals(ClaimTypes.Sid)).Value;
                        if (us != null)
                        {
                            int userid = Convert.ToInt32(us);
                            model.CreateUid  = userid;
                            model.WriteUid   = userid;
                            model.CreateDate = DateTime.Now;
                            model.WriteDate  = DateTime.Now;
                            repository.Add(model);
                            uow.SaveChanges();
                        }

                        else
                        {
                            res.code = ResCode.Error;
                            res.data = false;
                            res.msg  = "当前登录用户信息获取失败";
                        }
                        return(res);
                    }
                    catch (Exception ex)
                    {
                        res.code = ResCode.ServerError;
                        res.data = false;
                        res.msg  = ex.Message;
                        return(res);
                    }
                }
                else
                {
                    return(Unauthorized());
                }
            }
        }
Exemplo n.º 21
0
        public DataRes <List <ResDepartment> > GetChildList(int id)
        {
            var result = new DataRes <List <ResDepartment> >()
            {
                code = ResCode.Success
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResDepartment>();
                var depts      = repository.Query(f => f.StopFlag == false && f.ParentId == id);
                result.data = depts.ToList();
            }

            return(result);
        }
Exemplo n.º 22
0
        public DataRes <bool> Add([FromBody] Pub_Function model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            model.FunctionCode = bll.GetCode(model.ParentCode);
            model.editdate     = DateTime.Now;
            var user = User.GetZXYLUser();

            model.editor   = string.Format("{0}-{1}", user.UserCode, user.UserName);
            model.StopFlag = false;
            var r = bll.Insert(model);

            return(res);
        }
Exemplo n.º 23
0
        public DataRes <bool> Add([FromBody] Pub_Department model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            model.DeptCode = bll.GetCode();
            model.Lmdt     = model.Lmdt = DateTime.Now;
            var user = LQExtensionFactory.GetLQExtensionUser(User);

            model.Lmid     = $"{user.UserCode}-{user.UserName}";
            model.StopFlag = false;
            var r = bll.Insert(model);

            return(res);
        }
Exemplo n.º 24
0
        public DataRes <bool> Add([FromBody] Pub_Department model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            model.DeptCode = bll.GetCode();
            model.Lmdt     = model.Lmdt = DateTime.Now;
            var user = User.GetZXYLUser();

            model.Lmid     = string.Format("{0}-{1}", user.UserCode, user.UserName);
            model.StopFlag = false;
            var r = bll.Insert(model);

            return(res);
        }
Exemplo n.º 25
0
        public DataRes <bool> Add([FromBody] Pub_Function model)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            model.FunctionCode = bll.GetCode(model.ParentCode);
            model.editdate     = DateTime.Now;
            var user = LQExtensionFactory.GetLQExtensionUser(User);

            model.editor   = $"{user.UserCode}-{user.UserName}";
            model.StopFlag = false;
            var r = bll.Insert(model);

            return(res);
        }
Exemplo n.º 26
0
        public virtual async Task <ActionResult <DataRes <bool> > > Delete(int id)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                bool cp = await CheckPermission("Delete", uow);

                if (cp)
                {
                    try
                    {
                        var    repository = uow.GetRepository <TEntity>();
                        var    model      = repository.Get(id);
                        string us         = User.Claims.FirstOrDefault(p => p.Type.Equals(ClaimTypes.Sid)).Value;
                        if (us != null)
                        {
                            int userid = Convert.ToInt32(us);
                            repository.Remove(model);
                            uow.SaveChanges();
                        }
                        else
                        {
                            res.code = ResCode.Error;
                            res.data = false;
                            res.msg  = "当前登录用户信息获取失败";
                        }
                        return(res);
                    }
                    catch (Exception ex)
                    {
                        res.code = ResCode.ServerError;
                        res.msg  = ex.Message;
                        return(res);
                    }
                }
                else
                {
                    return(Unauthorized());
                }
            }
        }
Exemplo n.º 27
0
        public DataRes <bool> Delete(long id)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            var r = bll.ChangeSotpStatus($"id={id}", null);

            if (!r)
            {
                res.code = ResCode.Error;
                res.data = false;
                res.msg  = "删除失败";
            }

            return(res);
        }
Exemplo n.º 28
0
        public DataRes <dynamic> GetHomePageInfo()
        {
            var result        = new DataRes <dynamic>();
            var getInfo       = CourseClassfyBLL.GetList("ismadical=1 and stopFlag=0", limits: 8, sort: "clickCount Desc");
            var medicalCourse = getInfo.MapTo <List <V_PubCourse_Classfy>, List <Pub_course> >();
            var getInfo2      = CourseClassfyBLL.GetList("ismadical=0 and stopFlag=0", limits: 8, sort: "clickCount Desc");
            var noMedical     = getInfo2.MapTo <List <V_PubCourse_Classfy>, List <Pub_course> >();

            result = new DataRes <dynamic>
            {
                data = new
                {
                    medicalCourse = medicalCourse,
                    noMedical     = noMedical
                }
            };
            return(result);
        }
Exemplo n.º 29
0
        public DataRes <bool> Delete(long id)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            var r = courseBll.ChangeSotpStatus(string.Format("id={0}", id), null);

            if (!r)
            {
                res.code = ResCode.Error;
                res.data = false;
                res.msg  = "删除失败";
            }

            return(res);
        }
Exemplo n.º 30
0
        public DataRes <bool> Delete(string id)
        {
            DataRes <bool> res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            var r = bll.ChangeSotpStatus("FunctionCode='" + id + "'");

            if (!r)
            {
                res.code = ResCode.Error;
                res.data = false;
                res.msg  = "删除失败";
            }

            return(res);
        }