public void beginRead() { EventWaitHandle wh = new EventWaitHandle(false, EventResetMode.ManualReset); outputReader = new reader(this, false); outputReader.begin(); errorReader = new reader(this, true); errorReader.begin(); }
internal domain.sm.Folder getUserFolder(Int32 userId, Int32 folderId) { OracleQuery request = buildGetUserFoldersQuery(userId); reader rdr = delegate() { return(request.Command.ExecuteReader()); }; OracleDataReader response = (OracleDataReader)_cxn.query(request, rdr); if (response.Read()) { return(domain.sm.Folder.getFolderFromReader(response)); } else { throw new MdoException("User does not own that folder"); } }
/// <summary> /// 读取下一个文件数据 /// </summary> /// <param name="reader"></param> /// <returns></returns> private reader next(reader reader) { interlocked.CompareSetYield(ref readerLock); reader nextReader = reader.Next; if (nextReader == null) { currentReader = null; } else if ((reader.Next = nextReader.Next) == null) { currentReader = reader; } readerLock = 0; return(nextReader); }
public ActionResult Delete(int id, FormCollection collection) { try { string userid = User.Identity.GetUserId(); reader r = e.readers.Find(userid); Book b = r.Books.First(p => p.Id == id); r.Books.Remove(b); e.SaveChanges(); Logger.Log.Info("User" + userid + " deleted book " + id + " from Favourites"); return(RedirectToAction("MyBooks")); } catch { return(View()); } }
public decoder(reader r = default, @string vers = default, long width = default, long height = default, long loopCount = default, long delayTime = default, byte backgroundIndex = default, byte disposalMethod = default, byte imageFields = default, byte transparentIndex = default, bool hasTransparentIndex = default, color.Palette globalColorTable = default, slice <long> delay = default, slice <byte> disposal = default, slice <ptr <image.Paletted> > image = default, array <byte> tmp = default) { this.r = r; this.vers = vers; this.width = width; this.height = height; this.loopCount = loopCount; this.delayTime = delayTime; this.backgroundIndex = backgroundIndex; this.disposalMethod = disposalMethod; this.imageFields = imageFields; this.transparentIndex = transparentIndex; this.hasTransparentIndex = hasTransparentIndex; this.globalColorTable = globalColorTable; this.delay = delay; this.disposal = disposal; this.image = image; this.tmp = tmp; }
public List <reader> getReaderList() { //string connectString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["mysqlConnectString"].ToString(); MySqlConnection conn = new MySqlConnection(connectString); string sql = "SELECT id, name, sex, class_id, student_code, student_card_number, role, reader_status, generate_date from reader where 1 = 1 "; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader dr; List <reader> readerList = new List <reader>(); try { conn.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { reader reader = new reader(); reader.Id = Convert.ToInt32(dr["id"]); reader.Name = Convert.ToString(dr["name"]); reader.Sex = Convert.ToString(dr["sex"]); reader.Class_id = Convert.ToString(dr["class_id"]); reader.Student_code = Convert.ToString(dr["student_code"]); reader.Student_card_number = Convert.ToString(dr["student_card_number"]); reader.Role = Convert.ToString(dr["role"]); reader.Reader_status = Convert.ToString(dr["reader_status"]); reader.Generate_date = Convert.ToDateTime(dr["generate_date"]); readerList.Add(reader); } } catch (Exception ex) { Console.WriteLine(ex); } finally { conn.Close(); Console.WriteLine("finally!"); } return(readerList); }
public ActionResult Index(HttpPostedFileBase file) { var fileName = string.Empty; var path = string.Empty; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); file.SaveAs(path); } ArbolAVL <string, int> arbol = new ArbolAVL <string, int>(); reader myReader = new reader(Server.MapPath("~/App_Data/uploads/" + fileName)); ArbolAVL <string, int> arbolAVL = new ArbolAVL <string, int>(); //Nodo<string, int> primerNodo = new Nodo<string, int>(Storage); //primerNodo.nomFarmaco = Storage.Instance.listaFarmacos[0].nombreFarmaco; //primerNodo.lineaArchivo = (Storage.Instance.listaFarmacos[0].id + 1); //foreach (var farmacos in Storage.Instance.listaFarmacos) //{ // arbolBinario.InsertarNodo(farmacos.id, farmacos.nombreFarmaco, raiz); //} //Prueba para saber que el arbol esta bien //arbolBinario.Tranversal(raiz); return(RedirectToAction("Farmacos")); }
public ActionResult IsUserValid(string data) { var user = new reader(); if (!string.IsNullOrEmpty(data)) { try { using (var context = new LiberaryManagementEntities()) { var userValid = context.reader.Where(x => x.readerid.ToString() == data).FirstOrDefault(); if (userValid != null) { user = userValid; } } } catch (Exception e) { Console.WriteLine(e.Message); } } return(Json(user, JsonRequestBehavior.AllowGet)); }
_ => base.Read(reader, tag),
Read(ref reader, typeToConvert, options, default);
/// <summary> /// 等待缓存写入 /// </summary> /// <param name="reader"></param> private void wait(reader reader) { long endIndex = reader.EndIndex; if (endIndex <= fileLength) { if (set(reader)) reader.Read(); return; } flush(true); if (isDisposed == 0) { if (set(reader)) reader.Read(); } else reader.Cancel(); }
/// <summary> /// 读取下一个文件数据 /// </summary> /// <param name="reader"></param> /// <returns></returns> private reader next(reader reader) { interlocked.NoCheckCompareSetSleep0(ref readerLock); reader nextReader = reader.Next; if (nextReader == null) currentReader = null; else if ((reader.Next = nextReader.Next) == null) currentReader = reader; readerLock = 0; return nextReader; }
ConvertToJson(ref reader, jsonWriter, options);
var(reader, extensionName) = (arg.reader, arg.extensionName);
/// <summary> /// 开始读取文件 /// </summary> public unsafe void Read() { do { int readSize = index.Size + sizeof(int); try { if (FileStream.isDisposed == 0) { buffer = (memoryPool = memoryPool.GetOrCreate(readSize)).Get(); FileStream fileReader = FileStream.fileReader; long offset = fileReader.Position - index.Index; if (offset >= 0 || -offset < index.Index) { fileReader.Seek(offset, SeekOrigin.Current); } else { fileReader.Seek(index.Index, SeekOrigin.Begin); } if (fileReader.Read(buffer, 0, readSize) == readSize) { fixed(byte *bufferFixed = buffer) { if (*(int *)bufferFixed == index.Size) { readSize = index.Size; } else { log.Default.Add(FileStream.FileName + " index[" + index.Index.toString() + "] size[" + (*(int *)bufferFixed).toString() + "]<>" + index.Size.toString(), new System.Diagnostics.StackFrame(), false); } } } else { readSize = 0; } } } catch (Exception error) { log.Default.Add(error, null, false); } Func <fastCSharp.net.returnValue <fastCSharp.code.cSharp.tcpBase.subByteArrayEvent>, bool> onReaded = this.onReaded; if (readSize == index.Size) { if (onReaded(new fastCSharp.code.cSharp.tcpBase.subByteArrayEvent { Buffer = subArray <byte> .Unsafe(buffer, sizeof(int), index.Size), SerializeEvent = memoryPool })) { buffer = null; } else { memoryPool.Push(ref buffer); } } else { onReaded(default(fastCSharp.code.cSharp.tcpBase.subByteArrayEvent)); if (memoryPool != null) { memoryPool.Push(ref buffer); } } reader next = FileStream.next(this); if (next == null) { FileStream = null; onReaded = null; memoryPool = null; typePool <reader> .PushNotNull(this); return; } onReaded = next.onReaded; index = next.index; next.onReaded = null; typePool <reader> .PushNotNull(next); }while (true); }
await WriteAttributesAsync(reader, defattr).ConfigureAwait(false);
var(reader, objectType, existingValue, serializer, serializationFormat, serializationFilePath, filePath, configuration, rootNamespace, projectWorkspaceState, documents) = (arg.reader, arg.objectType, arg.existingValue, arg.serializer, arg.serializationFormat, arg.serializationFilePath, arg.filePath, arg.configuration, arg.rootNamespace, arg.projectWorkspaceState, arg.documents);
public static void Main() { try { TcpClient client = new TcpClient("127.0.0.1", 5001); StreamWriter writer = new StreamWriter(client.GetStream()); writer.Write(" hello"); writer.Flush(); reader streamowner = new reader(); streamowner.buffer = new byte[1024]; streamowner.stream = (NetworkStream)writer.BaseStream; streamowner.stream.BeginRead(streamowner.buffer, 0, 30, new AsyncCallback(Hit), streamowner); String s = String.Empty; while (true) { Console.WriteLine("Enter Message Type: "); string type = Console.ReadLine(); byte[] message = null; int fullmessagelen = 0; switch (type) { case "1": s = "1hello"; message = Encoding.UTF8.GetBytes(s); fullmessagelen = message.Length + BitConverter.GetBytes(message.Length).Length; writer.BaseStream.Write(BitConverter.GetBytes(fullmessagelen), 0, 4); writer.Flush(); Console.Write("Press Enter to Send"); Console.ReadLine(); message[0] = 0x01; writer.BaseStream.Write(message, 0, message.Length); writer.Flush(); break; case "2": Console.Write("Enter topic: "); s = "2" + Console.ReadLine(); message = Encoding.UTF8.GetBytes(s); fullmessagelen = message.Length + BitConverter.GetBytes(message.Length).Length; writer.BaseStream.Write(BitConverter.GetBytes(fullmessagelen), 0, 4); writer.Flush(); Console.Write("Press Enter to Send"); Console.ReadLine(); message[0] = 0x02; writer.BaseStream.Write(message, 0, message.Length); writer.Flush(); break; case "3": Console.Write("Enter topic: "); s = "3" + Console.ReadLine(); message = Encoding.UTF8.GetBytes(s); fullmessagelen = message.Length + BitConverter.GetBytes(message.Length).Length; writer.BaseStream.Write(BitConverter.GetBytes(fullmessagelen), 0, 4); writer.Flush(); Console.Write("Press Enter to Send"); Console.ReadLine(); message[0] = 0x03; writer.BaseStream.Write(message, 0, message.Length); writer.Flush(); break; case "5": Console.Write("Enter topic: "); string topic = Console.ReadLine(); Int16 toplen = (short)Encoding.UTF8.GetByteCount(topic); Console.Write("Enter content: "); string content = Console.ReadLine(); Int16 conlen = (short)Encoding.UTF8.GetByteCount(content); using (MemoryStream ms = new MemoryStream()) { ms.Write(Encoding.UTF8.GetBytes("5"), 0, Encoding.UTF8.GetByteCount("5")); ms.Write(BitConverter.GetBytes(toplen), 0, BitConverter.GetBytes(toplen).Length); ms.Write(Encoding.UTF8.GetBytes(topic), 0, toplen); ms.Write(BitConverter.GetBytes(conlen), 0, BitConverter.GetBytes(conlen).Length); ms.Write(Encoding.UTF8.GetBytes(content), 0, conlen); message = ms.ToArray(); message[0] = 0x05; fullmessagelen = message.Length + BitConverter.GetBytes(message.Length).Length; } writer.BaseStream.Write(BitConverter.GetBytes(fullmessagelen), 0, 4); writer.Flush(); Console.Write("Press Enter to Send"); Console.ReadLine(); writer.BaseStream.Write(message, 0, message.Length); writer.Flush(); break; } } writer.Close(); client.Close(); } catch (Exception e) { Console.WriteLine(e); Console.ReadLine(); } }
value = Read(ref reader, typeToConvert, options);
/// <summary> /// 读取文件分块数据//showjim+cache /// </summary> /// <param name="onReaded"></param> /// <param name="index">文件分块数据位置</param> internal unsafe void Read(Func <fastCSharp.net.returnValue <fastCSharp.code.cSharp.tcpBase.subByteArrayEvent>, bool> onReaded, ref index index) { if (onReaded == null) { log.Error.Throw(log.exceptionType.Null); } long endIndex = index.EndIndex; if (index.Size > 0 && ((int)index.Index & 3) == 0 && endIndex <= fileBufferLength) { if (endIndex <= fileLength) { reader reader = reader.Get(); if (reader != null) { reader.Set(onReaded, ref index); if (set(reader)) { fastCSharp.threading.threadPool.TinyPool.FastStart(reader, thread.callType.FileBlockStreamReader); } return; } } else { memoryPool memoryPool = null; byte[] buffer = null; int copyedSize = int.MinValue; Monitor.Enter(bufferLock); if (isDisposed == 0) { if (index.Index >= bufferIndex) { index.Index -= bufferIndex; try { buffer = (memoryPool = memoryPool.GetOrCreate(index.Size)).Get(index.Size); foreach (memoryPool.pushSubArray nextData in buffers.array) { subArray <byte> data = nextData.SubArray; if (index.Index != 0) { if (index.Index >= data.length) { index.Index -= data.length; continue; } data.UnsafeSet(data.startIndex + (int)index.Index, data.length - (int)index.Index); index.Index = 0; } if (copyedSize < 0) { fixed(byte *dataFixed = data.array) { if (*(int *)(dataFixed + data.startIndex) != index.Size) { break; } } if ((copyedSize = data.length - sizeof(int)) == 0) { continue; } data.UnsafeSet(data.startIndex + sizeof(int), copyedSize); copyedSize = 0; } int copySize = index.Size - copyedSize; if (data.length >= copySize) { Buffer.BlockCopy(data.array, data.startIndex, buffer, copyedSize, copySize); copyedSize = index.Size; break; } Buffer.BlockCopy(data.array, data.startIndex, buffer, copyedSize, copySize); copyedSize += copySize; } } catch (Exception error) { log.Default.Add(error, null, false); } finally { Monitor.Exit(bufferLock); } if (copyedSize == index.Size) { onReaded(new fastCSharp.code.cSharp.tcpBase.subByteArrayEvent { Buffer = subArray <byte> .Unsafe(buffer, 0, index.Size), SerializeEvent = memoryPool }); return; } } else { Monitor.Exit(bufferLock); reader reader = reader.Get(); if (reader != null) { reader.Set(onReaded, ref index); reader.WaitFileStream = this; fastCSharp.threading.threadPool.TinyPool.FastStart(reader, thread.callType.FileBlockStreamReaderWait); return; } } } else { Monitor.Exit(bufferLock); } } } onReaded(default(fastCSharp.code.cSharp.tcpBase.subByteArrayEvent)); }
public RecordEnumerable Records => new(new Record(reader, dataStart, dataEnd));
=> reader is DbDataReader db?Read(db, tokens, offset) !: ReadFallback(reader, tokens, offset) !;
return(ReadString(ref reader, Encoding.UTF8, length));
public TagByteArray(EndiannessAwareBinaryReader reader, bool readNames) => this.Read(reader, readNames);
/// <summary> /// 设置文件读取 /// </summary> /// <param name="reader"></param> /// <returns></returns> private bool set(reader reader) { interlocked.NoCheckCompareSetSleep0(ref readerLock); if (currentReader == null) { currentReader = reader; readerLock = 0; reader.FileStream = this; return true; } currentReader.Next = reader; readerLock = 0; return false; }
var(reader, serializer, descriptors, diagnostics) = (arg.reader, arg.serializer, arg.descriptors, arg.diagnostics);
/// <summary> /// 文件读取 /// </summary> /// <param name="index">读取文件位置</param> /// <param name="onReaded">读取文件回调函数</param> /// <returns></returns> public static reader Get(index index, Func<fastCSharp.code.cSharp.asynchronousMethod.returnValue<fastCSharp.code.cSharp.tcpBase.subByteArrayEvent>, bool> onReaded) { reader reader = typePool<reader>.Pop(); if (reader == null) { try { reader = new reader(); } catch { return null; } } reader.onReaded = onReaded; reader.index = index; return reader; }
ToTargetBlock(reader, buffer, true, fieldMappingOverrides);
var(reader, serializer, configurationName, languageVersionValue, extensions) = (arg.reader, arg.serializer, arg.configurationName, arg.languageVersionValue, arg.extensions);
/// <summary> /// Gets all the headers of the record. /// </summary> public HeaderEntryEnumerable RecordHeaders => new(new RecordHeaderEntry(reader, headerStart, dataStart - 4));
JsonTokenType.StartObject => DeserializeObj(ref reader, options),
public ReadWriter(reader reader, writer writer) { this.reader = reader; this.writer = writer; }
public TagList(EndiannessAwareBinaryReader reader, bool readNames) => this.Read(reader, readNames);
return(JsonSerializer.Create().Deserialize(reader, type));
/// <summary> /// Starts the command with all the settings as configured.</summary> /// <param name="stdin"> /// Provides a byte stream to be passed to the process’s standard input.</param> public void Start(byte[] stdin = null) { if (State != CommandRunnerState.NotStarted) throw new InvalidOperationException("This command has already been started, and cannot be started again."); State = CommandRunnerState.Started; _startInfo = new ProcessStartInfo(); _startInfo.FileName = @"cmd.exe"; _startInfo.Arguments = "/C " + EscapeCmdExeMetachars(Command); _startInfo.WorkingDirectory = WorkingDirectory; foreach (var kvp in EnvironmentVariables) _startInfo.EnvironmentVariables.Add(kvp.Key, kvp.Value); _startInfo.RedirectStandardInput = stdin != null; _startInfo.RedirectStandardOutput = true; _startInfo.RedirectStandardError = true; _startInfo.CreateNoWindow = true; _startInfo.WindowStyle = ProcessWindowStyle.Hidden; _startInfo.UseShellExecute = false; if (RunAsUser != null) { _startInfo.LoadUserProfile = RunAsUser.LoadProfile; _startInfo.Domain = RunAsUser.Domain; _startInfo.UserName = RunAsUser.Username; _startInfo.Password = RunAsUser.Password; } _stdoutReader = new reader(StdoutData, StdoutText, CaptureEntireStdout); _stderrReader = new reader(StderrData, StderrText, CaptureEntireStderr); _process = new Process(); _process.EnableRaisingEvents = true; _process.StartInfo = _startInfo; _process.Exited += processExited; _process.Start(); if (stdin != null) { _process.StandardInput.BaseStream.Write(stdin); _process.StandardInput.BaseStream.Close(); } Thread.Sleep(50); _started.Set(); // the main purpose of _started is to make Pause reliable when executed immediately after Start. _stdoutReader.ReadBegin(_process.StandardOutput.BaseStream); _stderrReader.ReadBegin(_process.StandardError.BaseStream); }
new(nameIndex, ReadRawData(reader, length));