//public static readonly InterfaceEventLogRepository LogRepository = new EventLogRepository();

        /// <summary>
        /// 得到正在发行的产品
        /// </summary>
        /// <returns></returns>
        //public OPM GetAllProducts()
        //{
        //    OPM opm111 = new OPM();
        //    List<OptionsProductModel> lopm = new List<OptionsProductModel>();

        //    IEnumerable<OptionsProduct> iop = OptionsProductRepository.FindAll().Where(p => p.Status == 1);
        //    if (iop != null && iop.Count() != 0)
        //    {
        //        foreach (var item in iop)
        //        {
        //            OptionsProductModel opm = new OptionsProductModel();
        //            opm.addDate = Convert.ToDateTime(item.AddDate).ToString("yyyy-MM-dd HH:mm:ss");
        //            opm.beginDate = Convert.ToDateTime(item.BeginDate).ToString("yyyy-MM-dd HH:mm:ss");
        //            opm.charge = item.Charge;
        //            opm.chargeType = item.ChargeType;
        //            opm.deadline = item.Deadline;
        //            opm.endDate = string.Empty;
        //            opm.callPriceType = item.CallPriceType;
        //            //opm.Margin = item.Margin;
        //            //opm.MarginType = item.MarginType;
        //            opm.maxNum = item.MaxNum;
        //            opm.optionsProductID = item.OptionsProductID;
        //            opm.optionType = item.OptionType;
        //            opm.partnerName = item.PartnerName;
        //            opm.price = item.Price;
        //            opm.priceType = item.PriceType;
        //            opm.amountType = item.AmountType;
        //            opm.productName = item.ProductName;
        //            opm.status = item.Status;
        //            opm.unit = item.Unit;
        //            opm.productDesc = item.ProductDesc;
        //            opm.productDtlDesc = item.ProductDtlDesc;
        //            opm.formula = item.Formula;
        //            opm.productUrl = item.ProductUrl;
        //            opm.contract = item.Contract;
        //            opm.contractChs = item.ContractChs;
        //            List<FallRoleModel> lfrm = new List<FallRoleModel>();
        //            List<FallRole> lfr = FallRoleRepository.FindList(f => f.OptionsProductID == item.OptionsProductID, string.Empty, false).ToList();
        //            if (lfr != null && lfr.Count() != 0)
        //            {
        //                foreach (var fall in lfr)
        //                {
        //                    FallRoleModel frm = new FallRoleModel();
        //                    frm.compensateNum = fall.CompensateNum;
        //                    frm.compensateType = fall.CompensateType;
        //                    frm.createDate = Convert.ToDateTime(fall.CreateDate).ToString("yyyy-MM-dd HH:mm:ss");
        //                    frm.down = fall.Down;
        //                    frm.fallRoleID = fall.FallRoleID;
        //                    frm.fallRoleName = fall.FallRoleName;
        //                    frm.optionsProductID = fall.OptionsProductID;
        //                    frm.partType = fall.PartType;
        //                    frm.topCompensateNum = fall.TopCompensateNum;
        //                    frm.topCompensateType = fall.TopCompensateType;
        //                    frm.up = fall.Up;
        //                    frm.upDownType = fall.UpDownType;
        //                    lfrm.Add(frm);
        //                }
        //            }
        //            opm.fallRole = lfrm;
        //            List<RiseRoleModel> lrrm = new List<RiseRoleModel>();
        //            List<RiseRole> lrr = RiseRoleRepository.FindList(r => r.OptionsProductID == item.OptionsProductID, string.Empty, false).ToList();
        //            if (lrr != null && lrr.Count() != 0)
        //            {
        //                foreach (var rise in lrr)
        //                {
        //                    RiseRoleModel rrm = new RiseRoleModel();
        //                    rrm.createDate = Convert.ToDateTime(rise.CreateDate).ToString("yyyy-MM-dd HH:mm:ss");
        //                    rrm.dividendNum = rise.DividendNum;
        //                    rrm.dividendType = rise.DividendType;
        //                    rrm.down = rise.Down;
        //                    rrm.optionsProductID = rise.OptionsProductID;
        //                    rrm.partType = rise.PartType;
        //                    rrm.riseRoleID = rise.RiseRoleID;
        //                    rrm.riseRoleName = rise.RiseRoleName;
        //                    rrm.topDividendNum = rise.TopDividendNum;
        //                    rrm.topDividendType = rise.TopDividendType;
        //                    rrm.up = rise.Up;
        //                    rrm.upDownType = rise.UpDownType;
        //                    lrrm.Add(rrm);
        //                }
        //            }
        //            opm.riseRole = lrrm;
        //            lopm.Add(opm);
        //        }
        //        opm111.products = lopm;
        //    }

        //    return opm111;
        //}
        //private static object o = new object();
        /// <summary>
        /// 第三方取得期货价格
        /// 异步操作
        /// </summary>
        /// <returns></returns>
        public async Task <HttpResponseMessage> PostFuturePriceByDate(HttpRequestMessage request)
        {
            try
            {
                string loginjson = request.Content.ReadAsStringAsync().Result;
                if (!string.IsNullOrEmpty(loginjson))
                {
                    return(await Task.Run(async() =>
                    {
                        RequestFuturePriceModel json = JsonConvert.DeserializeObject <RequestFuturePriceModel>(DESEncrypt.DesDecrypt(loginjson));
                        ReturnFuturePriceModel RFPM = new ReturnFuturePriceModel();
                        List <RFuturePrice> LFP = new List <RFuturePrice>();
                        List <DateTime> alldays = GetAllDays(Convert.ToDateTime(json.StartDate), Convert.ToDateTime(json.EndDate));
                        foreach (DateTime day in alldays)
                        {
                            //string sday = day.ToString("yyyy-MM-dd");

                            FuturePrice price = await FuturePriceRepository.FindAsync(p => p.TradeCode == json.Contract && p.Date == day);
                            if (price != null)
                            {
                                LFP.Add(new RFuturePrice {
                                    date = day.ToString("yyyy-MM-dd"), price = price.Price
                                });
                            }
                        }
                        RFPM.datas = LFP;
                        RFPM.result = "1";
                        RFPM.message = string.Empty;
                        string str = DESEncrypt.DesEncrypt(JsonConvert.SerializeObject(RFPM));
                        HttpResponseMessage result = new HttpResponseMessage {
                            Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                        };
                        return result;
                    }));
                }
                else
                {
                    string str = DESEncrypt.DesEncrypt("{\"result\":\"0\",\"message\":\"json为空\"}");
                    HttpResponseMessage result = new HttpResponseMessage {
                        Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                    };
                    return(result);
                }
            }
            catch (Exception ex)
            {
                string str = DESEncrypt.DesEncrypt("{\"result\":\"0\",\"message\":\"" + ex.Message + "\"}");
                HttpResponseMessage result = new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                };
                LogRepository.Add(new EventLog()
                {
                    Name = "第三方", Date = DateTime.Now.ToLocalTime(), Event = "取得期货价格失败" + ex.Message
                });
                return(result);
            }
        }
Пример #2
0
 public ActionResult AddUser(User user)
 {
     try
     {
         if (user != null)
         {
             user.Date         = DateTime.Now.ToLocalTime().ToString();
             user.UserPassword = EncryptUtils.Base64Encrypt(user.UserPassword);
             if (UserRepository.Add(user) != null)
             {
                 LogRepository.Add(new EventLog()
                 {
                     Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "新增用户成功"
                 });
                 return(Json(new
                 {
                     Success = true,
                     Msg = "用户添加成功。"
                 }));
             }
         }
         return(Json(new
         {
             Success = false,
             Msg = "添加失败,请重新提交。"
         }));
     }
     catch (Exception ex)
     {
         LogRepository.Add(new EventLog()
         {
             Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "新增用户失败" + ex.Message
         });
         return(Json(new { Success = false,
                           Msg = "添加失败," + ex.Message }));
     }
 }
Пример #3
0
 public ActionResult AddTemplateAction(Brochure model)
 {
     try
     {
         if (model != null)
         {
             model.TempDate = DateTime.Now.ToLocalTime();
             model.IsTemp   = true;
             if (BrochureRepository.Add(model) != null)
             {
                 LogRepository.Add(new EventLog()
                 {
                     Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "新增宣传册模板事件成功"
                 });
                 return(Json(new
                 {
                     Success = true
                 }));
             }
         }
         return(Json(new
         {
             Success = false
         }));
     }
     catch (Exception ex)
     {
         LogRepository.Add(new EventLog()
         {
             Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "新增宣传册模板事件失败" + ex.Message
         });
         return(Json(new
         {
             Success = false
         }));
     }
 }