Esempio n. 1
0
    public void SaveAsExcelsFiles()
    {
        string[] workerList;
        string   csvLog = "";

        string[] columns = new string[24];
        m_poolSaveAndLoad.ImportAllKeys(PoolManageByThisAPI.Ethermine.ToString(), m_workersObserved.GetFocusAddress(),
                                        out AbstractWorkerBasicInfo[]  workersDebug);

        for (int i = 0; i < 24; i++)
        {
            columns[i] = "H-" + i;
        }
        AbstractWorkerBasicInfo[] temp;
        workerList = workersDebug.Select(k => k.m_address.m_workerName).Distinct().ToArray();

        DateTime from, to;
        ulong    vFrom, vTo;

        from  = to = DateTime.UtcNow;
        vFrom = vTo = UnixTime.GetFromDate(from);

        CsvArray <long> sharedByRig = new CsvArray <long>();

        sharedByRig.SetSize(columns, workerList);

        for (uint i = 0; i < 24; i++)
        {
            from  = from.AddHours(-1);
            vFrom = UnixTime.GetFromDate(from);
            temp  = workersDebug.Where(k => k.m_timestampSeconds >= vFrom && k.m_timestampSeconds < vTo).ToArray();
            ulong[] value = new ulong[workerList.Length];
            for (uint j = 0; j < workerList.Length; j++)
            {
                long sum = temp.Where(k => k.m_address.m_workerName == workerList[j]).Sum(k => k.m_valideShare);
                sharedByRig.SetValue(i, j, sum);
            }


            to  = to.AddHours(-1);
            vTo = UnixTime.GetFromDate(to);
        }



        StringBuilder sb = new StringBuilder();

        sb.Append(" Hour/Workers ;" + string.Join(";", columns) + "\n");
        for (uint j = 0; j < workerList.Length; j++)
        {
            sb.Append(workerList[j] + ";");
            for (uint i = 0; i < 24; i++)
            {
                if (i < 23)
                {
                    sb.Append(sharedByRig.Get(i, j) + ";");
                }
                else
                {
                    sb.Append(sharedByRig.Get(i, j) + "\n");
                }
            }
        }
        m_poolSaveAndLoad.SaveAsLogFile(PoolManageByThisAPI.Ethermine, m_workersObserved.GetFocusAddress(), "last24H.csv", sb.ToString());
    }