public ActionResult GetGroup(DataTablesReqModel <List <NotifyAssignedViewModel> > data)
        {
            var _user = ((PtcIdentity)this.User.Identity).currentUser;

            if (_user.CompCd == "")
            {
                _user.CompCd = "711";
            }
            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                Conditions <DataBase.TTechnicianGroup> conGroup = new Conditions <DataBase.TTechnicianGroup>();
                conGroup.And(x => x.CompCd == _user.CompCd);       //公司別
                conGroup.And(x => x.VendorCd == _user.VenderCd);   //廠商
                var Data = _TTechnicianGroupRepo.GetList(conGroup);
                PagedList <TtechnicianGroup> meta = new PagedList <TtechnicianGroup>(Data);
                result.data = meta.Select(x => new NotifyAssignedViewModel(x).colData).ToArray();
                result.TotalCount(conGroup.TotalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null)
                {
                    _logger.Error(ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        _logger.Error(ex.InnerException.InnerException.Message);
                    }
                }
                result.error = ex.Message;
            }
            return(Json(result));
        }
        public ActionResult GetListBySingle(DataTablesReqModel <TassetsViewModel> data)
        {
            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                if (data == null)
                {
                    throw new ArgumentNullException($"no input data");
                }


                Conditions <DataBase.TASSETS> con = new Conditions <DataBase.TASSETS>
                                                        (data.length, (data.start / data.length));

                TassetsViewModel model = data.criteria;

                model?.GetProperties()?
                .Select(x => x.Avatar <AvatarAttribute>(model))
                .Where(x => x.Key != null)
                .ForEach(g => con.ConvertToFilter(g.Key.SubstituteName,
                                                  g.Key.ExpressionType,
                                                  g.Key.PredicateType,
                                                  g.Value));

                data.order?.ForEach(x =>
                {
                    con.Order(x.dir, data.columns[x.column].name);
                });

                PagedList <Tassets> meta = new PagedList <Tassets>(_baseRepo.GetList(con), (data.start / data.length), data.length);

                result.data = meta.Select(x => new TassetsResultViewModel(x).colData)
                              .ToArray();

                result.TotalCount(meta.TotalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                result.error = ex.Message;
            }

            return(Json(result));
        }
Beispiel #3
0
        public ActionResult GetTechnician(DataTablesReqModel <List <ChangeAssignedViewModel> > data)
        {
            var _user = ((PtcIdentity)this.User.Identity).currentUser;

            if (_user.CompCd == "")
            {
                _user.CompCd = "711";
            }
            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                Conditions <DataBase.TVenderTechnician> conTechnician = new Conditions <DataBase.TVenderTechnician>();
                conTechnician.And(x => x.Comp_Cd == _user.CompCd);      //公司別
                conTechnician.And(x => x.Vender_Cd == _user.VenderCd);  //廠商
                conTechnician.And(x => x.Enable == true);               //狀態:啟用
                var Data = _TvenderTechnicianRepo.GetList(conTechnician);
                PagedList <TvenderTechnician> meta = new PagedList <TvenderTechnician>(Data);
                result.data = meta.Select(x => new ChangeAssignedViewModel(x).colData).ToArray();
                result.TotalCount(conTechnician.TotalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null)
                {
                    _logger.Error(ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        _logger.Error(ex.InnerException.InnerException.Message);
                    }
                }
                result.error = ex.Message;
            }
            return(Json(result));
        }
Beispiel #4
0
        public ActionResult Getcallog(DataTablesReqModel <List <ChangeAssignedViewModel> > data)
        {
            var _user = ((PtcIdentity)this.User.Identity).currentUser;

            if (_user.CompCd == "")
            {
                _user.CompCd = "711";
            }
            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                #region 取得所有區域
                Conditions <DataBase.TZOCODE> conZo = new Conditions <DataBase.TZOCODE>();
                conZo.And(x => x.Comp_Cd == _user.CompCd); //公司別
                var Zo = _TzocodeRepo.GetList(conZo).ToList();
                #endregion

                #region 取得未完修案件
                Conditions <DataBase.VW_MobileCallogNoFinish> conCallog = new Conditions <DataBase.VW_MobileCallogNoFinish>();
                conCallog.And(x => x.Comp_Cd == _user.CompCd);               //公司別
                conCallog.And(x => x.Vender_Cd == _user.VenderCd);           //廠商
                conCallog.And(x => x.Close_Sts == (byte)CloseSts.process);   //剛立案
                conCallog.And(x => x.TimePoint >= (byte)TimePoint.Accepted); //timepoint>=2
                conCallog.And(x => x.TimePoint < (byte)TimePoint.Finish);    //timepoint<4
                data.order?.ForEach(x =>
                {
                    if (data.columns[x.column].name == "Zo_Name")
                    {
                        conCallog.Order(x.dir, "Z_O");
                    }
                    else if (data.columns[x.column].name == "Do_Name")
                    {
                        conCallog.Order(x.dir, "D_O");
                    }
                    else
                    {
                        conCallog.Order(x.dir, data.columns[x.column].name);
                    }
                });
                var Data = _VWMobileCallogNoFinishRepo.GetList(conCallog);
                #endregion
                int PageIndex = (data.start / data.length);
                PagedList <MobileCallogSearch> meta = new PagedList <MobileCallogSearch>(Data, PageIndex, data.length);
                result.data = meta.Select(x => new ChangeAssignedViewModel(x,
                                                                           Zo.Where(y => y.ZoCd == x.Zo && y.DoCd == "").Select(z => z.ZoName).FirstOrDefault(),
                                                                           Zo.Where(y => y.ZoCd == x.Zo && y.DoCd == x.Do).Select(z => z.DoName).FirstOrDefault()).colData).ToArray();
                result.TotalCount(conCallog.TotalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null)
                {
                    _logger.Error(ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        _logger.Error(ex.InnerException.InnerException.Message);
                    }
                }
                result.error = ex.Message;
            }
            return(Json(result));
        }
        public ActionResult GetList(DataTablesReqModel <List <TassetsViewModel> > data)
        {
            List <TassetsViewModel> models = data.criteria;

            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                Conditions <DataBase.TASSETS> con = new Conditions <DataBase.TASSETS>
                                                        (data.length, (data.start / data.length));

                models?.ForEach(model =>
                {
                    var component = new List <Expression <Func <DataBase.TASSETS, Boolean> > >();

                    model.GetProperties()?
                    .Select(x => x.Avatar <AvatarAttribute>(model))
                    .Where(x => x.Key != null)
                    .ForEach(g =>
                    {
                        component.Add(con.CombinationExpression(
                                          g.Key.SubstituteName,
                                          g.Key.ExpressionType,
                                          g.Value));
                    });

                    con.ConvertToMultiFilter(component);
                });

                data.order?.ForEach(x =>
                {
                    con.Order(x.dir, data.columns[x.column].name);
                });
                #region DataRange

                var _user = (this.User.Identity as AspnetMvc.Models.PtcIdentity).currentUser;

                con.And(x => x.Comp_Cd == _user.CompCd);


                #endregion
                PagedList <Tassets> meta = new PagedList <Tassets>(_baseRepo.GetList(con), (data.start / data.length), data.length);

                result.data = meta.Select(x => new TassetsResultViewModel(x).colData)
                              .ToArray();

                result.TotalCount(meta.TotalCount);
            }
            catch (AutoMapper.AutoMapperMappingException ex)
            {
                _logger.Error(ex);
                result.error = ex.InnerException.Message;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                result.error = ex.Message;
            }

            return(Json(result));
        }
        public ActionResult SearchMemberAuth(DataTablesReqModel <List <MemberSetSearchViewModel> > data)
        {
            List <MemberSetSearchViewModel> models = data.criteria;

            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                Conditions <DataBase.TUSRMST> con = new Conditions <DataBase.TUSRMST>(data.length, (data.start / data.length));

                models?.ForEach(model =>
                {
                    var component = new List <Expression <Func <DataBase.TUSRMST, Boolean> > >();

                    model.GetProperties()?
                    .Select(x => x.Avatar <AvatarAttribute>(model))
                    .Where(x => x.Key != null)
                    .ForEach(g =>
                    {
                        component.Add(con.CombinationExpression(
                                          g.Key.SubstituteName,
                                          g.Key.ExpressionType,
                                          g.Value));
                    });

                    con.ConvertToMultiFilter(component);
                });

                data.order?.ForEach(x =>
                {
                    con.Order(x.dir, data.columns[x.column].name);
                });

                //con.Include(x => x.TSYSROL);
                con.Include(x => x.TUSRDTL);
                #region DataRange

                var _user = (this.User.Identity as AspnetMvc.Models.PtcIdentity).currentUser;

                //con.And(x => x.Comp_Cd == _user.CompCd);


                #endregion
                var list = _tusrmstRepo.GetList(con);

                PagedList <UserBase> meta = new PagedList <UserBase>(list);



                result.data = list.Select(x => new MemberSetResultViewModel(x))
                              .Select(g => new string[] {
                    g.CompCd,
                    g.UserID,
                    g.UserName,
                    g.RoleName,
                })
                              .ToArray();



                result.TotalCount(con.TotalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                result.error = ex.Message;
            }
            return(Json(result));
        }
        public ActionResult GetList(DataTablesReqModel <List <TechnicianViewModel> > data)
        {
            List <TechnicianViewModel> models = data.criteria;

            DataTablesRespModel result = new DataTablesRespModel(data.draw);

            try
            {
                if (data.criteria == null)
                {
                    throw new Exception("沒有條件,無法查詢");
                }

                Conditions <DataBase.TVenderTechnician> con = new Conditions <DataBase.TVenderTechnician>(data.length, (data.start / data.length));

                models?.ForEach(model =>
                {
                    var component = new List <Expression <Func <DataBase.TVenderTechnician, Boolean> > >();

                    model.GetProperties()?
                    .Select(x => x.Avatar <AvatarAttribute>(model))
                    .Where(x => x.Key != null)
                    .ForEach(g =>
                    {
                        component.Add(con.CombinationExpression(
                                          g.Key.SubstituteName,
                                          g.Key.ExpressionType,
                                          g.Value));
                    });

                    con.ConvertToMultiFilter(component);
                });

                data.order?.ForEach(x =>
                {
                    con.Order(x.dir, data.columns[x.column].name);
                });

                #region DataRange

                var _user = (this.User.Identity as PtcIdentity).currentUser;

                con.And(x => x.Comp_Cd == _user.CompCd);

                if (_user.DataRange?.VendorCd != null)
                {
                    con.And(x => _user.DataRange.VendorCd.Contains(x.Vender_Cd));
                }

                #endregion

                var list      = _technicianRepo.GetList(con);
                int PageIndex = (data.start / data.length);
                PagedList <TvenderTechnician> meta = new PagedList <TvenderTechnician>(list, PageIndex, data.length);


                result.data = meta.Select(x => new TechnicianResultViewModel(x).colData)
                              .ToArray();

                result.TotalCount(con.TotalCount);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null)
                {
                    _logger.Error(ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        _logger.Error(ex.InnerException.InnerException.Message);
                    }
                }
                result.error = ex.Message;
            }
            return(Json(result));
        }