/// <summary> /// 获取文件相关信息 /// </summary> /// <param name="file">文件info</param> /// <param name="plies">层数</param> /// <returns></returns> public static RecordBean GetFileBean(FileInfo file, uint plies) { RecordBean bean = new RecordBean() { Path = file.FullName, Plies = plies, Size = file.Length, CerateTime = file.CreationTime, ModifyTime = file.LastWriteTime, VisitTime = file.LastAccessTime, ExceptionCode = (int)RecordExCode.Normal, FileCount = 1, IsFile = true, IsChange = false, }; // 获取文件占用空间 try { bean.SpaceUsage = SpaceUsage.Get(file.FullName); } catch (Win32Exception e) { bean.ExceptionCode = (int)RecordExCode.SpaceUsageException; Log.Warn(string.Format("获取文件占用空间失败。{0} {1}, [error code: {2}]", file.FullName, e.Message, bean.ExceptionCode)); } return(bean); }
//作用同上,调整新记录的指针 private static void SetNewId(ref DirNode node, RecordBean bean, uint incidentId) { if (bean.IncidentId != 0) { node.NewIncidentId = bean.IncidentId; node.NewId = bean.TargetId; } else { node.NewIncidentId = incidentId; node.NewId = bean.Id; } }
// 后续记录需要过滤掉未变化的重复项 private void SaveBeanForOtherRecord(RecordBean bean, RecordBean[] childDirBeans) { RecordBean targetBean = Extend.GetLastBean(bean.Path); if (targetBean == null) { bean.IsChange = true; } else { bean.IsChange = bean.IsChange || !bean.Equals(targetBean); } //如果该bean没有变化,则不再记录 if (bean.IsChange) { bean.Id = RecordMapper.AddOne(bean, incidentId, false); beanCount++; //刷新索引 DirIndexMapper.RefreshIndex(new DirIndexBean() { Path = bean.Path, IncidentId = incidentId, TargectId = bean.Id, }); foreach (RecordBean dirBean in childDirBeans) { if (dirBean.IsChange) { RecordMapper.SetParentId(dirBean.Id, bean.Id, incidentId); } else { //将未改变的bena也记录下来 dirBean.ParentId = bean.Id; RecordMapper.AddOne(dirBean, incidentId, false); beanCount++; } } } else { //为未改变节点添加索引 bean.IncidentId = targetBean.IncidentId; bean.TargetId = targetBean.Id; } }
//通过路径获取最新的记录节点 internal static RecordBean GetLastBean(string path) { DirIndexBean dirIndex = DirIndexMapper.GetOneByPath(path); if (dirIndex == null) { return(null); } RecordBean bean = RecordMapper.GetOneById(dirIndex.TargectId, dirIndex.IncidentId); if (bean == null) { return(null); } //告知该bean是属于哪一个事件的 bean.IncidentId = dirIndex.IncidentId; return(bean); }
// 第一次记录 private void SaveBeanForFirstRecord(RecordBean bean, RecordBean[] childDirBeans) { //记录并获取当前id bean.Id = RecordMapper.AddOne(bean, incidentId, true); //记录索引 DirIndexMapper.AddOne(new DirIndexBean() { Path = bean.Path, IncidentId = incidentId, TargectId = bean.Id, }); beanCount++; //设置子一级的父id foreach (RecordBean dirBean in childDirBeans) { RecordMapper.SetParentId(dirBean.Id, bean.Id, incidentId); } }
//将数据由表格转化为bean private static RecordBean[] GetBeansByTable(DataTable table) { int count = table.Rows.Count; RecordBean[] beans = new RecordBean[count]; for (int i = 0; i < count; i++) { DataRow row = table.Rows[i]; uint incidentId = 0; ulong targetId = 0; if (table.Columns.Contains("incident_id")) { incidentId = Convert.ToUInt32(row["incident_id"]); targetId = Convert.ToUInt64(row["target_id"]); } RecordBean bean = new RecordBean() { Id = Convert.ToUInt64(row["id"]), ParentId = Convert.ToUInt64(row["parent_id"]), IncidentId = incidentId, TargetId = targetId, Path = (string)row["path"], Plies = Convert.ToUInt32(row["plies"]), Size = BigInteger.Parse(row["size"] as string), SpaceUsage = BigInteger.Parse(row["space_usage"] as string), CerateTime = (DateTime)row["create_time"], ModifyTime = (DateTime)row["modify_time"], VisitTime = (DateTime)row["visit_time"], Owner = row["owner"] as string, ExceptionCode = Convert.ToInt32(row["exception_code"]), FileCount = Convert.ToUInt32(row["file_count"]), DirCount = Convert.ToUInt32(row["dir_count"]), }; beans[i] = bean; } return(beans); }
//使用回调的方式,遍历整个硬盘 private RecordBean SeeDirectory(DirectoryInfo baseDir, uint plies) { //告知当前进度 if (plies == 2) { plies2Path = baseDir.FullName; } RecordBean bean = BeanFactory.GetDirBean(baseDir, plies); //C盘有传送门,两个路径可以同时访问一个文件,所以这里放弃其中一个路径 if (bean.Path == @"C:\Users\All Users") { return(bean); } //获取子文件和子文件夹列表 DirectoryInfo[] dirs; FileInfo[] files; try { dirs = baseDir.GetDirectories(); files = baseDir.GetFiles(); } catch (UnauthorizedAccessException e) { bean.ExceptionCode = (int)RecordExCode.UnauthorizedAccess | bean.ExceptionCode; Log.Warn(string.Format("没有权限。{0}, [error code: {1}]", e.Message, RecordExCode.UnauthorizedAccess)); return(bean); } catch (IOException e) { bean.ExceptionCode = (int)RecordExCode.IOExceptionForGetFile | bean.ExceptionCode; Log.Warn(string.Format("{0}: {1}, [error code: {2}]", baseDir.FullName, e.Message, RecordExCode.IOExceptionForGetFile)); return(bean); } //用于记录子节点的bean RecordBean[] childDirBeans = new RecordBean[dirs.Length]; //遍历并获取子文件夹 for (int i = 0; i < dirs.Length; i++) { RecordBean dirBean = SeeDirectory(dirs[i], plies + 1); bean.Add(dirBean); childDirBeans[i] = dirBean; } //遍历并获取子文件 foreach (FileInfo file in files) { RecordBean fileBean = BeanFactory.GetFileBean(file, plies); bean.Add(fileBean); } // 存储记录结果 if (isFirst) { SaveBeanForFirstRecord(bean, childDirBeans); } else { SaveBeanForOtherRecord(bean, childDirBeans); } return(bean); }
/// <summary> /// 建立该节点的子节点 /// </summary> /// <param name="node">文件夹节点</param> public static void BuildChildrenNodes(DirNode node) { //获取对应节点下的文件夹列表 RecordBean[] oldBeans; if (node.OldIncidentId == 0) { oldBeans = new RecordBean[0]; } else { oldBeans = RecordMapper.GetBeansByPid(node.OldId, node.OldIncidentId); } RecordBean[] newBeans; if (node.NewIncidentId == 0) { newBeans = new RecordBean[0]; } else { newBeans = RecordMapper.GetBeansByPid(node.NewId, node.NewIncidentId); } List <DirNode> dirNodes = new List <DirNode>(); //遍历两个文件夹列表 foreach (RecordBean oldBean in oldBeans) { RecordBean newBean = null; //去除重复项 for (int i = 0; i < newBeans.Length; i++) { if (newBeans[i] == null) { continue; } if (oldBean.Path == newBeans[i].Path) { newBean = newBeans[i]; newBeans[i] = null; } } //建立node DirNode dirNode = new DirNode() { Name = oldBean.Name, Path = oldBean.Path, // 放入一个空数组,告知页面该节点可以展开 Children = oldBean.DirCount > 0 ? new DirNode[1] : null, }; SetOldId(ref dirNode, oldBean, node.OldIncidentId); //设置类型 if (newBean != null) { SetNewId(ref dirNode, newBean, node.NewIncidentId); if (oldBean.Equals(newBean)) { dirNode.Type = DirNodeType.Unchanged; } else { dirNode.Type = DirNodeType.Changed; } } else { dirNode.Type = DirNodeType.Deleted; } dirNodes.Add(dirNode); } //新纪录中新增的部分 foreach (RecordBean newBean in newBeans) { if (newBean == null) { continue; } DirNode dirNode = new DirNode() { Name = newBean.Name, Path = newBean.Path, Children = newBean.DirCount > 0 ? new DirNode[1] : null, //新增的节点 Type = DirNodeType.Added, }; SetNewId(ref dirNode, newBean, node.NewIncidentId); dirNodes.Add(dirNode); } //添加标签 TagBean nullTag = new TagBean() { Color = "#FFFFFF" }; foreach (DirNode dirNode in dirNodes) { TagBean tagBean = TagSupport.GetTagByPath(dirNode.Path, out bool isThis); if (tagBean == null) { dirNode.Tag = nullTag; continue; } dirNode.IsRootTag = isThis; dirNode.Tag = tagBean; } node.Children = dirNodes.ToArray(); }
/// <summary> /// 通过节点获取文件夹的比较信息 /// </summary> public static ComparisonInfo GetInfoByNode(DirNode node) { //获取bean RecordBean oldBean = null; if (node.OldId != 0) { oldBean = RecordMapper.GetOneById(node.OldId, node.OldIncidentId); } RecordBean newBean = null; if (node.NewId != 0) { newBean = RecordMapper.GetOneById(node.NewId, node.NewIncidentId); } //设置标签 ComparisonInfo info = new ComparisonInfo() { TagName = string.Concat("标签:", node.Tag.Name ?? "没有标签") }; //设置主要比较的数据 BigInteger oldSize, newSize, oldUsage, newUsage; if (oldBean != null) { info.Title = oldBean.Name; info.Location = oldBean.Location; info.CreateTime = "创建时间:" + oldBean.CerateTime.ToString("yy-MM-dd HH:mm:ss"); info.OldFileCount = Convert.ToInt32(oldBean.FileCount); info.OldDirCount = Convert.ToInt32(oldBean.DirCount); oldSize = oldBean.Size; oldUsage = oldBean.SpaceUsage; } else { oldSize = BigInteger.Zero; oldUsage = BigInteger.Zero; } if (newBean != null) { info.Title = newBean.Name; info.Location = newBean.Location; info.CreateTime = "创建时间:" + newBean.CerateTime.ToString("yy-MM-dd HH:mm:ss"); info.NewFileCount = Convert.ToInt32(newBean.FileCount); info.NewDirCount = Convert.ToInt32(newBean.DirCount); newSize = newBean.Size; newUsage = newBean.SpaceUsage; } else { newSize = BigInteger.Zero; newUsage = BigInteger.Zero; } //单位换算 info.OldSize = ConversionUtil.StorageFormate(oldSize, false); info.NewSize = ConversionUtil.StorageFormate(newSize, false); info.SizeChanged = ConversionUtil.StorageFormate(newSize - oldSize, true); info.OldUsage = ConversionUtil.StorageFormate(oldUsage, false); info.NewUsage = ConversionUtil.StorageFormate(newUsage, false); info.UsageChanged = ConversionUtil.StorageFormate(newUsage - oldUsage, true); //设置状态 switch (node.Type) { case DirNodeType.Unchanged: info.Action = "文件夹未发生变化"; break; case DirNodeType.Added: info.Action = "该文件夹是新增的文件夹"; break; case DirNodeType.Changed: info.Action = "该文件夹发生了变化"; break; case DirNodeType.Deleted: info.Action = "该文件夹已经被删除"; break; } return(info); }
public async Task <List <Grid> > creazioneGriglia(List <RecordBean> lista) { string codiceColore; Color colore = Color.Gray; Color color = new Color(); color = Color.LightGray; int riga = 1; List <RecordBean> Appoggio = new List <RecordBean>(); foreach (var i in lista) { Appoggio.Add(i); if (Appoggio.Count == 5) { Grid grigliaPrincipale = new Grid(); grigliaPrincipale.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grigliaPrincipale.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); var lblNominativi = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, TextColor = Color.White, Text = "Nominativi" }; var lblNominativi1 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, TextColor = Color.White, BackgroundColor = Color.Chocolate, Text = "Stato" }; var lblNominativi2 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "Ingresso" }; var lblNominativi3 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "In visita" }; var lblNominativi4 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "Attesa referti" }; var lblNominativi5 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "Attesa Dim." }; grigliaPrincipale.Children.Add(lblNominativi, 0, 0); grigliaPrincipale.Children.Add(lblNominativi1, 1, 0); grigliaPrincipale.Children.Add(lblNominativi2, 2, 0); grigliaPrincipale.Children.Add(lblNominativi3, 3, 0); grigliaPrincipale.Children.Add(lblNominativi4, 4, 0); grigliaPrincipale.Children.Add(lblNominativi5, 5, 0); for (int j = 0; j < Appoggio.Count; j++) { codiceColore = Appoggio[j].colore; switch (codiceColore) { case "Verde": colore = Color.LimeGreen; break; case "Rosso": colore = Color.Red; break; case "Bianco": colore = Color.White; break; case "Giallo": colore = Color.Yellow; break; } var imageArrowIngresso = new Image { Source = "freccia.png", HorizontalOptions = LayoutOptions.End, HeightRequest = 30, WidthRequest = 20 }; var imageArrowVisita = new Image { Source = "freccia.png", HorizontalOptions = LayoutOptions.End, HeightRequest = 30, WidthRequest = 20 }; var imageArrowAttesa = new Image { Source = "freccia.png", HorizontalOptions = LayoutOptions.End, HeightRequest = 30, WidthRequest = 20 }; var imageSessoUomo = new Image { Source = "male48.png" }; var imageSessoDonna = new Image { Source = "female48.png" }; var labelCodiciNominativi = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].cartella, BackgroundColor = colore, TextColor = Color.Black, WidthRequest = 80, HeightRequest = 40 }; var labelNomiCognomiEta = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].cognome.Substring(0, 1) + "." + " " + Appoggio[j].nome.Substring(0, 1) + "." + " età: " + Appoggio[j].eta, TextColor = Color.Black }; var labelStato = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontSize = 15, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].salaprimotriage + "\n" + Appoggio[j].stato, TextColor = Color.Black, BackgroundColor = Color.LightGray }; if (Appoggio[j].stato.Equals("Accettato") || Appoggio[j].stato.Equals("In Triage")) { color = Color.Orange; } else { color = Color.LightGray; } var labelIngresso = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].dataaccettazione + "\n" + Appoggio[j].oraaccettazione, TextColor = Color.Black, BackgroundColor = color }; if (Appoggio[j].stato.Equals("In Visita")) { color = Color.Orange; } else { color = Color.LightGray; } var labelInVisita = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].datapresaincarico + "\n" + Appoggio[j].orapresaincarico, TextColor = Color.Black, BackgroundColor = color }; if (Appoggio[j].stato.Equals("In Attesa Referto")) { color = Color.Orange; } else { color = Color.LightGray; } var labelInAttesa = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].dataprimarichiesta + "\n" + Appoggio[j].oraprimarichiesta, TextColor = Color.Black, BackgroundColor = color }; if (Appoggio[j].stato.Equals("In Osservazione OBI") || Appoggio[j].stato.Equals("Dimesso")) { color = Color.Orange; } else { color = Color.LightGray; } var labelDimissioni = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].datadimissione + "\n" + Appoggio[j].oradimissione, TextColor = Color.Black, BackgroundColor = color }; var stackNominativi = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackNominativiOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackNominativiGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackNominativi.Children.Add(labelCodiciNominativi); stackNominativiOrizzontale.Children.Add(labelNomiCognomiEta); stackNominativi.Children.Add(stackNominativiOrizzontale); stackNominativiGrande.Children.Add(stackNominativi); if (Appoggio[j].sesso == "M") { stackNominativiGrande.Children.Add(imageSessoUomo); } else if (Appoggio[j].sesso == "F") { stackNominativiGrande.Children.Add(imageSessoDonna); } var stackIngresso = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackIngressoOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackIngressoGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackIngresso.Children.Add(labelIngresso); stackIngressoOrizzontale.Children.Add(imageArrowIngresso); stackIngresso.Children.Add(stackIngressoOrizzontale); stackIngressoGrande.Children.Add(stackIngresso); var stackInVisita = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackInVisitaOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackInVisitaGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackInVisita.Children.Add(labelInVisita); stackInVisitaOrizzontale.Children.Add(imageArrowVisita); stackInVisita.Children.Add(stackInVisitaOrizzontale); stackInVisitaGrande.Children.Add(stackInVisita); var stackInAttesa = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackInAttesaOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackInAttesaGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackInAttesa.Children.Add(labelInAttesa); stackInAttesaOrizzontale.Children.Add(imageArrowAttesa); stackInAttesa.Children.Add(stackInAttesaOrizzontale); stackInAttesaGrande.Children.Add(stackInAttesa); var stackDimissioni = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Margin = 5 }; var stackDimissioniOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackDimissioniGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackDimissioni.Children.Add(labelDimissioni); //stackDimissioniOrizzontale.Children.Add( ); // stackDimissioni.Children.Add(stackDimissioniOrizzontale); stackDimissioniGrande.Children.Add(stackDimissioni); grigliaPrincipale.Children.Add(stackNominativiGrande, 0, riga); grigliaPrincipale.Children.Add(labelStato, 1, riga); grigliaPrincipale.Children.Add(stackIngressoGrande, 2, riga); grigliaPrincipale.Children.Add(stackInVisitaGrande, 3, riga); grigliaPrincipale.Children.Add(stackInAttesaGrande, 4, riga); grigliaPrincipale.Children.Add(stackDimissioniGrande, 5, riga); grigliaPrincipale.Children.Add(imageArrowIngresso, 2, riga); grigliaPrincipale.Children.Add(imageArrowVisita, 3, riga); grigliaPrincipale.Children.Add(imageArrowAttesa, 4, riga); grigliaPrincipale.ColumnSpacing = 2; grigliaPrincipale.RowSpacing = 2; riga++; } Appoggio.Clear(); riga = 1; listaProva.Add(grigliaPrincipale); } } if (Appoggio.Count < 5 && Appoggio.Count != 0) { ElencoPasientiBO p = new ElencoPasientiBO(); RecordBean g = new RecordBean(); g = p.aggiungiCampiVuoti(); while (Appoggio.Count != 5) { Appoggio.Add(g); } Grid grigliaPrincipale = new Grid(); grigliaPrincipale.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grigliaPrincipale.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); var lblNominativi = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, TextColor = Color.White, Text = "Nominativi" }; var lblNominativi1 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, TextColor = Color.White, BackgroundColor = Color.Chocolate, Text = "Stato" }; var lblNominativi2 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "Ingresso" }; var lblNominativi3 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "In visita" }; var lblNominativi4 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "Attesa referti" }; var lblNominativi5 = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, TextColor = Color.White, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.Chocolate, Text = "Attesa Dim." }; grigliaPrincipale.Children.Add(lblNominativi, 0, 0); grigliaPrincipale.Children.Add(lblNominativi1, 1, 0); grigliaPrincipale.Children.Add(lblNominativi2, 2, 0); grigliaPrincipale.Children.Add(lblNominativi3, 3, 0); grigliaPrincipale.Children.Add(lblNominativi4, 4, 0); grigliaPrincipale.Children.Add(lblNominativi5, 5, 0); for (int j = 0; j < Appoggio.Count; j++) { codiceColore = Appoggio[j].colore; switch (codiceColore) { case "Verde": colore = Color.LimeGreen; break; case "Rosso": colore = Color.Red; break; case "Bianco": colore = Color.White; break; case "Giallo": colore = Color.Yellow; break; case "---": colore = Color.Gray; break; } var imageArrowIngresso = new Image { Source = "freccia.png", HorizontalOptions = LayoutOptions.End, HeightRequest = 30, WidthRequest = 20 }; var imageArrowVisita = new Image { Source = "freccia.png", HorizontalOptions = LayoutOptions.End, HeightRequest = 30, WidthRequest = 20 }; var imageArrowAttesa = new Image { Source = "freccia.png", HorizontalOptions = LayoutOptions.End, HeightRequest = 30, WidthRequest = 20 }; var imageSessoUomo = new Image { Source = "male48.png" }; var imageSessoDonna = new Image { Source = "female48.png" }; var labelCodiciNominativi = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].cartella, BackgroundColor = colore, TextColor = Color.Black, WidthRequest = 80, HeightRequest = 40 }; var labelNomiCognomiEta = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].cognome.Substring(0, 1) + "." + " " + Appoggio[j].nome.Substring(0, 1) + "." + " età: " + Appoggio[j].eta, TextColor = Color.Black }; var labelStato = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].salaprimotriage + "\n" + Appoggio[j].stato, TextColor = Color.Black, FontSize = 15, BackgroundColor = Color.LightGray }; if (Appoggio[j].stato.Equals("Accettato") || Appoggio[j].stato.Equals("In Triage")) { color = Color.Orange; } else { color = Color.LightGray; } var labelIngresso = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, Text = Appoggio[j].dataaccettazione + "\n" + Appoggio[j].oraaccettazione, TextColor = Color.Black, FontSize = 15, BackgroundColor = color }; if (Appoggio[j].stato.Equals("In Visita")) { color = Color.Orange; } else { color = Color.LightGray; } var labelInVisita = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].datapresaincarico + "\n" + Appoggio[j].orapresaincarico, TextColor = Color.Black, BackgroundColor = color }; if (Appoggio[j].stato.Equals("In Attesa Referto")) { color = Color.Orange; } else { color = Color.LightGray; } var labelInAttesa = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].dataprimarichiesta + "\n" + Appoggio[j].oraprimarichiesta, TextColor = Color.Black, BackgroundColor = color }; if (Appoggio[j].stato.Equals("In Osservazione OBI") || Appoggio[j].stato.Equals("Dimesso")) { color = Color.Orange; } else { color = Color.LightGray; } var labelDimissioni = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold, FontSize = 15, Text = Appoggio[j].datadimissione + "\n" + Appoggio[j].oradimissione, TextColor = Color.Black, BackgroundColor = color }; var stackNominativi = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackNominativiOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackNominativiGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackNominativi.Children.Add(labelCodiciNominativi); stackNominativiOrizzontale.Children.Add(labelNomiCognomiEta); stackNominativi.Children.Add(stackNominativiOrizzontale); stackNominativiGrande.Children.Add(stackNominativi); if (Appoggio[j].sesso == "M") { stackNominativiGrande.Children.Add(imageSessoUomo); } else if (Appoggio[j].sesso == "F") { stackNominativiGrande.Children.Add(imageSessoDonna); } var stackIngresso = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackIngressoOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackIngressoGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackIngresso.Children.Add(labelIngresso); stackIngressoOrizzontale.Children.Add(imageArrowIngresso); stackIngresso.Children.Add(stackIngressoOrizzontale); stackIngressoGrande.Children.Add(stackIngresso); var stackInVisita = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackInVisitaOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackInVisitaGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackInVisita.Children.Add(labelInVisita); stackInVisitaOrizzontale.Children.Add(imageArrowVisita); stackInVisita.Children.Add(stackInVisitaOrizzontale); stackInVisitaGrande.Children.Add(stackInVisita); var stackInAttesa = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, Margin = 5 }; var stackInAttesaOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackInAttesaGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackInAttesa.Children.Add(labelInAttesa); stackInAttesaOrizzontale.Children.Add(imageArrowAttesa); stackInAttesa.Children.Add(stackInAttesaOrizzontale); stackInAttesaGrande.Children.Add(stackInAttesa); var stackDimissioni = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Margin = 5 }; var stackDimissioniOrizzontale = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, }; var stackDimissioniGrande = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = 5, BackgroundColor = Color.LightGray }; stackDimissioni.Children.Add(labelDimissioni); //stackDimissioniOrizzontale.Children.Add( ); // stackDimissioni.Children.Add(stackDimissioniOrizzontale); stackDimissioniGrande.Children.Add(stackDimissioni); grigliaPrincipale.Children.Add(stackNominativiGrande, 0, riga); grigliaPrincipale.Children.Add(labelStato, 1, riga); grigliaPrincipale.Children.Add(stackIngressoGrande, 2, riga); grigliaPrincipale.Children.Add(stackInVisitaGrande, 3, riga); grigliaPrincipale.Children.Add(stackInAttesaGrande, 4, riga); grigliaPrincipale.Children.Add(stackDimissioniGrande, 5, riga); grigliaPrincipale.Children.Add(imageArrowIngresso, 2, riga); grigliaPrincipale.Children.Add(imageArrowVisita, 3, riga); grigliaPrincipale.Children.Add(imageArrowAttesa, 4, riga); grigliaPrincipale.ColumnSpacing = 2; grigliaPrincipale.RowSpacing = 2; riga++; } Appoggio.Clear(); riga = 1; listaProva.Add(grigliaPrincipale); } return(listaProva); }
/// <summary> /// 添加一行数据 /// </summary> /// <param name="bean">对应的数据实体</param> /// <param name="incidentId">对应的事件id</param> /// <param name="isFirst">是否是第一次记录</param> /// <returns>该行的id</returns> public static ulong AddOne(RecordBean bean, uint incidentId, bool isFirst) { using (SQLiteCommand cmd = new SQLiteCommand()) { string param = string.Empty; string value = string.Empty; if (!isFirst) { param = "[incident_id], [target_id], "; value = "@incident_id, @target_id, "; } cmd.CommandText = string.Concat( "INSERT INTO [record_", incidentId, "] (" + "[parent_id], ", param, "[path], " + "[plies], " + "[size], " + "[space_usage], " + "[create_time], " + "[modify_time], " + "[visit_time], " + "[owner], " + "[exception_code], " + "[file_count], " + "[dir_count]) " + "VALUES (" + "@parent_id, ", value, "@path, " + "@plies, " + "@size, " + "@space_usage, " + "@create_time, " + "@modify_time, " + "@visit_time, " + "@owner, " + "@exception_code, " + "@file_count, " + "@dir_count);"); cmd.Parameters.Add("parent_id", DbType.UInt64).Value = bean.ParentId; cmd.Parameters.Add("path", DbType.String).Value = bean.Path; cmd.Parameters.Add("plies", DbType.UInt32).Value = bean.Plies; cmd.Parameters.Add("size", DbType.String).Value = bean.Size.ToString(); cmd.Parameters.Add("space_usage", DbType.String).Value = bean.SpaceUsage.ToString(); cmd.Parameters.Add("create_time", DbType.DateTime).Value = bean.CerateTime; cmd.Parameters.Add("modify_time", DbType.DateTime).Value = bean.ModifyTime; cmd.Parameters.Add("visit_time", DbType.DateTime).Value = bean.VisitTime; cmd.Parameters.Add("owner", DbType.String).Value = bean.Owner; cmd.Parameters.Add("exception_code", DbType.Int32).Value = bean.ExceptionCode; cmd.Parameters.Add("file_count", DbType.UInt32).Value = bean.FileCount; cmd.Parameters.Add("dir_count", DbType.UInt32).Value = bean.DirCount; if (!isFirst) { cmd.Parameters.Add("incident_id", DbType.UInt32).Value = bean.IncidentId; cmd.Parameters.Add("target_id", DbType.UInt64).Value = bean.TargetId; } SQLiteClient.Write(cmd); } ulong id; using (SQLiteCommand cmd = new SQLiteCommand()) { cmd.CommandText = "SELECT LAST_INSERT_ROWID();"; DataTable table = SQLiteClient.Read(cmd); id = Convert.ToUInt64(table.Rows[0][0]); } return(id); }