コード例 #1
0
ファイル: Cini.cs プロジェクト: scskarsper/CodeCRAs
        public string[] SectionValuesNew(string section)
        {
            string buffer = new string('\0', 32768);
            int    nlen   = getSectionValues(section, buffer, 32768, m_Path) - 1;

            if (nlen > 0)
            {
                string       RT  = buffer.Substring(0, nlen).Replace("\0", "\r\n");
                FileStream   fs  = new FileStream(m_Path, FileMode.Open);
                StreamReader SR1 = new StreamReader(fs, true);
                string       RL  = SR1.ReadToEnd();
                if (true || RL.IndexOf(RT) == -1)
                {
                    fs.Seek(0, SeekOrigin.Begin);
                    //SR1.Close();
                    SR1 = new StreamReader(fs, Encoding.GetEncoding("Shift-JIS"), true);
                    RL  = SR1.ReadToEnd();
                }

                SR1.Close();
                fs.Close();

                if (RL.IndexOf(RT) == -1)
                {
                    return(null);
                }
                else
                {
                    int    Index = RL.IndexOf(RT);
                    string T1    = RL.Substring(Index);
                    string T2    = T1.Split('[')[0];
                    return(T2.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            else
            {
                return(null);
            }
            return(SectionValues(section, 32768));
        }
コード例 #2
0
        /// <summary>
        /// Get a Dropped Domain Name from the DropList table
        /// </summary>
        public string GetDDN()
        {
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = Properties.Settings.Default.ConnStr;
                conn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "SELECT TOP 1 dropSeqno, drplDomain FROM DropList Where drplFlag = 'false' and drplSuffix = 'com'";
                cmd.Connection  = conn;
                string        DDN;
                Int16         seqno;
                SqlDataReader SR1;
                try
                {
                    SR1 = cmd.ExecuteReader();
                    SR1.Read();
                    DDN   = SR1["drplDomain"].ToString();
                    seqno = Convert.ToInt16(SR1["dropSeqno"]);
                    SR1.Close();
                }
                catch (Exception e1)
                {
                    ErrLogRec ErrLog = new ErrLogRec();
                    bool      lb_rtn = ErrLog.Insert("LinkRaker.GetDDN", e1);
                    return(null);
                }


                cmd.CommandText = "UPDATE DropList SET drplFlag = 'true' WHERE dropSeqno = @drplSeqno";
                cmd.Parameters.AddWithValue("@drplSeqno", seqno);
                int rtn = cmd.ExecuteNonQuery();
                if (dnRec == null)
                {
                    dnRec = new dnengMainRecord(DDN);
                }
                return(DDN);
            }
        }