public void updateExternalApplication(int id, Update externalApplication) { try { if (externalApplication.MessageTemplate != null) { JObject tmp = JObject.Parse(externalApplication.MessageTemplate); } } catch { throw new Exception("MessageTemplate must be in Json fromat"); } DBHelper._ExternalApplication dbhelp = new DBHelper._ExternalApplication(); ExternalApplication existingExternalApplication = dbhelp.GetByid(id); existingExternalApplication.Name = externalApplication.Name; existingExternalApplication.Description = externalApplication.Description; existingExternalApplication.MessageTemplate = externalApplication.MessageTemplate; existingExternalApplication.Method = externalApplication.Method; existingExternalApplication.ServiceURL = externalApplication.ServiceURL; existingExternalApplication.AuthType = externalApplication.AuthType; existingExternalApplication.AuthID = externalApplication.AuthID; existingExternalApplication.AuthPW = externalApplication.AuthPW; existingExternalApplication.TokenURL = externalApplication.TokenURL; existingExternalApplication.HeaderValues = externalApplication.HeaderValues; existingExternalApplication.TargetType = externalApplication.TargetType; dbhelp.Update(existingExternalApplication); }
public void addExternalApplication(Add externalApplication) { try { if (externalApplication.MessageTemplate != null) { JObject tmp = JObject.Parse(externalApplication.MessageTemplate); } } catch { throw new Exception("MessageTemplate must be in Json fromat"); } DBHelper._ExternalApplication dbhelp = new DBHelper._ExternalApplication(); var newExternalApplication = new ExternalApplication() { Name = externalApplication.Name, Description = externalApplication.Description, CompanyId = externalApplication.CompanyId, MessageTemplate = externalApplication.MessageTemplate, Method = externalApplication.Method, ServiceURL = externalApplication.ServiceURL, AuthType = externalApplication.AuthType, AuthID = externalApplication.AuthID, AuthPW = externalApplication.AuthPW, TokenURL = externalApplication.TokenURL, HeaderValues = externalApplication.HeaderValues, TargetType = externalApplication.TargetType }; dbhelp.Add(newExternalApplication); }
public void deleteExternalApplication(int id) { DBHelper._ExternalApplication dbhelp = new DBHelper._ExternalApplication(); ExternalApplication existingExternalApplication = dbhelp.GetByid(id); dbhelp.Delete(existingExternalApplication); }
public static Menu CreateMenu(IObservable <Optional <AbsoluteFilePath> > path) { var sublimeTextPath = ApplicationPaths.SublimeTextPath(); return(path .SelectPerElement(project => project.ContainingDirectory) .Select(dir => new [] { Menu.Item( name: "Open in Sublime", command: Command.Create( isEnabled: dir.HasValue && sublimeTextPath.HasValue, action: () => Task.Run(() => { if (Platform.OperatingSystem == OS.Mac) { ExternalApplication.FromAppBundle(sublimeTextPath.Value).Open(dir.Value); } else { var ps = new ProcessStartInfo() { FileName = (sublimeTextPath.Value / new FileName("sublime_text.exe")).NativePath, Arguments = "\"" + dir.Value.NativePath + "\"", UseShellExecute = false }; ps.UpdatePathEnvironment(); Process.Start(ps); } }))), }) .Concat()); }
protected Application ApplyForExternalJob(IJobAd jobAd, Guid applicantId) { var application = new ExternalApplication { ApplicantId = applicantId, PositionId = jobAd.Id }; _applicationsCommand.CreateApplication(application); return(application); }
public static ExternalApplicationEntity Map(this ExternalApplication application) { var entity = new ExternalApplicationEntity { id = application.Id }; application.MapTo(entity); return(entity); }
/// <summary> /// This method performs the login operation with the given credential field /// information to identify the controls in the form and the credentials to be populated. /// </summary> /// <param name="application"></param> public void DoLogin(object application) { ExternalApplication app = (ExternalApplication)application; ExternalControl control = (ExternalControl)app.TopLevelWindow; BindingList <LoginFieldRecord> fields = app.LoginFields; //LoginFieldRecord [] fields = app.LoginFields; if (null == fields || fields.Count == 0) { return; } int setFieldCount = 0; // For each credential field, perform the required operation. foreach (LoginFieldRecord field in fields) { // Get the handle of the child control corresponding to the login field. IntPtr controlHandle = GetControlHandle(control.Hwnd, field.ControlSequence); //topWindowHandle, field.ControlSequence); // If the credential field is not found, then the auto sign-on is failed. if (IntPtr.Zero == controlHandle) { throw new LoginFieldNotFoundException(field.LabelName); } switch (field.Operation) { // Set the text of the child window to the corresponding credential. case SET_OPERATION: { Set(controlHandle, app.AgentCreds[setFieldCount]); setFieldCount++; break; } case CLICK_OPERATION: { Click(control.Hwnd, controlHandle); break; } } } }
public void TestSameJobAd() { var applicantId = Guid.NewGuid(); var position1Id = Guid.NewGuid(); var application1 = new ExternalApplication { ApplicantId = applicantId, PositionId = position1Id, CreatedTime = DateTime.Now.AddMinutes(-5) }; _applicationsCommand.CreateApplication(application1); AssertApplications(applicantId, application1); var application2 = new ExternalApplication { ApplicantId = applicantId, PositionId = position1Id, CreatedTime = DateTime.Now.AddMinutes(-1) }; _applicationsCommand.CreateApplication(application2); AssertApplications(applicantId, application1); }
public void TestMultipleJobAds() { var applicantId = Guid.NewGuid(); var position1Id = Guid.NewGuid(); var position2Id = Guid.NewGuid(); var application1 = new ExternalApplication { ApplicantId = applicantId, PositionId = position1Id }; _applicationsCommand.CreateApplication(application1); AssertApplications(applicantId, application1); var application2 = new ExternalApplication { ApplicantId = applicantId, PositionId = position2Id }; _applicationsCommand.CreateApplication(application2); AssertApplications(applicantId, application1, application2); }
public Detail getExternalApplicationById(int id) { DBHelper._ExternalApplication dbhelp = new DBHelper._ExternalApplication(); ExternalApplication externalApplication = dbhelp.GetByid(id); return(new Detail() { Id = externalApplication.Id, Name = externalApplication.Name, Description = externalApplication.Description, CompanyId = externalApplication.CompanyId, MessageTemplate = (externalApplication.MessageTemplate == null) ? null : JObject.Parse(externalApplication.MessageTemplate), Method = externalApplication.Method, ServiceURL = externalApplication.ServiceURL, AuthType = externalApplication.AuthType, AuthID = externalApplication.AuthID, AuthPW = externalApplication.AuthPW, TokenURL = externalApplication.TokenURL, HeaderValues = externalApplication.HeaderValues, TargetType = externalApplication.TargetType }); }
public async Task <ExternalApplicationsResult> Create([FromBody] ExternalApplicationToCreate externalApplicationToCreate) { var bytes = new byte[60]; CryptoRandom.GetBytes(bytes); var applicationKey = Base64UrlTextEncoder.Encode(bytes); var newExternalApplication = new ExternalApplication { Active = externalApplicationToCreate.Active, ActiveUntil = externalApplicationToCreate.ActiveUntil, ApplicationKey = applicationKey, ExternalApplicationId = Guid.NewGuid(), Name = externalApplicationToCreate.Name }; await _externalApplicationStorage.CreateAsync(newExternalApplication); return(new ExternalApplicationsResult { ExternalApplications = new[] { newExternalApplication } }); }
protected override void Importing(ProtectionSettingsPart part, ImportContentContext context) { base.Importing(part, context); var root = context.Data.Element(part.PartDefinition.Name); if (root == null) { return; } var settings = new List <ExternalApplication>(); var webApiUtils = new WebApiUtils(); settings.AddRange(part.ExternalApplicationList.ExternalApplications); var externalApps = root.Elements("ExternalApplication"); foreach (var app in externalApps) { var name = app.Attribute("Name") != null?app.Attribute("Name").Value : ""; var externalApp = settings.FirstOrDefault(x => x.Name == name); if (externalApp == null) { externalApp = new ExternalApplication { Name = name }; settings.Add(externalApp); } externalApp.ApiKey = app.Attribute("ApiKey") != null?app.Attribute("ApiKey").Value : webApiUtils.RandomString(22); externalApp.EnableTimeStampVerification = app.Attribute("EnableTimeStampVerification") != null?bool.Parse(app.Attribute("EnableTimeStampVerification").Value) : true; // default value: true externalApp.Validity = app.Attribute("Validity") != null?int.Parse(app.Attribute("Validity").Value) : 10; // default value: 10 } part.ExternalApplicationList = new ExternalApplicationList { ExternalApplications = settings }; }
public ProgramEventArgs(ExternalApplication program) { Program = program ?? throw new ArgumentNullException(nameof(program)); }
public static void MapTo(this ExternalApplication application, ExternalApplicationEntity entity) { entity.createdTime = application.CreatedTime; entity.positionId = application.PositionId; entity.applicantId = application.ApplicantId; }
public IUnoHostControl Create( AbsoluteFilePath assemblyPath, Command onFocused, Menu contextMenu, AbsoluteFilePath userDataPath, Action <IUnoHostControl> initialize, Action <OpenGlVersion> gotVersion, params string[] arguments) { var currentExeDir = typeof(Application).Assembly.GetCodeBaseFilePath().ContainingDirectory; var contentsDir = currentExeDir / ".." / ".." / ".."; var unoHostBundle = contentsDir / "UnoHost.app"; UnoHostProcess.Application = ExternalApplication.FromAppBundle(unoHostBundle); var unoHostExe = unoHostBundle / "Contents" / "MacOS" / new FileName("UnoHost"); UnoHostProcess.Application = ExternalApplication.FromNativeExe(unoHostExe); var dispatcher = Fusion.Application.MainThread; var messagesToHost = new Subject <IBinaryMessage>(); var unoHost = UnoHostProcess.Spawn(assemblyPath, messagesToHost, userDataPath, /*TODO*/ new List <string>()); var control = new UnoHostControlImplementation() { Disposables = Disposable.Combine(unoHost), Messages = unoHost.Messages, MessagesTo = messagesToHost, Process = unoHost.Process, }; control.Control = Fusion.Control.Create(self => { var view = UnoHostViewFactory.Create(unoHost.Messages, messagesToHost); self.BindNativeDefaults(view.View, dispatcher); view.Focus .Where(foc => foc == FocusState.Focused) .WithLatestFromBuffered(onFocused.Execute.ConnectWhile(self.IsRooted), (_, c) => c) .Subscribe(c => c()); unoHost.Messages .SelectMany(m => m.TryParse(Ready.MessageType, Ready.ReadDataFrom)) .Take(1) .Subscribe(_ => initialize(control)); unoHost.Messages .SelectSome(OpenGlVersionMessage.TryParse) .Subscribe(gotVersion); unoHost.Messages.Connect(); return(view.View); }).SetContextMenu(contextMenu); return(control); }
public IUnoHostControl Create( AbsoluteFilePath assemblyPath, Command onFocused, Menu contextMenu, AbsoluteFilePath userDataPath, Action <IUnoHostControl> initialize, Action <OpenGlVersion> gotVersion, params string[] arguments) { UnoHostProcess.Application = ExternalApplication.FromNativeExe(typeof(UnoHostControlFactory).Assembly.GetCodeBaseFilePath()); var dispatcher = Fusion.Application.MainThread; var messagesToHost = new Subject <IBinaryMessage>(); var unoHost = UnoHostProcess.Spawn(assemblyPath, messagesToHost, userDataPath, /*TODO*/ new List <string>()); unoHost.Process.Subscribe(process => new Job().AddProcess(process.Id)); var windowCreated = unoHost.Receieve(WindowCreatedMessage.TryParse).Replay(1); windowCreated.Connect(); var control = new UnoHostControlImplementation() { _disposable = unoHost, Messages = unoHost.Messages, MessagesTo = messagesToHost, Process = unoHost.Process, }; control.Control = Fusion.Control.Create(location => { var dummyControl = Shapes.Rectangle(); dummyControl.Mount(location); var dummyElement = (FrameworkElement)dummyControl.NativeHandle; location.IsRooted .ObserveOn(dispatcher) .SubscribeUsing(rooted => rooted ? ContextMenuImplementation.AddMenuTemporarily(dummyElement, contextMenu, dispatcher) : Disposable.Empty); var mainWindow = DataBinding .ObservableFromNativeEvent <object>(dummyElement, "LayoutUpdated") .StartWith(new object()) .Select(_ => { var hwndSource1 = PresentationSource.FromVisual(dummyElement); if (hwndSource1 == null) { return(Optional.None <System.Windows.Window>()); } var window = hwndSource1.RootVisual as System.Windows.Window; if (window == null) { return(Optional.None <System.Windows.Window>()); } return(Optional.Some(window)); }) .DistinctUntilChanged() .NotNone() .Replay(1).RefCount(); var mainWindowHandle = mainWindow.Select(currentWindow => { var hwndSource = (HwndSource)PresentationSource.FromVisual(currentWindow); if (hwndSource == null) { return(Optional.None()); } return(Optional.Some(hwndSource.Handle)); }) .NotNone() .Replay(1); mainWindowHandle.Connect(); var focused = unoHost.Receieve(WindowFocusMessage.TryParse) .Where(focusState => focusState == FocusState.Focused); focused.CombineLatest(mainWindowHandle, (a, b) => b) .ObserveOn(dispatcher) .Subscribe(t => WinApi.ShowWindow(t, WinApi.ShowWindowEnum.ShowNoActivate)); unoHost.Receieve(WindowContextMenuMessage.TryParse) .ObserveOn(dispatcher) .Subscribe(t => dummyElement.ContextMenu.IsOpen = t); unoHost.Receieve(WindowMouseScrollMessage.TryParse) .ObserveOn(dispatcher) .Subscribe(deltaWheel => { var delta = deltaWheel; var routedEvent = Mouse.MouseWheelEvent; dummyElement.RaiseEvent( new MouseWheelEventArgs( Mouse.PrimaryDevice, Environment.TickCount, delta) { RoutedEvent = routedEvent, Source = dummyElement }); }); // This is a fix for a commit that "fixed" handling the shortcuts, but broke just // plain typing in a TextInput. // See https://github.com/fusetools/Fuse/issues/3342 // and https://github.com/fusetools/Fuse/issues/3887 // Workaround to fix a problem with handling shortcut keys in the application while // the viewport has focus and the user is typing in an TextInput in the app. // We have give the main window focus to handle the shortcut keys, but then // the viewport will lose focus. Current work around is to only do this when // the user presses down Ctrl. unoHost.Receieve(WindowKeyDown.TryParse) .WithLatestFromBuffered(mainWindow, (t, w) => new { Keys = t, Window = w }) .ObserveOn(dispatcher) .Subscribe(t => { var modifiers = System.Windows.Input.Keyboard.PrimaryDevice.Modifiers; var alt = modifiers.HasFlag(System.Windows.Input.ModifierKeys.Alt); // Activate the main window if the Ctrl-key was pressed. // Ctrl + Alt means AltGr which we want to keep in the Uno host e.g. for the '@' key on Nordic keyboards. if (t.Keys == Keys.ControlKey && !alt) { t.Window.Activate(); } }); focused .WithLatestFromBuffered(onFocused.Execute.ConnectWhile(dummyControl.IsRooted), (_, c) => c) .Subscribe(c => c()); var overlayForm = new OverlayForm(); Observable .CombineLatest(windowCreated, mainWindowHandle, (viewportHwnd, mainHwnd) => new { ViewportHwnd = viewportHwnd, MainHwnd = mainHwnd, }) .ObserveOn(dispatcher) .SubscribeUsing(t => overlayForm.BindTo(t.ViewportHwnd, t.MainHwnd, dummyControl, dummyElement.GetDpi())); unoHost.Messages .SelectMany(m => m.TryParse(Ready.MessageType, Ready.ReadDataFrom)) .Take(1) .Subscribe(_ => initialize(control)); unoHost.Messages .SelectSome(OpenGlVersionMessage.TryParse) .Subscribe(gotVersion); unoHost.Messages.Connect(); return(dummyElement); }); return(control); }
public static IFuse Initialize(string programName, List <string> args) { var systemId = SystemGuidLoader.LoadOrCreateOrEmpty(); var sessionId = Guid.NewGuid(); var report = ReportFactory.GetReporter(systemId, sessionId, programName); AppDomain.CurrentDomain.ReportUnhandledExceptions(report); report.Info("Initializing with arguments '" + args.Join(" ") + "'"); // Report running mono version Type type = Type.GetType("Mono.Runtime"); if (type != null) { MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName != null) { report.Info("Running with Mono " + displayName.Invoke(null, null)); } } EnsureSpecialFoldersExist(); var fuseExeOverride = args .TryParse("override-fuse-exe") .SelectMany(AbsoluteFilePath.TryParse); var rootDirSetByArgs = Optional.None <AbsoluteDirectoryPath>(); /*args * .FirstOrNone(a => a.StartsWith("fuse-root")) * .Select(a => a.Substring(a.IndexOf("=", StringComparison.InvariantCulture) + 1, a.Length - 1 - a.IndexOf("=", StringComparison.InvariantCulture))) * .Select(AbsoluteDirectoryPath.Parse);*/ var os = Platform.OperatingSystem; var fuseRoot = rootDirSetByArgs .Or(() => GetFuseRoot(os)) .OrThrow(new FuseRootDirectoryWasNotFound()); if (os != OS.Mac && os != OS.Windows) { throw new UnsupportedPlatformException(os); } var isMac = os == OS.Mac; var mono = isMac ? Optional.Some(FindMonoExe(fuseRoot)) : Optional.None(); var codeAssistanceService = new FileName("Fuse.CodeAssistanceService.exe"); var fuseExe = fuseExeOverride.Or(isMac ? fuseRoot / "MacOS" / new FileName("Fuse") : fuseRoot / new FileName("Fuse.exe")); var unoExe = FindUnoExe(fuseRoot); var impl = new FuseImpl { FuseRoot = fuseRoot, Version = SystemInfoFactory.GetBuildVersion(), UnoExe = unoExe, FuseExe = fuseExe, MonoExe = mono, Fuse = ExternalApplication.FromNativeExe(fuseExe), // Tools Designer = isMac ? ExternalApplication.FromAppBundle(fuseRoot / new FileName("Fuse Studio.app")) : ExternalApplication.FromNativeExe(fuseRoot / new FileName("Fuse Studio.exe")), // Services CodeAssistance = isMac ? ExternalApplication.FromMonoExe(fuseRoot / "MonoBundle" / codeAssistanceService, mono) : ExternalApplication.FromNativeExe(fuseRoot / codeAssistanceService), Tray = isMac ? ExternalApplication.FromNativeExe(fuseRoot / "Fuse Tray.app" / "Contents" / "MacOS" / new FileName("Fuse Tray")) : ExternalApplication.FromNativeExe(fuseRoot / new FileName("Fuse-Tray.exe")), LogServer = isMac ? ExternalApplication.FromNativeExe(fuseRoot / new FileName("fuse-logserver")) : null, // Uno Uno = isMac ? ExternalApplication.FromMonoExe(unoExe, mono) : ExternalApplication.FromNativeExe(unoExe), // System paths UserDataDir = isMac ? AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(Environment.SpecialFolder.Personal)) / ".fuse" : AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) / "Fusetools" / "Fuse", ProjectsDir = AbsoluteDirectoryPath.Parse(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) / "Fuse", SystemId = systemId, SessionId = sessionId, Report = report }; var partial = args.Remove("--partial") | args.Remove("-p"); if (!partial) { impl.CheckCompleteness(); } // Set assembly configuration for .unoconfig, to be able to find correct bin/$(Configuration) directories. #if DEBUG UnoConfigFile.Constants["Configuration"] = "Debug"; #else UnoConfigFile.Constants["Configuration"] = "Release"; #endif return(impl); }