本文整理汇总了C#中DataModel.Save方法的典型用法代码示例。如果您正苦于以下问题:C# DataModel.Save方法的具体用法?C# DataModel.Save怎么用?C# DataModel.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadDataModel
private static string ReadDataModel(XmlNode node, Content content)
{
try
{
if (node.Name == "DataModel")
{
string val = NodeGetString(node, Constants.GENERATOR_VALUE);
Field field = (Field)NodeGetObject(node, Constants.GENERATOR_FIELDCODE, fields);
DataModel dm = new DataModel(content, field, val);
dm.Save();
System.Console.WriteLine ("DataModel: " + content.Category.Code);
foreach (XmlNode n in node.ChildNodes)
{
if (n.Name == "Value")
{
dm.Value = n.InnerText;
dm.Save();
}
}
foreach (XmlNode n in node.ChildNodes)
{
if (n.Name == "File")
{
dm.Value = ReadFile(n).ToString();
dm.Save();
}
}
}
return null;
}
catch(System.FormatException)
{
return "No se pudo leeer columna ordering";
}
}
示例2: SaveCopiedContent
public void SaveCopiedContent (int contentId, int categoryId, int languageId)
{
Category category = Category.Find(categoryId);
CheckPermissions(category, Permission.Modify);
if (category == null)
{
Flash["error"] = "Categoria padre inexistente";
RedirectToAction(Constants.CATEGORIES);
return;
}
Content originalContent = Content.Find(contentId);
Content content = new Content(category);
content.Lang = Language.Find(languageId);
if (content.Lang == null)
{
logger.Error("language is null!!!: " + languageId);
return;
}
content.Save(); // Get an Id
if (originalContent != null)
{
foreach(string key in originalContent.DataHash.Keys) // duplicate content
{
DataModel originalDataModel = (DataModel)originalContent.DataHash[key];
DataModel copyDataModel = new DataModel(content, originalDataModel.Field,
originalDataModel.Value);
content.DataHash[key] = copyDataModel;
copyDataModel.Save();
}
content.Save();
}
//contentId = content.Id;
// Read form inputs and attached files
bool emptyForm = true;
if (Request.Form.Count > 0 || Request.Files.Count > 0)
{
foreach (string input in Request.Form)
{
DataModel data;
if (content.DataHash != null && content.DataHash.Contains(input))
{
data = (DataModel) content.DataHash[input];
data.Value = Request.Form[input];
}
else
{
Field field = Field.GetByName(input);
if (field == null)
continue; // invalid field name
data = new DataModel(content, field, Request.Form[input]);
}
data.Save();
emptyForm = false;
}
foreach (string input in Request.Files.Keys)
{
DataModel data;
System.Web.HttpPostedFile postedFile = Request.Files[input] as System.Web.HttpPostedFile;
if ((postedFile == null) || (postedFile.FileName.Length == 0) ||
(postedFile.ContentLength == 0))
{
logger.Debug("File not uploaded");
continue;
}
else if (content.DataHash != null && content.DataHash.Contains(input))
{
data = (DataModel) content.DataHash[input];
File oldfile = (File) data.GetObjectFromValue();
File file = new File( config.GetValue(Constants.MEDIA_FOLDER));
file.SaveAttach(postedFile);
data.Value = file.Id.ToString();
oldfile.RemoveAttach();
}
else
{
Field field = Field.GetByName(input);
if (field == null)
continue;
File file = new File(config.GetValue(Constants.MEDIA_FOLDER));
file.SaveAttach(postedFile);
data = new DataModel(content, field, file.Id.ToString());
#if CACHE
content.DataHash[input] = data; // force update cache
#endif
}
data.Save();
emptyForm = false;
}
if (emptyForm)
{
content.Delete();
}
else
{
bool isNew = true;
foreach (Content c in category.ContentList)
if (c.Id == content.Id)
isNew = false;
if (isNew)
//.........这里部分代码省略.........
示例3: ReadContent
private static string ReadContent(XmlNode node, Category c)
{
string keys = NodeGetString(node, "keys");
string vals = NodeGetString(node, "vals");
string[] colname = keys.Split(',');
string[] namedescr = vals.Split(',');
int l = colname.Length;
Field [] f = new Field[l];
for (int i=0; i<l; i++)
f[i] = Field.GetByName(colname[i]);
Content r = new Content(c);
r.Save();
for (int i=0; i<l; i++)
{
DataModel d = new DataModel(r, f[i], namedescr[i]);
d.Save();
}
return null;
}