Example #1
0
        public void GetOperation(HttpContext context)
        {
            JsonModelNum_Total jsonModelNum = null;

            try
            {
                HttpRequest request = context.Request;
                string      UID     = RequestHelper.string_transfer(request, "UID");
                string      dsp     = RequestHelper.string_transfer(request, "dsp");
                string      Key     = RequestHelper.string_transfer(request, "Key");

                string Year      = RequestHelper.string_transfer(request, "Year");
                string Section   = RequestHelper.string_transfer(request, "Section");
                string LoginName = RequestHelper.string_transfer(request, "LoginName");

                //当期奖项
                bool Current   = RequestHelper.bool_transfer(request, "Current");
                bool IsHistory = RequestHelper.bool_transfer(request, "IsHistory");

                int PageIndex = RequestHelper.int_transfer(request, "PageIndex");
                int PageSize  = RequestHelper.int_transfer(request, "PageSize");

                bool result = Constant.Check_Login_DIP(UID, dsp);
                if (result)
                {
                    jsonModelNum = GetOperation_Helper(PageIndex, PageSize, Key, Current, IsHistory, Year, Section, LoginName);
                }
                else
                {
                    jsonModelNum = JsonModelNum_Total.GetJsonModel(1000, "已超时");
                }
            }
            catch (Exception ex)
            {
                jsonModelNum = JsonModelNum_Total.GetJsonModel(400, ex.Message);
                LogHelper.Error(ex);
            }
            finally
            {
                //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】
                context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModelNum) + "}");
            }
        }
Example #2
0
        public static JsonModelNum_Total GetOperation_Helper(int pageIndex, int PageSize, string Key, bool Current, bool IsHistory, string Year, string Section, string LoginName)
        {
            JsonModelNum_Total jsm = null;

            try
            {
                List <Operation_Record> Operation_Record_List = Constant.Operation_Record_List;
                List <Award_Public>     Award_Public_List     = Constant.Award_Public_List;
                List <Globe_Clue>       Globe_Clue_List       = Constant.Globe_Clue_List;
                List <UserInfo>         UserInfo_List         = Constant.UserInfo_List;
                List <Globe>            Globe_List            = Constant.Globe_List;

                List <Operation_Record_S> recordList      = Get_Operation_Record_S(Operation_Record_List, Award_Public_List, Globe_Clue_List, UserInfo_List, Globe_List);
                List <Operation_Record_S> recordList_real = new List <Operation_Record_S>();


                if (!string.IsNullOrEmpty(LoginName))
                {
                    recordList_real = (from record in recordList where record.UserID == LoginName select record).ToList();
                }
                else
                {
                    if (Current)
                    {
                        List <Award_Public> price_list = Award_Public_List.Where(item => DateTime.Now < item.CloseTime && item.StartTime < DateTime.Now).ToList();
                        if (price_list.Count > 0)
                        {
                            var prize = price_list[0];
                            recordList_real = (from record in recordList where record.AwardCode == prize.Code select record).ToList();
                        }
                    }
                    else if (IsHistory)
                    {
                        List <int> codes = (from award in Award_Public_List where DateTime.Now > award.CloseTime select(int) award.Code).ToList();
                        if (codes.Count > 0)
                        {
                            recordList_real = (from record in recordList where codes.Contains((int)record.AwardCode) select record).ToList();
                        }
                    }
                    else
                    {
                        recordList_real = recordList;
                    }
                }


                if (!string.IsNullOrEmpty(Year))
                {
                    List <int> codes = (from award in Award_Public_List where Convert.ToString(award.Year) == Year select(int) award.Code).Distinct().ToList();
                    recordList_real = (from record in recordList_real where codes.Contains((int)record.AwardCode) select record).ToList();
                }
                if (!string.IsNullOrEmpty(Section))
                {
                    List <int> codes = (from award in Award_Public_List where Convert.ToString(award.Name) == Section select(int) award.Code).Distinct().ToList();
                    recordList_real = (from record in recordList_real where codes.Contains((int)record.AwardCode) select record).ToList();
                }



                decimal Araw_ReturnMoneyTotal = 0;
                decimal Get_MoneyTotal        = 0;
                decimal Return_MoneyTotal     = 0;
                decimal Using_MoneyTotal      = 0;
                decimal Win_MoneyTotal        = 0;
                foreach (var item in recordList_real)
                {
                    Araw_ReturnMoneyTotal += (decimal)item.Araw_ReturnMoney;
                    Get_MoneyTotal        += (decimal)item.Get_Money;
                    Return_MoneyTotal     += (decimal)item.Return_Money;
                    Using_MoneyTotal      += (decimal)item.Using_Money;
                    Win_MoneyTotal        += (decimal)(item.Get_Money + item.Araw_ReturnMoney + item.Return_Money - item.Using_Money);
                }

                List <Operation_Record_S> recordList_get = recordList_real.Skip((pageIndex - 1) * PageSize).Take(PageSize).OrderByDescending(i => i.CreateTime).ToList();
                SetContent(recordList_get, Globe_Clue_List);

                jsm = JsonModelNum_Total.GetJsonModel(0, "success", recordList_get);
                jsm.Araw_ReturnMoneyTotal = Araw_ReturnMoneyTotal;
                jsm.Get_MoneyTotal        = Get_MoneyTotal;
                jsm.Return_MoneyTotal     = Return_MoneyTotal;
                jsm.Using_MoneyTotal      = Using_MoneyTotal;
                jsm.Win_MoneyTotal        = Win_MoneyTotal;

                jsm.PageIndex = pageIndex;
                jsm.PageSize  = PageSize;
                jsm.PageCount = (recordList_real.Count + PageSize - 1) / PageSize;;
                jsm.RowCount  = recordList_real.Count;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(jsm);
        }