Skip to content

Commit

Permalink
增加别名设置功能
Browse files Browse the repository at this point in the history
  • Loading branch information
nacatcode committed Dec 26, 2023
1 parent c0f2bda commit c939c5a
Show file tree
Hide file tree
Showing 25 changed files with 503 additions and 45 deletions.
4 changes: 4 additions & 0 deletions Core/Models/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class AppModel
/// </summary>
public string Name { get; set; }
/// <summary>
/// 别名
/// </summary>
public string Alias { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions Core/Models/Db/WebSiteModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class WebSiteModel
/// </summary>
public string Domain { get; set; }
/// <summary>
/// 别名
/// </summary>
public string Alias { get; set; }
/// <summary>
/// 分类ID
/// </summary>
public int CategoryID { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.5")]
[assembly: AssemblyFileVersion("1.1.0.5")]
[assembly: AssemblyVersion("1.1.0.7")]
[assembly: AssemblyFileVersion("1.1.0.7")]
7 changes: 5 additions & 2 deletions Core/Servicers/Instances/AppData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ select app
File = m.File,
IconFile = m.IconFile,
Name = m.Name,
Alias = m.Alias,
TotalTime = m.TotalTime
})
.ToList();
Expand All @@ -73,12 +74,13 @@ public void UpdateApp(AppModel app_)
app.Description = app_.Description;
app.File = app_.File;
app.CategoryID = app_.CategoryID;
app.Alias = app_.Alias;
db.SaveChanges();
}
_databse.CloseWriter();
}
}
catch(Exception e)
catch (Exception e)
{
Logger.Error(e.ToString());
}
Expand Down Expand Up @@ -119,7 +121,8 @@ public void AddApp(AppModel app)
}
_databse.CloseWriter();
}
}catch(Exception e)
}
catch (Exception e)
{
Logger.Error(e.ToString());
}
Expand Down
45 changes: 39 additions & 6 deletions Core/Servicers/Instances/WebData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,12 @@ public List<WebSiteModel> GetDateRangeWebSiteList(DateTime start, DateTime end,
.GroupBy(m => m.SiteId)
.Select(s => new
{
Title = s.FirstOrDefault().Site.Title,
Domain = s.FirstOrDefault().Site.Domain,
CategoryID = s.FirstOrDefault().Site.CategoryID,
IconFile = s.FirstOrDefault().Site.IconFile,
ID = s.FirstOrDefault().Site.ID,
//Title = s.FirstOrDefault().Site.Title,
//Domain = s.FirstOrDefault().Site.Domain,
//CategoryID = s.FirstOrDefault().Site.CategoryID,
//IconFile = s.FirstOrDefault().Site.IconFile,
//ID = s.FirstOrDefault().Site.ID,
Site = s.FirstOrDefault().Site,
Duration = s.Sum(m => m.Duration),
});

Expand All @@ -302,7 +303,18 @@ public List<WebSiteModel> GetDateRangeWebSiteList(DateTime start, DateTime end,
{
data = data.OrderByDescending(m => m.Duration);
}
var result = JsonConvert.DeserializeObject<List<WebSiteModel>>(JsonConvert.SerializeObject(data.ToList()));
var list = data.Select(s => new
{
Alias = s.Site.Alias,
Title = s.Site.Title,
Domain = s.Site.Domain,
CategoryID = s.Site.CategoryID,
IconFile = s.Site.IconFile,
ID = s.Site.ID,
Duration = s.Duration,
}).ToList();

var result = JsonConvert.DeserializeObject<List<WebSiteModel>>(JsonConvert.SerializeObject(list));
return result;
}
}
Expand Down Expand Up @@ -777,6 +789,7 @@ from nc in newCategory.DefaultIfEmpty()
IconFile = s.FirstOrDefault().Site.IconFile,
CategoryID = s.FirstOrDefault().Site.CategoryID,
Category = s.FirstOrDefault().Category,
Alias = s.FirstOrDefault().Site.Alias,
}).ToList();

//var result = query.Select(s => new WebSiteModel
Expand Down Expand Up @@ -840,5 +853,25 @@ public void Export(string dir_, DateTime start_, DateTime end_)
}
}
}

public WebSiteModel Update(WebSiteModel website_)
{
using (var db = _database.GetWriterContext())
{
var website = db.WebSites.FirstOrDefault(m => m.ID == website_.ID);
if (website != null)
{
website.Alias = website_.Alias;
website.Domain = website_.Domain;
website.Title = website_.Title;
db.SaveChanges();
_database.CloseWriter();
}
return website;
//string sql = $"update WebSiteModels set CategoryID={categoryId_} where ID in ({string.Join(",", siteIds_)})";
//db.Database.ExecuteSqlCommand(sql);
//db.SaveChanges();
}
}
}
}
5 changes: 5 additions & 0 deletions Core/Servicers/Interfaces/IWebData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,10 @@ public interface IWebData
/// <param name="start_">开始时间</param>
/// <param name="end_">结束时间</param>
void Export(string dir_, DateTime start_, DateTime end_);
/// <summary>
/// 更新站点数据
/// </summary>
/// <param name="website_"></param>
WebSiteModel Update(WebSiteModel website_);
}
}
2 changes: 1 addition & 1 deletion UI/Controls/Charts/ChartsItemTypeCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void Render()
isRendering = true;

//对部分程序未获取程序名的程序使用路径中名字作为程序名
NameTextObj.Text = Data.Name;
//NameTextObj.Text = Data.Name;
//if (Data.Name.Trim() == "" && Data.PopupText.Trim() != "")
//{
// FileInfo fi = new FileInfo(Data.PopupText);
Expand Down
2 changes: 1 addition & 1 deletion UI/Controls/Charts/ChartsItemTypeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void Render()
return;
}
isRendering = true;
NameTextObj.Text = Data.Name;
//NameTextObj.Text = Data.Name;
//对部分程序未获取程序名的程序使用路径中名字作为程序名
//if (Data.Name.Trim() == "" && Data.PopupText.Trim() != "")
//{
Expand Down
3 changes: 2 additions & 1 deletion UI/Controls/Charts/Model/ChartsDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ namespace UI.Controls.Charts.Model
{
public class ChartsDataModel : UINotifyPropertyChanged
{
private string Name_;
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
public string Name { get { return Name_; } set { Name_ = value; OnPropertyChanged(); } }

/// <summary>
/// 值
Expand Down
Loading

0 comments on commit c939c5a

Please sign in to comment.