本文整理汇总了C#中SessionFactory.Find方法的典型用法代码示例。如果您正苦于以下问题:C# SessionFactory.Find方法的具体用法?C# SessionFactory.Find怎么用?C# SessionFactory.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionFactory
的用法示例。
在下文中一共展示了SessionFactory.Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public ActionResult Delete(FormCollection collection, long[] ids)
{
if (ids.Length == 0)
{
FlashWarn("请选择要删除的记录。");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
session.BeginTransaction();
var models = session.Find<TrainNotice>(m => m.Id.In(ids));
if (models.Count == 0)
{
FlashInfo("你没有选择任何可以删除的培训通知。");
return Close();
}
var notices = string.Join(", ", models.Select(m => m.Title));
if (models.Any(model => !session.Delete(model)))
{
session.Rollback();
FlashError("删除培训通知{0}失败!", notices);
return View(models);
}
session.Commit();
FlashSuccess("删除培训通知{0}成功!", notices);
return Close();
}
}
示例2: Delete
public ActionResult Delete(long[] ids, long id = 0)
{
if (ids.Length == 0)
{
FlashInfo("请选择要删除的记录。");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
var models = session.Find<PunishmentDossierFiles>(m => m.Id.In(ids));
if (models.Count == 0)
{
FlashInfo("你没有选择任何可以删除的记录。");
return Close();
}
if (models.Any(m => !m.CreatedBy.Equals(CurrentAccountNo)))
{
FlashInfo("你不是创建人,不能删除{0}", string.Join(",", models.Where(m => !m.CreatedBy.Equals(CurrentAccountNo)).Select(m => m.FileName)));
return Close();
}
var contract = session.Load<PunishmentDossier>(id);
if (contract == null)
{
FlashWarn("材料未找到,请联系管理员!");
return Close();
}
if (!IsEditAble(contract))
{
FlashInfo("材料已经提交,相关文件不能删除!");
return Close();
}
return View(models);
}
}
示例3: Delete
public ActionResult Delete(FormCollection collection, long[] ids)
{
if (ids.Length == 0)
{
FlashWarn("请选择要删除的记录。");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
session.BeginTransaction();
var models = session.Find<TrainManagement>(m => m.Id.In(ids));
if (models.Count == 0)
{
FlashInfo("你没有选择任何可以删除的记录。");
return Close();
}
var displays = string.Join(", ", models.Select(m => string.Concat(m.Id)));
if (session.Delete<TrainManagement>(m => m.Id.In(ids)))
{
session.Commit();
FlashSuccess("删除记录{0}成功!", displays);
return Close();
}
session.Rollback();
FlashError("删除记录{0}失败!", displays);
return View(models);
}
}
示例4: Active
public ActionResult Active(FormCollection collection, long[] ids)
{
if (ids.Length == 0)
{
FlashWarn("请选择要激活的用户。");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
session.BeginTransaction();
var models = session.Find<User>(m => m.Id.In(ids) && !m.IsActive);
if (models.Count == 0)
{
FlashInfo("你没有选择任何需要激活的用户。");
return Close();
}
foreach (User model in models)
{
if (!model.Active(session, CurrentAccountNo))
{
session.Rollback();
FlashError("账户激活失败!");
return Close();
}
}
session.Commit();
FlashSuccess("账户激活成功");
return Close();
}
}
示例5: AnalysisByYear
public ActionResult AnalysisByYear(FormCollection collection)
{
using (var session = new SessionFactory().OpenSession())
{
var contractList = session.Find<Contract>();
var dossierList = session.Find<Dossier>();
var punishmentDossierList = session.Find<PunishmentDossier>();
var recordList = session.Find<Record>();
var startYear = contractList.Min(m => m.Time).Year;
var endYear = contractList.Max(m => m.Time).Year;
var list = new List<Analysis>();
return View(list);
}
}
示例6: Edit
public ActionResult Edit(long[] ids)
{
using (var session = new SessionFactory().OpenSession())
{
var model = session.Load<TrainManagementItem>(ids[0]);
if (model.ExamStatus != null && !model.ExamStatus.Equals(ExamStatusConst.未考试))
{
FlashWarn("您已经完成该考试!");
return Close();
}
var q = new Criteria<Exam>(session)
.AndIn<TrainManagementItem>(m => m.TrainManId, n => n.TrainManId, n => n.Id == ids[0]);
var exam = q.Load();
if (exam == null)
{
FlashWarn("考试不存在!请联系管理员!");
return Close();
}
var models = session.Find<Question>(m => m.ExamId == exam.Id);
if (models == null || !models.Any())
{
FlashWarn("考试题目未设置!");
return Close();
}
Response.Write(string.Format("<script>window.open('Exam?ids={0}','_blank')</script>", ids[0]));
return Close();
}
}
示例7: BrandList
public static SelectList BrandList()
{
Session ds = new SessionFactory().OpenSession();
IList<SupplierBrand> d = ds.Find<SupplierBrand>();
var item = new SupplierBrand {Id = 0, Brand = "无"};
d.Add(item);
return new SelectList(d, "Id", "Brand");
}
示例8: SupplierList
public static SelectList SupplierList()
{
Session ds = new SessionFactory().OpenSession();
IList<Supplier> d = ds.Find<Supplier>();
var item = new Supplier {Id = 0, Name = "无"};
d.Add(item);
return new SelectList(d, "Id", "Name");
}
示例9: RoleList
public static SelectList RoleList()
{
var ds = new SessionFactory().OpenSession();
var d = ds.Find<Role>();
var item = new Role() { Id = 0, Name = "无" };
d.Add(item);
return new SelectList(d, "Id", "Name");
}
示例10: OrganizationList
public static SelectList OrganizationList()
{
Session ds = new SessionFactory().OpenSession();
IList<Organization> d = ds.Find<Organization>();
var item = new Organization {Id = 0, Name = "无"};
d.Add(item);
return new SelectList(d, "Id", "Name");
}
示例11: AnalysisByMonth
public ActionResult AnalysisByMonth(FormCollection collection)
{
using (var session = new SessionFactory().OpenSession())
{
var year = (collection["year"] + string.Empty).Trim().TryToInt();
if (!year.HasValue)
{
FlashWarn("年份有误,请选择年份!");
return Close();
}
var contractList = session.Find<Contract>();
var dossierList = session.Find<Dossier>();
var punishmentDossierList = session.Find<PunishmentDossier>();
var recordList = session.Find<Record>();
var list = new List<Analysis>();
for (int i = 1; i < 13; i++)
{
var item = new Analysis
{
Month = i + "月",
ContractNo = contractList.Count(m => m.Time.Year == year && m.Time.Month == i),
DossierNo = dossierList.Count(m => m.Time.Year == year && m.Time.Month == i),
PunishmentDossier = punishmentDossierList.Count(m => m.Time.Year == year && m.Time.Month == i),
RecordNo = recordList.Count(m => m.Time.Year == year && m.Time.Month == i)
};
list.Add(item);
}
var total =
new Analysis
{
Month = "合计",
ContractNo = contractList.Count(m => m.Time.Year == year),
DossierNo = dossierList.Count(m => m.Time.Year == year),
PunishmentDossier = punishmentDossierList.Count(m => m.Time.Year == year),
RecordNo = recordList.Count(m => m.Time.Year == year)
};
list.Add(total);
return View(list);
}
}
示例12: Exam
public ActionResult Exam(FormCollection collection, long[] ids)
{
if (ids.Length == 0)
{
FlashWarn("考试不存在!请联系管理员!");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
session.BeginTransaction();
var models = session.Find<ExamAnswer>(m => m.TrainManagementItemId == ids[0]);
if (models == null || !models.Any())
{
FlashWarn("用户答题记录不在在!请联系管理员!");
return Close();
}
var trainManagementItem = session.Load<TrainManagementItem>(ids[0]);
if (trainManagementItem == null)
{
FlashWarn("用户答题记录不在在!请联系管理员!");
return Close();
}
trainManagementItem.ExamScore = 0;
foreach (var question in models)
{
var score = GetDbQueryPara(question.Id + "");
try
{
question.Score = score==null||score.Equals("")?0:Decimal.Parse(score);
trainManagementItem.ExamScore += question.Score;
}
catch (Exception)
{
FlashError("评分输入错误!");
return Close();
}
}
trainManagementItem.ExamStatus = ExamStatusConst.已评阅;
trainManagementItem.UpdatedAt = DateTime.Now;
trainManagementItem.UpdatedBy = "SYSTEM";
if (session.Update(trainManagementItem) && session.Update(models))
{
session.Commit();
Response.Write("<script>window.close()</script>");
return Close();
}
session.Rollback();
FlashError("提交试卷不成功,请联系管理员!");
return View(models);
}
}
示例13: AnalysisByMonth
public ActionResult AnalysisByMonth(FormCollection collection)
{
using (var session = new SessionFactory().OpenSession())
{
var year = (collection["year"] + string.Empty).Trim().TryToInt();
if (!year.HasValue)
{
FlashWarn("年份有误,请选择年份!");
return Close();
}
var contractList = session.Find<Contract>();
var dossierList = session.Find<Dossier>();
var punishmentDossierList = session.Find<PunishmentDossier>();
var recordList = session.Find<Record>();
var list = new List<Analysis>();
return View(list);
}
}
示例14: Delete
public ActionResult Delete(long[] ids)
{
if (ids.Length == 0)
{
FlashWarn("请选择要删除的记录。");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
ViewData.Model = session.Find<SchoolDepartment>(m => m.Id.In(ids));
return View();
}
}
示例15: AnalysisByYear
public ActionResult AnalysisByYear(FormCollection collection)
{
using (var session = new SessionFactory().OpenSession())
{
var contractList = session.Find<Contract>();
var dossierList = session.Find<Dossier>();
var punishmentDossierList = session.Find<PunishmentDossier>();
var recordList = session.Find<Record>();
var startYear = contractList.Min(m => m.Time).Year;
var endYear = contractList.Max(m => m.Time).Year;
var list = new List<Analysis>();
for (int i = startYear; i <= endYear; i++)
{
var item = new Analysis
{
Year = i + "年",
ContractNo = contractList.Count(m => m.Time.Year == i),
DossierNo = dossierList.Count(m => m.Time.Year == i),
PunishmentDossier = punishmentDossierList.Count(m => m.Time.Year == i),
RecordNo = recordList.Count(m => m.Time.Year == i)
};
list.Add(item);
}
var total =
new Analysis
{
Year = "合计",
ContractNo = contractList.Count(),
DossierNo = dossierList.Count(),
PunishmentDossier = punishmentDossierList.Count(),
RecordNo = recordList.Count()
};
list.Add(total);
return View(list);
}
}