コード例 #1
0
ファイル: UserBusiness.cs プロジェクト: AuctusProject/Beta
        public FollowAsset FollowUnfollowAsset(int assetId, FollowActionType followActionType)
        {
            var user = GetValidUser();

            var asset = AssetBusiness.GetById(assetId);

            if (!asset.Enabled)
            {
                throw new BusinessException("Invalid asset.");
            }

            var followAsset = FollowAssetBusiness.Create(user.Id, assetId, followActionType);

            if (user.FollowedAssets != null)
            {
                if (followActionType == FollowActionType.Follow)
                {
                    user.FollowedAssets.Add(assetId);
                }
                else
                {
                    user.FollowedAssets.Remove(assetId);
                }

                SetUserToCache(user);
            }
            return(followAsset);
        }
コード例 #2
0
 private void setGridSource()
 {
     if (txtFromDate.Value.ToString() != "" && txtToDate.Value.ToString() != "")
     {
         AssetBusiness asset = new AssetBusiness();
         DataTable     dtnotExistRecords = new DataTable();
         var           dtAsset = asset.GetFileCount(txtFromDate.Value.ToString(), txtToDate.Value.ToString(), cmbTerm.SelectedItem.Value);
         string        date, path;
         dtnotExistRecords.Columns.Add("Class_Code");
         dtnotExistRecords.Columns.Add("term");
         dtnotExistRecords.Columns.Add("FileDate");
         foreach (DataRow dr in dtAsset.Rows)
         {
             date = dr["FileDate"].ToString().Replace('/', '-');
             path = Server.MapPath("../content/" + dr["Term"].ToString() + "/" + dr["Class_Code"].ToString() + "/" + date);
             if (Directory.Exists(path) == true)
             {
                 DirectoryInfo di = new DirectoryInfo(path);
                 // Get a reference to each file in that directory.
                 FileInfo[] fiArrZip = di.GetFiles("*.zip");
                 if ((di.GetFiles("*.mp3").Count() == 0 || di.GetFiles("*.avi").Count() == 0 || di.GetFiles("*.flv").Count() == 0) && fiArrZip.Count() == 0)
                 {
                     DataRow drNotExistRecordsrow = dtnotExistRecords.NewRow();
                     drNotExistRecordsrow["Class_Code"] = dr["Class_Code"].ToString();
                     drNotExistRecordsrow["term"]       = dr["term"].ToString();
                     drNotExistRecordsrow["FileDate"]   = dr["FileDate"].ToString();
                     dtnotExistRecords.Rows.Add(drNotExistRecordsrow);
                 }
             }
         }
         grd_NonExistFolder.DataSource = dtnotExistRecords;
     }
 }
コード例 #3
0
        protected void grd_ViewFiles_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            List <CMSViewFilesDTO> cmsvf    = new List <CMSViewFilesDTO>();
            AssetBusiness          adobebus = new AssetBusiness();

            cmsvf = adobebus.GetAllAssetByTermAndDaneshId(DDL_Term.SelectedValue, 0);
            grd_ViewFiles.DataSource = cmsvf;
        }
コード例 #4
0
        protected void DDL_Term_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            List <CMSViewFilesDTO> cmsvf    = new List <CMSViewFilesDTO>();
            AssetBusiness          adobebus = new AssetBusiness();

            cmsvf = adobebus.GetAllAssetByTermAndDaneshId(DDL_Term.SelectedValue, 0);
            grd_ViewFiles.DataSource = cmsvf;
            grd_ViewFiles.DataBind();
        }
コード例 #5
0
ファイル: Test.cs プロジェクト: adolphEat/UnityRefrence
    private void Start()
    {
        assetfiles    = new AssetFileMgr(this);
        assetbusiness = new AssetBusiness();

        object obj = assetbusiness.SyncLoadAsset <GameObject>("cube");

        GameObject.Instantiate <GameObject>((GameObject)obj,
                                            Vector3.zero,
                                            Quaternion.identity);
    }
コード例 #6
0
        public List <Distribution> List(IEnumerable <int> projectionIds)
        {
            if (projectionIds.Count() == 0)
            {
                return(new List <Distribution>());
            }

            var distributions = Data.List(projectionIds);
            var assets        = AssetBusiness.ListAssets();

            distributions.ForEach(c => c.Asset = assets.Single(a => a.Id == c.AssetId));
            return(distributions);
        }
コード例 #7
0
        public AdvisorResponse GetAdvisorData(int advisorId)
        {
            AdvisorRanking advisor = null;
            List <DomainObjects.Asset.Asset> assets            = null;
            List <FollowAdvisor>             advisorsFollowers = null;
            AdvisorRankingHistory            advisorHistory    = null;

            Parallel.Invoke(() => advisor           = AdvisorRankingBusiness.GetAdvisorFullData(advisorId),
                            () => assets            = AssetBusiness.ListAssets(false),
                            () => advisorsFollowers = FollowAdvisorBusiness.ListFollowers(new int[] { advisorId }, false),
                            () => advisorHistory    = AdvisorRankingHistoryBusiness.GetLastAdvisorRankingAndProfit(advisorId));

            return(AdvisorRankingBusiness.GetAdvisorResponse(advisor, advisor.TotalAdvisors, advisorsFollowers, GetLoggedUser(), assets, advisorHistory, null, null));
        }
コード例 #8
0
 public void UpdateAllAssetsValues()
 {
     AssetBusiness.UpdateAllAssetsValues();
 }
コード例 #9
0
        public async Task UpdateAssetEventsAsync()
        {
            var startDate = Data.GetDateTimeNow().AddDays(-1).Date;

            List <DomainObjects.Asset.Asset> assets     = null;
            List <AssetEventCategory>        categories = null;
            List <AssetEvent> assetEvents = null;
            List <Record>     events      = null;

            Parallel.Invoke(() => assets      = AssetBusiness.ListAssets(true),
                            () => categories  = AssetEventCategoryBusiness.ListCategories(),
                            () => assetEvents = Data.ListAssetEventsWithPagination(startDate, null, null, null, null, null),
                            () => events      = CoinMarketCalBusiness.ListEvents(startDate));

            events = events.OrderBy(c => c.FormattedCreatedDate).ThenBy(c => c.FormattedEventDate).ToList();

            foreach (var e in events)
            {
                bool updateProofImage     = false;
                bool isNewEvent           = false;
                var  linkCategoryToDelete = new List <LinkEventCategory>();
                var  linkCategoryToInsert = new List <LinkEventCategory>();
                var  linkAssetToDelete    = new List <LinkEventAsset>();
                var  linkAssetToInsert    = new List <LinkEventAsset>();

                var coinsId         = e.Coins.Select(c => c.Id).Distinct().ToHashSet();
                var eventAssets     = assets.Where(c => coinsId.Contains(c.CoinMarketCalId)).ToList();
                var categoriesId    = e.Categories.Select(c => c.Id).Distinct().ToHashSet();
                var eventCategories = categories.Where(c => categoriesId.Contains(c.Id)).ToList();

                if (eventAssets.Any())
                {
                    var workingEvent = assetEvents.FirstOrDefault(c => c.ExternalId == e.Id.ToString());
                    if (workingEvent == null)
                    {
                        isNewEvent       = true;
                        updateProofImage = true;
                        workingEvent     = new AssetEvent()
                        {
                            ExternalId   = e.Id.ToString(),
                            CreationDate = Data.GetDateTimeNow()
                        };
                        linkCategoryToInsert = eventCategories.Select(c => new LinkEventCategory()
                        {
                            AssetEventCategoryId = c.Id
                        }).ToList();
                        linkAssetToInsert = eventAssets.Select(c => new LinkEventAsset()
                        {
                            AssetId = c.Id
                        }).ToList();
                    }
                    else
                    {
                        linkCategoryToDelete = workingEvent.LinkEventCategory.Where(c => !eventCategories.Any(a => a.Id == c.AssetEventCategoryId)).ToList();
                        linkAssetToDelete    = workingEvent.LinkEventAsset.Where(c => !eventAssets.Any(a => a.Id == c.AssetId)).ToList();
                        linkCategoryToInsert = eventCategories.Where(c => !workingEvent.LinkEventCategory.Any(a => a.AssetEventCategoryId == c.Id)).Select(c => new LinkEventCategory()
                        {
                            AssetEventCategoryId = c.Id,
                            AssetEventId         = workingEvent.Id
                        }).ToList();
                        linkAssetToInsert = eventAssets.Where(c => !workingEvent.LinkEventAsset.Any(a => a.AssetId == c.Id)).Select(c => new LinkEventAsset()
                        {
                            AssetId      = c.Id,
                            AssetEventId = workingEvent.Id
                        }).ToList();

                        if (workingEvent.Title == e.Title && workingEvent.Description == e.Description && workingEvent.EventDate == e.FormattedEventDate &&
                            workingEvent.ExternalCreationDate == e.FormattedCreatedDate && workingEvent.CanOccurBefore == e.CanOccurBefore &&
                            workingEvent.ReliablePercentage == e.Percentage && workingEvent.Source == e.Source && workingEvent.Proof == e.Proof &&
                            linkCategoryToDelete.Count == 0 && linkAssetToDelete.Count == 0 && linkCategoryToInsert.Count == 0 && linkAssetToInsert.Count == 0)
                        {
                            continue;
                        }

                        updateProofImage = workingEvent.Proof != e.Proof;
                    }

                    UpdateAssetEventData(workingEvent, e);

                    try
                    {
                        using (var transaction = TransactionalDapperCommand)
                        {
                            if (isNewEvent)
                            {
                                transaction.Insert(workingEvent);
                            }
                            else
                            {
                                transaction.Update(workingEvent);
                            }

                            foreach (var linkCategory in linkCategoryToDelete)
                            {
                                transaction.Delete(linkCategory);
                            }
                            foreach (var linkCategory in linkCategoryToInsert)
                            {
                                linkCategory.AssetEventId = workingEvent.Id;
                                transaction.Insert(linkCategory);
                            }

                            foreach (var linkAsset in linkAssetToDelete)
                            {
                                transaction.Delete(linkAsset);
                            }
                            foreach (var linkAsset in linkAssetToInsert)
                            {
                                linkAsset.AssetEventId = workingEvent.Id;
                                transaction.Insert(linkAsset);
                            }

                            transaction.Commit();
                        }
                        if (updateProofImage)
                        {
                            var    fileName    = $"{workingEvent.Id}.png";
                            var    contentType = workingEvent.Proof.ToLower().EndsWith("png") ? "image/png" : workingEvent.Proof.ToLower().EndsWith("pdf") ? "application/pdf" : "image/jpeg";
                            byte[] file;
                            using (var client = new WebClient())
                            {
                                file = client.DownloadData(workingEvent.Proof);
                            }
                            if (!await AzureStorageBusiness.UploadAssetEventFromByteAsync(fileName, file, contentType))
                            {
                                throw new BusinessException($"Error on upload asset event proof image. (Id {workingEvent.Id} - Url {workingEvent.Proof}");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var telemetry = new TelemetryClient();
                        telemetry.TrackEvent($"AssetEventBusiness.UpdateAssetEvents.Id.{e?.Id}");
                        telemetry.TrackException(ex);
                    }
                }
            }
        }
コード例 #10
0
        protected IActionResult ListAssetsDetails()
        {
            var assetResponse = AssetBusiness.ListAssetData();

            return(Ok(assetResponse));
        }
コード例 #11
0
        protected IActionResult ListTrendingAssets(int?listSize)
        {
            var assetResponse = AssetBusiness.ListTrendingAssets(listSize);

            return(Ok(assetResponse));
        }
コード例 #12
0
 protected IActionResult GetAsset(int id)
 {
     return(Ok(AssetBusiness.GetAssetData(id)));
 }
コード例 #13
0
 protected IActionResult ListAssetStatus(int id)
 {
     return(Ok(AssetBusiness.ListAssetStatus(id)));
 }
コード例 #14
0
 protected IActionResult ListAssetBaseData(int id)
 {
     return(Ok(AssetBusiness.ListAssetBaseData(id)));
 }
コード例 #15
0
 protected IActionResult ListAssetsForTerminal()
 {
     return(Ok(AssetBusiness.ListAssetsForTerminal()));
 }
コード例 #16
0
 public List <Asset> ListAssets()
 {
     return(AssetBusiness.ListAssets());
 }
コード例 #17
0
ファイル: PortfolioBusiness.cs プロジェクト: mohnuris/Alpha
        public RiskType GetRisk(double projectionValue, Dictionary <int, double> distribution)
        {
            IEnumerable <DomainObjects.Asset.Asset> assets = AssetBusiness.ListAssets().Where(c => distribution.ContainsKey(c.Id));
            double cryptoAssetsPercentage = assets.Count(c => c.Type == AssetType.Crypto.Value) / assets.Count() * 100.0;

            if (cryptoAssetsPercentage == 0)
            {
                if (projectionValue >= 3)
                {
                    return(RiskType.VeryHigh);
                }
                else if (projectionValue >= 2)
                {
                    return(RiskType.High);
                }
                else if (projectionValue >= 1)
                {
                    return(RiskType.Medium);
                }
                else if (projectionValue >= 0.5)
                {
                    return(RiskType.Low);
                }
                else
                {
                    return(RiskType.VeryLow);
                }
            }
            else if (cryptoAssetsPercentage <= 10)
            {
                if (projectionValue >= 2)
                {
                    return(RiskType.VeryHigh);
                }
                else if (projectionValue >= 1)
                {
                    return(RiskType.High);
                }
                else if (projectionValue >= 0.5)
                {
                    return(RiskType.Medium);
                }
                else
                {
                    return(RiskType.Low);
                }
            }
            else if (cryptoAssetsPercentage <= 30)
            {
                if (projectionValue >= 1)
                {
                    return(RiskType.VeryHigh);
                }
                else if (projectionValue >= 0.5)
                {
                    return(RiskType.High);
                }
                else
                {
                    return(RiskType.Medium);
                }
            }
            else if (cryptoAssetsPercentage <= 50)
            {
                if (projectionValue >= 0.5)
                {
                    return(RiskType.VeryHigh);
                }
                else
                {
                    return(RiskType.High);
                }
            }
            else
            {
                return(RiskType.VeryHigh);
            }
        }
コード例 #18
0
 protected virtual IActionResult UpdateAssetsMarketcap(string api)
 {
     RunAsync(() => AssetBusiness.UpdateCoingeckoAssetsMarketcap());
     return(Ok());
 }
コード例 #19
0
 protected virtual IActionResult ListAssetsFollowedByUser(int id)
 {
     return(Ok(AssetBusiness.ListAssetsFollowedByUser(id)));
 }
コード例 #20
0
 protected virtual IActionResult CreateAssets(string api)
 {
     RunAsync(async() => await AssetBusiness.CreateCoingeckoNotIncludedAssetsAsync());
     return(Ok());
 }
コード例 #21
0
        protected void btn_ShowCount_Click(object sender, EventArgs e)
        {
            AssetBusiness asset   = new AssetBusiness();
            DataTable     dtAsset = new DataTable();

            DataRow dtnotExistRecordsrow = dtnotExistRecords.NewRow();

            if (dtnotExistFolder.Rows.Count > 0)
            {
                dtnotExistFolder.Clear();
            }
            if (dtnotExistRecords.Rows.Count > 0)
            {
                dtnotExistRecords.Clear();
            }
            DataRow dtnotExistFolderRow = dtnotExistFolder.NewRow();
            int     notExist = 0, mp3Count = 0, ExistFolder = 0, NotExistmp3Count = 0, mp3Length = 0, LowLengthCorrect = 0;

            dtAsset          = asset.GetFileCount(date_input_1.Value.ToString(), date_input_2.Value.ToString(), rcb_Term.SelectedValue);
            lblAllCount.Text = dtAsset.Rows.Count.ToString();
            for (int i = 0; i < dtAsset.Rows.Count; i++)
            {
                string d    = dtAsset.Rows[i]["FileDate"].ToString().Replace('/', '-');
                string path = Server.MapPath("../content/" + dtAsset.Rows[i]["Term"].ToString() + "/" + dtAsset.Rows[i]["Class_Code"].ToString() + "/" + d);
                if (Directory.Exists(path) == false)
                {
                    notExist++;
                    dtnotExistFolderRow["Class_Code"] = dtAsset.Rows[i]["Class_Code"].ToString();
                    dtnotExistFolderRow["Session"]    = dtAsset.Rows[i]["Session"].ToString();
                    dtnotExistFolderRow["FileDate"]   = dtAsset.Rows[i]["FileDate"].ToString();
                    dtnotExistFolder.Rows.Add(dtnotExistFolderRow);
                    dtnotExistFolderRow = dtnotExistFolder.NewRow();
                }
                else
                {
                    ExistFolder++;
                    DirectoryInfo di = new DirectoryInfo(path);
                    // Get a reference to each file in that directory.
                    FileInfo[] fiArr = di.GetFiles("mp3.zip");
                    if (fiArr.Count() > 0)
                    {
                        foreach (FileInfo f in fiArr)
                        {
                            if (f.Length > 1000000)
                            {
                                mp3Count++;
                            }
                            else
                            {
                                if (!bool.Parse(dtAsset.Rows[i]["IsArchive"].ToString()))
                                {
                                    mp3Length++;
                                    dtnotExistRecordsrow["Class_Code"] = dtAsset.Rows[i]["Class_Code"].ToString();
                                    dtnotExistRecordsrow["Session"]    = dtAsset.Rows[i]["Session"].ToString();
                                    dtnotExistRecordsrow["FileDate"]   = dtAsset.Rows[i]["FileDate"].ToString();
                                    dtnotExistRecordsrow["LowLength"]  = "1";
                                    dtnotExistRecords.Rows.Add(dtnotExistRecordsrow);
                                    dtnotExistRecordsrow = dtnotExistRecords.NewRow();
                                }
                                else
                                {
                                    mp3Count++;
                                    LowLengthCorrect++;
                                }
                            }
                        }
                    }
                    else
                    {
                        NotExistmp3Count++;
                        dtnotExistRecordsrow["Class_Code"] = dtAsset.Rows[i]["Class_Code"].ToString();
                        dtnotExistRecordsrow["Session"]    = dtAsset.Rows[i]["Session"].ToString();
                        dtnotExistRecordsrow["FileDate"]   = dtAsset.Rows[i]["FileDate"].ToString();
                        dtnotExistRecordsrow["LowLength"]  = "0";
                        dtnotExistRecords.Rows.Add(dtnotExistRecordsrow);
                        dtnotExistRecordsrow = dtnotExistRecords.NewRow();
                    }
                }
            }
            lblExistFolder.Text       = ExistFolder.ToString();
            lblRecordCount.Text       = mp3Count.ToString();
            lblNotExistFolder.Text    = notExist.ToString();
            lblNotExistRecords.Text   = NotExistmp3Count.ToString();
            lbl_Mp3Length.Text        = mp3Length.ToString();
            lbl_LowLengthCorrect.Text = LowLengthCorrect.ToString();
            grd_Records.DataSource    = dtnotExistRecords;
            grd_Records.DataBind();
            Grd_Folders.DataSource = dtnotExistFolder;
            Grd_Folders.DataBind();
        }
コード例 #22
0
 protected virtual IActionResult UpdateAssetsIcons(string api)
 {
     RunAsync(async() => await AssetBusiness.UpdateCoingeckoAssetsIconsAsync());
     return(Ok());
 }
コード例 #23
0
ファイル: UserBusiness.cs プロジェクト: AuctusProject/Beta
        public SearchResponse Search(string searchTerm)
        {
            if (string.IsNullOrWhiteSpace(searchTerm) || searchTerm.Trim().Length < 2)
            {
                return(new SearchResponse());
            }

            IEnumerable <DomainObjects.Advisor.Advisor> advisors = null;
            IEnumerable <DomainObjects.Asset.Asset>     assets   = null;

            Parallel.Invoke(() => advisors = AdvisorBusiness.ListByName(searchTerm), () => assets = AssetBusiness.ListByNameOrCode(searchTerm));

            if (!assets.Any() && !advisors.Any())
            {
                return(new SearchResponse());
            }

            var response = new SearchResponse();

            foreach (DomainObjects.Advisor.Advisor advisor in advisors)
            {
                response.Advisors.Add(new SearchResponse.AdvisorResult()
                {
                    Id          = advisor.Id,
                    Description = advisor.Description,
                    Name        = advisor.Name,
                    UrlGuid     = advisor.UrlGuid.ToString()
                });
            }
            foreach (DomainObjects.Asset.Asset asset in assets)
            {
                response.Assets.Add(new SearchResponse.AssetResult()
                {
                    Id                = asset.Id,
                    Code              = asset.Code,
                    Name              = asset.Name,
                    MarketCap         = asset.MarketCap,
                    CirculatingSupply = asset.CirculatingSupply
                });
            }
            response.Advisors = response.Advisors.OrderBy(c => c.Name).ToList();
            response.Assets   = response.Assets.OrderByDescending(c => c.MarketCap).ThenBy(c => c.Name).ToList();
            return(response);
        }
コード例 #24
0
        protected IActionResult ListAssets()
        {
            var assetResponse = AssetBusiness.ListAssetsOrderedByMarketCap();

            return(Ok(assetResponse));
        }