Ejemplo n.º 1
0
        public bool patchSCX(Dictionary <string, MPKEntry> mpk, string charset, Dictionary <string, dynamic> scx)
        {
            Log("[SCX] 正在应用 SCX 补丁...");
            foreach (KeyValuePair <string, dynamic> kv in scx)
            {
                if (!mpk.ContainsKey(kv.Key))
                {
                    Oops("[SCX] 无法找到文件 " + kv.Key);
                    return(false);
                }
                Log("[SCX] 正在对 " + kv.Key + " 应用补丁...");

                using (var ms = new MemoryStream())
                    using (var reader = new SCXReader(mpk[kv.Key].Data, charset))
                        using (var writer = new SCXWriter(ms, charset))
                        {
                            var sb = new StringBuilder();
                            if (!SCX.ApplyPatch(kv.Value, reader, writer, sb))
                            {
                                Log(sb.ToString());
                                Oops("[SCX] 补丁应用失败");
                                return(false);
                            }
                            mpk[kv.Key].SetData(ms.ToArray());
                        }
            }
            return(true);
        }
Ejemplo n.º 2
0
 private void button_scx_apply_Click(object sender, EventArgs e)
 {
     try
     {
         var patch = JSON.ToObject <Dictionary <string, dynamic> >(File.ReadAllText(textBox_scx_patch.Text));
         if (!patch.ContainsKey("data") || !(patch["data"] is Dictionary <string, dynamic> scx))
         {
             throw new Exception("Bad patch file: Key scx not found or not dictionary");
         }
         var    sb      = new StringBuilder();
         string charset = patch["charset_preset"] + patch["charset"];
         foreach (KeyValuePair <string, object> kv in scx)
         {
             string target = Path.Combine(textBox_scx_target.Text, kv.Key);
             if (!File.Exists(target + ".bak"))
             {
                 continue;
             }
             sb.AppendLine("---------- " + kv.Key + " ----------");
             using (var reader = new SCXReader(File.OpenRead(target + ".bak"), charset))
                 using (var writer = new SCXWriter(File.Open(target, FileMode.Create), charset))
                 {
                     if (!SCX.ApplyPatch((IList <object>)kv.Value, reader, writer, sb))
                     {
                         break;
                     }
                 }
         }
         sb.Append("\n");
         textBox_log.Clear();
         textBox_log.AppendText(sb.ToString());
         File.WriteAllText("R:/patch.log", sb.ToString());
     }
     catch (Exception ex) { Oops(ex); }
 }
Ejemplo n.º 3
0
    private void BindSCX()
    {
        DataSet ds = SCX.GetList("");

        this.drpProductLine.DataSource = ds;
        this.drpProductLine.DataBind();
        this.drpProductLine.Items.Insert(0, new ListItem("请选择", "0"));
        this.drpProductLine.SelectedIndex = 0;
    }
Ejemplo n.º 4
0
    private void bindSCX()
    {
        DataSet ds = SCX.GetList("");

        if (ds != null)
        {
            this.ScxDropdown.DataSource = ds;
            this.ScxDropdown.DataBind();
            this.ScxDropdown.Items.Insert(0, "--请选择--");
        }
    }
Ejemplo n.º 5
0
 //绑定生产线
 private void BindSCX()
 {
     try
     {
         DataSet ds = SCX.GetList("");
         this.drpSCX.DataSource = ds;
         this.drpSCX.DataBind();
         this.drpSCX.Items.Insert(0, new ListItem("请选择", "0"));
         this.drpSCX.SelectedIndex = 0;
     }
     catch
     {
         this.PrintfError("数据访问错误");
         return;
     }
 }