Example #1
0
        /// <summary>
        /// 
        /// </summary>
        internal ClientSocketManager( Listener listener, ServiceHandler serviceHandler, ReceiveQueue receiveBuffer )
        {
            if ( listener == null )
                throw new ArgumentNullException( "listener", "ClientSocketHandler.ClientSocketManager(...) - listener == null error!" );

            if ( serviceHandler == null )
                throw new ArgumentNullException( "serviceHandler", "ClientSocketHandler.ClientSocketManager(...) - serviceHandle == null error!" );

            if ( receiveBuffer == null )
                throw new ArgumentNullException( "receiveBuffer", "ClientSocketHandler.ClientSocketManager(...) - receiveBuffer == null error!" );

            m_Listener = listener;
            m_ServiceHandle = serviceHandler;
            m_ReceiveBuffer = receiveBuffer;
            {
                // �������
                m_ReceiveBuffer.Clear();
            }

            m_ServiceHandle.EventProcessData += OnListenerProcessMessageBlock;
            m_ServiceHandle.EventDisconnect += OnListenerDisconnect;

            // ��ʼ������ ��ʾ��û���ù�Free(...)����
            m_LockFree.SetValid();
        }
        public void ShouldThrowIfRegisterIsCalledBeforeAuthenticated()
        {
            var handler = new ServiceHandler(FakeUri);
            var model = new RegisterUserModel();

            Assert.That(() => handler.RegisterNewUser(model), Throws.InvalidOperationException);
        }
        /// <summary>
        /// 
        /// </summary>
        internal ClientSocketManager( Listener listener, ServiceHandler serviceHandler, ReceiveQueue receiveBuffer )
        {
            if ( listener == null )
                throw new Exception( "ClientSocketHandler.ClientSocketManager(...) - listener == null error!" );

            if ( serviceHandler == null )
                throw new Exception( "ClientSocketHandler.ClientSocketManager(...) - serviceHandle == null error!" );

            if ( receiveBuffer == null )
                throw new Exception( "ClientSocketHandler.ClientSocketManager(...) - receiveBuffer == null error!" );

            m_Listener = listener;
            m_ServiceHandle = serviceHandler;
            m_ReceiveBuffer = receiveBuffer;
            {
                // 清空数据
                m_ReceiveBuffer.Clear();
            }

            m_ServiceHandle.EventProcessData += new EventHandler<ProcessDataAtServerEventArgs>( this.OnListenerProcessMessageBlock );
            m_ServiceHandle.EventDisconnect += new EventHandler<DisconnectAtServerEventArgs>( this.OnListenerDisconnect );

            // 初始化数据 表示还没调用过Free(...)函数
            m_LockFree.SetValid();
        }
Example #4
0
        public void LoginAs(string username, string password)
        {
            Guard.VerifyStringIsNotNullOrEmpty(username, nameof(username));
            Guard.VerifyStringIsNotNullOrEmpty(password, nameof(password));

            var serviceLocation = GetServiceLocationFromAppConfig();

            if (string.IsNullOrEmpty(serviceLocation))
            { throw new Exception("Service Location must be present"); }

            _serviceHandler = new ServiceHandler(serviceLocation);
            IsLoggedIn = _serviceHandler.LoginAs(username, password);
        }
Example #5
0
        /// <summary>
        /// Prepara as impressoras lógicas do servidor para o monitoramento do spool. Seta seus
        /// atributos Direct, Queued e DoCompleteFirst. Desliga o file pooling de todas elas para
        /// que os print jobs tenham seus arquivos de spool(.SPL/.SHD) gravados corretamente
        /// </summary>
        public static void PreparePrinters(IListener listener)
        {
            // O file pooling gera arquivos no formato FP00000.SPL/SHD e impede o funcionamento
            // correto do monitor de spool (é um feature de SOs a partir do Win XP e Win 2003)
            // No site de suporte da Microsoft existe uma artigo descrevendo o problema
            // Artigo :  Third-Party Print Management Program Does Not Work as Expected
            //           After You Upgrade to Windows Server 2003 or Windows XP
            RegistryKey regKey          = null;
            String      defaultSpoolDir = null;

            try
            {
                regKey          = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Print\Printers");
                defaultSpoolDir = (String)regKey.GetValue("DefaultSpoolDirectory");
            }
            catch (Exception exception)
            {
                if (listener != null)
                {
                    listener.NotifyObject(exception);
                }
                return;
            }

            // Para cada impressora faz ajustes necessários para o funcionamento do spool
            foreach (String printer in regKey.GetSubKeyNames())
            {
                try
                {
                    RegistryKey printerKey = regKey.OpenSubKey(printer, true);

                    PrinterAttributesEnum printerAttributes = (PrinterAttributesEnum)printerKey.GetValue("Attributes");
                    // Desabilita impressão direto na impressora (força o uso de spool)
                    printerAttributes = printerAttributes & ~PrinterAttributesEnum.Direct;
                    // Habilita o uso de EMF para os trabalhos de impressão (RAW ou EMF)
                    printerAttributes = printerAttributes & ~PrinterAttributesEnum.RawOnly;
                    // Habilita buferização completa do job pré impressão
                    printerAttributes = printerAttributes | PrinterAttributesEnum.Queued;
                    // Determina que a ordem de impressão dos jobs deve ser "Complete First"
                    printerAttributes = printerAttributes | PrinterAttributesEnum.DoCompleteFirst;
                    printerKey.SetValue("Attributes", printerAttributes, RegistryValueKind.DWord);

                    // O preenchimento da propriedade SpoolDirectory desliga o "file pooling"
                    printerKey.SetValue("SpoolDirectory", defaultSpoolDir);

                    printerKey.Close();
                }
                catch (Exception exception)
                {
                    // Notifica a exceção e passa para a próxima impressora do "foreach"
                    if (listener != null)
                    {
                        listener.NotifyObject(exception);
                    }
                }
            }
            regKey.Close();

            // Reinicia o spooler de impressão para que as alterações tenham efeito
            ServiceHandler.StopService("Spooler", 5000);
            ServiceHandler.StartService("Spooler", 5000);
        }
        public void ShouldThrowArgumentExceptionIfModelNullWhenRegistering()
        {
            var handler = new ServiceHandler(FakeUri);

            Assert.Throws<ArgumentNullException>(() => handler.RegisterNewUser(null));
        }
 /// <summary>
 /// The on create.
 /// </summary>
 public override void OnCreate()
 {
     base.OnCreate();
     var localHandlerThread = new HandlerThread("IntentService[" + this.name + "]");
     localHandlerThread.Start();
     this.serviceLooper = localHandlerThread.Looper;
     this.serviceHandler = new ServiceHandler(this.serviceLooper, this);
 }
Example #8
0
 internal ServiceCaller(string service, Type responseType, ServiceHandler serviceHandler)
 {
     Service        = service;
     ResponseType   = responseType;
     ServiceHandler = serviceHandler;
 }
Example #9
0
 public MobilePresenter()
 {
     objComm = new CommonUtil();
     objServiceHandler = new ServiceHandler();
     objTblSvc = new TableService();
     objSvcPre = new ServicePresenter();
     svcInfo = ServiceInfo.ServiceConfig;
 }
Example #10
0
 /// <summary>
 /// Keep track of all UPnP devices on the network. The user can expect the OnAddedDeviceSink
 /// delegate to immidiatly be called for each device that is already known that matches the
 /// filter.
 /// </summary>
 /// <param name="OnAddedDeviceSink">Delegate called when a UPnP device is detected that match the filter</param>
 /// <param name="DevicePartialMatchFilter">Sets the filter to UPnP devices that start with this string</param>
 public UPnPSmartControlPoint(DeviceHandler OnAddedDeviceSink, ServiceHandler OnAddedServiceSink, string DevicePartialMatchFilter)
     : this(OnAddedDeviceSink, OnAddedServiceSink, new string[1] { DevicePartialMatchFilter })
 {
     MultiFilter = false;
 }
Example #11
0
 public bool SaveDevices(IEnumerable <DeviceSyncDto> devices)
 {
     Devices = devices;
     return(ServiceHandler.Save(Devices));
 }
        public override void OnCreate()
        {
            // TODO: It would be nice to have an option to hold a partial wakelock
            // during processing, and to have a static startService(Context, Intent)
            // method that would launch the service & hand off a wakelock.

            base.OnCreate();
            HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
            thread.Start();

            mServiceLooper = thread.Looper;
            mServiceHandler = new ServiceHandler(mServiceLooper, this);
        }
Example #13
0
        public ICollection <DeviceSyncDto> GetDevices()
        {
            var filter = new DeviceFilter();

            return(ServiceHandler.Get(filter).ToList());
        }
Example #14
0
 public bool SaveDevices()
 {
     return(ServiceHandler.Save(Devices));
 }
Example #15
0
 public void Dispose()
 {
     ServiceHandler.Dispose();
 }
 /// <summary> Reads asynchronously the service information. </summary>
 ///
 /// <returns> The service information. </returns>
 public async Task <ServiceInfo> InformationAsync()
 {
     return(await ServiceHandler.InformationAsync(this.httpClient, this.endpoint));
 }
        private void _loginButton_Click(object sender, EventArgs e)
        {
            _enableValidators = true;

            if (this.ValidateChildren() == false)
            {
                return;
            }


            //Disable the form
            SetLoggingIn(true);

            //Create a thread-safe delegate
            var launcherSignInComplete = new ServiceHandler.LauncherSignInCompleteDelegate(delegate(LauncherSignInResult launcherSignInResult)
            {
                //Unlock the form
                SetLoggingIn(false);

                if (launcherSignInResult.StatusSpecified == false)
                {
                    SetStatusBar("Failed to contact server, please try again later.", 0);
                }
                else
                {
                    switch (launcherSignInResult.Status)
                    {
                    case CheckInStatus.Ok:
                        if (LauncherSignInComplete != null)
                        {
                            LauncherSignInComplete(launcherSignInResult.Status);
                        }
                        break;

                    case CheckInStatus.AccountLinked:
                        if (ShowOfflineLaunch != null)
                        {
                            ShowOfflineLaunch(_usernameTextBox.Text, launcherSignInResult.LinkedAccount, false);
                        }
                        break;

                    case CheckInStatus.VirtualMachineBlocked:
                        if (ShowVirtualMachineInfo != null)
                        {
                            ShowVirtualMachineInfo(false);
                        }
                        break;

                    case CheckInStatus.InvalidCredentials:
                        SetStatusBar("Username or password was incorrect.", 0);
                        break;

                    case CheckInStatus.InvalidHash:
                        SetStatusBar("Machine information package was incorrect.", 0);
                        break;

                    case CheckInStatus.Timeout:
                        SetStatusBar("Server response timeout, please try again.", 0);
                        break;

                    case CheckInStatus.PermissionDenied:
                        SetStatusBar("Permission was denied, please try again.", 0);
                        break;

                    case CheckInStatus.AccountLocked:
                        SetStatusBar("Your account was locked out. Please use the forums for more help.", 0);
                        break;

                    default:
                        throw new NotSupportedException(launcherSignInResult.Status.ToString());
                    }
                }
            });

            //Check if the input credentials are valid
            ServiceHandler.LauncherSignIn(_usernameTextBox.Text, _passwordTextBox.Text, delegate(LauncherSignInResult launcherSignInResult)
            {
                //Check if it is safe to call the delegate from this thread
                if (this.InvokeRequired)
                {
                    this.Invoke(launcherSignInComplete, launcherSignInResult);
                }
                else
                {
                    launcherSignInComplete(launcherSignInResult);
                }
            });
        }
Example #18
0
 public static extern int RegisterServiceCtrlHandlerW( string lpServiceName,
     ServiceHandler lpHandlerProc);
Example #19
0
 public SQSXRayPipelineHandler()
 {
     _recorder       = AWSXRayRecorder.Instance;
     _serviceHandler = InitializeServiceHandler();
 }
Example #20
0
 public override void OnCreate()
 {
     var thread = new HandlerThread("RegressionTestService", Process.THREAD_PRIORITY_BACKGROUND);
     thread.Start();
     handler = new ServiceHandler(thread.Looper);
 }
Example #21
0
 public void Run(int threadCount, ServiceHandler handler)
 {
     this.RunHandler(threadCount, handler);
 }
Example #22
0
 public override void OnCreate()
 {
     base.OnCreate ();
     if (prefs == null)
         prefs = new PreferenceManager (this);
     var thread = new HandlerThread ("IntentService[BikrActivityService]");
     thread.Start ();
     serviceLooper = thread.Looper;
     serviceHandler = new ServiceHandler (this, serviceLooper);
 }
    public void DisplayLegend(string node, string name)
    {
        try
        {
            string TransString = string.Empty;
            //GetLegenddetails(node, name);
            //load only if station is selected
            //if (objDataPointInfo != null && (objDataPointInfo.stationLatitude != 0.0 || objDataPointInfo.stationLongitude != 0.0))
            {
                Label lblLegend = new Label();
                TransString = "";
                lblLegend.Text = TransString;
                lblLegend.CssClass = "label250";
                lblLegend.ID = "lbl_" + name;
                StringBuilder sbBody = new StringBuilder();
                StringBuilder sb1;
                StringBuilder sb;

                ServiceHandler serviceHandlerObj = new ServiceHandler();
                DataTable dtLegenddetails = serviceHandlerObj.GetLegendData(name);
                string legendPath = dtLegenddetails.Rows[0][2].ToString().ToString();
                using (StreamReader sr = new StreamReader(HttpRuntime.AppDomainAppPath + @"\Legends\" + legendPath))
                {
                    String line;
                    // Read and display lines from the file until the end of  the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {

                        sbBody.Append(line);

                    }
                    sb1 = new StringBuilder(sbBody.ToString().Substring(sbBody.ToString().IndexOf("<div"), (sbBody.ToString().IndexOf("</div>") - sbBody.ToString().IndexOf("<div") + 6)));

                    string strLegend = sb1.ToString();
                    //get delimiters from web.config
                    string startDelimiter = ConfigurationManager.AppSettings["startDelimiter"] != null && ConfigurationManager.AppSettings["startDelimiter"] != string.Empty ? ConfigurationManager.AppSettings["startDelimiter"] : "{";
                    string endDelimiter = ConfigurationManager.AppSettings["endDelimiter"] != null && ConfigurationManager.AppSettings["endDelimiter"] != string.Empty ? ConfigurationManager.AppSettings["endDelimiter"] : "}";
                    while (strLegend.IndexOf(endDelimiter) != -1)
                    {
                        int start = strLegend.IndexOf(startDelimiter);
                        int end = strLegend.IndexOf(endDelimiter);

                        string text = strLegend.Substring(start, end - start + startDelimiter.Count());
                        if (text != string.Empty)
                        {
                            TransString = getTransText(text.Substring(startDelimiter.Count(), text.Length - (endDelimiter.Count() + startDelimiter.Count())));
                            strLegend = strLegend.Remove(start) + TransString + strLegend.Substring(end + endDelimiter.Count());
                        }

                    }
                    sb = new StringBuilder(strLegend);
                }

                HtmlGenericControl div1 = new HtmlGenericControl("div");
                div1.ID = "divLegend_" + name;
                LiteralControl literal = new LiteralControl(sb.ToString());
                literal.ID = "legend_" + name;
                //System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
                //img.ImageUrl = "~/Images/boxminus.gif";
                //img.ID = "img1_" + name;
                //img.ClientIDMode = ClientIDMode.Static;
                //CentrePlaceHolder.Controls.Add(img);
                CentrePlaceHolder.Controls.Add(lblLegend);
                div1.Controls.Add(literal);
                CentrePlaceHolder.Controls.Add(div1);
            }
        }
        catch (Exception ex)
        {
            objSvcPre = new ServicePresenter();
            AgriCastException currEx = new AgriCastException(objSvcPre.GetServiceDetails(), ex);
            AgriCastLogger.Publish(currEx, AgriCastLogger.LogType.Error);
            HttpContext.Current.Session["ErrorMessage"] = objCommonUtil.getTransText(Constants.MOB_DISPLAYLEGEND_ERROR) + " : " + ex.Message.ToString();

        }
    }
Example #24
0
        /// <summary>
        /// Keep track of all UPnP devices on the network. The user can expect the OnAddedDeviceSink or OnAddedServiceSink
        /// delegate to immidiatly be called for each device that is already known.
        /// <para>
        /// if multiple filters are supplied, the results will be that of the parent device which satisfies all the search criteria. 
        /// </para>
        /// </summary>
        /// <param name="OnAddedDeviceSink"></param>
        /// <param name="OnAddedServiceSink"></param>
        /// <param name="Filters">Array of strings, which represent the search criteria</param>
        public UPnPSmartControlPoint(DeviceHandler OnAddedDeviceSink, ServiceHandler OnAddedServiceSink, string[] Filters)
        {
            //MultiFilter = true;
            PartialMatchFilters = new String[Filters.Length];
            MinimumVersion = new double[Filters.Length];
            for (int i = 0; i < PartialMatchFilters.Length; ++i)
            {
                if (Filters[i].Length > 15 && Filters[i].Length > UPnPStringFormatter.GetURNPrefix(Filters[i]).Length)
                {
                    PartialMatchFilters[i] = UPnPStringFormatter.GetURNPrefix(Filters[i]);
                    try
                    {
                        MinimumVersion[i] = double.Parse(Filters[i].Substring(PartialMatchFilters[i].Length), new CultureInfo("en-US").NumberFormat);
                    }
                    catch
                    {
                        MinimumVersion[i] = 1.0;
                    }
                }
                else
                {
                    PartialMatchFilters[i] = Filters[i];
                    MinimumVersion[i] = 1.0;
                }

            }

            if (OnAddedDeviceSink != null) { this.OnAddedDevice += OnAddedDeviceSink; }
            if (OnAddedServiceSink != null) { this.OnAddedService += OnAddedServiceSink; }

            iSCP.OnAddedDevice += new UPnPInternalSmartControlPoint.DeviceHandler(HandleAddedDevice);
            iSCP.OnDeviceExpired += new UPnPInternalSmartControlPoint.DeviceHandler(HandleExpiredDevice);
            iSCP.OnRemovedDevice += new UPnPInternalSmartControlPoint.DeviceHandler(HandleRemovedDevice);
            iSCP.OnUpdatedDevice += new UPnPInternalSmartControlPoint.DeviceHandler(HandleUpdatedDevice);

            IEnumerator cdEN = iSCP.GetCurrentDevices().GetEnumerator();
            if ((OnAddedDeviceSink != null || OnAddedServiceSink != null) && cdEN != null)
            {
                while (cdEN.MoveNext()) { HandleAddedDevice(null, (UPnPDevice)cdEN.Current); }
            }
        }
Example #25
0
 protected void Page_Init(object sender, EventArgs e)
 {
     //Initialize the objects
     objComm = new CommonUtil();
     objServiceHandler = new ServiceHandler();
     objMobPresenter = new MobilePresenter();
     svcInfo = new ServiceInfo();
     svcInfo = ServiceInfo.ServiceConfig;
 }
Example #26
0
 public void TestSerializationAndDeserialization()
 {
     FushareConfig cfg = new FushareConfig();
       ServiceConfigSection svc = new ServiceConfigSection();
       ServiceHandler handler1 = new ServiceHandler();
       handler1.type = typeof(BrunetDht).FullName;
       handler1.uri = new Uri("http://localhost:15151/xd.rem").ToString();
       svc.serviceHandlers = new ServiceHandler[] { handler1 };
       cfg.serviceConfig = svc;
       MemoryStream ms = new MemoryStream();
       FushareConfigHandler.Write(ms, cfg);
       Logger.WriteLineIf(LogLevel.Verbose, _log_props, Encoding.UTF8.GetString(ms.ToArray()));
       ms.Flush();
       ms.Position = 0;
       FushareConfig acutal = FushareConfigHandler.Read(ms);
       Assert.AreEqual("http://localhost:15151/xd.rem", acutal.serviceConfig.serviceHandlers[0].uri);
 }
Example #27
0
 internal ServiceCaller(string Service, Type ObjectType, ServiceHandler ServiceHandler)
 {
     service        = Service;
     objectType     = ObjectType;
     serviceHandler = ServiceHandler;
 }