private void UnregisterReceiveNotification(ActivityContext context)
        {
            var      subscriptionHandle = this.SubscriptionHandle.Get(context);
            Bookmark bookmark           = this.receiveCompleteBookmark.Get(context);

            if (bookmark != null)
            {
                if (subscriptionHandle != null)
                {
                    context.GetExtension <Hosting.FolderWatcherExtension>()
                    .UnregisterReceiveNotification(bookmark, subscriptionHandle.Id);
                }
            }
            if (context is NativeActivityContext)
            {
                NativeActivityContext ctx = context as NativeActivityContext;
                if (bookmark != null)
                {
                    ctx.RemoveBookmark(bookmark);
                }
                this.noPersistHandle.Get(ctx).Exit(ctx);
            }
            else if (context is NativeActivityFaultContext)
            {
                NativeActivityFaultContext ctx = context as NativeActivityFaultContext;
                if (bookmark != null)
                {
                    ctx.RemoveBookmark(bookmark);
                }
                this.noPersistHandle.Get(ctx).Exit(ctx);
            }
        }
Ejemplo n.º 2
0
        private TimerExtension GetTimerExtension(ActivityContext context)
        {
            TimerExtension timerExtension = context.GetExtension <TimerExtension>();

            Fx.Assert(timerExtension != null, "TimerExtension must exist.");
            return(timerExtension);
        }
Ejemplo n.º 3
0
 internal void InitializeChannelCacheEnabledSetting(ActivityContext context)
 {
     if (!this.channelCacheEnabled.HasValue)
     {
         SendMessageChannelCache extension = context.GetExtension <SendMessageChannelCache>();
         this.InitializeChannelCacheEnabledSetting(extension);
     }
 }
Ejemplo n.º 4
0
        public IOrganizationService GetService(ActivityContext executionContext, Guid?user)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }
            var svcFactory = executionContext.GetExtension <IOrganizationServiceFactory>();

            if (user == null)
            {
                var workflowContext = executionContext.GetExtension <IWorkflowContext>();
                return(svcFactory.CreateOrganizationService(workflowContext.UserId));
            }
            else
            {
                return(svcFactory.CreateOrganizationService(user));
            }
        }
Ejemplo n.º 5
0
        internal void InitializeChannelCacheEnabledSetting(ActivityContext context)
        {
            if (!this.channelCacheEnabled.HasValue)
            {
                SendMessageChannelCache channelCacheExtension = context.GetExtension <SendMessageChannelCache>();
                Fx.Assert(channelCacheExtension != null, "channelCacheExtension must exist!");

                InitializeChannelCacheEnabledSetting(channelCacheExtension);
            }
        }
Ejemplo n.º 6
0
        internal static Process GetProcessFromContext(ActivityContext context)
        {
            var DataContext = context.DataContext;
            var pi          = DataContext.GetProperties()["Process"];
            var process     = pi.GetValue(DataContext) as Process;
            var dbContext   = context.GetExtension <IDbContext>();

            process.DbContext = dbContext;
            return(process);
        }
            public override System.Activities.Location GetLocation(ActivityContext context)
            {
                SymbolResolver extension = context.GetExtension <SymbolResolver>();

                if (extension == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.CanNotFindSymbolResolverInWorkflowInstanceExtensions));
                }
                return(extension.GetLocation(base.Name, base.Type));
            }
Ejemplo n.º 8
0
        public static IActivityContext GetActivityContext(this ActivityContext context)
        {
            var activityContextExtension = context.GetExtension <ActivityContextExtension>();

            if (activityContextExtension == null)
            {
                throw new ValidationException(nameof(ActivityContextExtension) + " is not found.");
            }
            return(activityContextExtension.ActivityContext);
        }
Ejemplo n.º 9
0
        public static PreviousResponseParameterExtension GetPreviousResponseParameterExtension(this ActivityContext context)
        {
            var previousResponseParameterExtension = context.GetExtension <PreviousResponseParameterExtension>();

            if (previousResponseParameterExtension == null)
            {
                throw new ValidationException(nameof(PreviousResponseParameterExtension) + " is not found.");
            }
            return(previousResponseParameterExtension);
        }
        public static TimerExtension GetTimerExtension(this ActivityContext context)
        {
            TimerExtension timerExtension = context.GetExtension <TimerExtension>();

            if (timerExtension == null)
            {
                throw new ValidationException(nameof(TimerExtension) + " is not found.");
            }
            return(timerExtension);
        }
Ejemplo n.º 11
0
        public ITracingService GetTracingService(ActivityContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            return(tracingService);
        }
        public static void TrackDeploymentError(this ActivityContext context, string message)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IActivityTracking activityTracking = context.GetExtension <IDeploymentLoggingExtension>().GetActivityTracking(context);

            activityTracking.Node.Children.AddErrorNode(message);
        }
Ejemplo n.º 13
0
            public override Location GetLocation(ActivityContext context)
            {
                SymbolResolver resolver = context.GetExtension <SymbolResolver>();

                if (resolver == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.CanNotFindSymbolResolverInWorkflowInstanceExtensions));
                }

                return(resolver.GetLocation(this.Name, this.Type));
            }
Ejemplo n.º 14
0
            private void Release()
            {
                Debug.WriteLine("##WF> RelatedContentProtector releasing");
                var path         = _context.GetExtension <ContentWorkflowExtension>().WorkflowInstancePath;
                var stateContent = Node.Load <WorkflowHandlerBase>(path);

                if (stateContent.RelatedContent.Id == _node.Id)
                {
                    stateContent.RelatedContentTimestamp = _node.NodeTimestamp;
                    using (new SystemAccount())
                        stateContent.Save();
                }
                Debug.WriteLine("##WF> RelatedContentProtector released");
            }
        public VersionControlScope(VersionControlServer server, ActivityContext context)
        {
            this.Server = server;
            if (context != null)
            {
                this.ActionInvoker = context.GetExtension<ScheduleActionExtension>();
                if (this.ActionInvoker == null)
                {
                    throw new ServiceMissingException(typeof(ScheduleActionExtension));
                }
            }

            this.GettingHandlers = new List<Tuple<string, GettingEventHandler>>();
            this.NonFatalErrorHandlers = new List<Tuple<string, ExceptionEventHandler>>();
            this.NewPendingChangeHandlers = new List<Tuple<string, PendingChangeEventHandler>>();
        }
Ejemplo n.º 16
0
        public VersionControlScope(VersionControlServer server, ActivityContext context)
        {
            this.Server = server;
            if (context != null)
            {
                this.ActionInvoker = context.GetExtension <ScheduleActionExtension>();
                if (this.ActionInvoker == null)
                {
                    throw new ServiceMissingException(typeof(ScheduleActionExtension));
                }
            }

            this.GettingHandlers          = new List <Tuple <string, GettingEventHandler> >();
            this.NonFatalErrorHandlers    = new List <Tuple <string, ExceptionEventHandler> >();
            this.NewPendingChangeHandlers = new List <Tuple <string, PendingChangeEventHandler> >();
        }
Ejemplo n.º 17
0
            /// <summary>
            /// Make sure we have a log file in place.
            /// <para></para>
            /// If the user hasn't specified one we will create one for him on
            /// the logs drops folder path.
            /// <para></para>
            /// The file will have the same name as the solution/project being built, plus the
            /// context for configuration and platform with the .log file extension
            /// </summary>
            /// <param name="context">Activity Context</param>
            /// <returns>The location of the log file</returns>
            private string GenerateLogFile(ActivityContext context)
            {
                string finalLogFile = null;

                var buildDetail   = context.GetExtension <IBuildDetail>();
                var filePath      = this.FilePath.Get(this.ActivityContext);
                var configuration = this.Configuration.Get(this.ActivityContext);
                var platform      = this.Platform.Get(this.ActivityContext);

                var fileName = Path.GetFileName(filePath);

                if (fileName != null)
                {
                    string logDirectory = string.IsNullOrEmpty(buildDetail.DropLocation)
                        ? Path.GetDirectoryName(filePath)
                        : Path.Combine(buildDetail.DropLocation, @"logs");

                    if (!Directory.Exists(logDirectory))
                    {
                        Directory.CreateDirectory(logDirectory);
                    }

                    finalLogFile = Path.GetFileNameWithoutExtension(fileName);

                    if (string.IsNullOrWhiteSpace(configuration) == false)
                    {
                        finalLogFile += configuration;
                    }

                    if (string.IsNullOrWhiteSpace(platform) == false)
                    {
                        finalLogFile += platform;
                    }

                    finalLogFile += ".log";

                    finalLogFile = Path.Combine(logDirectory, SanitizeFileName(finalLogFile));
                }

                this.LogBuildMessage(string.Format("Log file {0} will be used.", finalLogFile));

                return(finalLogFile);
            }
Ejemplo n.º 18
0
            /// <summary>
            /// Make sure we have a log file in place.
            /// <para></para>
            /// If the user hasn't specified one we will create one for him on
            /// the logs drops folder path.
            /// <para></para>
            /// The file will have the same name of the solution/project being built, plus the
            /// context for configuration and platform with the .log file extension
            /// </summary>
            /// <param name="context">Activity Context</param>
            /// <returns>The location of the log file</returns>
            private string GenerateLogFile(ActivityContext context)
            {
                string finalLogFile = null;
                string logDirectory;

                var buildDetail = context.GetExtension <IBuildDetail>();

                var fileName = this.LogFilename.Get(context);

                if (fileName == null)
                {
                    return(null);
                }

                if (string.IsNullOrEmpty(buildDetail.LogLocation) == false)
                {
                    logDirectory = buildDetail.LogLocation;
                }
                else if (string.IsNullOrEmpty(buildDetail.DropLocation) == false)
                {
                    logDirectory = Path.Combine(buildDetail.DropLocation, @"logs");
                }
                else
                {
                    this.LogBuildWarning("drop location not defined. Will not write to log file");
                    return(null);
                }

                if (!Directory.Exists(logDirectory))
                {
                    Directory.CreateDirectory(logDirectory);
                }

                finalLogFile = Path.Combine(logDirectory, SanitizeFileName(fileName));

                this.LogBuildMessage(string.Format("Log file {0} will be used.", finalLogFile));

                return(finalLogFile);
            }
Ejemplo n.º 19
0
 public static TimerExtension GetTimerExtension(this ActivityContext context)
 => context.GetExtension <TimerExtension>() ?? throw new ValidationException(nameof(TimerExtension) + " is not found.");
Ejemplo n.º 20
0
            /// <summary>
            /// Make sure we have a log file in place.
            /// <para></para>
            /// If the user hasn't specified one we will create one for him on
            /// the logs drops folder path.
            /// <para></para>
            /// The file will have the same name as the solution/project being built, plus the
            /// context for configuration and platform with the .log file extension
            /// </summary>
            /// <param name="context">Activity Context</param>
            /// <returns>The location of the log file</returns>
            private string GenerateLogFile(ActivityContext context)
            {
                string finalLogFile = null;

                var buildDetail = context.GetExtension<IBuildDetail>();
                var filePath = this.FilePath.Get(this.ActivityContext);
                var configuration = this.Configuration.Get(this.ActivityContext);
                var platform = this.Platform.Get(this.ActivityContext);

                var fileName = Path.GetFileName(filePath);

                if (fileName != null)
                {
                    string logDirectory = string.IsNullOrEmpty(buildDetail.DropLocation)
                        ? Path.GetDirectoryName(filePath)
                        : Path.Combine(buildDetail.DropLocation, @"logs");

                    if (!Directory.Exists(logDirectory))
                    {
                        Directory.CreateDirectory(logDirectory);
                    }

                    finalLogFile = Path.GetFileNameWithoutExtension(fileName);

                    if (string.IsNullOrWhiteSpace(configuration) == false)
                    {
                        finalLogFile += configuration;
                    }

                    if (string.IsNullOrWhiteSpace(platform) == false)
                    {
                        finalLogFile += platform;
                    }

                    finalLogFile += ".log";

                    finalLogFile = Path.Combine(logDirectory, SanitizeFileName(finalLogFile));
                }

                this.LogBuildMessage(string.Format("Log file {0} will be used.", finalLogFile));

                return finalLogFile;
            }
Ejemplo n.º 21
0
		protected bool GetRunInProc(ActivityContext context)
		{
			bool flag = false;
			bool flag1;
			HostParameterDefaults extension = context.GetExtension<HostParameterDefaults>();
			if (this as PSGeneratedCIMActivity == null)
			{
				IEnumerator enumerator = context.DataContext.GetProperties().GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						PropertyDescriptor current = (PropertyDescriptor)enumerator.Current;
						if (!string.Equals(current.DisplayName, "PSRunInProcessPreference", StringComparison.OrdinalIgnoreCase))
						{
							continue;
						}
						object value = current.GetValue(context.DataContext);
						if (value == null || !LanguagePrimitives.TryConvertTo<bool>(value, CultureInfo.InvariantCulture, out flag))
						{
							continue;
						}
						flag1 = flag;
						return flag1;
					}
					this.psActivityContextImplementationVariable.Get(context);
					PSWorkflowHost workflowHost = PSActivity.GetWorkflowHost(extension);
					return workflowHost.PSActivityHostController.RunInActivityController(this);
				}
				finally
				{
					IDisposable disposable = enumerator as IDisposable;
					if (disposable != null)
					{
						disposable.Dispose();
					}
				}
				return flag1;
			}
			else
			{
				return true;
			}
		}
 private TimerExtension GetTimerExtension(ActivityContext context)
 {
     return context.GetExtension<TimerExtension>();
 }
            /// <summary>
            /// Make sure we have a log file in place.
            /// <para></para>
            /// If the user hasn't specified one we will create one for him on
            /// the logs drops folder path.
            /// <para></para>
            /// The file will have the same name of the solution/project being built, plus the
            /// context for configuration and platform with the .log file extension
            /// </summary>
            /// <param name="context">Activity Context</param>
            /// <returns>The location of the log file</returns>
            private string GenerateLogFile(ActivityContext context)
            {
                string finalLogFile = null;
                string logDirectory;

                var buildDetail = context.GetExtension<IBuildDetail>();

                var fileName = this.LogFilename.Get(context);

                if (fileName == null)
                {
                    return null;
                }

                if (string.IsNullOrEmpty(buildDetail.LogLocation) == false)
                {
                    logDirectory = buildDetail.LogLocation;
                }
                else if (string.IsNullOrEmpty(buildDetail.DropLocation) == false)
                {
                    logDirectory = Path.Combine(buildDetail.DropLocation, @"logs");
                }
                else
                {
                    this.LogBuildWarning("drop location not defined. Will not write to log file");
                    return null;
                }

                if (!Directory.Exists(logDirectory))
                {
                    Directory.CreateDirectory(logDirectory);
                }

                finalLogFile = Path.Combine(logDirectory, SanitizeFileName(fileName));

                this.LogBuildMessage(string.Format("Log file {0} will be used.", finalLogFile));

                return finalLogFile;
            }
Ejemplo n.º 24
0
        internal void InitializeChannelCacheEnabledSetting(ActivityContext context)
        {
            if (!this.channelCacheEnabled.HasValue)
            {
                SendMessageChannelCache channelCacheExtension = context.GetExtension<SendMessageChannelCache>();
                Fx.Assert(channelCacheExtension != null, "channelCacheExtension must exist!");

                InitializeChannelCacheEnabledSetting(channelCacheExtension);
            }
        }
Ejemplo n.º 25
0
 TimerExtension GetTimerExtension(ActivityContext context)
 {
     TimerExtension timerExtension = context.GetExtension<TimerExtension>();
     Fx.Assert(timerExtension != null, "TimerExtension must exist.");
     return timerExtension;
 }
        private static void ParseRetrieveXml(ActivityContext context, string textReceive, IMainWindowModel model)
        {
            var doc = new XmlDocument();

            doc.LoadXml(textReceive);

            XmlNodeList applicants = doc.GetElementsByTagName("reg:applicants");

            if (applicants.Count <= 0 || applicants.Item(0) == null)
            {
                model.RetrieveInfo = "Invalid xml format.";
                return;
            }

            var sb  = new StringBuilder();
            var ext = context.GetExtension <IAddressRetrieveExt>();
            var resultCollection = new ObservableCollection <AddressRetrieveViewModel>();

            int     rbGroupIndex = 1;
            XmlNode item         = applicants[0];

            foreach (XmlNode applicant in item.ChildNodes)
            {
                var addressAll = new StringBuilder();
                var rtModel    = new AddressRetrieveViewModel {
                    RbGroupName = "ItemGroup" + rbGroupIndex, Sequence = applicant.Attributes?["sequence"].Value
                };

                foreach (XmlNode node in applicant.ChildNodes)
                {
                    if (node.LocalName.Equals("addressbook"))
                    {
                        foreach (XmlNode book in node.ChildNodes)
                        {
                            if (book.LocalName.Equals("last-name"))
                            {
                                sb.AppendLine("Last Name:");
                                sb.AppendLine(book.InnerText);
                                rtModel.LastName = book.InnerText;
                            }

                            if (book.LocalName.Equals("first-name"))
                            {
                                sb.AppendLine("First Name:");
                                sb.AppendLine(book.InnerText);
                                rtModel.FirstName = book.InnerText;
                            }

                            if (book.LocalName.Equals("name"))
                            {
                                sb.AppendLine("Name:");
                                rtModel.Name = book.InnerText;
                                sb.AppendLine("- " + book.InnerText);
                            }

                            if (book.LocalName.Equals("fax"))
                            {
                                rtModel.Phone = book.InnerText;
                            }
                            if (book.LocalName.Equals("email"))
                            {
                                rtModel.Phone = book.InnerText;
                            }
                            if (book.LocalName.Equals("phone"))
                            {
                                rtModel.Phone = book.InnerText;
                            }

                            if (book.LocalName.Equals("address"))
                            {
                                sb.AppendLine("Address:");
                                addressAll.AppendLine("Address:");
                                foreach (XmlNode address in book.ChildNodes)
                                {
                                    sb.AppendLine("- " + address.InnerText);
                                    addressAll.AppendLine(address.InnerText);

                                    if (address.LocalName.Equals("country"))
                                    {
                                        rtModel.Country = address.InnerText;
                                    }
                                }
                            }
                        }
                    }
                }

                if (addressAll.Length > 0)
                {
                    rtModel.AddressRetrieve = addressAll.ToString();
                    if (!string.IsNullOrWhiteSpace(rtModel.FirstName) || !string.IsNullOrWhiteSpace(rtModel.LastName))
                    {
                        rtModel.EntityFormLegal = false;
                    }
                    else
                    {
                        rtModel.EntityFormLegal = true;
                    }
                    rtModel.EntityFormNatural = rtModel.EntityFormLegal == false;
                    resultCollection.Add(rtModel);
                }
                rbGroupIndex++;
            }

            var dtgaz = item.Attributes?["change-gazette-num"].Value;

            if (!string.IsNullOrWhiteSpace(dtgaz))
            {
                sb.AppendLine(new string('-', 40));
                sb.AppendLine($"[{dtgaz}]");
                sb.AppendLine(string.Empty);
            }

            if (sb.Length > 0)
            {
                model.RetrieveInfo = sb.ToString();
                ext.CallBackRetrieveAddress(resultCollection);
            }
        }
Ejemplo n.º 27
0
        public static T GetDependency <T>(this ActivityContext context)
        {
            var diExtension = context.GetExtension <DependencyInjectionExtension>();

            return(diExtension.GetDependency <T>());
        }
Ejemplo n.º 28
0
 private TimerExtension GetTimerExtension(ActivityContext context)
 {
     return(context.GetExtension <TimerExtension>());
 }
Ejemplo n.º 29
0
 public static TraceExtension GetTraceExtension(ActivityContext context)
 {
     return(context.GetExtension <TraceExtension>());
 }
 internal void InitializeChannelCacheEnabledSetting(ActivityContext context)
 {
     if (!this.channelCacheEnabled.HasValue)
     {
         SendMessageChannelCache extension = context.GetExtension<SendMessageChannelCache>();
         this.InitializeChannelCacheEnabledSetting(extension);
     }
 }