예제 #1
0
        public EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();
            if (context is ContentEventContext)
            {
                try
                {
                    ContentEventContext contentEventContext = (ContentEventContext)context;
                    if (contentEventContext.ContentAction == ContentAction.Add && contentEventContext.Content is TextContent)
                    {
                        var textContent = (TextContent)contentEventContext.Content;
                        var folder = (TextFolder)textContent.GetFolder().AsActual();
                        if (folder.EnabledWorkflow && !string.IsNullOrEmpty(contentEventContext.Content.UserId))
                        {
                            Services.ServiceFactory.WorkflowManager.StartWorkflow(textContent.GetRepository()
                                , folder.WorkflowName
                                , textContent
                                , contentEventContext.Content.UserId);
                        }
                    }
                }
                catch (Exception e)
                {
                    eventResult.Exception = e;
                }

            }
            return eventResult;
        }
예제 #2
0
        public EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();
            if (context is ContentEventContext)
            {
                try
                {
                    var contentContext = ((ContentEventContext)context);
                    if (contentContext.Content.___EnableVersion___)
                    {
                        if (contentContext.Content is TextContent)
                        {
                            switch (contentContext.ContentAction)
                            {
                                case Kooboo.CMS.Content.Models.ContentAction.Delete:
                                    break;
                                case Kooboo.CMS.Content.Models.ContentAction.Add:
                                case Kooboo.CMS.Content.Models.ContentAction.Update:
                                    Versioning.VersionManager.LogVersion((TextContent)(contentContext.Content));
                                    break;
                                default:

                                    break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    eventResult.Exception = e;
                }               
            }
            return eventResult;
        }
예제 #3
0
        public virtual EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();
            try
            {
                if (context is ContentEventContext)
                {
                    var contentEventContext = (ContentEventContext)context;

                    //Can not run the content broadcasting in parallel threads, must to make sure the execution by sequence.
                    //Thread processThread = new Thread(delegate()
                    //{
                    var contentContext = (ContentEventContext)context;

                    try
                    {
                        var sendingRepository = contentContext.Content.GetRepository().AsActual();
                        var sendingSetting = AllowSending(contentContext.Content, sendingRepository, contentContext);
                        if (sendingSetting != null)
                        {
                            var allRepositories = Services.ServiceFactory.RepositoryManager.All().Where(it => string.Compare(it.Name, sendingRepository.Name, true) != 0);

                            var summarize = contentContext.Content.GetSummary();
                            foreach (var receiver in allRepositories)
                            {
                                var repository = receiver.AsActual();
                                if (repository.EnableBroadcasting)
                                {
                                    Services.ServiceFactory.ReceiveSettingManager.ReceiveContent(repository, contentContext.Content, contentContext.ContentAction);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Bsc.Dmtds.Common.HealthMonitoring.Log.LogException(e);
                    }
                    //});

                    //processThread.Start();
                }
            }
            catch (Exception e)
            {
                eventResult.Exception = e;
            }

            return eventResult;
        }
        public virtual EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();
            try
            {
                if (context is ContentEventContext)
                {
                    var contentEventContext = (ContentEventContext)context;

                    Thread processThread = new Thread(delegate()
                    {
                        var contentContext = (ContentEventContext)context;

                        try
                        {
                            var sendingRepository = contentContext.Content.GetRepository().AsActual();
                            var sendingSetting = AllowSending(contentContext.Content, sendingRepository, contentContext);
                            if (sendingSetting != null)
                            {
                                var allRepositories = Services.ServiceFactory.RepositoryManager.All().Where(it => string.Compare(it.Name, sendingRepository.Name, true) != 0);

                                var summarize = contentContext.Content.GetSummary();
                                foreach (var receiver in allRepositories)
                                {
                                    var repository = receiver.AsActual();
                                    if (repository.EnableBroadcasting)
                                    {
                                        Services.ServiceFactory.ReceiveSettingManager.ReceiveContent(repository, contentContext.Content, contentContext.ContentAction);
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Kooboo.HealthMonitoring.Log.LogException(e);
                        }
                    });

                    processThread.Start();
                }
            }
            catch (Exception e)
            {
                eventResult.Exception = e;
            }

            return eventResult;
        }
예제 #5
0
        public EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();
            if (context is ContentEventContext)
            {
                try
                {
                    var contentEventContext = (ContentEventContext)context;
                    switch (contentEventContext.ContentAction)
                    {
                        case Kooboo.CMS.Content.Models.ContentAction.Add:
                            break;
                        case Kooboo.CMS.Content.Models.ContentAction.Update:
                            break;
                        case Kooboo.CMS.Content.Models.ContentAction.Delete:
                            break;
                        case Kooboo.CMS.Content.Models.ContentAction.PreAdd:
                            if (contentEventContext.Content.Sequence == 0)
                            {
                                var textFolder = contentEventContext.Content.GetFolder().AsActual();
                                int sequence = 1;
                                var maxSequenceContent = textFolder.CreateQuery().OrderByDescending("Sequence").FirstOrDefault();
                                if (maxSequenceContent != null)
                                {
                                    sequence = maxSequenceContent.Sequence + 1;
                                }
                                contentEventContext.Content.Sequence = sequence;

                            }

                            break;
                        case Kooboo.CMS.Content.Models.ContentAction.PreUpdate:
                            break;
                        case Kooboo.CMS.Content.Models.ContentAction.PreDelete:
                            break;
                        default:
                            break;
                    }
                }
                catch (Exception e)
                {
                    eventResult.Exception = e;
                }
                
            }
            return eventResult;
        }
예제 #6
0
 /// <summary>
 /// Instanciate New Event Message
 /// </summary>
 /// <param name="level">as event level</param>
 /// <param name="action">as event action</param>
 /// <param name="result">as event result</param>
 /// <param name="data">as event messages in list</param>
 /// <param name="app">as application</param>
 /// <param name="appver">as application version</param>
 /// <param name="opcode">as operation code</param>
 /// <param name="keys">as key words</param>
 /// <param name="uid">us user's identifier</param>
 /// <param name="ip">as client's ip address</param>
 /// <param name="url">as assoicated page url</param>
 public EventMessage(EventLevel level, EventAction action, EventResult result, List<String> data, String app,
                     String appver = "", String opcode = "", String keys = "", String uid = "", String ip = "", String url = "")
 {
     SetBase();
     Level = level;
     Action = action;
     Result = result;
     Data = data;
     Application = app;
     ApplicationVersion = appver;
     OperationCode = opcode;
     KeyWords = keys;
     EventDateTime = DateTime.UtcNow;
     IP = ip;
     URL = url;
     if (!String.IsNullOrEmpty(uid)) UID = new Guid(uid);
 }
        public EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();

            if (context is ContentEventContext)
            {
                var contentEventContext = (ContentEventContext)context;
                if (contentEventContext.ContentAction == Models.ContentAction.Delete)
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            var textFolder = contentEventContext.Content.GetFolder().AsActual();

                            // Delete the child contents in this folder.
                            DeleteChildContents(contentEventContext.Content, textFolder, textFolder);

                            if (textFolder.EmbeddedFolders != null)
                            {
                                foreach (var folderName in textFolder.EmbeddedFolders)
                                {
                                    var childFolder = new TextFolder(textFolder.Repository, folderName);
                                    DeleteChildContents(contentEventContext.Content, textFolder, childFolder);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            eventResult.Exception = e;
                        }

                    });
                }
            }

            return eventResult;
        }
예제 #8
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "Dicom Study Deleted" event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <remarks>
		/// This method automatically separates different patients into separately logged events, as required by DICOM.
		/// </remarks>
		/// <param name="aeTitle">The application entity from which the instances were deleted.</param>
		/// <param name="instances">The studies that were deleted.</param>
		/// <param name="eventSource">The source user or application entity which invoked the operation.</param>
		/// <param name="eventResult">The result of the operation.</param>
		public static void LogDeleteStudies(string aeTitle, AuditedInstances instances, EventSource eventSource, EventResult eventResult)
		{
			AuditLogHelper.LogDeleteStudies(aeTitle, instances, eventSource, eventResult);
		}
 public override void SetResult(EventResult <EnterpriseResourceCollection> result)
 {
     Param.Form.SetAdditional(result.Result.Count.ToString());
 }
예제 #10
0
        public async Task Invoke(HttpContext context)
        {
            var  stopWatch   = new Stopwatch();
            long elapsedTime = 0;

            var   eventStart  = DateTimeOffset.UtcNow;
            Event eventObject = null;

            try
            {
                //executing service
                stopWatch.Start();
                await _next(context).ConfigureAwait(false);

                stopWatch.Stop();

                //resolving status code and duration
                elapsedTime = stopWatch.ElapsedMilliseconds;
            }
            catch (Exception e)
            {
                //stopping stopwatch and resolving event
                if (stopWatch.IsRunning)
                {
                    stopWatch.Stop();
                }

                eventObject = context.GetEvent();

                if (eventObject == null)
                {
                    eventObject = Event.CreateNone();
                }

                elapsedTime = stopWatch.ElapsedMilliseconds;

                //logging event error
                _logger.LogError(eventObject.EventId, e, null, eventObject.EventInputs);
                context.Response.StatusCode = 500;
            }
            finally
            {
                //resolving event
                if (eventObject == null)
                {
                    eventObject = context.GetEvent();
                }

                //saving event result
                if (eventObject != null && Event.None.Id != eventObject.EventId.Id)
                {
                    var eventResult = new EventResult(eventObject, eventStart, elapsedTime,
                                                      context.Response.StatusCode, context.Request.GetTest());

                    _eventResultDAO.Insert(eventResult);
                    eventResult = null;
                }

                //returning public error msg
                if (context.Response.StatusCode == 500)
                {
                    await context.Response.WriteAsync("Internal Server Error.").ConfigureAwait(false);
                }

                eventObject = null;
            }
        }
예제 #11
0
        public Item Duplicate(ClientPipelineArgs args)
        {
            Item result = null;

            Assert.ArgumentNotNull(args, "args");

            var database = Factory.GetDatabase(args.Parameters["database"]);

            Assert.IsNotNull(database, args.Parameters["database"]);

            var itemId     = args.Parameters["id"];
            var sourceItem = database.Items[itemId];

            if (sourceItem == null)
            {
                SheerResponse.Alert(Translate.Text("Item not found."));
            }
            else
            {
                Item parent = sourceItem.Parent;
                if (parent == null)
                {
                    SheerResponse.Alert(Translate.Text("Cannot duplicate the root item."));
                }
                else if (parent.Access.CanCreate())
                {
                    Log.Audit(this, "Duplicate item: {0}", new string[1] {
                        AuditFormatter.FormatItem(sourceItem)
                    });
                    var bucketItemOrSiteRoot = ItemExtensions.GetParentBucketItemOrSiteRoot(sourceItem);
                    if (BucketManager.IsBucket(bucketItemOrSiteRoot) && BucketManager.IsBucketable(sourceItem))
                    {
                        if (!EventDisabler.IsActive)
                        {
                            EventResult eventResult = Event.RaiseEvent("item:bucketing:duplicating", args, this);
                            if (eventResult != null && eventResult.Cancel)
                            {
                                Log.Info(string.Format("Event {0} was cancelled", "item:bucketing:duplicating"), this);
                                args.AbortPipeline();
                                return(null);
                            }
                        }
                        result = Context.Workflow.DuplicateItem(sourceItem, args.Parameters["name"]);
                        Item destination = CreateAndReturnBucketFolderDestination(bucketItemOrSiteRoot, DateUtil.ToUniversalTime(DateTime.Now), sourceItem);
                        if (!IsBucketTemplateCheck(sourceItem))
                        {
                            destination = bucketItemOrSiteRoot;
                        }

                        ItemManager.MoveItem(result, destination);

                        if (!EventDisabler.IsActive)
                        {
                            Event.RaiseEvent("item:bucketing:duplicated", args, this);
                        }
                    }
                    else
                    {
                        result = Context.Workflow.DuplicateItem(sourceItem, args.Parameters["name"]);
                    }
                }
                else
                {
                    SheerResponse.Alert(Translate.Text("You do not have permission to duplicate \"{0}\".", sourceItem.DisplayName));
                }
            }
            args.AbortPipeline();
            return(result);
        }
예제 #12
0
 public void TestInvalidParams_2()
 {
     SmartsheetClient smartsheet  = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build();
     EventResult      eventResult = smartsheet.EventResources.ListEvents(DateTime.Today, null, 10, true);
 }
예제 #13
0
 public override EventResult Pause()
 {
     Click();
     return(EventResult.Complete());
 }
예제 #14
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a (received) "Query" event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <param name="remoteAETitle">The application entity that issued the query.</param>
		/// <param name="remoteHostName">The hostname of the application entity that issued the query.</param>
		/// <param name="eventResult">The result of the operation.</param>
		/// <param name="sopClassUid">The SOP Class Uid of the type of DICOM Query being received.</param>
		/// <param name="query">The dataset containing the DICOM query received.</param>
		public static void LogQueryReceived(string remoteAETitle, string remoteHostName, EventResult eventResult, string sopClassUid, DicomAttributeCollection query)
		{
			AuditLogHelper.LogQueryReceived(LocalAETitle, remoteAETitle, remoteHostName, EventSource.GetCurrentDicomAE(), eventResult, sopClassUid, query);
		}
        //TODO: add correct search criteria
        //year  month and roleBased
        private List <EventResult> SearchEvents(int month, int year)
        {
            //the resource will be searched only for the logged in users

            List <EventResult> results = new List <EventResult>();

            // Find pages that contain our search text in either their nodeName or bodyText fields...
            // but exclude any pages that have been hidden.
            // searchCriteria.Fields("nodeName",terms.Boost(8)).Or().Field("metaTitle","hello".Boost(5)).Compile();

            //if nothing selected return null result
            //if (model.ResTerm.IsNullOrWhiteSpace()
            //    && model.SelectedFileTypes == null
            //    && model.SelectedSubjects == null
            //    && model.SelectedAudences == null
            //    && model.SelectedActivities == null
            //    && model.State.IsNullOrWhiteSpace())
            //{
            //    return results;
            //}

            if (User.Identity.IsAuthenticated)
            {
                string[] roles = System.Web.Security.Roles.GetRolesForUser(User.Identity.Name);

                //Event search

                var criteriaEventRestricted = ExamineManager.Instance
                                              .SearchProviderCollection["EventSearcher"]
                                              .CreateSearchCriteria(BooleanOperation.Or);

                Examine.SearchCriteria.IBooleanOperation filter = null;


                filter = criteriaEventRestricted.Field("IsPublic", "false"); //just to start a dummy this is OR

                filter = filter.And().Field("roles", roles[0]);
                filter = filter.And().Field("eventmonth", month.ToString());
                filter = filter.And().Field("eventyear", year.ToString());

                //add date and month
                //filter = filter.And().Field()

                //if (model.ResTerm != null && model.ResTerm.Length > 0)
                //    filter = filter.And().GroupedOr(new string[] { "description", "eventtitle", "nodeName", "name", "seo", "intendedaudiences"}, model.ResTerm);



                ISearchResults SearchResults = ExamineManager.Instance
                                               .SearchProviderCollection["EventSearcher"]
                                               .Search(filter.Compile());


                foreach (var sr in SearchResults)
                {
                    EventResult result = new EventResult()
                    {
                        Id        = sr.Fields.ContainsKey("id") ? sr.Fields["id"] : "",
                        Url       = Umbraco.Content(sr.Fields["id"]).Url,
                        NodeName  = sr.Fields.ContainsKey("nodeName") ? sr.Fields["nodeName"] : "",
                        Text      = sr.Fields.ContainsKey("description") ? sr.Fields["description"] : "",
                        sdtTime   = sr.Fields.ContainsKey("datetimefrom") ? sr.Fields["datetimefrom"] : "",
                        sdtTimeTo = sr.Fields.ContainsKey("datetimeto") ? sr.Fields["datetimeto"] : "",
                    };

                    result.Text = result.Text.Substring(0, Math.Min(result.Text.Length, 250));


                    DateTime myDate;
                    if (DateTime.TryParse(result.sdtTime, out myDate))
                    {
                        result.day      = myDate.Day;
                        result.month    = myDate.Month;
                        result.year     = myDate.Year;
                        result.timeFrom = myDate.ToShortTimeString();
                    }
                    else
                    {
                        // handle parse failure
                    }

                    DateTime myDateTo;
                    if (DateTime.TryParse(result.sdtTimeTo, out myDateTo))
                    {
                        result.timeTo = myDateTo.ToShortTimeString();
                    }
                    else
                    {
                        // handle parse failure
                    }



                    results.Add(result);
                }
            }


            return(results);
        }
예제 #16
0
 public InternalEventResult(EventResult result, ExceptionDispatchInfo?exception)
 {
     Exception = exception;
     Result    = result;
 }
예제 #17
0
 /// <summary>
 /// Pause button pressed
 /// </summary>
 /// <returns></returns>
 public override Sites.Entities.EventResult Pause()
 {
     DoPlayOrPause();
     return(EventResult.Complete());
 }
예제 #18
0
        public override EventResult BrowserDocumentComplete()
        {
            MessageHandler.Info("Url: {0}, login: {1}, clicked: {2}, maximized: {3}", Url, login.ToString(), clicked.ToString(), maximized.ToString());
            if (login)
            {
                if (refreshed)
                {
                    login = false;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                else
                {
                    if (!clicked)
                    {
                        string js = " function doLogin() { ";
                        js += "document.getElementsByName('username')[0].value = '" + username + "'; ";
                        js += "document.getElementsByName('password')[0].value = '" + password + "'; ";
                        js += "document.getElementsByClassName('btn')[0].click(); }; ";
                        js += "setTimeout(\"doLogin()\", 1500); ";
                        InvokeScript(js);
                        clicked = true;
                        System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                        timer.Tick += (object sender, EventArgs e) =>
                        {
                            refreshed = true;
                            timer.Stop();
                            timer.Dispose();
                            //Browser.Refresh();
                            Url = "https://www.tv4play.se/";
                        };
                        timer.Interval = 3000;
                        timer.Start();
                    }
                }
            }
            else
            {
                InvokeScript("setTimeout(\"document.getElementById('player').setAttribute('style', 'position: fixed; z-index: 11000; top: 0px; left: 0px; width: 100%; height: 100%')\", 1000);");
                if (startTimer)
                {
                    startTimer = false;
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick += (object sender, EventArgs e) =>
                    {
                        if (showLoading)
                        {
                            HideLoading();
                        }
                        timer.Stop();
                        timer.Dispose();
                    };

                    timer.Interval = 2250;
                    timer.Start();

                    System.Windows.Forms.Timer maxTimer = new System.Windows.Forms.Timer();
                    maxTimer.Tick += (object sender, EventArgs e) =>
                    {
                        Cursor.Position = new System.Drawing.Point(Browser.FindForm().Right - 100, Browser.FindForm().Bottom - 100);
                        Application.DoEvents();
                        Cursor.Position = new System.Drawing.Point(Browser.FindForm().Right - 35, Browser.FindForm().Bottom - 35);
                        Application.DoEvents();
                        CursorHelper.DoLeftMouseClick();
                        Application.DoEvents();
                        Cursor.Position = new System.Drawing.Point(Browser.FindForm().Right - 100, Browser.FindForm().Bottom - 100);
                        Application.DoEvents();
                        //Workaround for keeping maximized flashplayer on top
                        Browser.FindForm().Activated += FormActivated;
                        InvokeScript("document.getElementById('player').focus();"); //Prevent play/pause problem
                        maximized = true;
                        maxTimer.Stop();
                        maxTimer.Dispose();
                    };
                    maxTimer.Interval = isPremium ? 15000 : 60000;
                    maxTimer.Start();
                }
                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;
            }
            return(EventResult.Complete());
        }
        public void EnqueueEventRaisedLogEntry <TEvent>(TimeSpan loggedTotalWorldTime, TEvent @event, EventResult result)
            where TEvent : Event
        {
            @event.ThrowIfNull("event");

            if (result == EventResult.None)
            {
                return;
            }

            var entry = new LogEntry(loggedTotalWorldTime, @event, result == EventResult.Completed ? LogEntryType.EventComplete : LogEntryType.EventCanceled, LogEntryLifetime);

            EnqueueLogEntry(entry);
        }
예제 #20
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "User Authentication" login event in the audit log, according to DICOM Supplement 95,
		/// and a "Security Alert" event if the operation failed.
		/// </summary>
		/// <param name="username">The username or asserted username of the account that was logged in.</param>
		/// <param name="eventResult">The result of the operation.</param>
		public static void LogLogin(string username, EventResult eventResult)
		{
			AuditLogHelper.LogLogin(username, eventResult);
		}
        public void EventRaised(Event @event, EventResult result)
        {
            @event.ThrowIfNull("event");

            _logRendererState.EnqueueEventRaisedLogEntry(_worldTime.Total, @event, result);
        }
예제 #22
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "User Authentication" logout event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <param name="username">The username or asserted username of the account that was logged out.</param>
		/// <param name="eventResult">The result of the operation.</param>
		/// <param name="sessionId">The ID of the session that is being logged out.</param>
		public static void LogLogout(string username, string sessionId, EventResult eventResult)
		{
			AuditLogHelper.LogLogout(username, sessionId, eventResult);
		}
        public void Subscribe <T, TH>(Func <TH> handler, string topicName, int maxConcurrent = 1)
            where T : Event
            where TH : IEventHandler <T>
        {
            new Thread(async() => {
                try {
                    string subscription = _busSettings.SubscriptionName.ToLower() + "-" + topicName.ToLower();
                    SubscriberClient subscriber;
                    CreateSubscription(topicName, subscription);
                    // Pull messages from the subscription using SimpleSubscriber.
                    SubscriptionName subscriptionName = new SubscriptionName(_busSettings.ProjectId, subscription);
                    subscriber = await SubscriberClient.CreateAsync(
                        subscriptionName,
                        null,
                        new SubscriberClient.Settings {
                        FlowControlSettings = new Google.Api.Gax.FlowControlSettings(maxConcurrent, null)
                    }
                        );

                    await subscriber.StartAsync(async(PubsubMessage message, CancellationToken token) => {
                        T eventMessage;
                        if ((_busSettings.Token != null && _busSettings.Token != "") && (!message.Attributes.ContainsKey("token") || message.Attributes["token"] != _busSettings.Token))
                        {
                            return(SubscriberClient.Reply.Ack);
                        }
                        try{
                            eventMessage = JsonConvert.DeserializeObject <T>(message.Data.ToStringUtf8());
                        }catch (JsonException ex) {
                            Console.WriteLine(ex.Message);
                            return(SubscriberClient.Reply.Ack);
                        }
                        try{
                            eventMessage.EventId   = message.MessageId;
                            eventMessage.Timestamp = message.PublishTime.Seconds * 1000;
                        }catch (NullReferenceException ex) {
                            Console.WriteLine(ex.Message);
                            return(SubscriberClient.Reply.Ack);
                        }
                        var invoke         = handler.DynamicInvoke();
                        var concreteType   = typeof(IEventHandler <>).MakeGenericType(typeof(T));
                        EventResult result = await(Task <EventResult>) concreteType.GetMethod("Handle").Invoke(invoke, new object[] { eventMessage, null });
                        if (result == EventResult.Success)
                        {
                            return(SubscriberClient.Reply.Ack);
                        }
                        else
                        {
                            return(SubscriberClient.Reply.Nack);
                        }
                    });
                    new Thread(() => Subscribe <T, TH>(handler, topicName, maxConcurrent)).Start();
                }
                // Restart when connection fail
                catch (RpcException ex)
                {
                    Console.WriteLine(ex.Message);
                    new Thread(() => Subscribe <T, TH>(handler, topicName, maxConcurrent)).Start();
                    return;
                }
            }).Start();
        }
예제 #24
0
        /// <summary>
        /// Add Event Message to system
        /// </summary>
        /// <param name="pconstring">as data source connection string</param>
        /// <param name="level">as event level</param>
        /// <param name="action">as event action</param>
        /// <param name="result">as event result</param>
        /// <param name="message">as event messages in list</param>
        /// <param name="app">as application</param>
        /// <param name="appver">as application version</param>
        /// <param name="opcode">as operation code</param>
        /// <param name="keys">as key words</param>
        /// <param name="user">as assoicated user</param>
        /// <param name="ip">as client's ip address</param>
        /// <param name="url">as assoicated page url</param>
        /// <returns></returns>
        public static bool Add(string pconstring, EventLevel level, EventAction action, EventResult result, String message, String app,
                            String appver = "", String opcode = "", String keys = "", CustomSecurity.User user = null, String ip = "", String url = "")
        {
            String suid = "";
            if (user != null && user.UID != null) suid = user.UID.ToString();
            EventMessage ev = new EventMessage(level: level, action: action, result: result, app: app, message: message, appver: appver, opcode: opcode, keys: keys.ToLower(), uid: suid, ip: ip, url: url);

            return ev.Add(pconstring);
        }
예제 #25
0
 public override EventResult PerformLogin(string username, string password)
 {
     ProcessComplete.Finished = true;
     ProcessComplete.Success  = true;
     return(EventResult.Complete());
 }
예제 #26
0
 internal static bool EqualsIgnoreEventId(EventResult expected, EventResult actual)
 {
     return((expected.ObjectExists == actual.ObjectExists) && (expected.Result == actual.Result) && (expected.Message == actual.Message));
 }
예제 #27
0
        public override Entities.EventResult BrowserDocumentComplete()
        {
            string jsCode;

            switch (_currentState)
            {
            case State.Login:

                if (Url.Contains("/Login?"))
                {
                    jsCode  = "document.getElementById('email').value = '" + _username + "'; ";
                    jsCode += "document.getElementById('password').value = '" + _password + "'; ";
                    if (_rememberLogin)
                    {
                        jsCode += "document.getElementById('RememberMe').checked = true; ";
                    }
                    else
                    {
                        jsCode += "document.getElementById('RememberMe').checked = false; ";
                    }
                    jsCode += "document.getElementById('login-form-contBtn').click();";
                    InvokeScript(jsCode);
                    _currentState = State.Profile;
                }
                else
                {
                    Url           = "https://www.netflix.com/SwitchProfile?tkn=" + _profile;
                    _currentState = State.ReadyToPlay;
                }
                break;

            case State.Profile:
                if (Url.Contains("/WiHome") || Url.Contains("/Kids") || Url.Contains("/ProfilesGate"))
                {
                    Url           = "https://www.netflix.com/SwitchProfile?tkn=" + _profile;
                    _currentState = State.ReadyToPlay;
                }
                break;

            case State.ReadyToPlay:
                if (Url.Contains("/WiHome") || Url.Contains("/Kids"))
                {
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                break;

            case State.StartPlay:
            case State.Playing:
                if (Url.Contains("movieid"))
                {
                    if (_showLoading)
                    {
                        HideLoading();
                    }
                    _currentState            = State.Playing;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                break;
            }
            return(EventResult.Complete());
        }
예제 #28
0
 public void TestInvalidParams()
 {
     SmartsheetClient smartsheet  = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build();
     EventResult      eventResult = smartsheet.EventResources.ListEvents(0, "2.1.0An4ZapaQaOXPdojlmediSZ1WqMdi5U_3l9gViOW7ic", 10, null);
 }
예제 #29
0
 public virtual void SetResult(EventResult <Result> result)
 {
     return;
 }
예제 #30
0
        public override Entities.EventResult BrowserDocumentComplete()
        {
            string jsCode;

            if (!_disableLogging)
            {
                MessageHandler.Info("Netflix. Url: {0}, State: {1}", Url, _currentState.ToString());
            }
            switch (_currentState)
            {
            case State.Login:
                if (Url.Contains("/Login?"))
                {
                    jsCode  = "document.getElementById('email').value = '" + _username + "'; ";
                    jsCode += "document.getElementById('password').value = '" + _password + "'; ";
                    if (_rememberLogin)
                    {
                        jsCode += "document.getElementById('RememberMe').checked = true; ";
                    }
                    else
                    {
                        jsCode += "document.getElementById('RememberMe').checked = false; ";
                    }
                    jsCode += "document.getElementById('login-form-contBtn').click();";
                    InvokeScript(jsCode);
                    _currentState = State.ProfilesGate;
                }
                else
                {
                    Url           = "https://www.netflix.com/ProfilesGate";
                    _currentState = State.SelectProfile;
                }
                break;

            case State.ProfilesGate:
                Url           = "https://www.netflix.com/ProfilesGate";
                _currentState = State.SelectProfile;
                break;

            case State.SelectProfile:
                if (Url.Contains("/ProfilesGate"))
                {
                    InvokeScript("document.querySelector('a[data-reactid*=" + _profile + "]').click();");
                    _currentState = State.ReadyToPlay;
                }
                break;

            case State.ReadyToPlay:
                //Sometimes the profiles gate loads again
                if (Url.Contains("/ProfilesGate"))
                {
                    InvokeScript("document.querySelector('a[data-reactid*=" + _profile + "]').click();");
                }
                if (Url.Contains("/browse") || Url.ToLower().Contains("/kid"))
                {
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                break;

            case State.Playing:
                if (_showLoading)
                {
                    HideLoading();
                }
                _currentState            = State.Playing;
                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;
                break;
            }
            return(EventResult.Complete());
        }
        public void EventRaised(Event @event, EventResult result)
        {
            @event.ThrowIfNull("event");

            _logRendererState.EnqueueEventRaisedLogEntry(_worldTime.Total, @event, result);
        }
예제 #32
0
        /// <summary>
        /// Process a message from the web browser
        /// </summary>
        /// <returns></returns>
        public override EventResult BrowserDocumentComplete()
        {
            switch (_currentState)
            {
            case State.LoggingIn:
                if (Url.EndsWith("/signin/skygo"))
                {
                    var jsCode = "document.getElementById('username').value = '" + _username + "';";
                    jsCode += "document.getElementById('password').value = '" + _password + "';";
                    jsCode += "document.getElementById('signinform').submit();";
                    InvokeScript(jsCode);
                    _currentState = State.LoginResult;
                }
                break;

            case State.LoginResult:
                if (Url == "http://go.sky.com/")
                {
                    _currentState            = State.None;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                else
                {
                    return(EventResult.Error("SkyGoGeneralConnector/ProcessMessage/Expected home page after log in, was actually " + Url));
                }
                break;

            case State.PlayPage:
                if (Url.Contains("/content/videos"))
                {
                    //Browser.Refresh(WebBrowserRefreshOption.Completely);// Need to do this for some reason
                    _currentState = State.None;

                    // The js code to wait for the video to appear
                    var jsCode = "setTimeout('doMaximise()', 1000);";
                    jsCode += "function doMaximise() {";
                    jsCode += "if(document.getElementsByClassName('silverlightVodPlayerWrapper') != null) {";
                    jsCode += "    document.getElementsByClassName('silverlightVodPlayerWrapper')[0].setAttribute('style', 'position: fixed; width: 100%; height: 100%; left: 0; top: 0; background: rgba(51,51,51,0.7); z-index: 10;');";
                    jsCode += "}";
                    jsCode += "else setTimeout('doMaximise()', 1000);";
                    jsCode += "}";

                    InvokeScript(jsCode);

                    var startTime = DateTime.Now;

                    _playPressThread = new Thread(new ParameterizedThreadStart(ClickPlayAfterFullScreen));
                    _playPressThread.Start();

                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;

                    // Wait 15 seconds for the video to start before disabling app storage - we'll do this in a separate thread
                    if (_disableAppStorageThread == null)
                    {
                        _disableAppStorageThread = new Thread(new ParameterizedThreadStart(DisableAppStorage));
                        _disableAppStorageThread.Start();
                    }

                    Browser.FindForm().Activate();
                    Browser.FindForm().Focus();
                }
                else
                {
                    if (!Url.EndsWith("/content/videos"))
                    {
                        return(EventResult.Error("SkyGoOnDemandConnector/ProcessMessage/Expected video play page, was actually " + Url));
                    }
                }
                break;

            case State.PlayPageLiveTv:
                if (Url.Contains("/detachedLiveTv.do") || Url.Contains("/live/"))
                {
                    // After 4 seconds we'll assume the page has loaded and will click in the top corner

                    /*var endDate = DateTime.Now.AddSeconds(4);
                     * while (DateTime.Now < endDate)
                     * {
                     *  Application.DoEvents();
                     *  System.Threading.Thread.Sleep(200);
                     * }
                     *
                     * TemporaryCursorHelper.MoveMouseTo(50, 50);
                     * Application.DoEvents();
                     * TemporaryCursorHelper.DoLeftMouseClick();
                     * Application.DoEvents();*/

                    // The js code to wait for the video to appear
                    var jsCode = "setTimeout('doMaximise()', 1000);";
                    jsCode += "function doMaximise() {";
                    jsCode += "if(  document.getElementById('silverlightWrapper') != null) {";
                    jsCode += "    document.getElementById('silverlightWrapper').setAttribute('style', 'position: fixed; width: 100%; height: 100%; left: 0; top: 0; background: rgba(51,51,51,0.7); z-index: 50;');";
                    jsCode += "}";
                    jsCode += "else setTimeout('doMaximise()', 1000);";
                    jsCode += "}";

                    //InvokeScript(jsCode);

                    _playPressThread = new Thread(new ParameterizedThreadStart(ClickFullScreen));
                    _playPressThread.Start();

                    HideLoading();
                    Browser.FindForm().Activate();
                    Browser.FindForm().Focus();

                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }

                break;
            }

            return(EventResult.Complete());
        }
예제 #33
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "DICOM Instances Transferred" received event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <remarks>
		/// This method automatically separates different patients into separately logged events, as required by DICOM.
		/// </remarks>
		/// <param name="remoteAETitle">The application entity from which the transfer was completed.</param>
		/// <param name="remoteHostName">The hostname of the application entity from which the transfer was completed.</param>
		/// <param name="instances">The studies that were transferred.</param>
		/// <param name="eventSource">The source user or application entity which invoked the operation.</param>
		/// <param name="eventResult">The result of the operation.</param>
		/// <param name="action">The action taken on the studies that were transferred.</param>
		public static void LogReceivedInstances(string remoteAETitle, string remoteHostName, AuditedInstances instances, EventSource eventSource, EventResult eventResult, EventReceiptAction action)
		{
			AuditLogHelper.LogReceivedInstances(LocalAETitle, remoteAETitle, remoteHostName, instances, eventSource, eventResult, action);
		}
예제 #34
0
        public override Entities.EventResult BrowserDocumentComplete()
        {
            if (!_disableLogging)
            {
                MessageHandler.Info("Netflix. Url: {0}, State: {1}", Url, _currentState.ToString());
            }
            switch (_currentState)
            {
            case State.Login:
                if (Url.ToLower().Contains("/login") && activateLoginTimer)
                {
                    activateLoginTimer = false;
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick += (object sender, EventArgs e) =>
                    {
                        timer.Stop();
                        timer.Dispose();
                        if (_use2200Mode)
                        {
                            string data = Browser.DocumentText;
                            _currentState = State.SelectProfile;
                            Regex  rgx     = new Regex(@"""authURL"":""(?<authURL>[^""]*)");
                            Match  m       = rgx.Match(data);
                            string authUrl = "";
                            if (m.Success)
                            {
                                authUrl = m.Groups["authURL"].Value;
                                authUrl = HttpUtility.UrlDecode(authUrl.Replace("\\x", "%"));
                                string loginPostDataFormat = "email={0}&password={1}&rememberMe=true&flow=websiteSignUp&mode=login&action=loginAction&withFields=email%2Cpassword%2CrememberMe%2CnextPage%2CshowPassword&authURL={2}&nextPage=&showPassword="******"", Encoding.UTF8.GetBytes(loginPostData), "Referer: " + Url + "\r\nContent-Type: application/x-www-form-urlencoded\r\n");
                            }
                        }
                        else
                        {
                            if (_showLoading)
                            {
                                HideLoading();
                            }
                            string[]    stringToSend = { "a", "{BACKSPACE}" };
                            HtmlElement elt          = GetFirstElement("input", "name", "emailOrPhoneNumber") ?? GetFirstElement("input", "name", "email");
                            HtmlElement eltp         = GetFirstElement("input", "name", "password");
                            if (elt != null && eltp != null)
                            {
                                elt.Focus();
                                elt.SetAttribute("Value", _username);
                                foreach (string s in stringToSend)
                                {
                                    Thread.Sleep(50);
                                    SendKeys.SendWait(s);
                                }
                                Thread.Sleep(100);
                                eltp.Focus();
                                eltp.SetAttribute("Value", _password);
                                foreach (string s in stringToSend)
                                {
                                    Thread.Sleep(50);
                                    SendKeys.SendWait(s);
                                }
                                Thread.Sleep(500);
                                _currentState = State.SelectProfile;
                                InvokeScript(Properties.Resources.NetflixJs);
                                InvokeScript(@"doClickDelay();");
                            }
                        }
                    };
                    timer.Interval = 1000;
                    timer.Start();
                }
                else if (!Url.ToLower().Contains("/login"))
                {
                    Url           = "https://www.netflix.com";
                    _currentState = State.SelectProfile;
                }
                break;

            case State.SelectProfile:
                if (activateProfileTimer)
                {
                    activateProfileTimer = false;
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick += (object sender, EventArgs e) =>
                    {
                        timer.Stop();
                        timer.Dispose();
                        Regex  rgx     = new Regex(@"""authURL"":""(?<authURL>[^""]*)");
                        Match  m       = rgx.Match(Browser.DocumentText);
                        string authUrl = "";
                        if (m.Success)
                        {
                            authUrl = m.Groups["authURL"].Value;
                            authUrl = HttpUtility.UrlDecode(authUrl.Replace("\\x", "%"));
                        }
                        InvokeScript(Properties.Resources.NetflixJs);
                        InvokeScript("switchProfile('" + _profileUrl + HttpUtility.UrlEncode(authUrl) + "'," + _profileIndex + ");");
                        _currentState = State.ReadyToPlay;
                    };
                    timer.Interval = 2000;
                    timer.Start();
                }
                break;

            case State.ReadyToPlay:
                if (activateReadyTimer)
                {
                    activateReadyTimer = false;
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick += (object sender, EventArgs e) =>
                    {
                        timer.Stop();
                        timer.Dispose();
                        _currentState = State.GotoToPlay;
                        InvokeScript("window.location.href = 'https://www.netflix.com/';");
                    };
                    timer.Interval = 1500;
                    timer.Start();
                }
                break;

            case State.GotoToPlay:
                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;
                break;

            case State.Playing:
                if (_showLoading)
                {
                    HideLoading();
                }
                _currentState            = State.Playing;
                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;
                break;
            }
            return(EventResult.Complete());
        }
예제 #35
0
 public HandleResult(EventResult eventResult, string message)
 {
     EventResult = eventResult;
     Message     = message;
 }
예제 #36
0
    private EventResult OnSetState(object eventData)
    {
        EventResult eventresult = new EventResult(false);

        return(eventresult);
    }
예제 #37
0
 public void addToHistorique(EventResult eventResult)
 {
     historique.Add(eventResult);
 }
예제 #38
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "Begin Transferring DICOM Instances" receive event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <remarks>
		/// This method automatically separates different patients into separately logged events, as required by DICOM.
		/// </remarks>
		/// <param name="remoteAETitle">The application entity from which the transfer was started.</param>
		/// <param name="remoteHostName">The hostname of the application entity from which the transfer was started.</param>
		/// <param name="instances">The studies that were requested for transfer.</param>
		/// <param name="eventSource">The source user or application entity which invoked the operation.</param>
		/// <param name="eventResult">The result of the operation.</param>
		public static void LogBeginReceiveInstances(string remoteAETitle, string remoteHostName, AuditedInstances instances, EventSource eventSource, EventResult eventResult)
		{
			AuditLogHelper.LogBeginReceiveInstances(LocalAETitle, remoteAETitle, remoteHostName, instances, eventSource, eventResult);
		}
예제 #39
0
    private EventResult OnInitFinished(object eventData)
    {
        EventResult eventresult = new EventResult(false);

        return(eventresult);
    }
예제 #40
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "Data Export" event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <remarks>
		/// One audit event is generated for each file system volume to which data is exported.
		/// If the audited instances are not on a file system, a single event is generated with an empty media identifier.
		/// </remarks>
		/// <param name="instances">The files that were exported.</param>
		/// <param name="eventSource">The source user or application entity which invoked the operation.</param>
		/// <param name="eventResult">The result of the operation.</param>
		public static void LogExportStudies(AuditedInstances instances, EventSource eventSource, EventResult eventResult)
		{
			AuditLogHelper.LogExportStudies(instances, eventSource, EventSource.GetCurrentDicomAE(), eventResult);
		}
        public override Entities.EventResult BrowserDocumentComplete()
        {
            string jsCode;

            switch (_currentState)
            {
            case State.Login:

                if (Url.Contains("/Login?"))
                {
                    jsCode  = "document.getElementById('email').value = '" + _username + "'; ";
                    jsCode += "document.getElementById('password').value = '" + _password + "'; ";
                    if (_rememberLogin)
                    {
                        jsCode += "document.getElementById('RememberMe').checked = true; ";
                    }
                    else
                    {
                        jsCode += "document.getElementById('RememberMe').checked = false; ";
                    }
                    jsCode += "document.getElementById('login-form-contBtn').click();";
                    InvokeScript(jsCode);
                    _currentState = State.Profile;
                }
                else
                {
                    //Url = "http://www.netflix.com/browse";
                    Url = "https://www.netflix.com/SwitchProfile?tkn=" + _profile;
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick += (object sender, EventArgs e) =>
                    {
                        timer.Stop();
                        timer.Dispose();
                        Url           = @"http://www.netflix.com/Kids";
                        _currentState = State.ReadyToPlay;
                    };
                    timer.Interval = 3000;
                    timer.Start();
                }
                break;

            case State.Profile:
                if (Url.Contains("/browse") || Url.Contains("/WiHome") || Url.Contains("/Kids") || Url.Contains("/ProfilesGate"))
                {
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick += (object sender, EventArgs e) =>
                    {
                        timer.Stop();
                        timer.Dispose();
                        Url           = @"http://www.netflix.com/Kids";
                        _currentState = State.ReadyToPlay;
                    };
                    timer.Interval = 3000;
                    timer.Start();
                    Url = "https://www.netflix.com/SwitchProfile?tkn=" + _profile;
                }
                break;

            case State.ReadyToPlay:
                if (Url.Contains("/browse") || Url.Contains("/WiHome") || Url.Contains("/Kids"))
                {
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                break;

            case State.StartPlay:
            case State.Playing:
                if (Url.Contains("movieid"))
                {
                    if (_showLoading)
                    {
                        HideLoading();
                    }
                    _currentState            = State.Playing;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                break;
            }
            return(EventResult.Complete());
        }
예제 #42
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "Dicom Instances Accessed" update event in the audit log (with ActionCode of Delete), according to DICOM Supplement 95.
		/// </summary>
		/// <remarks>
		/// This method automatically separates different patients into separately logged events, as required by DICOM.
		/// 
		/// We chose to impleemnt the DicomInstancesAccessed audit log, as opposed to the DicomStudyDeleted audit message because the whole
		/// study isn't being deleted, just a series.
		/// </remarks>
		/// <param name="aeTitles">The application entities from which the instances were accessed.</param>
		/// <param name="instances">The studies that the series belong that are being deleted.</param>
		/// <param name="eventSource">The source user or application entity which invoked the operation.</param>
		/// <param name="eventResult">The result of the operation.</param>
		public static void LogDeleteSeries(IEnumerable<string> aeTitles, AuditedInstances instances, EventSource eventSource, EventResult eventResult)
		{
			AuditLogHelper.LogDeleteSeries(aeTitles, instances, eventSource, eventResult);
		}
예제 #43
0
            public virtual EventResult CompletedOperation(Inferior.ChildEvent cevent, EventResult result, ref TargetEventArgs args)
            {
                Report.Debug (DebugFlags.EventLoop, "{0} operation completed: {1} {2} {3} - {4} {5}",
                      sse, this, cevent, result, ReportBreakpointHit, ReportSuspend);

                child = null;

                if (ReportSuspend) {
                result = EventResult.SuspendOperation;
                ReportSuspend = false;
                }

                if (result == EventResult.SuspendOperation) {
                if (!(this is InterruptibleOperation) || !sse.process.Session.Config.NestedBreakStates)
                    result = EventResult.Completed;
                }

                if (args != null)
                return result;

                //
                // We're done with our stepping operation, but first we need to
                // compute the new StackFrame.  While doing this, `frame_changed'
                // may discover that we need to do another stepping operation
                // before telling the user that we're finished.  This is to avoid
                // that we stop in things like a method's prologue or epilogue
                // code.  If that happens, we just continue stepping until we reach
                // the first actual source line in the method.
                //
                Operation new_operation = sse.frame_changed (inferior.CurrentFrame, this);

                if ((ReportBreakpointHit < 0) &&
                (CheckBreakpointsOnCompletion || (result == EventResult.SuspendOperation))) {
                int index;
                bool is_enabled;
                sse.process.BreakpointManager.LookupBreakpoint (
                    inferior.CurrentFrame, out index, out is_enabled);

                if ((index != 0) && is_enabled)
                    ReportBreakpointHit = index;
                }

                if (new_operation != null) {
                Report.Debug (DebugFlags.SSE,
                          "{0} frame changed at {1} => new operation {2}",
                          this, inferior.CurrentFrame, new_operation);

                if (cevent.Type == Inferior.ChildEventType.CHILD_HIT_BREAKPOINT)
                    ReportBreakpointHit = (int) cevent.Argument;
                if (result == EventResult.SuspendOperation)
                    ReportSuspend = true;

                sse.PushOperation (new_operation);

                args = null;
                return EventResult.Running;
                }

                //
                // Now we're really finished.
                //
                int bpt_hit = ReportBreakpointHit;
                ReportBreakpointHit = -1;

                if (cevent.Type == Inferior.ChildEventType.CHILD_HIT_BREAKPOINT)
                bpt_hit = (int) cevent.Argument;

                if (bpt_hit >= 0) {
                Breakpoint bpt = sse.lookup_breakpoint (bpt_hit);
                if ((bpt != null) && bpt.Breaks (sse.Thread.ID) && !bpt.HideFromUser) {
                    args = new TargetEventArgs (
                        TargetEventType.TargetHitBreakpoint, bpt.Index,
                        sse.current_frame);
                    return result;
                }
                }

                args = OperationCompleted (sse.current_frame, result == EventResult.SuspendOperation);
                return result;
            }
예제 #44
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "User Authentication" login event in the audit log, according to DICOM Supplement 95,
		/// and a "Security Alert" event if the operation failed.
		/// </summary>
		/// <param name="username">The username or asserted username of the account that was logged in.</param>
		/// <param name="authenticationServer">The authentication server against which the operation was performed.</param>
		/// <param name="eventResult">The result of the operation.</param>
		public static void LogLogin(string username, EventSource authenticationServer, EventResult eventResult)
		{
			AuditLogHelper.LogLogin(username, authenticationServer, eventResult);
		}
 /// <summary>
 /// Pause button pressed
 /// </summary>
 /// <returns></returns>
 public override EventResult Pause()
 {
     DoPlayOrPause();
     return(EventResult.Complete());
 }
예제 #46
0
파일: AuditHelper.cs 프로젝트: nhannd/Xian
		/// <summary>
		/// Generates a "User Authentication" logout event in the audit log, according to DICOM Supplement 95.
		/// </summary>
		/// <param name="username">The username or asserted username of the account that was logged out.</param>
		/// <param name="authenticationServer">The authentication server against which the operation was performed.</param>
		/// <param name="eventResult">The result of the operation.</param>
		/// <param name="sessionId">The ID of the session that is being logged out.</param>
		public static void LogLogout(string username, string sessionId, EventSource authenticationServer, EventResult eventResult)
		{
			AuditLogHelper.LogLogout(username, sessionId, authenticationServer, eventResult);
		}
        /// <summary>
        /// Document loaded - see what state we're in and react accordingly
        /// </summary>
        /// <returns></returns>
        public override EventResult BrowserDocumentComplete()
        {
            switch (_currentState)
            {
            case State.LoggingIn:
                if (Url.EndsWith("nav_signin_btn"))
                {
                    var jsCode = @"var u=document.getElementById('ap_email')||document.getElementById('ap-claim-autofill-hint');
                                    var r=document.getElementById('ap_signin_existing_radio')||document.getElementById('rememberMe');
                                    var p=document.getElementById('ap_password');
                                    var fm=document.getElementById('ap_signin_form')||document.forms['signIn'];
                                    if (u)u.value='" + _username + @"';
                                    if (p)p.value='" + _password + @"';
                                    if (r)r.checked='checked';
                                    if (fm)fm.submit();";
                    InvokeScript(jsCode);
                    _currentState = State.LoginResult;
                }
                break;

            case State.LoginResult:
                if (Url.Contains("yourstore/home"))
                {
                    _currentState            = State.None;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                else
                {
                    return(EventResult.Error("AmazonPrimeConnector/BrowserDocumentComplete/Expected home page after log in, was actually " + Url));
                }
                break;

            case State.PlayPage:

                _currentState = State.PlayPage1;
                break;

            case State.PlayPage1:

                // Retry play every 1 second(s)

                /*                    var jsPlay = "var mpOVPlay = function() { ";
                 *                  jsPlay += "   try {";
                 *                  jsPlay += "         AMZNDetails.dvPlayer.play();";
                 *                  jsPlay += "         amzn.webGlobalVideoPlayer._mainPlayer._enableFullWindowPlaybackMode();";
                 *                  jsPlay += "   } catch(err) {";
                 *                  jsPlay += "      setTimeout(mpOVPlay,1000);";
                 *                  jsPlay += "   }";
                 *                  jsPlay += "};";
                 *                  jsPlay += "mpOVPlay();";
                 *
                 *                  InvokeScript(jsPlay);*/

                // Hide the scroll bar - can't get the webpage to do this nicely :-(

                /*                    _blankPanel.Height = Browser.Height;
                 *                  _blankPanel.Width = 35;
                 *                  _blankPanel.BackColor = Color.Black;
                 *                  _blankPanel.Left = Browser.FindForm().Right - 35;
                 *
                 *                  // Browser.FindForm().Controls.Add(_blankPanel);
                 *                  _blankPanel.BringToFront();*/

                HideLoading();

                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;

                break;
            }

            return(EventResult.Complete());
        }
예제 #48
0
 private Result(bool consumed, IState nextState)
 {
     this.Event     = new EventResult(consumed);
     this.NextState = nextState;
 }
예제 #49
0
        /// <summary>
        /// Process a message from the web browser
        /// </summary>
        /// <returns></returns>
        public override EventResult BrowserDocumentComplete()
        {
            switch (_currentState)
            {
            case State.LoggingIn:
                if (Url.Contains("4id.channel4.com/login"))
                {
                    // The js code to actually do the login
                    var loginJsCode = "document.getElementById('capture_first_signIn_emailAddress').value = '" + _username + "';";
                    loginJsCode += "document.getElementById('capture_first_signIn_password').value = '" + _password + "';";
                    loginJsCode += "document.getElementById('capture_first_signIn_signInButton').click();";
                    //loginJsCode += "document.getElementById('userInformationForm').submit();";

                    // The js code to wait for the login box to appear
                    var jsCode = "setTimeout('doLogin()', 1000);";
                    jsCode += "function doLogin() {";
                    jsCode += "if(document.getElementById('capture_first_signIn_signInButton') != null) {";
                    jsCode += loginJsCode;
                    jsCode += "}";
                    jsCode += "else setTimeout('doLogin()', 1000);";
                    jsCode += "}";

                    InvokeScript(jsCode);
                    _currentState = State.LoginResult;
                }
                else
                {
                    // Already logged in
                    if (Url.EndsWith("www.channel4.com/"))
                    {
                        _currentState            = State.None;
                        ProcessComplete.Finished = true;
                        ProcessComplete.Success  = true;
                    }
                }
                break;

            case State.LoginResult:
                if (Url.EndsWith("www.channel4.com/"))
                {
                    _currentState            = State.None;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                //else
                //return EventResult.Error("C4ODGeneralConnector/ProcessMessage/Expected home page after log in, was actually " + _parent.Url);
                break;

            case State.PlayPage:
                if (Url.Contains(_nextVideoToPlayName))
                {
                    /* var swfElement = Browser.Document.GetElementById("catchUpPlayer");
                     *
                     * if (swfElement != null)
                     * {
                     *   DoResize();
                     *   // Not 100% sure why, but for some reason the page does reload after the initial element is loaded
                     *   // We'll basically do the accept and resize on the second refresh
                     *   _currentState = State.None;
                     *   ProcessComplete.Finished = true;
                     *   ProcessComplete.Success = true;
                     * }
                     */

                    HideLoading();
                    // Hide the controls of the flash player
                    _blankPanel.Width     = Browser.Width;
                    _blankPanel.Height    = 50;
                    _blankPanel.BackColor = Color.Black;
                    _blankPanel.Top       = Browser.FindForm().Bottom - 50;

                    Browser.FindForm().Controls.Add(_blankPanel);
                    _blankPanel.BringToFront();

                    // Rather than click the age restriction button we'll set the cookie for this program
                    if (HasAgeRestriction())
                    {
                        InvokeScript("function cookieObject() {this.allowedToWatch = 18};");
                        InvokeScript("C4.Util.setCookieValue('C4AccessControlCookie_" + _nextVideoToPlayName + "', new cookieObject())");
                    }
                    //  DoResize();
                    _currentState            = State.Playing;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                break;

            case State.Playing:
                // Handle the accepting of age restrictions, do this before making it fullscreen so we can get the absolute position of the box

                /*var currPosLeft = Browser.Document.Window.Position.X + 125;
                 * var currPosTop = Browser.Document.Window.Position.Y + 260;
                 * var coloursToLookFor = new[] { "0F7FA8", "FFFFFF", "009ACA" };
                 *
                 * if (HasAgeRestriction())
                 * {
                 *  Cursor.Position = new System.Drawing.Point(currPosLeft, currPosTop);
                 *  Application.DoEvents();
                 *
                 *  // Wait for the warning to come up
                 *  while (!coloursToLookFor.Contains(CursorHelper.GetColourUnderCursor().Name.Substring(2).ToUpper()))
                 *  {
                 *      Application.DoEvents();
                 *      Thread.Sleep(10);
                 *  }
                 *
                 *  CursorHelper.DoLeftMouseClick();
                 *  Application.DoEvents();
                 * }*/

                DoResize();
                // We'll keep coming into this case in case the page refreshes for some reason - re-attaching the screen re-size javascript won't do any damage
                //_currentState = State.None;
                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;
                break;
            }

            return(EventResult.Complete());
        }
예제 #50
0
        public EventResult Receive(IEventContext context)
        {
            EventResult eventResult = new EventResult();
            if (context is ContentEventContext && HttpContext.Current != null)
            {
                try
                {
                    ContentEventContext contentEventContext = (ContentEventContext)context;
                    var content = contentEventContext.Content;

                    var result = (contentEventContext.ContentAction & ContentAction.PreAdd) == ContentAction.PreAdd || (contentEventContext.ContentAction & ContentAction.PreUpdate) == ContentAction.PreUpdate;

                    if (result)
                    {
                        var cropField = HttpContext.Current.Request.Form["Kooboo-Image-Crop-Field"];
                        var toRemove = new List<string>();
                        if (!string.IsNullOrEmpty(cropField))
                        {
                            var fields = cropField.Split(',');
                            foreach (var field in fields)
                            {

                                var imgParam = JsonHelper.Deserialize<ImageParam>(HttpContext.Current.Request.Form[field + "_param"].ToString());
                                if (imgParam != null)
                                {
                                    string sourceFilePath = HttpContext.Current.Server.MapPath(imgParam.Url);

                                    toRemove.Add(sourceFilePath);

                                    var contentPath = new TextContentPath(content);

                                    var vPath = Kooboo.Web.Url.UrlUtility.Combine(contentPath.VirtualPath, "kooboo-crop-" + Path.GetFileName(imgParam.Url));

                                    Kooboo.IO.IOUtility.EnsureDirectoryExists(contentPath.PhysicalPath);

                                    var phyPath = HttpContext.Current.Server.MapPath(vPath);

                                    Kooboo.Drawing.ImageTools.CropImage(sourceFilePath, phyPath, imgParam.X, imgParam.Y, imgParam.Width, imgParam.Height);
                                    content[field] = vPath;
                                }
                            }

                        }
                        foreach (var r in toRemove)
                        {
                            if (File.Exists(r))
                            {
                                File.Delete(r);
                            }

                        }
                    }
                }
                catch (Exception e)
                {
                    eventResult.Exception = e;
                }
            }

            return eventResult;
        }
예제 #51
0
    public override EventResult doExcute(Character character, string selectCode, int rollValue)
    {
        EventResult er        = new EventResult();
        int         dicePoint = 0;

        if (character.isPlayer())
        {
            dicePoint = rollValue;
            //Debug.Log("事件判定 你的结果为 " + dicePoint);
        }
        else
        {
            int spe = character.getAbilityInfo()[1] + character.getDiceNumberBuffer();
            dicePoint = diceRoll.calculateDice(spe);
            dicePoint = dicePoint + character.getDiceValueBuffer();
        }

        if (selectCode == EventConstant.OPTION_CODE_1)
        {
            Debug.Log("select 1 and dicePoint is " + dicePoint + ",and checkP is " + this.getBadCheckPoint());
            if (dicePoint > this.getBadCheckPoint())
            {
                er.setStatus(true);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_GOOD);
            }
            else
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_NORMAL);
            }
        }
        else if (selectCode == EventConstant.OPTION_CODE_2)
        {
            if (dicePoint <= this.getBadCheckPoint())
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_BAD);
            }
            else
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_NORMAL);
            }
        }
        else if (selectCode == EventConstant.OPTION_CODE_3)
        {
            if (dicePoint >= this.getGoodCheckPoint())
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_NORMAL);
            }
            else
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_BAD);
            }
        }
        else
        {
            if (dicePoint > this.getBadCheckPoint())
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_NORMAL);
            }
            else
            {
                er.setStatus(false);
                er.setResultCode(EventConstant.FALL_DOWN__EVENT_BAD);
            }
        }


        return(er);
    }