Ejemplo n.º 1
0
 private static void Abort(IChannel channel, ChannelFactory channelFactory)
 {
     if (channel != null)
         channel.Abort();
     if (channelFactory != null)
         channelFactory.Abort();
 }
Ejemplo n.º 2
0
 static void Abort(IChannel channel, ChannelFactory cf)
 {
     if (channel != null)
         channel.Abort();
     if (cf != null)
         cf.Abort();
 }
Ejemplo n.º 3
0
        // The product code will check the Dns identity from the server and throw if it does not match what is specified in DnsEndpointIdentity
        public static void VerifyServiceIdentityMatchDnsEndpointIdentity()
        {
            string testString = "Hello";

            NetTcpBinding binding = new NetTcpBinding();
            //SecurityMode.Transport is not supported yet, we will get an exception here, tracked by issue #81
            binding.Security.Mode = SecurityMode.Transport;
            binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

            EndpointAddress endpointAddress = new EndpointAddress(new Uri(Endpoints.Tcp_VerifyDNS_Address),new DnsEndpointIdentity("localhost"));
            ChannelFactory<IWcfService> factory = new ChannelFactory<IWcfService>(binding, endpointAddress);
            // factory.Credentials.ServiceCertificate is not availabe currently, tracked by issue 243
            // We need to change the validation mode as we use a test certificate. It does not affect the purpose of this test
            // factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            IWcfService serviceProxy = factory.CreateChannel();

            try
            {
                var result = serviceProxy.Echo(testString);
                Assert.Equal(testString, result);
            }
            finally
            {
                if (factory != null && factory.State != CommunicationState.Closed)
                {factory.Abort();
                }
            }
        }
Ejemplo n.º 4
0
        private void bPipe_Click(object sender, EventArgs e)
        {
            //ChannelFactory<IDesktopService> httpFactory = new ChannelFactory<IDesktopService>(new WebHttpBinding(),
            //    new EndpointAddress("http://localhost:8000/Desk"));

            //IDesktopService httpProxy =
            //  httpFactory.CreateChannel();
            ChannelFactory<IDesktopService> pipeFactory = null;
            try
            {
                var b = new NetNamedPipeBinding();
                b.MaxReceivedMessageSize = int.MaxValue;
                b.MaxBufferSize = int.MaxValue;
                pipeFactory =
                    new ChannelFactory<IDesktopService>(b,
                        new EndpointAddress("net.pipe://localhost/DeskPipe"));

                IDesktopService pipeProxy =
                    pipeFactory.CreateChannel();
                sw.Start();
                var d = pipeProxy.C("par");
                sw.Stop();
                box.Text += "GetData returned {0} bytes and costed {1} ms\r\n".Fmt(d.Result.ToString().Length, sw.ElapsedMilliseconds);
                var s = d.Result.ToString();
                if (!string.IsNullOrEmpty(s))
                {
                    var bytes = Convert.FromBase64String(s);
                    using (var ms = new MemoryStream())
                    {
                        ms.Write(bytes, 0, bytes.Length);
                        var bmp = Image.FromStream(ms);
                        pic.Image = bmp;
                    }
                }
                //var img = d.Result as Bitmap;
                //pic.Image = img;
            }
            catch (Exception ex)
            {
                Error.Handle(ex);
            }
            finally
            {
                sw.Reset();
                if (pipeFactory != null && pipeFactory.State != CommunicationState.Closed)
                {
                    if (pipeFactory.State == CommunicationState.Faulted)
                    {
                        pipeFactory.Abort();
                    }
                    else
                    {
                        pipeFactory.Close();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void Abort()
        {
            IChannel channel = (IChannel)_channel;

            if (channel != null)
            {
                channel.Abort();
            }
            ChannelFactory.Abort();
        }
        private string CallSyncService()
        {
            string lResult = string.Empty;

            if (mut.WaitOne(0))
            {
                try
                {
                    var lServiceHostAddress = new Uri(Properties.Settings.Default.ServiceHostAddress);
                    var lServiceEndPointAddress = Properties.Settings.Default.ServiceEndPointAddress;
                    var lEndPointAddress =
                        new EndpointAddress(new Uri(String.Format("{0}/{1}", lServiceHostAddress, lServiceEndPointAddress)));
                    this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: lEndPointAddress = {0}", lEndPointAddress);

                    var lBinding = new TcpChunkingBinding();
                    lBinding.OpenTimeout = Properties.Settings.Default.OpenTimeout;
                    lBinding.ReceiveTimeout = Properties.Settings.Default.ReceiveTimeout;
                    lBinding.SendTimeout = Properties.Settings.Default.SendTimeout;
                    lBinding.CloseTimeout = Properties.Settings.Default.CloseTimeout;

                    this.WriteLog(USLogLevel.Trace, "lBinding params lBinding.OpenTimeout = {0}; lBinding.ReceiveTimeout = {1}; lBinding.SendTimeout = {2}; lBinding.CloseTimeout = {3}", lBinding.OpenTimeout, lBinding.ReceiveTimeout, lBinding.SendTimeout, lBinding.CloseTimeout);

                    using (var factory = new ChannelFactory<IUSInService>(lBinding, lEndPointAddress))
                    {
                        try
                        {
                            this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: ChannelFactory created");
                            var service = factory.CreateChannel();
                            this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: IUSExService service = factory.CreateChannel created");
                            lResult = service.EntitySync(LinkSyncServiceEntitiesId);
                            this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: service.EntitySync выполнен");
                            factory.Close();
                        }
                        finally
                        {
                            factory.Abort();
                        }
                    }
                    this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: ChannelFactory Closed");
                }
                catch (Exception e)
                {
                    this.WriteLog(USLogLevel.Trace|USLogLevel.Debug, string.Format("SyncServiceProperties.CallSyncService: Ошибка синхронизации LinkSyncServiceEntitiesId = {0}. Ошибка: {1}", LinkSyncServiceEntitiesId, e));
                    this.WriteLogException(string.Format("SyncServiceProperties.CallSyncService: Ошибка синхронизации LinkSyncServiceEntitiesId = {0}. Ошибка: {1}", LinkSyncServiceEntitiesId, e), e);
                    lResult = string.Empty;
                }
                finally
                {
                    mut.ReleaseMutex();                    
                }
            }

            return lResult;
        }
Ejemplo n.º 7
0
 private void CreateDashboardPipe()
 {
     try{
         //Connect to the master channel
         m_DasboardComFactory = new ChannelFactory<ICTMComR2D>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/Dashboard/CTMComR2D"));
         m_DashboardPipe = m_DasboardComFactory.CreateChannel();
     }
     catch
     {
         m_DasboardComFactory.Abort();
     }
 }
        public AuthenticationResponse Authenticate(AuthenticationRequest request)
        {
            ChannelFactory<IAuthenticationService> channelFactory = null;
            AuthenticationResponse response = null;
            try
            {
                channelFactory = new ChannelFactory<IAuthenticationService>("authentication");
                channelFactory.Open();

                var service = channelFactory.CreateChannel();

                response = service.Authenticate(request);

                channelFactory.Close();
            }
            catch (CommunicationException)
            {
                if (channelFactory != null)
                {
                    channelFactory.Abort();
                }
            }
            catch (TimeoutException)
            {
                if (channelFactory != null)
                {
                    channelFactory.Abort();
                }
            }
            catch (Exception)
            {
                if (channelFactory != null)
                {
                    channelFactory.Abort();
                }
                throw;
            }

            return response;
        }
Ejemplo n.º 9
0
	    private void bError_Click(object sender, EventArgs e)
		{
			using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(new NetTcpBinding(), TestService.NetTcpAddress))
			{
				try
				{
					ITestService ts = cf.CreateChannel();
					ts.TestError();
				}
				catch(FaultException ex)
				{
					MessageBox.Show(ex.ToString());
					cf.Abort();
				}
			}
		}
Ejemplo n.º 10
0
 public void Dispose()
 {
     try
     {
         _remoteFactory.Close();
         _remoteFactory = null;
     }
     catch
     {
         if (_remoteFactory != null)
         {
             _remoteFactory.Abort();
             _remoteFactory = null;
         }
     }
 }
Ejemplo n.º 11
0
        public void GETTest()
        {
            GeoLocation output = null;
            var factory = new ChannelFactory<IService<GeoLocation>>("GeoLocationService");
            if (factory.State != CommunicationState.Faulted)
            {
                var proxy = factory.CreateChannel();
                output = proxy.Read("werwtw4hej3u");
                Console.WriteLine(output.Identifier);
                if (factory.State == CommunicationState.Faulted)
               {
                    factory.Abort();
                }
                ((IDisposable)proxy).Dispose();
            }

            Assert.IsNotNull(output);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 此静态构造函数用来检测存活的Search个数
        /// </summary>
        static Address()
        {
            Timer timer = new Timer();
            timer.Interval = 6000;
            timer.Elapsed += (sender, e) =>
            {

                Console.WriteLine("\n***************************************************************************");
                Console.WriteLine("当前存活的Search为:");

                lock (obj)
                {
                    //遍历当前存活的Search
                    foreach (var single in search)
                    {
                        ChannelFactory<IProduct> factory = null;

                        try
                        {
                            //当Search存在的话,心跳服务就要定时检测Search是否死掉,也就是定时的连接Search来检测。
                            factory = new ChannelFactory<IProduct>(new NetTcpBinding(SecurityMode.None), new EndpointAddress(single));
                            factory.CreateChannel().TestSearch();
                            factory.Close();

                            Console.WriteLine(single);

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);

                            //如果抛出异常,则说明此search已经挂掉
                            search.Remove(single);
                            factory.Abort();
                            Console.WriteLine("\n当前时间:" + DateTime.Now + " ,存活的Search有:" + search.Count() + "个");
                        }
                    }
                }

                //最后统计下存活的search有多少个
                Console.WriteLine("\n当前时间:" + DateTime.Now + " ,存活的Search有:" + search.Count() + "个");
            };
            timer.Start();
        }
Ejemplo n.º 13
0
        private void bTest_Click(object sender, EventArgs e)
	    {
	        var binding = new NetTcpBinding(SecurityMode.Transport);
	        using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(binding, TestService.NetTcpAddress))
	        {
                ITestService ts = cf.CreateChannel();
                for (int i = 0; i < 10; i++)
	            {
	                try
	                {
                        var rlt = ts.Test();
                        Log(rlt);
	                }
	                catch (Exception ex)
	                {
	                    Log(ex.Message);
	                    cf.Abort();
	                }
	            }
	        }
	    }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(new NetTcpBinding(), TestService.NetTcpAddress))
            {
                ITestService ts = cf.CreateChannel();
                for (int i = 0; i < 10; i++)
                {
                    try
                    {
                        var rlt = ts.Test();
                        Log(rlt);
                    }
                    catch (Exception ex)
                    {
                        Log(ex.Message);
                        cf.Abort();
                    }
                }
            } 

            //using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(new NetTcpBinding(), TestService.Address))
            //{
            //    ITestService ts = cf.CreateChannel();
            //    for (int i = 0; i < 10; i++)
            //    {
            //        try
            //        {
            //            var rlt = ts.Test();
            //            Log(rlt);
            //        }
            //        catch (Exception ex)
            //        {
            //            Log(ex.Message);
            //            cf.Abort();
            //        }
            //    }
            //}
            Console.ReadKey();
        }
Ejemplo n.º 15
0
        public void POSTTest()
        {
            var input = new GeoLocation
                               {
                                   Accuracy = 1.26743233E+14,
                                   Altitude = 1.26743233E+14,
                                   AltitudeAccuracy = 1.26743233E+14,
                                   Heading = 1.26743233E+14,
                                   Latitude = 1.26743233E+14,
                                   Longitude = 1.26743233E+14,
                                   Speed = 1.26743233E+14,
                                   Timestamp = DateTime.Parse("1999-05-31T11:20:00")
                               };
            GeoLocation output = null;
            var factory = new ChannelFactory<IService<GeoLocation>>("GeoLocationService");
            if (factory.State != CommunicationState.Faulted)
            {
                var proxy = factory.CreateChannel();
                try
                {
                    output = proxy.Create(input);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.InnerException.StackTrace);
                }
                Console.WriteLine(output.Identifier);
                if (factory.State == CommunicationState.Faulted)
                {
                    factory.Abort();
                }
                ((IDisposable)proxy).Dispose();
            }

            Assert.IsNotNull(output);
        }
Ejemplo n.º 16
0
        internal static void worker(int loop, string name)
        {
            //ThreadPool.QueueUserWorkItem(delegate
            //{
                ChannelFactory<ITest> factory = null;
                try
                {
                    factory = new ChannelFactory<ITest>(name);
                    var channel = factory.CreateChannel();

                    using (var ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        var response = string.Empty;
                        response = channel.Ping2(loop);
                        //channel.Ping(loop);
                       
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(string.Format("[{0}, {1}]: {2}, tid={3}\n", loop, name, response, Thread.CurrentThread.GetHashCode()));
                        Console.ResetColor();

                        //Thread.Sleep(1000);

                        Console.WriteLine("\n+++ Press 'a' to abort or any key to finish a transaction. Timeout = 60sec. +++\n");

                        var ki = Console.ReadKey();
                        if (ki.Key == ConsoleKey.A)
                        {
                            throw new Exception("M A N U A L Y  A B O R T E D");
                        }
                                 
                        ts.Complete();
                    }
                    ((IChannel)channel).Close();
                    factory.Close();
                }
                catch (Exception ex)
                {
                    if (factory != null) factory.Abort();

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n" + ex.Message);
                    Console.ResetColor();
                }

            //});
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press a key to connect...");
            Console.ReadLine();
            Console.WriteLine("Connecting...");

            EndpointAddress address = new EndpointAddress("https://localhost:8089/WCF");
            IDoSomethingSimple mProxy = null;
            ChannelFactory<IDoSomethingSimple> mFactory = null;
            try
            {
                //ClientCredentials clientCredentials = new ClientCredentials();
                //clientCredentials.UserName.UserName = "******";
                //clientCredentials.UserName.Password = "******";
                //BindingParameterCollection bindingParms = new BindingParameterCollection();
                //bindingParms.Add(clientCredentials);

                // mFactory = ConnectionBindingUserNamePassword().BuildChannelFactory<IDoSomethingSimple>(bindingParms);

                //mFactory.Open();
                //mFactory.CreateChannel(address);
                mFactory = new ChannelFactory<IDoSomethingSimple>(ConnectionBindingUserNamePassword(), address);
                mFactory.Credentials.UserName.UserName = "******";
                mFactory.Credentials.UserName.Password = "******";

                //HttpDigestClientCredential gg =  mFactory.Credentials.HttpDigest;


                mProxy = mFactory.CreateChannel();

            }
            catch (Exception ex)
            {
                throw ex;
            }

            Console.WriteLine("Connected");
            try
            {
                for (string item = "Starting ..."; item != "END"; item = Console.ReadLine())
                {
                    mProxy.PassThisThrough(item);
                }

                Console.WriteLine("----------------------------------------");
                Console.WriteLine("---------------   ENDED   --------------");


                if (mFactory.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    mFactory.Close();
                }
            }
            catch (TimeoutException)
            {
                // Handle the timeout exception.
                mFactory.Abort();
            }
            catch (CommunicationException)
            {
                // Handle the communication exception.
                mFactory.Abort();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled exception: " + ex.ToString());
                mFactory.Abort();
            }

        }
 /// <summary>
 /// Method to Instantiate Duplex channel factory for Waiter Service
 /// </summary>
 private void InitializeWaiterChannel()
 {
     try
     {
         this.waiterServiceAddress = new EndpointAddress(new Uri("net.tcp://localhost:4502/WaiterService"));
         this.callbackInstance = new InstanceContext(new OrderNotifitcation());
         this.waiterServiceFactory = new DuplexChannelFactory<IWaiterService>(
             this.callbackInstance,
             new NetTcpBinding(),
             this.waiterServiceAddress);
         this.waiterClient = this.waiterServiceFactory.CreateChannel();
         this.guid = Guid.NewGuid();
         this.waiterClient.RegisterWaiter(this.guid);
         this.errorProvider = new ErrorProvider();
     }
     catch (FaultException<RestaurantService.Contracts.ServiceFaultDetails> ex)
     {
         MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (CommunicationException ex)
     {
         ((IClientChannel)waiterClient).Abort();
         waiterClient = null;
         MessageBox.Show(ex.Message, "Communication Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         waiterServiceFactory.Abort();
         System.Environment.Exit(1);
     }
 }
        internal static string InternalGetCookiesWinApiOnProxy(Uri url, string key)
        {
            var processId = Process.GetCurrentProcess().Id.ToString();
            var endpointUrl = new Uri(string.Format("net.pipe://localhost/SnkLib.App.CookieGetter.x86Proxy/{0}/Service/", processId));
            string lpszCookieData = null;
            ChannelFactory<IProxyService> proxyFactory = null;
            Process proxyProcess = null;
            //多重呼び出しされる事がよくあるため、既に起動しているx86ProxyServiceの存在を期待する。
            //初回呼び出しなど期待外れもあり得るので2回は試行する。
            for (var i = 0; i < 2; i++)
                try
                {
                    proxyFactory = new ChannelFactory<IProxyService>(new NetNamedPipeBinding(), endpointUrl.AbsoluteUri);
                    var proxy = proxyFactory.CreateChannel();
                    var hResult = proxy.GetCookiesFromProtectedModeIE(out lpszCookieData, url, key);
                    break;
                }
                catch (CommunicationException)
                {
                    //x86Serviceからの起動完了通知受信用
                    using (var pipeServer = new System.IO.Pipes.AnonymousPipeServerStream(
                        System.IO.Pipes.PipeDirection.In, HandleInheritability.Inheritable))
                    {
                        proxyProcess = Process.Start(
                            new System.Diagnostics.ProcessStartInfo()
                            {
#if IS_CGS
                                FileName = @".\Win32\SnkLib.App.CookieGetter.x86Proxy.exe",
#else
                                FileName = @".\x86\SnkLib.App.CookieGetter.x86Proxy.exe",
#endif
                                //サービス側のendpointUrlに必要な情報をコマンドライン引数として渡す
                                Arguments = string.Join(" ", new[] { processId, pipeServer.GetClientHandleAsString(), }),
                                CreateNoWindow = true,
                                UseShellExecute = false,
                            });
                        pipeServer.ReadByte();
                    }
                }
                finally { proxyFactory.Abort(); }
            return lpszCookieData;
        }
Ejemplo n.º 20
0
        internal static void worker(int loop, string name)
        {
            //ThreadPool.QueueUserWorkItem(delegate
            //{
                ChannelFactory<ITest> factory = null;
                ITest channel = null;

                try
                {
                    factory = new ChannelFactory<ITest>(name);
                    channel = factory.CreateChannel();

                    channel.Ping(loop); 

                    channel.Ping2(loop);

                    channel.Ping3(loop);

                    //Thread.Sleep(10000);

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(string.Format("\n[{0}, {1:####.###}]: DONE, tid={2}\n", loop, name, Thread.CurrentThread.GetHashCode()));
                    Console.ResetColor();

                    //Console.WriteLine("\n+++ press any key to close this channel +++\n");
                    //Console.ReadLine();

                    ((IChannel)channel).Close();
                    factory.Close();
                }
                catch (Exception ex)
                {
                    if (channel != null) ((IChannel)channel).Abort();
                    if (factory != null) factory.Abort();

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n" + (ex.InnerException == null ? ex.Message : ex.InnerException.Message));
                    Console.ResetColor();
                }
            //});
        }
Ejemplo n.º 21
0
        private Stream CallWebMethod(
            Stream requestData,
            string serviceUrl,
            string action,
            string username,
            string password,
            Context ctx )
        {
            try
            {
                Stream responseData;
                var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.UseDefaultWebProxy = true;               

                var epa = new EndpointAddress(new Uri(serviceUrl));

                ChannelFactory<genericContract> cf = null;
                genericContract channel;
                Message request;
                Message response;
                string responseString;

                try
                {
                    cf = new ChannelFactory<genericContract>(binding, epa);
                    cf.Credentials.UserName.UserName = username;
                    cf.Credentials.UserName.Password = password;
                    
                    cf.Open();
                    channel = cf.CreateChannel();
                    using (new OperationContextScope((IContextChannel)channel))
                    {
                        XmlReader r = new XmlTextReader(requestData);

                        request = Message.CreateMessage(MessageVersion.Soap11, action, r);

                        foreach (var header in _soapHeaders)
                        {
                            MessageHeader messageHeader = MessageHeader.CreateHeader(header.HeaderName, header.HeaderNameSpace, header.HeaderInstance);
                            OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader);
                        }
                        
                        response = channel.Invoke(request);

                        string responseStr = response.GetReaderAtBodyContents().ReadOuterXml();
                        ctx.LogXmlData("Response", responseStr);
                        responseData = StreamHelper.LoadMemoryStream(responseStr); 
                    }
                    request.Close();
                    response.Close();
                    cf.Close();
                }
                catch (CommunicationException ce)
                {
                    ctx.LogException(ce);
                    if (cf != null)
                    {
                        cf.Abort();
                    }
                    throw;
                }
                catch (TimeoutException te)
                {
                    ctx.LogException(te);
                    if (cf != null)
                    {
                        cf.Abort();
                    }
                    throw;
                }
                catch (Exception e)
                {
                    ctx.LogException(e);
                    if (cf != null)
                    {
                        cf.Abort();
                    }
                    throw;
                }

                return responseData;
            }
            catch (Exception ex)
            {
                ctx.LogException(ex);
                throw;
            }
        }
Ejemplo n.º 22
0
 private void bBasicHttp_Click(object sender, EventArgs e)
 {
     var binding = new WebHttpBinding(WebHttpSecurityMode.None);
     using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(binding, TestService.BasicHttpAddress))
     {
         try
         {
             cf.Endpoint.Behaviors.Add(new WebHttpBehavior());
             ITestService ts = cf.CreateChannel();
             string rlt = ts.TestHttp();
             Log(rlt);
         }
         catch (FaultException ex)
         {
             MessageBox.Show(ex.ToString());
             cf.Abort();
         }
     }
 }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            using (ChannelFactory<ISpoti15WCF> spotFactory = new ChannelFactory<ISpoti15WCF>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/Spoti15WCF")))
            {
                try
                {
                    ISpoti15WCF iface = spotFactory.CreateChannel();
                    iface.Shutdown();
                    spotFactory.Close();

                    System.Threading.Thread.Sleep(1000);
                }
                catch
                {
                    spotFactory.Abort();
                    spotFactory.Close();
                }
            }

            host = new ServiceHost(typeof(Spoti15WcfImpl), new Uri[] { new Uri("net.pipe://localhost") });
            host.AddServiceEndpoint(typeof(ISpoti15WCF), new NetNamedPipeBinding(), "Spoti15WCF");
            host.Open();

            if (args.Length == 0 || args[0] != "-autostart")
            {
                Properties.Settings.Default.HideIcon = false;
                Properties.Settings.Default.Save();
            }

            ContextMenu cm = new ContextMenu();
            MenuItem menu;

            menu = new MenuItem();
            menu.Text = "&Hide tray icon";
            menu.Click += HideClick;
            cm.MenuItems.Add(menu);

            menu = new MenuItem();
            menu.Checked = Autostart.IsEnabled();
            menu.Text = "&Autostart";
            menu.Click += AutostartClick;
            cm.MenuItems.Add(menu);
            autostartItem = menu;

            cm.MenuItems.Add("-");

            menu = new MenuItem();
            menu.Text = "E&xit";
            menu.Click += ExitClick;
            cm.MenuItems.Add(menu);

            notico = new NotifyIcon();
            notico.Text = "Spoti15";
            notico.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            notico.ContextMenu = cm;
            notico.Visible = !Properties.Settings.Default.HideIcon;

            Spoti15 spoti15 = new Spoti15();

            Application.Run();

            GC.KeepAlive(spoti15);
            host.Close();
        }
        /// <summary>
        /// Метод синхронизации
        /// </summary>
        /// <param name="aLinkSyncServiceEntitiesId"></param>
        /// <param name="aIsFullSync"></param>
        /// <returns></returns>
        public static string EntitySync(double aLinkSyncServiceEntitiesId, bool aIsFullSync = false)
        {
            var beginArgument = new SyncEventArgument {Exception = null, Result = aLinkSyncServiceEntitiesId};
            OnBeginSync(beginArgument);
            
            _logger.Trace("EntitySync: Начата синхронизация: {0}", aLinkSyncServiceEntitiesId);
            LinkSyncServEntId = aLinkSyncServiceEntitiesId;
            IsFullSync = aIsFullSync;
            var lResult = string.Empty;
            try
            {
                using (var lData = new SyncServicesEntities(GetConnectionString()))
                {
                    lData.Connection.Open();
                    try
                    {
                        var lSyncDateTime = lData.GET_SYSDATE();
                        _syncParams = lData.GetSyncServiceData(aLinkSyncServiceEntitiesId);
                        if (_syncParams == null)
                        {
                            var ex = new NullReferenceException(lResult);
                            OnEndSync(new SyncEventArgument{Exception =ex,Result = lResult});
                            return lResult;
                        }
                        var lIteratorNumber = 1;
                        var lErrorMsg = string.Empty;
                        var lJSonElements = string.Empty;
                        int lSyncResult;
                        do
                        {
                            switch (Convert.ToInt16(lData.GetLinkSyncServEntData(aLinkSyncServiceEntitiesId, lIteratorNumber, ref lJSonElements, ref lErrorMsg)))
                            {
                                case 0: // ошибка
                                    lSyncResult = 0;
                                    lResult = lErrorMsg;
                                    break;
                                case 1: // успешное получение данных. 
                                    lSyncResult = 1;
                                    if (lJSonElements != string.Empty)
                                    {
                                        // успешное получение данных. данные не пустые. запускаем синхронизацию
                                        // формируем данные для передачи на филиал
                                        var lInData = new USInServiceValues
                                                          {
                                                              EntityTypeId = _syncParams.ElsysTypeId,
                                                              JsonEntityData = Convert.ToString(lJSonElements)
                                                          };
                                        // серриализация данных для передачи на филиал
                                        var lJsonInData = JsonConvert.SerializeObject(lInData);
                                        _logger.Trace("EntitySync: Кодировка на клиенте {0}", Encoding.Default.EncodingName);
                                        // создаем поток который будет передан на филиал
                                        var DBEncoding = Encoding.GetEncoding(Properties.Settings.Default.DBEncodingName);
                                        var TransmissionEncoding = Encoding.GetEncoding(Properties.Settings.Default.TransmissionEncodingName);
                                        _logger.Trace("EntitySync: Кодировка на базе {0}", DBEncoding.EncodingName);
                                        _logger.Trace("EntitySync: Кодировка передачи {0}", TransmissionEncoding.EncodingName);
                                        using (var ms = new MemoryStream(Encoding.Convert(DBEncoding, TransmissionEncoding, DBEncoding.GetBytes(lJsonInData))))
                                        {
                                            var lBinding = new TcpChunkingBinding
                                                               {
                                                                   OpenTimeout = Properties.Settings.Default.OpenTimeout,
                                                                   ReceiveTimeout =
                                                                       Properties.Settings.Default.ReceiveTimeout,
                                                                   SendTimeout = Properties.Settings.Default.SendTimeout,
                                                                   CloseTimeout = Properties.Settings.Default.CloseTimeout
                                                               };

                                            var endPointAdress = _syncParams.EndPointAddress;
                                            //endPointAdress = string.Empty;
                                            using (var factory = new ChannelFactory<IUSExService>(lBinding, new EndpointAddress(endPointAdress)))
                                            {
                                                try
                                                {
                                                    var service = factory.CreateChannel();
                                                    var lRetValuesStr = service.EntitySync(ms);
                                                    factory.Close();
                                                    var lRetValues = JsonConvert.DeserializeObject<USInServiceRetValues>(lRetValuesStr);
                                                    lSyncResult = Convert.ToInt16(lRetValues.Result);
                                                    lResult = lRetValues.ErrorMessage;
                                                }
                                                catch (Exception e)
                                                {
                                                    lResult =
                                                        string.Format("EntitySync: Синхронизация LinkSyncServiceEntitiesId = {0} закончилась с ошибкой. Ошибка: {1}",
                                                                      aLinkSyncServiceEntitiesId, e);
                                                    OnErrorSync(new SyncEventArgument {Exception = e,Result = lResult});
                                                    continue;
                                                }
                                                factory.Abort();
                                            }
                                            ms.Close();
                                        }
                                    }
                                    break;
                                case 2: // ошибки не было но данные не были получены
                                    lSyncResult = 2;
                                    lResult = lErrorMsg;
                                    OnErrorSync(new SyncEventArgument {Exception = null,Result = lResult});
                                    continue;
                                    //break;
                                default: lSyncResult = 0;
                                    lResult = string.Format("EntitySync: Синхронизация LinkSyncServiceEntitiesId = {0} закончилась с ошибкой. Не прогнозируемый результат получения данных",
                                                            aLinkSyncServiceEntitiesId);
                                    OnErrorSync(new SyncEventArgument {Exception = null,Result = lResult});
                                    continue;
                                    //break;
                            }

                            lIteratorNumber += 1;
                        }
                        while ((lSyncResult == 1) && (lJSonElements != string.Empty));

                        switch (lSyncResult)
                        {
                            case 0:
                                var s0 = string.Format("Ошибка при синхронизация сущности EntitySync: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}; Ошибка {5}",
                                              aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                              _syncParams.ElsysTypeName, _syncParams.BranchName, lResult);
                                OnEndSync(new SyncEventArgument {Exception = null,Result = s0});
                                break;
                            case 1:
                                lData.SET_LINK_SYNC_SERV_CALL_DATA(Convert.ToDecimal(LinkSyncServEntId), lSyncDateTime);

                                var s1 =string.Format("Успешная синхронизация сущности EntitySync: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}",
                                              aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                              _syncParams.ElsysTypeName, _syncParams.BranchName);
                                OnEndSync(new SyncEventArgument {Exception = null,Result = s1});
                                break;
                            case 2:
                                var s2 = string.Format("Cинхронизация сущности EntitySync не завершена: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}. Причина {5}",
                                              aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                              _syncParams.ElsysTypeName, _syncParams.BranchName, lResult);
                                OnEndSync(new SyncEventArgument {Exception = null,Result = s2});
                                lResult = string.Empty;
                                break;
                        }
                    }
                    finally
                    {
                        lData.Connection.Close();
                        lData.Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                lResult =
                    string.Format("EntitySync: Синхронизация LinkSyncServiceEntitiesId = {0} закончилась с ошибкой. Ошибка: {1}",
                                  aLinkSyncServiceEntitiesId, e);
                
                OnErrorSync(new SyncEventArgument {Exception = e,Result = lResult});
            }
            OnEndSync(new SyncEventArgument {Exception = null,Result = aLinkSyncServiceEntitiesId});
            return lResult;
        }
Ejemplo n.º 25
0
 string PrivateGetCookiesWinApi(Uri url, string key)
 {
     #if DEBUG
     //動作確認用
     //-1:分岐指定なし、0:IE11以上時の処理、1:IE8以上でx64の時の処理
     var specifyPath_Debug = -1;
     #else
     var specifyPath_Debug = -1;
     #endif
     var ieVersion = win32api.GetIEVersion();
     //IEのバージョンによって使えるAPIに違いがあるため、分岐させる。
     //IE11以上はクッキー取得APIを使用する。IE11からはx64モード下でも使用可能になっている。
     //IE8以上もx86環境では問題ないので一緒に取得させておく。
     if((ieVersion.Major >= 11 || ieVersion.Major >= 8 && Environment.Is64BitProcess == false) && specifyPath_Debug < 0 || specifyPath_Debug == 0) {
         string lpszCookieData;
         var hResult = win32api.GetCookiesFromProtectedModeIE(out lpszCookieData, url, key);
         Debug.WriteLineIf(
             lpszCookieData == null, string.Format("win32api.GetCookieFromProtectedModeIE error code:{0}", hResult));
         return lpszCookieData ?? string.Empty;
     }
     //IE8以上はクッキー取得APIを使用する。
     //x64モード下での使用は未対応なのでx86の子プロセスを経由させる
     else if(ieVersion.Major >= 8 && specifyPath_Debug < 0 || specifyPath_Debug == 1) {
         var processId = Process.GetCurrentProcess().Id.ToString();
         var endpointUrl = new Uri(string.Format("net.pipe://localhost/CookieGetterSharp.x86Proxy/{0}/Service/", processId));
         var lpszCookieData = string.Empty;
         ChannelFactory<IX86ProxyService> proxyFactory = null;
         Process proxyProcess = null;
         //多重呼び出しされる事がよくあるため、既に起動しているx86ProxyServiceの存在を期待する。
         //初回呼び出しなど期待外れもあり得るので2回は試行する。
         for(var i = 0; i < 2; i++)
             try {
                 proxyFactory = new ChannelFactory<IX86ProxyService>(new NetNamedPipeBinding(), endpointUrl.AbsoluteUri);
                 var proxy = proxyFactory.CreateChannel();
                 var hResult = proxy.GetCookiesFromProtectedModeIE(out lpszCookieData, url, key);
                 Debug.WriteLineIf(
                     lpszCookieData == null, string.Format("proxy.GetCookieFromProtectedModeIE error code:{0}", hResult));
                 break;
             }
             catch(CommunicationException) {
                 //x86Serviceからの起動完了通知受信用
                 using(var pipeServer = new System.IO.Pipes.AnonymousPipeServerStream(
                     System.IO.Pipes.PipeDirection.In, HandleInheritability.Inheritable)) {
                     proxyProcess = Process.Start(
                         new System.Diagnostics.ProcessStartInfo() {
                             FileName = ".\\CookieGetterSharp.x86Proxy.exe",
                             //サービス側のendpointUrlに必要な情報をコマンドライン引数として渡す
                             Arguments = string.Join(" ", new[] { processId, pipeServer.GetClientHandleAsString(), }),
                             CreateNoWindow = true,
                             UseShellExecute = false,
                         });
                     pipeServer.ReadByte();
                 }
             }
             finally { proxyFactory.Abort(); }
         return lpszCookieData ?? string.Empty;
     }
     else
         return string.Empty;
 }
        /// <summary>
        /// Method to Clean up.
        /// </summary>
        private void CleanUp()
        {
            try
            {
                this.timer.Stop();
                ((IClientChannel)chefClient).Close();
                chefClient = null;
                chefServiceFactory.Close();
                chefServiceFactory = null;
            }
            catch (CommunicationException commProblem)
            {
                Console.WriteLine(commProblem.Message);

                if (chefServiceFactory != null)
                {
                    chefServiceFactory.Abort();
                }

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                if (chefServiceFactory != null)
                {
                    chefServiceFactory.Abort();
                }

                Console.ReadLine();
            }
            finally
            {
                if (chefClient != null)
                {
                    ((IClientChannel)chefClient).Close();
                }

                if (chefServiceFactory != null)
                {
                    chefServiceFactory.Abort();
                }
            }
        }
Ejemplo n.º 27
0
 public void Abort()
 {
     _channelFactory.Abort();
 }
        /// <summary>
        /// Method to Clean up.
        /// </summary>
        private void CleanUp()
        {
            try
            {
                errorProvider = null;
                waiterClient.DeRegisterWaiter(guid);
                ((IClientChannel)waiterClient).Close();
                waiterClient = null;
                waiterServiceFactory.Close();
                waiterServiceFactory = null;
            }
            catch (CommunicationException commProblem)
            {
                Console.WriteLine(commProblem.Message);

                if (waiterServiceFactory != null)
                {
                    waiterServiceFactory.Abort();
                }

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                if (waiterServiceFactory != null)
                {
                    waiterServiceFactory.Abort();
                }

                Console.ReadLine();
            }
            finally
            {
                if (waiterClient != null)
                {
                    ((IClientChannel)waiterClient).Close();
                }

                if (waiterServiceFactory != null)
                {
                    waiterServiceFactory.Abort();
                }
            }
        }
        public string EntitySync(double aLinkSyncServiceEntitiesId, bool aIsFullSync = false)
        {
            this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, "EntitySync: Начата синхронизация: {0}", aLinkSyncServiceEntitiesId);
            LinkSyncServEntId = aLinkSyncServiceEntitiesId;
            IsFullSync = aIsFullSync;
            string lResult = string.Empty;
            
            try
            {
                using (var lData = new SyncServicesEntities(GetConnectionString()))
                {
                    lData.Connection.Open();
                    try
                    {
                        var lSyncDateTime = lData.GET_SYSDATE();
                        _syncParams = lData.GetSyncServiceData(aLinkSyncServiceEntitiesId);

                        if (_syncParams == null)
                        {
                            lResult = string.Format("EntitySync: aLinkSyncServiceEntitiesId = {0} параметры синхронизации не определены", aLinkSyncServiceEntitiesId);
                            this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, lResult);
                            return lResult;
                        }

                        this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, "EntitySync: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}",
                                aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                _syncParams.ElsysTypeName, _syncParams.BranchName);
                        int lIteratorNumber = 1;
                        var lErrorMsg = string.Empty;
                        var lJSonElements = string.Empty;
                        int lSyncResult = 0;

                        do
                        {
                            this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} данные по сущности получены и сериализованы. Шаг {1}", aLinkSyncServiceEntitiesId, lIteratorNumber);
                            switch (Convert.ToInt16(lData.GetLinkSyncServEntData(aLinkSyncServiceEntitiesId, lIteratorNumber, ref lJSonElements, ref lErrorMsg)))
                            {
                                case 0: // ошибка
                                    lSyncResult = 0;
                                    lResult = lErrorMsg;
                                    break;
                                case 1: // успешное получение данных. 
                                    lSyncResult = 1;
                                    if (lJSonElements != string.Empty)
                                    {
                                        // успешное получение данных. данные не пустые. запускаем синхронизацию

                                        // формируем данные для передачи на филиал
                                        var lInData = new USInServiceValues
                                        {
                                            EntityTypeId = _syncParams.ElsysTypeId,
                                            JsonEntityData = Convert.ToString(lJSonElements)
                                        };

                                        // серриализация данных для передачи на филиал
                                        string lJsonInData = Newtonsoft.Json.JsonConvert.SerializeObject(lInData);
                                        if (Properties.Settings.Default.NeedLogSyncData)
                                        {
                                            this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} lJsonInData сформирован = {1}", aLinkSyncServiceEntitiesId, lJsonInData);
                                        }
                                        lInData = null;

                                        this.WriteLog(USLogLevel.Trace, "EntitySync: Кодировка на клиенте {0}", Encoding.Default.EncodingName);
                                        // создаем поток который будет передан на филиал
                                        var DBEncoding = Encoding.GetEncoding(Properties.Settings.Default.DBEncodingName);
                                        var TransmissionEncoding = Encoding.GetEncoding(Properties.Settings.Default.TransmissionEncodingName);
                                        this.WriteLog(USLogLevel.Trace, "EntitySync: Кодировка на базе {0}", DBEncoding.EncodingName);
                                        this.WriteLog(USLogLevel.Trace, "EntitySync: Кодировка передачи {0}", TransmissionEncoding.EncodingName);

                                        using (var ms = new MemoryStream(Encoding.Convert(DBEncoding, TransmissionEncoding, DBEncoding.GetBytes(lJsonInData))))
                                        {
                                            this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} MemoryStream создан", aLinkSyncServiceEntitiesId);
                                            lJsonInData = String.Empty;

                                            var lBinding = new TcpChunkingBinding();
                                            lBinding.OpenTimeout = Properties.Settings.Default.OpenTimeout;
                                            lBinding.ReceiveTimeout = Properties.Settings.Default.ReceiveTimeout;
                                            lBinding.SendTimeout = Properties.Settings.Default.SendTimeout;
                                            lBinding.CloseTimeout = Properties.Settings.Default.CloseTimeout;

                                            this.WriteLog(USLogLevel.Trace, "lBinding params lBinding.OpenTimeout = {0}; lBinding.ReceiveTimeout = {1}; lBinding.SendTimeout = {2}; lBinding.CloseTimeout = {3}", lBinding.OpenTimeout, lBinding.ReceiveTimeout, lBinding.SendTimeout, lBinding.CloseTimeout);

                                            using (var factory = new ChannelFactory<IUSExService>(lBinding, new EndpointAddress(_syncParams.EndPointAddress)))
                                            {
                                                try
                                                {
                                                    this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} ChannelFactory created", aLinkSyncServiceEntitiesId);
                                                    IUSExService service = factory.CreateChannel();
                                                    this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} IUSExService service = factory.CreateChannel created", aLinkSyncServiceEntitiesId);
                                                    
                                                    var lRetValuesStr = service.EntitySync(ms);

                                                    this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} service.EntitySync выполнен", aLinkSyncServiceEntitiesId);
                                                    factory.Close();
                                                    this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} ChannelFactory Closed", aLinkSyncServiceEntitiesId);

                                                    this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} Returned Value Deserialized", aLinkSyncServiceEntitiesId);
                                                    var lRetValues = Newtonsoft.Json.JsonConvert.DeserializeObject<USInServiceRetValues>(lRetValuesStr);
                                                    lSyncResult = Convert.ToInt16(lRetValues.Result);
                                                    lResult = lRetValues.ErrorMessage;
                                                }
                                                catch (Exception e)
                                                {
                                                    lResult =
                                                        string.Format("EntitySync: Синхронизация LinkSyncServiceEntitiesId = {0} закончилась с ошибкой. Ошибка: {1}",
                                                                      aLinkSyncServiceEntitiesId, e);
                                                    this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, lResult, e);
                                                    this.WriteLogException(lResult, e);
                                                }
                                                factory.Abort();
                                            }
                                        }
                                    }
                                    break;
                                case 2: // ошибки не было но данные не были получены
                                    lSyncResult = 2;
                                    lResult = lErrorMsg;
                                    break;
                                default: lSyncResult = 0;
                                    lResult = string.Format("EntitySync: Синхронизация LinkSyncServiceEntitiesId = {0} закончилась с ошибкой. Не прогнозируемый результат получения данных",
                                                              aLinkSyncServiceEntitiesId);
                                    break;
                            }

                            lIteratorNumber += 1;
                        }
                        while ((lSyncResult == 1) && (lJSonElements != string.Empty));

                        switch (lSyncResult)
                        {
                            case 0:
                                this.WriteLog(USLogLevel.Trace | USLogLevel.Debug | USLogLevel.Error, "Ошибка при синхронизация сущности EntitySync: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}; Ошибка {5}",
                                aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                _syncParams.ElsysTypeName, _syncParams.BranchName, lResult);
                                break;
                            case 1: 
                                lData.SET_LINK_SYNC_SERV_CALL_DATA(Convert.ToDecimal(LinkSyncServEntId), lSyncDateTime);

                                this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, "Успешная синхронизация сущности EntitySync: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}",
                                    aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                    _syncParams.ElsysTypeName, _syncParams.BranchName);
                                break;
                            case 2:
                                this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, "Cинхронизация сущности EntitySync не завершена: aLinkSyncServiceEntitiesId = {0} Описание {1}; Сущность {2}: {3}; Филиал {4}. Причина {5}",
                                    aLinkSyncServiceEntitiesId, _syncParams.Description, _syncParams.ElsysTypeId,
                                    _syncParams.ElsysTypeName, _syncParams.BranchName, lResult);
                                lResult = string.Empty;
                                break;
                            default:
                                break;
                        }
                    }
                    finally
                    {
                        lData.Connection.Close();
                        this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} Соединение закрыто", aLinkSyncServiceEntitiesId);
                        lData.Dispose();
                        this.WriteLog(USLogLevel.Trace, "EntitySync: aLinkSyncServiceEntitiesId = {0} lData.Dispose done", aLinkSyncServiceEntitiesId);
                    }
                }
            }
            catch (Exception e)
            {
                lResult =
                    string.Format("EntitySync: Синхронизация LinkSyncServiceEntitiesId = {0} закончилась с ошибкой. Ошибка: {1}",
                                  aLinkSyncServiceEntitiesId, e);
                this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, lResult, e);
                this.WriteLogException(lResult, e);
            }
            this.WriteLog(USLogLevel.Trace | USLogLevel.Debug, "EntitySync: Завершена синхронизация: {0}", aLinkSyncServiceEntitiesId);

            return lResult;
        }