Beispiel #1
0
 public void GetDateList(Action <ActionResult> action = null)
 {
     Task.Factory.StartNew(() =>
     {
         Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
         TitleInfoRequest request  = new TitleInfoRequest();
         request.PageIndex         = 1;
         request.PageSize          = 100;
         TitleInfoListResponse str = titleInfo.SelectTitleInfoList(request);
         if (str.RowCount > 0)
         {
             List <MainWindowModel> tList = str.mainWindowModels.ToList();
             ObservableCollection <MainWindowModel> oc = new ObservableCollection <MainWindowModel>();
             tList.ForEach(x => oc.Add(x));
             Items = oc;
         }
         else
         {
             return;
         }
         var result = new ActionResult();
         try
         {
             result.Result = true;
         }
         catch (Exception exception)
         {
             result.ErrorMessage = exception.Message;
         }
         finally
         {
             action?.Invoke(result);
         }
     });
 }
Beispiel #2
0
        public TitleInfoListResponse SelectTitleInfoList(TitleInfoRequest Request)
        {
            TitleInfoListResponse response = new TitleInfoListResponse();

            try
            {
                using (var entities = new ResKey_dbEntities())
                {
                    var rowCount = Request.PageIndex * Request.PageSize;
                    var pageSize = Request.PageSize;
                    var list     = new List <Expression <Func <Entity.Model.TitleInfo, bool> > >();

                    if (Request.ID.HasValue)
                    {
                        list.Add(c => c.ID == Request.ID.Value);
                    }
                    if (Request.IsHandle.HasValue)
                    {
                        list.Add(c => c.IsHandle == Request.IsHandle);
                    }
                    Expression <Func <Entity.Model.TitleInfo, bool> > entitiesQuery = null;
                    foreach (var expression in list)
                    {
                        entitiesQuery = entitiesQuery == null ? expression : entitiesQuery.And(expression);
                    }
                    var dbset           = entities.TitleInfo;
                    var query           = entitiesQuery == null ? dbset : dbset.Where(entitiesQuery);
                    var mainWindowModel = query.Select(entity => new MainWindowModel
                    {
                        ID               = entity.ID,
                        IsAdd            = entity.IsAdd,
                        IsHandle         = entity.IsHandle,
                        OldID            = entity.OldID,
                        ModificationTime = entity.ModificationTime,
                        NewTitle         = entity.NewTitle,
                        OldTitle         = entity.OldTitle,
                        UpTime           = entity.UpTime
                    });
                    var arrayL = mainWindowModel.OrderBy(c => c.ID)
                                 .Skip(rowCount)
                                 .Take(pageSize)
                                 .ToArray()
                                 .OrderByDescending(c => c.ID).ToArray();
                    response.mainWindowModels = arrayL;
                    response.RowCount         = arrayL.Count();
                    response.PageSize         = pageSize;
                }
            }
            catch (Exception exception)
            {
                //response.Error = new Error
                //{
                //    ErrorMessage = exception.GetBaseException().Message,
                //    ErrorCode = 5001
                //};
            }
            return(response);
        }
Beispiel #3
0
        /// <summary>
        /// 查询所有关键字
        /// </summary>
        /// <param name="Request"></param>
        /// <returns></returns>
        public TitleInfoListResponse SelectAllTitleInfoList(TitleInfoRequest Request)
        {
            TitleInfoListResponse response = new TitleInfoListResponse();

            try
            {
                using (var entities = new ResKey_dbEntities())
                {
                    var rowCount = Request.PageIndex * Request.PageSize;
                    var pageSize = Request.PageSize;
                    var list     = new List <Expression <Func <Entity.Model.TitleInfo, bool> > >();
                    list.Add(c => c.IsHandle == 0);
                    if (!string.IsNullOrWhiteSpace(Request.TitleName))
                    {
                        list.Add(c => c.NewTitle.Contains(Request.TitleName));
                    }
                    Expression <Func <Entity.Model.TitleInfo, bool> > entitiesQuery = null;
                    foreach (var expression in list)
                    {
                        entitiesQuery = entitiesQuery == null ? expression : entitiesQuery.And(expression);
                    }
                    var dbset           = entities.TitleInfo;
                    var query           = entitiesQuery == null ? dbset : dbset.Where(entitiesQuery);
                    var mainWindowModel = query.Select(entity => new MainWindowModel
                    {
                        ID               = entity.ID,
                        IsAdd            = entity.IsAdd,
                        IsHandle         = entity.IsHandle,
                        OldID            = entity.OldID,
                        ModificationTime = entity.ModificationTime,
                        NewTitle         = entity.NewTitle,
                        OldTitle         = entity.OldTitle,
                        UpTime           = entity.UpTime
                    });
                    var arrayL = mainWindowModel.OrderBy(c => c.ID)
                                 .Skip(rowCount)
                                 .Take(pageSize)
                                 .ToArray()
                                 .OrderByDescending(c => c.ID).ToArray();
                    //int c = a % b == 0 ? a / b : a / b + 1;
                    response.PageMax = (mainWindowModel.Count() % Request.PageSize == 0 ? mainWindowModel.Count() / Request.PageSize : mainWindowModel.Count() / Request.PageSize + 1) - 1;
                    //mainWindowModel.Count()/Request.PageSize;
                    response.mainWindowModels = arrayL;
                    response.RowCount         = arrayL.Count();
                    response.PageSize         = pageSize;
                }
            }
            catch (Exception exception)
            {
            }
            return(response);
        }
Beispiel #4
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public async void Init()
        {
            Items.Clear();
            await Task.Run(() =>
            {
                try
                {
                    Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
                    TitleInfoRequest request = new TitleInfoRequest();
                    request.PageIndex        = 0;
                    request.PageSize         = 20;
                    //request.IsOccupy = 0;
                    request.UserNo = No;
                    var str        = titleInfo.SelectAllTitleInfoList(request);
                    if (str.RowCount > 0)
                    {
                        PageMax   = str.PageMax;
                        var tList = str.mainWindowModels.ToList();
                        ObservableCollection <MainWindowModel> oc = new ObservableCollection <MainWindowModel>();
                        tList.ForEach(x => oc.Add(x));
                        Items = oc;

                        //foreach (var item in tList)
                        //{
                        //    Items.Add(item);
                        //}

                        //foreach (var item in Items)
                        //{
                        //    item.IsHandle = 0;
                        //}
                    }
                    else
                    {
                        return;
                    }
                    //var result = new ActionResult();
                    //result.Result = true;
                }
                catch (Exception e)
                {
                    var str = e.Message;
                }
                finally
                {
                }
            });
        }
        /// <summary>
        /// 身份认证
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            //string logStr = "select count(*) from UserInfo where UserName='******' and PassWord='******'";
            //int result = SqlHelper.cmdExecuteScalar(logStr);
            //if (result == 0)
            //{
            //    MessageBox.Show("登陆失败!");
            //    return;
            //}
            //this.Title = "欢迎【" + this.txtUserName.Text.Trim() + "】登陆!";
            //var dt = SqlHelper.GetLocalDataTable("select * from keywords where isown='" + this.txtUserName.Text.Trim() + "' and isuse=0 order by search_total");
            //var list = ModelConvertHelper<keyWordDto>.ConvertToModel(dt);

            Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
            TitleInfoRequest             request   = new TitleInfoRequest();

            request.PageIndex = 0;
            request.PageSize  = 10;
            request.IsOccupy  = 0;
            //request.UserNo = No;
            TitleInfoListResponse str = titleInfo.SelectUserTitleInfoList(request);
            var tList = new List <MainWindowModel>();

            if (str.RowCount > 0)
            {
                //PageMax = str.PageMax;
                tList = str.mainWindowModels.ToList();
                //ObservableCollection<MainWindowModel> oc = new ObservableCollection<MainWindowModel>();
                //tList.ForEach(x => oc.Add(x));
                //Items = oc;
            }
            else
            {
                return;
            }
            foreach (var l in tList)
            {
                Button btn = new Button()
                {
                    BorderThickness = new Thickness(2), FontSize = Convert.ToDouble(15.0)
                };
                btn.Click  += Btn_Click;
                btn.Content = l.NewTitle;
                this.warpPanelKeys.Children.Add(btn);
            }
        }
 private void Handle_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
         TitleHandleRequest           request   = new TitleHandleRequest();
         //request.PageIndex = 0;
         //request.PageSize = 20;
         ////request.IsOccupy = 0;
         //PageNo = request.PageIndex;
         //request.UserNo = No;
         request.ID = ViewModel.SelectItem.ID;
         var str = titleInfo.TitleHandle(request);
         if (str == 1)
         {
             //Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
             TitleInfoRequest requestTitleInfo = new TitleInfoRequest();
             requestTitleInfo.PageIndex = ViewModel.PageNo;
             requestTitleInfo.PageSize  = 20;
             //request.IsOccupy = 0;
             requestTitleInfo.UserNo = ViewModel.No;
             var strTitleInfo = titleInfo.SelectAllTitleInfoList(requestTitleInfo);
             if (strTitleInfo.RowCount > 0)
             {
                 ViewModel.PageMax = strTitleInfo.PageMax;
                 var tList = strTitleInfo.mainWindowModels.ToList();
                 ObservableCollection <MainWindowModel> oc = new ObservableCollection <MainWindowModel>();
                 tList.ForEach(x => oc.Add(x));
                 ViewModel.Items = oc;
             }
         }
         else
         {
             return;
         }
         //var result = new ActionResult();
         //result.Result = true;
     }
     catch (Exception)
     {
     }
     finally
     {
     }
 }
        public void LoadData()
        {
            warpPanelKeys.Children.Clear();
            Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
            TitleInfoRequest             request   = new TitleInfoRequest();

            request.PageIndex = 0;
            request.PageSize  = 10;
            request.IsOccupy  = 0;
            request.UserNo    = ViewModel.No;
            TitleInfoListResponse str = titleInfo.SelectUserTitleInfoList(request);
            var tList = new List <MainWindowModel>();

            if (str.RowCount > 0)
            {
                //PageMax = str.PageMax;
                tList = str.mainWindowModels.ToList();
                //ObservableCollection<MainWindowModel> oc = new ObservableCollection<MainWindowModel>();
                //tList.ForEach(x => oc.Add(x));
                //Items = oc;
            }
            else
            {
                return;
            }
            foreach (var l in tList)
            {
                Button btn = new Button()
                {
                    BorderThickness = new Thickness(2), FontSize = Convert.ToDouble(15.0)
                };
                //FontSize = "24"
                btn.FontSize = 20;
                btn.Margin   = new Thickness(10);
                btn.Click   += Btn_Click;
                btn.Content  = l.NewTitle;
                this.warpPanelKeys.Children.Add(btn);
            }
        }
 /// <summary>
 /// 加载数据
 /// </summary>
 public async void Init()
 {
     await Task.Run(() =>
     {
         try
         {
             Entity.EFOperation.TitleInfo titleInfo = new Entity.EFOperation.TitleInfo();
             TitleInfoRequest request  = new TitleInfoRequest();
             request.PageIndex         = 0;
             request.PageSize          = 500;
             request.IsOccupy          = 0;
             request.UserNo            = No;
             request.IsStep            = 2;
             TitleInfoListResponse str = titleInfo.SelectUserTitleInfoList(request);
             if (str.RowCount > 0)
             {
                 //PageMax = str.PageMax;
                 var tList = str.mainWindowModels.ToList();
                 ObservableCollection <MainWindowModel> oc = new ObservableCollection <MainWindowModel>();
                 tList.ForEach(x => oc.Add(x));
                 Items = oc;
             }
             else
             {
                 return;
             }
             //var result = new ActionResult();
             //result.Result = true;
         }
         catch (Exception)
         {
         }
         finally
         {
         }
     });
 }
Beispiel #9
0
        public int TitleAddUser(TitleInfoRequest Request)
        {
            using (var dbContextTransaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    var rowCount = Request.PageIndex * Request.PageSize;
                    var pageSize = Request.PageSize;
                    var list     = new List <Expression <Func <Entity.Model.TitleInfo, bool> > >();
                    if (Request.IsHandle.HasValue)
                    {
                        list.Add(c => c.IsHandle == Request.IsHandle);
                    }
                    list.Add(c => c.IsOccupy == 0);
                    Expression <Func <Entity.Model.TitleInfo, bool> > entitiesQuery = null;
                    foreach (var expression in list)
                    {
                        entitiesQuery = entitiesQuery == null ? expression : entitiesQuery.And(expression);
                    }
                    var dbset           = DbContext.TitleInfo;
                    var query           = entitiesQuery == null ? dbset : dbset.Where(entitiesQuery);
                    var mainWindowModel = query.Select(entity => new MainWindowModel
                    {
                        ID               = entity.ID,
                        IsAdd            = entity.IsAdd,
                        IsHandle         = entity.IsHandle,
                        OldID            = entity.OldID,
                        ModificationTime = entity.ModificationTime,
                        NewTitle         = entity.NewTitle,
                        OldTitle         = entity.OldTitle,
                        UpTime           = entity.UpTime
                    });
                    var arrayL = mainWindowModel.OrderBy(c => c.ID)
                                 .Skip(rowCount)
                                 .Take(pageSize)
                                 .ToArray()
                                 .OrderByDescending(c => c.ID).ToArray();

                    for (int i = 0; i < arrayL.Count(); i++)
                    {
                        var ID      = arrayL[i].ID;
                        var dbModel = DbContext.TitleInfo.Where(c => c.ID == ID).FirstOrDefault();
                        if (dbModel != null)
                        {
                            dbModel.IsOccupy = 1;//已占用
                            var info = DbContext.UserInfo.Where(c => c.TitleInfoID == dbModel.ID && c.IsEnable == 1).FirstOrDefault();
                            if (info != null && info.ID > 0)
                            {
                                //return 2;
                            }
                            else
                            {
                                Model.UserInfo userInfo = new UserInfo
                                {
                                    IsEnable    = 1,
                                    TitleInfoID = dbModel.ID,
                                    UserName    = Request.UserName,
                                    UserNo      = Request.UserNo,
                                };
                                DbContext.UserInfo.Add(userInfo);
                                DbContext.SaveChanges();
                            }
                        }
                    }
                    dbContextTransaction.Commit();
                    return(1);
                }
                catch (Exception e)
                {
                    dbContextTransaction.Rollback();
                    return(101);
                }
            }
        }