示例#1
0
        public string GetLatestJournalFile()
        {
            try
            {
                string journalDir = String.Empty;
                _dt       = new DataTable();
                _appSetTa = new AppSettingsTableAdapter();
                _dt       = _appSetTa.GetData();
                string path = null;
                foreach (DataRow row in _dt.Rows)
                {
                    path = row["JournalPath"].ToString();
                }

                string pattern = "*.txt";
                if (path != String.Empty || path != null || path != "")
                {
                    journalDir = path;
                }
                var dirInfo = new DirectoryInfo(journalDir);
                var file    = (from f in dirInfo.GetFiles(pattern)
                               orderby f.LastWriteTime descending
                               select f)
                              .First();
                return(file.FullName);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Read journal path err : " + ex.Message);
            }
            return(null);
        }
示例#2
0
        static DataTable GetTerminalParams()
        {
            try
            {
                _dt       = new DataTable();
                _appSetTa = new AppSettingsTableAdapter();
                _dt       = _appSetTa.GetData();
                int c = _dt.Rows.Count;
                if (c > 0)
                {
                    return(_dt);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("GetTerminalParams err : " + ex.Message);
            }

            return(null);
        }
示例#3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Validate())
            {
                TerminalProvision pv = new TerminalProvision();
                pv.TerminalId    = txbtid.Text.ToUpper();
                pv.Address       = txbuseraddress.Text;
                pv.AliasName     = txbalias.Text.ToUpper();
                pv.CustodianName = txbusername.Text.ToUpper();
                pv.Email         = txbuseremail.Text.ToUpper();
                pv.ImagePath     = imgpath.Text;
                pv.JournalPath   = jppath.Text;
                pv.Location      = txbloc.Text.ToUpper();
                pv.Name          = txbbank.Text.ToUpper();
                pv.HeartBeat     = int.Parse(txbheartbeat.Text);
                pv.Phone         = txbuserphone.Text;
                pv.RemoteIp      = txbsip.Text;
                pv.Id            = id;
                pv.TerminalType  = cmbtmodel.SelectedItem.ToString();
                pv.TerminalIp    = txbtip.Text;
                pv.TerminalPort  = int.Parse(txbport.Text);

                //send to server
                //serialize object
                string objStr = SerializeObject(pv);
                bool   s      = SetupClientSocket.SendMessage(4, objStr);

                if (s)
                {
                    _appConfTa = new AppSettingsTableAdapter();
                    _dt        = new DataTable();
                    _dt        = _appConfTa.GetData();
                    int rId = 0;
                    if (_dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < _dt.Rows.Count; i++)
                        {
                            rId = Convert.ToInt32(_dt.Rows[i][0]);
                        }
                        int a = _appConfTa.UpdateQuery(
                            pv.TerminalId,
                            pv.TerminalType,
                            pv.TerminalIp,
                            pv.RemoteIp,
                            pv.TerminalPort.ToString(),
                            pv.ImagePath,
                            pv.CurrentFile,
                            pv.CustodianName,
                            pv.Phone,
                            pv.Email,
                            pv.Address,
                            pv.JournalPath,
                            pv.Name, pv.AliasName, pv.Location, pv.HeartBeat,
                            rId
                            );
                        if (a > 0)
                        {
                            MessageBox.Show(@"Settings Modified");
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(@"Settings Modification failed");
                        }
                    }
                    else
                    {
                        _appConfTa = new AppSettingsTableAdapter();
                        int a = _appConfTa.Insert(
                            pv.TerminalId,
                            pv.TerminalType,
                            pv.TerminalIp,
                            pv.RemoteIp,
                            pv.TerminalPort.ToString(),
                            pv.ImagePath,
                            pv.CurrentFile,
                            pv.CustodianName,
                            pv.Phone,
                            pv.Email,
                            pv.Address,
                            pv.JournalPath,
                            pv.Name, pv.AliasName, pv.Location, pv.HeartBeat
                            );
                        if (a > 0)
                        {
                            MessageBox.Show(@"Settings Created");
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(@"Settings Create failed");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Required fields are missing");
            }
        }