protected override void Invoking(MessageReceivedEventArgs e, PlainText appName, PlainText operationText, ComplexMessage elements) { try { var config = Configuration.AppStatusConfig; var app = AppUtilities.GetApps(e.Source, e.Subject).Where(x => x.Name.ToLower() == appName.Content.ToLower()).Single(); bool?operation = operationText.Content.ToLower().ToBool("on", "off"); if (app.CanDisable) { if (operation.HasValue) { config.Config[e.Source.ToString(true)][app.Name] = operation.Value; e.Reply($"已{(operation.Value ? "启用" : "停用")}应用 {app.DisplayName}({app.Name}) ✧(≖ ◡ ≖✿ "); config.Save(); } } else { e.Reply($"该应用 {app.DisplayName}({app.Name})不允许被启用/停用 o(゚Д゚)っ!"); } } catch (InvalidOperationException) { e.Reply($"应用 {appName} 不存在 (•́へ•́╬)"); } }
public void InstallUpdate() { var updateFilePath = Path.Combine(DownloadPath, UpdateFileName); var updateExists = File.Exists(updateFilePath); if (!updateExists) { Log.Warning($"Cannot update, update file not found. {updateFilePath}"); return; } var arguments = $"-o \"{ExecutablePath}\" -u \"{updateFilePath}\""; Log.Debug("Running updater"); Log.Debug(arguments); var processStartInfo = new ProcessStartInfo { FileName = UpdaterPath, Arguments = arguments, UseShellExecute = true }; if (!FileUtilities.HasWriteAccess(AppUtilities.ApplicationFilePath) && Environment.OSVersion.Version.Major >= 6) { Log.Information("Running updater as admin"); processStartInfo.Verb = "runas"; } Process.Start(processStartInfo); AppUtilities.ShutdownApplication(); }
private DeleteConfirmationDialog(string function, IReadOnlyCollection <string> dependentFunctions) { InitializeComponent(); string message; if (dependentFunctions.Count > 1) { message = string.Format(CultureInfo.CurrentUICulture, AppUtilities.GetString("DeleteMessage"), function); } else { message = AppUtilities.GetString("DeleteSingleMessage", function, dependentFunctions.First()); } Span span = (Span)XamlReader.Load(string.Format(CultureInfo.CurrentUICulture, SpanXaml, message)); MessageBlock.Inlines.Add(span); if (dependentFunctions.Count > 1) { MessageBlock.Inlines.Add(new LineBreak()); Run run = new Run() { Text = " " + string.Join("\r\n ", dependentFunctions) }; Bold functionList = new Bold(); functionList.Inlines.Add(run); MessageBlock.Inlines.Add(functionList); } }
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args) { DataPackage package = args.Request.Data; package.Properties.ApplicationName = AppUtilities.GetString("AppName"); package.Properties.Title = AppUtilities.GetString("ShareTitle"); package.SetDataProvider(StandardDataFormats.Bitmap, ProvideData); }
public ResponseModel <string> Office365SignUp(IDictionary <string, string> data) { string email = string.Empty; if (data.ContainsKey("email")) { email = data["email"]; } else if (data.ContainsKey("upn")) { email = data["upn"]; } if (string.IsNullOrWhiteSpace(email)) { return(new ResponseModel <string> { message = "Invalid email! Cannot register account at the moment." }); } var userProfile = _context.UserProfile.FirstOrDefault(x => x.Email == email); if (userProfile == null) { Random rnd = new Random(); Int64 i64 = rnd.Next(10000000, 99999999); i64 = (i64 * 100000000) + rnd.Next(0, 999999999); var result = Math.Abs(i64).ToString(); UserProfile profile = new UserProfile { Id = Convert.ToInt64(result), Email = email, FirstName = data.ContainsKey("given_name") == true ? data["given_name"] : data["name"], LastName = data.ContainsKey("family_name") == true ? data["family_name"] : string.Empty, Gender = "male" }; _context.UserProfile.Add(profile); _context.SaveChanges(); AppUtilities.SetCookiesData(new Office365Model { GivenName = data.ContainsKey("given_name") == true ? data["given_name"] : data["name"], UserPrincipalName = data["email"], Surname = data.ContainsKey("family_name") == true ? data["family_name"] : string.Empty }); return(new ResponseModel <string> { status = true, message = "Success", Data = "" }); } else { return(new ResponseModel <string> { message = "User already registered." }); } }
public async Task InitializeUserSessionAsync() { UserActivityChannel channel = UserActivityChannel.GetDefault(); _activity = await channel.GetOrCreateUserActivityAsync(_sessionId); _activity.ActivationUri = new Uri($"quadrant-app:resume?{_sessionId}"); _activity.VisualElements.DisplayText = AppUtilities.GetString("AppName"); await _activity.SaveAsync(); _session = _activity.CreateSession(); }
public Test_AppBackgroundTask() { appSettings = new AppSettings(); appSettings.LeicaJob = new[] { "dummyCommand; dummyResponse" }; appUtilities = new AppUtilities(appSettings); mockPort = new Mock<IAppPort>(); mockPort.Setup(x => x.IsOpen).Returns(true); mockPort.Setup(x => x.Open()); mockPort.Setup(x => x.Close()); mockPort.Setup(x => x.WriteLine(It.IsAny<string>())); mockPort.Setup(x => x.ReadLine()).Returns("dummyResponse"); appBackgroundTask = new AppBackgroundTask(appSettings, appUtilities, mockPort.Object); timeStamp = DateTime.Now.AddDays(1); }
public Test_AppBackgroundTask() { appSettings = new AppSettings(); appSettings.LeicaJob = new[] { "dummyCommand; dummyResponse" }; appUtilities = new AppUtilities(appSettings); mockPort = new Mock <IAppPort>(); mockPort.Setup(x => x.IsOpen).Returns(true); mockPort.Setup(x => x.Open()); mockPort.Setup(x => x.Close()); mockPort.Setup(x => x.WriteLine(It.IsAny <string>())); mockPort.Setup(x => x.ReadLine()).Returns("dummyResponse"); appBackgroundTask = new AppBackgroundTask(appSettings, appUtilities, mockPort.Object); timeStamp = DateTime.Now.AddDays(1); }
public BaseApp(AppUtilities appUtilities) { this.SetColors(); // Standard XAML initialization this.InitializeComponent(); this.AppUtilities = appUtilities; // iOS requires "Application windows are expected to have a root view controller at the end of application launch" // So for iOS only, set a view Device.OnPlatform(iOS: () => { // Create nav page and set the first page. this.MainPage = this.GetNavigationPage(new ContentPage()); }); }
public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null) { returnUrl ??= Url.Content("~/"); ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.UserNameOrEmail, model.Password, model.RememberMe, lockoutOnFailure : true); // Tìm UserName theo Email, đăng nhập lại if ((!result.Succeeded) && AppUtilities.IsValidEmail(model.UserNameOrEmail)) { var user = await _userManager.FindByEmailAsync(model.UserNameOrEmail); if (user != null) { result = await _signInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, lockoutOnFailure : true); } } if (result.Succeeded) { _logger.LogInformation(1, "User logged in."); return(LocalRedirect(returnUrl)); } if (result.RequiresTwoFactor) { return(RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); } if (result.IsLockedOut) { _logger.LogWarning(2, "Tài khoản bị khóa"); return(View("Lockout")); } else { ModelState.AddModelError("Không đăng nhập được."); return(View(model)); } } return(View(model)); }
private GraphPrinter(FunctionGraph graph) { _graph = graph; // Resources cannot be loaded from the print thread, so do it here. _title = AppUtilities.GetString("PrintTaskTitle"); _graphSizeOption = AppUtilities.GetString(nameof(GraphSize)); _fullPageItem = AppUtilities.GetString(nameof(GraphSize.FullPage)); _windowSizeItem = AppUtilities.GetString(nameof(GraphSize.Window)); _labelLocationOption = AppUtilities.GetString(nameof(LabelLocation)); _noneItem = AppUtilities.GetString(nameof(LabelLocation.None)); _topLeftItem = AppUtilities.GetString(nameof(LabelLocation.TopLeft)); _topRightItem = AppUtilities.GetString(nameof(LabelLocation.TopRight)); _bottomLeftItem = AppUtilities.GetString(nameof(LabelLocation.BottomLeft)); _bottomRightItem = AppUtilities.GetString(nameof(LabelLocation.BottomRight)); _printDocument = new CanvasPrintDocument(); _printDocument.Preview += PrintDocument_Preview; _printDocument.Print += PrintDocument_Print; _printDocument.PrintTaskOptionsChanged += PrintDocument_PrintTaskOptionsChanged; }
protected override void Invoking(MessageReceivedEventArgs e, PlainText plainText, ComplexMessage elements) { var apps = AppUtilities.GetApps(e.Source, e.Subject); if (int.TryParse(plainText, out int pageIndex)) { var appInfos = apps.Select(GetAppInfo).OrderBy(x => x); int pageCount = (int)Math.Ceiling((float)appInfos.Count() / MaxCount); if (pageIndex > 0 && pageIndex <= pageCount) { int start = (pageIndex - 1) * MaxCount; int count = pageIndex < pageCount ? MaxCount : appInfos.Count() - start; var appInfosSplit = appInfos.Skip(start).Take(count); e.Source.Send($"帮助菜单 (第 {pageIndex} 页 / 共 {pageCount} 页):\n\n" + string.Join("\n", appInfosSplit)); } else if (pageIndex < 1) { e.Reply($"页数不能小于等于 0 (T▽T)"); } else if (pageIndex > pageCount) { e.Reply($"帮助菜单仅有 {pageCount} 页 |ω・`)"); } } else { try { var app = apps.Where(x => x.Name.ToLower() == plainText.Content.ToLower()).Single(); e.Source.Send(GetAppInfo(app) + ":\n" + string.Join("\n", app.Features.Where(f => f.Usage != null).Select(f => f.Usage))); } catch (InvalidOperationException) { e.Reply($"应用 {plainText} 不存在 (•́へ•́╬)"); } } string GetAppInfo(AppBase app) => $"{(app.IsEnabled(e.Source) ? string.Empty : "【已停用】")}{app.DisplayName} ({app.Name})"; }
public ResponseModel <string> Office365Login(IDictionary <string, string> data) { string email = string.Empty; if (data.ContainsKey("email")) { email = data["email"]; } else if (data.ContainsKey("upn")) { email = data["upn"]; } if (string.IsNullOrWhiteSpace(email)) { return(new ResponseModel <string> { message = "Invalid user! Your office365 account is not registered with us." }); } var userProfile = _context.UserProfile.FirstOrDefault(x => x.Email == email); if (userProfile == null) { return(new ResponseModel <string> { message = "Invalid user! Your office365 account is not registered with us." }); } AppUtilities.SetCookiesData(new Office365Model { GivenName = data.ContainsKey("given_name") == true ? data["given_name"] : data["name"], UserPrincipalName = email, Surname = data.ContainsKey("family_name") == true ? data["family_name"] : string.Empty }); return(new ResponseModel <string> { status = true, message = "Success", Data = "" }); }
protected override string GetLocalizedControlTypeCore() => AppUtilities.GetString("GraphControlTypeName");
private static bool validateContactData(Dictionary <string, string> data) { if (data["name"] != "" && data["email"] != "" && data["contact"] != "" && AppUtilities.IsEmailValid(data["email"])) { return(true); } else { return(false); } }
private static bool validateMeetingData(Dictionary <string, string> data) { if (data["name"] != "" && data["email"] != "" && data["subject"] != "" && data["location"] != "" && Convert.ToDateTime(data["date"]).Date > DateTime.Now.Date && AppUtilities.IsEmailValid(data["email"])) { return(true); } else { return(false); } }
public TimeApp(AppUtilities appComponents) : base(appComponents) { }
public ExpenseApp(AppUtilities appComponents) : base(appComponents) { }