Exemplo n.º 1
0
    override protected void DoCreate()
    {
        if (Nest.buffers == null)
        {
            throw new Exception("buffers == null");
        }
        this.buffers = Nest.buffers;

        buffers.frame = this;
        buffers.list.SelectedChange += OnTabSelected;

        tabBar                    = new TabBar <Buffer>(buffers.list, Buffer.StringOf);
        tabBar.CloseClick        += OnCloseClick;
        tabBar.TabDoubleClick    += OnTabDoubleClick;
        tabBar.NewTabDoubleClick += OnNewTabDoubleClick;
        Controls.Add(tabBar);

        splitLine = new SplitLine();
        Controls.Add(splitLine);

        KeyMap frameKeyMap = new KeyMap();

        frameKeyMap.AddItem(new KeyItem(Keys.Tab, Keys.Control, new KeyAction("&View\\Switch tab", DoTabDown, DoTabModeChange, false)));
        {
            KeyAction action = new KeyAction("&View\\Close tab", DoCloseTab, null, false);
            frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.W, null, action));
            frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F4, null, action));
        }
        frameKeyMap.AddItem(new KeyItem(Keys.Tab, null,
                                        new KeyAction("&Edit\\Snippets\\Apply snippet", Snippets_DoApply, null, false)));
        frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.Tab, null,
                                        new KeyAction("&Edit\\Snippets\\Autocomplete snippet", Snippets_DoAutocomplete, null, false)));

        textBox             = new MulticaretTextBox();
        textBox.ViShortcut += OnViShortcut;
        textBox.KeyMap.AddAfter(KeyMap);
        textBox.KeyMap.AddAfter(frameKeyMap);
        textBox.KeyMap.AddAfter(DoNothingKeyMap, -1);
        textBox.FocusedChange += OnTextBoxFocusedChange;
        textBox.Controller     = GetEmptyController();
        Controls.Add(textBox);

        InitResizing(tabBar, splitLine);
        tabBar.MouseDown += OnTabBarMouseDown;
        OnTabSelected();
    }
Exemplo n.º 2
0
        private async Task <AuthenticationResult> SendAuthCommand(string command)
        {
            AuthenticationResult result = default(AuthenticationResult);

            await WriteLineAsync(command).ConfigureAwait(false);

            SplitLine reply = await ReadLineAsync().ConfigureAwait(false);

            if (reply[0] == "OK")
            {
                result.IsAuthenticated = true;
                result.Guid            = reply[1] != string.Empty ? Guid.ParseExact(reply[1], "N") : Guid.Empty;

                if (_socket.SupportsFdPassing)
                {
                    await WriteLineAsync("NEGOTIATE_UNIX_FD").ConfigureAwait(false);

                    reply = await ReadLineAsync().ConfigureAwait(false);

                    result.SupportsFdPassing = reply[0] == "AGREE_UNIX_FD";
                }

                await WriteLineAsync("BEGIN").ConfigureAwait(false);

                return(result);
            }
            else if (reply[0] == "REJECTED")
            {
                return(result);
            }
            else
            {
                await WriteLineAsync("ERROR").ConfigureAwait(false);

                return(result);
            }
        }
Exemplo n.º 3
0
 public SplitLine SplitLine()
 {
     splitLine = new SplitLine();
     return(splitLine);
 }
Exemplo n.º 4
0
    private SplitLine ParseLine(string Line)
    {
        SplitLine sl = new SplitLine();

        sl.Valid = false;
        Regex rx;
        Match m;

        // is it dos format?
        rx = new Regex(@"(?<Date>[0-9|-]{8})\s*(?<Time>[0-9|:|AM|PM]*)\s*(?<Size>[0-9"
                       + @"|\<|\>|DIR]*)\s*(?<Name>.*)\r", RegexOptions.IgnoreCase);

        m = rx.Match(Line);
        if (m.Success)
        {
            sl.Valid = true;
            if (m.Groups["Size"].Value == "<DIR>")
            {
                sl.Dir      = true;
                sl.FileSize = 0;
            }
            else
            {
                sl.Dir      = false;
                sl.FileSize = Convert.ToInt32(m.Groups["Size"].Value);
            }
            sl.FileName = m.Groups["Name"].Value;
            sl.FileDate = m.Groups["Date"].Value;
            sl.FileTime = m.Groups["Time"].Value;
        }
        else
        {
            // is it unix format?
            rx = new Regex(@"(?<Dir>.{1}).{9}\s*[0-9]*\s*\w*\s*\w*\s*(?<Size>[0-9]*)\s*(?"
                           + @"<Month>[a-z|A-Z]{3})\s*(?<Day>[0-9]*)\s*(?<Time>[0-9|:]*)\s*("
                           + @"?<Name>.*)\r", RegexOptions.None);

            m = rx.Match(Line);
            if (m.Success)
            {
                sl.Valid = true;
                if (m.Groups["Dir"].Value == "d")
                {
                    sl.Dir = true;
                }
                else
                {
                    sl.Dir = false;
                }
                sl.FileSize = Convert.ToInt32(m.Groups["Size"].Value);
                sl.FileName = m.Groups["Name"].Value;

                if (m.Groups["Time"].Value.IndexOf(':') == -1)
                {
                    sl.FileDate = m.Groups["Day"].Value + " " + m.Groups["Month"].Value + " " + m.Groups["Time"].Value;
                    sl.FileTime = "";
                }
                else
                {
                    sl.FileDate = m.Groups["Day"].Value + " " + m.Groups["Month"].Value + " " + DateTime.Now.Year.ToString();
                    sl.FileTime = m.Groups["Time"].Value;
                }
            }
        }

        return(sl);
    }
Exemplo n.º 5
0
    /// Return a list of files & Directories from the file system.
    public void GetDirList(DirList dl)
    {
        Socket cSocket;
        int    bytes;
        char   seperator = Convert.ToChar("\n");

        string[] mess;

        m_sMes = "";

        /// Check to see if you are logged on to the FTP server.

        if (!m_bLoggedIn)
        {
            Login();
        }

        cSocket = CreateDataSocket();
        /// Send an FTP command.
        SendCommand("LIST -AL");

        if (!(m_iRetValue == 150 || m_iRetValue == 125))
        {
            MessageString = m_sReply;
            throw new IOException(m_sReply.Substring(4));
        }

        m_sMes = "";

        while (true)
        {
            Array.Clear(m_aBuffer, 0, m_aBuffer.Length);
            bytes   = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0);
            m_sMes += ASCII.GetString(m_aBuffer, 0, bytes);

            if (bytes < m_aBuffer.Length)
            {
                break;
            }
            System.Threading.Thread.Sleep(10);
        }

        mess = m_sMes.Split(seperator);
        cSocket.Close();
        ReadReply();

        if (m_iRetValue != 226)
        {
            MessageString = m_sReply;
            throw new IOException(m_sReply.Substring(4));
        }

        if (mess.Length > 0)
        {
            foreach (string tmpstr in mess)
            {
                if (tmpstr != "")
                {
                    DirFile lf;

                    SplitLine sl = ParseLine(tmpstr);

                    if (sl.Valid)
                    {
                        if (sl.Dir)
                        {
                            lf = new DirFile(sl.FileName, sl.FileDate, sl.FileTime, true, 0);
                        }
                        else
                        {
                            lf = new DirFile(sl.FileName, sl.FileDate, sl.FileTime, false, sl.FileSize);
                        }
                        dl.Add(lf);
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
        public DataTable GetDataCSV196(string ruta196)
        {
            try
            {
                String    LineaTexto = String.Empty;
                String    nombre_archivo196;
                DataTable dtReporte196 = new DataTable("Reporte196");

                dtReporte196.Columns.Add("Unidad de Negocio", typeof(String));
                dtReporte196.Columns.Add("Fecha", typeof(DateTime));
                dtReporte196.Columns.Add("PPU", typeof(String));
                dtReporte196.Columns.Add("Tipo de GPS", typeof(String));
                dtReporte196.Columns.Add("Servicio", typeof(String));
                dtReporte196.Columns.Add("Sentido", typeof(String));
                dtReporte196.Columns.Add("Intervalo", typeof(String));
                dtReporte196.Columns.Add("Operativo", typeof(String));
                dtReporte196.Columns.Add("KM Intervalo", typeof(Double));
                dtReporte196.Columns.Add("KM del viaje en intervalo", typeof(Double));
                dtReporte196.Columns.Add("Fecha Inicio Viaje", typeof(DateTime));
                dtReporte196.Columns.Add("Fecha Fin Viaje", typeof(DateTime));
                dtReporte196.Columns.Add("Tiempo de este viaje", typeof(Double));
                dtReporte196.Columns.Add("Tiempo total de viaje del intervalo", typeof(Double));
                dtReporte196.Columns.Add("Tiempo de Viaje", typeof(String));
                dtReporte196.Columns.Add("Inicio y Fin de Ruta", typeof(String));
                dtReporte196.Columns.Add("120 Minutos Antes", typeof(String));
                dtReporte196.Columns.Add("120 Minutos Despues", typeof(String));
                dtReporte196.Columns.Add("PC cada 2 Km", typeof(String));
                dtReporte196.Columns.Add("Igual Servicio", typeof(String));

                String[] SplitLine;;
                Int32    intContador = 0;
                nombre_archivo196 = System.IO.Path.GetFileName(ruta196);

                label1.Text = nombre_archivo196;

                if (System.IO.File.Exists(ruta196) == true)
                {
                    Int32 contColumnas = 0;
                    var   objReader    = new System.IO.StreamReader(ruta196);
                    while (objReader.Peek() != -1)
                    {
                        LineaTexto   = objReader.ReadLine();
                        SplitLine    = LineaTexto.Split(';');
                        contColumnas = SplitLine.Count();

                        if (intContador > 7)
                        {
                            Dictionary <String, String> diccionario = new Dictionary <string, string>();
                            diccionario.Add("I", "Ida");
                            diccionario.Add("IDA", "Ida");
                            diccionario.Add("R", "Ret");
                            diccionario.Add("RETORNO", "Ret");
                            diccionario.Add("REGRESO", "Ret");

                            String unidad_negocio  = SplitLine[0].Trim();
                            String PPU             = SplitLine[2].Trim();
                            String GPS             = SplitLine[3].Trim();
                            String Servicio        = SplitLine[4].Replace(" ", "").ToUpper();
                            String Sentido         = SplitLine[5].Trim().ToUpper();
                            String Intervalo       = SplitLine[6].Trim();
                            String Operativo       = SplitLine[7].Trim();
                            String tiempos_viaje   = SplitLine[14];
                            String Inicio_fin_ruta = SplitLine[15];
                            String min_120_antes   = SplitLine[16];
                            String min_120_despues = SplitLine[17];
                            String pc_cada2km      = SplitLine[18];
                            String igual_servicio  = SplitLine[19];

                            ///Creamos las filas en el DataTable

                            DataRow NuevaFila = dtReporte196.NewRow();

                            NuevaFila[0] = unidad_negocio;

                            if (IsDate(SplitLine[1]))
                            {
                                NuevaFila[1] = Convert.ToDateTime(SplitLine[1]);
                            }

                            NuevaFila[2] = PPU;
                            NuevaFila[3] = GPS;

                            NuevaFila[4] = Servicio;

                            NuevaFila[5] = Sentido;
                            NuevaFila[6] = Intervalo;
                            NuevaFila[7] = Operativo;

                            if (IsNumeric(SplitLine[8]))
                            {
                                NuevaFila[8] = SplitLine[8];
                            }

                            if (IsNumeric(SplitLine[9]))
                            {
                                NuevaFila[9] = SplitLine[9];
                            }

                            if (IsDate(SplitLine[10]))
                            {
                                NuevaFila[10] = Convert.ToDateTime(SplitLine[10]);
                            }

                            if (IsDate(SplitLine[11]))
                            {
                                NuevaFila[11] = Convert.ToDateTime(SplitLine[11]);
                            }

                            if (IsNumeric(SplitLine[12]))
                            {
                                NuevaFila[12] = SplitLine[12];
                            }

                            if (IsNumeric(SplitLine[13]))
                            {
                                NuevaFila[13] = SplitLine[13];
                            }

                            NuevaFila[14] = tiempos_viaje;
                            NuevaFila[15] = Inicio_fin_ruta;
                            NuevaFila[16] = min_120_antes;
                            NuevaFila[17] = min_120_despues;
                            NuevaFila[18] = pc_cada2km;
                            NuevaFila[19] = igual_servicio;

                            dtReporte196.Rows.Add(NuevaFila);
                        }
                        intContador = intContador + 1;
                    }
                    objReader.Close();
                }
                else
                {
                    MessageBox.Show("No Existe el Archivo");
                }
                return(dtReporte196);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
        }
Exemplo n.º 7
0
    private SplitLine ParseLine(string Line)
    {
        SplitLine sl = new SplitLine();
        sl.Valid = false;
        Regex rx;
        Match m;

        // is it dos format?
        rx = new Regex(@"(?<Date>[0-9|-]{8})\s*(?<Time>[0-9|:|AM|PM]*)\s*(?<Size>[0-9"
            + @"|\<|\>|DIR]*)\s*(?<Name>.*)\r", RegexOptions.IgnoreCase);

        m = rx.Match(Line);
        if (m.Success)
        {
            sl.Valid = true;
            if (m.Groups["Size"].Value == "<DIR>")
            {
                sl.Dir = true;
                sl.FileSize = 0;
            }
            else
            {
                sl.Dir = false;
                sl.FileSize = Convert.ToInt32(m.Groups["Size"].Value);
            }
            sl.FileName = m.Groups["Name"].Value;
            sl.FileDate = m.Groups["Date"].Value;
            sl.FileTime = m.Groups["Time"].Value;
        }
        else
        {
            // is it unix format?
            rx = new Regex(@"(?<Dir>.{1}).{9}\s*[0-9]*\s*\w*\s*\w*\s*(?<Size>[0-9]*)\s*(?"
                + @"<Month>[a-z|A-Z]{3})\s*(?<Day>[0-9]*)\s*(?<Time>[0-9|:]*)\s*("
                + @"?<Name>.*)\r", RegexOptions.None);

            m = rx.Match(Line);
            if (m.Success)
            {
                sl.Valid = true;
                if (m.Groups["Dir"].Value == "d")
                {
                    sl.Dir = true;
                }
                else
                {
                    sl.Dir = false;
                }
                sl.FileSize = Convert.ToInt32(m.Groups["Size"].Value);
                sl.FileName = m.Groups["Name"].Value;

                if (m.Groups["Time"].Value.IndexOf(':') == -1)
                {
                    sl.FileDate = m.Groups["Day"].Value + " " + m.Groups["Month"].Value + " " + m.Groups["Time"].Value;
                    sl.FileTime = "";
                }
                else
                {
                    sl.FileDate = m.Groups["Day"].Value + " " + m.Groups["Month"].Value + " " + DateTime.Now.Year.ToString();
                    sl.FileTime = m.Groups["Time"].Value;
                }
            }
        }

        return sl;
    }