Ejemplo n.º 1
0
        internal void NewQuestion(XmppAccountNode Owner, ProvisioningClient ProvisioningClient, Question Question)
        {
            QuestionView QuestionView = this.FindQuestionTab(Owner, ProvisioningClient);

            if (QuestionView != null && Question != null)
            {
                QuestionView.NewQuestion(Question);
                return;
            }

            Task.Run(async() =>
            {
                try
                {
                    LinkedList <Question> Questions = new LinkedList <Question>();
                    bool Found = Question == null;

                    foreach (Question Question2 in await Database.Find <Question>(new FilterAnd(new FilterFieldEqualTo("OwnerJID", Owner?.BareJID),
                                                                                                new FilterFieldEqualTo("ProvisioningJID", ProvisioningClient?.ProvisioningServerAddress)), "Created"))
                    {
                        Questions.AddLast(Question2);

                        if (!Found)
                        {
                            Found = Question2.ObjectId == Question.ObjectId;
                        }
                    }

                    if (!Found)
                    {
                        Questions.AddLast(Question);
                    }

                    if (Questions.First != null)
                    {
                        DispatcherOperation Op = MainWindow.currentInstance.Dispatcher.BeginInvoke(new ThreadStart(() =>
                        {
                            if (QuestionView == null)
                            {
                                QuestionView = this.CreateQuestionTab(Owner, ProvisioningClient);
                            }

                            foreach (Question Question2 in Questions)
                            {
                                QuestionView.NewQuestion(Question2);
                            }
                        }));
                    }
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                }
            });
        }
Ejemplo n.º 2
0
        private async Task NewQuestion(string ProvisioningJid, Question Question)
        {
            QuestionView QuestionView;
            bool         DoSearch;

            if (Question == null)
            {
                QuestionView = null;
                DoSearch     = true;
            }
            else
            {
                QuestionView = this.OpenQuestionTab(ProvisioningJid, out DoSearch);
            }

            if (DoSearch)
            {
                bool Found = false;

                foreach (Question Question2 in await Database.Find <Question>(
                             new FilterFieldEqualTo("ProvisioningJid", ProvisioningJid), "Created"))
                {
                    if (QuestionView == null)
                    {
                        QuestionView = this.OpenQuestionTab(ProvisioningJid, out DoSearch);
                    }

                    QuestionView.NewQuestion(Question2);

                    if (Question != null)
                    {
                        Found |= Question2.ObjectId == Question.ObjectId;
                    }
                }

                if (Found)
                {
                    return;
                }
            }

            if (Question != null)
            {
                QuestionView.NewQuestion(Question);
            }
        }