public async Task <IActionResult> Add(errModel model) { if (ModelState.IsValid) { err error = await db.Errors.FirstOrDefaultAsync(u => u.id == model.id); if (error == null) { db.Errors.Add(new err { criticalityId = model.criticalityId, statusId = 1, urgencyId = model.urgencyId, f_descript = model.f_descript, s_descript = model.s_descript, date = DateTime.Now, user_id = User.Identity.Name, }); await db.SaveChangesAsync(); err error1 = await db.Errors.LastOrDefaultAsync(p => p.id > 0); db.ErHstr.Add(new ErrorHistory { date = DateTime.Now, act = "Ввод", user_id = User.Identity.Name, errId = error1.id }); await db.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Такая ошибка уже есть в базе"); } return(View(model)); }
public async Task <IActionResult> Update(int?id) { if (id != null) { err error = await db.Errors.FirstOrDefaultAsync(p => p.id == id); var hstr = db.ErHstr.Where(p => p.errId == id); editClass ed = new editClass { Err = error, ErHs = hstr.ToArray() }; return(View(ed)); } return(NotFound()); }
public async Task <IActionResult> Details(int?id) { if (id != null) { err error = await db.Errors.Include(p => p.Histories).Include(p => p.status).Include(p => p.urgency).Include(p => p.criticality).FirstOrDefaultAsync(p => p.id == id); var hstr = db.ErHstr.Where(p => p.errId == id); editClass ed = new editClass { Err = error, ErHs = hstr.ToArray() }; ErrorHistory[] e = hstr.ToArray(); return(View(error)); } return(NotFound()); }
SRes read(void *data, std::size_t&size) { if (!osdfile) { osd_printf_error("un7z: called CSzFile::read without file\n"); return(SZ_ERROR_READ); } if (!size) { return(SZ_OK); } // TODO: this casts a size_t to a uint32_t, so it will fail if >=4GB is requested at once (need a loop) std::uint32_t read_length(0); auto const err = osdfile->read(data, currfpos, size, read_length); size = read_length; currfpos += read_length; return((osd_file::error::NONE == err) ? SZ_OK : SZ_ERROR_READ); }
async public void sendGet(string uriStr, Dictionary <string, string> dic, finishd delegatefi, err e) { string apendStr = "?"; foreach (string key in dic.Keys) { string value = dic[key]; apendStr += key + "=" + value + "&"; } apendStr = apendStr.Remove(apendStr.Length - 1, 1); uriStr += apendStr; //var content = new HttpFormUrlEncodedContent(dic); Uri uri = new Uri(uriStr); try { HttpResponseMessage message = await client.GetAsync(uri); if (message.StatusCode == HttpStatusCode.Ok && message != null) { JsonObject json = JsonObject.Parse(message.Content.ToString()); delegatefi(json); } else { e("请求失败"); } } catch { e("链接错误"); } }
async public void sendPOST(string uriStr, Dictionary <string, string> dic, finishd delegatefi, err e) { // Dictionary<string, string> dic = new Dictionary<string, string>(); var content = new HttpFormUrlEncodedContent(dic); Uri uri = new Uri(uriStr); try { HttpResponseMessage message = await client.PostAsync(uri, content); if (message.StatusCode == HttpStatusCode.Ok && message != null) { JsonObject json = JsonObject.Parse(message.Content.ToString()); delegatefi(json); } else { e("请求失败"); } } catch { e("链接错误"); } }
async public void sendPostHtml(string uriStr, Dictionary <string, string> dic, finishdHtml delegatefi, err e) { //var content = new HttpFormUrlEncodedContent(dic); Uri uri = new Uri(uriStr); try { //CancellationTokenSource cts = new CancellationTokenSource(7000); //client.DefaultRequestHeaders.TryAppendWithoutValidation("Accept-Encoding", "gzip, deflate"); //client.DefaultRequestHeaders.TryAppendWithoutValidation("Accept", "text/html, application/xhtml+xml, image/jxr, */*"); var content = new HttpFormUrlEncodedContent(dic); HttpResponseMessage message = await client.PostAsync(uri, content); if (message.StatusCode == HttpStatusCode.Ok && message != null) { var contentType = message.Content.Headers.ContentType; if (string.IsNullOrEmpty(contentType.CharSet)) { contentType.CharSet = "utf-8"; } // JsonObject json = JsonObject.Parse(message.Content.ToString()); delegatefi(message.Content.ToString()); } else { e("请求失败"); } } catch { e("链接错误"); } }
public archive_file.error decompress(ListBytes buffer, uint32_t length) { #if false // if we don't have enough buffer, error if (length < m_curr_length) { osd_printf_error("un7z: buffer too small to decompress %s from %s\n", m_curr_name.c_str(), m_filename.c_str()); return(archive_file::error::BUFFER_TOO_SMALL); } // make sure the file is open.. if (!m_archive_stream.osdfile) { m_archive_stream.currfpos = 0; osd_file::error const err = osd_file::open(m_filename, OPEN_FLAG_READ, m_archive_stream.osdfile, m_archive_stream.length); if (err != osd_file::error::NONE) { osd_printf_error("un7z: error reopening archive file %s (%d)\n", m_filename.c_str(), int(err)); return(archive_file::error::FILE_ERROR); } osd_printf_verbose("un7z: reopened archive file %s\n", m_filename.c_str()); } std::size_t offset(0); std::size_t out_size_processed(0); SRes const res = SzArEx_Extract( &m_db, &m_look_stream.s, m_curr_file_idx, // requested file &m_block_index, &m_out_buffer, &m_out_buffer_size, // solid block caching &offset, &out_size_processed, // data size/offset &m_alloc_imp, &m_alloc_temp_imp); // allocator helpers if (res != SZ_OK) { osd_printf_error("un7z: error decompressing %s from %s (%d)\n", m_curr_name.c_str(), m_filename.c_str(), int(res)); switch (res) { case SZ_ERROR_UNSUPPORTED: return(archive_file::error::UNSUPPORTED); case SZ_ERROR_MEM: return(archive_file::error::OUT_OF_MEMORY); case SZ_ERROR_INPUT_EOF: return(archive_file::error::FILE_TRUNCATED); default: return(archive_file::error::DECOMPRESS_ERROR); } } // copy to destination buffer std::memcpy(buffer, m_out_buffer + offset, (std::min <std::size_t>)(length, out_size_processed)); return(archive_file::error::NONE); #endif int cur = 0; foreach (var entry in m_sharpCompressArchive.Entries) { if (cur++ == m_curr_file_idx) { MemoryStream stream = new MemoryStream((int)entry.Size); entry.WriteTo(stream); stream.Seek(0, SeekOrigin.Begin); int bufferPos = 0; while (bufferPos < stream.Length) { buffer[bufferPos++] = Convert.ToByte(stream.ReadByte()); } return(archive_file.error.NONE); } } return(archive_file.error.FILE_ERROR); }
public async Task <IActionResult> Update(editClass ed) { err err1 = await db.Errors.FirstOrDefaultAsync(p => p.id == ed.Err.id); string a = Request.Form["status"].ToString(); if (err1.statusId != 4) { if (a == "Открытая") { Models.Status st = await db.Statuses.FirstOrDefaultAsync(p => p.id == 2); err1.status = st; } if (a == "Решенная") { Models.Status st = await db.Statuses.FirstOrDefaultAsync(p => p.id == 3); err1.status = st; } if (a == "Закрытая") { Models.Status st = await db.Statuses.FirstOrDefaultAsync(p => p.id == 4); err1.status = st; } ErrorHistory e = new ErrorHistory(); if (a == "Открытая") { e.act = "Открытие"; } if (a == "Решенная") { e.act = "Решение"; } if (a == "Закрытая") { e.act = "Закрытие"; } ed.Err.user_id = User.Identity.Name; e.errId = ed.Err.id; if (ed.buf != null && err1.status != null) { e.comnt = ed.buf; } e.date = DateTime.Now; e.user_id = ed.Err.user_id; db.ErHstr.Add(e); db.Errors.Update(err1); await db.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }