示例#1
0
        private ActivityItems getActivityItems(Message message)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ActivityItems));
            ActivityItems items      = null;

            // deserialize the body of the SQS message as an ActivityItems instance
            using (XmlTextReader sr = new XmlTextReader(new StringReader(message.Body))) {
                log.Debug("Received SQS message: " + message.MessageId + ": " + message.Body);
                items = (ActivityItems)serializer.Deserialize(sr);
            }

            // Print out the message metadata
            foreach (Amazon.SQS.Model.Attribute attr in message.Attribute)
            {
                if (attr.Name.Equals("ApproximateReceiveCount"))
                {
                    if (Int16.Parse(attr.Value) == 1)
                    {
                        log.Debug(attr.Name + ": " + attr.Value);
                    }
                    else
                    {
                        log.Info(attr.Name + ": " + attr.Value);
                    }
                }
            }

            return(items);
        }
示例#2
0
        public void ProcessActivities(object sender, DownloadStringCompletedEventArgs e)
        {
            MemoryStream ms = null;

            if ((e == null && !_fromCache) || (e != null && (e.Error != null || e.Cancelled)))
            {
                _activity = true;
                return;
            }
            if (e == null && _fromCache)
            {
                ms = new MemoryStream(Encoding.UTF8.GetBytes(LoadFromStorage("activities", ".json")));
            }
            else if (e != null)
            {
                ms = new MemoryStream(Encoding.UTF8.GetBytes(SaveToStorage("activities", ".json", e.Result)));
            }
            var serializer = new DataContractJsonSerializer(typeof(ObservableCollection <ActivityItemsViewModel>));

            if (ms != null)
            {
                var list = (ObservableCollection <ActivityItemsViewModel>)serializer.ReadObject(ms);
                if (list == null)
                {
                    return;
                }
                foreach (var activityItemView in list.Where(activityItemView => DateTime.Parse(activityItemView.StartDate, new CultureInfo("nl-BE")) >= DateTime.Now))
                {
                    ActivityItems.Add(activityItemView);
                }
            }
            _activity = true;
            NotifyPropertyChanged("GroupedActivities");
        }
示例#3
0
        private int ProcessMessage()
        {
            int           numReceived = 0;
            ActivityItems items       = null;

            try {
                ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);

                if (receiveMessageResponse.IsSetReceiveMessageResult())
                {
                    ReceiveMessageResult receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                    numReceived = receiveMessageResult.Message.Count;

                    foreach (Message message in receiveMessageResult.Message)
                    {
                        items = getActivityItems(message);
                        dispatchItems(items);

                        deleteMessageRequest.WithReceiptHandle(message.ReceiptHandle);
                        sqs.DeleteMessage(deleteMessageRequest);
                    }
                }
            } catch (Exception ex) {
                log.Warn("An unknown error has occurred.  Will retry message.", ex);
            }

            return(numReceived);
        }
        private void initFavoriteActivities()
        {
            ItemFavorites           = new ActivityTreeItem();
            ItemFavorites.GroupType = ActivityTreeItem.enGroupType.Favorite;
            ActivityItemsRemove(ActivityTreeItem.enGroupType.Favorite);
            ActivityItems.Add(ItemFavorites);

            XmlDocument doc = new XmlDocument();

            //doc.Load(App.LocalRPAStudioDir+ @"\Config\FavoriteActivities.xml");
            doc.Load(GetActivitiesXML("FavoriteActivities"));
            var rootNode = doc.DocumentElement;

            ItemFavorites.Name       = (rootNode as XmlElement).GetAttribute("Name");
            ItemFavorites.IsExpanded = (rootNode as XmlElement).GetAttribute("IsExpanded").ToLower() == "true";
            ItemFavorites.ToolTip    = (rootNode as XmlElement).GetAttribute("ToolTip");

            var activitiesNodes = rootNode.SelectNodes("Activity");

            foreach (XmlNode activityNode in activitiesNodes)
            {
                var TypeOf = (activityNode as XmlElement).GetAttribute("TypeOf");
                var item   = GetActivityItemByTypeOf(TypeOf);
                if (item != null)
                {
                    item.IsFavorite = true;
                    ItemFavorites.Children.Add(item);
                }
            }
        }
示例#5
0
 /// <summary>
 /// Creates and adds the data to the viewmodels
 /// </summary>
 public void LoadData(bool reload)
 {
     if (!IsEssentialsLoaded)
     {
         LoadInfo();
         LoadAssociations();
         LoadSettings();
         try
         {
             LoadFaceBookSettings();
         }
         catch (Exception)
         {
             //NIET INGELOGD
         }
     }
     if (!reload)
     {
         return;
     }
     RestoItems.Clear();
     NewsItems.Clear();
     ActivityItems.Clear();
     SchamperItems.Clear();
     _fromCache = DateTime.Now.AddMinutes(-60) < _cacheTime;
     if (!_fromCache && !HasConnection)
     {
         _fromCache = true;
     }
     LoadNews();
     LoadResto();
     LoadActivities();
     LoadSchamper();
 }
        private void AddActivityItem(ActivityForActivitiesPanel activity)
        {
            var activityItem = _serviceProvider.GetRequiredService <ActivitiesPanelActivityItem>();

            activityItem.ActivityDeletionRequested += OnActivityDeletionRequestedAsync;
            activityItem.Initialize(activity);
            ActivityItems.Add(activityItem);
        }
 private void ActivityItemsRemove(ActivityTreeItem.enGroupType groupType)
 {
     foreach (var item in ActivityItems)
     {
         if (item.GroupType == groupType)
         {
             ActivityItems.Remove(item);
             break;
         }
     }
 }
        private void OnActivityDeleted(ActivityDeletedEventArgs args)
        {
            CurrentDialog = null;
            RaisePropertyChanged(nameof(CurrentDialog));

            var deletedActivity = ActivityItems.FirstOrDefault(activityItem => activityItem.Activity.Id == args.DeletedActivityId);

            if (deletedActivity is null)
            {
                return;
            }

            ActivityItems.Remove(deletedActivity);
        }
        private void initRecentActivities()
        {
            ItemRecent           = new ActivityTreeItem();
            ItemRecent.GroupType = ActivityTreeItem.enGroupType.Recent;
            ActivityItemsRemove(ActivityTreeItem.enGroupType.Recent);
            ActivityItems.Add(ItemRecent);

            XmlDocument doc = new XmlDocument();

            doc.Load(App.LocalRPAStudioDir + @"\Config\RecentActivities.xml");
            var rootNode = doc.DocumentElement;

            ItemRecent.Name       = (rootNode as XmlElement).GetAttribute("Name");
            ItemRecent.IsExpanded = (rootNode as XmlElement).GetAttribute("IsExpanded").ToLower() == "true";
            ItemRecent.ToolTip    = (rootNode as XmlElement).GetAttribute("ToolTip");
        }
        private void initAvailableActivities()
        {
            //初始化可用组件
            ItemAvailable           = new ActivityTreeItem();
            ItemAvailable.GroupType = ActivityTreeItem.enGroupType.Available;
            ActivityItemsRemove(ActivityTreeItem.enGroupType.Available);
            ActivityItems.Add(ItemAvailable);

            if (AvailableActivitiesXmlDocument == null)
            {
                XmlDocument doc         = new XmlDocument();
                var         resourceXML = Properties.ResourceLocalizer.GetConfigXML("AvailableActivities");
                using (var ms = new MemoryStream(resourceXML))
                {
                    ms.Flush();
                    ms.Position = 0;
                    doc.Load(ms);
                    ms.Close();
                }

                AvailableActivitiesXmlDocument = doc;
            }

            var rootNode = AvailableActivitiesXmlDocument.DocumentElement;

            ItemAvailable.Name       = (rootNode as XmlElement).GetAttribute("Name");
            ItemAvailable.IsExpanded = (rootNode as XmlElement).GetAttribute("IsExpanded").ToLower() == "true";
            ItemAvailable.ToolTip    = (rootNode as XmlElement).GetAttribute("ToolTip");

            var strIsSortable = (rootNode as XmlElement).GetAttribute("IsSortable").ToLower();

            if (strIsSortable == "true")
            {
                ItemAvailable.IsSortable = true;
            }
            else if (strIsSortable == "false")
            {
                ItemAvailable.IsSortable = false;
            }
            else
            {
                ItemAvailable.IsSortable = null;
            }

            initAvailableGroup(rootNode, ItemAvailable);
        }
示例#11
0
        public static void ClassSetup(TestContext testContext)
        {
            _mockActivityHandler = new Mock<IActivityHandler>();

            _activityItems = new ActivityItems(_mockActivityHandler.Object);
        }
        private void dispatchItems(ActivityItems items)
        {
            if(items.BouncedMessageActivity != null)
            {
                foreach(BouncedMessageActivity bounce in items.BouncedMessageActivity)
                {
                    log.Info("Received a bounce message belonging to job: " + bounce.RequestId);
                    listener.OnBounce(bounce);
                }
            }

            if(items.ClickActivity != null)
            {
                foreach(ClickActivity click in items.ClickActivity)
                {
                    log.Info("Received a click message belonging to job: " + click.RequestId);
                    listener.OnClick(click);
                }
            }

            if(items.DeliveredMessageActivity != null)
            {
                foreach(DeliveredMessageActivity delivery in items.DeliveredMessageActivity)
                {
                    log.Info("Received a delivery message belonging to job: " + delivery.RequestId);
                    listener.OnDelivery(delivery);
                }
            }

            if(items.JobErrorActivity != null)
            {
                foreach(JobErrorActivity jobError in items.JobErrorActivity)
                {
                    log.Info("Received a job error message belonging for job: " + jobError.RequestId);
                    listener.OnJobError(jobError);
                }
            }

            if(items.OpenActivity != null)
            {
                foreach(OpenActivity open in items.OpenActivity)
                {
                    log.Info("Received an open message belonging for job: " + open.RequestId);
                    listener.OnOpen(open);
                }
            }

            if(items.RenderErrorActivity != null)
            {
                foreach(RenderErrorActivity renderError in items.RenderErrorActivity)
                {
                    log.Info("Received a render error message belonging to job: " + renderError.RequestId);
                    listener.OnRenderError(renderError);
                }
            }

            if(items.SpamComplaintActivity != null)
            {
                foreach(SpamComplaintActivity spamComplaint in items.SpamComplaintActivity)
                {
                    log.Info("Received a spam complaint message belonging to job: " + spamComplaint.RequestId);
                    listener.OnSpamComplaint(spamComplaint);
                }
            }

            if(items.UnsubActivity != null)
            {
                foreach(UnsubActivity unsub in items.UnsubActivity)
                {
                    log.Info("Received an unsub message belonging to job: " + unsub.RequestId);
                    listener.OnUnsub(unsub);
                }
            }
        }
示例#13
0
        private void dispatchItems(ActivityItems items)
        {
            if (items.BouncedMessageActivity != null)
            {
                foreach (BouncedMessageActivity bounce in items.BouncedMessageActivity)
                {
                    log.Debug("Received a bounce message belonging to job: " + bounce.RequestId);
                    listener.OnBounce(bounce);
                }
            }

            if (items.ClickActivity != null)
            {
                foreach (ClickActivity click in items.ClickActivity)
                {
                    log.Debug("Received a click message belonging to job: " + click.RequestId);
                    listener.OnClick(click);
                }
            }

            if (items.DeliveredMessageActivity != null)
            {
                foreach (DeliveredMessageActivity delivery in items.DeliveredMessageActivity)
                {
                    log.Debug("Received a delivery message belonging to job: " + delivery.RequestId);
                    listener.OnDelivery(delivery);
                }
            }

            if (items.JobErrorActivity != null)
            {
                foreach (JobErrorActivity jobError in items.JobErrorActivity)
                {
                    log.Debug("Received a job error message belonging for job: " + jobError.RequestId);
                    listener.OnJobError(jobError);
                }
            }

            if (items.OpenActivity != null)
            {
                foreach (OpenActivity open in items.OpenActivity)
                {
                    log.Debug("Received an open message belonging for job: " + open.RequestId);
                    listener.OnOpen(open);
                }
            }

            if (items.RenderErrorActivity != null)
            {
                foreach (RenderErrorActivity renderError in items.RenderErrorActivity)
                {
                    log.Debug("Received a render error message belonging to job: " + renderError.RequestId);
                    listener.OnRenderError(renderError);
                }
            }

            if (items.SpamComplaintActivity != null)
            {
                foreach (SpamComplaintActivity spamComplaint in items.SpamComplaintActivity)
                {
                    log.Debug("Received a spam complaint message belonging to job: " + spamComplaint.RequestId);
                    listener.OnSpamComplaint(spamComplaint);
                }
            }

            if (items.UnsubActivity != null)
            {
                foreach (UnsubActivity unsub in items.UnsubActivity)
                {
                    log.Debug("Received an unsub message belonging to job: " + unsub.RequestId);
                    listener.OnUnsub(unsub);
                }
            }
        }
 private void activityItemsSortByGroupType()
 {
     ActivityItems.Sort((x, y) => x.GroupType.CompareTo(y.GroupType));
 }
示例#15
0
        public void Export()
        {
            var name      = string.Empty;
            var workBook  = new XLWorkbook();
            var worksheet = workBook.Worksheets.Add("Resultaat");

            switch (LogType)
            {
            case LogTypes.Score:
                name = "Score";
                worksheet.Row(1).Cell(1).Value  = "FotoNaam";
                worksheet.Row(1).Cell(2).Value  = "Lid";
                worksheet.Row(1).Cell(3).Value  = "Jury1";
                worksheet.Row(1).Cell(4).Value  = "Jury2";
                worksheet.Row(1).Cell(5).Value  = "Jury3";
                worksheet.Row(1).Cell(6).Value  = "Jury4";
                worksheet.Row(1).Cell(7).Value  = "Jury5";
                worksheet.Row(1).Cell(8).Value  = "Totaal";
                worksheet.Row(1).Cell(9).Value  = "Afwijking";
                worksheet.Row(1).Cell(10).Value = "Totaal (%)";
                worksheet.Row(1).Cell(11).Value = "GelijkeScores";

                if (ScoreItems != null)
                {
                    worksheet.Cells("A2").Value = ScoreItems.Select(s => new ScoreItem
                    {
                        FotoNaam      = s.FotoNaam,
                        Lid           = s.Lid,
                        Jury1         = s.Jury1,
                        Jury2         = s.Jury2,
                        Jury3         = s.Jury3,
                        Jury4         = s.Jury4,
                        Jury5         = s.Jury5,
                        Afwijking     = string.IsNullOrEmpty(s.Afwijking) ? string.Empty : (s.Afwijking.Equals(Variables.DefaultScore) ? string.Empty : s.Afwijking),
                        GelijkeScores =
                            string.IsNullOrEmpty(s.GelijkeScores) ? string.Empty : s.GelijkeScores.Equals(Variables.DefaultScore) ? string.Empty : s.GelijkeScores,
                        MaxPoints           = s.MaxPoints,
                        NumberOfJuryMembers = s.NumberOfJuryMembers
                    }).AsEnumerable();
                }
                //format decimals
                worksheet.Column(10).Style.NumberFormat.Format = "#,##0.00";

                var indx = 11;
                if (ScoreItems != null && ScoreItems.All(w => string.IsNullOrEmpty(w.GelijkeScores)))
                {
                    worksheet.Columns(indx, indx).Delete();
                    indx--;
                }
                if (ScoreItems != null && ScoreItems.All(w => string.IsNullOrEmpty(w.Afwijking)))
                {
                    worksheet.Columns(9, 9).Delete();
                    indx--;
                }
                if (ScoreItems != null && (!MemberModuleActive || ScoreItems.All(w => string.IsNullOrEmpty(w.Lid))))
                {
                    worksheet.Columns(2, 2).Delete();
                    indx--;
                }
                worksheet.Range(1, 1, 1, indx).AddToNamed("Titles");
                worksheet.Columns(12, 17).Delete();
                worksheet.Columns().AdjustToContents();
                break;

            case LogTypes.Activity:
                name = "Activity";
                worksheet.Row(1).Cell(1).Value = "Club";
                worksheet.Row(1).Cell(2).Value = "Datum";
                worksheet.Row(1).Cell(3).Value = "Ip";
                worksheet.Row(1).Cell(4).Value = "Source";
                worksheet.Row(1).Cell(5).Value = "Type";
                worksheet.Row(1).Cell(6).Value = "Lokatie";
                worksheet.Row(1).Cell(7).Value = "Omschrijving";

                worksheet.Range(1, 1, 1, 7).AddToNamed("Titles");
                if (ActivityItems != null)
                {
                    worksheet.Cells("A2").Value = ActivityItems.Select(s => new ActivityItem
                    {
                        Club         = s.Club,
                        Datum        = s.Datum,
                        Ip           = s.Ip,
                        Source       = s.Source,
                        Type         = s.Type,
                        Lokatie      = s.Lokatie,
                        Omschrijving = s.Omschrijving
                    }).AsEnumerable();
                }
                worksheet.Columns().AdjustToContents();
                break;
            }

            //format titles
            var titlesStyle = workBook.Style;

            titlesStyle.Font.Bold            = true;
            titlesStyle.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            titlesStyle.Fill.BackgroundColor = XLColor.LightBlue;
            workBook.NamedRanges.NamedRange("Titles").Ranges.Style = titlesStyle;

            var memoryStream = new MemoryStream();

            workBook.SaveAs(memoryStream);
            memoryStream.Position = 0;

            var folderDialog = new SaveFileDialog
            {
                FileName   = $"{name}_{DateTime.Now:yyyymmddhhmmss}.xlsx",
                DefaultExt = ".xlsx",
                Filter     = @"Microsoft Excel Worksheet (.xlsx)|*.xlsx"
            };

            var result = folderDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                using (var fileStream = File.OpenWrite(folderDialog.FileName))
                {
                    memoryStream.WriteTo(fileStream);
                }
            }
        }