Ejemplo n.º 1
0
        //----< process incoming messages on child thread >----------------

        private void processMessages()
        {
            ThreadStart thrdProc = () =>
            {
                while (true)
                {
                    CsMessage msg = translater.getMessage();
                    try
                    {
                        if (msg.value("command") != "getFiles" && msg.value("command") != "getDirs")
                        {
                            msg.show();
                        }
                        string msgId = msg.value("command");
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.Write("\n {0}", e.Message);
                        msg.show();
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
        //----< respond to mouse click on Connect >----------------

        private void Connect_Click(object sender, RoutedEventArgs e)
        {
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;

            PathTextBlock2.Text = "Storage";
            pathStack_.Push("../Storage");
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "getDirs");
            msg.add("path", pathStack_.Peek());
            Console.WriteLine("\n  posting message in Translater");
            msg.show();
            translater.postMessage(msg);
            msg.remove("command");
            msg.add("command", "getFiles");
            Console.WriteLine("\n  posting message in Translater");
            msg.show();
            translater.postMessage(msg);

            isConnect = true;
        }
Ejemplo n.º 3
0
        //----< load clearAll processing into dispatcher dictionary >------

        private void DispatcherLoadClearAll()
        {
            Action <CsMessage> afterClearAll = (CsMessage rcvMsg) =>
            {
                clearing = false;
                Action clearDone = () =>
                {
                    Tab.SelectedIndex = 0;
                    txtStatus.Text    = "Clearing Done!";
                };
                Dispatcher.Invoke(clearDone, new Object[] { });
                //Tab.SelectedIndex = 1;
                if (closing)
                {
                    Action disconnect = () =>
                    {
                        CsMessage msg = new CsMessage();
                        msg.add("to", CsEndPoint.toString(serverEndPoint_));
                        msg.add("from", CsEndPoint.toString(endPoint_));
                        msg.add("command", "quit");
                        Console.Write("\nClient sending ");
                        msg.show();
                        translater.postMessage(msg);
                    };
                    Dispatcher.Invoke(disconnect, new Object[] { });
                }
            };

            addClientProc("clearAll", afterClearAll);
        }
        //----< respond to mouse click on view file >----------------

        private void Browse_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("\n  Demonstrating Requirement #4 - Browsing & View-File");

            string     selectedFileName = (string)FileList2.SelectedItem;
            CsEndPoint serverEndPoint   = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "browse2");
            msg.add("fname", selectedFileName);

            Console.WriteLine("\n  posting message in Translater");
            msg.show();
            translater.postMessage(msg);

            Thread.Sleep(500);

            string contents = File.ReadAllText("../../../temp/" + selectedFileName);
            Action showfile = () =>
            {
                showFile(selectedFileName, contents);
            };

            Dispatcher.Invoke(showfile, new Object[] { });
        }
Ejemplo n.º 5
0
 public void commandDownload()
 {
     if (downloading)
     {
         txtStatus.Text = "Please do not reclick when downloading...";
     }
     else
     {
         if (listProducts.SelectedItems.Count == 0)
         {
             txtStatus.Text = "Please choose at least one file to download!";
         }
         else
         {
             downloading = true;
             planDownloads.Clear();
             txtStatus.Text = "Downloading...Please wait.";
             var       selected = listProducts.SelectedItems;
             CsMessage msg      = new CsMessage();
             msg.add("to", CsEndPoint.toString(serverEndPoint_));
             msg.add("from", CsEndPoint.toString(endPoint_));
             msg.add("command", "downloadSelected");
             msg.add("saveFilePath", txtFDirOut.Text + "\\HTML");
             for (int i = 0; i < selected.Count; i++)
             {
                 msg.add("download-product" + i, selected[i].ToString());
             }
             Console.Write("\nClient sending ");
             msg.show();
             translater.postMessage(msg);
         }
     }
 }
        private void selectDependency_Click(object sender, RoutedEventArgs e)
        {
            //dependencyFiles_ = selectedFiles_;
            //string tempStr = "";
            //foreach (var item in selectedFiles_) {
            //    tempStr += item + ", ";
            //}
            //localNotification.Items.Add("confirm select dependency files : " + tempStr);
            MainWindow win = (MainWindow)Window.GetWindow(this);

            string fileName = (string)FileList.SelectedItem;
            string srcFile  = localStorageRoot_ + "/" + pathStack_.Peek() + "/" + fileName;

            srcFile = System.IO.Path.GetFullPath(srcFile);
            string dstFile = win.sendFilesPath + "/" + fileName;

            System.IO.File.Copy(srcFile, dstFile, true);

            dependencyFiles_ += fileName + "/";

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(navEndPoint_));
            msg.add("command", "preCheckingin");
            msg.add("sendingFile", fileName);
            msg.show();
            win.translater.postMessage(msg);
            localNotification.Items.Add("add " + (string)FileList.SelectedItem + " to dependency files");
        }
        //----< process incoming messages on child thread >----------------

        private void processMessages()
        {
            ThreadStart thrdProc = () => {
                while (true)
                {
                    CsMessage msg = translater.getMessage();
                    try
                    {
                        string msgId = msg.value("command");
                        Console.Write("\n  client getting message \"{0}\"", msgId);
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write("\n  {0}", ex.Message);
                        msg.show();
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
        //----<trigger connection to start comm and load dispatcher>------------------------
        private void Connect_Click(object sender, RoutedEventArgs e)
        {
            // start Comm
            serverEndPoint = new CsEndPoint();
            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;

            endPoint_ = new CsEndPoint();
            endPoint_.machineAddress = "localhost";
            endPoint_.port           = int.Parse(Environment.GetCommandLineArgs()[1]);

            translater = new Translater();
            translater.listen(endPoint_);
            loadDispatcher();
            processMessages();

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "connect");
            translater.postMessage(msg);
            msg.show();
            msg.remove("command");
            checkoutPathStack_.Push("../Repository");
            ShowRepo();
            Console.WriteLine("\n  Connected to the repo server.");
        }
Ejemplo n.º 9
0
        private void Connect(object sender, RoutedEventArgs e)
        {
            // start Comm
            endPoint_ = new CsEndPoint();
            endPoint_.machineAddress = "localhost";
            endPoint_.port           = 8082;
            translater = new Translater();
            translater.listen(endPoint_);

            // start processing messages
            processMessages();

            // load dispatcher
            loadDispatcher();

            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;
            listboxforconnect.Items.Insert(0, "request to connect...");
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "connect");
            msg.show();
            translater.postMessage(msg);
        }
        //----< respond to pop up file content >-------
        private void FileMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string fileName;

            if (isTest)
            {
                fileName = "MPC_IComm.h.1";
            }
            else
            {
                fileName = RepoFileList.SelectedValue as string;
            }
            try
            {
                string path = System.IO.Path.Combine(checkoutPathStack_.Peek(), fileName);

                CsMessage msg = new CsMessage();
                msg.add("to", CsEndPoint.toString(serverEndPoint));
                msg.add("from", CsEndPoint.toString(endPoint_));
                msg.add("command", "viewFile");
                msg.add("viewFile", checkoutPathStack_.Peek());
                msg.add("fileName", fileName);
                translater.postMessage(msg);
                msg.show();
                // build message to get files and post it
                msg.remove("command");
                msgCount = 1;
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }
        }
        private void checkin_Click(object sender, RoutedEventArgs e)
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(navEndPoint_));
            msg.add("command", "checkin");
            msg.add("checkinFile", fileName_);
            msg.add("userName", userName_);
            msg.add("descrip", descript_);
            msg.add("category", category_);
            //string tempDependency = "";
            //foreach (var item in dependencyFiles_) {
            //    tempDependency += item + ",";
            //}
            msg.add("dependencyFiles", dependencyFiles_);
            msg.show();
            win.translater.postMessage(msg);

            fileName_        = "";
            userName_        = "";
            descript_        = "";
            category_        = "";
            dependencyFiles_ = "";
        }
        //----< respond to check_out click >-------
        private void Checkout_Click(object sender, RoutedEventArgs e)
        {
            if (isConnected == false)
            {
                MessageBox.Show("Please connect to the server first!");
                return;
            }
            if (checkoutFile == "")
            {
                MessageBox.Show("Please select a parent file.");
                return;
            }

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("destination", "../../../Staging");
            msg.add("source", checkoutPathStack_.Peek());
            msg.add("command", "checkout");
            msg.add("requestfile", checkoutFile);
            translater.postMessage(msg);
            msg.show();

            // build message to get files and post it
            msg.remove("command");
            CheckoutList.Items.Clear();
            checkoutFile = "";
        }
        //private void localFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    //selectedFiles_.Clear();
        //    ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
        //    foreach (var files in FileList.SelectedItems)
        //    {

        //        tempFile_ =  files.ToString();
        //    }
        //}

        private void selectFile_Click(object sender, RoutedEventArgs e)
        {
            //if (selectedFiles_.Count() == 1)
            //{
            //    fileName_ = selectedFiles_[0];
            //    localNotification.Items.Add("confirm select " + fileName_ +" as check in file");
            //}
            MainWindow win = (MainWindow)Window.GetWindow(this);

            fileName_ = (string)FileList.SelectedItem;

            string srcFile = localStorageRoot_ + "/" + pathStack_.Peek() + "/" + fileName_;

            srcFile = System.IO.Path.GetFullPath(srcFile);
            string dstFile = win.sendFilesPath + "/" + fileName_;

            System.IO.File.Copy(srcFile, dstFile, true);

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(navEndPoint_));
            msg.add("command", "preCheckingin");
            msg.add("sendingFile", fileName_);
            msg.show();
            win.translater.postMessage(msg);

            localNotification.Items.Add("confirm select " + fileName_ + " as check in file");
        }
        //----< function for checkIn>----------------

        void CheckIn()
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            win.txtStatusBar.Text = "Sending CheckIn request to server...";
            try
            {
                string fileName = (string)FileList.SelectedItem;
                string srcFile  = localStorageRoot_ + pathStack_.Peek() + "/" + fileName;
                srcFile = System.IO.Path.GetFullPath(srcFile);
                string dstFile = win.sendFilesPath + "/" + fileName;
                System.IO.File.Copy(srcFile, dstFile, true);
                // prepare message to send as a request to server and send it
                CsEndPoint serverEndPoint = new CsEndPoint();
                serverEndPoint.machineAddress = "localhost";
                serverEndPoint.port           = 8080;
                CsMessage msg = new CsMessage();
                string    status, category = "", dependency = "", author = "";
                author = AuthText.Text;
                foreach (ListBoxItem item in CatList.SelectedItems)
                {
                    category = category + item.Content.ToString() + "-";
                }
                if (OpenBtn.IsChecked == true)
                {
                    status = "Open";
                }
                else
                {
                    status = "Close";
                }
                string pathDep = pathStackRemote_.Peek();
                string pkg     = pathDep.Substring(pathDep.LastIndexOf('/') + 1);
                if (pkg == "Storage")
                {
                    pkg = "";
                }
                foreach (string item in FileListRemote.SelectedItems)
                {
                    dependency = dependency + pkg + "::" + item.ToString() + "-";
                }
                msg.add("to", CsEndPoint.toString(serverEndPoint));
                msg.add("from", CsEndPoint.toString(win.endPoint_));
                msg.add("command", "checkInFile");
                msg.add("sendingFile", fileName);
                msg.add("path", pathStack_.Peek());
                msg.add("fileName", fileName);
                msg.add("verbose", "sending checkin file");
                msg.add("author", author);
                msg.add("dependency", dependency);
                msg.add("status", status);
                msg.add("category", category);
                msg.show();
                win.translater.postMessage(msg);
            }
            catch (Exception e)
            {
                win.txtStatusBar.Text = "Something is wrong..." + e;
            }
        }
        //----< function for browse message>----------------

        void BrowseMsg(string qFileName, string category, string qDep, string qVer, string qParent)
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            win.txtStatusBar.Text = "Sending browseFiles request to server...";

            // prepare message to send as a request to server and send it
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(win.endPoint_));
            msg.add("command", "browseFiles");
            msg.add("verbose", "browse files by queries");
            msg.add("qFileName", qFileName);
            msg.add("qCategory", category);
            msg.add("qDependency", qDep);
            msg.add("qVersion", qVer);
            msg.add("qParent", qParent);
            msg.show();
            win.translater.postMessage(msg);
        }
        //----< function to respond to CheckIn button-click>----------------
        void CheckInMsg(string fileName, string path, string author, string dependency, string status, string category)
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            win.txtStatusBar.Text = "Sending CheckIn request to server...";
            string srcFile = localStorageRoot_ + path + "/" + fileName;

            srcFile = System.IO.Path.GetFullPath(srcFile);
            string dstFile = win.sendFilesPath + "/" + fileName;

            System.IO.File.Copy(srcFile, dstFile, true);
            // prepare message to send as a request to server and send it
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(win.endPoint_));
            msg.add("command", "checkInFile");
            msg.add("sendingFile", fileName);
            msg.add("path", path);
            msg.add("fileName", fileName);
            msg.add("verbose", "sending checkin file");
            msg.add("author", author);
            msg.add("dependency", dependency);
            msg.add("status", status);
            msg.add("category", category);
            msg.show();
            win.translater.postMessage(msg);
        }
        //--------------------<Browse button click event>------------------------------
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (isConnected == false)
            {
                MessageBox.Show("Please connect to the server first!");
                return;
            }
            if (ConditionComboBox == null)
            {
                MessageBox.Show("Please select a query condition!");
                return;
            }
            String queryCondition = ConditionComboBox.Text;
            String content        = tbQueryContent.Text;

            if (content == "")
            {
                MessageBox.Show("Please input browsing arguments.");
                return;
            }
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "browse");
            msg.add("queryCondition", queryCondition);
            msg.add("queryContent", content);
            translater.postMessage(msg);
            msg.show();
            msg.remove("command");
        }
Ejemplo n.º 18
0
        public void commandGetDirsAndFiles()
        {
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "getDirs");
            msg.add("path", pathStack_.Peek());
            Console.Write("\nClient sending ");
            msg.show();
            translater.postMessage(msg);
            msg.remove("command");
            msg.add("command", "getFiles");
            Console.Write("\nClient sending ");
            msg.show();
            translater.postMessage(msg);
        }
Ejemplo n.º 19
0
        public void commandDemoOn()
        {
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "demoOn");
            Console.Write("\nClient sending ");
            msg.show();
            translater.postMessage(msg);
        }
        //--------------------<send message to server to get files without parents of the selected category>-------------------
        private void CategoriesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            String    category = CategoriesList.SelectedValue as String;
            CsMessage msg      = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "getRoot");
            msg.add("category", category);
            translater.postMessage(msg);
            msg.show();
            msg.remove("command");
        }
Ejemplo n.º 21
0
        //----< respond to click on restart button >----------------

        private void BtnRestart_Click(object sender, RoutedEventArgs e)
        {
            txtStatus.Text = "Clearing client temp files on server...Please wait.";
            clearing       = true;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "clearAll");
            Console.Write("\nClient sending ");
            msg.show();
            translater.postMessage(msg);
        }
Ejemplo n.º 22
0
        //----< Send check out message for given fileName>------
        private void CheckOut(string filePath, string fileName)
        {
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "checkOut");
            msg.add("path", filePath);
            msg.add("fileName", fileName);
            msg.add("type", "CheckOut");
            translater.postMessage(msg);
            msg.show();
        }
Ejemplo n.º 23
0
        //----< navigation logic for repo (used in Build/Submit page) >---------

        private void navigate()
        {
            CsEndPoint userEndPoint = new CsEndPoint();

            userEndPoint.machineAddress = "localhost";
            userEndPoint.port           = 9000;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(userEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "Show_Contents");
            if (currentPath.Length == 0)
            {
                currentPath = "../MockRepo";
            }
            else if (LeftListBox.SelectedItem.ToString().Substring(0, 5) == "<dir>")
            {
                currentPath += "/" + LeftListBox.SelectedItem.ToString().Substring(6);
            }
            else if (LeftListBox.SelectedItem.ToString() == "<-- Back")
            {
                int lastIndex = currentPath.LastIndexOf('/');
                currentPath = currentPath.Substring(0, lastIndex);
            }
            if (currentPath == "..")
            {
                currentPath = "../MockRepo";
                LeftListBox.Items.Clear();
                LeftListBox.Items.Add("MockRepo");
                return;
            }
            msg.add("dir_name", currentPath);
            translater.postMessage(msg);
            CsMessage replyMsg = translater.getMessage();

            // No point in checking command with this esoteric (and brittle)
            // message passing structure, but it should be "Show_Contents_Reply".
            replyMsg.show();
            string contentsString = replyMsg.value("Contents_String");

            string[] contentsArray = contentsString.Split('$');
            LeftListBox.Items.Clear();
            LeftListBox.Items.Add("<-- Back");
            for (int i = 0; i < contentsArray.Length; i++)
            {
                if (contentsArray[i] != "." && contentsArray[i] != "..")
                {
                    LeftListBox.Items.Add(contentsArray[i]);
                }
            }
        }
        private void confirm_descrip_Click(object sender, RoutedEventArgs e)
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(navEndPoint_));
            msg.add("command", "descripFolder");
            descript_ = description.Text;
            msg.add("descripFolder", descript_);
            msg.show();
            win.translater.postMessage(msg);
        }
Ejemplo n.º 25
0
        void test8()
        {
            Console.WriteLine("\n\n  Test check in Comm.cpp AGAIN, depends on Comm.h.Folder name in Repo is the same as package description");
            Console.WriteLine("  ===================================");
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint_));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "descripFolder");
            msg.add("descripFolder", "Comm Package");
            translater.postMessage(msg);
            string fileName = "Comm.cpp";
            string srcFile  = NavLocal.localStorageRoot_ + "/" + fileName;

            srcFile = System.IO.Path.GetFullPath(srcFile);
            string dstFile = sendFilesPath + "/" + fileName;

            System.IO.File.Copy(srcFile, dstFile, true);
            msg.remove("descripFolder");
            msg.remove("command");
            msg.add("command", "preCheckingin");
            msg.add("sendingFile", fileName);
            translater.postMessage(msg);
            NavLocal.localNotification.Items.Add("confirm select " + fileName + " as check in file");
            fileName = "Comm.h";
            srcFile  = NavLocal.localStorageRoot_ + "/" + fileName;
            dstFile  = sendFilesPath + "/" + fileName;
            System.IO.File.Copy(srcFile, dstFile, true);
            msg.remove("sendingFile");
            msg.add("sendingFile", fileName);
            translater.postMessage(msg);
            NavLocal.localNotification.Items.Add("add " + fileName + " to dependency files");
            fileName = "Comm.cpp";
            srcFile  = NavLocal.localStorageRoot_ + "/" + fileName;
            dstFile  = sendFilesPath + "/" + fileName;
            System.IO.File.Copy(srcFile, dstFile, true);
            CsMessage msg_commH = new CsMessage();

            msg_commH.add("to", CsEndPoint.toString(serverEndPoint_));
            msg_commH.add("from", CsEndPoint.toString(endPoint_));
            msg_commH.add("command", "checkin");
            msg_commH.add("checkinFile", "Comm.cpp");
            msg_commH.add("userName", "WeitianDing");
            msg_commH.add("descrip", "Comm Package");
            msg_commH.add("category", "MsgPassingCommunication/TestNameSpace/");
            msg_commH.add("dependencyFiles", "Comm.h/");
            msg_commH.show();
            translater.postMessage(msg_commH);
            //test9();
        }
Ejemplo n.º 26
0
        //----< navigation logic for repo >-------------------------------------

        private void navigateForRepoListBox()
        {
            CsEndPoint userEndPoint = new CsEndPoint();

            userEndPoint.machineAddress = "localhost";
            userEndPoint.port           = 9000;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(userEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "Show_Contents");
            if (currentPathForRepoListBox.Length == 0)
            {
                currentPathForRepoListBox = "../MockRepo";
            }
            else if (RepoListBox.SelectedItem.ToString().Substring(0, 5) == "<dir>")
            {
                currentPathForRepoListBox += "/" + RepoListBox.SelectedItem.ToString().Substring(6);
            }
            else if (RepoListBox.SelectedItem.ToString() == "<-- Back")
            {
                int lastIndex = currentPathForRepoListBox.LastIndexOf('/');
                currentPathForRepoListBox = currentPathForRepoListBox.Substring(0, lastIndex);
            }
            if (currentPathForRepoListBox == "..")
            {
                currentPathForRepoListBox = "../MockRepo";
                RepoListBox.Items.Clear();
                RepoListBox.Items.Add("MockRepo");
                return;
            }
            msg.add("dir_name", currentPathForRepoListBox);
            translater.postMessage(msg);
            CsMessage replyMsg = translater.getMessage();

            replyMsg.show();
            string contentsString = replyMsg.value("Contents_String");

            string[] contentsArray = contentsString.Split('$');
            RepoListBox.Items.Clear();
            RepoListBox.Items.Add("<-- Back");
            for (int i = 0; i < contentsArray.Length; i++)
            {
                if (contentsArray[i] != "." && contentsArray[i] != "..")
                {
                    RepoListBox.Items.Add(contentsArray[i]);
                }
            }
        }
Ejemplo n.º 27
0
        //----< function to send ConnectToServer message request>----------------

        void donotReply()
        {
            // prepare message to send as a request to server and send it
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "doNotReply");
            msg.add("verbose", "Do not reply message - one way");
            msg.show();
            translater.postMessage(msg);
        }
        //----< function for browse>----------------

        void Browse()
        {
            MainWindow win = (MainWindow)Window.GetWindow(this);

            try
            {
                win.txtStatusBar.Text = "Sending browseFiles request to server...";

                // prepare message to send as a request to server and send it
                CsEndPoint serverEndPoint = new CsEndPoint();
                serverEndPoint.machineAddress = "localhost";
                serverEndPoint.port           = 8080;
                CsMessage msg = new CsMessage();

                string qFileName = txtFname.Text;
                string qDep      = txtDep.Text;
                string qVer      = txtVer.Text;
                string qParent   = "";
                if ((bool)qChkParent.IsChecked)
                {
                    qParent = "Yes";
                }
                string category = "";
                foreach (ListBoxItem item in qCatList.SelectedItems)
                {
                    category = category + item.Content.ToString();
                }

                msg.add("to", CsEndPoint.toString(serverEndPoint));
                msg.add("from", CsEndPoint.toString(win.endPoint_));
                msg.add("command", "browseFiles");
                msg.add("verbose", "browse files by queries");
                msg.add("qFileName", qFileName);
                msg.add("qCategory", category);
                msg.add("qDependency", qDep);
                msg.add("qVersion", qVer);
                msg.add("qParent", qParent);
                msg.show();
                win.translater.postMessage(msg);
            }
            catch (Exception ex)
            {
                win.txtStatusBar.Text = "Something is wrong..." + ex;
            }
        }
Ejemplo n.º 29
0
        //----< function to send ConnectToServer message request>----------------

        void ConnectToServer()
        {
            txtStatusBar.Text = "Sending ConnectToServer request...";

            // prepare message to send as a request to server and send it
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8080;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "connectToServer");
            msg.add("verbose", "connection request");
            msg.show();
            translater.postMessage(msg);
        }
Ejemplo n.º 30
0
        //-------< Demonstrating Requirement 5 >------------------------------------
        void demoReq5()
        {
            Console.WriteLine("Demonstrating Requirement 5: \n");
            Console.WriteLine("Provided message designs appropriate for this application. " +
                              "All messages are instances of the same Message class, but have a specified set of attributes " +
                              "and body contents suited for the intended task. \n");
            Console.WriteLine("Structure of messages is as below\n");
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.port = serverport;
            CsMessage msg = new CsMessage();

            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("command", "echo");
            msg.add("demo_msg", "demo msg 1");
            msg.show();
            Console.WriteLine("\n-------------------------------------------------\n");
        }