コード例 #1
0
        public virtual PerformanceStatistic UpdatePerformanceStatistic(PerformanceStatistic entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            PerformanceStatistic other = GetPerformanceStatistic(entity.PerformanceStatisticId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update PerformanceStatistic set  [CPU]=@CPU
							, [Memory]=@Memory
							, [CreationDate]=@CreationDate
							, [MachineName]=@MachineName
							, [IPAddress]=@IPAddress
							, [DriveSpaceAvailable]=@DriveSpaceAvailable
							, [DriveTotalSpace]=@DriveTotalSpace 
							 where PerformanceStatisticID=@PerformanceStatisticID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@CPU", entity.Cpu ?? (object)DBNull.Value)
                , new SqlParameter("@Memory", entity.Memory ?? (object)DBNull.Value)
                , new SqlParameter("@CreationDate", entity.CreationDate ?? (object)DBNull.Value)
                , new SqlParameter("@MachineName", entity.MachineName ?? (object)DBNull.Value)
                , new SqlParameter("@IPAddress", entity.IpAddress ?? (object)DBNull.Value)
                , new SqlParameter("@DriveSpaceAvailable", entity.DriveSpaceAvailable ?? (object)DBNull.Value)
                , new SqlParameter("@DriveTotalSpace", entity.DriveTotalSpace ?? (object)DBNull.Value)
                , new SqlParameter("@PerformanceStatisticID", entity.PerformanceStatisticId)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetPerformanceStatistic(entity.PerformanceStatisticId));
        }
コード例 #2
0
        public PerformanceStatistic GetPCPerformance()
        {
            PerformanceStatistic stats = new PerformanceStatistic();
            PerformanceCounter   cpuCounter;
            PerformanceCounter   ramCounter;

            cpuCounter = new PerformanceCounter();

            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName  = "% Processor Time";
            cpuCounter.InstanceName = "_Total";

            ramCounter = new PerformanceCounter("Memory", "Available MBytes");
            Int64 phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB();
            Int64 tot  = PerformanceInfo.GetTotalMemoryInMiB();

            stats.Memory = Math.Round((double)(100 - (((decimal)phav / (decimal)tot) * 100)), 2);
            stats.Cpu    = cpuCounter.NextValue();
            Thread.Sleep(1000);
            stats.Cpu          = cpuCounter.NextValue();
            stats.CreationDate = DateTime.UtcNow;

            stats.MachineName = System.Environment.MachineName.ToString();

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            DriveStatisticRepository driveRepo = new DriveStatisticRepository();

            if (allDrives.Count() > 0)
            {
                stats.DriveSpaceAvailable = 0;
                stats.DriveTotalSpace     = 0;
                for (int i = 0; i < allDrives.Count(); i++)
                {
                    try
                    {
                        DriveStatistic dS = new DriveStatistic();
                        dS.CreationDate        = stats.CreationDate;
                        dS.DriveName           = allDrives[i].Name;
                        dS.MachineName         = stats.MachineName + ":" + allDrives[i].Name;
                        dS.DriveSpaceAvailable = Math.Round(((allDrives[i].TotalFreeSpace / 1024.0) / 1024.0) / 1024.0, 2);
                        dS.DriveTotalSpace     = Math.Round(((allDrives[i].TotalSize / 1024.0) / 1024.0) / 1024.0, 2);
                        string hostNames = Dns.GetHostName();
                        string myIPs     = Dns.GetHostByName(hostNames).AddressList[0].ToString();
                        dS.IpAddress = myIPs + ":" + allDrives[i].Name;
                        driveRepo.InsertDriveStatistic(dS);
                        stats.DriveSpaceAvailable += dS.DriveSpaceAvailable;
                        stats.DriveTotalSpace     += dS.DriveTotalSpace;
                    }
                    catch (Exception exp)
                    { }
                }
            }

            string hostName = Dns.GetHostName();
            string myIP     = Dns.GetHostByName(hostName).AddressList[0].ToString();

            stats.IpAddress = myIP;

            return(stats);
        }
コード例 #3
0
        public DataTransfer <GetOutput> Get(string _id)
        {
            DataTransfer <GetOutput> tranfer = new DataTransfer <GetOutput>();

            System.Int32 performancestatisticid = 0;
            if (!string.IsNullOrEmpty(_id) && System.Int32.TryParse(_id, out performancestatisticid))
            {
                PerformanceStatistic performancestatistic = _iPerformanceStatisticRepository.GetPerformanceStatistic(performancestatisticid);
                if (performancestatistic != null)
                {
                    tranfer.IsSuccess = true;
                    GetOutput output = new GetOutput();
                    output.CopyFrom(performancestatistic);
                    tranfer.Data = output;
                }
                else
                {
                    tranfer.IsSuccess = false;
                    tranfer.Errors    = new string[1];
                    tranfer.Errors[0] = "Error: No record found.";
                }
            }
            else
            {
                tranfer.IsSuccess = false;
                tranfer.Errors    = new string[1];
                tranfer.Errors[0] = "Error: Invalid request.";
            }
            return(tranfer);
        }
コード例 #4
0
        public override PerformanceStatistic InsertPerformanceStatistic(PerformanceStatistic entity)
        {
            PerformanceStatistic other = new PerformanceStatistic();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into PerformanceStatistic ( [CPU],[Memory],[CreationDate],[MachineName],[IPAddress],[DriveSpaceAvailable],[DriveTotalSpace] ) Values
( @CPU, @Memory, getutcdate(), @MachineName, @IPAddress, @DriveSpaceAvailable, @DriveTotalSpace ); Select scope_identity()";
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@CPU", entity.Cpu ?? (object)DBNull.Value)
                    , new SqlParameter("@Memory", entity.Memory ?? (object)DBNull.Value)
                    , new SqlParameter("@MachineName", entity.MachineName ?? (object)DBNull.Value)
                    , new SqlParameter("@IPAddress", entity.IpAddress ?? (object)DBNull.Value)
                    , new SqlParameter("@DriveSpaceAvailable", entity.DriveSpaceAvailable ?? (object)DBNull.Value)
                    , new SqlParameter("@DriveTotalSpace", entity.DriveTotalSpace ?? (object)DBNull.Value)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetPerformanceStatistic(Convert.ToInt32(identity)));
            }
            return(entity);
        }
コード例 #5
0
        public void ActionScenario(string actionName, Action <WebBaseElement> action, LogLevels logSettings)
        {
            _element.LogAction(actionName, logSettings);
            var timer = new Timer();

            new Timer(JDISettings.Timeouts.CurrentTimeoutSec).Wait(() => {
                action(_element);
                return(true);
            });
            JDISettings.Logger.Info(actionName + " done");
            PerformanceStatistic.AddStatistic(timer.TimePassed.TotalMilliseconds);
        }
コード例 #6
0
 public virtual void CopyFrom(PerformanceStatistic other)
 {
     if (other != null)
     {
         this.PerformanceStatisticId = other.PerformanceStatisticId;
         this.Cpu                 = other.Cpu;
         this.Memory              = other.Memory;
         this.CreationDate        = other.CreationDate;
         this.MachineName         = other.MachineName;
         this.IpAddress           = other.IpAddress;
         this.DriveSpaceAvailable = other.DriveSpaceAvailable;
         this.DriveTotalSpace     = other.DriveTotalSpace;
     }
 }
コード例 #7
0
        public virtual PerformanceStatistic PerformanceStatisticFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            PerformanceStatistic entity = new PerformanceStatistic();

            if (dr.Table.Columns.Contains("PerformanceStatisticID"))
            {
                entity.PerformanceStatisticId = (System.Int32)dr["PerformanceStatisticID"];
            }
            if (dr.Table.Columns.Contains("CPU"))
            {
                entity.Cpu = dr["CPU"] == DBNull.Value?(System.Double?)null : (System.Double?)dr["CPU"];
            }
            if (dr.Table.Columns.Contains("Memory"))
            {
                entity.Memory = dr["Memory"] == DBNull.Value?(System.Double?)null : (System.Double?)dr["Memory"];
            }
            if (dr.Table.Columns.Contains("CreationDate"))
            {
                entity.CreationDate = dr["CreationDate"] == DBNull.Value?(System.DateTime?)null : (System.DateTime?)dr["CreationDate"];
            }
            if (dr.Table.Columns.Contains("MachineName"))
            {
                entity.MachineName = dr["MachineName"].ToString();
            }
            if (dr.Table.Columns.Contains("IPAddress"))
            {
                entity.IpAddress = dr["IPAddress"].ToString();
            }
            if (dr.Table.Columns.Contains("DriveSpaceAvailable"))
            {
                entity.DriveSpaceAvailable = dr["DriveSpaceAvailable"] == DBNull.Value?(System.Double?)null : (System.Double?)dr["DriveSpaceAvailable"];
            }
            if (dr.Table.Columns.Contains("DriveTotalSpace"))
            {
                entity.DriveTotalSpace = dr["DriveTotalSpace"] == DBNull.Value?(System.Double?)null : (System.Double?)dr["DriveTotalSpace"];
            }
            return(entity);
        }
コード例 #8
0
        public DataTransfer <PutOutput> Update(PutInput Input)
        {
            DataTransfer <PutOutput> transer = new DataTransfer <PutOutput>();
            IList <string>           errors  = Validator.Validate(Input);

            if (errors.Count == 0)
            {
                PerformanceStatistic performancestatisticinput  = new PerformanceStatistic();
                PerformanceStatistic performancestatisticoutput = new PerformanceStatistic();
                PutOutput            output = new PutOutput();
                performancestatisticinput.CopyFrom(Input);
                PerformanceStatistic performancestatistic = _iPerformanceStatisticRepository.GetPerformanceStatistic(performancestatisticinput.PerformanceStatisticId);
                if (performancestatistic != null)
                {
                    performancestatisticoutput = _iPerformanceStatisticRepository.UpdatePerformanceStatistic(performancestatisticinput);
                    if (performancestatisticoutput != null)
                    {
                        output.CopyFrom(performancestatisticoutput);
                        transer.IsSuccess = true;
                        transer.Data      = output;
                    }
                    else
                    {
                        transer.IsSuccess = false;
                        transer.Errors    = new string[1];
                        transer.Errors[0] = "Error: Could not update.";
                    }
                }
                else
                {
                    transer.IsSuccess = false;
                    transer.Errors    = new string[1];
                    transer.Errors[0] = "Error: Record not found.";
                }
            }
            else
            {
                transer.IsSuccess = false;
                transer.Errors    = errors.ToArray <string>();
            }
            return(transer);
        }
コード例 #9
0
        public string Execute(string argument)
        {
            SystemEventLogService          logService     = new SystemEventLogService();
            PerformanceStatisticRepository pStatisticRepo = new PerformanceStatisticRepository();

            try
            {
                PerformanceStatistic stats = new PerformanceStatistic();
                stats = GetPCPerformance();

                PerformanceStatistic input = new PerformanceStatistic();
                input.CopyFrom(stats);

                if (input != null)
                {
                    pStatisticRepo.InsertPerformanceStatistic(input);
                }

                List <NetworkStatistic> Networkstats = new List <NetworkStatistic>();
                Networkstats = GetSystemNetworkStatistic();

                if (Networkstats.Count > 0 && Networkstats != null)
                {
                    foreach (NetworkStatistic nstatistic in Networkstats)
                    {
                        if (nstatistic.IpAddress != null)
                        {
                            //nstatistic.IpAddress = Convert.ToString(0);
                            InsertNetworkStatistic(nstatistic);
                        }
                    }
                }

                return("Success");
            }
            catch (Exception exp)
            {
                logService.InsertSystemEventLog(string.Format("Error in PerformanceStatisticThread: {0}", exp.Message), exp.StackTrace, EventCodes.Error);
                return("Error");
            }
        }
コード例 #10
0
 public override PerformanceStatistic InsertPerformanceStatistic(PerformanceStatistic entity)
 {
     PerformanceStatistic other = new PerformanceStatistic();
     other = entity;
     if (entity.IsTransient())
     {
         string sql = @"Insert into PerformanceStatistic ( [CPU],[Memory],[CreationDate],[MachineName],[IPAddress],[DriveSpaceAvailable],[DriveTotalSpace] ) Values
     ( @CPU, @Memory, getutcdate(), @MachineName, @IPAddress, @DriveSpaceAvailable, @DriveTotalSpace ); Select scope_identity()";
         SqlParameter[] parameterArray = new SqlParameter[]{
              new SqlParameter("@CPU",entity.Cpu ?? (object)DBNull.Value)
             , new SqlParameter("@Memory",entity.Memory ?? (object)DBNull.Value)
             , new SqlParameter("@MachineName",entity.MachineName ?? (object)DBNull.Value)
             , new SqlParameter("@IPAddress",entity.IpAddress ?? (object)DBNull.Value)
             , new SqlParameter("@DriveSpaceAvailable",entity.DriveSpaceAvailable ?? (object)DBNull.Value)
             , new SqlParameter("@DriveTotalSpace",entity.DriveTotalSpace ?? (object)DBNull.Value)};
         var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
         if (identity == DBNull.Value) throw new DataException("Identity column was null as a result of the insert operation.");
         return GetPerformanceStatistic(Convert.ToInt32(identity));
     }
     return entity;
 }
コード例 #11
0
        public DataTransfer <PostOutput> Insert(PostInput Input)
        {
            DataTransfer <PostOutput> transer = new DataTransfer <PostOutput>();
            IList <string>            errors  = Validator.Validate(Input);

            if (errors.Count == 0)
            {
                PerformanceStatistic performancestatistic = new PerformanceStatistic();
                PostOutput           output = new PostOutput();
                performancestatistic.CopyFrom(Input);
                performancestatistic = _iPerformanceStatisticRepository.InsertPerformanceStatistic(performancestatistic);
                output.CopyFrom(performancestatistic);
                transer.IsSuccess = true;
                transer.Data      = output;
            }
            else
            {
                transer.IsSuccess = false;
                transer.Errors    = errors.ToArray <string>();
            }
            return(transer);
        }
コード例 #12
0
        public TResult ResultScenario <TResult>(string actionName, Func <WebBaseElement, TResult> action, Func <TResult, string> logResult, LogLevels level)
        {
            _element.LogAction(actionName);
            var timer  = new Timer();
            var result =
                ActionWithException(() => new Timer(JDISettings.Timeouts.CurrentTimeoutSec)
                                    .GetResultByCondition(() => action.Invoke(_element), res => true),
                                    ex => $"Do action {actionName} failed. Can't got result. Reason: {ex}");

            if (result == null)
            {
                throw JDISettings.Exception($"Do action {actionName} failed. Can't got result");
            }
            var stringResult = logResult == null
                    ? result.ToString()
                    : logResult.Invoke(result);

            var timePassed = timer.TimePassed.TotalMilliseconds;

            PerformanceStatistic.AddStatistic(timer.TimePassed.TotalMilliseconds);
            JDISettings.ToLog($"Get result '{stringResult}' in {(timePassed / 1000).ToString("F")} seconds", level);
            return(result);
        }
コード例 #13
0
 public PerformanceStatistic InsertPerformanceStatistic(PerformanceStatistic entity)
 {
     return _iPerformanceStatisticRepository.InsertPerformanceStatistic(entity);
 }
コード例 #14
0
 public virtual PerformanceStatistic DeletePerformanceStatistic(PerformanceStatistic entity)
 {
     this.DeletePerformanceStatistic(entity.PerformanceStatisticId);
     return entity;
 }
コード例 #15
0
 public virtual PerformanceStatistic UpdatePerformanceStatistic(PerformanceStatistic entity)
 {
     if (entity.IsTransient()) return entity;
     PerformanceStatistic other = GetPerformanceStatistic(entity.PerformanceStatisticId);
     if (entity.Equals(other)) return entity;
     string sql=@"Update PerformanceStatistic set  [CPU]=@CPU
                     , [Memory]=@Memory
                     , [CreationDate]=@CreationDate
                     , [MachineName]=@MachineName
                     , [IPAddress]=@IPAddress
                     , [DriveSpaceAvailable]=@DriveSpaceAvailable
                     , [DriveTotalSpace]=@DriveTotalSpace
                      where PerformanceStatisticID=@PerformanceStatisticID";
     SqlParameter[] parameterArray=new SqlParameter[]{
              new SqlParameter("@CPU",entity.Cpu ?? (object)DBNull.Value)
             , new SqlParameter("@Memory",entity.Memory ?? (object)DBNull.Value)
             , new SqlParameter("@CreationDate",entity.CreationDate ?? (object)DBNull.Value)
             , new SqlParameter("@MachineName",entity.MachineName ?? (object)DBNull.Value)
             , new SqlParameter("@IPAddress",entity.IpAddress ?? (object)DBNull.Value)
             , new SqlParameter("@DriveSpaceAvailable",entity.DriveSpaceAvailable ?? (object)DBNull.Value)
             , new SqlParameter("@DriveTotalSpace",entity.DriveTotalSpace ?? (object)DBNull.Value)
             , new SqlParameter("@PerformanceStatisticID",entity.PerformanceStatisticId)};
     SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray);
     return GetPerformanceStatistic(entity.PerformanceStatisticId);
 }
コード例 #16
0
 public PerformanceStatistic UpdatePerformanceStatistic(PerformanceStatistic entity)
 {
     return(_iPerformanceStatisticRepository.UpdatePerformanceStatistic(entity));
 }
コード例 #17
0
 public PerformanceStatistic InsertPerformanceStatistic(PerformanceStatistic entity)
 {
     return(_iPerformanceStatisticRepository.InsertPerformanceStatistic(entity));
 }
コード例 #18
0
 public virtual PerformanceStatistic DeletePerformanceStatistic(PerformanceStatistic entity)
 {
     this.DeletePerformanceStatistic(entity.PerformanceStatisticId);
     return(entity);
 }
コード例 #19
0
 public DataTransfer<PostOutput> Insert(PostInput Input)
 {
     DataTransfer<PostOutput> transer = new DataTransfer<PostOutput>();
     IList<string> errors = Validator.Validate(Input);
     if(errors.Count==0)
     {
         PerformanceStatistic performancestatistic = new PerformanceStatistic();
         PostOutput output = new PostOutput();
         performancestatistic.CopyFrom(Input);
         performancestatistic = _iPerformanceStatisticRepository.InsertPerformanceStatistic(performancestatistic);
         output.CopyFrom(performancestatistic);
         transer.IsSuccess = true;
         transer.Data = output;
     }
     else
     {
         transer.IsSuccess = false;
         transer.Errors = errors.ToArray<string>();
     }
     return transer;
 }
コード例 #20
0
        public string Execute(string argument)
        {
            SystemEventLogService logService = new SystemEventLogService();
            PerformanceStatisticRepository pStatisticRepo = new PerformanceStatisticRepository();
            try
            {
                PerformanceStatistic stats = new PerformanceStatistic();
                stats = GetPCPerformance();

                PerformanceStatistic input = new PerformanceStatistic();
                input.CopyFrom(stats);

                if (input != null)
                {
                    pStatisticRepo.InsertPerformanceStatistic(input);
                }

                List<NetworkStatistic> Networkstats = new List<NetworkStatistic>();
                Networkstats = GetSystemNetworkStatistic();

                if (Networkstats.Count > 0 && Networkstats != null)
                {
                    foreach (NetworkStatistic nstatistic in Networkstats)
                    {
                        if (nstatistic.IpAddress != null)
                        {
                            //nstatistic.IpAddress = Convert.ToString(0);
                            InsertNetworkStatistic(nstatistic);
                        }
                    }
                }

                return "Success";
            }
            catch (Exception exp)
            {
                logService.InsertSystemEventLog(string.Format("Error in PerformanceStatisticThread: {0}", exp.Message), exp.StackTrace, EventCodes.Error);
                return "Error";
            }
        }
コード例 #21
0
 public PerformanceStatistic UpdatePerformanceStatistic(PerformanceStatistic entity)
 {
     return _iPerformanceStatisticRepository.UpdatePerformanceStatistic(entity);
 }
コード例 #22
0
 public virtual PerformanceStatistic PerformanceStatisticFromDataRow(DataRow dr)
 {
     if(dr==null) return null;
     PerformanceStatistic entity=new PerformanceStatistic();
     if (dr.Table.Columns.Contains("PerformanceStatisticID"))
     {
     entity.PerformanceStatisticId = (System.Int32)dr["PerformanceStatisticID"];
     }
     if (dr.Table.Columns.Contains("CPU"))
     {
     entity.Cpu = dr["CPU"]==DBNull.Value?(System.Double?)null:(System.Double?)dr["CPU"];
     }
     if (dr.Table.Columns.Contains("Memory"))
     {
     entity.Memory = dr["Memory"]==DBNull.Value?(System.Double?)null:(System.Double?)dr["Memory"];
     }
     if (dr.Table.Columns.Contains("CreationDate"))
     {
     entity.CreationDate = dr["CreationDate"]==DBNull.Value?(System.DateTime?)null:(System.DateTime?)dr["CreationDate"];
     }
     if (dr.Table.Columns.Contains("MachineName"))
     {
     entity.MachineName = dr["MachineName"].ToString();
     }
     if (dr.Table.Columns.Contains("IPAddress"))
     {
     entity.IpAddress = dr["IPAddress"].ToString();
     }
     if (dr.Table.Columns.Contains("DriveSpaceAvailable"))
     {
     entity.DriveSpaceAvailable = dr["DriveSpaceAvailable"]==DBNull.Value?(System.Double?)null:(System.Double?)dr["DriveSpaceAvailable"];
     }
     if (dr.Table.Columns.Contains("DriveTotalSpace"))
     {
     entity.DriveTotalSpace = dr["DriveTotalSpace"]==DBNull.Value?(System.Double?)null:(System.Double?)dr["DriveTotalSpace"];
     }
     return entity;
 }
コード例 #23
0
        public PerformanceStatistic GetPCPerformance()
        {
            PerformanceStatistic stats = new PerformanceStatistic();
            PerformanceCounter cpuCounter;
            PerformanceCounter ramCounter;
            cpuCounter = new PerformanceCounter();

            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName = "% Processor Time";
            cpuCounter.InstanceName = "_Total";

            ramCounter = new PerformanceCounter("Memory", "Available MBytes");
            Int64 phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB();
            Int64 tot = PerformanceInfo.GetTotalMemoryInMiB();
            stats.Memory = Math.Round((double)(100 - (((decimal)phav / (decimal)tot) * 100)), 2);
            stats.Cpu = cpuCounter.NextValue();
            Thread.Sleep(1000);
            stats.Cpu = cpuCounter.NextValue();
            stats.CreationDate = DateTime.UtcNow;

            stats.MachineName = System.Environment.MachineName.ToString();

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            DriveStatisticRepository driveRepo = new DriveStatisticRepository();
            if (allDrives.Count() > 0)
            {
                stats.DriveSpaceAvailable = 0;
                stats.DriveTotalSpace = 0;
                for (int i = 0; i < allDrives.Count(); i++)
                {
                    try
                    {
                        DriveStatistic dS = new DriveStatistic();
                        dS.CreationDate = stats.CreationDate;
                        dS.DriveName = allDrives[i].Name;
                        dS.MachineName = stats.MachineName + ":" + allDrives[i].Name;
                        dS.DriveSpaceAvailable = Math.Round(((allDrives[i].TotalFreeSpace / 1024.0) / 1024.0) / 1024.0, 2);
                        dS.DriveTotalSpace = Math.Round(((allDrives[i].TotalSize / 1024.0) / 1024.0) / 1024.0, 2);
                        string hostNames = Dns.GetHostName();
                        string myIPs = Dns.GetHostByName(hostNames).AddressList[0].ToString();
                        dS.IpAddress = myIPs + ":" + allDrives[i].Name;
                        driveRepo.InsertDriveStatistic(dS);
                        stats.DriveSpaceAvailable += dS.DriveSpaceAvailable;
                        stats.DriveTotalSpace += dS.DriveTotalSpace;
                    }
                    catch (Exception exp)
                    { }
                }
            }

            string hostName = Dns.GetHostName();
            string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();

            stats.IpAddress = myIP;

            return stats;
        }
コード例 #24
0
 public DataTransfer<PutOutput> Update(PutInput Input)
 {
     DataTransfer<PutOutput> transer = new DataTransfer<PutOutput>();
     IList<string> errors = Validator.Validate(Input);
     if (errors.Count == 0)
     {
         PerformanceStatistic performancestatisticinput = new PerformanceStatistic();
         PerformanceStatistic performancestatisticoutput = new PerformanceStatistic();
         PutOutput output = new PutOutput();
         performancestatisticinput.CopyFrom(Input);
         PerformanceStatistic performancestatistic = _iPerformanceStatisticRepository.GetPerformanceStatistic(performancestatisticinput.PerformanceStatisticId);
         if (performancestatistic!=null)
         {
             performancestatisticoutput = _iPerformanceStatisticRepository.UpdatePerformanceStatistic(performancestatisticinput);
             if(performancestatisticoutput!=null)
             {
                 output.CopyFrom(performancestatisticoutput);
                 transer.IsSuccess = true;
                 transer.Data = output;
             }
             else
             {
                 transer.IsSuccess = false;
                 transer.Errors = new string[1];
                 transer.Errors[0] = "Error: Could not update.";
             }
         }
         else
         {
             transer.IsSuccess = false;
             transer.Errors = new string[1];
             transer.Errors[0] = "Error: Record not found.";
         }
     }
     else
     {
         transer.IsSuccess = false;
         transer.Errors = errors.ToArray<string>();
     }
     return transer;
 }