public void Calculate_BasicStocks_ReturnsCorrectResult()
        {
            // arrange
            var results = new PortfoliosTestBuilder()
                          .WithPortfolio("A")
                          .WithSecurity(new Security {
                Name = "FB", Price = 100, QuantityHeld = 100
            })
                          .WithSecurity(new Security {
                Name = "AAPL", Price = 100, QuantityHeld = 100
            })
                          .WithSecurity(new Security {
                Name = "Cash", Price = 80000, QuantityHeld = 1
            }).Done()
                          .Build();

            mockRepo
            .Setup(x => x.GetItems())
            .Returns(results);

            // act
            var result = _sut.Calculate("FB", 50);

            // assert
            var expectedResult = new ShareResult[]
            {
                new ShareResult {
                    PortfolioName = "A", Quantity = 400
                }
            };

            Assert.That(expectedResult.Length, Is.EqualTo(1));
            Assert.That(expectedResult[0].PortfolioName, Is.EqualTo("A"));
            Assert.That(expectedResult[0].Quantity, Is.EqualTo(400));
        }
Пример #2
0
        public override void OnShareLinkComplete(string responseJsonData)
        {
            string formattedResponse = CanvasFacebook.FormatResult(responseJsonData);
            var    result            = new ShareResult(formattedResponse);

            CallbackManager.OnFacebookResponse(result);
        }
 private void btnShare_Click(object sender, EventArgs e)
 {
     Task.Run(new Action(() =>
     {
         metroProgressSpinner1.Visible = true;
         Client client = new Client();
         if (checkBox1.Checked)
         {
             ShareResult result = client.SharePrivate(path_list, txtPwd.Text);
             if (result.errno != 0)
             {
                 MessageBox.Show($"{Errno.Instance.GetDescription(result.errno)}. 分享失败.");
                 return;
             }
             txtShort.Text = result.shorturl;
             txtLong.Text  = result.link;
         }
         else
         {
             ShareResult result = client.Share(path_list);
             if (result.errno != 0)
             {
                 MessageBox.Show($"{Errno.Instance.GetDescription(result.errno)}. 分享失败.");
                 return;
             }
             txtShort.Text = result.shorturl;
             txtLong.Text  = result.link;
         }
         metroProgressSpinner1.Visible = false;
     }));
 }
Пример #4
0
 public void ShareResult(ShareResult shareResult)
 {
     // say we did a thing
     Q.Add(new SnafflerMessage
     {
         DateTime    = DateTime.Now,
         ShareResult = shareResult,
         Type        = SnafflerMessageType.ShareResult
     });
 }
Пример #5
0
        public List <ShareResult> GetUrlsShares(string url, List <SocialNetworks> networks)
        {
            List <ShareResult> shareResults = new List <ShareResult>();
            ShareResult        sr;

            foreach (var item in networks)
            {
                sr = new ShareResult();
                switch (item)
                {
                case SocialNetworks.Facebook:
                    sr = Facebook.GetShares(url);
                    break;

                case SocialNetworks.Twitter:
                    sr = Twitter.GetShares(url);
                    break;

                case SocialNetworks.Vk:
                    sr = VKontakte.GetShares(url);
                    break;

                case SocialNetworks.Linkedin:
                    sr = Linkedin.GetShares(url);
                    break;

                case SocialNetworks.Mailru:
                    sr = Mailru.GetShares(url);
                    break;

                case SocialNetworks.Pinterest:
                    sr = Pinterest.GetShares(url);
                    break;

                case SocialNetworks.Odnoklassniki:
                    sr = Odnoklassniki.GetShares(url);
                    break;

                case SocialNetworks.Reddit:
                    sr = Reddit.GetShares(url);
                    break;

                case SocialNetworks.Stumbleupon:
                    sr = Stumbleupon.GetShares(url);
                    break;

                case SocialNetworks.Google:
                    sr = Google.GetShares(url);
                    break;
                }
                shareResults.Add(sr);
            }
            return(shareResults);
        }
Пример #6
0
        internal void GetComputerShares(string computer)
        {
            // find the shares
            HostShareInfo[]             hostShareInfos    = GetHostShareInfo(computer);
            BlockingStaticTaskScheduler treeTaskScheduler = SnaffCon.GetTreeTaskScheduler();

            foreach (HostShareInfo hostShareInfo in hostShareInfos)
            {
                string shareName = GetShareName(hostShareInfo, computer);
                if (!String.IsNullOrWhiteSpace(shareName))
                {
                    bool matched = false;

                    // classify them
                    foreach (ClassifierRule classifier in MyOptions.ShareClassifiers)
                    {
                        ShareClassifier shareClassifier = new ShareClassifier(classifier);
                        if (shareClassifier.ClassifyShare(shareName))
                        {
                            matched = true;
                            break;
                        }
                    }
                    // by default all shares should go on to TreeWalker unless the classifier pulls them out.
                    // send them to TreeWalker
                    if (!matched)
                    {
                        if (IsShareReadable(shareName))
                        {
                            ShareResult shareResult = new ShareResult()
                            {
                                Listable  = true,
                                SharePath = shareName
                            };
                            Mq.ShareResult(shareResult);

                            Mq.Info("Creating a TreeWalker task for " + shareResult.SharePath);
                            treeTaskScheduler.New(() =>
                            {
                                try
                                {
                                    new TreeWalker(shareResult.SharePath);
                                }
                                catch (Exception e)
                                {
                                    Mq.Trace(e.ToString());
                                }
                            });
                        }
                    }
                }
            }
        }
Пример #7
0
        private ShareResult CreateShare
        (
            string filePath,
            string description,
            uint maximumAllowed,
            bool allowMaximum,
            string account,
            params FileSystemRights[] rights
        )
        {
            ShareResult result = ShareResult.Success;

            try
            {
                _params["Name"]        = _name;
                _params["Description"] = description;
                _params["Path"]        = filePath;
                _params["Access"]      = null; // CreateSecurityDescriptor(account, rights);

                if (allowMaximum)
                {
                    _params["MaximumAllowed"] = null;
                }
                else
                {
                    _params["MaximumAllowed"] = maximumAllowed;
                }

                ManagementBaseObject output = _manager.InvokeMethod("Create", _params, null);
                uint returnValue            = (uint)(output.Properties["ReturnValue"].Value);
                result = (ShareResult)returnValue;

                Console.WriteLine("Result: <{0}>, <{1}>", returnValue, result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            return(result);
        }
Пример #8
0
        private ShareResult CreateShare
        (
            string filePath,
            string description,
            uint maximumAllowed,
            bool allowMaximum,
            string account,
            params FileSystemRights[] rights
        )
        {
            ShareResult result = ShareResult.Success;

            try
            {
                _params["Name"]        = _name;
                _params["Description"] = description;
                _params["Path"]        = filePath;
                _params["Access"]      = null; // CreateSecurityDescriptor(account, rights);

                if (allowMaximum)
                {
                    _params["MaximumAllowed"] = null;
                }
                else
                {
                    _params["MaximumAllowed"] = maximumAllowed;
                }

                ManagementBaseObject output = _manager.InvokeMethod("Create", _params, null);
                uint returnValue            = (uint)(output.Properties["ReturnValue"].Value);
                result = (ShareResult)returnValue;

                TraceFactory.Logger.Debug("Result: {0}".FormatWith(result));
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error(ex);
                throw;
            }

            return(result);
        }
Пример #9
0
        public void ShareLink(Uri contentURL, string contentTitle = "",
                              string contentDescription           = "", Uri photoURL = null)
        {
            if (!IsLoggedIn)
            {
                MyDebug.LogWarning("Authorise user before posting, fail event generated");

                IShareResult res = new ShareResult("User isn't authorised");
                OnPostingCompleteAction(FacebookHelperResultType.ERROR, res);
                return;
            }

            FB.ShareLink(
                contentURL: contentURL,
                contentTitle: contentTitle,
                contentDescription: contentDescription,
                photoURL: photoURL,
                callback: PostCallBack
                );
        }
        public ShareResult ShareAppMessage(Guid campaignId, Guid?memberId, string openId)
        {
            ShareResult result = new ShareResult();

            CampaignEntity campaign = GetCampaign(campaignId);

            if (campaign == null || campaign.Status != EnumCampaignStatus.Ongoing)
            {
                return(result);
            }

            PointTrackResult pointTrackResult = ShareCampaignToAppMessage(campaign, memberId, openId);

            if (pointTrackResult.Success == false)
            {
                return(result);
            }

            result.Point = campaign.ShareAppMessagePoint;
            return(result);
        }
Пример #11
0
        public void SubmitTestResult(TuckfirtlePowSubmitInformation submitInformation)
        {
            var powInformation = PowInformation;
            var powValue       = Core.Pow.TuckfirtlePow.GetPowValueUnsafe($"{submitInformation.BlockHeaderTemplate}{submitInformation.Nonce}");

            if (powValue == submitInformation.PowValue && powValue < powInformation.TargetPowValue)
            {
                // Test Success. Move to next block.
                LastBlock.Height++;
                LastBlock.DateTime       = DateTimeOffset.Now;
                LastBlock.Nonce          = submitInformation.Nonce;
                LastBlock.TargetPowValue = submitInformation.PowValue;

                FoundBlocks.Add(new TuckfirtlePowBenchmarkTestBlock
                {
                    Version        = LastBlock.Version,
                    Height         = LastBlock.Height,
                    DateTime       = LastBlock.DateTime,
                    Nonce          = LastBlock.Nonce,
                    TargetPowValue = LastBlock.TargetPowValue
                });

                RenewIndex = 0;

                powInformation.Height++;
                powInformation.TargetPowValue      = powValue;
                powInformation.BlockHeaderTemplate = JsonConvert.SerializeObject(LastBlock, Formatting.None);

                TotalAcceptedShare++;

                ShareResult?.Invoke(this, true, "Accepted");
                NewJob?.Invoke(this, powInformation);
            }
            else
            {
                TotalRejectedShare++;
                ShareResult?.Invoke(this, false, "Invalid share.");
            }
        }
        //分享的回调函数
        void ShareResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
        {
            shareButton.enabled = true;

            Debug.LogFormat("share result :{0}", state);

            if (state == ResponseState.Success)
            {
                shareResult = ShareResult.Succeed;
            }
            else if (state == ResponseState.Fail)
            {
                shareResult = ShareResult.Faild;
            }
            else if (state == ResponseState.Cancel)
            {
                shareResult = ShareResult.Canceled;
            }

            DataHandler.DeleteFile(Application.persistentDataPath + "/tempPics/shareImage.jpg");

            QuitShareView();
        }
        public override void OnShareLinkComplete(ResultContainer resultContainer)
        {
            var result = new ShareResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Пример #14
0
 public override void OnShareLinkComplete(string message)
 {
     ShareResult result = new ShareResult(message);
     base.CallbackManager.OnFacebookResponse(result);
 }
Пример #15
0
        internal void GetComputerShares(string computer)
        {
            // find the shares
            HostShareInfo[] hostShareInfos = GetHostShareInfo(computer);

            foreach (HostShareInfo hostShareInfo in hostShareInfos)
            {
                string shareName = GetShareName(hostShareInfo, computer);
                if (!String.IsNullOrWhiteSpace(shareName))
                {
                    bool matched = false;

                    // SYSVOL and NETLOGON shares are replicated so they have special logic - do not use Classifiers for these
                    switch (hostShareInfo.shi1_netname.ToUpper())
                    {
                    case "SYSVOL":
                        if (MyOptions.ScanSysvol == true)
                        {
                            //  leave matched as false so that we don't suppress the TreeWalk for the first SYSVOL replica we see
                            //  toggle the flag so that any other shares replica will be skipped
                            MyOptions.ScanSysvol = false;
                            break;
                        }
                        matched = true;
                        break;

                    case "NETLOGON":
                        if (MyOptions.ScanNetlogon == true)
                        {
                            //  same as SYSVOL above
                            MyOptions.ScanNetlogon = false;
                            break;
                        }
                        matched = true;
                        break;

                    default:
                        // classify them
                        foreach (ClassifierRule classifier in MyOptions.ShareClassifiers)
                        {
                            ShareClassifier shareClassifier = new ShareClassifier(classifier);
                            if (shareClassifier.ClassifyShare(shareName))
                            {
                                matched = true;
                                break;
                            }
                        }
                        break;
                    }

                    // by default all shares should go on to TreeWalker unless the classifier pulls them out.
                    // send them to TreeWalker
                    if (!matched)
                    {
                        if (IsShareReadable(shareName))
                        {
                            ShareResult shareResult = new ShareResult()
                            {
                                Listable  = true,
                                SharePath = shareName
                            };
                            Mq.ShareResult(shareResult);

                            Mq.Info("Creating a TreeWalker task for " + shareResult.SharePath);
                            TreeTaskScheduler.New(() =>
                            {
                                try
                                {
                                    TreeWalker.WalkTree(shareResult.SharePath);
                                }
                                catch (Exception e)
                                {
                                    Mq.Error("Exception in TreeWalker task for share " + shareResult.SharePath);
                                    Mq.Error(e.ToString());
                                }
                            });
                        }
                    }
                }
            }
        }
        public ShareResult ShareAppMessage(Guid pageId, Guid?memberId, string openId)
        {
            ShareResult result = new ShareResult();

            AdvancedArticleEntity advancedArticle = GetAdvancedArticle(pageId);

            if (advancedArticle == null)
            {
                return(result);
            }

            #region 判断有没有分享过

            ShareLogEntity log = _shareManager.GetShareLog(pageId, openId);
            if (log == null)
            {
                log                 = new ShareLogEntity();
                log.Member          = memberId;
                log.OpenId          = openId;
                log.PageId          = pageId;
                log.ShareAppMessage = true;
                _shareManager.Create(log);
            }
            else
            {
                if (log.ShareAppMessage && log.Member.HasValue)
                {
                    return(result);
                }

                if (log.ShareAppMessage && memberId.HasValue == false)
                {
                    return(result);
                }

                log.Member          = memberId;
                log.ShareAppMessage = true;
                _shareManager.Update(log);
            }

            #endregion

            if (advancedArticle.ShareAppMessagePoint <= 0)
            {
                return(result);
            }

            if (memberId.HasValue)
            {
                PointTrackArgs args = new PointTrackArgs();
                args.DomainId = advancedArticle.Domain;
                args.MemberId = memberId.Value;
                args.Quantity = advancedArticle.ShareAppMessagePoint;
                args.Type     = MemberPointTrackType.Share;
                args.TagName  = advancedArticle.Title;
                args.TagId    = advancedArticle.Id;

                PointTrackResult pointTrackResult = _memberManager.PointTrack(args);
                if (pointTrackResult.Success == false)
                {
                    return(result);
                }

                result.Point = advancedArticle.ShareAppMessagePoint;
            }

            return(result);
        }
        /// <summary>
        /// 初始化分享界面
        /// </summary>
        public void SetUpShareView(ShareType shareType, CallBack shareSucceedCallBack, CallBack shareFailedCallBack, CallBack quitShareCallBack)
        {
            // 更新单词数据库,确保分享数据是正确的
            if (ExploreManager.Instance != null)
            {
                ExploreManager.Instance.UpdateWordDataBase();
            }

            // 初始化分享类型和分享回调
            this.shareType = shareType;

            shareResult = ShareResult.Canceled;

            this.shareSucceedCallBack = shareSucceedCallBack;

            this.shareFailedCallBack = shareFailedCallBack;

            this.quitShareCallBack = quitShareCallBack;

            // 初始化UI
            // 计算学习天数
            DateTime now = DateTime.Now;

            DateTime installDate = Convert.ToDateTime(GameManager.Instance.gameDataCenter.gameSettings.installDateString);

            TimeSpan timeSpan = now.Subtract(installDate);

            learnedDaysText.text = string.Format("<size=60>{0}</size>  天", timeSpan.Days + 1);

            LearningInfo learningInfo = LearningInfo.Instance;

            int learnedWordCountOfCurrentType = learningInfo.learnedWordCount;

            int wrongWordCountOfCurrentType = learningInfo.ungraspedWordCount;

            learnedWordCountText.text = string.Format("<size=60>{0}</size>  个", learnedWordCountOfCurrentType);

            int correctPercentageMultiply100 = learnedWordCountOfCurrentType == 0 ? 0 : (learnedWordCountOfCurrentType - wrongWordCountOfCurrentType) * 100 / learnedWordCountOfCurrentType;


            switch (shareType)
            {
            case ShareType.WeChat:
                shareTo.text = "分享到微信";
                break;

            case ShareType.Weibo:
                shareTo.text = "分享到微博";
                break;
            }

            shareButton.enabled = true;

            GetComponent <Canvas>().enabled = true;

#if UNITY_IOS
            codeIcon.sprite       = iosCodeSprite;
            downloadHintText.text = "前往AppStore\n进行下载";
#elif UNITY_ANDROID
            codeIcon.sprite       = androidCodeSprite;
            downloadHintText.text = "前往TapTap\n进行下载";
#elif UNITY_EDITOR
            UnityEditor.BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;

            switch (buildTarget)
            {
            case UnityEditor.BuildTarget.Android:
                codeIcon.sprite       = androidCodeSprite;
                downloadHintText.text = "前往TapTap\n进行下载";
                break;

            case UnityEditor.BuildTarget.iOS:
                codeIcon.sprite       = iosCodeSprite;
                downloadHintText.text = "前往AppStore\n进行下载";
                break;
            }
#endif


            if (zoomCoroutine != null)
            {
                StopCoroutine(zoomCoroutine);
            }

            //
            zoomCoroutine = HUDZoomIn();

            StartCoroutine(zoomCoroutine);
        }
 public override void OnShareLinkComplete(string message)
 {
     var result = new ShareResult(message);
     CallbackManager.OnFacebookResponse(result);
 }
Пример #19
0
        internal void GetComputerShares(string computer)
        {
            // find the shares
            HostShareInfo[] hostShareInfos = GetHostShareInfo(computer);

            foreach (HostShareInfo hostShareInfo in hostShareInfos)
            {
                // skip IPC$ and PRINT$ shares for #OPSEC!!!
                List <string> neverScan = new List <string> {
                    "ipc$", "print$"
                };
                if (neverScan.Contains(hostShareInfo.shi1_netname.ToLower()))
                {
                    continue;
                }

                string shareName = GetShareName(hostShareInfo, computer);
                if (!String.IsNullOrWhiteSpace(shareName))
                {
                    bool matched = false;

                    // SYSVOL and NETLOGON shares are replicated so they have special logic - do not use Classifiers for these
                    switch (hostShareInfo.shi1_netname.ToUpper())
                    {
                    case "SYSVOL":
                        if (MyOptions.ScanSysvol == true)
                        {
                            //  Leave matched as false so that we don't suppress the TreeWalk for the first SYSVOL replica we see.
                            //  Toggle the flag so that any other shares replica will be skipped
                            MyOptions.ScanSysvol = false;
                            break;
                        }
                        matched = true;
                        break;

                    case "NETLOGON":
                        if (MyOptions.ScanNetlogon == true)
                        {
                            //  Same logic as SYSVOL above
                            MyOptions.ScanNetlogon = false;
                            break;
                        }
                        matched = true;
                        break;

                    default:
                        // classify them
                        foreach (ClassifierRule classifier in MyOptions.ShareClassifiers)
                        {
                            ShareClassifier shareClassifier = new ShareClassifier(classifier);
                            if (shareClassifier.ClassifyShare(shareName))
                            {
                                // in this instance 'matched' means 'matched a discard rule, so don't send to treewalker'.
                                matched = true;
                                break;
                            }
                        }
                        break;
                    }

                    // by default all shares should go on to TreeWalker unless the classifier pulls them out.
                    // send them to TreeWalker
                    if (!matched)
                    {
                        // At least one classifier was matched so we will return this share to the results
                        ShareResult shareResult = new ShareResult()
                        {
                            Listable     = true,
                            SharePath    = shareName,
                            ShareComment = hostShareInfo.shi1_remark.ToString()
                        };

                        // Try to find this computer+share in the list of DFS targets


                        /*
                         *                      foreach (DFSShare dfsShare in MyOptions.DfsShares)
                         *                      {
                         *                          ///TODO: Add some logic to match cases where short hostnames is used in DFS target list
                         *                          if (dfsShare.RemoteServerName.Equals(computer, StringComparison.OrdinalIgnoreCase) &&
                         *                              dfsShare.Name.Equals(hostShareInfo.shi1_netname, StringComparison.OrdinalIgnoreCase))
                         *                          {
                         *                              // why the not operator?   if (!MyOptions.DfsNamespacePaths.Contains(dfsShare.DfsNamespacePath))
                         *                              if (MyOptions.DfsNamespacePaths.Contains(dfsShare.DfsNamespacePath))
                         *                              {
                         *                                  // remove the namespace path to make sure we don't kick it off again.
                         *                                  MyOptions.DfsNamespacePaths.Remove(dfsShare.DfsNamespacePath);
                         *                                  // sub out the \\computer\share path for the dfs namespace path. this makes sure we hit the most efficient endpoint.
                         *                                  shareName = dfsShare.DfsNamespacePath;
                         *                              }
                         *                              else // if that dfs namespace has already been removed from our list, skip further scanning of that share.
                         *                              {
                         *                                  skip = true;
                         *                              }
                         *
                         *                              // Found DFS target matching this computer+share - no further comparisons needed
                         *                              break;
                         *                          }
                         *                      }
                         */


                        // If this path can be accessed via DFS
                        if (MyOptions.DfsSharesDict.ContainsKey(shareName))
                        {
                            string dfsUncPath = MyOptions.DfsSharesDict[shareName];

                            Mq.Degub(String.Format("Matched host path {0} to DFS {1}", shareName, dfsUncPath));

                            // and if we haven't already scanned this share
                            if (MyOptions.DfsNamespacePaths.Contains(dfsUncPath))
                            {
                                Mq.Degub(String.Format("Will scan {0} using DFS referral instead of explicit host", dfsUncPath));

                                // sub out the \\computer\share path for the dfs namespace path. this makes sure we hit the most efficient endpoint.
                                shareResult.SharePath = dfsUncPath;

                                // remove the namespace path to make sure we don't kick it off again.
                                MyOptions.DfsNamespacePaths.Remove(dfsUncPath);
                            }
                            else // if that dfs path has already been removed from our list, skip further scanning of that share.
                            {
                                // Do we want to report a gray share result for these?  I think not.
                                // Mq.ShareResult(shareResult);
                                break;
                            }
                        }

                        //  If the share is readable then dig deeper.
                        if (IsShareReadable(shareResult.SharePath))
                        {
                            // Share is readable, report as green  (the old default/min of the Triage enum )
                            shareResult.Triage = Triage.Green;

                            try
                            {
                                DirectoryInfo dirInfo = new DirectoryInfo(shareResult.SharePath);

                                //EffectivePermissions.RwStatus rwStatus = effectivePermissions.CanRw(dirInfo);

                                shareResult.RootModifyable = false;
                                shareResult.RootWritable   = false;
                                shareResult.RootReadable   = true;

                                /*
                                 * if (rwStatus.CanWrite || rwStatus.CanModify)
                                 * {
                                 *  triage = Triage.Yellow;
                                 * }
                                 */
                            }
                            catch (System.UnauthorizedAccessException e)
                            {
                                Mq.Error("Failed to get permissions on " + shareResult.SharePath);
                            }

                            if (MyOptions.ScanFoundShares)
                            {
                                Mq.Trace("Creating a TreeWalker task for " + shareResult.SharePath);
                                TreeTaskScheduler.New(() =>
                                {
                                    try
                                    {
                                        TreeWalker.WalkTree(shareResult.SharePath);
                                    }
                                    catch (Exception e)
                                    {
                                        Mq.Error("Exception in TreeWalker task for share " + shareResult.SharePath);
                                        Mq.Error(e.ToString());
                                    }
                                });
                            }
                            Mq.ShareResult(shareResult);
                        }
                        else if (MyOptions.LogDeniedShares == true)
                        {
                            Mq.ShareResult(shareResult);
                        }
                    }
                }
            }
        }
Пример #20
0
        /// <summary>
        /// 生成订单
        /// </summary>
        /// <param name="shareAmount">分润金额</param>
        /// <param name="orderUser">下单用户</param>
        /// <param name="shareUser">收益用户</param>
        /// <param name="parameter">参数</param>
        /// <param name="config">分润配置</param>
        /// <param name="resultList"></param>
        /// <param name="configName"></param>
        protected void CreateResultList(decimal shareAmount, User orderUser, User shareUser, TaskParameter parameter, ShareBaseConfig config, IList <ITaskResult> resultList, string configName = "")
        {
            //如果分润金额小于等于0,则退出
            if (shareAmount > 0 && shareUser != null)
            {
                if (shareUser.Status == Alabo.Domains.Enums.Status.Normal)
                {
                    parameter.TryGetValue("OrderId", out long orderId);

                    // 如果限制供应商购买过的店铺
                    // 检查该会员是否购买过该店铺的商品,核对User_TypeUser表
                    if (Configuration.ProductRule.IsLimitStoreBuy)
                    {
                        //TODO 重构
                        //// 如果是订单用户
                        //if (TriggerType == TriggerType.Order) {
                        //    var order = Ioc.Resolve<IOrderService>().GetSingle(orderId);
                        //    if (order != null) {
                        //        var storeUser = Ioc.Resolve<ITypeUserService>()
                        //            .GetStoreUser(order.StoreId, shareUser.Id);
                        //        if (storeUser == null) {
                        //            //分润用户不是该店铺的用户 退出
                        //            return;
                        //            // ExecuteResult<ITaskResult>.Cancel($"分润用户不是该店铺的用户");
                        //        }
                        //    }
                        //}
                    }

                    var moneyTypes = Resolve <IAutoConfigService>().GetList <MoneyTypeConfig>(r => r.Status == Alabo.Domains.Enums.Status.Normal);
                    foreach (var rule in Configuration.RuleItems)
                    {
                        var ruleAmount    = shareAmount * rule.Ratio;
                        var ruleMoneyType = moneyTypes.FirstOrDefault(r => r.Id == rule.MoneyTypeId);
                        if (ruleMoneyType == null)
                        {
                            continue;
                            //ExecuteResult<ITaskResult>.Cancel($"资产分润规则设置错误,货币类型Id{ruleMoneyType.Id}");
                        }

                        var shareResult = new ShareResult {
                            OrderUser       = orderUser,
                            ShareUser       = shareUser,
                            ShareOrder      = base.ShareOrder,
                            Amount          = ruleAmount,
                            MoneyTypeId     = rule.MoneyTypeId,
                            ModuleConfigId  = config.Id,
                            ModuleId        = config.ModuleId,
                            SmsNotification = config.TemplateRule.SmsNotification
                        };
                        //描述
                        shareResult.Intro = Configuration.TemplateRule.LoggerTemplate.Replace("{OrderUserName}", orderUser.GetUserName())
                                            .Replace("{ShareUserName}", shareUser.GetUserName())
                                            .Replace("{ConfigName}", configName)
                                            .Replace("{AccountName}", ruleMoneyType.Name)
                                            .Replace("{OrderId}", orderId.ToString())
                                            .Replace("{OrderPrice}", base.ShareOrder.Amount.ToString("F2"))
                                            .Replace("{ShareAmount}", ruleAmount.ToString("F2"));

                        //短信内容
                        shareResult.SmsIntro = Configuration.TemplateRule.LoggerTemplate.Replace("{OrderUserName}", orderUser.GetUserName())
                                               .Replace("{ShareUserName}", shareUser.GetUserName())
                                               .Replace("{ConfigName}", configName)
                                               .Replace("{AccountName}", ruleMoneyType.Name)
                                               .Replace("{OrderId}", orderId.ToString())
                                               .Replace("{OrderPrice}", base.ShareOrder.Amount.ToString("F2"))
                                               .Replace("{ShareAmount}", ruleAmount.ToString("F2"));

                        var queueResult = new TaskQueueResult <ITaskResult>(Context)
                        {
                            ShareResult = shareResult
                        };
                        resultList.Add(queueResult);
                    }
                }
            }
        }
Пример #21
0
 public override void OnShareLinkComplete(ResultContainer resultContainer)
 {
     var result = new ShareResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }