public static void SaveWorker(List <Worker> workers, string path) { string[] output = new string[workers.Count * 2]; for (int i = 0; i < workers.Count; i++) { Worker worker = workers[i]; output[i * 2 + 0] = $"[{i}]"; output[i * 2 + 1] = $"Name={worker.Name}"; } WriteFiles.Write(output, path); }
public static void SaveStation(List <Station> stations, string path) { string[] output = new string[stations.Count * 2]; for (int i = 0; i < stations.Count; i++) { Station station = stations[i]; output[i * 2 + 0] = $"[{i}]"; output[i * 2 + 1] = $"Name={station.Name}"; } WriteFiles.Write(output, path); }
public static void WebsiteSave(Array_Website websites, string path) { string[] output = new string[websites.GetTotal() * 3]; for (int i = 0; i < websites.GetTotal(); i++) { Website tem = websites.GetArray()[i]; output[i * 3 + 0] = "[" + tem.Name + "]"; output[i * 3 + 1] = "Name=" + tem.Name; output[i * 3 + 2] = "URL=" + tem.URL; } WriteFiles.Write(output, path); }
public static void PlayerItemSave(Array_Item items, string path) { string[] output = new string[items.GetTotal() * 3]; int i = 0; foreach (Item tem in items.GetArray()) { output[i * 3 + 0] = "[" + tem.ID + "]"; output[i * 3 + 1] = "item_id=" + tem.ID; output[i * 3 + 2] = "item_number=" + tem.Number; i++; } WriteFiles.Write(output, path); }
public static void WriteApps(List <App> apps, string path) { string[] result = new string[apps.Count * 3]; int i = 0; foreach (App app in apps) { result[i * 3] = "[" + app.Name + "]"; result[i * 3 + 1] = "name=" + app.Name; result[i * 3 + 2] = "path=" + app.Path; i++; } WriteFiles.Write(result, path); }
public static void PlayerEquipmentSave(Array_Equipment equipments, string path) { string[] output = new string[equipments.GetTotal() * 2]; int i = 0; foreach (Equipment tem in equipments.GetArray()) { if (tem != null) { output[i * 2 + 0] = "[" + tem.ID + "]"; output[i * 2 + 1] = "equipment_id=" + tem.ID; i++; } } WriteFiles.Write(output, path); }
public static void SaveKey(List <Key> keys, string path) { string[] output = new string[keys.Count * 7]; for (int i = 0; i < keys.Count; i++) { Key key = keys[i]; output[i * 7 + 0] = $"[{i}]"; output[i * 7 + 1] = $"Text={key.Text}"; output[i * 7 + 2] = $"Score={key.Score}"; output[i * 7 + 3] = $"Coefficient_Licensor={key.Coefficient[WorkerType.Licensor].ToString()}"; output[i * 7 + 4] = $"Coefficient_Operator={key.Coefficient[WorkerType.Operator].ToString()}"; output[i * 7 + 5] = $"Coefficient_Guardian={key.Coefficient[WorkerType.Guardian].ToString()}"; output[i * 7 + 6] = $"Coefficient_Principal={key.Coefficient[WorkerType.Principal].ToString()}"; } WriteFiles.Write(output, path); }
public static void SaveTask(List <Task> tasks, string path) { List <string> output = new List <string>(); for (int i = 0; i < tasks.Count; i++) { Task task = tasks[i]; output.Add($"[{i}]"); output.Add($"Name={task.Name}"); output.Add($"Time={task.Time.ToString()}"); if (task.Station != null) { output.Add($"Station={task.Station.Name}"); } if (task.Licensor != "") { output.Add($"Licensor={task.Licensor}"); } foreach (string o in task.Operators) { output.Add($"Operator={o}"); } if (task.Guardian != "") { output.Add($"Guardian={task.Guardian}"); } if (task.Principal != "") { output.Add($"Principal={task.Principal}"); } output.Add($"Completed={task.Completed.ToString()}"); output.Add($"Quality={task.Quality.ToString()}"); if (task.Key != null) { output.Add($"Key={task.Key.Text}"); } else { output.Add($"Key="); } } WriteFiles.Write(output.ToArray(), path); }
public static void GamePlayerSave(List <Player> players, string path) { string[] output = new string[players.Count * 13]; int i = 0; foreach (Player tem in players) { output[i * 13 + 0] = "[" + tem.Name + "]"; output[i * 13 + 1] = "player_name=" + tem.Name; output[i * 13 + 2] = "player_profession=" + tem.Profession; output[i * 13 + 3] = "player_exp=" + tem.Exp; output[i * 13 + 4] = "player_money=" + tem.Money; output[i * 13 + 5] = "player_pp=" + tem.PP; output[i * 13 + 6] = "player_hp=" + tem.HP; output[i * 13 + 7] = "player_hp_talent=" + tem.TalentPoints.HP; output[i * 13 + 8] = "player_power_talent=" + tem.TalentPoints.Power; output[i * 13 + 9] = "player_defense_talent=" + tem.TalentPoints.Defense; output[i * 13 + 10] = "player_agile_talent=" + tem.TalentPoints.Agile; output[i * 13 + 11] = "player_precise_talent=" + tem.TalentPoints.Precise; output[i * 13 + 12] = "player_remain_talent=" + tem.RemainTalentPoints; i++; } WriteFiles.Write(output, path); }
private void But_ReleaseTasks_Click(object sender, EventArgs e) { if (Tasks.Count != 0) { //写入html { HDoc doc = new HDoc(); doc.AddChild("html", new HProp("lang", "zh"), new HProp("dir", "ltr")); doc["html"].AddChildren(new HTag("head"), new HTag("body")); doc["html"]["head"].AddChild(new HTag("meta", new HProp("charset", "utf-8"))); doc["html"]["head"].AddChild(new HTag("style", @" body{ background:#fef9e7; } .main{ margin:0% 10%; } .title{ text-align:center; font-family:‘黑体’; font - size:20px } h1.title{ margin - left:40px; font - size:35px; } .worker{ font - size:25px; font - family:‘楷体’; } table{ text - align:center; font - size:18px; }")); doc["html"]["head"].AddChild(new HTag("title", $"【{DateTime.Today.ToShortDateString()}】工作任务")); doc["html"]["body"].AddChild(new HTag("h1", $"【{DateTime.Today.ToShortDateString()}】工作任务")); doc["html"]["body"]["h1"].AddProperties(new HProp("class", "title")); doc["html"]["body"].AddChild(new HTag("div", new HProp("class", "main"))); doc["html"]["body"]["div"].AddChild(new HTag("table", new HProp("border", "1"), new HProp("width", "100%"))); doc["html"]["body"]["div"]["table"].AddChildren(new HTag("tr"), new HTag("tr")); doc["html"]["body"]["div"]["table"]["tr", 0].AddChildren(new HTag("th", new HProp("rowspan", "2")), new HTag("th", new HProp("rowspan", "2")), new HTag("th", new HProp("rowspan", "2")), new HTag("th", new HProp("rowspan", "2")), new HTag("th", new HProp("colspan", "7"))); doc["html"]["body"]["div"]["table"]["tr", 0]["th", 0].AddChild(new HTextTag("序号")); doc["html"]["body"]["div"]["table"]["tr", 0]["th", 1].AddChild(new HTextTag("时间")); doc["html"]["body"]["div"]["table"]["tr", 0]["th", 2].AddChild(new HTextTag("站名")); doc["html"]["body"]["div"]["table"]["tr", 0]["th", 3].AddChild(new HTextTag("工作任务")); doc["html"]["body"]["div"]["table"]["tr", 0]["th", 4].AddChild(new HTextTag("工作人员")); doc["html"]["body"]["div"]["table"]["tr", 1].AddChildren(new HTag("th", "许可人"), new HTag("th", new HProp("colspan", "4")), new HTag("th", "监护人"), new HTag("th", "负责人")); doc["html"]["body"]["div"]["table"]["tr", 1]["th", 1].AddChild(new HTextTag("操作人")); for (int i = 0; i < Tasks.Count; i++) { Task task = Tasks[i]; int index = i + 2; doc["html"]["body"]["div"]["table"].AddChild("tr"); doc["html"]["body"]["div"]["table"]["tr", index].AddChildren(new HTag("td", (i + 1).ToString()), new HTag("td", task.Time.ToString()), new HTag("td", task.Station.Name), new HTag("td", task.Name)); if (task.Licensor != "") { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", task.Licensor)); } else { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", " ")); } for (int j = 0; j < 4; j++) { if (j < task.Operators.Count) { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", task.Operators[j])); } else { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", " ")); } } if (task.Guardian != "") { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", task.Guardian)); } else { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", " ")); } if (task.Principal != "") { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", task.Principal)); } else { doc["html"]["body"]["div"]["table"]["tr", index].AddChild(new HTag("td", " ")); } } WriteFiles.Write(doc.GenerateHtml(), PublicValue.ProgramPath + "/今日任务.html"); } //打开html Process.Start(PublicValue.ProgramPath + "/今日任务.html"); string str = $"/select,\"{ PublicValue.ProgramPath}\\今日任务.html\""; Process.Start("Explorer.exe", str); } else { MessageBox.Show("今日任务为空,请添加后再发布"); } }
private void But_ScoreDisplay_Click(object sender, EventArgs e) //处理HTML并调用浏览器显示工分 { DateTime first = dtp_First.Value; DateTime last = dtp_Last.Value; Save(); //写入html文档 { HDoc doc = new HDoc(); doc.AddChild("html"); doc["html"].AddChildren(new HTag("head"), new HTag("body")); doc["html"]["head"].AddChild(new HTag("title", "工分计算")); doc["html"]["head"].AddChild(new HTag("meta", new HProp("charset", "utf-8"))); doc["html"]["head"].AddChild("style", @" body{ background:#fef9e7; } .main{ margin:0% 15%; } .title{ text-align:center; font-family:'黑体'; font - size:20px } h1.title{ margin-left:40px; font-size:35px; } .worker{ font-size:25px; font-family:'楷体'; } table{ text-align:center; font-size:18px; } "); doc["html"]["body"].AddChild(new HTag("h1", "工分计算")); doc["html"]["body"]["h1"].Properties.Add("class", "title"); doc["html"]["body"].AddChild(new HTag("div", new HProp("class", "main"))); doc["html"]["body"].AddChild("ul"); for (int i = 0; i < PublicValue.Workers.Count; i++) { Worker worker = PublicValue.Workers[i]; doc["html"]["body"]["ul"].AddChild("li"); HTag item = doc["html"]["body"]["ul"]["li", i]; item.AddChildren(new HTag("p", worker.Name), new HTag("p", $"总工分:{worker.GetScore(first, last).ToString()}")); item[0].AddProperties(new HProp("class", "worker")); item[1].AddProperties(new HProp("class", "score")); item.AddChild("table", new HProp("border", "1"), new HProp("width", "100%")); item["table"].AddChild("caption", "工分详情"); item["table"]["caption"].AddProperties(new HProp("class", "title")); HTag table = item["table"]; table.AddChild("tr"); table["tr", 0].AddChildren(new HTag("th", "序号"), new HTag("th", "时间"), new HTag("th", "站名"), new HTag("th", "工作任务"), new HTag("th", "工作类型"), new HTag("th", "对应工分")); var tasks = worker.GetTasks(first, last); int add = 0; //定义重复任务附加值 for (int j = 0; j < tasks.Count; j++) { Task task = tasks[j]; for (int k = 0; k < worker.Types[task].Count; k++) { if (k > 0) { add++; } int index = j + 1 + add; table.AddChild("tr"); WorkerType wt = worker.Types[task][k]; string station; if (task.Station == null) { station = " "; } else { station = task.Station.Name; } table["tr", index].AddChildren(new HTag("td", index.ToString()), new HTag("td", task.Time.ToString()), new HTag("td", station), new HTag("td", task.Name), new HTag("td", Function.GetWorkerTypeString(wt)), new HTag("td", task.GetScore(wt).ToString())); } } } WriteFiles.Write(doc.GenerateHtml(), PublicValue.ProgramPath + "/html.html"); //写入文件 } Process.Start(PublicValue.ProgramPath + "/html.html"); //调用浏览器 }