//Retrieve all the member customers Net Holdings for Group Dashboard
        public DataSet GetGrpAssetNetHoldings(int CustomerId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  grpNetHoldings;

            try
            {
                grpNetHoldings = assetDao.GetGrpAssetNetHoldings(CustomerId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AssetBo.cs:GetGrpAssetNetHoldings()");

                object[] objects = new object[1];
                objects[0] = CustomerId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(grpNetHoldings);
        }
        public DataSet GetPortfolioAssetAggregateCurrentValues(int PortfolioId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  aggrCurrentValues;

            try
            {
                aggrCurrentValues = assetDao.GetPortfolioAssetAggregateCurrentValues(PortfolioId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AssetBo.cs:GetPortfolioAssetAggregateCurrentValues()");

                object[] objects = new object[1];
                objects[0] = PortfolioId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(aggrCurrentValues);
        }
        public DataSet GetAssetMaturityDates(int portfolioId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  getAssetMaturityDatesDs;

            try
            {
                getAssetMaturityDatesDs = assetDao.GetAssetMaturityDates(portfolioId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetAssetMaturityDates()");
                object[] objects = new object[1];
                objects[0]   = portfolioId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(getAssetMaturityDatesDs);
        }
        public DataSet GetNetIncomeSummary(int PortfolioId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  dsNetIncomeSummary;

            try
            {
                dsNetIncomeSummary = assetDao.GetNetIncomeSummary(PortfolioId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AssetBo.cs:GetNetIncomeSummary()");

                object[] objects = new object[1];
                objects[0] = PortfolioId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(dsNetIncomeSummary);
        }
        public DataTable GetFrequencyCode(string path)
        {
            AssetDao  assetDao = new AssetDao();
            DataTable dt;

            try
            {
                dt = assetDao.GetFrequencyCode(path);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetFrequencyCode()");
                object[] objects = new object[1];
                objects[0]   = path;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(dt);
        }
        public DataSet GetPrevUlipPlanCode(int UlipSubPlanCode)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  getPrevUlipPlanDs;

            try
            {
                getPrevUlipPlanDs = assetDao.GetPrevUlipPlanCode(UlipSubPlanCode);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetPrevUlipPlanCode()");
                object[] objects = new object[1];
                objects[0]   = UlipSubPlanCode;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(getPrevUlipPlanDs);
        }
        public DataSet GetAssetInstrumentSubSubCategory(string groupCode, string instrumentCategory, string instrumentSubCategory)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  assetSubSubCategories;

            try
            {
                assetSubSubCategories = assetDao.GetAssetInstrumentSubSubCategory(groupCode, instrumentCategory, instrumentSubCategory);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetAssetInstrumentSubSubCategory()");
                object[] objects = new object[3];
                objects[0]   = groupCode;
                objects[1]   = instrumentCategory;
                objects[2]   = instrumentSubCategory;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(assetSubSubCategories);
        }
        public DataSet GetAdvisorRM_All_AssetAgr(int advisorId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  ds       = new DataSet();

            try
            {
                ds = assetDao.GetAdvisorRM_All_AssetAgr(advisorId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetAdvisorRM_All_AssetAgr()");
                object[] objects = new object[1];
                objects[0]   = advisorId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(ds);
        }
        public DataSet GetAdviserBranchMF_EQ_In_AggregateCurrentValues(int advisorId, out int Count, int currentPage, out double total)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  ds       = new DataSet();

            try
            {
                ds = assetDao.GetAdviserBranchMF_EQ_In_AggregateCurrentValues(advisorId, out Count, currentPage, out total);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetAdviserBranchMF_EQ_In_AggregateCurrentValues()");
                object[] objects = new object[1];
                objects[0]   = advisorId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(ds);
        }
Beispiel #10
0
 public string Add(Asset form)
 {
     AssetDao dao = new AssetDao();
     form.IsDeleted = 0;
     form.Enabled = 1;
     return dao.Add(form);
 }
        public DataSet GetAssetOwnerShip(int AssetId, string AssetGroupCode, int customerId, int associateId, Int16 IsMainCustomer)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  getAssetOwnerShipDs;

            try
            {
                getAssetOwnerShipDs = assetDao.GetAssetOwnerShip(AssetId, AssetGroupCode, customerId, associateId, IsMainCustomer);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetAssetOwnerShip()");
                object[] objects = new object[4];
                objects[0]   = AssetId;
                objects[1]   = AssetGroupCode;
                objects[2]   = customerId;
                objects[3]   = associateId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(getAssetOwnerShipDs);
        }
        /// <summary>
        /// Get Absolute return value for all type of asset category
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="portfolioId"></param>
        /// <returns></returns>
        public DataSet GetAbsoluteReturnForAllAssetType(int customerId, int portfolioId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  dsGetAbsoluteReturn;

            try
            {
                dsGetAbsoluteReturn = assetDao.GetAbsoluteReturnForAllAssetType(customerId, portfolioId);
            }
            catch (BaseApplicationException Ex)
            {
                throw (Ex);
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AssetBo.cs:GetAbsoluteReturnForAllAssetType()");
                object[] objects = new object[2];
                objects[0]   = customerId;
                objects[1]   = portfolioId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(dsGetAbsoluteReturn);
        }
        public DataSet GetAssetGroups()
        {
            AssetDao assetDao = new AssetDao();
            DataSet  assetGroupsDs;

            try
            {
                assetGroupsDs = assetDao.GetAssetGroups();
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AssetBo.cs:GetAssetInstrumentCategory()");


                object[] objects = new object[1];

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(assetGroupsDs);
        }
Beispiel #14
0
        public string Add(Asset form)
        {
            AssetDao dao = new AssetDao();

            form.IsDeleted = 0;
            form.Enabled   = 1;
            return(dao.Add(form));
        }
Beispiel #15
0
 public static void Clear()
 {
     if (AssetDao.Clear() > 0)
     {
         Log.Information("清理资产数据成功");
     }
     else
     {
         Log.Warning("清理资产数据失败");
     }
 }
Beispiel #16
0
        // GET /api/asset/1
        public Asset GetAsset(string id)
        {
            var asset = AssetDao.ReadFromFile().SingleOrDefault(c => Equals(c.Id, id));

            if (asset == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(asset);
        }
Beispiel #17
0
        public IEnumerable <Asset> GetAsset(Group group)
        {
            var asset = AssetDao.ReadFromFile().Where(a => a.Group == group);

            if (asset == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(asset);
        }
        public DataSet GetSubCategoryPieChartValue(int portfolioId, int adviserId)
        {
            AssetDao assetDao = new AssetDao();
            DataSet  dsSubCategoryPieChartValue;

            try
            {
                dsSubCategoryPieChartValue = assetDao.GetSubCategoryPieChartValue(portfolioId, adviserId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            return(dsSubCategoryPieChartValue);
        }
Beispiel #19
0
        public IHttpActionResult DeleteAsset(string id)
        {
            var list        = AssetDao.ReadFromFile().ToList();
            var assetInFile = list.SingleOrDefault(c => Equals(c.Id, id));

            if (assetInFile == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            list.Remove(assetInFile);

            AssetDao.WriteToFile(list);
            return(Ok());
        }
        public double GetCustomerPortfolioLiability(int portfolioId)
        {
            double               liabilityValue    = 0;
            AssetDao             assetDao          = new AssetDao();
            Calculator           calculator        = new Calculator();
            List <LiabilitiesVo> listLiabilitiesVo = new List <LiabilitiesVo>();
            LiabilitiesVo        liabilityVo       = new LiabilitiesVo();

            try
            {
                listLiabilitiesVo = assetDao.GetCustomerPortfolioLiability(portfolioId);
                for (int i = 0; i < listLiabilitiesVo.Count; i++)
                {
                    liabilityVo = new LiabilitiesVo();
                    liabilityVo = listLiabilitiesVo[i];
                    if (liabilityVo.PaymentOptionCode == 1)
                    {
                        liabilityValue = liabilityValue + calculator.GetLoanOutstanding(liabilityVo.CompoundFrequency, liabilityVo.LoanAmount, liabilityVo.InstallmentStartDate, liabilityVo.InstallmentEndDate, 1, liabilityVo.LumpsumRepaymentAmount, liabilityVo.NoOfInstallments);
                    }
                    else if (liabilityVo.PaymentOptionCode == 2)
                    {
                        liabilityValue = liabilityValue + calculator.GetLoanOutstanding(liabilityVo.FrequencyCodeEMI, liabilityVo.LoanAmount, liabilityVo.InstallmentStartDate, liabilityVo.InstallmentEndDate, 2, liabilityVo.EMIAmount, liabilityVo.NoOfInstallments);
                    }
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AssetBo.cs:GetCustomerPortfolioLiability(int portfolioId)");

                object[] objects = new object[1];
                objects[0] = portfolioId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(liabilityValue);
        }
Beispiel #21
0
        public Asset Save(Asset asset)
        {
            AssetDao dao = new AssetDao();
            Asset    a   = null;

            if (string.IsNullOrEmpty(asset.ID))
            {
                asset.Enabled   = 1;
                asset.IsDeleted = 0;
                dao.Add(asset);
                a = asset;
            }
            else
            {
                a = dao.Query(new AssetQueryForm
                {
                    ID = asset.ID,
                }).FirstOrDefault();
                if (a != null)
                {
                    dao.Update(new AssetUpdateForm
                    {
                        Entity = new Asset
                        {
                            Usage       = asset.Usage,
                            Address     = asset.Address,
                            Area        = asset.Area,
                            RegPrice    = asset.RegPrice,
                            LastUpdator = asset.LastUpdator,
                            Remark      = asset.Remark,
                        },
                        AssetQueryForm = new AssetQueryForm {
                            ID = a.ID, Enabled = 1
                        },
                    });
                }
                else
                {
                    asset.Enabled   = 1;
                    asset.IsDeleted = 0;
                    dao.Add(asset);
                    a = asset;
                }
            }
            return(a);
        }
Beispiel #22
0
 public Asset Save(Asset asset)
 {
     AssetDao dao = new AssetDao();
     Asset a = null;
     if (string.IsNullOrEmpty(asset.ID))
     {
         asset.Enabled = 1;
         asset.IsDeleted = 0;
         dao.Add(asset);
         a = asset;
     }
     else
     {
         a = dao.Query(new AssetQueryForm
         {
             ID = asset.ID,
         }).FirstOrDefault();
         if (a != null)
         {
             dao.Update(new AssetUpdateForm
             {
                 Entity = new Asset
                 {
                     Usage = asset.Usage,
                     Address = asset.Address,
                     Area = asset.Area,
                     RegPrice = asset.RegPrice,
                     LastUpdator = asset.LastUpdator,
                     Remark = asset.Remark,
                 },
                 AssetQueryForm = new AssetQueryForm { ID = a.ID, Enabled = 1 },
             });
         }
         else
         {
             asset.Enabled = 1;
             asset.IsDeleted = 0;
             dao.Add(asset);
             a = asset;
         }
     }
     return a;
 }
Beispiel #23
0
        public IHttpActionResult UpdateAssetCount(AssetPatchRequest request)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var list        = AssetDao.ReadFromFile().ToList();
            var assetInFile = list.SingleOrDefault(c => Equals(c.Id, request.Id));

            if (assetInFile == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            list.Remove(assetInFile);
            assetInFile.Count = request.Count;
            list.Add(assetInFile);
            AssetDao.WriteToFile(list);
            return(Ok());
        }
Beispiel #24
0
        public bool Delete(AssetQueryForm form)
        {
            AssetDao dao = new AssetDao();

            return(dao.Delete(form));
        }
Beispiel #25
0
        public bool Update(AssetUpdateForm form)
        {
            AssetDao dao = new AssetDao();

            return(dao.Update(form));
        }
Beispiel #26
0
 public bool Delete(AssetQueryForm form)
 {
     AssetDao dao = new AssetDao();
     return dao.Delete(form);
 }
        // GET: Asset
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            ViewBag.CurrentSort = sortOrder;

            ViewBag.NameSortParm       = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.GroupSortParm      = sortOrder == "group_asc" ? "group_desc" : "group_asc";
            ViewBag.PriceSortParm      = sortOrder == "price_asc" ? "price_desc" : "price_asc";
            ViewBag.CountSortParm      = sortOrder == "count_asc" ? "count_desc" : "count_asc";
            ViewBag.TotalPriceSortParm = sortOrder == "total_asc" ? "total_desc" : "total_asc";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var list = AssetDao.ReadFromFile();

            // Search box filtering
            if (!String.IsNullOrEmpty(searchString))
            {
                list = list.Where(s => s.Name.ToUpper().Contains(searchString.ToUpper()) ||
                                  s.Group.ToString().ToUpper().Contains(searchString.ToUpper()) ||
                                  s.Id.ToUpper().Contains(searchString));
            }

            // Sorting
            switch (sortOrder)
            {
            case "price_asc":
                list = list.OrderBy(s => s.UnitPrice);
                break;

            case "price_desc":
                list = list.OrderByDescending(s => s.UnitPrice);
                break;

            case "count_asc":
                list = list.OrderBy(s => s.Count);
                break;

            case "count_desc":
                list = list.OrderByDescending(s => s.Count);
                break;

            case "total_asc":
                list = list.OrderBy(s => s.TotalValue);
                break;

            case "total_desc":
                list = list.OrderByDescending(s => s.TotalValue);
                break;

            case "group_asc":
                list = list.OrderBy(s => s.Group);
                break;

            case "group_desc":
                list = list.OrderByDescending(s => s.Group);
                break;

            case "name_desc":
                list = list.OrderByDescending(s => s.Name);
                break;

            default:
                list = list.OrderBy(s => s.Name);
                break;
            }

            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            return(View(list.ToPagedList(pageNumber, pageSize)));
        }
Beispiel #28
0
 public List<Asset> Query(AssetQueryForm form)
 {
     AssetDao dao = new AssetDao();
     form.IsDeleted = 0;
     return dao.Query(form);
 }
Beispiel #29
0
 // GET /api/asset
 public IEnumerable <Asset> GetAsset()
 {
     return(AssetDao.ReadFromFile());
 }
Beispiel #30
0
        public string Save(Project project, List <Asset> assets, List <Customer> buyers, List <Customer> sellers, List <Customer> thirdpart,
                           List <Guarantor> Guarantor, List <CreditReceiverInfo> creditInfo, string userid)
        {
            #region 初始化变量
            ISqlMapper            mapper      = Common.GetMapperFromSession();
            ProjectDao            projectdao  = new ProjectDao(mapper);
            AssetDao              assetdao    = new AssetDao(mapper);
            Asset_ProjectDao      apdao       = new Asset_ProjectDao(mapper);
            Customer_ProjectDao   cpdao       = new Customer_ProjectDao(mapper);
            CustomerDao           customerdao = new CustomerDao(mapper);
            Customer_AssetDao     cadao       = new Customer_AssetDao(mapper);
            CreditReceiverInfoDao cridao      = new CreditReceiverInfoDao(mapper);
            AssetBLL              assetbll    = new AssetBLL();
            CustomerBLL           customerbll = new CustomerBLL();
            #endregion

            #region 处理项目信息
            DateTime createstart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
            DateTime createend   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
            if (string.IsNullOrEmpty(project.Name))
            {
                int index = projectdao.QueryMaxProjectIndex(new ProjectQueryForm {
                    CreateTime_Start = createstart, CreateTime_End = createend
                });
                string code = DateTime.Now.ToString("yyMMdd") + (index + 1).ToString();
                project.Name  = code;
                project.Index = index + 1;
            }
            project.Creator   = project.LastUpdator = userid;
            project.IsDeleted = 0;
            var projecttemp = projectdao.Query(new ProjectQueryForm {
                ID = project.ID
            }).FirstOrDefault();
            if (projecttemp == null)
            {
                projectdao.Add(project);
            }
            else
            {
                projectdao.Update(new ProjectUpdateForm
                {
                    Entity           = project,
                    ProjectQueryForm = new ProjectQueryForm {
                        ID = project.ID
                    },
                });
            }
            cpdao.Delete(new Customer_ProjectQueryForm {
                ProjectID = project.ID
            });
            cadao.Delete(new Customer_AssetQueryForm {
                ProjectID = project.ID
            });
            apdao.Delete(new Asset_ProjectQueryForm {
                ProjectID = project.ID
            });
            #endregion

            #region 处理房产信息
            if (assets != null)
            {
                foreach (var asset in assets)
                {
                    asset.Creator = userid;
                    var a = assetbll.Save(asset);
                    //处理房产和公权人
                    foreach (var j in asset.Joint)
                    {
                        var c = customerbll.Save(new Customer {
                            Creator      = userid,
                            Name         = j.Name,
                            IdentityCode = j.IdentityCode,
                            Phone        = j.Phone,
                        });
                        cadao.Add(new Customer_Asset
                        {
                            AssetID    = a.ID,
                            CustomerID = c.ID,
                            ProjectID  = project.ID,
                            Type       = j.JointType,
                        });
                    }
                    //处理房产和项目关系
                    Asset_Project ap = new Asset_Project
                    {
                        AssetID   = a.ID,
                        ProjectID = project.ID,
                    };
                    apdao.Add(ap);
                }
            }
            #endregion

            #region 处理客户信息
            ProcessCustomer(buyers, customerdao, cpdao, project.ID, userid, CustomerType.Buyer);
            ProcessCustomer(sellers, customerdao, cpdao, project.ID, userid, CustomerType.Seller);
            ProcessCustomer(thirdpart, customerdao, cpdao, project.ID, userid, CustomerType.ThirdParty);
            #endregion

            #region 处理共权人信息
            if (Guarantor != null)
            {
                foreach (Guarantor g in Guarantor)
                {
                    g.Creator = userid;
                    var c = customerbll.Save(g);
                    Customer_Project cp = new Customer_Project
                    {
                        CustomerID = c.ID,
                        ProjectID  = project.ID,
                        Type       = (int)CustomerType.Guarantor,
                    };
                    cpdao.Add(cp);
                    foreach (var asset in g.Assets)
                    {
                        asset.Creator = userid;
                        var            a  = assetbll.Save(asset);
                        Customer_Asset ca = new Customer_Asset
                        {
                            AssetID    = a.ID,
                            CustomerID = c.ID,
                            ProjectID  = project.ID,
                            Type       = (int)CustomerAssetType.Guarantor,
                        };
                        cadao.Add(ca);
                    }
                }
            }
            #endregion

            #region 处理贷款接收账号信息
            cridao.Delete(new CreditReceiverInfoQueryForm {
                ProjectID = project.ID
            });
            if (creditInfo != null)
            {
                foreach (var c in creditInfo)
                {
                    c.ProjectID = project.ID;
                    cridao.Add(c);
                }
            }
            #endregion

            return(project.ID);
        }
Beispiel #31
0
        public static async Task <AssetAnalysisModel> Analyse()
        {
            decimal total = 0, stock = 0, bond = 0, cash = 0;
            var     funds     = new List <FundAnalysisModel>();
            var     positions = AssetDao.GetAllPositions();

            foreach (var item in positions)
            {
                if (item.Share <= 0)
                {
                    continue;
                }

                var nav = (await DataService.GetFundNavs(item.FundCode))?.LastOrDefault();
                if (nav == null)
                {
                    Log.Warning($"{item.FundCode} 无法获取到净值数据,无法进行数据分析");
                    continue;
                }
                var config = DataService.GetFundAssetConfigs(item.FundCode)?.LastOrDefault();
                if (config == null)
                {
                    Log.Warning($"{item.FundCode} 无法获取到资产配置,无法进行数据分析");
                    continue;
                }
                Log.Information($"{item.FundCode} 最新的净值日期为 {nav.Date}");
                Log.Information($"{item.FundCode} 最新的报告期为 {config.Date}");

                var net = item.Share * nav.UnitNav;
                total += net;
                stock += net * config.StockRatio;
                bond  += net * config.BondRatio;
                cash  += net * config.CashRatio;

                var info = DataService.GetFundInfo(item.FundCode);
                funds.Add(new FundAnalysisModel
                {
                    FundCode           = item.FundCode,
                    FundName           = info?.FundName,
                    AvgCost            = item.AvgCost,
                    FundNav            = nav.UnitNav,
                    NavDate            = nav.Date,
                    PositionProfit     = item.Share * (nav.UnitNav - item.AvgCost),
                    MarketValue        = item.Share * nav.UnitNav,
                    PositionProfitRate = nav.UnitNav / item.AvgCost - 1,
                    Share     = item.Share,
                    Abilities = await Ability.AnalyseFund(item.FundCode)
                });
            }

            var cost = funds.Sum(x => x.Share * x.AvgCost);

            AssetDao.UpsertAssetSnapshot(new AssetSnapshot
            {
                Date       = DateTime.Now.Date,
                TotalAsset = total,
                TotalCost  = cost,
                BondAsset  = bond,
                CashAsset  = cash,
                StockAsset = stock
            });
            return(new AssetAnalysisModel
            {
                TotalAsset = total,
                TotalCost = cost,
                BondAsset = bond,
                CashAsset = cash,
                StockAsset = stock,
                Funds = funds.OrderByDescending(x => x.PositionProfitRate).ToList(),
                LastSnapshot = AssetDao.GetAssetSnapshot(DateTime.Now.Date.AddDays(-1))
            });
        }
Beispiel #32
0
 public static bool RemoveFundPosition(string fundCode) => AssetDao.DeleteFundPosition(fundCode) > 0;
Beispiel #33
0
 public bool Update(AssetUpdateForm form)
 {
     AssetDao dao = new AssetDao();
     return dao.Update(form);
 }
Beispiel #34
0
        public static bool AddFundPosition(string fundCode, decimal avgCost, decimal share)
        {
            if (string.IsNullOrWhiteSpace(fundCode))
            {
                Log.Warning("Asset.AddFundPosition 指令 fundcode 不能为空");
                return(false);
            }
            if (avgCost <= 0)
            {
                Log.Warning("Asset.AddFundPosition 指令 avgCost 必须为正数");
                return(false);
            }

            var position = AssetDao.GetFundPosition(fundCode);

            if (position == null)
            {
                if (share <= 0)
                {
                    Log.Warning("Asset.AddFundPosition 指令 share 必须为正数");
                    return(false);
                }

                if (AssetDao.AddFundPosition(new Entities.FundPosition
                {
                    FundCode = fundCode,
                    AvgCost = avgCost,
                    Share = share
                }) > 0)
                {
                    Log.Information($"添加持仓成功,fundcode: {fundCode}, avgCost: {avgCost}, share: {share}");
                    return(true);
                }
                else
                {
                    Log.Warning($"添加持仓失败,fundcode: {fundCode}, avgCost: {avgCost}, share: {share}");
                    return(false);
                }
            }
            else
            {
                if (share > 0)
                {
                    var amount = position.AvgCost * position.Share + avgCost * share;
                    position.Share  += share;
                    position.AvgCost = amount / position.Share;
                }
                else
                {
                    if (position.Share + share < 0)
                    {
                        Log.Warning($"添加持仓失败,fundcode: {fundCode}, avgCost: {avgCost}, share: {share}, 减仓份额大于现有份额 {position.Share}");
                        return(false);
                    }
                    var amount = position.AvgCost * position.Share + avgCost * share;
                    position.Share  += share;
                    position.AvgCost = amount / position.Share;
                }
                if (AssetDao.UpdateFundPosition(position) > 0)
                {
                    Log.Information($"添加持仓成功,fundcode: {fundCode}, avgCost: {avgCost}, share: {share}, 现有份额: {position.Share}, 摊薄成本: {position.AvgCost}");
                    return(true);
                }
                else
                {
                    Log.Warning($"添加持仓失败,fundcode: {fundCode}, avgCost: {avgCost}, share: {share}");
                    return(false);
                }
            }
        }