Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            try
            {
                //System.Diagnostics.Debugger.Launch();

                InstanceSettings InstanceInfo = new InstanceSettings();
                InstanceInfo = InstanceInfo.GetInstanceSettings();

                System.Timers.Timer ServiceTimer = new Timer((InstanceInfo.PollingInterval * 60000) /*1800000 300000*/);
                ServiceTimer.AutoReset = true;
                ServiceTimer.Elapsed  += CheckMail;
                ServiceTimer.Enabled   = true; //ServiceTimer.Start();//ServiceTimer.Enabled = true;
                ServiceTimer.Start();


                GC.KeepAlive(ServiceTimer);

                // write an entry to the log
                eventLog1.WriteEntry("Operation - V1 Request Asset Creator Service Started");
            }
            catch (Exception e)
            {
                eventLog1.WriteEntry("ERROR - OnStart - " + e.InnerException.Message);
            }
        }
        /*
         * public bool ConnectToV1()
         * {
         *  bool Connected = false;
         *
         *  CreateDefect();
         *
         *  V1Connector connector = V1Connector
         *      .WithInstanceUrl("https://www8.v1host.com/Terrys_Instance052215")
         *      .WithUserAgentHeader("V1-Asset-Creator", "1.0")
         *      .WithAccessToken("1.eqpQfm0root/o7s+lOXLWYK3wCQ=")
         *      .Build();
         *
         *  IServices services = new Services(connector);
         *
         *
         *  Oid projectId = services.GetOid("Scope:1111");
         *  IAssetType defectType = services.Meta.GetAssetType("Defect");
         *  Asset NewDefect = services.New(defectType, projectId);
         *  IAttributeDefinition nameAttribute = defectType.GetAttributeDefinition("Name");
         *  NewDefect.SetAttributeValue(nameAttribute, "My New Defect");
         *  services.Save(NewDefect);
         *
         *
         *
         *  return (Connected);
         *
         * }*/

        public V1Connector ConnectToV1()
        {
            InstanceSettings InstanceInfo = new InstanceSettings();

            InstanceInfo = InstanceInfo.GetInstanceSettings();

            V1Connector connector = null;

            if (String.IsNullOrEmpty(InstanceInfo.ProxyURL) == true)
            {
                connector = V1Connector
                            .WithInstanceUrl(InstanceInfo.InstanceURL)
                            .WithUserAgentHeader("V1-Asset-Creator", "1.0")
                            .WithAccessToken(InstanceInfo.AccessToken)
                            .Build();
            }
            else
            {
                Uri           proxyURL      = new Uri(InstanceInfo.ProxyURL);
                ProxyProvider proxySettings = new ProxyProvider(proxyURL,
                                                                InstanceInfo.ProxyUserName,
                                                                InstanceInfo.ProxyPassword);

                connector = V1Connector
                            .WithInstanceUrl(InstanceInfo.InstanceURL)
                            .WithUserAgentHeader("V1-Asset-Creator", "1.0")
                            .WithAccessToken(InstanceInfo.AccessToken)
                            .WithProxy(proxySettings)
                            .Build();
            }

            /*
             * V1Connector connector = V1Connector
             *  .WithInstanceUrl("https://www8.v1host.com/Terrys_Instance052215")
             *  .WithUserAgentHeader("V1-Asset-Creator", "1.0")
             *  .WithAccessToken("1.eqpQfm0root/o7s+lOXLWYK3wCQ=")
             *  .Build();
             */
            return(connector);
        }