public JsonResult JoinSave(JOIN data) { ret = new resultObj(); if (data.content == null) { data.content = ""; //不同物件 需要處理不同的欄位預設值 } if (data.title == null) { data.title = ""; } using (var DB = new MACAUMAMIEntities()) { data.date_modify = DateTime.Now; if (data.id == 0) { data.date_created = DateTime.Now; DB.JOIN.Add(data); } else { var obj = DB.JOIN.Find(data.id); DB.Entry(obj).CurrentValues.SetValues(data); } DB.SaveChanges(); ret.isSuccess = true; ret.data1 = data; } return(Json(ret)); }
internal static HandleRef getCPtrAndSetReference(resultObj obj, object parent) { if (obj != null) { obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
internal static HandleRef getCPtrAndDisown(resultObj obj, object parent) { if (obj != null) { obj.swigCMemOwn = false; obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
static resultObj Loop(string[] _directories) { var ns = XNamespace.Get("http://www.w3.org/2000/svg"); Dictionary <string, Dictionary <string, string[]> > icons = new Dictionary <string, Dictionary <string, string[]> >(StringComparer.Ordinal); int fileCount = 0, folderCount = 0; foreach (var dir in _directories) { folderCount++; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"Current Directory: {dir}"); var currentDict = new Dictionary <string, string[]>(StringComparer.Ordinal); icons[Path.GetFileName(dir)] = currentDict; Console.ForegroundColor = ConsoleColor.Blue; foreach (var file in Directory.GetFiles(dir, "*.svg")) { fileCount++; Console.WriteLine($"Current File: {file}"); var doc = XDocument.Load(file); var className = Path.GetFileNameWithoutExtension(file); var viewBox = doc.Root.Attribute("viewBox").Value; if (!viewBox.StartsWith("0 0 ", StringComparison.Ordinal)) { throw new Exception($"Expecting viewbox to start with '0 0 ' for '{className}'"); } viewBox = viewBox.Substring("0 0 ".Length); var size = viewBox.Split(' '); var path = doc.Root.Element(ns + "path").Attribute("d").Value; var width = int.Parse(size[0], CultureInfo.InvariantCulture); var height = int.Parse(size[1], CultureInfo.InvariantCulture); var ratio = width / height; var ratioClass = ratio == 1f ? "16" : (ratio == 1.25f ? "20" : "14"); currentDict.Add(className, new[] { viewBox, path, Math.Ceiling(width / (double)height * 16d).ToString(CultureInfo.InvariantCulture) }); } } resultObj result = new resultObj { folderCount = folderCount, fileCount = fileCount, icons = icons }; return(result); }
public JsonResult JoinSearch(QueryObj_JOIN q) { ret = new resultObj(); var predicate = PredicateBuilder.New <JOIN>(true); predicate = predicate.And(p => p.lang == q.lang); predicate = predicate.And(p => p.content.Contains(q.keyword) || p.title.Contains(q.title)); using (var DB = new MACAUMAMIEntities()) { var objs = DB.JOIN.Where(predicate).ToList(); //這裡需要分頁功能 if (objs.Count > 0) { ret.isSuccess = true; ret.data1 = objs; ret.data2 = objs.Count; } } return(Json(ret)); }
public JsonResult AboutSearch(QueryObj_ABOUT q) { ret = new resultObj(); var predicate = PredicateBuilder.New <ABOUT>(true); predicate = predicate.And(p => p.lang == q.lang); predicate = predicate.And(p => p.content.Contains(q.keyword)); using (var DB = new MACAUMAMIEntities()) { var objs = DB.ABOUT.Where(predicate).ToList(); if (objs.Count > 0) { ret.isSuccess = true; ret.data1 = objs; ret.data2 = objs.Count; } } return(Json(ret)); }
internal static HandleRef getCPtr(resultObj obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public shapeObj getShape(resultObj record) { IntPtr cPtr = mapscriptPINVOKE.layerObj_getShape(swigCPtr, resultObj.getCPtr(record)); shapeObj ret = (cPtr == IntPtr.Zero) ? null : new shapeObj(cPtr, true, ThisOwn_true()); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }