本文整理汇总了C#中BusinessContext.SetResponse方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessContext.SetResponse方法的具体用法?C# BusinessContext.SetResponse怎么用?C# BusinessContext.SetResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusinessContext
的用法示例。
在下文中一共展示了BusinessContext.SetResponse方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloseAssignment
/// <summary>
/// Closes the assignment.
/// </summary>
/// <param name="context">The context.</param>
protected virtual void CloseAssignment(BusinessContext context)
{
CloseAssignmentRequest request = (CloseAssignmentRequest)context.Request;
// Load Assignment
MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Active)
throw new InvalidOperationException();
DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);
// Update Meta Object Fields
metaObject[AssignmentEntity.FieldClosedBy] = (int)DataContext.Current.CurrentUserId;
metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Closed;
metaObject[AssignmentEntity.FieldExecutionResult] = request.ExecutionResult;
metaObject[AssignmentEntity.FieldComment] = request.Comment;
metaObject[AssignmentEntity.FieldActualFinishDate] = dateTimeNow;
// Save Meta Object
metaObject.Save();
if (metaObject[AssignmentEntity.FieldWorkflowInstanceId]!=null)
{
// Run Workflow
AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
RunWorkflow(entity);
}
context.SetResponse(new Response());
}
示例2: Delete
/// <summary>
/// Deletes the specified context.
/// </summary>
/// <param name="context">The context.</param>
protected override void Delete(BusinessContext context)
{
// OZ: Comment base logic and call custom business logic ListManager.DeleteList
//base.Delete(context);
ListManager.DeleteList((int)context.GetTargetPrimaryKeyId().Value);
context.SetResponse(new Response());
}
示例3: Create
/// <summary>
/// Creates the specified context.
/// </summary>
/// <param name="context">The context.</param>
protected override void Create(BusinessContext context)
{
CustomizationProfileUserEntity newEntity = (CustomizationProfileUserEntity)context.Request.Target;
if (newEntity.ProfileId > 0)
{
base.Create(context);
}
else // for default profile we don't need to create a new record
{
context.SetResponse(new CreateResponse(PrimaryKeyId.Empty));
}
}
示例4: CustomMethod
protected override void CustomMethod(BusinessContext context)
{
switch (context.Request.Method)
{
case ReportRequestMethod.GetReportData:
context.SetResponse(GetReportData(context.Request));
break;
default:
base.CustomMethod(context);
break;
}
}
示例5: CustomMethod
protected override void CustomMethod(BusinessContext context)
{
switch (context.Request.Method)
{
case ChangeTrackingMethod.METHOD_NAME:
context.SetResponse(ChangeTrackingMethod.ChangeTracking(context.Request as ChangeTrackingRequest));
break;
default:
base.CustomMethod(context);
break;
}
base.CustomMethod(context);
}
示例6: Create
protected override void Create(BusinessContext context)
{
CreateRequest createRequest = context.Request as CreateRequest;
bool forceBase = createRequest.Parameters.GetValue<bool>(EventHelper.FORCE_BASE_PARAM, false);
if (!forceBase)
{
CreateResponse response = Mediachase.Ibn.Events.CustomMethods.EventHelper.CreateResourceRequestHandle(createRequest);
context.SetResponse(response);
}
else
{
base.Create(context);
}
}
示例7: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public void Execute(BusinessContext context)
{
switch (context.GetMethod())
{
case RequestMethod.Load:
if (context.GetTargetPrimaryKeyId().HasValue)
{
EntityObject item = LoadEntityObject(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);
if (item != null)
{
LoadResponse response = new LoadResponse(item);
context.SetResponse(response);
}
}
break;
case RequestMethod.List:
{
// Filters Not Implemented
ListResponse response = context.Response as ListResponse;
if (response != null)
{
EntityObject[] items = LoadEntityObjects(context.GetTargetMetaClassName(), ((ListRequest)context.Request).Filters);
if (items.Length > 0)
{
List<EntityObject> newArray = new List<EntityObject>(response.EntityObjects.Length + items.Length);
newArray.AddRange(response.EntityObjects);
newArray.AddRange(items);
// TODO: Sorting Not Implemented
response.EntityObjects = newArray.ToArray();
}
}
}
break;
}
}
示例8: UpdateState
/// <summary>
/// Customs the method.
/// </summary>
/// <param name="context">The context.</param>
protected virtual void UpdateState(BusinessContext context)
{
// Load Meta Object
MetaObject metaObject = MetaObjectActivator.CreateInstance(DocumentContentVersionEntity.GetAssignedMetaClassName(),
context.GetTargetPrimaryKeyId().Value);
// Extract old and new states
DocumentContentVersionState newState = (DocumentContentVersionState)(int)context.Request.Target["State"];
DocumentContentVersionState oldState = (DocumentContentVersionState)(int)metaObject["State"];
if (oldState == newState)
return;
BusinessContext.Current.Items["MC_Document_SourceMetaObject"] = metaObject;
BusinessContext.Current.Items["MC_Document_NewState"] = newState;
BusinessContext.Current.Items["MC_Document_OldState"] = oldState;
// Pre-Process
switch(oldState)
{
case DocumentContentVersionState.Active:
{
// Reset Content Reference to Active Document here
DocumentEntity document = (DocumentEntity)BusinessManager.Load(DocumentEntity.GetAssignedMetaClassName(), (PrimaryKeyId)metaObject["OwnerDocumentId"]);
document.ActiveVersionId = null;
BusinessManager.Update(document);
}
break;
case DocumentContentVersionState.Draft:
// Nothing
break;
case DocumentContentVersionState.Obsolete:
// Nothing
break;
}
// Process
switch(newState)
{
case DocumentContentVersionState.Active:
{
DocumentEntity document = (DocumentEntity)BusinessManager.Load(DocumentEntity.GetAssignedMetaClassName(), (PrimaryKeyId)metaObject["OwnerDocumentId"]);
// Reset Current Reference to Active Document here
if (document.ActiveVersionId.HasValue)
{
DocumentContentVersionEntity oldVersion = new DocumentContentVersionEntity(document.ActiveVersionId.Value);
oldVersion.State = (int)DocumentContentVersionState.Draft;
UpdateStateRequest request = new UpdateStateRequest(oldVersion);
BusinessManager.Execute(request);
}
// Update Current Reference to Active Document here
document.ActiveVersionId = context.GetTargetPrimaryKeyId();
BusinessManager.Update(document);
}
break;
case DocumentContentVersionState.Draft:
break;
case DocumentContentVersionState.Obsolete:
break;
}
// Update Data Storage And Save
metaObject["State"] = (int)newState;
metaObject.Save();
context.SetResponse(new Response());
}
示例9: SetDefaultAddress
/// <summary>
/// Customs the method.
/// </summary>
/// <param name="context">The context.</param>
protected virtual void SetDefaultAddress(BusinessContext context)
{
// Load Address
MetaObject newDefaultAddress = MetaObjectActivator.CreateInstance(AddressEntity.GetAssignedMetaClassName(),
context.GetTargetPrimaryKeyId().Value);
if (newDefaultAddress["ContactId"] != null)
{
// Find default addresses
MetaObject[] defaultAddressList = MetaObject.List(DataContext.Current.GetMetaClass(AddressEntity.GetAssignedMetaClassName()),
FilterElement.EqualElement("ContactId", newDefaultAddress["ContactId"]),
FilterElement.EqualElement("IsDefaultContactElement", true));
// Reset default addresses
foreach (MetaObject defaultAddress in defaultAddressList)
{
defaultAddress["IsDefaultContactElement"] = false;
defaultAddress.Save();
}
// Set default address
newDefaultAddress["IsDefaultContactElement"] = true;
newDefaultAddress.Save();
}
else if (newDefaultAddress["OrganizationId"] != null)
{
// Find default addresses
MetaObject[] defaultAddressList = MetaObject.List(DataContext.Current.GetMetaClass(AddressEntity.GetAssignedMetaClassName()),
FilterElement.EqualElement("OrganizationId", newDefaultAddress["OrganizationId"]),
FilterElement.EqualElement("IsDefaultOrganizationElement", true));
// Reset default addresses
foreach (MetaObject defaultAddress in defaultAddressList)
{
defaultAddress["IsDefaultOrganizationElement"] = false;
defaultAddress.Save();
}
// Set default address
newDefaultAddress["IsDefaultOrganizationElement"] = true;
newDefaultAddress.Save();
}
context.SetResponse(new Response());
}
示例10: SuspendAssignment
/// <summary>
/// Suspends the assignment.
/// </summary>
/// <param name="context">The context.</param>
private void SuspendAssignment(BusinessContext context)
{
// Load Assignment
MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Active)
throw new InvalidOperationException();
// Load Meta Object
metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Suspended;
// Save Meta Object
metaObject.Save();
if (metaObject[AssignmentEntity.FieldWorkflowInstanceId] != null)
{
// Run Workflow
AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
RunWorkflow(entity);
}
context.SetResponse(new Response());
}
示例11: Reactivate
private void Reactivate(BusinessContext context)
{
// Load Assignment
MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Closed)
throw new InvalidOperationException();
// Load Meta Object
metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Active;
metaObject[AssignmentEntity.FieldActualFinishDate] = null;
metaObject[AssignmentEntity.FieldActualWork] = null;
// Save Meta Object
metaObject.Save();
//if (entity.WorkflowInstanceId.HasValue)
//{
// // Run Workflow
// RunWorkflow(entity);
//}
context.SetResponse(new Response());
}
示例12: ActivateAssignment
/// <summary>
/// Activates the assignment.
/// </summary>
/// <param name="context">The context.</param>
private void ActivateAssignment(BusinessContext context)
{
// Load Assignment
MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Pending)
throw new InvalidOperationException();
// Load Meta Object
DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);
metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Active;
metaObject[AssignmentEntity.FieldActualStartDate] = dateTimeNow;
// Save Meta Object
metaObject.Save();
//if (entity.WorkflowInstanceId.HasValue)
//{
// // Run Workflow
// RunWorkflow(entity);
//}
context.SetResponse(new Response());
}
示例13: InitializeMappingDocument
/// <summary>
/// Initializes the mapping document.
/// </summary>
/// <param name="context">The context.</param>
protected override void InitializeMappingDocument(BusinessContext context)
{
InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request);
MetaClass metaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName());
List<PrimaryKeyId> primaryKeyIds = new List<PrimaryKeyId>();
// Create Default Mapping
MappingDocument retVal = new MappingDocument();
DataTable dataTable = request.Data.Tables[request.TableIndex];
MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name);
retVal.Add(mapping);
MappingElementBuilder builder = new MappingElementBuilder(retVal);
//Call creation mapping document by saved patterns
DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder);
// Write Response
InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse();
response.MappingDocument = retVal;
context.SetResponse(response);
}