Пример #1
0
 public override void GoToPosition(long position)
 {
     try
     {
         if (position < 0)
         {
             throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.NegativePosition
                                                        .AddParameter(position));
         }
         fileWriter.Seek(position);
     }
     catch (System.IO.IOException e)
     {
         long l = -1;
         try
         {
             l = fileWriter.Length();
         }
         catch (System.IO.IOException)
         {
         }
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.GoToPosition
                                                    .AddParameter(position).AddParameter(l), e);
     }
 }
Пример #2
0
        private void Init(string fileName, bool canWrite)
        {
            string dataDirectory = NeoDatis.Tool.Wrappers.OdbSystem.GetProperty("data.directory"
                                                                                );

            if (dataDirectory != null)
            {
                wholeFileName = dataDirectory + "/" + fileName;
            }
            else
            {
                wholeFileName = fileName;
            }
            try
            {
                if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
                {
                    NeoDatis.Tool.DLogger.Info("Opening datatbase file : " + new NeoDatis.Tool.Wrappers.IO.OdbFile
                                                   (wholeFileName).GetFullPath());
                }
                fileWriter = BuildFileWriter(canWrite);
                SetIoDeviceLength(fileWriter.Length());
            }
            catch (System.Exception e)
            {
                //fixme
                new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
                                                     , e);
            }
            if (canWrite)
            {
                try
                {
                    fileWriter.LockFile();
                }
                catch (System.Exception)
                {
                    // The file region is already locked
                    throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbFileIsLockedByCurrentVirtualMachine
                                                               .AddParameter(wholeFileName).AddParameter(NeoDatis.Tool.Wrappers.OdbThread.GetCurrentThreadName
                                                                                                             ()).AddParameter(NeoDatis.Odb.OdbConfiguration.IsMultiThread().ToString()));
                }
                if (!fileWriter.IsLocked())
                {
                    throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbFileIsLockedByExternalProgram
                                                               .AddParameter(wholeFileName).AddParameter(NeoDatis.Tool.Wrappers.OdbThread.GetCurrentThreadName
                                                                                                             ()).AddParameter(NeoDatis.Odb.OdbConfiguration.IsMultiThread().ToString()));
                }
            }
        }
		private void Init(string fileName, bool canWrite)
		{
			string dataDirectory = NeoDatis.Tool.Wrappers.OdbSystem.GetProperty("data.directory"
				);
			if (dataDirectory != null)
			{
				wholeFileName = dataDirectory + "/" + fileName;
			}
			else
			{
				wholeFileName = fileName;
			}
			try
			{
				if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
				{
					NeoDatis.Tool.DLogger.Info("Opening datatbase file : " + new NeoDatis.Tool.Wrappers.IO.OdbFile
						(wholeFileName).GetFullPath());
				}
				fileWriter = BuildFileWriter(canWrite);
				SetIoDeviceLength(fileWriter.Length());
			}
			catch (System.Exception e)
			{
				//fixme
				new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
					, e);
			}
			if (canWrite)
			{
				try
				{
					fileWriter.LockFile();
				}
				catch (System.Exception)
				{
					// The file region is already locked
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbFileIsLockedByCurrentVirtualMachine
						.AddParameter(wholeFileName).AddParameter(NeoDatis.Tool.Wrappers.OdbThread.GetCurrentThreadName
						()).AddParameter(NeoDatis.Odb.OdbConfiguration.IsMultiThread().ToString()));
				}
				if (!fileWriter.IsLocked())
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbFileIsLockedByExternalProgram
						.AddParameter(wholeFileName).AddParameter(NeoDatis.Tool.Wrappers.OdbThread.GetCurrentThreadName
						()).AddParameter(NeoDatis.Odb.OdbConfiguration.IsMultiThread().ToString()));
				}
			}
		}