Exemplo n.º 1
0
        public bool ValidateParameters()
        {
            if (string.IsNullOrEmpty(CacheName))
            {
                OutputProvider.WriteErrorLine("Error: Cache name not specified.");
                return(false);
            }

            if (string.IsNullOrEmpty(AssemblyPath))
            {
                OutputProvider.WriteErrorLine("Error: Assembly path not specified.");
                return(false);
            }
            if (string.IsNullOrEmpty(Class))
            {
                OutputProvider.WriteErrorLine("Error: Class name not specified.");
                return(false);
            }
            if (string.IsNullOrEmpty(Name))
            {
                OutputProvider.WriteErrorLine("Error: Provider name not specified.");
                return(false);
            }


            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            return(true);
        }
Exemplo n.º 2
0
        public bool ValidateParameters()
        {
            _bridgeService.Port       = Port;
            _bridgeService.ServerName = Server;
            if (Port == -1)
            {
                _bridgeService.Port = _bridgeService.UseTcp ? BridgeConfigurationManager.NCacheTcpPort : BridgeConfigurationManager.NCacheHttpPort;
            }
            //validate BridgeID
            if (string.IsNullOrEmpty(BridgeId))
            {
                OutputProvider.WriteErrorLine("Error: BridgeID not specified.");
                return(false);
            }

            if (string.IsNullOrEmpty(Server))
            {
                OutputProvider.WriteErrorLine("Error: Bridge server is not specified.");
                return(false);
            }

            //validate Server
            if (string.IsNullOrEmpty(DeleteBridgeNode))
            {
                OutputProvider.WriteErrorLine("Error: Server to be removed is not specified.");
                return(false);
            }

            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            return(true);
        }
Exemplo n.º 3
0
        public bool ValidateParameters()
        {
            if (string.IsNullOrEmpty(BridgeId))
            {
                OutputProvider.WriteErrorLine("Error: Bridge-id not specified.");
                return(false);
            }
            if (string.IsNullOrEmpty(CacheName))
            {
                OutputProvider.WriteErrorLine("Error: Cache-id not specified.");
                return(false);
            }


            bool multipleServers = false;

            if (CacheServer != null || CacheServer != string.Empty)
            {
                _serverList = CacheServer.Split(',');
                if (_serverList.Length > 1 || (_serverList[0].Contains(":")))
                {
                    multipleServers = true;
                }
            }
            VerifyCacheServer(multipleServers);

            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            return(true);
        }
Exemplo n.º 4
0
        public bool ValidateParameters()
        {
            try
            {
                if (CacheName == String.Empty || CacheName == null)
                {
                    OutputProvider.WriteErrorLine("Error: Cache name not specified.");
                    return(false);
                }

                if (!string.IsNullOrEmpty(Server))
                {
                    string[] servers = Server.Split(new char[] { ',' });

                    for (int i = 0; i < servers.Length; i++)
                    {
                        if (!ToolsUtil.IsValidIP(servers[i]))
                        {
                            OutputProvider.WriteErrorLine("Error: Invalid Server IP. {0}", servers[i]);
                            return(false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                OutputProvider.WriteLine("Exception occured while parsing input parameters. Please verify all given parameters are in correct format.");
                OutputProvider.WriteLine(ex.Message);
                return(false);
            }
            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            return(true);
        }
Exemplo n.º 5
0
 private void FetchAndDisplayContinousuly(List <ICacheServer> cacheClients)
 {
     try
     {
         if (SampleInterval < 0 || SampleInterval > int.MaxValue)
         {
             throw new ArgumentOutOfRangeException("Number must be either non-negative and less than or equal to Int32.MaxValue");
         }
         while (true)
         {
             Thread.Sleep(SampleInterval * 1000);
             SortedDictionary <string, string[]> CountList = FetchCounters(cacheClients);
             DisplayTimeStamp();
             DisplayCounters(CountList);
             OutputProvider.WriteLine(" \n\n");
         }
     }
     catch (ArgumentOutOfRangeException ex)
     {
         OutputProvider.WriteErrorLine(ex);
     }
     catch (Exception ex)
     {
         OutputProvider.WriteErrorLine(ex);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the application level parameters to those specified at the command line.
        /// </summary>
        /// <param name="args">array of command line parameters</param>
        public bool ValidateParameters()
        {
            if (Name != null && Name.Length > 0)
            {
                CachesList = new ArrayList();
                CachesList.AddRange(Name);
            }
            NCache            = new NCacheRPCService("");
            NCache.ServerName = Server;
            if (String.IsNullOrEmpty(NCache.ServerName))
            {
                NCache.ServerName = System.Environment.MachineName;
            }
            NCache.Port = Port;
            if (NCache.Port == -1)
            {
                NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort;
            }
            if (CachesList.Count == 0)
            {
                OutputProvider.WriteErrorLine("Error: cache name not specified.");
            }
            if (CachesList.Count > 1)
            {
                _partId = string.Empty;
            }

            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            return(true);
        }
        public bool ValidateParameters()
        {
            _bridgeService.Port       = Port;
            _bridgeService.ServerName = BridgeServer;



            if (Port == -1)
            {
                _bridgeService.Port = _bridgeService.UseTcp ? BridgeConfigurationManager.NCacheTcpPort : BridgeConfigurationManager.NCacheHttpPort;
            }

            if (string.IsNullOrEmpty(BridgeId))
            {
                OutputProvider.WriteErrorLine("Error: Bridge-id not specified.");
                return(false);
            }
            if (string.IsNullOrEmpty(CacheName))
            {
                OutputProvider.WriteErrorLine("Error: Cache-id not specified.");
                return(false);
            }

            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            return(true);
        }
Exemplo n.º 8
0
        public async void Run(string chosenDirectory)
        {
            this.outputProvider = new OutputProvider(this.ChosenDirectoryStorage);

            await this.outputProvider.Setup();

            AutofacConfig autofacConfig = new AutofacConfig(this.outputProvider);

            this.operations = autofacConfig.GetContainer();

            var checkedOperationsNames = this.OperationsViewModel.GetCheckedOperationsNames();

            foreach (var operation in this.operations)
            {
                var operationName = GetOperationName(operation.ToString());

                if (checkedOperationsNames.Contains(operationName))
                {
                    await operation.Run();
                }
            }

            if (!String.IsNullOrEmpty(this.ZipPassword))
            {
                await this.outputProvider.CreateSecuredZipFile(this.ZipPassword);
            }
            else
            {
                await this.outputProvider.CreateZipFile();
            }

            MessageDialog messageDialog = new MessageDialog("Zip file created.");
            await messageDialog.ShowAsync();
        }
Exemplo n.º 9
0
        public void ClearCache(string cacheId, bool forceClear)
        {
            ICache cache = null;

            try
            {
                CacheConnectionOptions cacheParams = new CacheConnectionOptions();

                cache = CacheManager.GetCache(cacheId.ToLower(), cacheParams);


                if (!ForceClear)
                {
                    long count = cache.Count;
                    OutputProvider.WriteLine("");
                    OutputProvider.WriteLine("\"" + cacheId + "\" cache currently has " + count + " items. ");
                    OutputProvider.WriteLine("Do you really want to clear it (Y or N)? ");
                    string response = string.Empty;
                    if (isPowershell)
                    {
                        ICollection <PSObject> resp = this.InvokeCommand.InvokeScript("Read-Host");

                        foreach (PSObject r in resp)
                        {
                            response = r.ToString();
                        }
                    }
                    else
                    {
                        response = Console.ReadLine();
                    }

                    if (response != "Y" && response != "y")
                    {
                        OutputProvider.WriteLine("");

                        OutputProvider.WriteLine("Cache not cleared.");
                        return;
                    }
                }

                cache.Clear();
                OutputProvider.WriteLine("");
                OutputProvider.WriteLine("Cache cleared.");
            }
            catch (Exception e)
            {
                OutputProvider.WriteLine("Error: " + e.Message);
                OutputProvider.WriteErrorLine(e.ToString());
            }
            finally
            {
                if (cache != null)
                {
                    cache.Dispose();
                }
            }
        }
Exemplo n.º 10
0
 public GenerateOutputCommand(DbProvider dbProvider, DbTraceCodeFormatter dbCodeFormatter,
                              HighlightCodeProvider codeHighlighter, OutputProvider outputProvider, string traceName)
 {
     _dbProvider      = dbProvider;
     _dbCodeFormatter = dbCodeFormatter;
     _codeHighlighter = codeHighlighter;
     _outputProvider  = outputProvider;
     _traceName       = traceName;
 }
Exemplo n.º 11
0
        public void VerifyLicense()
        {
            ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
            string            ipAddress = "this machine";
            ServerLicenseInfo serverLicenseInfo;

            try
            {
                if (string.IsNullOrEmpty(Server))
                {
                    serverLicenseInfo = new ServerLicenseInfo();
                }
                else
                {
                    NCache            = new NCacheRPCService("");
                    NCache.Port       = Port;
                    NCache.ServerName = Server;
                    ipAddress         = Server;
                    ICacheServer nCacheServer = null;
                    nCacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                    if (nCacheServer != null)
                    {
                        serverLicenseInfo = nCacheServer.GetServerLicenseInfo();
                    }
                    else
                    {
                        serverLicenseInfo = new ServerLicenseInfo();
                    }
                }

                OutputProvider.WriteLine("This product is registered to ");
                OutputProvider.WriteLine("User:        "******"Email:       " + serverLicenseInfo._email);
                OutputProvider.WriteLine("Company:     " + serverLicenseInfo._companyName);
                OutputProvider.WriteLine("Edition:     " + "NCache OpenSource ");

                if (LicenseManager.LicenseMode(null) == LicenseManager.LicenseType.UnRegistered)
                {
                    OutputProvider.WriteLine("\nThe machine does not have a valid registration information. Please register this machine with a FREE installation key.You can get free installation key from http://www.alachisoft.com/activate/RequestKey.php?Edition=NC-OSS-50-4x&Version=5.0&Source=Register-NCache");

                    OutputProvider.WriteLine("\nIf you are using this machine as NCache client, then you don't need to register NCache on this machine. Only cache server machines are required to be registered");
                }
                else
                {
                    OutputProvider.WriteLine("");
                    OutputProvider.WriteLine("Licensed to use FREE of cost. Use As-is without support.");
                }
            }
            catch (Exception ex)
            {
                OutputProvider.WriteLine(ex.ToString());
                return;
            }

            OutputProvider.WriteLine("\n");
        }
Exemplo n.º 12
0
        void StartCacheOnServer()
        {
            OutputProvider.WriteLine("Licensed to use FREE of cost. Use As-is without support.\n");
            string cacheIp = string.Empty;

            try
            {
                ICacheServer      cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                CacheServerConfig config      = null;
                if (cacheServer != null)
                {
                    cacheIp = cacheServer.GetClusterIP();
                    foreach (string cache in CachesList)
                    {
                        try
                        {
                            config = cacheServer.GetCacheConfiguration(cache);
                            if (config != null && config.InProc)
                            {
                                throw new Exception("InProc caches cannot be started explicitly.");
                            }

                            OutputProvider.WriteLine("Starting cache '{0}' on server {1}:{2}.", cache, cacheIp, NCache.Port);

                            cacheServer.StartCache(cache, _partId);


                            OutputProvider.WriteLine("'{0}' successfully started on server {1}:{2}.\n", cache, cacheIp,
                                                     NCache.Port);
                        }

                        catch (Exception e)
                        {
                            OutputProvider.WriteErrorLine("Failed to start '{0}' on server {1}.", cache,
                                                          cacheIp);
                            OutputProvider.WriteErrorLine(e.ToString() + "\n");
                        }
                    }
                }
            }
            catch (ManagementException ex)
            {
                OutputProvider.WriteErrorLine("Error : {0}", "NCache service could not be contacted on server");

                OutputProvider.WriteErrorLine(ex.ToString());
            }
            catch (Exception e)
            {
                OutputProvider.WriteErrorLine("Error : {0}", e.Message);
                OutputProvider.WriteErrorLine(e.ToString());
            }
            finally
            {
                NCache.Dispose();
            }
        }
Exemplo n.º 13
0
 public bool ValidateParameters()
 {
     if (string.IsNullOrEmpty(Name))
     {
         OutputProvider.WriteErrorLine("\nError: Cache name not specified.");
         return(false);
     }
     ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME);
     return(true);
 }
Exemplo n.º 14
0
        protected void DisplayTimeStamp()
        {
            string toolName  = "Cache Client Statistics";
            string timeStamp = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");
            int    length    = toolName.Length + timeStamp.Length;
            string line      = new string('-', length + 4);

            OutputProvider.WriteLine(toolName + " at " + timeStamp);
            OutputProvider.WriteLine(line);
        }
Exemplo n.º 15
0
        public void Execute(string[] commandParameters)
        {
            var ID = Convert.ToInt32(commandParameters[1]);

            if (employeeService.EmployeeExists(ID))
            {
                var currentEmployee = employeeService.GetEmployeeByID <EmployeeInfoDTO>(ID);
                OutputProvider.PrintMessage(currentEmployee.ToString(), Color);
            }
        }
Exemplo n.º 16
0
 protected void StartProcess()
 {
     try
     {
     }
     catch (Exception ex)
     {
         OutputProvider.WriteErrorLine(ex.ToString());
     }
 }
Exemplo n.º 17
0
        public void Execute(string[] commandParameters)
        {
            var employeeDto = new EmployeeDTO();

            employeeDto.FirstName = commandParameters[1];
            employeeDto.Surname   = commandParameters[2];
            employeeDto.Salary    = Convert.ToDecimal(commandParameters[3]);
            employeeService.AddEmployee(employeeDto);

            OutputProvider.PrintMessage(Strings.AddedEmployee, Color);
        }
Exemplo n.º 18
0
 protected override void StopProcessing()
 {
     try
     {
         _taskManger.StopTasks(true);
     }
     catch (Exception ex)
     {
         OutputProvider.WriteErrorLine(ex.ToString());
     }
 }
Exemplo n.º 19
0
        public void Execute(string[] commandParameters)
        {
            var ID         = Convert.ToInt32(commandParameters[1]);
            var newAddress = string.Join(" ", commandParameters.Skip(2));

            if (employeeService.EmployeeExists(ID))
            {
                employeeService.SetAddress(ID, newAddress);
                OutputProvider.PrintMessage(Strings.SetAddress, Color);
            }
        }
Exemplo n.º 20
0
        public void ClearCache(string cacheId, bool forceClear, bool webOnly)
        {
            Cache cache = null;

            try
            {
                CacheInitParams cacheParams = new CacheInitParams();


                cache = Web.Caching.NCache.InitializeCache(cacheId.ToLower(), cacheParams);


                if (!ForceClear)
                {
                    long count = cache.Count;
                    OutputProvider.WriteLine("");
                    OutputProvider.WriteLine("\"" + cacheId + "\" cache currently has " + count + " items. ");
                    OutputProvider.WriteLine("Do you really want to clear it (Y or N)? ");
                    ICollection <PSObject> response = this.InvokeCommand.InvokeScript("Read-Host");
                    string resp = string.Empty;
                    foreach (PSObject r in response)
                    {
                        resp = r.ToString();
                    }
                    if (resp != "Y" && resp != "y")
                    {
                        OutputProvider.WriteLine("");
                        OutputProvider.WriteLine("Cache not cleared.");
                        return;
                    }
                }

                cache.Clear();

                OutputProvider.WriteLine("");



                OutputProvider.WriteLine("Cache cleared.");
            }
            catch (Exception e)
            {
                OutputProvider.WriteLine("Error: " + e.Message);
                OutputProvider.WriteErrorLine(e.ToString());
            }
            finally
            {
                if (cache != null)
                {
                    cache.Dispose();
                }
            }
        }
Exemplo n.º 21
0
        public void DumpCacheKeys()
        {
            try
            {
                if (!ValidateParameters())
                {
                    return;
                }
                CacheConnectionOptions cacheParams = new CacheConnectionOptions();

                ICache cache = CacheManager.GetCache(Name.ToLower(), cacheParams);
                //cache.ExceptionsEnabled = true;

                OutputProvider.WriteLine("Cache count:    " + cache.Count);
                IDictionaryEnumerator keys = (IDictionaryEnumerator)cache.GetEnumerator();

                if (keys != null)
                {
                    long index       = 0;
                    bool checkFilter = (KeyFilter != "");
                    KeyFilter = KeyFilter.Trim();
                    while (keys.MoveNext())
                    {
                        if ((KeyCount > 0) && (index >= KeyCount))
                        {
                            break;
                        }

                        if (checkFilter == true)
                        {
                            string tmpKey = (string)keys.Key;

                            if (tmpKey.Contains(KeyFilter) == true)
                            {
                                OutputProvider.WriteLine(tmpKey);
                            }
                        }
                        else
                        {
                            OutputProvider.WriteLine(keys.Key);
                        }
                        index++;
                    } //end while
                }     //end if
                cache.Dispose();
            }         //end try block
            catch (Exception e)
            {
                OutputProvider.WriteErrorLine("Error: " + e.Message);
                OutputProvider.WriteErrorLine(e.ToString());
            }
            OutputProvider.WriteLine(Environment.NewLine);
        }
Exemplo n.º 22
0
        public void Execute(string[] commandParameters)
        {
            var EmployeeID = Convert.ToInt32(commandParameters[1]);
            var ManagerID  = Convert.ToInt32(commandParameters[2]);

            if (employeeService.EmployeeExists(EmployeeID) && employeeService.EmployeeExists(ManagerID))
            {
                employeeService.SetManager(EmployeeID, ManagerID);
            }

            OutputProvider.PrintMessage(Strings.SetManager, Color);
        }
Exemplo n.º 23
0
        public void CreateProvider_Ultimate_TBD()
        {
            //arrange
            var config = new OrchestratorConfig {
                OutputDataKind = KindOfTextData.Ultimate
            };

            //act
            var sut = OutputProvider.CreateProvider(config, null, null);

            //assert
            sut.Should().BeNull(); // future use
        }
Exemplo n.º 24
0
        public void CreateProvider_Delimited_OfDelimitedType()
        {
            //arrange
            var config = new OrchestratorConfig {
                OutputDataKind = KindOfTextData.Delimited
            };

            //act
            var sut = OutputProvider.CreateProvider(config, null, null);

            //assert
            sut.Should().BeOfType <DelimitedOutputProvider>();
        }
Exemplo n.º 25
0
        public void CreateProvider_Flat_OfFlatType()
        {
            //arrange
            var config = new OrchestratorConfig {
                OutputDataKind = KindOfTextData.Flat
            };

            //act
            var sut = OutputProvider.CreateProvider(config, null, null);

            //assert
            sut.Should().BeOfType <FlatOutputProvider>();
        }
Exemplo n.º 26
0
 public bool ValidateParameters()
 {
     if (string.IsNullOrEmpty(CacheName))
     {
         OutputProvider.WriteErrorLine("\nError: Cache name not specified.");
         return(false);
     }
     if (string.IsNullOrEmpty(CounterNames))
     {
         DoNotShowDefaultCounters = false;
     }
     return(true);
 }
Exemplo n.º 27
0
        public void CreateProvider_UnboudJSON_OfXrecordType()
        {
            //arrange
            var config = new OrchestratorConfig {
                OutputDataKind = KindOfTextData.UnboundJSON
            };

            //act
            var sut = OutputProvider.CreateProvider(config, null, null);

            //assert
            sut.Should().BeOfType <XrecordOutputProvider>();
        }
Exemplo n.º 28
0
        public void CreateProvider_Arbitrary_OfXrecordType()
        {
            //arrange
            var config = new OrchestratorConfig {
                OutputDataKind = KindOfTextData.Arbitrary
            };

            //act
            var sut = OutputProvider.CreateProvider(config, null, null);

            //assert
            sut.Should().BeOfType <ArbitraryOutputProvider>();
        }
Exemplo n.º 29
0
        public void CreateProvider_Keyword_OfKwType()
        {
            //arrange
            var config = new OrchestratorConfig {
                OutputDataKind = KindOfTextData.Keyword
            };

            //act
            var sut = OutputProvider.CreateProvider(config, null, null);

            //assert
            sut.Should().BeOfType <KwOutputProvider>();
        }
Exemplo n.º 30
0
        public void Execute(string[] commandParameters)
        {
            var ManagerID = Convert.ToInt32(commandParameters[1]);

            ManagerDTO manager = new ManagerDTO();

            if (employeeService.EmployeeExists(ManagerID))
            {
                manager = employeeService.GetManagerByID(ManagerID);
            }

            OutputProvider.PrintMessage(manager.ToString(), Color);
        }
Exemplo n.º 31
0
 public virtual void print(OutputProvider @out)
 {
     print(new Output(@out.print, @out.println));
 }