示例#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 FinancingRepoApplyIdCompleteCancel(string userStr, int repoApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

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

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    RepoApply repoApply = result.ReturnValue as RepoApply;

                    result = repoApplyDAL.CompleteCancel(user, repoApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    //完成撤销赎回申请单明细
                    RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    result = repoApplyDetailDAL.LoadByRepoApplyId(user, repoApplyId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result.Message;

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

                    foreach (RepoApplyDetail detail in details)
                    {
                        result = repoApplyDetailDAL.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}", "FinancingRepoApplyIdCompleteCancel", e.Message);
                return e.Message;
            }
        }