Beispiel #1
0
        public async Task <BasicOutput <ChatRoom> > CreateChatRoom(string chatRoomName)
        {
            var result = new BasicOutput <ChatRoom>();

            if (string.IsNullOrWhiteSpace(chatRoomName))
            {
                result.AddNotification(new Notification("Chat name should not be empty", ENotificationType.Error, "chatRoomName"));
            }

            if (result.Invalid)
            {
                return(result);
            }

            var chatRoom = new ChatRoom(chatRoomName);

            if (chatRoom.Invalid)
            {
                result.AddNotifications(chatRoom.ValidationResult);
                return(result);
            }

            await _chatRoomRepository.Create(chatRoom);

            await _unitOfWork.CommitAsync();

            result.SetOutput(chatRoom);
            return(result);
        }
Beispiel #2
0
        public BasicOutput <IEnumerable <ChatRoom> > GetChatRooms()
        {
            var output = new BasicOutput <IEnumerable <ChatRoom> >();

            var chatRooms = _chatRoomRepository.GetAll();

            output.SetOutput(chatRooms);

            return(output);
        }
Beispiel #3
0
        public async Task <BasicOutput <ChatRoom> > GetChatRoom(string chatRoomId)
        {
            var output = new BasicOutput <ChatRoom>();

            var chatRoom = await _chatRoomRepository.GetChatRoomById(Guid.Parse(chatRoomId), false);

            chatRoom.Conversation = _chatRoomRepository.GetChatRoomConversation(chatRoom.Id, 50).ToList();
            output.SetOutput(chatRoom);

            return(output);
        }
Beispiel #4
0
    public override void Activate()
    {
        this.toolName  = "Wire Tool";
        selectedInput  = null;
        selectedOutput = null;

        line.positionCount = 2;
        line.startWidth    = holdWidth;
        line.endWidth      = holdWidth;
        line.startColor    = holdColor;
        line.endColor      = holdColor;
    }
Beispiel #5
0
        public async Task <BasicOutput <string> > SendMessage(string chatRoomId, string authorId, string authorName, string message)
        {
            var result   = new BasicOutput <string>();
            var chatRoom = await _chatRoomRepository.GetChatRoomById(Guid.Parse(chatRoomId), true);

            if (chatRoom == null)
            {
                result.AddNotification(new Notification("Specified chat room could not be found", ENotificationType.Error, "chatRoom"));
            }

            if (result.Invalid)
            {
                return(result);
            }

            var author      = new ChatMessageAuthor(authorId, authorName);
            var chatMessage = new ChatMessage(message, author);

            if (chatMessage.Invalid)
            {
                result.AddNotifications(chatMessage.ValidationResult);
                return(result);
            }

            if (chatMessage.IsMessage)
            {
                chatRoom.AddChatMessage(chatMessage);
                _chatRoomRepository.Update(chatRoom);
                await _unitOfWork.CommitAsync();
            }

            if (chatMessage.IsCommand)
            {
                await _webSocketService.SendCommand(chatRoom.Id.ToString(), chatMessage.Content);
            }

            await _webSocketService
            .SendMessage(
                chatRoom.Id.ToString(),
                chatMessage);

            result.SetOutput("The message has been sent successfully");
            return(result);
        }
Beispiel #6
0
        private string logout(string sessionid)
        {
            BasicOutput outputObj = new BasicOutput();

            try
            {
                outputObj = eloadObj.logout(sessionid);
                Thread.Sleep(AppConfiguration.VinaPhoneTimeout);
            }
            catch
            {
                return("");
            }

            if (outputObj.status == "0")
            {
                return(outputObj.transId);
            }
            else
            {
                return("");
            }
        }
 public void Disconnect()
 {
     this.input = null;
     Deactivate();
     signalLine.enabled = false;
 }
 public void Connect(BasicOutput input)
 {
     this.input = input;
 }
Beispiel #9
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));
             }
         }
Beispiel #10
0
 void ClearSelected()
 {
     selectedInput  = null;
     selectedOutput = null;
 }