コード例 #1
0
        public void StatoscopeForm_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[]          droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, false) as string[];
                FileSessionInfo[] sessions         = new FileSessionInfo[droppedFilePaths.Length];

                for (int i = 0; i < droppedFilePaths.Length; i++)
                {
                    sessions[i] = new FileSessionInfo(droppedFilePaths[i]);
                }

                ProcessLogLoadRequest(sessions);
            }
            else if (e.Data.GetDataPresent(DataFormats.Text))
            {
                OpenLog(e.Data.GetData(DataFormats.Text) as string);
            }
        }
コード例 #2
0
        public void OpenLog(string logURI)
        {
            if (logURI == "")
            {
                return;
            }

            string          tempFile      = "";
            string          ssProtocolStr = "statoscope://";
            FileSessionInfo session;

            try
            {
                if (logURI.StartsWith(ssProtocolStr))
                {
                    Dictionary <string, string> args = null;
                    string argsString = logURI.Substring(ssProtocolStr.Length);                         // remove statoscope://
                    string sourceLocation;
                    string localFile = "";

                    if (argsString.Contains('='))
                    {
                        // argsString = "logFile=statoscope.bin&platform=ps3" -> args = { logFile: statoscope.bin, platform: ps3 }
                        args           = argsString.Split('&').ToDictionary(s => s.Split('=')[0], s => s.Split('=')[1]);
                        sourceLocation = args["logFile"];
                    }
                    else
                    {
                        // support for the old format
                        sourceLocation = argsString;
                    }


                    DialogResult result = DialogResult.No;                     // MessageBox.Show("Download request for:\n\n" + sourceLocation + "\n\nWould you like to save a local copy?", "Save downloaded log", MessageBoxButtons.YesNoCancel);

                    switch (result)
                    {
                    case DialogResult.Cancel:
                        return;

                    case DialogResult.Yes:
                        SaveFileDialog fd = new SaveFileDialog();
                        fd.CheckFileExists = false;
                        fd.FileName        = "statoscope.bin";
                        fd.Filter          = "Binary log files (*.bin)|*.bin|All files (*.*)|*.*";
                        fd.FilterIndex     = 0;

                        if (fd.ShowDialog() == DialogResult.OK)
                        {
                            localFile = fd.FileName;
                        }

                        break;
                    }

                    if (localFile == "")
                    {
                        tempFile  = Path.GetTempFileName();
                        localFile = tempFile;
                    }

                    if (localFile == "")
                    {
                        return;
                    }

                    LogDownload.DownloadFile(sourceLocation, localFile);

                    if (args != null)
                    {
                        session = new TelemetrySessionInfo(localFile, sourceLocation, args["peerName"], args["platform"], args["peerType"]);
                    }
                    else
                    {
                        session = new FileSessionInfo(localFile);
                    }
                }
                else
                {
                    session = new FileSessionInfo(logURI);
                }

                ProcessLogLoadRequest(new FileSessionInfo[] { session });
            }
            finally
            {
                if (tempFile != "")
                {
                    File.Delete(tempFile);
                }
            }
        }
コード例 #3
0
 public FileLogProcessor(FileSessionInfo sessionInfo)
 {
     SessionInfo = sessionInfo;
 }