本文整理汇总了C#中CmsEntities类的典型用法代码示例。如果您正苦于以下问题:C# CmsEntities类的具体用法?C# CmsEntities怎么用?C# CmsEntities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CmsEntities类属于命名空间,在下文中一共展示了CmsEntities类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Fix
public void Fix()
{
CmsEntities cee = new CmsEntities();
List<IssueRelatedIssue> itemsToAdd = new List<IssueRelatedIssue>();
var allRelatedIssues = cee.IssueRelatedIssues.ToList();
foreach (var relatedIssue in allRelatedIssues)
{
var reverseExist = (allRelatedIssues.FirstOrDefault(x => x.RelatedIssueId == relatedIssue.IssueId));
if (reverseExist == null)
{
if (itemsToAdd.FirstOrDefault(x => x.IssueId == relatedIssue.IssueId && x.RelatedIssueId == relatedIssue.RelatedIssueId) == null)
{
itemsToAdd.Add(new IssueRelatedIssue {IssueId = relatedIssue.RelatedIssueId, RelatedIssueId = relatedIssue.IssueId});
}
}
}
if (itemsToAdd.Any())
{
foreach (var issueRelatedIssue in itemsToAdd)
{
cee.IssueRelatedIssues.Add(new IssueRelatedIssue { IssueId = issueRelatedIssue.IssueId, RelatedIssueId = issueRelatedIssue.RelatedIssueId });
}
}
cee.SaveChanges();
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:31,代码来源:FixIssueRelatedIssues.cs
示例2: DeleteIssueApprovalDuplicates
public void DeleteIssueApprovalDuplicates()
{
using (CmsEntities cee = new CmsEntities(120,mConnectCMS))
{
var issues = (from x in cee.Issues orderby x.Id select x).ToList();
foreach (var issue in issues)
{
Console.Out.WriteLine("Processing issue {0}", issue.Id);
var issueApprovals = (from x in cee.IssueApprovals
where x.IssueId == issue.Id
select x);
var duplicates = issueApprovals.GroupBy(x => new { x.IssueId, x.IssueCategoryId })
.Where(g => g.Count() > 1)
.Select(g => g.Key)
.ToList();
foreach (var issueApproval in duplicates)
{
var delete = (from x in cee.IssueApprovals
where x.IssueId == issueApproval.IssueId
&& x.IssueCategoryId == issueApproval.IssueCategoryId
select x).OrderByDescending(x => x.Date).Skip(1).ToList();
delete.ForEach(x => cee.IssueApprovals.Remove(x));
}
}
cee.SaveChanges();
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:35,代码来源:FixCategoriesDuplicates.cs
示例3: TuningPropertiesImporter
public TuningPropertiesImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.TuningProperties.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:7,代码来源:TuningPropertiesImporter.cs
示例4: IssueSystemReferencesImporter
public IssueSystemReferencesImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.SystemReferences.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:7,代码来源:IssueSystemReferencesImporter.cs
示例5: Export
public string Export(int[] pipeIdList, string usersBaseReportingDirectory)
{
if (pipeIdList == null) throw new ArgumentNullException("pipeIdList");
if (String.IsNullOrEmpty(usersBaseReportingDirectory)) throw new ArgumentNullException("usersBaseReportingDirectory");
if (!Directory.Exists(usersBaseReportingDirectory))
{
Directory.CreateDirectory(usersBaseReportingDirectory);
}
using (CmsEntities cee = new CmsEntities())
{
IList<PipeComponent> allPipeComponents = (from x in cee.PipeComponents
.Include("Pipe")
.Include("PipeComponentType")
.Include("PipePropertyValues")
.Include("Pipe.PipeClass")
.Include("Pipe.PipeSize")
.Include("Pipe.PipeFluidCode")
.Include("Pipe.PipeSpecialFeature")
.Include("Pipe.Area")
where pipeIdList.Contains(x.Id)
select x).ToList();
return RunExport(cee, usersBaseReportingDirectory, allPipeComponents);
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:26,代码来源:PipeComponentExporter.cs
示例6: InterlockRiskImporter
public InterlockRiskImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.InterlockRisks.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:7,代码来源:InterlockRiskImporter.cs
示例7: ElectricalImporter
public ElectricalImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.ElectricalEquipments.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:7,代码来源:ElectricalImporter.cs
示例8: Cji5Importer
//private readonly CmsEntities mCee;
public Cji5Importer(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.Financial.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:Cji5Importer.cs
示例9: AddIssueTypeSubType
public DbOperationResult<IssueTypeSubType> AddIssueTypeSubType(IssueType issueType, IssueSubType issueSubType)
{
var result = new DbOperationResult<IssueTypeSubType>();
//guard against duplicate.
using (var cee = new CmsEntities())
{
int k = (from x in cee.IssueTypeSubTypes where x.IssueTypeId == issueType.Id && x.IssueSubTypeId == issueSubType.Id select x.Id).Count();
if (k > 0)
{
result.ServerErrorMessages.Add(string.Format("Insert Failed. An IssueTypeSubType with the combination IssueType Name: '{0}' and Issue SubType Name: '{1}' already exists.", issueType.Name, issueSubType.Name));
return result;
}
var typeSubType = new IssueTypeSubType
{
IssueSubTypeId = issueSubType.Id,
IssueTypeId = issueType.Id,
Ordinal = 0
};
cee.IssueTypeSubTypes.Add(typeSubType);
cee.SaveChanges();
result.EntityResult = typeSubType;
}
return result;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:29,代码来源:CmsWebService.Issue.cs
示例10: AddElectricalComponentTypeProperty
public ElectricalEquipmentComponentTypeProperty AddElectricalComponentTypeProperty(ElectricalEquipmentComponentTypeProperty mecp)
{
using (CmsEntities cee = new CmsEntities())
{
//Check if this component property already exist
ElectricalEquipmentComponentTypeProperty temp = (from x in cee.ElectricalEquipmentComponentTypeProperties
where x.ElectricalEquipmentPropertyId == mecp.ElectricalEquipmentPropertyId &&
x.ElectricalEquipmentComponentTypeId == mecp.ElectricalEquipmentComponentTypeId
select x).FirstOrDefault();
if (temp == null)
{
//Add new Component Type
temp = new ElectricalEquipmentComponentTypeProperty();
temp.ElectricalEquipmentPropertyId = mecp.ElectricalEquipmentPropertyId;
temp.ElectricalEquipmentComponentTypeId = mecp.ElectricalEquipmentComponentTypeId;
temp.Ordinal = mecp.Ordinal;
cee.ElectricalEquipmentComponentTypeProperties.Add(temp);
cee.SaveChanges();
}
else
{
temp.Ordinal = mecp.Ordinal;
cee.SaveChanges();
}
return temp;
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:29,代码来源:CmsWebService.Electrical.cs
示例11: DeleteRole
public DbOperationResult DeleteRole(int roleId)
{
using (CmsEntities cee = new CmsEntities())
{
Role role = (from x in cee.Roles where x.Id == roleId select x).FirstOrDefault();
if (role == null)
{
DbOperationResult result = new DbOperationResult();
result.ServerErrorMessages.Add(string.Format("Cannot find the Role to delete with Id = {0}", role.Id));
return result;
}
cee.Roles.Remove(role);
try
{
cee.SaveChanges();
}
catch (Exception ex)
{
log.Error("", ex, ex.ToString());
DbOperationResult result = new DbOperationResult();
result.ServerErrorMessages.Add(ex.Message);
return result;
}
}
return new DbOperationResult();
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:31,代码来源:CmsWebService.Security.cs
示例12: MobilePlantComponentImporter
public MobilePlantComponentImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.Components.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:7,代码来源:MobilePlantComponentImporter.cs
示例13: SaveIssueFiles
public DbOperationResult SaveIssueFiles(List<IssueFile> issueFiles)
{
try
{
using (var cee = new CmsEntities())
{
foreach (IssueFile attachment in issueFiles)
{
IssueFile existingAttachment = (from x in cee.IssueFiles
where x.Filename == attachment.Filename &&
x.Path == attachment.Path
select x).FirstOrDefault();
if (existingAttachment != null)
{
existingAttachment.Description = attachment.Description;
}
else
{
attachment.User = null;
attachment.Issue = null;
attachment.AttachmentType = null;
cee.IssueFiles.Add(attachment);
}
}
cee.SaveChanges();
}
}
catch (Exception ex)
{
return new DbOperationResult { ServerErrorMessages = new List<string> { ex.Message } };
}
return new DbOperationResult();
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:35,代码来源:CmsEmailCorrespondenceSaver.cs
示例14: Migrate
public void Migrate()
{
using (CmsEntities cee = new CmsEntities(120,mConnectCMS))
{
//var issues = (from x in cee.Issues orderby x.Id
// where
// x.TimeToImplement.HasValue
// || x.TimeToTest.HasValue
// || x.TimeToDocument.HasValue
// || x.ActualTimeImplement.HasValue
// || x.ActualTimeTest.HasValue
// || x.ActualTimeDocument.HasValue
// || x.Budgeted.HasValue
// || x.FundingType != null
// || x.EstimateScope.HasValue
// || x.ActualScope.HasValue
// || x.EstimateDesign.HasValue
// || x.ActualDesign.HasValue
// || x.HasScope.HasValue
// || x.HasDesign.HasValue
// || x.HasScopeUserId.HasValue
// || x.HasDesignUserId.HasValue
// || x.EstimatedCost.HasValue
// || x.Effort.HasValue
// || x.Reward.HasValue
// select x).ToList();
//foreach (var issue in issues)
//{
// Console.Out.WriteLine("Processing issue {0}", issue.Id);
// if (issue.IssueTracking == null)
// {
// issue.IssueTracking = new IssueTracking();
// }
// issue.IssueTracking.ImplementedEstimate = issue.TimeToImplement;
// issue.IssueTracking.TestedEstimate = issue.TimeToTest;
// issue.IssueTracking.DocumentedEstimate = issue.TimeToDocument;
// issue.IssueTracking.ImplementedActual = issue.ActualTimeImplement;
// issue.IssueTracking.TestedActual = issue.ActualTimeTest;
// issue.IssueTracking.DocumentedActual = issue.ActualTimeDocument;
// issue.IssueTracking.Budgeted = issue.Budgeted;
// issue.IssueTracking.FundingType = issue.FundingType;
// issue.IssueTracking.ScopedEstimate = issue.EstimateScope;
// issue.IssueTracking.ScopedActual = issue.ActualScope;
// issue.IssueTracking.PeerReviewEstimate = issue.EstimateDesign;
// issue.IssueTracking.PeerReviewActual = issue.ActualDesign;
// issue.IssueTracking.Scoped = issue.HasScope.HasValue && issue.HasScope.Value;
// issue.IssueTracking.PeerReviewed = issue.HasDesign.HasValue && issue.HasDesign.Value;
// issue.IssueTracking.ScopedUserId = issue.HasScopeUserId;
// issue.IssueTracking.PeerReviewedUserId = issue.HasDesignUserId;
// issue.IssueTracking.EstimatedCost = issue.EstimatedCost;
// issue.IssueTracking.Effort = issue.Effort;
// issue.IssueTracking.Return = issue.Reward;
//}
//cee.SaveChanges();
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:59,代码来源:TrackingMigrator.cs
示例15: GetAppSettingValue
public static string GetAppSettingValue(CommonUtils.AppSettingKey keyIn)
{
using (CmsEntities cee = new CmsEntities())
{
string keyInText = keyIn.ToString();
return (from x in cee.AppSettings where string.Compare(keyInText, x.Key, StringComparison.OrdinalIgnoreCase) == 0 select x.Value).FirstOrDefault();
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:Common.cs
示例16: PipeComponentImporter
public PipeComponentImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.Components.ToString();
Cee = new CmsEntities();
//mCee.CommandTimeout = 5000;
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:PipeComponentImporter.cs
示例17: GetAttachmentType
private static AttachmentType GetAttachmentType()
{
using (var cee = new CmsEntities())
{
var attachmentType = (from x in cee.AttachmentTypes where x.Code.Equals("Correspondence", StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
return attachmentType;
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:Program.cs
示例18: PipeImporter
public PipeImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.Pipes.ToString();
Cee = new CmsEntities();
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:PipeImporter.cs
示例19: DocumentEquipmentImporter
//private readonly CmsEntities mCee;
public DocumentEquipmentImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.RelatedEquipment.ToString();
//mCee = new CmsEntities(5000);
Cee = new CmsEntities();
//mCee.CommandTimeout = 5000;
Cee.Configuration.LazyLoadingEnabled = false;
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:10,代码来源:DocumentEquipmentImporter.cs
示例20: AuthenticateUser
/// <summary>
/// Authenticate a user
/// </summary>
/// <returns></returns>
public User AuthenticateUser(string username, string password, bool isDomainUser, string assemblyFileVersion)
{
using (CmsEntities cee = new CmsEntities())
{
User user;
if (isDomainUser)
{
user = (from x in cee.Users.Include("Role").Include("Role.RolePrivileges").Include("Role.RolePrivileges.Privilege").Include("Role.RolePrivileges.SecurityObject")
.Include("UserPreference").Include("Role.RoleApprovalCategories")
where x.UserName.ToLower() == username &&
x.ActiveUser
select x).FirstOrDefault();
if (user == null)
{
user = (from x in cee.Users.Include("Role").Include("Role.RolePrivileges").Include("Role.RolePrivileges.Privilege").Include("Role.RolePrivileges.SecurityObject")
.Include("UserPreference").Include("Role.RoleApprovalCategories")
where x.UserName.ToLower() == "guest" &&
x.ActiveUser
select x).FirstOrDefault();
}
}
else
{
user = (from x in cee.Users.Include("Role").Include("Role.RolePrivileges").Include("Role.RolePrivileges.Privilege").Include("Role.RolePrivileges.SecurityObject")
.Include("UserPreference").Include("Role.RoleApprovalCategories")
where x.UserName.ToLower() == username &&
x.Password == password &&
x.ActiveUser
select x).FirstOrDefault();
}
if (user != null && user.UserPreference == null)
{
//Created new default preference
user.UserPreference = new UserPreference();
user.UserPreference.SummaryTabsExpanded = true;
user.UserPreference.ShowDocumentPreview = true;
const int Width = 315;
user.UserPreference.IssuePanelWidth = Width;
user.UserPreference.ControlPanelWidth = Width;
user.UserPreference.ElectricalPanelWidth = Width;
user.UserPreference.InstrumentPanelWidth = Width;
user.UserPreference.MechanicalPanelWidth = Width;
user.UserPreference.MobilePanelWidth = Width;
user.UserPreference.PipePanelWidth = Width;
user.UserPreference.DocumentPanelWidth = 630;
user.UserPreference.AdminPanelWidth = Width;
}
CheckClientServerVersions(user, assemblyFileVersion);
return user;
}
}
开发者ID:barrett2474,项目名称:CMS2,代码行数:61,代码来源:CmsWebService.Security.cs
注:本文中的CmsEntities类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论