static void CreateShareFile()
        {
            try
            {
                #region Creating the Shared Files in Azure

                _storageAccount = CloudStorageAccount.Parse(
                    CloudConfigurationManager.GetSetting("StorageConnection"));

                _share = _storageAccount.CreateCloudFileClient().GetShareReference("documentos");

                if (_share.Exists())
                {
                    //Console.Clear();
                    // Check current usage stats for the share.
                    // Note that the ShareStats object is part of the protocol layer for the File service.
                    ShareStats stats = _share.GetStats();
                    //Console.WriteLine("Current share usage: {0} GB", stats.Usage.ToString());

                    // Specify the maximum size of the share, in GB.
                    // This line sets the quota to be 10 GB greater than the current usage of the share.
                    _share.Properties.Quota = 10 + stats.Usage;
                    _share.SetProperties();

                    // Now check the quota for the share. Call FetchAttributes() to populate the share's properties.
                    _share.FetchAttributes();
                    //Console.WriteLine("Current share quota: {0} GB", _share.Properties.Quota);

                    // Create a new shared access policy and define its constraints.
                    SharedAccessFilePolicy sharedPolicy = new SharedAccessFilePolicy()
                    {
                        SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24),
                        Permissions            = SharedAccessFilePermissions.Read | SharedAccessFilePermissions.Write
                    };

                    // Get existing permissions for the share.
                    FileSharePermissions permissions = _share.GetPermissions();

                    if (!permissions.SharedAccessPolicies.ContainsKey("sampleSharePolicy"))
                    {
                        // Add the shared access policy to the share's policies. Note that each policy must have a unique name.
                        permissions.SharedAccessPolicies.Add("sampleSharePolicy", sharedPolicy);
                        _share.SetPermissions(permissions);
                    }

                    //Console.ReadKey();
                }
                else
                {
                    _share.CreateIfNotExists();
                }

                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadKey();
            }
        }
        public ActionResult <SimpleStatus> Get()
        {
            var lastJob = WorkerManager.lastJob.ToString("yyyy-MM-ddTHH:mm:ssK");

            var conn = ConnectionManager.GetCurrConn();

            if (conn == null)
            {
                return(StatusCode(404, "No Straturm Connection active."));
            }


            var lastSHare   = conn.lastShare;
            var totalShares = conn.totalShares;
            var accepted    = conn.sharesAccepted;
            var rejected    = conn.sharesRejected;
            var tooLate     = conn.sharesTooLate;
            ///TODO do WorkerManagera dat SolutionsFound (kolik dohromady ze vsech karet) a
            /// SolutionsSubmitted (to bude az co projde pres diff)

            SimpleStatus status = new SimpleStatus();

            status.LastShare = lastSHare.ToString("yyyy-MM-ddTHH:mm:ssK");
            status.LastJob   = lastJob;

            List <SimpleWorkerInfo> workers = new List <SimpleWorkerInfo>();

            foreach (var worker in WorkerManager.GetWorkersInfo())
            {
                SimpleWorkerInfo wi = new SimpleWorkerInfo();

                wi.GPUName         = worker.GPUName;
                wi.Platform        = worker.GPUOption.PlatformID.ToString();
                wi.Status          = worker.GPUStatus;
                wi.GraphsPerSecond = worker.GraphsPerSecond;
                wi.ID           = worker.ID;
                wi.TotalSols    = worker.TotalSols;
                wi.LastSolution = worker.lastSolution.ToString("yyyy-MM-ddTHH:mm:ssK");
                wi.Fidelity     = (float)worker.Fidelity;
                workers.Add(wi);
            }
            status.Workers = workers;

            if (ConnectionManager.IsInFee())
            {
                status.ConnectionAddress = $"FEE (GrinPro collects 1% as fee for the Grin Development Fund and 1% for further miner development.)";
                status.ConnectionStatus  = conn.IsConnected == true ? "Connected" : "Disconnectd";
            }
            else
            {
                status.ConnectionAddress = $"{conn.ip}:{conn.port}";
                status.ConnectionStatus  = conn.IsConnected == true ? "Connected" : "Disconnectd";
            }

            ShareStats ss = new ShareStats();

            ss.Accepted         = accepted;
            ss.FailedToValidate = rejected;
            ss.Found            = (uint)workers.Sum(w => w.TotalSols);
            ss.Submitted        = totalShares;
            ss.TooLate          = tooLate;

            status.Shares = ss;

            return(status);
        }
        public ActionResult <Status> GetAll()
        {
            var lastJob = WorkerManager.lastJob.ToString();

            var conn = ConnectionManager.GetCurrConn();

            if (conn == null)
            {
                return(StatusCode(404, "No Straturm Connection active."));
            }


            var lastSHare   = conn.lastShare;
            var totalShares = conn.totalShares;
            var accepted    = conn.sharesAccepted;
            var rejected    = conn.sharesRejected;
            var tooLate     = conn.sharesTooLate;
            ///TODO do WorkerManagera dat SolutionsFound (kolik dohromady ze vsech karet) a
            /// SolutionsSubmitted (to bude az co projde pres diff)

            Status status = new Status();

            status.LastShare = lastSHare.ToString();
            status.LastJob   = lastJob;



            List <WorkerInfo> workers = new List <WorkerInfo>();

            foreach (var worker in WorkerManager.GetWorkersInfo())
            {
                workers.Add(worker);
            }
            status.Workers = workers;

            var  sc1   = conn;
            bool isFee = ConnectionManager.IsInFee();
            var  c1    = new StratumConnectionInfo()
            {
                Address           = isFee ? "FEE" : sc1.ip,
                Port              = isFee ? "FEE" : sc1.port.ToString(),
                Login             = isFee ? "FEE" : sc1.login,
                Password          = isFee ? "FEE" : sc1.password,
                Status            = sc1.IsConnected == true ? "Connected" : "Disconnectd",
                LastCommunication = sc1.lastComm.ToString(),
                LastJob           = sc1.CurrentJob?.timestamp.ToString(),
            };

            status.ActiveConnection = c1;


            ShareStats ss = new ShareStats();

            ss.Accepted         = accepted;
            ss.FailedToValidate = rejected;
            ss.Found            = (uint)workers.Sum(w => w.TotalSols);
            ss.Submitted        = totalShares;
            ss.TooLate          = tooLate;

            status.Shares = ss;

            return(status);
        }