public ResponseItem Put(yy_Product value) { var _Entity = DB.yy_Product.Find(value.ID); if (_Entity != null) { _Entity.IsShow = value.IsShow; _Entity.ShowIndex = value.ShowIndex; _Entity.Title = value.Title; _Entity.KeyWords = value.KeyWords; _Entity.Summary = value.Summary; _Entity.TypeIDs = value.TypeIDs; if (!_Entity.Info.Equals(value.Info)) { value.Info = KeywordReplace.Excute(DB, value.Info, 2, value.TypeIDs); } _Entity.Info = value.Info; _Entity.TargetPlatforms = value.TargetPlatforms; _Entity.CanReply = value.CanReply; _Entity.CreateDate = value.CreateDate; DB.SaveChanges(); return(new ResponseItem(0, "")); } return(new ResponseItem(2, "不存在的产品。")); }
public ResponseItem Post(yy_Product value) { try { value.Info = KeywordReplace.Excute(DB, value.Info, 2, value.TypeIDs); DB.yy_Product.Add(value); DB.SaveChanges(); return(new ResponseItem(0, "添加产品成功。")); } catch (Exception ex) { return(new ResponseItem(2, ex.Message)); } }
public ResponseItem Post(yy_News value) { try { value.Info = KeywordReplace.Excute(DB, value.Info, 1, value.TypeIDs); DB.yy_News.Add(value); DB.SaveChanges(); //同步微信 if (value.TargetPlatforms.Contains(",1,")) { MessageQueue_Send("WechatSync", value.ID.ToString()); } return(new ResponseItem(0, "添加新闻成功。")); } catch (Exception ex) { return(new ResponseItem(2, ex.Message)); } }
private string BuildFile() { KeywordReplace t = target as KeywordReplace; string format = $"file = file.Replace(\"#KEYWORD#\", COMMAND.ToString());"; var keywords = new List <string>(t.keywords.Count); foreach (var kdata in t.keywords) { var s = format.Replace("KEYWORD", kdata.keyword.ToUpper()); s = s.Replace("COMMAND", kdata.command); keywords.Add(s); } StringBuilder sb = new StringBuilder(); sb.AppendLine(@"using UnityEngine; using UnityEditor; public class KeywordReplacer : UnityEditor.AssetModificationProcessor { public static void OnWillCreateAsset(string path) { path = path.Replace("".meta"", """"); int index = path.LastIndexOf("".""); if (index <= 0) { return; } string file = path.Substring(index); if (file != "".cs"" && file != "".js"" && file != "".boo"") return; index = Application.dataPath.LastIndexOf(""Assets""); path = Application.dataPath.Substring(0, index) + path; file = System.IO.File.ReadAllText(path); // This is where you can insert your custom keywords "); foreach (var item in keywords) { sb.AppendLine("\t\t" + item); } sb.AppendLine( @" System.IO.File.WriteAllText(path, file); AssetDatabase.Refresh(); } }"); return(sb.ToString()); //@"using UnityEngine; //using UnityEditor; //public class KeywordReplacer : UnityEditor.AssetModificationProcessor //{ // public static void OnWillCreateAsset(string path) // { // path = path.Replace("".meta"", """"); // int index = path.LastIndexOf("".""); // string file = path.Substring(index); // if (file != "".cs"" && file != "".js"" && file != "".boo"") return; // index = Application.dataPath.LastIndexOf(""Assets""); // path = Application.dataPath.Substring(0, index) + path; // file = System.IO.File.ReadAllText(path); // file = file.Replace(""#CREATIONDATE#"", System.DateTime.Now + """"); // file = file.Replace(""#PROJECTNAME#"", PlayerSettings.productName); // file = file.Replace(""#SMARTDEVELOPERS#"", PlayerSettings.companyName); // System.IO.File.WriteAllText(path, file); // AssetDatabase.Refresh(); // } //}"; }