Example #1
0
        public async Task LoadDiskSpaceResultTest_FileNotExist()
        {
            var savedResult = ComplianceInfo.ClearSystemComplianceItemResult <DiskSpaceInfo>();
            var actual      = await DiskSpace.LoadDiskSpaceResult().ConfigureAwait(false);

            Assert.AreEqual(DiskSpaceInfo.Default, actual);
        }
Example #2
0
 public void AppendDirectorySeparatorCharTest_NullInput_Exception()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var actual = DiskSpace.AppendDirectorySeparatorChar(null);
     }
                                       );
 }
Example #3
0
        public static DiskSpace GetDriveSpace(string ServerName, string DriveLetter)
        {
            DiskSpace DriveDetails = new DiskSpace();

            try
            {
                ConnectionOptions oConn        = new ConnectionOptions();
                string            strNameSpace = @"\\";

                if (ServerName != "")
                {
                    strNameSpace += ServerName;
                }
                else
                {
                    strNameSpace += ".";
                }

                strNameSpace += @"\root\cimv2";
                ManagementScope oMs = new ManagementScope(strNameSpace, oConn);

                //get Fixed disk state
                ObjectQuery oQuery = new ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");
                ManagementObjectSearcher   oSearcher         = new ManagementObjectSearcher(oMs, oQuery);
                ManagementObjectCollection oReturnCollection = oSearcher.Get();

                //loop through found drives and write out info
                double D_Freespace  = 0;
                double D_Totalspace = 0;
                foreach (ManagementObject oReturn in oReturnCollection)
                {
                    // Free Space in bytes
                    string strFreespace = oReturn["FreeSpace"].ToString();
                    D_Freespace = Math.Round(D_Freespace + System.Convert.ToDouble(strFreespace) / 1024 / 1024 / 1024, 2);

                    string strTotalspace = oReturn["Size"].ToString();
                    D_Totalspace = Math.Round(D_Totalspace + System.Convert.ToDouble(strTotalspace) / 1024 / 1024 / 1024, 2);

                    string driveReturned = oReturn["Name"].ToString().Substring(0, 1);

                    if (driveReturned == DriveLetter)
                    {
                        DriveDetails.TotalSpace                 = D_Totalspace;
                        DriveDetails.RemainingSpace             = D_Freespace;
                        DriveDetails.PercentageOfSpaceRemaining =
                            Math.Round(Convert.ToDouble(DriveDetails.RemainingSpace) / Convert.ToDouble(DriveDetails.TotalSpace) * 100, 0);
                    }
                }
            }
            catch
            {
                //MessageBox.Show("Failed to obtain Server Information. The node you are trying to scan can be a Filer or a node which you don't have administrative priviledges. Please use the UNC convention to scan the shared folder in the server", "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(DriveDetails);
        }
Example #4
0
        public async Task SaveLoadDiskSpaceResultTest_Success()
        {
            var expected = new DiskSpaceInfo {
                SccmCacheSize = 12, TotalFreeDiskSpace = 123
            };
            var savedResult = await ComplianceInfo.SaveSystemComplianceItemResult <DiskSpaceInfo>(expected).ConfigureAwait(false);

            var actual = await DiskSpace.LoadDiskSpaceResult().ConfigureAwait(false);

            Assert.AreEqual(expected, actual);
        }
Example #5
0
 public void GetFreeDiskSpaceTest()
 {
     DiskSpace.GetFreeDiskSpaceInGigaBytes("c:\\").Match <decimal>(size =>
     {
         Assert.IsTrue(size > 0M);
         Assert.IsTrue(size < 10000M);
         return(size);
     }, exception =>
     {
         Assert.Fail(exception.ToString());
         return(0);
     });
 }
Example #6
0
 public void TryGetFilesTest()
 {
     var actual = DiskSpace.TryGetFiles(new DirectoryInfo(@"c:\temp\UserTemp\msdtadmin"), "*.*");
     var files  = actual.Try().Match <FileInfo[]>(infos =>
     {
         Assert.IsTrue(false, "Not expected.");
         return(infos);
     }, exception =>
     {
         Assert.True(true);
         return(new FileInfo[] { });
     });
 }
Example #7
0
        public void Setup()
        {
            _shimsContext    = ShimsContext.Create();
            _fakeHttpContext = new FakeHttpContext.FakeHttpContext();

            MockDiskMonitorProxy();
            MockReportContentGenerator();

            _page = new DiskSpace(_diskMonitorProxyMock.Object, _reportContentGeneratorMock.Object);

            InitializePage(_page);
            RetrievePageControls();
        }
Example #8
0
 /// <summary>
 /// Update data for the metrics. Called immediately before the metrics are scraped.
 /// </summary>
 public void UpdateMetrics()
 {
     foreach (var drive in DriveInfo.GetDrives().Where(x => _driveTypes.Contains(x.DriveType)))
     {
         try
         {
             DiskSpace.WithLabels(drive.Name, drive.DriveFormat).Set(drive.AvailableFreeSpace);
             Size.WithLabels(drive.Name, drive.DriveFormat).Set(drive.TotalSize);
         }
         catch (Exception ex)
         {
             _logger.LogWarning("Could not get information for disk {0}: {1}", drive.Name, ex.Message);
         }
     }
 }
Example #9
0
        public async Task GetFolderSizeTest()
        {
            var actual = await DiskSpace.GetFolderSize(@"c:\temp");

            var actualSize = actual.Match <UDecimal>(size =>
            {
                Assert.IsTrue(true);
                return(size);
            }, exception =>
            {
                Assert.False(true, "Not expected to fail");
                return(0M);
            });

            Assert.IsTrue(actualSize > 0);
        }
Example #10
0
        void checkDiskSpace()
        {
            if (DateTime.Now.Minute == 0)
            {
                if (DiskSpace.GetAvailable(Configuration.Instance.Main.SystemDrive) <= 10)
                {
                    var _subject = string.Format("From> {0}@{1} -WARNING- System Disk Space almost used", Configuration.Instance.Main.HostName, Configuration.Instance.Main.HostIP);
                    TimokLogger.Instance.LogRbr(LogSeverity.Critical, "Houskeeper.checkDiskSpace", _subject);
                    Email.SetForSending(Path.Combine(Configuration.Instance.Folders.EmailFolder, Guid.NewGuid().ToString("N")),
                                        Configuration.Instance.Email.ClientFrom,
                                        Configuration.Instance.Email.ClientTo,
                                        Configuration.Instance.Email.SupportTo,
                                        null,
                                        Configuration.Instance.Email.ClientEmailServer,
                                        Configuration.Instance.Email.ClientEmailPassword,
                                        _subject,
                                        string.Empty);
                }

                if (Configuration.Instance.Main.SystemDrive != Configuration.Instance.Main.ArchiveDrive)
                {
                    if (DiskSpace.GetAvailable(Configuration.Instance.Main.ArchiveDrive) <= 10)
                    {
                        var _subject = string.Format("From> {0}@{1} -WARNING- Archive Disk Space almost used", Configuration.Instance.Main.HostName, Configuration.Instance.Main.HostIP);
                        TimokLogger.Instance.LogRbr(LogSeverity.Critical, "Houskeeper.checkDiskSpace", _subject);
                        Email.SetForSending(Path.Combine(Configuration.Instance.Folders.EmailFolder, Guid.NewGuid().ToString("N")),
                                            Configuration.Instance.Email.ClientFrom,
                                            Configuration.Instance.Email.ClientTo,
                                            Configuration.Instance.Email.SupportTo,
                                            null,
                                            Configuration.Instance.Email.ClientEmailServer,
                                            Configuration.Instance.Email.ClientEmailPassword,
                                            _subject,
                                            string.Empty);
                    }
                }
            }
        }
Example #11
0
        private void BtnCompute_Click(object sender, EventArgs e)
        {
            IDataValidator DV = new DataValidator();
            IDiskSpace     DS = new DiskSpace();

            if (!DV.validateInputData(txtUsed.Text, txtTotal.Text))
            {
                txtResult.Text = DV.errorDescription;
                return;
            }

            int minimal = DS.minDrives(DV.used, DV.total);

            if (minimal < 0)
            {
                txtResult.Text = "Invalid parameters to calculate minDrives";
                return;
            }

            txtResult.Text  = $"Total drives: {DV.used.Length}{Environment.NewLine}";
            txtResult.Text += $"Total disk space: {DS.TotalAvailiableSpace}{Environment.NewLine}";
            txtResult.Text += $"Total used space: {DS.TotalUsedSpace}{Environment.NewLine}";
            txtResult.Text += $"== MINIMUM DRIVES REQUIRED: {minimal} ==";
        }
        public void Constructor_DiskSpace_5_Objects_Creation_No_Paramters_Test()
        {
            // Arrange
            var firstDiskSpace  = new DiskSpace();
            var secondDiskSpace = new DiskSpace();
            var thirdDiskSpace  = new DiskSpace();
            var fourthDiskSpace = new DiskSpace();
            var fifthDiskSpace  = new DiskSpace();
            var sixthDiskSpace  = new DiskSpace();

            // Act, Assert
            firstDiskSpace.ShouldNotBeNull();
            secondDiskSpace.ShouldNotBeNull();
            thirdDiskSpace.ShouldNotBeNull();
            fourthDiskSpace.ShouldNotBeNull();
            fifthDiskSpace.ShouldNotBeNull();
            sixthDiskSpace.ShouldNotBeNull();
            firstDiskSpace.ShouldNotBeSameAs(secondDiskSpace);
            thirdDiskSpace.ShouldNotBeSameAs(firstDiskSpace);
            fourthDiskSpace.ShouldNotBeSameAs(firstDiskSpace);
            fifthDiskSpace.ShouldNotBeSameAs(firstDiskSpace);
            sixthDiskSpace.ShouldNotBeSameAs(firstDiskSpace);
            sixthDiskSpace.ShouldNotBeSameAs(fourthDiskSpace);
        }
Example #13
0
 public List <DiskSpace> GetDeviceInformation()
 {
     DiskSpace.CountSpaces();
     return(DiskSpace.AllDisk);
 }
Example #14
0
        void InterfaceActivityTracker()
        {
            int k = 0;

            int[] dataSavedSeconds = new int[this._Sensors.Count];
            int[] secondsCounter   = new int[this._Sensors.Count];
            int[] full             = new int[this._Sensors.Count];
            int[] partial          = new int[this._Sensors.Count];
            int[] empty            = new int[this._Sensors.Count];

            if (!Directory.Exists(this._StorageDirectory + "\\log\\"))
            {
                Directory.CreateDirectory(this._StorageDirectory + "\\log\\");
            }
            if (!Directory.Exists(this._StorageDirectory + "\\data\\summary\\"))
            {
                Directory.CreateDirectory(this._StorageDirectory + "\\data\\summary\\");
            }


            for (int i = 0; (i < this._Sensors.Count); i++)
            {
                dataSavedSeconds[i] = 0;
                secondsCounter[i]   = 0;
                full[i]             = 0;
                partial[i]          = 0;

                this._Sensors[i]._ReceivedACs      = 0;
                this._Sensors[i]._TotalReceivedACs = 0;
                this._Sensors[i]._SavedACs         = 0;
                this._Sensors[i]._TotalSavedACs    = 0;
                Core.WRITE_FULL_RECEIVED_COUNT(i, 0);
                Core.WRITE_PARTIAL_RECEIVED_COUNT(i, 0);
                Core.WRITE_EMPTY_RECEIVED_COUNT(i, 0);
                Core.WRITE_RECEIVED_ACs(i, -1);
                Core.WRITE_SAVED_ACs(i, -1);
            }
            while (true)
            {
                if (connecting)
                {
                    SystemIdleTimerReset();


                    if ((this != null) && (this._Sensors.Count > 0))
                    {
                        //Check 2 things, num of connection failures
                        // check if data received is > 0
                        // if num connections >2, ready to pause
                        // if data received is >0, ready to pause within 2 seconds.

                        bool receiveFailed    = true;
                        bool receivedFullData = true;
                        bool notimeoutData    = true;
                        for (int i = 0; (i < this._Sensors.Count); i++)
                        {
                            receivedFullData &= (this._Sensors[i]._ReceivedPackets == ((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount);

                            //halt, if either 1 successful connection was made
                            // or any data was received
                            // or 3 or more reconnections were made
                            if ((((RFCOMMReceiver)this._Receivers[i])._Reconnections < 3))
                            {
                                receiveFailed = false;
                            }

                            //if (((RFCOMMReceiver)this._Receivers[i])._SuccessfulConnections >= 1)
                            secondsCounter[i] = secondsCounter[i] + 1;

                            notimeoutData &= (secondsCounter[i] > 20);
                        }

                        if ((receivedFullData) || (receiveFailed) || (notimeoutData))
                        {
                            // if didnt get full data, sleep for 2 seconds
                            if (!receivedFullData)
                            {
                                Thread.Sleep(3000);
                            }

                            //save whatever we have so far then sleep
                            connecting = false;
                            SYSTEM_POWER_STATUS_EX2 bpower = Battery.GetSystemPowerStatus();
                            DateTime now         = DateTime.Now;
                            double   unixtime    = WocketsTimer.GetUnixTime(now);
                            string   currentTime = now.ToString("yyyy-MM-dd HH:mm:ss");
                            string   log_line    = ++k + "," + currentTime + "," + bpower.BatteryLifePercent + "," + bpower.BatteryVoltage + "," + bpower.BatteryCurrent + "," + bpower.BatteryTemperature;
                            string   hourlyPath  = now.ToString("yyyy-MM-dd") + "\\" + now.Hour;

                            DiskSpace space1            = Memory.GetDiskSpace(this._StorageDirectory);
                            DiskSpace space2            = Memory.GetDiskSpace("/");
                            int       remainingStorage1 = (int)(space1.TotalNumberOfBytes / System.Math.Pow(2, 20));
                            int       remainingStorage2 = (int)(space2.TotalNumberOfBytes / System.Math.Pow(2, 20));

                            string upload_log = currentTime + "," + bpower.BatteryLifePercent + "," + remainingStorage2 + "," + remainingStorage1;


                            for (int i = 0; (i < this._Sensors.Count); i++)
                            {
                                if ((this._Sensors[i]._ReceivedPackets > 4000) || (((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount > 4000))
                                {
                                    upload_log += "," + this._Sensors[i]._BatteryLevel + "," + 0 + "," + 0;
                                }
                                else
                                {
                                    upload_log += "," + this._Sensors[i]._BatteryLevel + "," + ((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount + "," + this._Sensors[i]._ReceivedPackets;
                                }
                                if (this._Sensors[i]._ReceivedPackets == ((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount)
                                {
                                    full[i] = full[i] + 1;
                                }
                                else if (this._Sensors[i]._ReceivedPackets == 0)
                                {
                                    empty[i] = empty[i] + 1;
                                }
                                else
                                {
                                    partial[i] = partial[i] + 1;
                                }

                                Core.WRITE_FULL_RECEIVED_COUNT(i, full[i]);
                                Core.WRITE_PARTIAL_RECEIVED_COUNT(i, partial[i]);
                                Core.WRITE_EMPTY_RECEIVED_COUNT(i, empty[i]);

                                Core.WRITE_RECEIVED_ACs(i, ((WocketsDecoder)this._Decoders[i])._ACIndex);
                                Core.WRITE_RECEIVED_COUNT(i, this._Sensors[i]._ReceivedPackets);

                                log_line           += "," + this._Sensors[i]._ReceivedPackets + "," + ((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount + "," + ((RFCOMMReceiver)this._Receivers[i])._SuccessfulConnections + "," + ((RFCOMMReceiver)this._Receivers[i])._Reconnections + "," + ((RFCOMMReceiver)this._Receivers[i])._ConnectionTime;
                                dataSavedSeconds[i] = 0;
                                countSeconds[i]     = false;
                                secondsCounter[i]   = 0;
                                ((WocketsDecoder)this._Decoders[i])._ExpectedBatchCount = -1;


                                if (!Directory.Exists(this._StorageDirectory + "\\data\\summary\\" + hourlyPath))
                                {
                                    Directory.CreateDirectory(this._StorageDirectory + "\\data\\summary\\" + hourlyPath);
                                }

                                TextWriter tw2         = new StreamWriter(this._StorageDirectory + "\\data\\summary\\" + hourlyPath + "\\SummaryAC-" + this._Sensors[i]._Location + "-" + i + ".csv", true);
                                int        nextACIndex = LastACIndex[i] + 1;
                                if (nextACIndex == 960)
                                {
                                    nextACIndex = 0;
                                }
                                int countsaved = 0;
                                for (int j = nextACIndex; (j != ((WocketsDecoder)this._Decoders[i])._ActivityCountIndex);)
                                {
                                    DateTime ac_dt = new DateTime();
                                    WocketsTimer.GetDateTime((long)((WocketsDecoder)this._Decoders[i])._ActivityCounts[j]._TimeStamp, out ac_dt);
                                    string ac_currentTime = ac_dt.ToString("yyyy-MM-dd HH:mm:ss");
                                    tw2.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "," + j + "," + ((WocketsDecoder)this._Decoders[i])._ActivityCounts[j]._SeqNum + "," + ac_currentTime + "," + ((WocketsDecoder)this._Decoders[i])._ActivityCounts[j]._TimeStamp + "," + ((WocketsDecoder)this._Decoders[i])._ActivityCounts[j]._Count);
                                    SynchronizedLogger.Write(i + "," + ac_currentTime + "," + ((RFCOMMReceiver)this._Receivers[i])._Address + "," + ((WocketsDecoder)this._Decoders[i])._ActivityCounts[j]._Count);
                                    LastSeqNum[i]  = ((WocketsDecoder)this._Decoders[i])._ActivityCounts[j]._SeqNum;
                                    LastACIndex[i] = j;
                                    countsaved++;
                                    j++;
                                    if (j == 960)
                                    {
                                        j = 0;
                                    }
                                }
                                if (countsaved > 10)
                                {
                                    Core.WRITE_SAVED_ACs(i, 10);
                                }
                                else
                                {
                                    Core.WRITE_SAVED_ACs(i, countsaved);
                                }

                                tw2.Close();
                            }

                            this._Polling = false;

                            //shutting down BT here causes a strange delay on wakeup.
                            int btshutdown_counter = 0;
                            while (true)
                            {
                                btshutdown_counter++;
                                try
                                {
                                    if ((Wockets.Utils.network.NetworkStacks._BluetoothStack.Dispose()) || (btshutdown_counter > 5))
                                    {
                                        break;
                                    }
                                }
                                catch
                                {
                                }
                                SystemIdleTimerReset();
                                Thread.Sleep(1000);
                            }

                            SynchronizedLogger.Write(upload_log);
                            //TextWriter tw = new StreamWriter(this._StorageDirectory + "\\data\\log\\" + hourlyPath + "\\stats.csv", true);
                            //tw.Close();
                            Logger.Log(log_line);


                            SystemIdleTimerReset();
                            for (int i = 0; (i < this._Sensors.Count); i++)
                            {
                                try
                                {
                                    this._Sensors[i].Save();
                                }
                                catch (Exception e)
                                {
                                    Logger.Error("Sensor " + i + ": failed to save:" + e.Message);
                                }
                            }

                            Thread.Sleep(1000);
                            if ((bpower.BatteryCurrent < 0) && (DateTime.Now.Subtract(lastActivity).TotalSeconds > 30))
                            {
                                SetSystemPowerState(null, POWER_STATE_SUSPEND, POWER_FORCE);
                            }
                        }
                    }
                }

                Thread.Sleep(1000);
            }
        }
Example #15
0
    /*----TEST minDrives WITH KNOWN EXAMPLES----*/
    public static void exampleTest()
    {
        int[]     used           = null;
        int[]     total          = null;
        int       expectedResult = -1;
        DiskSpace dS             = null;
        int       result         = -1;

        /*---ASK THE NUMBER OF THE EXAMPLE TO BE TESTED----*/
        System.Console.WriteLine("Enter the number of the example:");
        System.Console.Write("> ");
        string example = Console.ReadLine();

        switch (example)
        {
        case "0":
            /*----CASE 0 DATA----*/
            used           = new int[] { 300, 525, 110 };
            total          = new int[] { 350, 600, 115 };
            expectedResult = 2;

            printExampleData(used, total, expectedResult);
            /*----HERE IS THE minDrives CALL---*/
            dS     = new DiskSpace();
            result = dS.minDrives(used, total);

            verify(expectedResult, result);
            break;

        case "1":
            /*----CASE 1 DATA----*/
            used           = new int[] { 1, 200, 200, 199, 200, 200 };
            total          = new int[] { 1000, 200, 200, 200, 200, 200 };
            expectedResult = 1;

            printExampleData(used, total, expectedResult);
            /*----HERE IS THE minDrives CALL---*/
            dS     = new DiskSpace();
            result = dS.minDrives(used, total);

            verify(expectedResult, result);
            break;

        case "2":
            /*----CASE 2 DATA----*/
            used           = new int[] { 750, 800, 850, 900, 950 };
            total          = new int[] { 800, 850, 900, 950, 1000 };
            expectedResult = 5;

            printExampleData(used, total, expectedResult);
            /*----HERE IS THE minDrives CALL---*/
            dS     = new DiskSpace();
            result = dS.minDrives(used, total);

            verify(expectedResult, result);
            break;

        case "3":
            /*----CASE 3 DATA----*/
            used           = new int[] { 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49 };
            total          = new int[] { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, };
            expectedResult = 49;

            printExampleData(used, total, expectedResult);
            /*----HERE IS THE minDrives CALL---*/
            dS     = new DiskSpace();
            result = dS.minDrives(used, total);

            verify(expectedResult, result);
            break;

        case "4":
            /*----CASE 3 DATA----*/
            used           = new int[] { 331, 242, 384, 366, 428, 114, 145, 89, 381, 170, 329, 190, 482, 246, 2, 38, 220, 290, 402, 385 };
            total          = new int[] { 992, 509, 997, 946, 976, 873, 771, 565, 693, 714, 755, 878, 897, 789, 969, 727, 765, 521, 961, 906 };
            expectedResult = 6;

            printExampleData(used, total, expectedResult);
            /*----HERE IS THE minDrives CALL---*/
            dS     = new DiskSpace();
            result = dS.minDrives(used, total);

            verify(expectedResult, result);
            break;

        default:
            System.Console.WriteLine("ERROR: case example {0} does not exist.", example);
            break;
        }
    }
Example #16
0
    /*----TEST minDrives WITH CUSTOM EXAMPLES----*/
    public static void customTest()
    {
        /*----ASK THE TOTAL NUMBER OF HARD DRIVES AND ASSIGN IT TO totalHardDrives VARIABLE----*/
        System.Console.WriteLine("Enter the total number of hard drives. It must be an integer between 1 and 50:");
        int  totalHardDrives;
        bool isInteger            = false;
        bool totalHardDrivesError = false;

        do
        {
            System.Console.Write("> ");
            isInteger = int.TryParse(Console.ReadLine(), out totalHardDrives);
            /*----VERIFY IF THE TOTAL NUMBER OF HARD DRIVES IS OK----*/
            totalHardDrivesError = !isInteger | totalHardDrives < 1 | totalHardDrives > 50;

            if (totalHardDrivesError)
            {
                System.Console.Write("ERROR: the total number of hard drives must be an integer between 1 and 50. Press ENTER and try again...");
                Console.ReadLine();
            }
        } while (totalHardDrivesError);

        int[] totalArr = new int[totalHardDrives];
        /*----ASK THE TOTAL CAPACITY OF EACH DRIVE AND ASSIGN IT TO totalArr ARRAY----*/
        System.Console.WriteLine("Enter the total capacity of each drive. It must be an integer between 1 and 1000:");

        for (int i = 0; i < totalHardDrives; i++)
        {
            int  totali      = 1;
            bool totaliError = false;

            do
            {
                System.Console.Write("> drive {0}: ", i);
                isInteger = int.TryParse(Console.ReadLine(), out totali);
                /*----VERIFY IF THE TOTAL CAPACITY OF DRIVE i IS OK----*/
                totaliError = !isInteger | totali < 1 | totali > 1000;

                if (totaliError)
                {
                    System.Console.Write("ERROR: the total capacity of drive {0} must be an integer between 1 and 1000. Press ENTER and try again...", i);
                    Console.ReadLine();
                }
            } while (totaliError);

            totalArr[i] = totali;
        }

        int[] usedArr = new int[totalHardDrives];
        /*----ASK THE AMOUNT OF DISK SPACE USED ON EACH DRIVE AND ASSIGN IT TO usedArr ARRAY----*/
        System.Console.WriteLine("Enter the amount of disk space used on each drive. It must be an integer between 1 and 1000 and less than or equal to its total capacity:");

        for (int i = 0; i < totalHardDrives; i++)
        {
            int  usedi      = 1;
            bool usediError = false;

            do
            {
                System.Console.Write("> drive {0}: ", i);
                isInteger = int.TryParse(Console.ReadLine(), out usedi);
                /*----VERIFY IF THE AMOUNT OF DISK SAPCE USED ON DRIVE i IS OK----*/
                usediError = !isInteger | usedi > totalArr[i] | usedi < 1 | usedi > 1000;
                if (usediError)
                {
                    System.Console.Write("ERROR: the amount of disk space used on drive {0} must be an integer between 1 and 1000, and less than or equal to {1}. Press ENTER and try again...", i, totalArr[i]);
                    Console.ReadLine();
                }
            } while (usediError);

            usedArr[i] = usedi;
        }

        /*----ASK THE EXPECTED RESULT AND ASSIGN IT TO expectedResult VARIABLE----*/
        System.Console.WriteLine("Enter the expected result. It must be an integer between 1 and {0}:", totalHardDrives);
        int  expectedResult      = -1;
        bool expectedResultError = false;

        do
        {
            System.Console.Write("> ");
            isInteger = int.TryParse(Console.ReadLine(), out expectedResult);
            /*----VERIFY IF THE expectedResult IS OK----*/
            expectedResultError = !isInteger | expectedResult <1 | expectedResult> totalHardDrives;

            if (expectedResultError)
            {
                System.Console.Write("ERROR: the expected result must be an integer between 1 and {0}. Press ENTER and try again...", totalHardDrives);
                Console.ReadLine();
            }
        } while (expectedResultError);

        printExampleData(usedArr, totalArr, expectedResult);
        /*----HERE IS THE minDrives CALL---*/
        DiskSpace ds     = new DiskSpace();
        int       result = ds.minDrives(usedArr, totalArr);

        verify(expectedResult, result);
    }
Example #17
0
 public void ShouldDiskSpaceCountSpacesNumofDrives()
 {
     DiskSpace.CountSpaces();
     Assert.That(DiskSpace.AllDisk.Count(), Is.GreaterThan(0));
 }
Example #18
0
        public static bool DiskSpaceCheck()
        {
            DiskSuccess = false;

            try
            {
                using (var context = new DriveSpaceDBContext())
                {
                    var DiskRecords = context.DiskCheckers.ToList();

                    foreach (var i in DiskRecords)
                    {
                        if (!i.Disable)
                        {
                            DiskSpace availableSpace = GetDriveSpace(i.ServerName, i.DriveLetter);

                            //Update DB
                            var Update = context.DiskCheckers.Find(i.ID);
                            Update.AvailableSpace = availableSpace.RemainingSpace.ToString();
                            Update.DriveSize      = availableSpace.TotalSpace.ToString();
                            Update.LastRan        = Convert.ToDateTime(DateTimeNow);
                            //Update.LowDiskPercentage = Convert.ToInt32(availableSpace.PercentageOfSpaceRemaining);

                            // Mark as Changed
                            context.Entry(Update).State = System.Data.Entity.EntityState.Modified;
                            context.SaveChanges();

                            if (i.AdminEmailAlert == true || i.AlertSubscribers == true)
                            {
                                //If emails are needed, check to see if any alerts need to be sent
                                if (Convert.ToDateTime(i.LastRan).AddMinutes(i.PollTime) <= Convert.ToDateTime(DateTimeNow))
                                {
                                    int LowPercentageAlert = Convert.ToInt32(i.LowDiskPercentage);
                                    int CurrentPercentage  = Convert.ToInt32(availableSpace.PercentageOfSpaceRemaining);

                                    //Is the disk in a low disk state
                                    if (LowPercentageAlert > CurrentPercentage)
                                    {
                                        //Send Email
                                        string AllEmailAddresses = string.Empty;
                                        //Get Addresses
                                        if (i.AdminEmailAlert)
                                        {
                                            AllEmailAddresses = "*****@*****.**";
                                        }

                                        if (i.AlertSubscribers = true && AllEmailAddresses == string.Empty)
                                        {
                                            AllEmailAddresses = AllEmailAddresses + ", " + i.SubcriptionEmailAddresses;
                                        }
                                        else if (i.AlertSubscribers)
                                        {
                                            AllEmailAddresses = i.SubcriptionEmailAddresses;
                                        }
                                        else
                                        {
                                            //log
                                        }


                                        string EmailSubject = EmailTemplate.EmailSubject(i.ServerName, i.DriveLetter);
                                        string HtmlBody     = EmailTemplate.EmailBody(i.ServerName, i.DriveLetter, availableSpace.PercentageOfSpaceRemaining, availableSpace.RemainingSpace, availableSpace.TotalSpace);
                                        bool   EmailSuccess = EmailAlets.SendEmail(HtmlBody, EmailSubject, AllEmailAddresses);
                                        //Log Email Success
                                    }
                                    else
                                    {
                                        //
                                    }
                                }
                            }
                        }
                    }
                }
                DiskSuccess = true;
            }
            catch
            {
            }

            return(DiskSuccess);
        }
 public void UpdateiFolder(iFolderWeb ifolder)
 {
     this.ifolder = ifolder;
        if (ifolder.LastSyncTime == null || ifolder.LastSyncTime == "")
     LastSuccessfulSync.Text = Util.GS("N/A");
        else
     LastSuccessfulSync.Text = ifolder.LastSyncTime;
        FFSyncValue.Text = "0";
        int syncInterval = 0;
        if (ifolder.SyncInterval <= 0)
        {
     try
     {
      syncInterval = ifws.GetDefaultSyncInterval();
     }
     catch
     {}
        }
        else
        {
     syncInterval = ifolder.SyncInterval;
        }
        if (syncInterval > 0)
        {
     syncInterval = syncInterval / 60;
        }
        SyncIntervalValue.Text = syncInterval + " " + Util.GS("minute(s)");
        NameLabel.Markup = string.Format("<span weight=\"bold\">{0}</span>", ifolder.Name);
        OwnerLabel.Markup = string.Format("<span size=\"small\">{0}</span>", ifolder.Owner);
        LocationLabel.Markup = string.Format("<span size=\"small\">{0}</span>", ifolder.UnManagedPath);
        try
        {
     SyncSize ss = ifws.CalculateSyncSize(ifolder.ID);
     FFSyncValue.Text = string.Format("{0}", ss.SyncNodeCount);
        }
        catch(Exception e)
        {
     FFSyncValue.Text = Util.GS("N/A");
        }
        try
        {
     ds = ifws.GetiFolderDiskSpace(ifolder.ID);
        }
        catch(Exception e)
        {
     ds = null;
        }
        if(ifolder.CurrentUserID == ifolder.OwnerID)
        {
     if(LimitCheckButton == null)
     {
      LimitCheckButton =
       new CheckButton(Util.GS("Set _Quota:"));
      LimitCheckButton.Toggled +=
     new EventHandler(OnLimitSizeButton);
      diskTable.Attach(LimitCheckButton, 0,1,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitEntry = new Entry();
      LimitEntry.Changed +=
       new EventHandler(OnLimitChanged);
      LimitEntry.Activated +=
       new EventHandler(OnLimitEdited);
      LimitEntry.FocusOutEvent +=
       new FocusOutEventHandler(OnLimitFocusLost);
      LimitEntry.WidthChars = 6;
      LimitEntry.MaxLength = 10;
      LimitEntry.Layout.Alignment = Pango.Alignment.Left;
      diskTable.Attach(LimitEntry, 1,2,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitCheckButton.ShowAll();
      LimitEntry.ShowAll();
     }
     else
     {
      LimitCheckButton.Visible = true;
      LimitEntry.Visible = true;
     }
     if(LimitLabel != null)
     {
      LimitLabel.Visible = false;
      LimitValue.Visible = false;
     }
        }
        else
        {
     if(LimitLabel == null)
     {
      LimitLabel = new Label(Util.GS("Quota:"));
      LimitLabel.Xalign = 0;
      diskTable.Attach(LimitLabel, 0,1,1,2,
       AttachOptions.Expand | AttachOptions.Fill, 0,0,0);
      LimitValue = new Label("0");
      LimitValue.Xalign = 1;
      diskTable.Attach(LimitValue, 1,2,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitLabel.ShowAll();
      LimitValue.ShowAll();
     }
     else
     {
      LimitLabel.Visible = true;
      LimitValue.Visible = true;
     }
     if(LimitCheckButton != null)
     {
      LimitCheckButton.Visible = false;
      LimitEntry.Visible = false;
     }
        }
        if(ds != null)
        {
     int tmpValue;
     if(ds.Limit == 0)
     {
      LimitUnit.Sensitive = false;
      AvailLabel.Sensitive = false;
      AvailValue.Sensitive = false;
      AvailUnit.Sensitive = false;
      DiskUsageBar.Sensitive = false;
      DiskUsageFrame.Sensitive = false;
      DiskUsageFullLabel.Sensitive = false;
      DiskUsageEmptyLabel.Sensitive = false;
      if(LimitCheckButton != null)
      {
       LimitCheckButton.Active = false;
       LimitEntry.Sensitive = false;
       LimitEntry.Text = "0";
      }
      if(LimitLabel != null)
      {
       LimitLabel.Sensitive = false;
       LimitValue.Sensitive = false;
       LimitValue.Text = "0";
      }
      AvailValue.Text = "0";
     }
     else
     {
      LimitUnit.Sensitive = true;
      AvailLabel.Sensitive = true;
      AvailValue.Sensitive = true;
      AvailUnit.Sensitive = true;
      DiskUsageBar.Sensitive = true;
      DiskUsageFrame.Sensitive = true;
      DiskUsageFullLabel.Sensitive = true;
      DiskUsageEmptyLabel.Sensitive = true;
      if(LimitCheckButton != null)
      {
       LimitCheckButton.Active = true;
       LimitEntry.Sensitive = true;
       tmpValue = (int)(ds.Limit / (1024 * 1024));
       LimitEntry.Text = string.Format("{0}", tmpValue);
      }
      if(LimitLabel != null)
      {
       LimitLabel.Sensitive = true;
       LimitValue.Sensitive = true;
       tmpValue = (int)(ds.Limit / (1024 * 1024));
       LimitValue.Text = string.Format("{0}", tmpValue);
      }
      tmpValue = (int)(ds.AvailableSpace / (1024 * 1024));
      AvailValue.Text = string.Format("{0}",tmpValue);
     }
     SetGraph(ds.UsedSpace, ds.Limit);
     if(ds.UsedSpace == 0)
     {
      UsedValue.Text = "0";
     }
     else
     {
      tmpValue = (int)(ds.UsedSpace / (1024 * 1024)) + 1;
      UsedValue.Text = string.Format("{0}", tmpValue);
     }
        }
 }
 public void UpdateiFolder(iFolderWeb ifolder)
 {
     DomainController domainController = DomainController.GetDomainController();
        this.domain = domainController.GetDomain(ifolder.DomainID);
        this.ifolder = ifolder;
        if (ifolder.LastSyncTime == null || ifolder.LastSyncTime == "")
     LastSuccessfulSync.Text = Util.GS("N/A");
        else
     LastSuccessfulSync.Text = ifolder.LastSyncTime;
        FFSyncValue.Text = Util.GS("0");
        int syncInterval = 0;
        if (ifolder.EffectiveSyncInterval <= 0)
        {
     try
     {
      syncInterval = ifws.GetDefaultSyncInterval();
     }
     catch
     {}
        }
        else
        {
     syncInterval = ifolder.EffectiveSyncInterval;
        }
        if (syncInterval > 0)
        {
     syncInterval = syncInterval / 60;
        }
        SyncIntervalValue.Text = syncInterval + " " + Util.GS("minute(s)");
        string ifolderName = null, ifolderLocation = null;
        ifolderName = ifolder.Name;
        ifolderLocation = ifolder.UnManagedPath;
        if(ifolder.Name.Length > displayName)
        {
        ifolderName = ifolder.Name.Substring(0,displayName) + "..." ;
        }
        if(ifolder.UnManagedPath.Length > displayableLocation)
        {
        ifolderLocation = ifolder.UnManagedPath.Substring(0,displayableLocation) + "..." ;
        }
        NameLabel.Markup = string.Format("<span weight=\"bold\">{0}</span>", GLib.Markup.EscapeText(ifolderName));
        OwnerLabel.Markup = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(ifolder.Owner));
        LocationLabel.Markup = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(ifolderLocation));
        AccountLabel.Markup = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(domain.Name));
        try
        {
     SyncSize ss = ifws.CalculateSyncSize(ifolder.ID);
     FFSyncValue.Text = string.Format("{0}", ss.SyncNodeCount);
        }
        catch(Exception)
        {
     FFSyncValue.Text = Util.GS("N/A");
        }
        try
        {
     ds = ifws.GetiFolderDiskSpace(ifolder.ID);
        }
        catch(Exception)
        {
     ds = null;
        }
     if(LimitLabel == null)
     {
      LimitLabel = new Label(Util.GS("Quota:"));
      LimitLabel.Xalign = 0;
      diskTable.Attach(LimitLabel, 0,1,1,2,
       AttachOptions.Expand | AttachOptions.Fill, 0,0,0);
      LimitValue = new Label(Util.GS("0"));
      LimitValue.Xalign = 1;
      diskTable.Attach(LimitValue, 1,2,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitLabel.ShowAll();
      LimitValue.ShowAll();
     }
     else
     {
      LimitLabel.Visible = true;
      LimitValue.Visible = true;
     }
     if(LimitCheckButton != null)
     {
      LimitCheckButton.Visible = false;
      LimitEntry.Visible = false;
     }
        if(ds != null)
        {
     int tmpValue;
     if(ds.Limit == 0)
     {
      LimitUnit.Sensitive = false;
      AvailLabel.Sensitive = false;
      AvailValue.Sensitive = false;
      AvailUnit.Sensitive = false;
      DiskUsageBar.Sensitive = false;
      DiskUsageFrame.Sensitive = false;
      DiskUsageFullLabel.Sensitive = false;
      DiskUsageEmptyLabel.Sensitive = false;
      if(LimitCheckButton != null)
      {
       LimitCheckButton.Active = false;
       LimitEntry.Sensitive = false;
       LimitEntry.Text = Util.GS("0");
      }
      if(LimitLabel != null)
      {
       LimitLabel.Sensitive = false;
       LimitValue.Sensitive = false;
       LimitValue.Text = Util.GS("0");
      }
      AvailValue.Text = Util.GS("0");
     }
     else
     {
      LimitUnit.Sensitive = true;
      AvailLabel.Sensitive = true;
      AvailValue.Sensitive = true;
      AvailUnit.Sensitive = true;
      DiskUsageBar.Sensitive = true;
      DiskUsageFrame.Sensitive = true;
      DiskUsageFullLabel.Sensitive = true;
      DiskUsageEmptyLabel.Sensitive = true;
      if(LimitCheckButton != null)
      {
       LimitCheckButton.Active = true;
       LimitEntry.Sensitive = true;
       tmpValue = (int)(ds.Limit / (1024 * 1024));
       LimitEntry.Text = string.Format("{0}", tmpValue);
      }
      if(LimitLabel != null)
      {
       LimitLabel.Sensitive = true;
       LimitValue.Sensitive = true;
       tmpValue = (int)(ds.Limit / (1024 * 1024));
       LimitValue.Text = string.Format("{0}", tmpValue);
      }
      tmpValue = (int)(ds.AvailableSpace / (1024 * 1024));
      AvailValue.Text = string.Format("{0}",tmpValue);
     }
     SetGraph(ds.UsedSpace, ds.Limit);
     if(ds.UsedSpace == 0)
     {
      UsedValue.Text = Util.GS("0");
     }
     else
     {
      tmpValue = (int)(ds.UsedSpace / (1024 * 1024)) + 1;
      UsedValue.Text = string.Format("{0}", tmpValue);
     }
        }
        SecureSync.Active = ifolder.ssl;
                 if(ifolder.CurrentUserID != ifolder.OwnerID)
     SecureSync.Sensitive = false;
        if( domain.HostUrl.StartsWith( System.Uri.UriSchemeHttps ) )
        {
     SecureSync.Active = true;
                         SecureSync.Sensitive = false;
        }
 }
Example #21
0
        /// <summary>
        /// Initial;ize Disk Space Page
        /// </summary>
        private void InitDiskSpacePage()
        {
            DiskSpace ds = ifdata.GetUserDiskSpace(domain.MemberUserID);

            if (ds == null)
            {
                QuotaTotalLabel.Text     = Util.GS("N/A");
                QuotaUsedLabel.Text      = Util.GS("N/A");
                QuotaAvailableLabel.Text = Util.GS("N/A");
                QuotaGraph.Fraction      = 0;
            }
            else
            {
                int tmpValue;

                if (ds.Limit == -1)
                {
                    QuotaTotalLabel.Text = Util.GS("N/A");
                }
                else
                {
                    tmpValue             = (int)(ds.Limit / (1024 * 1024));
                    QuotaTotalLabel.Text =
                        string.Format("{0} {1}", tmpValue, Util.GS("MB"));
                }

                if (ds.UsedSpace == 0)
                {
                    QuotaUsedLabel.Text = Util.GS("N/A");
                }
                else
                {
                    tmpValue            = (int)(ds.UsedSpace / (1024 * 1024)) + 1;
                    QuotaUsedLabel.Text =
                        string.Format("{0} {1}", tmpValue, Util.GS("MB"));
                }

                if (ds.AvailableSpace == 0)
                {
                    QuotaAvailableLabel.Text = Util.GS("N/A");
                }
                else
                {
                    tmpValue = (int)(ds.AvailableSpace / (1024 * 1024));
                    QuotaAvailableLabel.Text =
                        string.Format("{0} {1}", tmpValue, Util.GS("MB"));
                }

                if (ds.Limit == 0)
                {
                    QuotaGraph.Fraction = 0;
                }
                else
                {
                    if (ds.Limit < ds.UsedSpace)
                    {
                        QuotaGraph.Fraction = 1;
                    }
                    else
                    {
                        QuotaGraph.Fraction = ((double)ds.UsedSpace) /
                                              ((double)ds.Limit);
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        /// Update iFolder
        /// </summary>
        /// <param name="ifolder">iFolderWeb Object</param>
        public void UpdateiFolder(iFolderWeb ifolder)
        {
            DomainController domainController = DomainController.GetDomainController();

            this.domain = domainController.GetDomain(ifolder.DomainID);

            this.ifolder = ifolder;

            if (ifolder.LastSyncTime == null || ifolder.LastSyncTime == "")
            {
                LastSuccessfulSync.Text = Util.GS("N/A");
            }
            else
            {
                LastSuccessfulSync.Text = ifolder.LastSyncTime;
            }
            FFSyncValue.Text = Util.GS("0");

            int syncInterval = 0;

            if (ifolder.EffectiveSyncInterval <= 0)
            {
                try
                {
                    syncInterval = ifws.GetDefaultSyncInterval();
                }
                catch
                {}
            }
            else
            {
                syncInterval = ifolder.EffectiveSyncInterval;
            }

            // Make sure it's shown in minutes
            if (syncInterval > 0)
            {
                syncInterval = syncInterval / 60;
            }

            SyncIntervalValue.Text = syncInterval + " " + Util.GS("minute(s)");

            string ifolderName = null, ifolderLocation = null;

            ifolderName     = ifolder.Name;
            ifolderLocation = ifolder.UnManagedPath;
            if (ifolder.Name.Length > displayName)
            {
                ifolderName = ifolder.Name.Substring(0, displayName) + "...";
            }
            if (ifolder.UnManagedPath.Length > displayableLocation)
            {
                ifolderLocation = ifolder.UnManagedPath.Substring(0, displayableLocation) + "...";
            }



            NameLabel.Markup     = string.Format("{0}", GLib.Markup.EscapeText(ifolderName));
            OwnerLabel.Markup    = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(ifolder.Owner));
            LocationLabel.Markup = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(ifolderLocation));
            AccountLabel.Markup  = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(domain.Name));

            try
            {
                SyncSize ss = ifws.CalculateSyncSize(ifolder.ID);
                FFSyncValue.Text = string.Format("{0}", ss.SyncNodeCount);
            }
            catch (Exception)
            {
                FFSyncValue.Text = Util.GS("N/A");

//				iFolderExceptionDialog ied = new iFolderExceptionDialog(
//													topLevelWindow, e);
//				ied.Run();
//				ied.Hide();
//				ied.Destroy();
            }


            try
            {
                ds = ifws.GetiFolderDiskSpace(ifolder.ID);
            }
            catch (Exception)
            {
                ds = null;
//				iFolderExceptionDialog ied = new iFolderExceptionDialog(
//													topLevelWindow, e);
//				ied.Run();
//				ied.Hide();
//				ied.Destroy();
            }

            // check for iFolder Owner

/*			if(ifolder.CurrentUserID == ifolder.OwnerID)
 *                      {
 *                              if(LimitCheckButton == null)
 *                              {
 *                                      LimitCheckButton =
 *                                              new CheckButton(Util.GS("Set _Quota:"));
 *                                      LimitCheckButton.Toggled +=
 *                                                              new EventHandler(OnLimitSizeButton);
 *                                      diskTable.Attach(LimitCheckButton, 0,1,1,2,
 *                                              AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
 *
 *                                      LimitEntry = new Entry();
 *                                      LimitEntry.Changed +=
 *                                              new EventHandler(OnLimitChanged);
 *                                      LimitEntry.Activated +=
 *                                              new EventHandler(OnLimitEdited);
 *                                      LimitEntry.FocusOutEvent +=
 *                                              new FocusOutEventHandler(OnLimitFocusLost);
 *                                      LimitEntry.WidthChars = 6;
 *                                      LimitEntry.MaxLength = 10;
 *                                      LimitEntry.Layout.Alignment = Pango.Alignment.Left;
 *                                      diskTable.Attach(LimitEntry, 1,2,1,2,
 *                                              AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
 *                                      LimitCheckButton.ShowAll();
 *                                      LimitEntry.ShowAll();
 *                              }
 *                              else
 *                              {
 *                                      LimitCheckButton.Visible = true;
 *                                      LimitEntry.Visible = true;
 *                              }
 *
 *                              if(LimitLabel != null)
 *                              {
 *                                      LimitLabel.Visible = false;
 *                                      LimitValue.Visible = false;
 *                              }
 *                      }
 *                      else   */
//			{
            //Commenting the code since Owner of an iFolder canot change the quta settings set by the Admin . 261517
            if (LimitLabel == null)
            {
                LimitLabel        = new Label(Util.GS("Quota:"));
                LimitLabel.Xalign = 0;
                diskTable.Attach(LimitLabel, 0, 1, 0, 1,
                                 AttachOptions.Expand | AttachOptions.Fill, 0, 0, 0);

                LimitValue        = new Label(Util.GS("0"));
                LimitValue.Xalign = 1;
                diskTable.Attach(LimitValue, 1, 2, 0, 1,
                                 AttachOptions.Shrink | AttachOptions.Fill, 0, 0, 0);
                LimitLabel.ShowAll();
                LimitValue.ShowAll();
            }
            else
            {
                LimitLabel.Visible = true;
                LimitValue.Visible = true;
            }

            //LimitCheckButton never assinged, always has value NULL, below code will never get excuted

            /*
             * if(LimitCheckButton != null)
             * {
             *      LimitCheckButton.Visible = false;
             *      LimitEntry.Visible = false;
             * }*/
//			}

            if (ds != null)
            {
                int tmpValue;

                // there is no limit set, disable controls
                if (ds.Limit == -1)
                {
                    LimitUnit.Sensitive           = false;
                    AvailLabel.Sensitive          = false;
                    AvailValue.Sensitive          = false;
                    AvailUnit.Sensitive           = false;
                    DiskUsageBar.Sensitive        = false;
                    DiskUsageFrame.Sensitive      = false;
                    DiskUsageFullLabel.Sensitive  = false;
                    DiskUsageEmptyLabel.Sensitive = false;
                    AvailUnit.Text = "";
                    LimitUnit.Text = "";
                    //LimitCheckButton never assinged, always has value NULL, below code will never get excuted

                    /*	if(LimitCheckButton != null)
                     *      {
                     *              LimitCheckButton.Active = false;
                     *              LimitEntry.Sensitive = false;
                     *              LimitEntry.Text = Util.GS("0");
                     *      }*/
                    if (LimitLabel != null)
                    {
                        LimitLabel.Sensitive = false;
                        LimitValue.Sensitive = false;
                        LimitValue.Text      = Util.GS("N/A");
                    }
                    AvailValue.Text = Util.GS("N/A");
                }
                else
                {
                    LimitUnit.Sensitive           = true;
                    AvailLabel.Sensitive          = true;
                    AvailValue.Sensitive          = true;
                    AvailUnit.Sensitive           = true;
                    DiskUsageBar.Sensitive        = true;
                    DiskUsageFrame.Sensitive      = true;
                    DiskUsageFullLabel.Sensitive  = true;
                    DiskUsageEmptyLabel.Sensitive = true;
                    AvailUnit.Text = Util.GS("MB");
                    LimitUnit.Text = Util.GS("MB");

                    //LimitCheckButton never assinged, always has value NULL, below code will never get excuted

                    /*
                     * if(LimitCheckButton != null)
                     * {
                     *      LimitCheckButton.Active = true;
                     *      LimitEntry.Sensitive = true;
                     *      tmpValue = (int)(ds.Limit / (1024 * 1024));
                     *      LimitEntry.Text = string.Format("{0}", tmpValue);
                     * }*/
                    if (LimitLabel != null)
                    {
                        LimitLabel.Sensitive = true;
                        LimitValue.Sensitive = true;
                        tmpValue             = (int)(ds.Limit / (1024 * 1024));
                        LimitValue.Text      = string.Format("{0}", tmpValue);
                    }

                    tmpValue        = (int)(ds.AvailableSpace / (1024 * 1024));
                    AvailValue.Text = string.Format("{0}", tmpValue);
                }

                SetGraph(ds.UsedSpace, ds.Limit);

                // Add one because there is no iFolder that is zero
                if (ds.UsedSpace == 0)
                {
                    UsedValue.Text = Util.GS("0");
                }
                else
                {
                    tmpValue       = (int)(ds.UsedSpace / (1024 * 1024)) + 1;
                    UsedValue.Text = string.Format("{0}", tmpValue);
                }
            }
            SecureSync.Active = ifolder.ssl;
            // allow User to change the secure sync [ ssl ] if user is owner of iFolder
            if (ifolder.CurrentUserID != ifolder.OwnerID)
            {
                SecureSync.Sensitive = false;
            }

            if (domain.HostUrl.StartsWith(System.Uri.UriSchemeHttps))
            {
                SecureSync.Active    = true;
                SecureSync.Sensitive = false;
            }
        }