Esempio n. 1
0
        private void SaveToCacheRs(string Key, string FullPathToSave)
        {
            CreateCacheFolder();

            string FullPathCache = GetFullPathCacheRs(Key);

            if (!File.Exists(FullPathCache))
            {
                CreateRs(FullPathCache, false);
            }

            Recordset Rs = new Recordset();

            Rs.Open(FullPathCache, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1);

            string Criteria = "Key = '" + Key.Replace("'", "''") + "'";

            Rs.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value);

            if (!Rs.EOF)
            {
                Rs.Fields["Content"].AppendChunk(CFile.GetByteFromFile(FullPathToSave));
            }
            else
            {
                Rs.AddNew(Missing.Value, Missing.Value);
                Rs.Fields["Key"].Value = Key;
                Rs.Fields["Content"].AppendChunk(CFile.GetByteFromFile(FullPathToSave));
            }

            Rs.Save(FullPathCache, PersistFormatEnum.adPersistXML);
            Rs.Close();
            Rs = null;
        }
Esempio n. 2
0
        private string GetFullPathCacheContent(string Key)
        {
            if (string.IsNullOrEmpty(this.mCacheFolder))
            {
                throw new Exception("CacheFolder 값이 없습니다");
            }

            string FullPathTemp = "";

            if (this.mUseAdo)
            {
                string FullPathCache = GetFullPathCacheRs(Key);
                //Remove 메쏘드로 삭제하다 더 이상 행이 없으면 파일 자체가 삭제됨
                if (!File.Exists(FullPathCache))
                {
                    return("");
                }

                Recordset Rs = new Recordset();
                Rs.Open(FullPathCache, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1);

                string Criteria = "Key = '" + Key.Replace("'", "''") + "'";
                Rs.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value);
                if (Rs.EOF)
                {
                    Rs.Close();
                    return("");
                }

                FullPathTemp = CFile.GetTempFileName();
                CAdo.GetFileFromField(Rs.Fields["Content"], FullPathTemp);
            }
            else
            {
                string FullPathCache = GetFullPathCacheDt(Key);
                //Remove 메쏘드로 삭제하다 더 이상 행이 없으면 파일 자체가 삭제됨
                if (!File.Exists(FullPathCache))
                {
                    return("");
                }

                DataTable dt = new DataTable();
                dt.ReadXml(FullPathCache);

                string    Criteria = "Key = '" + Key.Replace("'", "''") + "'";
                DataRow[] adr      = dt.Select(Criteria);
                if (adr.Length == 0)
                {
                    dt = null;
                    return("");
                }
                DataRow dr = adr[0];

                FullPathTemp = CFile.GetTempFileName();
                CFile.WriteByteToFile(FullPathTemp, (byte[])dr["Content"]);
            }

            return(FullPathTemp);
        }
Esempio n. 3
0
        private void cmbParameters_SelectedIndexChanged(object eventSender, EventArgs eventArgs)
        {
            Recordset recordset = new RecordsetClass();

            if (Strings.Len(this.cmbParameters.Text) != 0)
            {
                Recordset recordset2 = recordset;
                recordset2.Open("select * from ParameterInfo", this.frmMain.DatabaseConnection, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockPessimistic, -1);
                recordset2.Find("ParameterName='" + this.cmbParameters.Text + "'", 0, SearchDirectionEnum.adSearchForward, Missing.Value);
                if (Operators.ConditionalCompareObjectEqual(recordset2[]["Length"][], (short)60, false))
Esempio n. 4
0
        private string GetFullPathCacheRs(string Key)
        {
            string FullPathIndex = mCacheFolder + "\\CacheIndex.rs";

            if (!File.Exists(FullPathIndex))
            {
                CreateRs(FullPathIndex, true);
            }

            Recordset RsIndex = new Recordset();

            RsIndex.Open(FullPathIndex, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1);

            string FileName = "";
            int    Seq      = 0;

            string Criteria = "Key = '" + Key.Replace("'", "''") + "'";

            RsIndex.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value);
            if (!RsIndex.EOF)
            {
                FileName = (string)RsIndex.Fields["FileName"].Value;
            }
            else
            {
                if (RsIndex.RecordCount > 0)
                {
                    RsIndex.MoveLast();

                    Seq = ((int)RsIndex.Fields["Seq"].Value + 1);

                    FileName = (string)RsIndex.Fields["FileName"].Value;
                    if (((Seq - 1) % drUnitForFile100) == 0)
                    {
                        FileName = GetNextFileName(FileName);
                    }
                }
                else
                {
                    Seq      = 1;
                    FileName = "Cache.rs";
                }

                RsIndex.AddNew(Missing.Value, Missing.Value);
                RsIndex.Fields["Seq"].Value      = Seq;
                RsIndex.Fields["Key"].Value      = Key;
                RsIndex.Fields["FileName"].Value = FileName;

                RsIndex.Save(FullPathIndex, PersistFormatEnum.adPersistXML);
                RsIndex.Close();
                RsIndex = null;
            }

            return(mCacheFolder + "\\" + FileName);
        }
Esempio n. 5
0
        public void Remove(string Key)
        {
            string Criteria = "Key = '" + Key.Replace("'", "''") + "'";

            if (mUseAdo)
            {
                string FullPathIndex = mCacheFolder + "\\CacheIndex.rs";
                if (!File.Exists(FullPathIndex))
                {
                    throw new Exception(FullPathIndex + " 파일이 없습니다.");
                }

                Recordset RsIndex = new Recordset();
                RsIndex.Open(FullPathIndex, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1);

                RsIndex.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value);
                if (RsIndex.EOF)
                {
                    throw new Exception(Criteria + " 조건에 해당하는 행이 " + FullPathIndex + " 파일에 없습니다.");
                }

                string FileName      = (string)RsIndex.Fields["FileName"].Value;
                string FullPathCache = mCacheFolder + "\\" + FileName;


                Recordset rs = new Recordset();
                rs.Open(FullPathCache, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockPessimistic, -1);

                rs.Find(Criteria, 0, SearchDirectionEnum.adSearchForward, Missing.Value);
                if (rs.EOF)
                {
                    throw new Exception(Criteria + " 조건에 해당하는 행이 " + FullPathCache + " 파일에 없습니다.");
                }

                rs.Delete(AffectEnum.adAffectCurrent);
                if (rs.RecordCount > 0)
                {
                    rs.Save(FullPathCache, PersistFormatEnum.adPersistXML);
                    rs.Close();
                }
                else
                {
                    rs.Close();
                    File.Delete(FullPathCache);
                }
                rs = null;

                RsIndex.Delete(AffectEnum.adAffectCurrent);
                RsIndex.Save(FullPathIndex, PersistFormatEnum.adPersistXML);
                RsIndex.Close();
                RsIndex = null;
            }
            else
            {
                string FullPathIndex = mCacheFolder + "\\CacheIndex.dt";
                if (!File.Exists(FullPathIndex))
                {
                    throw new Exception(FullPathIndex + " 파일이 없습니다.");
                }

                DataTable DtIndex = new DataTable();
                DtIndex.ReadXml(FullPathIndex);

                DataRow[] adrIndex = DtIndex.Select(Criteria);
                if (adrIndex.Length == 0)
                {
                    throw new Exception(Criteria + " 조건에 해당하는 행이 " + FullPathIndex + " 파일에 없습니다.");
                }

                string FileName      = (string)adrIndex[0]["FileName"];
                string FullPathCache = mCacheFolder + "\\" + FileName;


                DataTable dt = new DataTable();
                dt.ReadXml(FullPathCache);

                DataRow[] adrCache = dt.Select(Criteria);
                if (adrCache.Length == 0)
                {
                    throw new Exception(Criteria + " 조건에 해당하는 행이 " + FullPathCache + " 파일에 없습니다.");
                }

                dt.Rows.Remove(adrCache[0]);
                if (dt.Rows.Count > 0)
                {
                    dt.WriteXml(FullPathCache, XmlWriteMode.WriteSchema);
                }
                else
                {
                    File.Delete(FullPathCache);
                }

                DtIndex.Rows.Remove(adrIndex[0]);
                DtIndex.WriteXml(FullPathIndex, XmlWriteMode.WriteSchema);
            }
        }