As redes Sociais e as suas “aplicações”

“Uma rede social é uma estrutura social composta por pessoas ou organizações, conectadas por um ou vários tipos de relações, que partilham valores e objetivos comuns. Uma das características fundamentais na definição das redes é a sua abertura e porosidade, possibilitando relacionamentos horizontais e não hierárquicos entre os participantes. “Redes não são, portanto, apenas uma outra forma de estrutura, mas quase uma não estrutura, no sentido de que parte de sua força está na habilidade de se fazer e desfazer rapidamente.” 

Esta é segundo a definição da Wikipédia,  uma rede social. Julgo que também ser do conhecimento de todos – há alguém que nos dias de hoje não conheça uma?

E este é o tema que me leva  a escrever por aqui hoje, coisa, cada vez mais rara pelos vistos.

Podemos considerar também um blog agregado num agregador ou planeta uma “espécie” de rede social.

E se nos blogs é normal colocarmos determinados conteúdos que nos identificam, e permitem de alguma forma dar a conhecer os seus autores ou pensamentos, nas redes sociais é prática comum, e faz parte do senso comum, que as informações nelas publicadas devem carecer de algum cuidado.

Note-se contudo que existem pessoas que não têm quaisquer problemas em colocar determinadas informações online, usando muitas até essas plataforms para a (auto)promoção, e outros que se deveriam resguardar mais um pouco por vezes abusam. Tais situações podem levar a roubos de entidade, stalking, assédios, ou simplesmente ter bastantes dissabores, levando a que aquilo que deveria ser um divertimento seja por vezes uma grande dor de cabeça.

Mas não é esse o tema que me leva a escrever acerca disto… disso já toda a gente sabe, ou se não sabe é porque não quer sabes, porque já foi amplamente abordado.

A quantidade de redes sociais existentes hoje em dia leva a uma fragmentação das pessoas pelas mesmas, consoante os seus gostos, e dado o número cada vez maior delas, á repetição de conteúdos pelas mesmas, bem como o conceito de amizade multiplamente repetido por n redes sociais.

Isto é assim cada vez mais, e quando nasce uma nova que é o hype do momento lá vamos nós novamente. Podemos ver isso na recente rede social da Google, depois dos seus fracassos do Google Wave, e do Buzz, que nunca teve muita aceitação na minha modesta opinião, surge agora o Google Plus, a rede social da Google – penso que o Orkut é o parente pobre e nunca vingou em grande, sendo apenas bastante popular no Brasil e India com 58% e 32% de utilizadores desses países respectivamente.

E como este aumentar de redes aumenta a fragmentação e a segmentação, criando até por vezes autênticos baús de informação privilegiada, e moribunda – Hi5 por exemplo?

E depois no meio de tudo isto vêm as inocentes aplicações que pululam pelas várias e me levam a escrever este post…

Quem têm uma conta no Facebook sabe bem o que falo… é constantemente recebermos assédios de “amigos” que nos enviam convites. Ora claro que não são eles que nos convidam… pelo menos a grande maioria.

No meio do processo de experimentação da nova aplicação é habitualmente pedido ao utilizador que autorize o acesso a  determinados dados, e determinadas características do seu perfil, e como é habitual, as pessoas simplesmente carregam no OK.

No meio de tudo isto, as simpáticas aplicações, em regra além de recolherem os nossos dados sabe-se lá com que fins, spamam habitualmente todos os nossos conhecidos com simpáticos convites.

E no meio de tudo isto é fácil se perder o controlo… e quantas vezes não damos por nós e temos aplicações a publicarem coisas nos nossos perfis, auto publicitando-se ou fazendo pior… enfim!

No meio disto criam-se gigantescas bases de dados para efeitos de publicidade/marketing/spam/whatever com um valor extaordinário, e o simples utilizador, que vai para o Facebook jogar, ou ver os amigos que cada vez vê menos na realidade, e mais virtualmente é apanhado na teia, muitas vezes de forma insconciente, e muitas vezes nunca disso têm consciência.

E com a abertura da API do Google+ muitas mais aplicações destas surgirão.  E com as próximas redes sociais que surgirão o efeito será amplificado. E muita informação ficará por aí, num estado de abandonware.

É preciso cuidado com os dados que colocamos, e especialmente com os previlégios que concedemos de acesso aos mesmos. Note-se que hoje cada vez mais é comum usar-se o Facebook / Google como mecanismo de autenticação, e com faltas de atenção e cuidado, rápidamente podemos dar acesso a terceiros de toda a nossa “vida” online.

Imagem: Reseau Sociaux, fonte Wikipédia 

 

Creating a Windows Service in C#

So… for mental note, to never forget, here are the steps:

References:

Interesting – http://www.c-sharpcorner.com/uploadfile/mahesh/window_service11262005045007am/window_service.aspx

A good Cookbook, the supreme source for all info… bow to MSDN – http://msdn.microsoft.com/en-us/library/zt39148a%28v=vs.80%29.aspx

Visit to Online Content is recommended, as instructions/references may change in time.

Walkthrough: Creating a Windows Service Application in the Component Designer

Visual Studio 2010

Updated: July 2011

NoteNote
The Windows Service template and associated functionality is not available in the Standard Edition of Visual Studio.

The procedures in this topic demonstrate creating a simple Windows Service application that writes messages to an event log. The basic steps that you perform to create and use your service include the following:

  • Create a project by using the Windows Service application template. This template creates a class for you that inherits from ServiceBase and writes much of the basic service code, such as the code to start the service.
  • Write the code for the OnStart and OnStop procedures, and override any other methods that you want to redefine.
  • Add the necessary installers for your service application. By default, a class that contains two or more installers is added to your application when you click the Add Installer link: one to install the process, and one for each associated service that your project contains.
  • Build your project.
  • Create a setup project to install your service, and then install it.
  • Access the Windows Services Control Manager and start your service.

To begin, you create the project and set values that are required for the service to function correctly.

 

NoteNote
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To create and configure your service

  1. On the File menu, click New Project.

    The New Project dialog box opens.

  2. Select Windows Service in the list of Visual Basic or Visual C# project templates, and name the project MyNewService. Click OK.
    Note Note
    The project template automatically adds a component class named Service1 that inherits from System.ServiceProcess.ServiceBase.
  3. Click the designer to select Service1. Then, in the Properties window, set the ServiceName and the (Name) property for Service1 to MyNewService.

In the next section, you add a custom event log to the Windows service. Event logs are not associated in any way with Windows services. Here the EventLog component is used as an example of the type of component you could add to a Windows service.

To add custom event log functionality to your service

  1. In Solution Explorer, right-click Service1.vb or Service1.cs and select View Designer.
  2. From the Components tab of the Toolbox, drag an EventLog component to the designer.
  3. In Solution Explorer, right-click Service1.vb or Service1.cs and select View Code.
  4. Add or edit the constructor to define a custom event log.

    	public MyNewService()
    	{
    		InitializeComponent();
    		if (!System.Diagnostics.EventLog.SourceExists("MySource")) 
    		{         
    				System.Diagnostics.EventLog.CreateEventSource(
    					"MySource","MyNewLog");
    		}
    		eventLog1.Source = "MySource";
    		eventLog1.Log = "MyNewLog";
    	}

To define what occurs when the service starts

  • In the Code Editor, locate the OnStart method that was automatically overridden when you created the project, and write code to determine what occurs when the service starts running:

    	protected override void OnStart(string[] args)
    	{
    		eventLog1.WriteEntry("In OnStart");
    	}
    Note Note
    A service application is designed to be long running. Therefore, it usually polls or monitors something in the system. The monitoring is set up in the OnStart method. However, OnStart does not actually do the monitoring. The OnStart method must return to the operating system after the service’s operation has begun. It must not loop forever or block. To set up a simple polling mechanism, you can use the System.Timers.Timer component. In the OnStart method, you would set parameters on the component, and then you would set the Enabled property to true. The timer would then raise events in your code periodically, at which time your service could do its monitoring.

To define what occurs when the service is stopped

  • In the Code Editor, select the OnStop procedure from the Method Name drop-down list, which was automatically overridden when you created the project. Write code to determine what occurs when the service is stopped:

    	protected override void OnStop()
    	{
    		eventLog1.WriteEntry("In onStop.");
    	}

You can also override the OnPause, OnContinue, and OnShutdown methods to define additional processing for your component.

To define other actions for the service

  • For the method that you want to handle, override the appropriate method and define what you want to occur.

    The following code shows what it looks like if you override the OnContinue method:

    	protected override void OnContinue()
    	{
    		eventLog1.WriteEntry("In OnContinue.");
    	}

Some custom actions have to occur when a Windows service is installed, which can be done by the Installer class. Visual Studio can create these installers specifically for a Windows service and add them to your project.

To create the installers for your service

  1. In Solution Explorer, right-click Service1.vb or Service1.cs and select View Designer.
  2. Click the background of the designer to select the service itself, instead of any of its contents.
  3. With the designer in focus, right-click, and then click Add Installer.

    By default, a component class that contains two installers is added to your project. The component is named ProjectInstaller, and the installers it contains are the installer for your service and the installer for the service’s associated process.

  4. In Design view for ProjectInstaller, click ServiceInstaller1 for a Visual Basic project, or serviceInstaller1 for a Visual C# project.
  5. In the Properties window, make sure the ServiceName property is set to MyNewService.
  6. Set the StartType property to Automatic.
  7. In the designer, click ServiceProcessInstaller1 for a Visual Basic project, or serviceProcessInstaller1 for a Visual C# project. Set the Account property to LocalSystem. This will cause the service to be installed and to run on a local service account.
    Security note Security Note
    The LocalSystem account has broad permissions, including the ability to write to the event log. Use this account with caution, because it might increase your risk of attacks from malicious software. For other tasks, consider using the LocalService account, which acts as a non-privileged user on the local computer and presents anonymous credentials to any remote server.

To build your service project

  1. In Solution Explorer, right-click your project and then click Properties. The project’s Property Designer appears.
  2. On the Application page, from the Startup object list, click MyNewService.Program.
  3. Press CTRL+SHIFT+B to build the project.

Now that the project is built, it can be deployed. A setup project will install the compiled project files and run the installers that are required to run the Windows service. To create a complete setup project you will have to add the project output, MyNewService.exe, to the setup project and then add a custom action to have MyNewService.exe installed. For more information about setup projects, see Setup and Deployment Projects. For more information about custom actions, see Walkthrough: Creating a Custom Action.

To create a setup project for your service

  1. In Solution Explorer, right-click your solution node (not the project node), point to Add, and then click New Project.
  2. Under Installed Templates, expand Other Project Types and then expand Setup and Deployment.
  3. Select Visual Studio Installer.
  4. In the Templates pane, select Setup Project. Name the project MyServiceSetup. Click OK.

    A setup project is added to the solution.

Next you will add the output from the Windows service project, MyNewService.exe, to the setup.

To add MyNewService.exe to the setup project

  1. In Solution Explorer, right-click MyServiceSetup, point to Add, and then click Project Output.

    The Add Project Output Group dialog box appears.

  2. MyNewService is selected in the Project box.
  3. From the list, select Primary Output, and click OK.

    A project item for the primary output of MyNewService is added to the setup project.

Now add a custom action to install the MyNewService.exe file.

To add a custom action to the setup project

  1. In Solution Explorer, right-click the setup project, point to View, and then click Custom Actions.

    The Custom Actions editor appears.

  2. In the Custom Actions editor, right-click the Custom Actions node and click Add Custom Action.

    The Select Item in Project dialog box appears.

  3. Double-click the Application Folder in the list to open it, select Primary Output from MyNewService (Active), and click OK.

    The primary output is added to all four nodes of the custom actions — Install, Commit, Rollback, and Uninstall.

  4. In Solution Explorer, right-click the MyServiceSetup project and click Build.

To install the Windows Service

  1. To install MyNewService.exe, right-click the setup project in Solution Explorer and select Install.
  2. Follow the steps in the Setup Wizard. Build and save your solution.

To start and stop your service

  1. To open the Services Control Manager in Windows 7, Windows Vista, and Windows Server, right-click Computer on the Start menu, and then click Manage. In the Computer Management console, expand the Services and Applications node in the left pane. Click Services.

    You should now see MyNewService listed in the Services section of the window.

  2. Select your service in the list, right-click it, and then click Start.
  3. Right-click the service, and then click Stop.

To verify the event log output of your service

  1. Open Server Explorer and access the Event Logs node.
  2. Locate the listing for MyNewLog and expand it. You should see entries for the actions your service has performed.

To uninstall your service

  • On the Start menu, open Control Panel and click Add or Remove Programs, and then locate your service and click Uninstall.