Beispiel #1
0
        public override TaskStatus Execute()
        {
            TaskStatus status = TaskStatus.Success;

            foreach (Task task in Tasks)
            {
                try
                {
                    TaskStatus thisStatus = task.Execute();
                    if (thisStatus == TaskStatus.Failure)
                    {
                        MessagesList.AddRange(task.Messages);
                        return(TaskStatus.Failure);
                    }
                    else if (thisStatus == TaskStatus.Warning)
                    {
                        MessagesList.AddRange(task.Messages);
                        status = TaskStatus.Warning;
                    }
                }
                catch (Exception ex)
                {
                    MessagesList.AddRange(task.Messages);
                    MessagesList.Add(ex.ToString());
                    return(TaskStatus.Failure);
                }
            }

            return(status);
        }
Beispiel #2
0
        /// <summary>
        /// Handle the message display after service added
        /// </summary>
        /// <param name="message"></param>
        public void OnServiceAdded(string message, StatesEnum state)
        {
            switch (state)
            {
            case StatesEnum.ServiceInvalid:
                MessagesList.Add(new MessageItem {
                    Message = Messages.msgServiceAddedFailed, FileName = string.Empty
                });
                break;

            case StatesEnum.ConnectionAlreadyExist:
                MessagesList.Add(new MessageItem {
                    Message = Messages.msgServiceAddedAlreadyExist, FileName = string.Empty
                });
                break;

            case StatesEnum.ConnectionAddedAndActivated:
                MessagesList.Add(new MessageItem {
                    Message = Messages.msgServiceActivatedAddedOK, FileName = string.Empty
                });
                break;

            default:
                MessagesList.Add(new MessageItem {
                    Message = Messages.msgServiceAddedOK, FileName = string.Empty
                });
                break;
            }
        }
Beispiel #3
0
        private async void WaitingForGame(object source, ElapsedEventArgs e)
        {
            if (playerInGame == maxPlayers && aTimer.Enabled && !IsMaxPlayersEnd)
            {
                IsMaxPlayersEnd = true;
                timeForGame     = e.SignalTime.AddSeconds(4);
            }
            else if ((int)Math.Round((timeForGame - e.SignalTime).TotalSeconds, MidpointRounding.ToEven) <= 0 && aTimer.Enabled)
            {
                timeForGame = DateTime.Now.AddMinutes(10);

                await Program.bot.SendTextMessageAsync(ChatId, EndGame()).ConfigureAwait(true);

                DelMsgList(MessagesList);

                aTimer.Stop();
                aTimer.Dispose();
                aTimer.Enabled = false;

                MessagesList = new List <Message>();
            }
            else if ((int)Math.Round((timeForGame - e.SignalTime).TotalSeconds, MidpointRounding.ToEven) <= 3 &&
                     (int)Math.Round((timeForGame - e.SignalTime).TotalSeconds, MidpointRounding.ToEven) > 0)
            {
                MessagesList.Add(await Program.bot.SendTextMessageAsync(ChatId, $"{(int)Math.Round((timeForGame - e.SignalTime).TotalSeconds, MidpointRounding.ToEven)}...").ConfigureAwait(true)); // 3... 2... 1...
            }
            else if ((int)Math.Round((timeForGame - e.SignalTime).TotalSeconds, MidpointRounding.ToEven) == 60 + 1)
            {
                MessagesList.Add(await Program.bot.SendTextMessageAsync(ChatId, $"До начала розыгрыша {(int)Math.Round((timeForGame - e.SignalTime).TotalMinutes, MidpointRounding.ToEven)} мин...").ConfigureAwait(true)); // Уведомление о том что осталась 1 минута
            }
        }
Beispiel #4
0
        private void CheckVariablesUsage()
        {
            LexicalAnalyzer lexAnalyzer = new LexicalAnalyzer();
            SyntaxAnalyzer  syntaxAnalyzer;

            foreach (Transition trans in TransitionsList)
            {
                if (trans is SimpleTransition strans)
                {
                    lexAnalyzer.Source = strans.Condition;
                    syntaxAnalyzer     = new SyntaxAnalyzer(lexAnalyzer, VariableCollection.GetConditionDictionary(trans.OwnerDraw.OwnerSheet).Keys.ToList());
                    foreach (SyntaxToken token in syntaxAnalyzer.Tokens)
                    {
                        if (token.Qualifier != SyntaxToken.Qualifiers.Correct)
                        {
                            MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, string.Format("{0}: {1}.", trans.Name, token.ToString()), trans));
                        }
                    }
                    foreach (string outputOperation in strans.OutputsList)
                    {
                        string outputName = LexicalRules.GetOutputId(outputOperation);
                        if (!trans.OwnerDraw.OwnerSheet.Variables.InternalOutputs.Exists(output => output.Name == outputName))
                        {
                            MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Output " + outputName + " is not defined in variables list.", trans));
                        }
                    }
                }
            }
            foreach (DrawableObject obj in ObjectsTable)
            {
                if (obj is State state)
                {
                    //state.EnterOutputsList.RemoveAll(str => !state.OwnerDraw.OwnerSheet.Variables.InternalOutputs.Exists(var => var.Name == LexicalAnalyzer.GetId(str)));
                    foreach (string outputOperation in state.EnterOutputsList)
                    {
                        string outputName = LexicalRules.GetOutputId(outputOperation);
                        if (!state.OwnerDraw.OwnerSheet.Variables.InternalOutputs.Exists(var => var.Name == LexicalAnalyzer.GetId(outputName)))
                        {
                            MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Output " + outputName + " is not defined in variables list.", state));
                        }
                    }
                    //state.ExitOutputsList.RemoveAll(str => !state.OwnerDraw.OwnerSheet.Variables.InternalOutputs.Exists(var => var.Name == LexicalAnalyzer.GetId(str)));
                    foreach (string outputOperation in state.ExitOutputsList)
                    {
                        string outputName = LexicalRules.GetOutputId(outputOperation);
                        if (!state.OwnerDraw.OwnerSheet.Variables.InternalOutputs.Exists(var => var.Name == LexicalAnalyzer.GetId(outputName)))
                        {
                            MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Output " + outputName + " is not defined in variables list.", state));
                        }
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Handle the message display after report generated
        /// </summary>
        /// <param name="messae"></param>
        /// <param name="generationOK"></param>
        public void OnReportGenerated(string fileName, TimeSpan timeSpan)
        {
            MessagesList.Add(new MessageItem {
                Message = Messages.msgReportGenerationSuccess, FileName = fileName
            });

#if DEBUG
            MessagesList.Add(new MessageItem {
                Message = string.Format("Generation duration : {0}", timeSpan)
            });
#endif
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="percentage"></param>
        public void OnStepDone(double percentage, string message, TimeSpan timeSpan)
        {
            ProgressPercentage += percentage;

#if DEBUG
            lock (MessagesList)
            {
                MessagesList.Add(new MessageItem {
                    Message = string.Format("{0}({1})", message, timeSpan), FileName = string.Empty
                });
            }
#endif
        }
Beispiel #7
0
 /// <summary>
 ///  Handle the message display when error occurs
 /// </summary>
 /// <param name="message"></param>
 public void OnErrorOccured(Exception exception)
 {
     if (exception is WebException)
     {
         MessagesList.Add(new MessageItem {
             Message = Messages.msgWSError, FileName = string.Empty
         });
     }
     else
     {
         MessagesList.Add(new MessageItem {
             Message = Messages.msgGenericError, FileName = string.Empty
         });
     }
 }
Beispiel #8
0
 private void CheckObjectsInterMachines()
 {
     for (int i = 0; i < Trees.Count - 1; i++)
     {
         BasicObjectsTree tree1 = Trees[i];
         for (int j = i + 1; j < Trees.Count; j++)
         {
             BasicObjectsTree tree2 = Trees[j];
             var list = tree1.UsedObjects.Keys.Intersect(tree2.UsedObjects.Keys);
             foreach (DrawableObject obj in list)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, string.Format("Object '{0}' is shared between '{1}' and '{2}' machines.", obj.Name, tree1.Root.Name, tree2.Root.Name), obj));
             }
         }
     }
 }
Beispiel #9
0
 public void AddMessage(Message msg)
 {
     if (msg != null)
     {
         //check message comes from current conversation user
         if (msg.Name == Contact.Name)
         {
             MessagesList.Add(msg);
             OnMessageReceived(this, msg);
         }
         else
         {
             //Store message in DB, so this can be retrieved later from Conversations page
         }
     }
 }
Beispiel #10
0
                public virtual void OnNext(Model.Message value)
                {
                    App.Current.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        bool result = value.EncodeMessage(Encoding.Unicode);
                        if (!result)
                        {
                            return;
                        }

                        messagesQueue.Add(value);
                        if (messagesQueue.Count > 2)
                        {
                            messagesQueue.RemoveAt(0);
                        }
                    }));
                }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="percentage"></param>
        /// <param name="message"></param>
        /// <param name="timeSpan"></param>
        public void OnStepDone(double percentage, string message, TimeSpan timeSpan)
        {
            ProgressPercentage += percentage;
#if DEBUG
            lock (MessagesList)
            {
                MessagesList.Add(new MessageItem {
                    Message = $"{message}({timeSpan})", FileName = string.Empty
                });
            }
#else
            lock (MessagesList)
            {
                MessagesList.Add(new MessageItem {
                    Message = $"{message}", FileName = string.Empty
                });
            }
#endif
        }
        //public async Task ExecuteSelectFileToInsert()
        //{
        //    FileData filedata = await CrossFilePicker.Current.PickFile();

        //    //Getting the filename and the data info from the image picked
        //    FileName = filedata.FileName;
        //    FileData = filedata.DataArray;

        //    File newFile = new File(FileName, FileData);

        //    var MessageToPush = new MessageModel(UserLogged.UserName, newFile);

        //    var item = await client
        //      .Child("Chat")
        //      //.WithAuth("<Authentication Token>") // <-- Add Auth token if required. Auth instructions further down in readme.
        //      .PostAsync(MessageToPush);

        //    MessagesList.Add(MessageToPush);
        //}

        public async Task ExecuteSendMessageToChat()
        {
            var MessageToPush = new MessageModel(MessageText, UserLogged.UserName);
            //{
            //    Title = MessageText,
            //    MessageOwner = User.UserName
            //};

            //if (!InverseChat)
            //{
            //    ChatKey = UserLogged.UserName + "_" + SelectedIt.UserName;
            //}

            var item = await client
                       .Child(ChatKey) //Este Item va dentro del nodo:
                                       //.WithAuth("<Authentication Token>") // <-- Add Auth token if required. Auth instructions further down in readme.
                       .PostAsync(MessageToPush);

            MessagesList.Add(MessageToPush);
        }
Beispiel #13
0
        private void BuildBasicObjectsTrees()
        {
            Trees           = new List <BasicObjectsTree>();
            GlobalObjects   = new List <IBasicGlobal>();
            BasicStatesList = new List <BasicState>();
            foreach (IGlobal global in Book.Globals)
            {
                switch (global)
                {
                case Origin origin:
                    if (origin.Father == null)
                    {
                        var basicObjectsTree = new BasicObjectsTree(origin.OwnerDraw.OwnerSheet, origin);
                        Trees.Add(basicObjectsTree);
                        if (!basicObjectsTree.AddStatesToList(BasicStatesList))
                        {
                            MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "There is one or more states used in diferent state machines.", null));
                        }
                        GlobalObjects.Add(basicObjectsTree);
                    }
                    break;

                case Relation indir:
                    GlobalObjects.Add(RelationsList.Find(bi => bi.Relation == indir));
                    break;

                case Equation eq:
                    GlobalObjects.Add(EquationsList.Find(be => be.Equation == eq));
                    break;
                }
            }
            if (Trees.Count == 0)
            {
                MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "There is not a valid state machine to check.", null));
            }
        }
Beispiel #14
0
 /// <summary>
 ///
 /// </summary>
 public void OnSettingsSaved()
 {
     MessagesList.Add(new MessageItem {
         Message = Messages.msgSettingsSaved, FileName = string.Empty
     });
 }
Beispiel #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public void OnServiceRemoved(string url)
 {
     MessagesList.Add(new MessageItem {
         Message = Messages.msgServiceRemoved, FileName = string.Empty
     });
 }
Beispiel #16
0
 /// <summary>
 ///  Handle the message display after service tested (ping)
 /// </summary>
 /// <param name="url"></param>
 /// <param name="pingOK"></param>
 public void OnServiceChecked(string url, bool pingOK)
 {
     MessagesList.Add(new MessageItem {
         Message = (pingOK) ? Messages.msgPingServiceSuccess : Messages.msgPingServiceFailure, FileName = string.Empty
     });
 }
Beispiel #17
0
 private void GetUsedObjects(DrawingSheet sheet, VariableCollection variables)
 {
     if (sheet is ModelSheet model)
     {
         UsedModels.Add(model);
     }
     else
     {
         UsedSheets.Add(sheet);
     }
     foreach (DrawableObject obj in sheet.Sketch.Objects)
     {
         if (obj is Relation indir)
         {
             Variable input  = VariableCollection.GetIndirectInput(sheet, indir.Trigger);
             Variable output = VariableCollection.GetIndirectOutput(sheet, indir.Output);
             if (input == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation trigger variable not found.", indir));
             }
             if (output == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation output variable not found.", indir));
             }
             if (input != null && output != null)
             {
                 BasicRelation ibindir = RelationsList.FirstOrDefault(ind => ind.Input.Name == input.Name);
                 BasicRelation obindir = RelationsList.FirstOrDefault(ind => ind.Action.Output.Name == input.Name);
                 if (ibindir != null)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation has same input than other one.", indir, ibindir.Relation));
                 }
                 if (obindir != null)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation has same output than other one.", indir, obindir.Relation));
                 }
                 if (ibindir == null && obindir == null)
                 {
                     BasicOutput   action = indir.Action == null ? null : new BasicOutput((OperationType)Enum.Parse(typeof(OperationType), indir.Action), output);
                     BasicRelation bindir = new BasicRelation(indir, input, action);
                     RelationsList.Add(bindir);
                 }
             }
         }
         else if (obj is Equation eq)
         {
             IInternalOutput output = variables.IndirectOutputs.FirstOrDefault(io => io.Name == eq.AssignTo);
             if (output == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Relation trigger variable not found.", eq));
             }
             if (eq.Operation == "")
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Equation does not have operation.", eq));
             }
             LexicalAnalyzer lexAnalyzer = new LexicalAnalyzer();
             SyntaxAnalyzer  syntaxAnalyzer;
             lexAnalyzer.Source = eq.Operation;
             syntaxAnalyzer     = new SyntaxAnalyzer(lexAnalyzer, VariableCollection.GetConditionDictionary(eq.OwnerDraw.OwnerSheet).Keys.ToList());
             foreach (SyntaxToken token in syntaxAnalyzer.Tokens)
             {
                 if (token.Qualifier != SyntaxToken.Qualifiers.Correct)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, string.Format("{0}: {1}.", eq.Name, token.ToString()), eq));
                 }
             }
             EquationsList.Add(new BasicEquation(eq));
         }
         else if (obj is Transition trans)
         {
             TransitionsList.Add(trans);
             if (trans.StartObject == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition without start connection.", trans));
             }
             if (trans.EndObject == null)
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition without end connection.", trans));
             }
             if (trans is SimpleTransition strans && strans.Condition == "" && strans.Timeout == 0)
             {
                 if (strans.StartObject is Origin origin)
                 {
                     if (strans.EndObject is End || strans.EndObject is Abort)
                     {
                         MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "One shot machine Transition should have a condition.", trans));
                     }
                 }
                 else if (!strans.DefaultTransition)
                 {
                     MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition does not have condition or timeout value.", trans));
                 }
             }
             else if (trans is SuperTransition sptrans && sptrans.Links == "")
             {
                 MessagesList.Add(new CheckMessage(CheckMessage.MessageTypes.Error, "Transition is not linking any object.", trans));
             }
         }
 public void InsertMessage(MessageModel message)
 {
     MessageObservable.OnNext(message);
     MessagesList.Add(message);
 }
Beispiel #19
0
 public async void StartGiveaway()
 {
     MessagesList.Add(await Program.bot.SendTextMessageAsync(ChatId, GiveawayEventAndText()).ConfigureAwait(false));
 }
        private void RbInstantMessaging_MessageReceived(object sender, Rainbow.Events.MessageEventArgs e)
        {
            if (e.ConversationId == this.conversationId)
            {
                log.Debug("[RbInstantMessaging_MessageReceived] - FromJId:[{0}] - ToJid:[{1}] - CarbonCopy:[{2}] - Message.Id:[{3}] - Message.ReplaceId:[{4}]", e.Message.FromJid, e.Message.ToJid, e.CarbonCopy, e.Message.Id, e.Message.ReplaceId);

                InstantMessaging.Model.Message newMsg = GetMessageFromRBMessage(e.Message, rbConversation.Type);
                if (newMsg == null)
                {
                    log.Warn("[RbInstantMessaging_MessageReceived] - Impossible to have Model.Message from XMPP Message - Message.Id:[{3}]", e.Message.Id);
                    return;
                }

                // Since message is not null, set the Avatar Source
                newMsg.AvatarSource = Helper.GetContactAvatarImageSource(newMsg.PeerId);

                // Manage incoming REPLACE message
                if (!String.IsNullOrEmpty(e.Message.ReplaceId))
                {
                    InstantMessaging.Model.Message previousMessage = GetMessageByMessageId(e.Message.Id);
                    if (previousMessage == null)
                    {
                        // We do nothing in this case ... Message not in the cache, so not visible ...
                        return;
                    }

                    previousMessage.Body          = newMsg.Body;
                    previousMessage.BodyIsVisible = String.IsNullOrEmpty(previousMessage.Body) ? "False" : "True";

                    previousMessage.EditedIsVisible = "True";
                }
                // Manage incoming NEW message
                else
                {
                    // It's a new message to add in the list
                    newMessageAdded = true;

                    lock (lockObservableMessagesList)
                    {
                        // Do we have already some message ?
                        if (MessagesList.Count == 0)
                        {
                            MessagesList.Add(newMsg);
                        }
                        else
                        {
                            // Add to the list but need to check date
                            InstantMessaging.Model.Message storedMsg;
                            bool newMsgInserted = false;
                            int  nb             = MessagesList.Count - 1;

                            for (int i = nb; i > 0; i--)
                            {
                                storedMsg = MessagesList[i];
                                if (newMsg.MessageDateTime > storedMsg.MessageDateTime)
                                {
                                    if (i == nb)
                                    {
                                        MessagesList.Add(newMsg);
                                    }
                                    else
                                    {
                                        MessagesList.Insert(i, newMsg);
                                    }
                                    newMsgInserted = true;
                                    break;
                                }
                            }
                            // If we don't have already added the new message, we insert it to the first place
                            if (!newMsgInserted)
                            {
                                MessagesList.Insert(0, newMsg);
                            }
                        }
                    }
                }

                // Mark the message as read
                if (XamarinApplication.CurrentConversationId == this.conversationId)
                {
                    XamarinApplication.RbInstantMessaging.MarkMessageAsRead(this.conversationId, newMsg.Id, null);
                }
            }
        }