コード例 #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();
        }
コード例 #2
0
        string formMetaDataString(CsMessage msg)
        {
            string metadata = "Name: " + msg.value("name") + "\n" +
                              "Description: " + msg.value("description") + "\n" +
                              "Date Time: " + msg.value("datetime") + "\nChildren: ";


            var enumer = msg.attributes.GetEnumerator();

            while (enumer.MoveNext())
            {
                string key = enumer.Current.Key;
                if (key.Contains("child"))
                {
                    metadata = metadata + enumer.Current.Value + "  ";
                }
            }

            metadata = metadata + "\nStatus: " + msg.value("status") + "\n" +
                       "Filepath: " + msg.value("filepath") + "\n" + "Categories: ";

            var enumer1 = msg.attributes.GetEnumerator();

            while (enumer1.MoveNext())
            {
                string key = enumer1.Current.Key;
                if (key.Contains("category"))
                {
                    metadata = metadata + enumer1.Current.Value + "  ";
                }
            }
            return(metadata);
        }
コード例 #3
0
        private void Dbcore_checkbox_clicked(object sender, RoutedEventArgs e)
        {
            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_));
            if (DbCore.IsChecked == true)
            {
                msg.add("command", "filesofcategory");
                msg.add("category", "DbCore");

                Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
                translater.postMessage(msg);
            }
            if (DbCore.IsChecked == false)
            {
                msg.add("command", "removefilesofcategory");
                msg.add("category", "DbCore");

                Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
                translater.postMessage(msg);
            }
        }
コード例 #4
0
        //----< process incoming messages on child thread >----------------

        private void processMessages()
        {
            ThreadStart thrdProc = () =>
            {
                while (true)
                {
                    CsMessage msg = translater.getMessage();
                    if (msg.attributes.ContainsKey("log") && msg.attributes.ContainsKey("requestName"))
                    {
                        byte[] data          = Convert.FromBase64String(msg.value("log"));
                        string decodedString = Encoding.UTF8.GetString(data);
                        string filePath      = msg.value("requestName") + "-result" + ".txt";
                        decodedString = decodedString.Replace("\n", System.Environment.NewLine);
                        using (var streamWriter = File.CreateText(filePath))
                        {
                            streamWriter.Write(decodedString);
                        }
                        this.Dispatcher.Invoke(() =>
                        {
                            TestStatusText.Text += "Test request " + msg.value("requestName") + " executed \n " + "Find the result in -> " + filePath;
                            ResultList.Add(filePath);
                            string[] args = Environment.GetCommandLineArgs();
                            if (args.Length > 1 && args[1] == "INDEMO")
                            {
                                Process.Start(filePath);
                            }
                        });
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
コード例 #5
0
 //-------< Handles the reply msg recieved from Server with Command ViewMetadata>-----------
 private void ViewMeta(CsMessage msg)
 {
     ViewFiletxtbox.Text  = "Message Received \n";
     ViewFiletxtbox.Text += "---------------------- \n";
     ViewFiletxtbox.Text += "COMMAND : " + msg.value("command") + "\n";
     ViewFiletxtbox.Text += "TO : " + msg.value("to") + "\n";
     ViewFiletxtbox.Text += "FROM : " + msg.value("from") + "\n";
     ViewFiletxtbox.Text += "PACKAGE : " + msg.value("pkginfo") + "\n" + "\n";
     statusBarText.Text   = "Recieved ViewMetadata Msg";
 }
コード例 #6
0
 //-------< Handles the reply msg recieved from Server with Command CheckOut>-----------
 private void showCheckOut(CsMessage msg)
 {
     ShowCheckOut.Text += "Message Received \n";
     ShowCheckOut.Text += "---------------------- \n";
     ShowCheckOut.Text += "COMMAND : " + msg.value("command") + "\n";
     ShowCheckOut.Text += "TO : " + msg.value("to") + "\n";
     ShowCheckOut.Text += "FROM : " + msg.value("from") + "\n";
     ShowCheckOut.Text += "FILENAME : " + msg.value("fileinfo") + "\n" + "\n";
     statusBarText.Text = "Recieved CheckOut Msg";
 }
コード例 #7
0
 //-------< Handles the reply msg recieved from Server with Command Connect>-------------
 private void Connectme(CsMessage msg)
 {
     connecttxtbox.Text += "Connection Successful!!\n";
     connecttxtbox.Text += "Message Received \n";
     connecttxtbox.Text += "---------------------- \n";
     connecttxtbox.Text += "COMMAND : " + msg.value("command") + "\n";
     connecttxtbox.Text += "TO : " + msg.value("to") + "\n";
     connecttxtbox.Text += "FROM : " + msg.value("from") + "\n" + "\n";
     statusBarText.Text  = "Recieved Connect Msg";
 }
コード例 #8
0
        //----< start Comm, and demonstrates all requirements >------

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Console.Write("\n This is client");
            Console.Write("\n----------------");
            string[] args = System.Environment.GetCommandLineArgs();
            Console.Write("\n The port of this client is " + args[1]);
            endPoint_ = new CsEndPoint();
            endPoint_.machineAddress = "localhost";
            endPoint_.port           = int.Parse(args[1]);
            translater = new Translater();
            translater.listen(endPoint_);
            processMessages();
            loadDispatcher();

            CsEndPoint serverEndPoint = new CsEndPoint();

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

            PathTextBlock.Text = "Storage";
            pathTextBlock.Text = "Storage";
            pathStack_.Push("../ServerStorage");
            PathStack_.Push("../ServerStorage");
            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("\n\n Requesting the server with Command :" + msg.value("command"));
            translater.postMessage(msg);
            msg.remove("command");

            msg.add("command", "getDirsForCheckin");
            Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
            translater.postMessage(msg);
            msg.remove("command");
            msg.add("command", "getFiles");
            Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
            translater.postMessage(msg);
            msg.remove("command");
            msg.add("command", "getDirsforBrowse");
            msg.remove("path");
            msg.add("path", PathStack_.Peek());
            Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
            translater.postMessage(msg);
            msg.remove("command");
            msg.add("command", "getFilesforBrowse");
            Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
            translater.postMessage(msg);
            //  checkin_and_checkout_and_viewmetadata();
        }
コード例 #9
0
 //----< send show metadata request to the repository >---------------
 private void showMetadata(CsMessage msg)
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("File Name: " + msg.value("name"));
         sb.AppendLine("Description: " + msg.value("description"));
         sb.AppendLine("Date Time: " + msg.value("datetime"));
         sb.AppendLine("Dependency: " + msg.value("dependency"));
         sb.AppendLine("Location at repo: " + msg.value("location"));
         sb.AppendLine("Category: " + msg.value("category"));
         sb.AppendLine("isOpen: " + msg.value("isOpen"));
         sb.AppendLine("Version: " + msg.value("version"));
         Paragraph paragraph = new Paragraph();
         paragraph.Inlines.Add(new Run(sb.ToString()));
         CodePopUpWindow popUp = new CodePopUpWindow();
         popUp.Show();
         popUp.CodeView.Blocks.Clear();
         popUp.CodeView.Blocks.Add(paragraph);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #10
0
        //----< processing message which are received from server >------
        private void processMessages()
        {
            ThreadStart thrdProc = () => {
                while (true)
                {
                    try
                    {
                        CsMessage msg   = translater.getMessage();
                        string    msgId = msg.value("command");
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
コード例 #11
0
        // Process Messages Received
        private void processMessages()
        {
            ThreadStart thrdProc = () => {
                while (true)
                {
                    CsMessage msg = translater.getMessage();
                    if (msg.contain_key("command"))
                    {
                        string msgId = msg.value("command");
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                        else
                        {
                            update_status("Invalid message!");
                        }
                    }
                }
            };

            recv = new Thread(thrdProc);
            recv.IsBackground = true;
            recv.Start();
        }
コード例 #12
0
        //----< 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();
        }
コード例 #13
0
        //----< process incoming messages on child thread >----------------
        private void processMessages()
        {
            ThreadStart thrdProc = () => {
                while (true)
                {
                    try
                    {
                        CsMessage msg   = client.getMessage();
                        string    msgId = msg.value("command");
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
コード例 #14
0
        //----< process incoming messages on child thread >----------------

        private void processMessages()
        {
            Console.Write("\n Starting Receiving Thread for Client\n");


            ThreadStart thrdProc = () => {
                while (true)
                {
                    CsMessage msg = translater.getMessage();
                    try
                    {
                        string msgId = msg.value("command");

                        Console.Write("\n The received msg with command is " + msgId);
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                    }catch (Exception e)
                    {
                        Console.WriteLine("\n The exception is" + e);
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
コード例 #15
0
        /*test end*/
        private void showfile_Click(object sender, RoutedEventArgs e)
        {
            checkinfiles.Items.Clear();
            checkindependency.Items.Clear();

            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("path", "../Storage");
            msg.add("command", "getFiles");
            translater.postMessage(msg);
            DirectoryInfo folder = new DirectoryInfo("../../../../clientstore");

            Console.WriteLine("\n---------------send a message to get the file list,command is getFiles---------------------");
            Console.WriteLine("\n send getFiles message from " + msg.value("from") + " to " + msg.value("to"));

            foreach (FileInfo file in folder.GetFiles("*.*"))
            {
                checkinfiles.Items.Add(file);
            }
        }
コード例 #16
0
 private void modify_Click(object sender, RoutedEventArgs e)
 {
     if (notclosedfiles.SelectedItem != null)
     {
         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", "modify");
         msg.add("operatefile", notclosedfiles.SelectedItem.ToString());
         msg.add("author", authorname.Text);
         msg.add("catagary", catagary.Text);
         msg.add("descript", description.Text);
         int tempc = 0;
         foreach (var item in adddependencies.SelectedItems)
         {
             msg.add("children" + tempc.ToString(), item.ToString());
             tempc++;
         }
         Console.WriteLine("\n---------------send a message to modify metadata,command is modify--------------------");
         Console.WriteLine("\n send modify message from " + msg.value("from") + " to " + msg.value("to"));
         translater.postMessage(msg);
     }
 }
コード例 #17
0
        // ----------< do action for a message >-----------
        private void InterpretReceivedMsgs(CsMessage msg)
        {
            string msgId = msg.value("command");

            if (dispatcher_.ContainsKey(msgId))
            {
                dispatcher_[msgId].Invoke(msg);
            }
        }
コード例 #18
0
 //-------< Handles the reply msg recieved from Server with Command CheckIn>-----------
 private void showCheckMsg(CsMessage msg)
 {
     //ShowCheckInfo.Text += "Message Received \n";
     //ShowCheckInfo.Text += "---------------------- \n";
     //ShowCheckInfo.Text += "COMMAND : " + msg.value("command") + "\n";
     //ShowCheckInfo.Text += "TO : " + msg.value("to") + "\n";
     //ShowCheckInfo.Text += "FROM : " + msg.value("from") + "\n";
     //ShowCheckInfo.Text += "FILENAME : " + msg.value("fileinfo") + "\n" + "\n";
     statusBarText.Text = "CheckIn Successful for " + msg.value("fileinfo");
 }
コード例 #19
0
 private void HandleIncomingRequest(CsMessage message)
 {
     if (message.containsKey("responseId"))
     {
         string uniqueId = message.value("responseId");
         if (dispatcher_.ContainsKey(uniqueId))
         {
             dispatcher_[uniqueId].Invoke(message);
         }
     }
 }
コード例 #20
0
        private void showBrowsemsg(CsMessage msg)
        {
            string keycount = msg.value("keycount");
            int    kc       = Int32.Parse(keycount);

            if (kc == 0)
            {
                ShowBrowse.Text = "No Keys in the Repository match your Query\n";
            }
            else
            {
                ShowBrowse.Text  = "------------------------------------------------------------\n";
                ShowBrowse.Text += "KEYS matching query in repository are :\n";
                for (int i = 0; i < kc; i++)
                {
                    string myString = "key" + (i + 1).ToString();
                    ShowBrowse.Text += msg.value(myString) + "\n";
                }
            }
            statusBarText.Text = "Browse Msg Recieved";
        }
コード例 #21
0
        //----< submit test request >-------------------------------------------

        private void SubmitTestRequestButton_Click(object sender, RoutedEventArgs e)
        {
            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_));
            string testDriverElement = TestDriverListBox.Items[0].ToString();
            int    arraySize         = TestedCodeListBox.Items.Count;

            string[] testedCodeElements = TestedCodeListBox.Items.OfType <string>().ToArray();
            msg.add("command", "Test_Request");
            string str           = CreateTestRequestString(testDriverElement, testedCodeElements);
            string testNumString = testNum.ToString();

            // msg.add("testNumString", testNumString);
            msg.add("name", str);
            translater.postMessage(msg);
            string forStatusListBox = CreateTextBoxStringFromTestRequestInfo(testDriverElement, testedCodeElements);
            string statusMsg        = forStatusListBox + "Awaiting Status Msg";

            //"\nTest Number " + testNum.ToString() + ":\n" +
            updateStatusListBox(statusMsg);
            CsMessage msgIn = translater2.getMessage();

            if (msgIn.value("command") == "Test Status Message")
            {
                msgIn.show();
                string statusReplyMsg =
                    "Test Number:     " + msgIn.value("testRequestID") +
                    "\nStatus:          " + msgIn.value("status") +
                    "\nTime Date Stamp: " + msgIn.value("TimeDateStamp") +
                    "\nTest Log File:   " + msgIn.value("TestLogFileString") + "\n";
                StatusListBox.Items.Add(statusReplyMsg);
            }
            testNum++;
        }
コード例 #22
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]);
                }
            }
        }
コード例 #23
0
        //----< process the received messages >---------------------------

        private void processMessages()
        {
            ThreadStart thrdProc = () =>
            {
                while (true)
                {
                    CsMessage msg = translater.getMessage();
                    if (msg.attributes.Count != 0)
                    {
                        Console.Write("\n\n  received message: " + msg.value("command"));
                        string msgId = msg.value("command");
                        if (dispatcher_.ContainsKey(msgId))
                        {
                            dispatcher_[msgId].Invoke(msg);
                        }
                    }
                }
            };

            rcvThrd = new Thread(thrdProc);
            rcvThrd.IsBackground = true;
            rcvThrd.Start();
        }
コード例 #24
0
        //----< Requests Repository server for connecting >------

        private void connect_to_server_click(object sender, RoutedEventArgs e)
        {
            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", "echo");
            Console.Write("\n\n Requesting the server with Command :" + msg.value("command"));
            translater.postMessage(msg);
        }
コード例 #25
0
        private void checkin_click(object sender, RoutedEventArgs e)
        {
            if (checkinfiles.SelectedItem != null)
            {
                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", "checkin");
                msg.add("parent", "true");
                msg.add("author", author.Text);
                msg.add("description", descrip.Text);
                msg.add("category", cate.Text);
                msg.add("namespace", ns.Text);
                msg.add("file", checkinfiles.SelectedItem.ToString());
                msg.add("sendpath", "../../../../clientstore");
                msg.add("receivepath", "../Storage");
                string abspath = System.IO.Path.GetFullPath("../../../../clientstore");
                Console.WriteLine("\n ----------you click checkin button----------");
                Console.WriteLine("\n send check in message from " + msg.value("from") + " to " + msg.value("to"));
                Console.WriteLine("\n send files from " + msg.value("from") + " to " + msg.value("to"));
                Console.WriteLine("\n send path is " + abspath);
                Console.WriteLine("\n file name is:");
                Console.WriteLine(checkinfiles.SelectedItem.ToString());
                int tempc = 0;
                foreach (var item in checkindependency.SelectedItems)
                {
                    msg.add("children" + tempc.ToString(), item.ToString());
                    tempc++;
                }
                translater.postMessage(msg);
            }

            showfilesnotclosed_Click(null, null);
        }
コード例 #26
0
 // Update test result
 private void handle_result(CsMessage msg)
 {
     new Thread(() =>
     {
         this.Dispatcher.Invoke(new Action(() =>
         {
             //Display test results in GUI
             string result_info = "";
             result_info        = "Name: ";
             if (msg.contain_key("name"))
             {
                 result_info += msg.value("name");
             }
             result_info += "\nAuthor: ";
             if (msg.contain_key("author"))
             {
                 result_info += msg.value("author");
             }
             result_info += "\nTime: ";
             if (msg.contain_key("time"))
             {
                 result_info += msg.value("time");
             }
             result_info += "\nLibrary: ";
             if (msg.contain_key("dll"))
             {
                 result_info += msg.value("dll");
             }
             result_info += "\nResult: ";
             if (msg.contain_key("result"))
             {
                 result_info += msg.value("result");
             }
             result.Items.Add(result_info);
         }));
     }).Start();
 }
コード例 #27
0
        //----< Requests server for check-in, check-out and viewing meta data  >------

        private void checkin_and_checkout_and_viewmetadata()
        {
            //checkout
            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", "checkout");
            msg.add("filename", "Comm.h");
            msg.add("receivePath", "../../../../ClientStorage");
            Console.Write("\n\n Requesting the server with Command :" + msg.value("command") + " for the file " + msg.value("filename"));
            translater.postMessage(msg);


            //checkin
            CsMessage msg1 = new CsMessage();

            msg1.add("to", CsEndPoint.toString(serverEndPoint));
            msg1.add("from", CsEndPoint.toString(endPoint_));
            msg1.add("command", "checkin");
            msg1.add("file", "IComm.h");
            msg1.add("name", "checkin");
            msg1.add("sendPath", "../../../../ClientStorage");
            Console.Write("\n\n Requesting the server with Command :" + msg1.value("command") + " for the file " + msg1.value("file"));
            translater.postMessage(msg1);

            //viewmetadata
            CsMessage msg2 = new CsMessage();

            msg2.add("to", CsEndPoint.toString(serverEndPoint));
            msg2.add("from", CsEndPoint.toString(endPoint_));
            msg2.add("command", "viewmetadata");
            msg2.add("name", "DbCore.h");
            msg2.add("description", "Implements NoSql database");
            msg2.add("dateTime", DateTime.Now.ToString());
            msg2.add("Children", "PayLoad.h , PayLoad.cpp");
            msg2.add("Categories", "NoSqlDb , DbCOre");
            Console.Write("\n\n Requesting the server with Command :" + msg2.value("command") + " for the file " + msg2.value("name"));
            translater.postMessage(msg2);
            String file = "../../../../ClientStorage/Comm.h";

            System.Threading.Thread.Sleep(1000);

            viewSelectedFile(file);
        }
コード例 #28
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]);
                }
            }
        }
コード例 #29
0
 private void checkout_Click(object sender, RoutedEventArgs e)
 {
     Console.WriteLine("\n -----------------you click the check out button--------------------------");
     if (checkoutfiles.SelectedItem != null)
     {
         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("requestfile", checkoutfiles.SelectedItem.ToString());//checkoutfiles.SelectedItem.ToString()
         msg.add("command", "checkout");
         Console.WriteLine("\n send check out message from " + msg.value("from") + " to " + msg.value("to"));
         Console.WriteLine("\n download file from " + msg.value("to") + " to " + msg.value("from"));
         Console.WriteLine("\n file name is:");
         Console.WriteLine(checkoutfiles.SelectedItem.ToString());
         translater.postMessage(msg);
     }
     else
     {
         return;
     }
 }
コード例 #30
0
        private void viewfiles_Click(object sender, RoutedEventArgs e)
        {
            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("path", "../Storage");
            msg.add("command", "getFiles");
            Console.WriteLine("\n---------------send a message to get the file list,command is getFiles---------------------");
            Console.WriteLine("\n send getFiles message from " + msg.value("from") + " to " + msg.value("to"));
            translater.postMessage(msg);
        }