本文整理汇总了C#中CodeActivityContext类的典型用法代码示例。如果您正苦于以下问题:C# CodeActivityContext类的具体用法?C# CodeActivityContext怎么用?C# CodeActivityContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeActivityContext类属于命名空间,在下文中一共展示了CodeActivityContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Processes the conversion of the version number
/// </summary>
/// <param name="context"></param>
protected override void Execute(CodeActivityContext context)
{
// Get the values passed in
var versionPattern = context.GetValue(VersionPattern);
var buildNumber = context.GetValue(BuildNumber);
var buildNumberPrefix = context.GetValue(BuildNumberPrefix);
var version = new StringBuilder();
var addDot = false;
// Validate the version pattern
if (string.IsNullOrEmpty(versionPattern))
{
throw new ArgumentException("VersionPattern must contain the versioning pattern.");
}
var versionPatternArray = versionPattern.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
// Go through each pattern and convert it
foreach (var conversionItem in versionPatternArray)
{
if (addDot) { version.Append("."); }
version.Append(VersioningHelper.ReplacePatternWithValue(conversionItem, buildNumber, buildNumberPrefix, DateTime.Now));
addDot = true;
}
// Return the value back to the workflow
context.SetValue(ConvertedVersionNumber, version.ToString());
}
示例2: Execute
// 如果活动返回值,则从 CodeActivity<TResult>
// 派生并从 Execute 方法返回该值。
protected override void Execute(CodeActivityContext context)
{
// 获取 Text 输入参数的运行时值
ReviewCheck ReviewCheck = ReviewChecks.Get(context);
DocumentApply documentApply = inApply.Get(context);
if (ReviewCheck.Agree == 1)
{
if (inApply.Get(context).IsNeed)
{
documentApply.Status = 4;
}
else
{
documentApply.Status = 5;
}
}
else
{
documentApply.Status = 6;
}
new YunShanOA.BusinessLogic.DocumentManager.DocumentManager().Save(documentApply);
outApply.Set(context, documentApply);
}
示例3: Execute
protected override void Execute(CodeActivityContext context)
{
try
{
Guid FlowInstranceID = context.WorkflowInstanceId;
DebugStatus debug = new DebugStatus();
if (debug.status == 0)
{
string result = s.Get(context);
if (result == "true")
{
//TODO Change the step.
//BLL.Document.DocumentEndStep(FlowInstranceID, "1");
}
else
{
//BLL.Document.DocumentEndStep(FlowInstranceID, "2");
}
}
}
catch//(Exception e)
{
//执行出错
}
}
示例4: Execute
protected override void Execute(CodeActivityContext context)
{
bool hire = Hire.Get(context);
ApplicantResume resume = Resume.Get(context);
string baseURI = WebConfigurationManager.AppSettings["BaseURI"];
if (string.IsNullOrEmpty(baseURI))
throw new InvalidOperationException("No baseURI appSetting found in web.config");
string htmlMailText;
if (hire)
{
htmlMailText = string.Format(ServiceResources.GenericMailTemplate,
ServiceResources.HireHeading,
string.Format(ServiceResources.OfferText, resume.Name),baseURI);
}
else
{
htmlMailText = string.Format(ServiceResources.GenericMailTemplate,
ServiceResources.NoHireHeading,
string.Format(ServiceResources.NoHireText, resume.Name), baseURI);
}
SmtpClient smtpClient = new SmtpClient();
MailMessage msg = new MailMessage("[email protected]", resume.Email,
string.Format(ServiceResources.ApplicationMailSubject), htmlMailText);
msg.IsBodyHtml = true;
smtpClient.Send(msg);
}
示例5: Execute
protected override void Execute(CodeActivityContext executionContext)
{
//Create the tracing service
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
//Create the context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
Entity entity = null;
var inputs = context.InputParameters;
if (context.InputParameters.Contains("target"))
entity = (Entity)context.InputParameters["target"];
if (entity == null)
return;
DocLogic logic = new DocLogic(service);
LoadDocParametersFactory loadDocParametersFactory = null;
var subject = Subject.Get(executionContext);
switch (entity.LogicalName)
{
case "opportunity":
loadDocParametersFactory = new OpportunityParametersFactory(service, entity, subject);
break;
case "new_order":
loadDocParametersFactory = new OrderParametersFactory(service, entity, subject);
break;
default:
loadDocParametersFactory = null;
break;
}
logic.Excute(loadDocParametersFactory);
}
示例6: Execute
/// <summary>
/// You need to put this activity in a different agent that write the diagnostics log that you want to change.
/// </summary>
/// <param name="context"></param>
protected override void Execute(CodeActivityContext context)
{
Thread.Sleep(30000);
var findAndReplace = context.GetValue(FindAndReplaceStrings);
_teamProjectUri = context.GetValue(TeamProjectUri);
_buildUri = context.GetValue(BuildUri);
var vssCredential = new VssCredentials(true);
_fcClient = new FileContainerHttpClient(_teamProjectUri, vssCredential);
var containers = _fcClient.QueryContainersAsync(new List<Uri>() { _buildUri }).Result;
if (!containers.Any())
return;
var agentLogs = GetAgentLogs(containers);
if (agentLogs == null)
return;
using (var handler = new HttpClientHandler() { UseDefaultCredentials = true })
{
var reader = DownloadAgentLog(agentLogs, handler);
using (var ms = new MemoryStream())
{
ReplaceStrings(findAndReplace, reader, ms);
var response = UploadDocument(containers, agentLogs, ms);
}
}
}
示例7: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="context">
/// The context.
/// </param>
/// <exception cref="HttpResponseException">
/// There is a matching ETag
/// </exception>
protected override void Execute(CodeActivityContext context)
{
if (this.Request.Get(context).Headers.IfMatch.Any(etag => EntityTag.IsMatchingTag(this.ETag.Get(context), etag.Tag)))
{
throw new HttpResponseException(HttpStatusCode.PreconditionFailed);
}
}
示例8: Execute
protected override void Execute(CodeActivityContext context)
{
TrackMessage(context, "Starting SVN action");
string destinationPath = context.GetValue(this.DestinationPath);
string svnPath = context.GetValue(this.SvnPath);
string svnToolPath = context.GetValue(this.SvnToolPath);
string svnCommandArgs = context.GetValue(this.SvnCommandArgs);
SvnCredentials svnCredentials = context.GetValue(this.SvnCredentials);
string svnCommand = Regex.Replace(svnCommandArgs, "{uri}", svnPath);
svnCommand = Regex.Replace(svnCommand, "{destination}", destinationPath);
svnCommand = Regex.Replace(svnCommand, "{username}", svnCredentials.Username);
TrackMessage(context, "svn command: " + svnCommand);
// Never reveal the password!
svnCommand = Regex.Replace(svnCommand, "{password}", svnCredentials.Password);
if (File.Exists(svnToolPath))
{
var process = Process.Start(svnToolPath, svnCommand);
if (process != null)
{
process.WaitForExit();
process.Close();
}
}
TrackMessage(context, "End SVN action");
}
示例9: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="context">
/// The context.
/// </param>
protected override void Execute(CodeActivityContext context)
{
var args = this.Args ?? new object[0];
Console.WriteLine(
"[{0,2:00}] {1}", Thread.CurrentThread.ManagedThreadId, string.Format(this.Message, args));
}
示例10: Execute
/// <summary>
/// Executes the workflow activity.
/// </summary>
/// <param name="executionContext">The execution context.</param>
protected override void Execute(CodeActivityContext executionContext)
{
// Create the tracing service
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
if (tracingService == null)
{
throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
}
tracingService.Trace("Entered " + _processName + ".Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
executionContext.ActivityInstanceId,
executionContext.WorkflowInstanceId);
// Create the context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
if (context == null)
{
throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
}
tracingService.Trace(_processName + ".Execute(), Correlation Id: {0}, Initiating User: {1}",
context.CorrelationId,
context.InitiatingUserId);
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
try
{
//do the regex match
Match match = Regex.Match(StringToValidate.Get(executionContext), MatchPattern.Get(executionContext),
RegexOptions.IgnoreCase);
//did we match anything?
if (match.Success)
{
Valid.Set(executionContext, 1);
}
else
{
Valid.Set(executionContext, 0);
}
}
catch (FaultException<OrganizationServiceFault> e)
{
tracingService.Trace("Exception: {0}", e.ToString());
// Handle the exception.
throw;
}
catch (Exception e)
{
tracingService.Trace("Exception: {0}", e.ToString());
throw;
}
tracingService.Trace("Exiting " + _processName + ".Execute(), Correlation Id: {0}", context.CorrelationId);
}
示例11: Context
internal Context(IGraywulfActivity activity, CodeActivityContext activityContext)
{
InitializeMembers();
// Get job info from the scheduler
var scheduler = activityContext.GetExtension<IScheduler>();
if (scheduler != null)
{
Guid jobguid, userguid;
string jobid, username;
scheduler.GetContextInfo(
activityContext.WorkflowInstanceId,
out userguid, out username,
out jobguid, out jobid);
this.userGuid = userguid;
this.userName = username;
this.jobGuid = jobguid;
this.jobID = jobid;
this.contextGuid = activityContext.WorkflowInstanceId;
this.activityContext = activityContext;
this.activity = activity;
}
}
示例12: DoExecute
protected override void DoExecute(CodeActivityContext context)
{
devlog.Debug(string.Format("Entered for '{0}'", adapterAppointment));
var myAdapterAppointment = adapterAppointment.Get(context);
devlog.Debug(string.Format("would call for '{0}'", myAdapterAppointment));
AdapterAppointmentRepository.InsertOrUpdate(myAdapterAppointment);
}
示例13: Execute
protected override void Execute(CodeActivityContext context)
{
var isValid = new bool?();
var loan = context.GetValue(this.Loan);
if (!(loan.CreditRating > 0))
{
isValid = false;
}
if (!(loan.DownPaymentAmount > 0))
{
isValid = false;
}
if (!(loan.LoanAmount > 0))
{
isValid = false;
}
//If we didn't get set to false then we're valid.
if(!isValid.HasValue)
{
isValid = true;
}
context.SetValue(Valid, isValid);
}
示例14: ExecuteOperation
protected override string ExecuteOperation(CodeActivityContext context)
{
var hostedServiceName = context.GetValue<string>(HostedServiceName);
var slot = context.GetValue(Slot).Description();
var storageServiceName = context.GetValue<string>(StorageServiceName);
var deploymentName = context.GetValue<string>(DeploymentName);
var label = context.GetValue<string>(Label);
var package = context.GetValue<string>(Package);
var configuration = context.GetValue<string>(Configuration);
if (string.IsNullOrEmpty(deploymentName))
{
deploymentName = Guid.NewGuid().ToString();
}
Uri packageUrl;
if (package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) ||
package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase))
{
packageUrl = new Uri(package);
}
else
{
//upload package to blob
var storageName = string.IsNullOrEmpty(storageServiceName) ? hostedServiceName : storageServiceName;
packageUrl = this.RetryCall(s =>
AzureBlob.UploadPackageToBlob(
channel,
storageName,
s,
package));
}
//create new deployment package
var deploymentInput = new CreateDeploymentInput
{
PackageUrl = packageUrl,
Configuration = Utility.GetConfiguration(configuration),
Label = ServiceManagementHelper.EncodeToBase64String(label),
Name = deploymentName
};
using (new OperationContextScope((IContextChannel)channel))
{
try
{
this.RetryCall(s => this.channel.CreateOrUpdateDeployment(
s,
hostedServiceName,
slot,
deploymentInput));
}
catch (CommunicationException ex)
{
throw new CommunicationExceptionEx(ex);
}
return RetrieveOperationId();
}
}
示例15: Execute
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
ItemInfo i = new ItemInfo();
i.ItemCode = context.GetValue<string>(this.ItemCode);
switch (i.ItemCode)
{
case "12345":
i.Description = "Widget";
i.Price = (decimal)10.0;
break;
case "12346":
i.Description = "Gadget";
i.Price = (decimal)15.0;
break;
case "12347":
i.Description = "Super Gadget";
i.Price = (decimal)25.0;
break;
}
context.SetValue(this.Item, i);
}