public ActionResult Edit([Bind(Include = "id,path,owner")] doc doc) { if (ModelState.IsValid) { db.Entry(doc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.owner = new SelectList(db.teachers, "Id", "name", doc.owner); return(View(doc)); }
public string ReadContentFromFile(string filePath) { //Time:O(m+n) doc r = root; var rFile = filePath.Split('/'); for (int i = 1; i < rFile.Length - 1; i++) { r = r.docs[rFile[i]]; } return(r.docs[rFile[rFile.Length - 1]].content); }
public ActionResult Create([Bind(Include = "id,path,owner")] doc doc) { if (ModelState.IsValid) { db.docs.Add(doc); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.owner = new SelectList(db.teachers, "Id", "name", doc.owner); return(View(doc)); }
public static void show(doc d, frm_main m, int weight = -1, int height = -1, int ss_hide = 0, bool light = false) { try { int w = 300, h = 22, hv = 30; Color bc = !light ? m.style.bc_tooltip : m.style.bc_tooltip2; StringBuilder html = new StringBuilder($@"<html xml:lang='en-us' xmlns='http://www.w3.org/1999/xhtml'><head> <meta charset='utf-8'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <meta name='viewport' content='width=device-width, initial-scale=1'> <style> body {{ font-family:{m.style.font_family_semibold}; color:white; font-size:{m.style.font_size_normal - 2}pt; background-color:{m.style.css_clr(bc)}; padding:7px; margin:0px; border:0px; }} div.voice {{ height:23px; padding:4px; }} div.voice:hover {{ background-color:{m.style.css_clr(ctrls.ctrls.change_light(bc, 1.4f))}; }} a.l-title {{ margin-right:3px; color:white; display:block; vertical-align:middle; text-decoration: none; }} a.l-title span.base {{ display:inline-block; }} a.l-title span.img {{ display:inline-block; position:relative; top:-7px; margin-left:5px; }} a.l-title span.noimg {{ display:inline-block; position:relative; margin-left:34px; }} </style> <script language=javascript> </script> </head> <body>"); bool one_image = false; foreach (doc_element e in d.elements) { if (e is doc_voice && !string.IsNullOrEmpty(((doc_voice)e).image_name)) { one_image = true; } } foreach (doc_element e in d.elements) { if (e is doc_voice) { string image_name = ((doc_voice)e).image_name; html.Append($@"<div class='voice'> <a class='l-title' href=""javascript:{{ {((doc_voice)e).href}; window.external.hide(); }}""> {(!string.IsNullOrEmpty(image_name) ? $"<img src='{style.image_path_24(image_name)}'>" : "")} <span {(!string.IsNullOrEmpty(image_name) ? "class='img'" : (one_image ? "class='noimg'" : "class='base'"))}>{((doc_voice)e).title}</span></a></div>"); h += hv; } else if (e is doc_text) { html.Append($@"<div>{((doc_text)e).text}</div>"); } } html.Append("</body></html>"); frm_tooltip.show_tooltip(html.ToString(), weight > 0 ? weight : w, height > 0 ? height : h, d.for_scripting, ss_hide, light); } catch { } }
// For delete ACR Document public static bool DeleteACRDocument(int docId) { using (EditorsEntities entity = new EditorsEntities()) { doc DeleteDoc = entity.docs.Find(docId); if (DeleteDoc != null) { entity.docs.Remove(DeleteDoc); entity.SaveChanges(); } return(true); } }
private void button1_Click(object sender, EventArgs e) { if ((textBox1.Text == "") || (comboBox1.Text == "") || (textBox3.Text == "") || (textBox4.Text == "")) { MessageBox.Show("Заполните все поля!!!!", "Ошибка", MessageBoxButtons.OKCancel); } else { Doctor v = new Doctor(textBox1.Text, comboBox1.Text, textBox3.Text, Convert.ToInt32(textBox4.Text)); if (!(textBox1.Text == "") && !(comboBox1.Text == "") && !(textBox3.Text == "") && !(textBox4.Text == "")) { FileStream file1 = new FileStream("Doc.txt", FileMode.Append); StreamWriter zap1 = new StreamWriter(file1); zap1.WriteLine(textBox1.Text); zap1.WriteLine(comboBox1.Text); zap1.WriteLine(textBox3.Text); zap1.WriteLine(textBox4.Text); zap1.Close(); DataTable dt = new DataTable(); dt.Columns.Add("Фамилия"); dt.Columns.Add("Специализация"); dt.Columns.Add("Должность"); dt.Columns.Add("Разряд"); doc[] user = new doc[100]; StreamReader zap = new StreamReader("Doc.txt"); // Поток на чтение с файла int i = 0; while (zap.Peek() != -1) // Считывание с файла { i++; user[i].fam = zap.ReadLine(); user[i].spec = zap.ReadLine(); user[i].dzn = zap.ReadLine(); user[i].raz = Convert.ToInt32(zap.ReadLine()); } zap.Close(); for (int j = 1; j <= i; j++) { dt.Rows.Add(user[j].fam, user[j].spec, user[j].dzn, user[j].raz); } Form3 f3 = new Form3(); f3.dataGridView1.DataSource = dt; } MessageBox.Show("Данные добавлены!!!", "Добавление", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } textBox1.Clear(); textBox3.Clear(); textBox4.Clear(); }
public static bool AddDocument(ACRDocumentsModel ModelAddDocument) { using (EditorsEntities entity = new EditorsEntities()) { doc newDoc = new doc(); newDoc.source = ModelAddDocument.Source; newDoc.nm = ModelAddDocument.Name; newDoc.last_updated_dt = ModelAddDocument.LastUpdatedDate; newDoc.clicks_count = ModelAddDocument.ClicksCount; newDoc.auto_upd = ModelAddDocument.IsAutoUpdate; entity.docs.Add(newDoc); entity.SaveChanges(); } return(true); }
public void Mkdir(string path) { //Time:O(m+n) doc dir = root; var dirs = path.Split('/'); for (int i = 1; i < dirs.Length; i++) { if (!dir.docs.ContainsKey(dirs[i])) { dir.docs.Add(dirs[i], new doc()); } dir = dir.docs[dirs[i]]; } }
public static bool UpdateACRDocClickCount(int Id) { using (EditorsEntities entity = new EditorsEntities()) { doc Result = (from ad in entity.docs where ad.id == Id select ad).FirstOrDefault(); if (Result != null) { Result.clicks_count++; entity.Entry(Result).State = EntityState.Modified; entity.SaveChanges(); } return(true); } }
public string upload(int id) { var file = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(HttpContext.Current.Server.MapPath("~/docs"), fileName); file.SaveAs(path); doc d = new doc(); d.owner = id; d.path = path; db.docs.Add(d); db.SaveChanges(); } return(file != null ? file.FileName + " OK" : null); }
// GET: /Docs/Details/5 public ActionResult Details(int?id) { if (Session["logged"] == null) { return(RedirectToAction("Index", "login", null)); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } doc doc = db.docs.Find(id); if (doc == null) { return(HttpNotFound()); } return(View(doc)); }
public void AddContentToFile(string filePath, string content) { //Time:O(m+n) doc f = root; var fLoc = filePath.Split('/'); for (int i = 1; i < fLoc.Length - 1; i++) { f = f.docs[fLoc[i]]; } if (!f.docs.ContainsKey(fLoc[fLoc.Length - 1])) { f.docs.Add(fLoc[fLoc.Length - 1], new doc()); } f = f.docs[fLoc[fLoc.Length - 1]]; f.isFile = true; f.content = f.content + content; }
// for update ACR Document public static bool EditDocument(ACRDocumentsModel EditDocumentModel) { using (EditorsEntities entity = new EditorsEntities()) { doc editDoc = entity.docs.Find(EditDocumentModel.Id); if (editDoc != null) { editDoc.source = EditDocumentModel.Source; editDoc.nm = EditDocumentModel.Name; editDoc.last_updated_dt = EditDocumentModel.LastUpdatedDate; editDoc.clicks_count = EditDocumentModel.ClicksCount; editDoc.auto_upd = EditDocumentModel.IsAutoUpdate; entity.Entry(editDoc).State = EntityState.Modified; entity.SaveChanges(); } return(true); } }
// GET: /Docs/Edit/5 public ActionResult Edit(int?id) { if (Session["logged"] == null) { return(RedirectToAction("Index", "login", null)); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } doc doc = db.docs.Find(id); if (doc == null) { return(HttpNotFound()); } ViewBag.owner = new SelectList(db.teachers, "Id", "name", doc.owner); return(View(doc)); }
/// <summary> /// 작성할 파일을 생성한다. /// </summary> public override StreamWriter w00_create_dir_and_file(string root_path, doc doc) { string cur_path = root_path; if (null != doc.category_info) { foreach (var dir in doc.category_info) { cur_path += "/"; cur_path += dir; } } System.IO.Directory.CreateDirectory(cur_path); cur_path = cur_path + "/" + doc.uniq_id + ".h"; System.IO.StreamWriter wr = new System.IO.StreamWriter(cur_path); return(wr); }
private bool GetPropertyIsNullable(PropertyInfo p, doc doc, string name) { if (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { return(true); } else { var d = doc.members.Where(r => r.name == "P:" + name).FirstOrDefault(); if (d != null && d.@null != null) { return(true); } if (d != null && d.summary != null && d.summary.@null != null) { return(true); } return(false); } }
// To add ACRDocument Relation public static bool AddACRDocumentRelation(ACRDocumentRelationshipModel NewRelation, string subtopicId) { using (EditorsEntities entity = new EditorsEntities()) { doc ACRDocument = entity.docs.Find(NewRelation.DocId); if (ACRDocument != null) { doc_in_subtopic newRelationDB = new doc_in_subtopic(); newRelationDB.doc_id = NewRelation.DocId; newRelationDB.subtopic_id = Convert.ToInt32(subtopicId); entity.doc_in_subtopic.Add(newRelationDB); entity.SaveChanges(); return(true); } else { return(false); } } }
private string GetDesc(doc doc, string name, DocT t) { if (t == DocT.Property) { var d = doc.members.Where(r => r.name == "P:" + name).FirstOrDefault(); if (d != null && d.summary != null && d.summary.Text != null && d.summary.Text.Length > 0) { return(d.summary.Text[0].Trim(new char[] { ' ', '\n' })); } return(""); } else { var d = doc.members.Where(r => r.name.StartsWith("T:") && r.name.Contains(name)).FirstOrDefault(); if (d != null && d.summary != null && d.summary.Text != null && d.summary.Text.Length > 0) { return(d.summary.Text[0].Trim(new char[] { ' ', '\n' })); } return(""); } }
public IList <string> Ls(string path) { //Time: O(m+n+klogk) m-length of string,n-depth of last directory,k-entries doc d = root; var result = new List <string>(); if (path != "/") { //file var files = path.Split('/'); for (int i = 1; i < files.Length; i++) { d = d.docs[files[i]]; } if (d.isFile) { result.Add(files[files.Length - 1]); return(result); } } //folder result.AddRange(d.docs.Keys.OrderBy(x => x)); return(result); }
internal static Dictionary <string, List <DocInfo> > FromXmlFile(FileInfo file) { Args.ThrowIfNull(file, "file"); Dictionary <string, List <DocInfo> > tempResults = new Dictionary <string, List <DocInfo> >(); if (file.Exists) { doc doc = file.FromXmlFile <doc>(); string assemblyName = doc.assembly.name; if (doc.members != null && doc.members.Items != null) { doc.members.Items.Each(mem => { DocInfo info = new DocInfo(); info.AssemblyName = assemblyName; string memberName; info.MemberType = GetMemberType(mem.name, out memberName); info.MemberName = memberName; info.From = DocInfoFrom.Xml; #region ugly if (mem.Items != null) { mem.Items.Each(memberItem => { if (!info.TrySetSummary(memberItem)) { if (!info.TrySetRemarks(memberItem)) { if (!info.TrySetExample(memberItem)) { if (!info.TrySetValue(memberItem)) { if (!info.TrySetReturns(memberItem)) { if (!info.TrySetParam(memberItem)) { if (!info.TrySetTypeParam(memberItem)) { if (!info.TrySetCode(memberItem)) { if (!info.TrySetException(memberItem)) { if (!info.TrySetPermission(memberItem)) { info.TrySetSeeAlso(memberItem); } } } } } } } } } } }); } #endregion if (!tempResults.ContainsKey(memberName)) { tempResults.Add(memberName, new List <DocInfo>()); } tempResults[memberName].Add(info); }); } } else { Log.AddEntry("Requested DocInfo Dictionary for non-existent file: {0}", file.FullName); } return(tempResults); }
public SearchServiceResponse SearchService(SearchServiceRqeuest request) { if (AppSetting("FibbdenFind", "false") == "true") { throw new BException("禁止访问服务"); } else { try { var ret = new SearchServiceResponse(); if (request.Route == "Heart/Heart") { return(new SearchServiceResponse() { Attributes = new List <string>(), Exceptions = new List <string>(), Method = "POST", RelativePath = "Heart/Heart", Request = "", Requests = new List <ServiceAttribute>() { }, Response = "", Responses = new List <ServiceAttribute>() { }, ServcieName = "心跳服务" }); } var routes = Configuration.Services.GetApiExplorer().ApiDescriptions.Where(r => r.Route.RouteTemplate == request.Route); #region ex if (routes.Count() == 0) { throw new BException("服务不存在"); } if (routes.Count() > 1) { throw new BException("服务存在多个"); } #endregion var api = routes.FirstOrDefault(); var jObj = new JObject(); ret.Attributes = api.ActionDescriptor.GetCustomAttributes <Attribute>(true).Select(r => r.TypeId.ToString()).ToList(); ret.Method = api.HttpMethod.Method; ret.RelativePath = api.RelativePath; var serviceXml = api.ActionDescriptor.ControllerDescriptor.ControllerType.Assembly.CodeBase.Replace(".dll", ".xml").Replace(".DLL", ".xml").Replace("file:///", ""); #region servicename if (!File.Exists(serviceXml)) { throw new BException("服务相关的注释文件不存在!"); } else { #region 获取服务名称 var file = new FileStream(serviceXml, FileMode.Open, FileAccess.Read); var xmlSearializer = new XmlSerializer(typeof(ApiBase.Entity.Service.doc)); var doc1 = (ApiBase.Entity.Service.doc)xmlSearializer.Deserialize(file); file.Close(); var methodName = api.ActionDescriptor.ControllerDescriptor.ControllerName + "Controller" + "." + api.ActionDescriptor.ActionName; var i = doc1.members.Where(r => r.name.Contains(methodName + "(")).FirstOrDefault(); if (i == null) { i = doc1.members.Where(r => r.name.Contains(methodName)).FirstOrDefault(); } if (i != null && i.Items != null && i.Items.Length > 0) { for (int k = 0; k < i.ItemsElementName.Length; k++) { if (i.ItemsElementName[k] == ApiBase.Entity.Service.ItemsChoiceType.summary) { ret.ServcieName = i.Items[k].ToString().Trim(); } else if (i.ItemsElementName[k] == ApiBase.Entity.Service.ItemsChoiceType.exception) { ret.Exceptions.Add(i.Items[k].ToString().Trim()); } } } #endregion } #endregion doc doc = null; #region process request if (api.HttpMethod == HttpMethod.Post) { var parameters = api.ParameterDescriptions; if (parameters.Count == 1) { var pd = parameters[0].ParameterDescriptor; var pdType = pd.ParameterType; #region 解析xml文件 var xmlpath = pdType.Assembly.CodeBase.Replace(".dll", ".xml").Replace(".DLL", ".xml").Replace("file:///", ""); if (!File.Exists(xmlpath)) { throw new BException("请求实体相关的注释文件不存在"); } var file = new FileStream(xmlpath, FileMode.Open, FileAccess.Read); var xmlSearializer = new XmlSerializer(typeof(doc)); doc = (doc)xmlSearializer.Deserialize(file); file.Close(); if (doc == null) { throw new BException("请求实体相关的注释文件不存在!"); } #endregion var properties = GetProperties(pd.ParameterType); var i = 0; #region 解析属性 for (int j = 0; j < properties.Count; j++) { var propertie = properties[j]; if ((propertie.PropertyType.IsGenericType || propertie.PropertyType.IsArray) && propertie.PropertyType.Name != typeof(Nullable <>).Name) { jObj.Add(propertie.Name, "[{" + i + "}]"); i = i + 1; ret.Requests.Add(new ServiceAttribute() { Description = GetDesc(doc, propertie.DeclaringType.FullName + "." + propertie.Name, DocT.Property), Name = propertie.Name, Type = GetPropertyInfoName(propertie), IsNullable = GetPropertyIsNullable(propertie, doc, propertie.DeclaringType.FullName + "." + propertie.Name), ValueDescriptions = GetValueDesc(doc, propertie.DeclaringType.FullName + "." + propertie.Name, DocT.Property), }); } else if (propertie.PropertyType.IsClass && propertie.PropertyType != typeof(string)) { var jObjClass = new JObject(); var ps = propertie.PropertyType.GetProperties(); for (int k = 0; k < ps.Length; k++) { var psk = ps[k]; if (psk.PropertyType.IsClass && psk.PropertyType != typeof(string)) { jObjClass.Add(psk.Name, "[{" + i + "}]"); } else { jObjClass.Add(psk.Name, "{" + i + "}"); } i = i + 1; ret.Requests.Add(new ServiceAttribute() { Description = GetDesc(doc, psk.DeclaringType.FullName + "." + psk.Name, DocT.Property), Name = psk.Name, Type = GetPropertyInfoName(psk), IsNullable = GetPropertyIsNullable(psk, doc, psk.DeclaringType.FullName + "." + psk.Name), ValueDescriptions = GetValueDesc(doc, psk.DeclaringType.FullName + "." + psk.Name, DocT.Property), }); } jObj.Add(propertie.Name, jObjClass.ToString(Formatting.None)); } else { jObj.Add(propertie.Name, "{" + i + "}"); i = i + 1; ret.Requests.Add(new ServiceAttribute() { Description = GetDesc(doc, propertie.DeclaringType.FullName + "." + propertie.Name, DocT.Property), Name = propertie.Name, Type = GetPropertyInfoName(propertie), IsNullable = GetPropertyIsNullable(propertie, doc, propertie.DeclaringType.FullName + "." + propertie.Name), ValueDescriptions = GetValueDesc(doc, propertie.DeclaringType.FullName + "." + propertie.Name, DocT.Property), }); } } #endregion } } ret.Request = (jObj.Count > 0 ? jObj.ToString(Formatting.None) : "").Replace("\"[", "[").Replace("]\"", "]"); #endregion #region process response if (api.ResponseDescription.DeclaredType != null) { if (doc == null) { #region 解析xml文件 var xmlpath = api.ResponseDescription.DeclaredType.Assembly.CodeBase.Replace(".dll", ".xml").Replace(".DLL", ".xml").Replace("file:///", ""); if (!File.Exists(xmlpath)) { throw new BException("请求实体相关的注释文件不存在"); } var file = new FileStream(xmlpath, FileMode.Open, FileAccess.Read); var xmlSearializer = new XmlSerializer(typeof(doc)); doc = (doc)xmlSearializer.Deserialize(file); file.Close(); if (doc == null) { throw new BException("请求实体相关的注释文件不存在!"); } #endregion } if (api.ResponseDescription.DeclaredType != typeof(String) && api.ResponseDescription.DeclaredType.IsValueType == false) { ret.Response = JsonConvert.SerializeObject(Activator.CreateInstance(api.ResponseDescription.DeclaredType)); var properties1 = GetProperties(api.ResponseDescription.DeclaredType); #region 解析属性 for (int j = 0; j < properties1.Count; j++) { var propertie = properties1[j]; var s = new ServiceAttribute() { Description = GetDesc(doc, propertie.DeclaringType.FullName + "." + propertie.Name, DocT.Property), Name = propertie.Name, Type = GetPropertyInfoName(propertie), IsNullable = GetPropertyIsNullable(propertie, doc, propertie.DeclaringType.FullName + "." + propertie.Name), ValueDescriptions = GetValueDesc(doc, propertie.DeclaringType.FullName + "." + propertie.Name, DocT.Property), }; List <PropertyInfo> properties = null; if (propertie.PropertyType.IsGenericType || propertie.PropertyType.IsArray) { if (propertie.PropertyType.GenericTypeArguments != null && propertie.PropertyType.GenericTypeArguments.Length > 0) { var type = propertie.PropertyType.GenericTypeArguments[0]; if (type != typeof(String)) { properties = GetProperties(type); } } } else if (propertie.PropertyType.IsClass && propertie.PropertyType != typeof(string)) { properties = GetProperties(propertie.PropertyType); } if (properties != null) { s.ClassDescriptions = new List <ServiceAttribute>(); foreach (var item in properties) { s.ClassDescriptions.Add(new ServiceAttribute() { Description = GetDesc(doc, item.DeclaringType.FullName + "." + item.Name, DocT.Property), Name = item.Name, Type = GetPropertyInfoName(item), IsNullable = GetPropertyIsNullable(item, doc, item.DeclaringType.FullName + "." + item.Name), ValueDescriptions = GetValueDesc(doc, item.DeclaringType.FullName + "." + item.Name, DocT.Property), }); } } ret.Responses.Add(s); } #endregion } else { var apiPath = api.ActionDescriptor.ControllerDescriptor.ControllerType.Assembly.CodeBase.Replace(".dll", ".xml").Replace(".DLL", ".xml").Replace("file:///", ""); var file = new FileStream(apiPath, FileMode.Open, FileAccess.Read); var xmlSearializer = new XmlSerializer(typeof(doc)); var doc1 = (doc)xmlSearializer.Deserialize(file); file.Close(); var path = "Controller." + api.ActionDescriptor.ActionName + "("; var item = doc1.members.FirstOrDefault(r => r.name.Contains(path)); if (item != null) { var name = ""; if (item.returns != null) { try { name = ((System.Xml.XmlNode[])item.returns).FirstOrDefault().Value; } catch (Exception) { } } ret.Responses.Add(new ServiceAttribute() { Description = "", Name = name, Type = api.ResponseDescription.DeclaredType.Name, IsNullable = false, ValueDescriptions = null, }); } } } #endregion return(ret); } catch (Exception ex) { if (ex is BException) { throw ex; } else { throw new BException(ex.Message + ex.StackTrace); } } } }
private void pictureBox3_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Вы действительно хотите удалить строку ?", "Удаление строки", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { doc[] user = new doc[100]; StreamReader zap1 = new StreamReader("Doc.txt"); // Октрывает поток на чтение int i = 0, size = 0; while (zap1.Peek() != -1) //Считываем данные с файла { i++; user[i].fam = zap1.ReadLine(); user[i].spec = zap1.ReadLine(); user[i].dzn = zap1.ReadLine(); user[i].raz = Convert.ToInt32(zap1.ReadLine()); size++; } int del; del = dataGridView1.CurrentCell.RowIndex; del++; doc[] user2 = new doc[100]; for (int j = 1; j <= size; j++) // Перезапись исходного массива в новый без удаляемого элемента, т.е. сдвиг { if (j < del) { user2[j] = user[j]; } if (j > del) { user2[j - 1] = user[j]; } } zap1.Close(); File.Delete("Doc.txt"); FileStream file2 = new FileStream("Doc.txt", FileMode.Create); // Перезапись исходного файла StreamWriter zap2 = new StreamWriter(file2); for (int j = 1; j < size; j++) { zap2.WriteLine(user2[j].fam); zap2.WriteLine(user2[j].spec); zap2.WriteLine(user2[j].dzn); zap2.WriteLine(user2[j].raz); } zap2.Close(); DataTable dt = new DataTable(); dt.Columns.Add("Фамилия"); dt.Columns.Add("Специлизация"); dt.Columns.Add("Должность"); dt.Columns.Add("Разряд"); StreamReader zap = new StreamReader("Doc.txt"); int p = 0; while (zap.Peek() != -1) // Считывание с файла { p++; user2[i].fam = zap.ReadLine(); user2[i].spec = zap.ReadLine(); user2[i].dzn = zap.ReadLine(); user2[i].raz = Convert.ToInt32(zap.ReadLine()); } zap.Close(); for (int j = 1; j <= p; j++) { dt.Rows.Add(user2[j].fam, user2[j].spec, user2[j].dzn, user2[j].raz); } dataGridView1.DataSource = dt; } }
internal Element(DB.Document doc, DB.ElementId id) => SetValue(doc, id);
private void button2_Click(object sender, EventArgs e) { FileInfo f1 = new FileInfo("Poisk.txt"); f1.Delete(); string sp = ""; string dz = ""; if (radioButton1.Checked == true) { sp = "детский"; } if (radioButton2.Checked == true) { sp = "взрослый"; } if (checkBox1.Checked == true) { dz = "терапевт"; } if (checkBox2.Checked == true) { dz = "хирург"; } if (checkBox3.Checked == true) { dz = "стоматолог"; } if ((radioButton1.Checked == false) && (radioButton2.Checked == false)) { MessageBox.Show("Выберите специализацию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if ((checkBox1.Checked == false) && (checkBox2.Checked == false) && (checkBox3.Checked == false)) { for (int i = 0; i < dataGridView1.RowCount; i++) { string znach = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value); if (sp == znach) { FileStream file1 = new FileStream("Poisk.txt", FileMode.Append); StreamWriter zap1 = new StreamWriter(file1); zap1.WriteLine(dataGridView1.Rows[i].Cells[0].Value); zap1.WriteLine(dataGridView1.Rows[i].Cells[1].Value); zap1.WriteLine(dataGridView1.Rows[i].Cells[2].Value); zap1.WriteLine(dataGridView1.Rows[i].Cells[3].Value); zap1.Close(); } } } else { for (int i = 0; i < dataGridView1.RowCount; i++) { string znachd = Convert.ToString(dataGridView1.Rows[i].Cells[2].Value); string znach = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value); if ((sp == znach) && (dz == znachd)) { FileStream file1 = new FileStream("Poisk.txt", FileMode.Append); StreamWriter zap1 = new StreamWriter(file1); zap1.WriteLine(dataGridView1.Rows[i].Cells[0].Value); zap1.WriteLine(dataGridView1.Rows[i].Cells[1].Value); zap1.WriteLine(dataGridView1.Rows[i].Cells[2].Value); zap1.WriteLine(dataGridView1.Rows[i].Cells[3].Value); zap1.Close(); } } } DataTable dt = new DataTable(); dt.Columns.Add("Фамилия"); dt.Columns.Add("Специализация"); dt.Columns.Add("Должность"); dt.Columns.Add("Разряд"); doc[] user = new doc[100]; StreamReader zap = new StreamReader("Poisk.txt"); // Поток на чтение с файла int p = 0; while (zap.Peek() != -1) // Считывание с файла { p++; user[p].fam = zap.ReadLine(); user[p].spec = zap.ReadLine(); user[p].dzn = zap.ReadLine(); user[p].raz = Convert.ToInt32(zap.ReadLine()); } zap.Close(); for (int j = 1; j <= p; j++) { dt.Rows.Add(user[j].fam, user[j].spec, user[j].dzn, user[j].raz); } dataGridView1.DataSource = dt; radioButton1.Checked = false; radioButton2.Checked = false; checkBox1.Checked = false; checkBox2.Checked = false; checkBox3.Checked = false; } }
FillTemplate(doc, toReplace);
public FilePathResult Download(int id) { doc d = (from x in db.docs where x.id == id select x).First(); return(File(d.path, "multipart/form-data", d.path.Split('/').Last())); }
public FileSystem() { root = new doc(); }
/// <summary> /// 작성할 파일을 생성한다. /// </summary> public virtual StreamWriter w00_create_dir_and_file(string root_path, doc doc) { throw new NotImplementedException(System.Reflection.MethodBase.GetCurrentMethod().Name); }