Ejemplo n.º 1
0
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Deleting information component.");
            InformationContainer cont = Globals.RationallyAddIn.View.Children.FirstOrDefault(obj => obj.RationallyType == "information") as InformationContainer;

            cont?.Children.RemoveAll(obj => obj.Shape.Equals(changedShape));
        }
Ejemplo n.º 2
0
        public void StartClient(string url)
        {
            // Connect to a remote device.
            try
            {
                // Establish the remote endpoint for the socket.
                // The name of the
                IPHostEntry ipClientInfo    = Dns.GetHostEntry(Dns.GetHostName());
                IPAddress   ipClientAddress = ipClientInfo.AddressList[0];

                IPHostEntry ipHostInfo = Dns.GetHostEntry(url);
                IPAddress   ipAddress  = ipHostInfo.AddressList[0];
                IPEndPoint  remoteEP   = new IPEndPoint(ipAddress, port);

                // Create a TCP/IP socket.
                Socket client = new Socket(ipAddress.AddressFamily,
                                           SocketType.Stream, ProtocolType.Tcp);

                // Connect to the remote endpoint.
                client.BeginConnect(remoteEP,
                                    new AsyncCallback(ConnectCallback), client);
                connectDone.WaitOne();

                string[] IPParts = ipClientAddress.ToString().Split('%');
                // Send test data to the remote device.
                Send(client, IPParts[0] + "<IPIF>");

                InformationContainer.selfIP = IPParts[0];

                sendDone.WaitOne();

                // Receive the response from the remote device.
                Receive(client);
                receiveDone.WaitOne();

                // Write the response to the console.
                Console.WriteLine("Response received : {0}", response);

                InformationContainer.PushIPAddressesIntoLoop(url);
                SentConfirm(true);


                // Release the socket.
                client.Shutdown(SocketShutdown.Both);
                client.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                SentConfirm(false);
            }
        }
Ejemplo n.º 3
0
        public void ReadCallback(IAsyncResult ar)
        {
            string content = String.Empty;

            StateReader stateReader = (StateReader)ar.AsyncState;
            Socket      handler     = stateReader.workSocket;

            int bytesRead = handler.EndReceive(ar);

            if (bytesRead > 0)
            {
                stateReader.sb.Append(Encoding.ASCII.GetString(stateReader.buffer, 0, bytesRead));
                content = stateReader.sb.ToString();

                if (content.IndexOf("<EOF>") > -1 || content.IndexOf("<IPIF>") > -1)
                {
                    Console.WriteLine("Read {0} bytes from socket. \n Data : {1}",
                                      content.Length, content);
                    //richTextBox.Text=content;
                    richTextBox.Invoke((MethodInvoker) delegate
                    {
                        if (content.IndexOf("<IPIF>") == -1)
                        {
                            richTextBox.Text += content.Replace("<EOF>", "\n");
                        }
                        else
                        {
                            InformationContainer.PushIPAddressesIntoLoop(content.Replace("<IPIF>", ""));
                        }
                    });
                    // Echo the data back to the client.
                    Send(handler, content);
                }
                else
                {
                    handler.BeginReceive(stateReader.buffer, 0, StateReader.BufferSize, 0,
                                         new AsyncCallback(ReadCallback), stateReader);
                }
            }
        }
        private void submit_Click(object sender, EventArgs e)
        {
            if (panelList.TrueForAll(panel => panel.IsValid()))
            {
                Log.Debug("Everyting is valid.");
                pleaseWait.Show();
                pleaseWait.Refresh();
                //wrap all changes that will be triggered by wizard changes in one undo scope
                int wizardScopeId = Globals.RationallyAddIn.Application.BeginUndoScope("Wizard actions");

                CurrentPanel.UpdateModel();
                Globals.RationallyAddIn.Model = ModelCopy;
                Log.Debug("Replaced rationally model by wizard model copy");
                Log.Debug($"Check if wizard creates a new document: {DocumentCreation}");

                if (DocumentCreation)
                {
                    Log.Debug($"Create Decision View Header with title {ModelCopy.DecisionName} by {ModelCopy.Author}");
                    TitleLabel header = new TitleLabel(Globals.RationallyAddIn.Application.ActivePage, ModelCopy.DecisionName);
                    Log.Debug("TitleLabel has been created successfully.");
                    Globals.RationallyAddIn.View.Children.Add(header);
                    Log.Debug("Added title component to the sheet.");
                    //draw the information container
                    InformationContainer informationContainer = new InformationContainer(Globals.RationallyAddIn.Application.ActivePage, ModelCopy.Author, ModelCopy.DateString, ModelCopy.Version);
                    Log.Debug("InformationContainer was created succesfully.");
                    Globals.RationallyAddIn.View.Children.Add(informationContainer);
                    Log.Debug("Added information container to the sheet.");
                    DocumentCreation = false;
                }
                Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is AlternativesContainer)?.Repaint(); //Temporary styling (margin fix) for adding multiple alternatives
                RepaintHandler.Repaint();
                //all changes have been made, close the scope and the wizard
                Globals.RationallyAddIn.Application.EndUndoScope(wizardScopeId, true);
                Close();
                Log.Debug("Closed wizard");
                pleaseWait.Hide();
                //TestServerCreateDecision();
            }
        }
Ejemplo n.º 5
0
 void Start()
 {
     instance = this;
 }
Ejemplo n.º 6
0
 public override void AddToTree(Shape s, bool allowAddOfSubpart)
 {
     if (AlternativesContainer.IsAlternativesContainer(s.Name))
     {
         if (Children.Exists(x => AlternativesContainer.IsAlternativesContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneAlternativesContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             Children.Add(new AlternativesContainer(Page, s));
         }
     }
     else if (RelatedDocumentsContainer.IsRelatedDocumentsContainer(s.Name))
     {
         if (Children.Exists(x => RelatedDocumentsContainer.IsRelatedDocumentsContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneRelatedDocumentsContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             RelatedDocumentsContainer rdc = new RelatedDocumentsContainer(Page, s);
             Children.Add(rdc);
         }
     }
     else if (ForcesContainer.IsForcesContainer(s.Name))
     {
         if (Children.Exists(x => ForcesContainer.IsForcesContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneForcesContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             ForcesContainer forcesContainer = new ForcesContainer(Page, s);
             Children.Add(forcesContainer);
         }
     }
     else if (InformationContainer.IsInformationContainer(s.Name))
     {
         if (Children.Exists(x => InformationContainer.IsInformationContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneInformationContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             InformationContainer informationContainer = new InformationContainer(Page, s);
             Children.Add(informationContainer);
         }
     }
     else if (TitleLabel.IsTitleLabel(s.Name))
     {
         if (Children.Exists(x => TitleLabel.IsTitleLabel(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneTitleAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             TitleLabel titleLabel = new TitleLabel(Page, s);
             Children.Add(titleLabel);
         }
     }
     else if (StakeholdersContainer.IsStakeholdersContainer(s.Name))
     {
         if (Children.Exists(x => StakeholdersContainer.IsStakeholdersContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneStakeholdersContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             StakeholdersContainer stakeholdersContainer = new StakeholdersContainer(Page, s);
             Children.Add(stakeholdersContainer);
         }
     }
     else if (PlanningContainer.IsPlanningContainer(s.Name))
     {
         if (Children.Exists(x => PlanningContainer.IsPlanningContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OnePlanningContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             PlanningContainer planningContainer = new PlanningContainer(Page, s);
             Children.Add(planningContainer);
         }
     }
     else if (allowAddOfSubpart)
     {
         Children.ForEach(r => r.AddToTree(s, true));
     }
 }