Changeset 2018


Ignore:
Timestamp:
Oct 27, 2010, 9:14:52 PM (11 years ago)
Author:
Sven Rech
Message:

put UniqueIdentifier class in PluginBase

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginBase/CrypPluginBase.csproj

    r2010 r2018  
    8989    </Reference>
    9090    <Reference Include="System.Drawing" />
     91    <Reference Include="System.Management" />
    9192    <Reference Include="System.Numerics" />
    9293    <Reference Include="System.Xaml" />
     
    141142    <Compile Include="Miscellaneous\SuperTooltip.cs" />
    142143    <Compile Include="Miscellaneous\Tokenizer.cs" />
     144    <Compile Include="Miscellaneous\UniqueIdentifier.cs" />
    143145    <Compile Include="PluginExtension.cs" />
    144146    <Compile Include="Attributes\PluginInfoAttribute.cs">
  • trunk/CrypPlugins/QuadraticSieve/PeerToPeer.cs

    r1883 r2018  
    6666        private QuadraticSievePresentation quadraticSieveQuickWatchPresentation;
    6767        private AutoResetEvent newRelationPackageEvent;
    68         private int ourID;           //Our ID
     68        private long ourID;           //Our ID
    6969        private Dictionary<int, string> nameCache;  //associates the ids with the names
    7070        private Queue<PeerPerformanceInformations> peerPerformances;      //A queue of performances from the different peers ordered by the date last checked.
     
    9999        private void SetOurID()
    100100        {
    101             string username = WindowsIdentity.GetCurrent().Name;
    102             string mac = GetMacIdentifier();
    103 
    104             MD5 md5 = new MD5CryptoServiceProvider();
    105             byte[] idBytes = md5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(username + mac));
    106 
    107             ourID = BitConverter.ToInt32(idBytes, 3);
     101            ourID = Cryptool.PluginBase.Miscellaneous.UniqueIdentifier.GetID();
    108102            quadraticSieveQuickWatchPresentation.ProgressRelationPackages.setOurID(ourID);
    109 
    110             ourName = System.Net.Dns.GetHostName();
     103            ourName = Cryptool.PluginBase.Miscellaneous.UniqueIdentifier.GetHostName();
    111104        }
    112105
     
    424417        }
    425418
    426         private void SetProgressRelationPackage(int index, int id, string name)
     419        private void SetProgressRelationPackage(int index, long id, string name)
    427420        {
    428421            quadraticSieveQuickWatchPresentation.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     
    455448        }
    456449
    457         private string NameIdentifier(int ID)
     450        private string NameIdentifier(long ID)
    458451        {
    459452            return channel + "#" + number + "NAME" + ID.ToString();
    460453        }
    461454
    462         private string PerformanceIdentifier(int ID)
     455        private string PerformanceIdentifier(long ID)
    463456        {
    464457            return channel + "#" + number + "-" + factor + "PERFORMANCE" + ID.ToString();
     
    502495        }
    503496       
    504         /// <summary>
    505         /// Returns an identifier that depends on the MAC addresses of this system
    506         /// </summary>       
    507         private string GetMacIdentifier()
    508         {
    509             string MacID = "";
    510             ManagementClass MC = new ManagementClass("Win32_NetworkAdapter");
    511             ManagementObjectCollection MOCol = MC.GetInstances();
    512             foreach (ManagementObject MO in MOCol)
    513                 if (MO != null)
    514                     if (MO["MacAddress"] != null)
    515                         MacID += MO["MACAddress"].ToString();
    516             return MacID;
    517         }
     497
    518498
    519499        public Queue GetLoadedRelationPackagesQueue()
  • trunk/CrypPlugins/QuadraticSieve/ProgressRelationPackages.xaml.cs

    r1692 r2018  
    2020    public partial class ProgressRelationPackages : UserControl
    2121    {
    22         private int ourID;
     22        private long ourID;
    2323        private ScrollViewer scrollViewer;
    2424
    25         public void Set(int i, int id, string name)
     25        public void Set(int i, long id, string name)
    2626        {
    2727            if (root.Children.Count <= i)   //if no shape exists for this relation package yet
     
    4444        }
    4545
    46         public void setOurID(int id)
     46        public void setOurID(long id)
    4747        {
    4848            ourID = id;
    4949        }
    5050
    51         private void SetShapeToStatus(int index, int uploaderID, string uploaderName)
     51        private void SetShapeToStatus(int index, long uploaderID, string uploaderName)
    5252        {
    5353            ToolTip tooltip = new ToolTip();
     
    9191        }
    9292
    93         private Brush GetColor(int uploaderID)
     93        private Brush GetColor(long uploaderID)
    9494        {           
    9595            SolidColorBrush color = new SolidColorBrush();
    96             Random random = new Random(uploaderID);
     96            Random random = new Random((int)uploaderID);
    9797
    9898            bool ok;
     
    121121        }
    122122
    123         private void CreateRelationPackageShape(int c, int id, string name)
     123        private void CreateRelationPackageShape(int c, long id, string name)
    124124        {
    125125            Shape shape = GetRelationPackageShape(id);           
     
    129129        }
    130130
    131         private Shape GetRelationPackageShape(int id)
     131        private Shape GetRelationPackageShape(long id)
    132132        {
    133133            Shape shape;
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSieve.csproj

    r1763 r2018  
    8585      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    8686    </Reference>
    87     <Reference Include="System.Management" />
    8887    <Reference Include="System.Numerics" />
    8988    <Reference Include="System.Xaml" />
Note: See TracChangeset for help on using the changeset viewer.