public ActionResult GetProfitsByProductId(int id)
        {
            int memberId = 0;
            EarninisRecordsViewModel model = new EarninisRecordsViewModel();

            if (int.TryParse(SystemSettingsHelper.GetSystemSettingsByKey("show:accountId"), out memberId))
            {
                IContentType           ct     = Services.ContentTypeService.GetContentType("EarningsRecordsElement");
                IEnumerable <IContent> result = Services.ContentService.GetContentOfContentType(ct.Id)
                                                .Where(e => e.GetValue <int>("memberId") == memberId)
                                                .Where(e => e.GetValue <int>("productid") == id);
                if (result != null && result.Count() > 0)
                {
                    var groupkeys = result.OrderByDescending(e => e.CreateDate)
                                    .GroupBy(e => e.CreateDate.ToString("MM/dd"))
                                    .Select(e => new
                    {
                        Key   = e.Key,
                        Value = e.Sum(a => a.GetValue <decimal>("earning"))
                    });

                    foreach (var item in groupkeys.OrderBy(e => Convert.ToDateTime(e.Key)))
                    {
                        model.Times.Add(item.Key);
                        model.Datas.Add(item.Value);
                    }
                }
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        void MemberService_Created(IMemberService sender, Umbraco.Core.Events.NewEventArgs <Umbraco.Core.Models.IMember> e)
        {
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                try
                {
                    int tplid;
                    string managerTeplateId               = SystemSettingsHelper.GetSystemSettingsByKey("manager:register:tplid");
                    string rgisterTemplateId              = SystemSettingsHelper.GetSystemSettingsByKey("member:register:tplid:bytefunds");
                    string managerEmail                   = SystemSettingsHelper.GetSystemSettingsByKey("manager:email");
                    Configuration configurationFile       = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
                    MailSettingsSectionGroup mailSettings = (MailSettingsSectionGroup)configurationFile.GetSectionGroup("system.net/mailSettings");
                    if (int.TryParse(managerTeplateId, out tplid))
                    {
                        //用户创建成功给管理员和用户自己发邮件
                        IMedia mediatamplate =
                            ApplicationContext.Current.Services.MediaService.GetById(tplid);
                        string content = mediatamplate.GetValue <string>("bodytext").Replace("{{name}}", e.Entity.Name);
                        library.SendMail(mailSettings.Smtp.Network.UserName, managerEmail, mediatamplate.GetValue <string>("title"), content, true);
                    }
                    if (int.TryParse(rgisterTemplateId, out tplid))
                    {
                        //给用户发邮件
                        IMedia mediatamplate =
                            ApplicationContext.Current.Services.MediaService.GetById(tplid);
                        //string memberbodycontent = Helpers.SendmailHelper.Replace(mediatamplate.GetValue<string>("bodytext"),
                        //    e.Entity.Key, -1);
                        //Helpers.SendmailHelper.SendEmail(membercontent.GetValue<string>("title"), memberbodycontent,
                        //    e.Entity.Email);

                        library.SendMail(mailSettings.Smtp.Network.UserName, e.Entity.Email, mediatamplate.GetValue <string>("title"), mediatamplate.GetValue <string>("bodytext"), true);
                    }
                }
                catch (Exception ex)
                {
                    return;
                }
            });
        }
Beispiel #3
0
        void ContentService_Created(IContentService sender, Umbraco.Core.Events.NewEventArgs <Umbraco.Core.Models.IContent> e)
        {
            #region 出入金发邮件
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                try
                {
                    //给管理员发邮件,用户入金出金操作
                    //File.WriteAllText("d:\\" + Guid.NewGuid().ToString() + ".txt", "contentcreated");
                    if (e.Alias.ToLower().Equals("payrecords") || e.Alias.ToLower().Equals("withdrawelement"))
                    {
                        string tplid        = string.Empty;
                        string title        = string.Empty;
                        string accountbuyId = string.Empty, accountwithdrawId = string.Empty;
                        string managerEmail = SystemSettingsHelper.GetSystemSettingsByKey("manager:email");
                        if (e.Alias.ToLower().Equals("payrecords"))
                        {
                            tplid        = SystemSettingsHelper.GetSystemSettingsByKey("manager:payment:tplid");
                            accountbuyId = SystemSettingsHelper.GetSystemSettingsByKey("account:buy:tplid");

                            int tpl, accounttplid;

                            if (int.TryParse(tplid, out tpl) && int.TryParse(accountbuyId, out accounttplid))
                            {
                                IMedia content       = ApplicationContext.Current.Services.MediaService.GetById(tpl);
                                IMedia accountbuytmp = ApplicationContext.Current.Services.MediaService.GetById(accounttplid);
                                //创建Content的时候Name属性赋值的email
                                IMember member   = ApplicationContext.Current.Services.MemberService.GetById(e.Entity.GetValue <int>("memberPicker"));
                                IContent product = ApplicationContext.Current.Services.ContentService.GetById(e.Entity.GetValue <int>("buyproduct"));
                                if (member == null)
                                {
                                    return;
                                    // throw new CustomException.NotFoundEmailException("邮箱不存在");
                                }
                                Configuration configurationFile       = WebConfigurationManager.OpenWebConfiguration("/");
                                MailSettingsSectionGroup mailSettings = (MailSettingsSectionGroup)configurationFile.GetSectionGroup("system.net/mailSettings");


                                string oldbodycontent = content.GetValue <string>("bodytext")
                                                        .Replace("{{name}}", member.Name)
                                                        .Replace("{{product}}", product.GetValue <string>("title"))
                                                        .Replace("{{orderid}}", e.Entity.GetValue <string>("payBillno"))
                                                        .Replace("{{amount}}", e.Entity.GetValue <double>("amountCny").ToString("N2"));
                                //发送邮件到管理员
                                library.SendMail(mailSettings.Smtp.Network.UserName, managerEmail, content.GetValue <string>("title"), oldbodycontent, true);
                                //发送邮件到用户
                                string accountContent = accountbuytmp.GetValue <string>("bodytext")
                                                        .Replace("{{name}}", member.Name)
                                                        .Replace("{{product}}", product.GetValue <string>("title"))
                                                        .Replace("{{rate}}", product.GetValue <string>("rate"))
                                                        .Replace("{{amount}}", e.Entity.GetValue <double>("amountCny").ToString("N2"));
                                Common.CustomLog.WriteLog(member.Username + "\r\n" + accountbuytmp.GetValue <string>("title"));
                                library.SendMail(mailSettings.Smtp.Network.UserName, member.Username, accountbuytmp.GetValue <string>("title"), accountContent, true);
                            }
                        }
                        else if (e.Alias.ToLower().Equals("withdrawelement"))
                        {
                            IMember member = ApplicationContext.Current.Services.MemberService.GetById(e.Entity.GetValue <int>("memberId"));
                            Dictionary <string, string> managerdir = new Dictionary <string, string>();
                            managerdir.Add("{{name}}", member.Name);
                            managerdir.Add("{{bankOpenName}}", e.Entity.GetValue <string>("memberName"));
                            managerdir.Add("{{amount}}", e.Entity.GetValue <string>("amount"));
                            managerdir.Add("{{bankNumber}}", e.Entity.GetValue <string>("bankNumber"));
                            managerdir.Add("{{bankName}}", e.Entity.GetValue <string>("bankName"));
                            //发送给管理员
                            SendmailHelper.SendEmail(managerEmail, "manager:withdraw:tplid", managerdir);
                            Dictionary <string, string> accountdir = new Dictionary <string, string>();
                            accountdir.Add("{{name}}", member.Name);
                            accountdir.Add("{{amount}}", e.Entity.GetValue <string>("amount"));
                            //发送给用户
                            SendmailHelper.SendEmail(member.Username, "member:withdraw:tplId", accountdir);
                        }
                    }
                    else if (e.Alias.ToLower().Equals("ChipsDepositDocument", StringComparison.OrdinalIgnoreCase))
                    {
                        IMember member = ApplicationContext.Current.Services.MemberService.GetById(e.Entity.GetValue <int>("member"));
                        //DOTO
                    }
                }
                catch (Exception ex)
                {
                    Common.CustomLog.WriteLog(ex.ToString());
                    return;
                }
            });
            #endregion
        }
        public async Task AllTextVisibleInHighContrastModesAsync()
        {
            if (!Directory.Exists(ArtifactDir))
            {
                Directory.CreateDirectory(ArtifactDir);
            }

            string imagePathFormat = ArtifactDir + "{0}_{1}.png";

            async Task GetScreenshotImagesAsync(string identifier)
            {
                async Task TakeScreenshotThenExtractTextAsync(WindowsDriver <WindowsElement> session, string imageId)
                {
                    var imgFile   = string.Format(imagePathFormat, imageId, identifier);
                    var linesFile = $"{imgFile}.lines.txt";
                    var wordsFile = $"{imgFile}.words.txt";

                    CursorHelper.MoveToTopLeftOfScreen(); // To avoid cursor being over any controls that changes their visuals

                    session.SaveScreenshot(imgFile);

                    if (this.testSettings.IsFreeSubscription)
                    {
                        // Therefore rate limited
                        await Task.Delay(30000); // This pause to avoid querying the server too often
                    }

                    var(lines, words) = await CognitiveServicesHelpers.GetTextFromImageAsync(imgFile, this.testSettings.SubscriptionKey, this.testSettings.AzureRegion);

                    File.WriteAllLines(linesFile, lines);
                    File.WriteAllLines(wordsFile, words);
                }

                var appSession = WinAppDriverHelper.LaunchExe(PathToExe);

                await TakeScreenshotThenExtractTextAsync(appSession, "Settings");

                appSession.FindElementByName("Profile").Click();
                await Task.Delay(1000);

                await TakeScreenshotThenExtractTextAsync(appSession, "Profile");

                appSession.FindElementByName("Mappings").Click();
                await Task.Delay(1000);

                await TakeScreenshotThenExtractTextAsync(appSession, "Mappings");

                appSession.FindElementByName("Datacontext").Click();
                await Task.Delay(1000);

                await TakeScreenshotThenExtractTextAsync(appSession, "Datacontext");

                appSession.FindElementByName("General").Click();
                await Task.Delay(1000);

                await TakeScreenshotThenExtractTextAsync(appSession, "General");

                appSession.ClickElement("Close");
            }

            var sysSettings = new SystemSettingsHelper();

            await sysSettings.TurnOffHighContrastAsync();

            VirtualKeyboard.MinimizeAllWindows();
            await GetScreenshotImagesAsync("normal");

            await sysSettings.SwitchToHighContrastNumber1Async();

            VirtualKeyboard.MinimizeAllWindows();
            await GetScreenshotImagesAsync("HiContrast1");

            await sysSettings.SwitchToHighContrastNumber2Async();

            VirtualKeyboard.MinimizeAllWindows();
            await GetScreenshotImagesAsync("HiContrast2");

            await sysSettings.SwitchToHighContrastBlackAsync();

            VirtualKeyboard.MinimizeAllWindows();
            await GetScreenshotImagesAsync("HiContrastBlack");

            await sysSettings.SwitchToHighContrastWhiteAsync();

            VirtualKeyboard.MinimizeAllWindows();
            await GetScreenshotImagesAsync("HiContrastWhite");

            void CompareWordsText(string refIdentifier, string compIdentifier)
            {
                // These pages have text that goes beyond the TextBox bounds
                // - as text size changes this affects the number of lines shown which results in different text on the screen
                var pagesToIgnore = new[] { "Mapping", "Profile" };

                foreach (var refFile in Directory.EnumerateFiles(ArtifactDir, $"*{refIdentifier}*.words.txt"))
                {
                    bool skipCheck = false;
                    foreach (var toIgnore in pagesToIgnore)
                    {
                        if (refFile.Contains(toIgnore))
                        {
                            skipCheck = true;
                            break;
                        }
                    }

                    if (skipCheck)
                    {
                        continue;
                    }

                    var compFile = refFile.Replace(refIdentifier, compIdentifier);
                    if (!File.Exists(compFile))
                    {
                        Assert.Fail($"Expected file not found: '{compFile}'");
                    }
                    else
                    {
                        var refText  = File.ReadAllLines(refFile);
                        var compText = File.ReadAllLines(compFile);

                        List <string> RemoveKnownExceptions(string[] origin)
                        {
                            // Close and Maximize buttons are sometimes detected as text
                            return(origin.Where(t => t != "X" && t != "O").ToList());
                        }

                        var filteredRefText  = RemoveKnownExceptions(refText);
                        var filteredCompText = RemoveKnownExceptions(compText);

                        List <string> TrimNonAlphaNumerics(List <string> origin)
                        {
                            string TrimNANStart(string source)
                            {
                                var trimIndex = 0;

                                for (int i = 0; i < source.Length; i++)
                                {
                                    if (char.IsLetterOrDigit(source[i]))
                                    {
                                        trimIndex = i;
                                        break;
                                    }
                                }

                                return(source.Substring(trimIndex));
                            }

                            string TrimNANEnd(string source)
                            {
                                var trimIndex = -1;

                                for (int i = source.Length - 1; i >= 0; i--)
                                {
                                    if (char.IsLetterOrDigit(source[i]))
                                    {
                                        trimIndex = i;
                                        break;
                                    }
                                }

                                return(source.Substring(0, trimIndex + 1));
                            }

                            return(origin.Select(o => TrimNANStart(TrimNANEnd(o))).Where(t => !string.IsNullOrWhiteSpace(t)).ToList());
                        }

                        // Allow for text detection being inconsistent with punctuation
                        var trimmedRefText  = TrimNonAlphaNumerics(filteredRefText);
                        var trimmedCompText = TrimNonAlphaNumerics(filteredCompText);

                        List <string> AccountForKnownExceptions(List <string> origin)
                        {
                            string RemoveKnownSubstringExceptions(string source)
                            {
                                if (source.EndsWith("$()"))
                                {
                                    return(source.Substring(0, source.Length - 3));
                                }

                                if (source.EndsWith("$0"))
                                {
                                    return(source.Substring(0, source.Length - 2));
                                }

                                return(source);
                            }

                            return(origin.Select(t => RemoveKnownSubstringExceptions(t)).ToList());
                        }

                        var testableRefText  = AccountForKnownExceptions(trimmedRefText);
                        var testableCompText = AccountForKnownExceptions(trimmedCompText);

                        ListOfStringAssert.AssertAreEqualIgnoringOrder(
                            testableRefText,
                            testableCompText,
                            caseSensitive: false,
                            message: $"Difference between '{refFile}' and '{compFile}'.");
                    }
                }
            }

            // Now we've got all images and extracted the text, actually do the comparison
            // It's easier to restart the tests and just do these checks if something fails.
            // It's also easier to have all versions available if needing to do manual checks.
            CompareWordsText("normal", "HiContrast1");
            CompareWordsText("normal", "HiContrast2");
            CompareWordsText("normal", "HiContrastBlack");
            CompareWordsText("normal", "HiContrastWhite");
        }
 public async Task CleanUpAsync()
 {
     var sysSettings = new SystemSettingsHelper();
     await sysSettings.TurnOffHighContrastAsync();
 }
        public ActionResult RenewalFund([Bind(Prefix = "renewalViewModel")] RenewalFundViewModel model)
        {
            ResponseModel response = new ResponseModel();
            IMember       member   = Services.MemberService.GetById(Members.GetCurrentMemberId());

            //旧的交易记录
            IContent oldContent = Services.ContentService.GetById(model.CurrentPayId);
            //旧的产品
            IContent oldProduct = Services.ContentService.GetById(oldContent.GetValue <int>("buyproduct"));

            if (model.RenewalFundId == -1)
            {
                response.Success     = true;
                response.Msg         = "恭喜您已经成功解约,到期将余额返回到您账户余额";
                response.RedirectUrl = "/memberinfo";
                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    //member:ter:tplid
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("{{name}}", member.Name);
                    dic.Add("{{product}}", oldProduct.GetValue <string>("title"));
                    dic.Add("{{start}}", oldContent.GetValue <DateTime>("rechargeDateTime").ToString("yyyy-MM-dd HH:mm:ss"));
                    dic.Add("{{end}}", oldContent.GetValue <DateTime>("expirationtime").ToString("yyyy-MM-dd HH:mm:ss"));
                    Helpers.SendmailHelper.SendEmail(member.Username, "member:ter:tplid", dic);
                    dic.Add("{{option}}", "到期解约");
                    string manageremail = SystemSettingsHelper.GetSystemSettingsByKey("manager:email");
                    Helpers.SendmailHelper.SendEmail(manageremail, "manager:ter:tplid", dic);
                });
            }
            else
            {
                //续约的产品
                IContent product = Services.ContentService.GetById(model.RenewalFundId);
                //新的交易记录
                DateTime     start   = oldContent.GetValue <DateTime>("expirationtime").AddDays(1);
                DateTime     end     = start.AddMonths(product.GetValue <int>("cycle"));
                IContentType ct      = ApplicationContext.Services.ContentTypeService.GetContentType("PayRecords");
                IContent     content = ApplicationContext.Services.ContentService.CreateContent("无用户名", ct.Id, "PayRecords");

                content.SetValue("username", member.Name);
                content.Name = member.Email;
                content.SetValue("email", member.Email);
                content.SetValue("memberPicker", member.Id);
                content.SetValue("buyproduct", product.Id);
                content.SetValue("mobilePhone", member.GetValue <string>("tel"));
                content.SetValue("memberPicker", member.Id.ToString());
                content.SetValue("amountCny", oldContent.GetValue <string>("amountCny"));
                content.SetValue("rechargeDateTime", start.ToString("yyyy-MM-dd HH:mm:ss"));
                content.SetValue("expirationtime", end.ToString("yyyy-MM-dd HH:mm:ss"));
                content.SetValue("payBillno", "续约订单:" + oldContent.GetValue <string>("payBillno"));
                content.SetValue("isdeposit", true);
                content.SetValue("isexpired", false);
                Services.ContentService.Save(content);

                response.Success     = true;
                response.Msg         = "恭喜你已经完成自动续约!请查收邮件";
                response.IsRedirect  = true;
                response.RedirectUrl = "/memberinfo";
                //发送邮件
                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    //member:renewal:tplid
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("{{name}}", member.Name);
                    dic.Add("{{oldproduct}}", oldProduct.GetValue <string>("title"));
                    dic.Add("{{newproduct}}", product.GetValue <string>("title"));
                    dic.Add("{{start}}", start.ToString("yyyy-MM-dd HH:mm:ss"));
                    dic.Add("{{end}}", end.ToString("yyyy-MM-dd HH:mm:ss"));
                    Helpers.SendmailHelper.SendEmail(member.Username, "member:renewal:tplid", dic);
                    dic.Add("{{option}}", "自动续约");
                    string manageremail = SystemSettingsHelper.GetSystemSettingsByKey("manager:email");
                    Helpers.SendmailHelper.SendEmail(manageremail, "manager:renewal:tplid", dic);
                });
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }