Пример #1
0
        public Common.ResultModel GetEmailInfo(Common.UserModel user)
        {
            Common.ResultModel result = new Common.ResultModel();
            StringBuilder sb = new StringBuilder();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    switch (m_finType)
                    {
                        case FinType.质押:
                            sb.Clear();
                            DAL.PledgeApplyDAL pledgeApplyDAL = new DAL.PledgeApplyDAL();
                            result = pledgeApplyDAL.Get(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply;
                            if (pledgeApply == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取质押申请单失败";
                                return result;
                            }

                            NFMT.Data.Model.Bank bank = NFMT.Data.BasicDataProvider.Banks.SingleOrDefault(a => a.BankId == pledgeApply.FinancingBankId);
                            sb.Append(GetBanInfo(bank));

                            DAL.PledgeApplyCashDetailDAL pledgeApplyCashDetailDAL = new DAL.PledgeApplyCashDetailDAL();
                            result = pledgeApplyCashDetailDAL.LoadByPledgeApplyId(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;

                            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

                            foreach (System.Data.DataRow dr in dt.Rows)
                            {
                                sb.Append("<span>");
                                sb.AppendFormat("We short {0} lots Copper at price  USD{1}/MT, prompt date: {2} under contract {3};", dr["Hands"], dr["Price"], Convert.ToDateTime(dr["ExpiringDate"]).ToString("MMMM dd, yyyy", new CultureInfo("en-us")), dr["StockContractNo"]);
                                sb.Append("</span>");
                                sb.Append("<br>");
                            }

                            break;
                        case FinType.赎回:
                            sb.Clear();
                            DAL.RepoApplyDAL repoApplyDAL = new DAL.RepoApplyDAL();
                            result = repoApplyDAL.GetByPledgeApplyId(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;
                            int bankId = (int)result.ReturnValue;

                            bank = NFMT.Data.BasicDataProvider.Banks.SingleOrDefault(a => a.BankId == bankId);
                            sb.Append(GetBanInfo(bank));

                            DAL.RepoApplyDetailDAL repoApplyDetailDAL = new DAL.RepoApplyDetailDAL();
                            result = repoApplyDetailDAL.LoadByRepoApplyId(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;

                            dt = result.ReturnValue as System.Data.DataTable;

                            foreach (System.Data.DataRow dr in dt.Rows)
                            {
                                sb.Append("<span>");
                                sb.AppendFormat("We long {0} lots Copper at price  USD{1}/MT, prompt date: {2} under contract {3};", dr["Hands"], dr["Price"], Convert.ToDateTime(dr["ExpiringDate"]).ToString("MMMM dd, yyyy", new CultureInfo("en-us")), dr["StockContractNo"]);
                                sb.Append("</span>");
                                sb.Append("<br>");
                            }
                            break;
                        default:
                            break;
                    }

                    if (result.ResultStatus == 0)
                    {
                        scope.Complete();
                        result.ReturnValue = sb.ToString();
                    }
                }
            }
            catch(Exception e)
            {
                result.ResultStatus = -1;
                result.Message = e.Message;
                result.ReturnValue = sb.Clear();
            }

            return result;
        }
Пример #2
0
        public string FinancingPledgeApplyIdCompleteCancel(string userStr, int pledgeApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                UserModel user = serializer.Deserialize<UserModel>(userStr);

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    PledgeApply pledgeApply = result.ReturnValue as PledgeApply;

                    result = pledgeApplyDAL.CompleteCancel(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    //完成撤销质押申请单实货明细
                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    result = pledgeApplyStockDetailDAL.LoadByPledgeApplyId(user, pledgeApplyId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    List<PledgeApplyStockDetail> stockDetails = result.ReturnValue as List<PledgeApplyStockDetail>;
                    if (stockDetails == null || !stockDetails.Any())
                        return "获取质押申请单实货明细失败";

                    foreach (PledgeApplyStockDetail detail in stockDetails)
                    {
                        result = pledgeApplyStockDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result.Message;
                    }

                    //完成撤销质押申请单头寸明细
                    PledgeApplyCashDetailDAL pledgeApplyCashDetailDAL = new PledgeApplyCashDetailDAL();
                    result = pledgeApplyCashDetailDAL.LoadByPledgeApplyId(user, pledgeApplyId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    List<PledgeApplyCashDetail> cashDetails = result.ReturnValue as List<PledgeApplyCashDetail>;
                    if (cashDetails == null || !cashDetails.Any())
                        return "获取质押申请单头寸明细失败";

                    foreach (PledgeApplyCashDetail detail in cashDetails)
                    {
                        result = pledgeApplyCashDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result.Message;
                    }

                    if (result.ResultStatus == 0)
                    {
                        scope.Complete();
                        return "执行完成撤销 成功";
                    }
                    else
                        return "执行完成撤销 失败";
                }
            }
            catch (Exception e)
            {
                this.log.ErrorFormat("FinService出错,出错方法:{0},{1}", "FinancingPledgeApplyIdCompleteCancel", e.Message);
                return e.Message;
            }
        }