예제 #1
0
        protected WFProcessor(uint port)
        {
            this.OutputFilesSpecified = true;
            this.OutputFiles          = new WFFileList();
            this.FileToProcess        = string.Empty;
            this.TrackingId           = Guid.NewGuid();
            this.ParentTrackingId     = this.TrackingId;
            this.WFManagerAdminProxy  = null;
            this.ExportDirectory      = string.Empty;
            this.IPAddress            = string.Empty;
            this.Port = port;

//			try
//			{
//				this.SetProcessedObject = typeof(WFProcessingResult).GetMethod("SetProcessedObject").MakeGenericMethod(new [] { this.GetType() });
//			}
//			catch (Exception ex)
//			{
//				throw new Exception(String.Format("No method named SetProcessedObject for type: {0}", this.GetType().FullName), ex);
//			}

#if false
            string host      = System.Net.Dns.GetHostName();
            string ipaddress = string.Empty;
            if (WFUtilities.SetHostAndIPAddress(host, ref ipaddress))
            {
                this.IPAddress = ipaddress;
                this.Port      = port;
            }
#endif
        }
예제 #2
0
        protected Processor(uint port)
        {
            this.WFManagerAdminProxy = null;
            this.IPAddress           = string.Empty;
            this.Port = port;

            string host      = System.Net.Dns.GetHostName();
            string ipaddress = string.Empty;

            if (WFUtilities.SetHostAndIPAddress(host, ref ipaddress))
            {
                this.IPAddress = ipaddress;
                this.Port      = port;
            }
#if false
            try
            {
                EndpointAddress ep = new EndpointAddress(new Uri(string.Format(@"http://{0}:{1}/WFManagerWCF/WFManagerWCF", this.IPAddress, this.Port)));                //				, EndpointIdentity.CreateDnsIdentity("localhost"));
                this.WFManagerAdminProxy = DuplexChannelFactory <Interfaces.Wcf.IWFManagerAdmin> .CreateChannel(this, new WSDualHttpBinding(), ep);

                WFLogger.NLogger.Trace("Discovery {0}", string.Format(@"http://{0}:{1}/WFManagerWCF/WFManagerWCF", this.IPAddress, this.Port));
                this.WFManagerAdminProxy.Discovery();
                WFLogger.NLogger.Trace("Discovery {0} Leaving", string.Format(@"http://{0}:{1}/WFManagerWCF/WFManagerWCF", this.IPAddress, this.Port));
            }
            catch (Exception ex)
            {
                WFLogger.NLogger.ErrorException("ERROR: DuplexChannelFactory failed!", ex);
            }
#endif
        }
예제 #3
0
        public WFTarget(WFTargetData wftargetdata, string assemblycache)
        {
            if (WFTarget.TargetQueues == null)
            {
                WFTarget.TargetQueues = new Dictionary <string, IWFMessageQueue>();
            }

            if (wftargetdata.AssemblyType != string.Empty && wftargetdata.AssemblyDll != string.Empty)
            {
                this.AssemblyPath = Directory.GetCurrentDirectory();

//				if (wftargetdata.AssemblyType != "ProcessorData" && !string.IsNullOrEmpty(assemblycache))
                if (!string.IsNullOrEmpty(assemblycache))
                {
                    this.AssemblyPath = string.Format(@"{0}\{1}", assemblycache, Path.GetFileNameWithoutExtension(wftargetdata.AssemblyDll));
                }

                Assembly assembly = string.IsNullOrEmpty(wftargetdata.AssemblyDll) ? Assembly.GetExecutingAssembly() : Assembly.LoadFrom(this.AssemblyPath + @"\" + wftargetdata.AssemblyDll);
                if (assembly != null)
                {
                    //The AssemblyResolve event is called when the common language runtime tries to bind to the assembly and fails.
                    AppDomain currentDomain = AppDomain.CurrentDomain;
                    currentDomain.AssemblyResolve += new ResolveEventHandler(currentDomain_AssemblyResolve);
                    try
                    {
                        this.AssemblyType         = assembly.GetType(assembly.GetTypes().Where(x => (x.Name.ToUpper() == wftargetdata.AssemblyType.ToUpper()) || (x.FullName.ToUpper() == wftargetdata.AssemblyType.ToUpper())).Select(x => x.FullName).FirstOrDefault());
                        this.AssemblyTypeInstance = assembly.CreateInstance(this.AssemblyType.FullName);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("", ex);
                    }
                    finally
                    {
                        currentDomain.AssemblyResolve -= new ResolveEventHandler(currentDomain_AssemblyResolve);
                    }
                }
                else
                {
                    throw new Exception("");
                }
            }

            if (wftargetdata.QueueName != string.Empty)
            {
                string ip = string.Empty;
                if (WFUtilities.SetHostAndIPAddress(wftargetdata.QueueHost, ref ip))
                {
                    Type type = null;
                    int  port = 0;
                    WFMessageQueueType publisherorconsumer = WFMessageQueueType.None;

                    switch (wftargetdata.QueueType)
                    {
                    case ".netqueue":
                        type = typeof(System.Collections.Queue);
                        break;

                    case "msmq":
                        type = typeof(MessageQueue);
                        break;

                    case "rabbitmq":
                        type = typeof(QueueingBasicConsumer);
                        port = 5672;
                        publisherorconsumer = WFMessageQueueType.Publisher;
                        if (this is WFSrc)
                        {
                            publisherorconsumer = WFMessageQueueType.Consumer;
                        }
                        break;

                    default:
                        break;
                    }

                    if (WFTarget.TargetQueues.ContainsKey(wftargetdata.QueueName))
                    {
                        this.MessageQueue = WFTarget.TargetQueues[wftargetdata.QueueName];
                    }
                    else
                    {
                        Type genericqueuetype = typeof(IWFMessageQueueFactory <,>).MakeGenericType(new[] { type, this.AssemblyType == null ? typeof(ProcessorData) : this.AssemblyType });
                        this.MessageQueue = (IWFMessageQueue)genericqueuetype.GetMethod(WFTarget.CreateWFMessageQueue, new object[] { ip, port, wftargetdata.QueueName, publisherorconsumer }.Select(p => p.GetType()).ToArray()).Invoke(null, new object[] { ip, port, wftargetdata.QueueName, publisherorconsumer });
                        WFTarget.TargetQueues[wftargetdata.QueueName] = this.MessageQueue;
                    }
                    //					genericqueuetype = typeof(WFMessageQueue<>).MakeGenericType(new[] { this.AssemblyType });
                    //					this.GenericQueue = Activator.CreateInstance(genericqueuetype, new object[] { @"FormatName:Direct=TCP:" + ip + @"\Private$\" + queuename });
                    //					this.MessageQueue = (System.Messaging.MessageQueue)genericqueuetype.GetProperty("MessageQueue").GetGetMethod().Invoke(this.GenericQueue, new object[0]);
                }
                else
                {
                    throw new Exception("");
                }
            }
        }