示例#1
0
 public DesignDevice(string name)
 {
     base.Name = name;
     base.BatteryLevel = 50;
     base.PhoneNumber = "(012) 345-6789";
     base.WinMoDeviceId = "ABCDEF123456";
     base.Manufacturer = "Faux";
     base.Description = "3000";
     StorageInfo info = new StorageInfo {
         TotalBytes = 0x2710L,
         UsedStorageMusic = 500L,
         UsedStoragePictures = 0x5dcL,
         UsedStoragePodcasts = 300L,
         UsedStorageVideos = 500L,
         UsedStorageApps = 0x3e8L,
         UsedStorageSystem = 0x3e8L,
         FreeBytes = 0x1388L
     };
     base.StorageDevices = new Dictionary<string, StorageInfo>();
     base.StorageDevices["built-in"] = info;
     info = new StorageInfo {
         TotalBytes = 0x2710L,
         UsedStorageMusic = 500L,
         UsedStoragePictures = 0x5dcL,
         UsedStoragePodcasts = 300L,
         UsedStorageVideos = 500L,
         UsedStorageApps = 0x3e8L,
         UsedStorageSystem = 0x3e8L,
         FreeBytes = 0x1388L
     };
     base.StorageDevices["sd card"] = info;
 }
示例#2
0
 /// <summary>
 /// 创建任务
 /// </summary>
 public static void CreatTaskInfo(DispatchTaskInfo TaskInfo, bool IsUserStoreState)
 {
     try
     {
         IDbOperator dbOperator = CreateDbOperator.DbOperatorInstance(ConnectConfigTool.DBase);
         using (TransactionScope scope = new TransactionScope())
         {
             Hashtable hs = new Hashtable();
             hs["dispatchNo"] = TaskInfo.dispatchNo;
             hs["stationNo"]  = TaskInfo.stationNo;
             hs["BuildTime"]  = DateTime.Now.ToString("yyyyMMddHHmmss");
             hs["TaskState"]  = TaskInfo.TaskState;
             hs["CallLand"]   = TaskInfo.CallLand;
             hs["CallID"]     = TaskInfo.CallID;
             hs["taskType"]   = TaskInfo.taskType;
             hs["GoodsInfo"]  = TaskInfo.GoodsInfo;
             hs["OwerArea"]   = TaskInfo.OwerArea;
             //保存任务主表
             dbOperator.SetDatas("InsertTaskInfo", hs);
             //保存任务明细信息
             foreach (DispatchTaskDetail detail in TaskInfo.TaskDetail)
             {
                 hs["DetailID"]       = detail.DetailID;
                 hs["LandCode"]       = detail.LandCode;
                 hs["OperType"]       = detail.OperType;
                 hs["IsAllowExcute"]  = detail.IsAllowExcute;
                 hs["PassType"]       = detail.PassType;
                 hs["State"]          = detail.State;
                 hs["PutType"]        = detail.PutType;
                 hs["IsSensorStop"]   = detail.IsSensorStop;
                 hs["PassTye"]        = detail.PassType;
                 hs["IsNeedCallBack"] = detail.IsNeedCallBack;
                 hs["IsCallGoods"]    = detail.IsCallGoods;
                 hs["StorageID"]      = detail.StorageID;
                 dbOperator.SetDatas("InsertTaskDetail", hs);
                 //处理储位占用
                 if (IsUserStoreState)
                 {
                     StorageInfo CurrentTaskUseStore = CoreData.StorageList.FirstOrDefault(p => p.ID == detail.StorageID);
                     if (CurrentTaskUseStore != null)
                     {
                         hs["storeState"] = CurrentTaskUseStore.StorageState;
                         hs["LockState"]  = 1;
                         hs["ID"]         = CurrentTaskUseStore.ID;
                         dbOperator.SetDatas("UpdateStorageState", hs);
                         CurrentTaskUseStore.LockState = 1;
                     }
                 }
             }
             scope.Complete();
         }
     }
     catch (Exception ex)
     { throw ex; }
 }
示例#3
0
        /// <summary>
        /// Creates the StorageInfo for the thread when one isn't already present.
        /// </summary>
        private StorageInfo CreateStorageInfo()
        {
            // we do our own locking, tell hosts this is a bad time to interrupt us.
            Thread.BeginCriticalRegion();

            StorageInfo[] curStorage = s_updating;
            try
            {
                int         threadId = GetCurrentThreadId();
                StorageInfo newInfo  = new StorageInfo(Thread.CurrentThread);

                // set to updating while potentially resizing/mutating, then we'll
                // set back to the current value.
                while ((curStorage = Interlocked.Exchange(ref _stores, s_updating)) == s_updating)
                {
                    // another thread is already updating...
                    Thread.Sleep(0);
                }

                // check and make sure we have a space in the array for our value
                if (curStorage == null)
                {
                    curStorage = new StorageInfo[threadId + 1];
                }
                else if (curStorage.Length <= threadId)
                {
                    StorageInfo[] newStorage = new StorageInfo[threadId + 1];
                    for (int i = 0; i < curStorage.Length; i++)
                    {
                        // leave out the threads that have exited
                        if (curStorage[i] != null && curStorage[i].Thread.IsAlive)
                        {
                            newStorage[i] = curStorage[i];
                        }
                    }
                    curStorage = newStorage;
                }

                // create our StorageInfo in the array, the empty check ensures we're only here
                // when we need to create.
                Debug.Assert(curStorage[threadId] == null || curStorage[threadId].Thread != Thread.CurrentThread);

                return(curStorage[threadId] = newInfo);
            }
            finally
            {
                if (curStorage != s_updating)
                {
                    // let others access the storage again
                    Interlocked.Exchange(ref _stores, curStorage);
                }

                Thread.EndCriticalRegion();
            }
        }
示例#4
0
 /// 更新数据
 /// </summary>
 /// <param name="info">数据表实体</param>
 public static bool UpdateStorageInfo(StorageInfo info)
 {
     try
     {
         return(StorageDAL.UpdateStorageInfo(info));
     }
     catch
     {
         throw;
     }
 }
示例#5
0
 /// 添加数据
 /// </summary>
 /// <param name="info">数据表实体对象</param>
 public static bool AddStorage(StorageInfo info)
 {
     try
     {
         return(StorageDAL.AddStorage(info));
     }
     catch
     {
         throw;
     }
 }
示例#6
0
        public virtual void TestRegistrationWithDifferentSoftwareVersionsDuringUpgrade()
        {
            Configuration conf = new HdfsConfiguration();

            conf.Set(DFSConfigKeys.DfsDatanodeMinSupportedNamenodeVersionKey, "1.0.0");
            MiniDFSCluster cluster = null;

            try
            {
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(0).Build();
                NamenodeProtocols rpcServer = cluster.GetNameNodeRpc();
                long        nnCTime         = cluster.GetNamesystem().GetFSImage().GetStorage().GetCTime();
                StorageInfo mockStorageInfo = Org.Mockito.Mockito.Mock <StorageInfo>();
                Org.Mockito.Mockito.DoReturn(nnCTime).When(mockStorageInfo).GetCTime();
                DatanodeRegistration mockDnReg = Org.Mockito.Mockito.Mock <DatanodeRegistration>();
                Org.Mockito.Mockito.DoReturn(HdfsConstants.DatanodeLayoutVersion).When(mockDnReg)
                .GetVersion();
                Org.Mockito.Mockito.DoReturn("fake-storage-id").When(mockDnReg).GetDatanodeUuid();
                Org.Mockito.Mockito.DoReturn(mockStorageInfo).When(mockDnReg).GetStorageInfo();
                // Should succeed when software versions are the same and CTimes are the
                // same.
                Org.Mockito.Mockito.DoReturn(VersionInfo.GetVersion()).When(mockDnReg).GetSoftwareVersion
                    ();
                Org.Mockito.Mockito.DoReturn("127.0.0.1").When(mockDnReg).GetIpAddr();
                Org.Mockito.Mockito.DoReturn(123).When(mockDnReg).GetXferPort();
                rpcServer.RegisterDatanode(mockDnReg);
                // Should succeed when software versions are the same and CTimes are
                // different.
                Org.Mockito.Mockito.DoReturn(nnCTime + 1).When(mockStorageInfo).GetCTime();
                rpcServer.RegisterDatanode(mockDnReg);
                // Should fail when software version of DN is different from NN and CTimes
                // are different.
                Org.Mockito.Mockito.DoReturn(VersionInfo.GetVersion() + ".1").When(mockDnReg).GetSoftwareVersion
                    ();
                try
                {
                    rpcServer.RegisterDatanode(mockDnReg);
                    NUnit.Framework.Assert.Fail("Should not have been able to register DN with different software"
                                                + " versions and CTimes");
                }
                catch (IncorrectVersionException ive)
                {
                    GenericTestUtils.AssertExceptionContains("does not match CTime of NN", ive);
                    Log.Info("Got expected exception", ive);
                }
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
示例#7
0
 public StructuredStorageRoot(string fileName)
 {
     try
     {
         this._storageRoot = (StorageInfo)StructuredStorageRoot.InvokeStorageRootMethod(null, "Open", fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
     }
     catch (Exception innerException)
     {
         throw new StructuredStorageException("Cannot get StructuredStorageRoot", innerException);
     }
 }
示例#8
0
        public virtual QuorumCall <AsyncLogger, Void> DoUpgrade(StorageInfo sInfo)
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <Void> future = logger.DoUpgrade(sInfo);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
示例#9
0
        /// <summary>
        ///     Invokes StorageRoot.
        /// </summary>
        /// <param name="storageRoot"></param>
        /// <param name="methodName"></param>
        /// <param name="methodArgs"></param>
        /// <returns></returns>
        private static object InvokeStorageRoot(StorageInfo storageRoot, string methodName, params object[] methodArgs)
        {
            if (methodName == null)
            {
                throw new ArgumentNullException(nameof(methodName));
            }

            var type = typeof(StorageInfo).Assembly.GetType("System.IO.Packaging.StorageRoot", true, false);

            return(type.InvokeMember(methodName, _flags, null, storageRoot, methodArgs));
        }
示例#10
0
 public StructuredStorageRoot(Stream stream)
 {
     try
     {
         this._storageRoot = (StorageInfo)StructuredStorageRoot.InvokeStorageRootMethod(null, "CreateOnStream", stream);
     }
     catch (Exception innerException)
     {
         throw new StructuredStorageException("Cannot get StructuredStorageRoot", innerException);
     }
 }
        public IHttpActionResult GetStorageInfo(int id)
        {
            StorageInfo storageInfo = db.StorageInfoes.Find(id);

            if (storageInfo == null)
            {
                return(NotFound());
            }

            return(Ok(storageInfo));
        }
示例#12
0
        public StorageInfo GetStorage()
        {
            StorageInfo            storageInfo = new StorageInfo();
            NSFileSystemAttributes values      = NSFileManager.DefaultManager.GetFileSystemAttributes(Environment.GetFolderPath(Environment.SpecialFolder.Personal));

            storageInfo.LocalStorage.TotalSpace     = values.Size;
            storageInfo.LocalStorage.FreeSpace      = values.FreeSize;
            storageInfo.LocalStorage.AvailableSpace = values.FreeSize;

            return(storageInfo);
        }
示例#13
0
 public NamenodeRegistration(string address, string httpAddress, StorageInfo storageInfo
                             , HdfsServerConstants.NamenodeRole role)
     : base(storageInfo)
 {
     // RPC address of the node
     // HTTP address of the node
     // node role
     this.rpcAddress  = address;
     this.httpAddress = httpAddress;
     this.role        = role;
 }
示例#14
0
        public DateTime GetAttachmentDateTime(string attachedFileName)
        {
            if (Path.IsPathRooted(attachedFileName))
            {
                attachedFileName = System.IO.Path.GetFileName(attachedFileName);
            }

            StorageInfo storageInfo = m_SourceStorage.GetStorageInfo(attachedFileName, StorageInfoFlags.LastModified);

            return(storageInfo.LastModified);
        }
        public IHttpActionResult PostStorageInfo(StorageInfo storageInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StorageInfoes.Add(storageInfo);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = storageInfo.StorageId }, storageInfo));
        }
示例#16
0
        public void DelRecord(StorageInfo obj)
        {
            int rec = _records.FindIndex(x => obj.Equals(x.Storage));

            if (rec >= 0)
            {
                Record rc = _records[rec];
                rc.ReturnBookDate = DateTime.Now;
                _records.RemoveAt(rec);
                _archive.Add(rc);
            }
        }
示例#17
0
        public static SerializableStorageInfo GetSerializableStorageInfo(StorageInfo storageInfo)
        {
            SerializableStorageInfo serializableStorageInfo = new SerializableStorageInfo
            {
                CreationDate = storageInfo.CreationDate,
                UsedStorage  = storageInfo.UsedStorage
            };

            GetInnerFiles(serializableStorageInfo.Directories, storageInfo.Directories);

            return(serializableStorageInfo);
        }
示例#18
0
        public StorageInfo GetStorageInfoModelByName(string sName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" select  top 1 StorageID,sCode,sName,sManager,sTel,sAddress,sRemake,sAppendTime,StorageClassID,sState,");
            strSql.Append("    (select tbStaffInfo.sName from tbStaffInfo where tbStaffInfo.StaffID = sManager) as  Manager ,");
            strSql.Append("   (select tbStorageClassInfo.sClassName from tbStorageClassInfo where tbStorageClassInfo.StorageClassID=tbStorageInfo.StorageClassID) as storageName from tbStorageInfo");
            strSql.Append(" where sCode=@sCode ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sName", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = sName;

            StorageInfo model = new StorageInfo();
            DataSet     ds    = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["StorageID"].ToString() != "")
                {
                    model.StorageID = int.Parse(ds.Tables[0].Rows[0]["StorageID"].ToString());
                }
                model.sCode       = ds.Tables[0].Rows[0]["sCode"].ToString();
                model.sName       = ds.Tables[0].Rows[0]["sName"].ToString();
                model.ManagerName = ds.Tables[0].Rows[0]["Manager"].ToString();
                if (ds.Tables[0].Rows[0]["sManager"].ToString() != "")
                {
                    model.sManager = int.Parse(ds.Tables[0].Rows[0]["sManager"].ToString());
                }
                model.sTel     = ds.Tables[0].Rows[0]["sTel"].ToString();
                model.sAddress = ds.Tables[0].Rows[0]["sAddress"].ToString();
                model.sRemake  = ds.Tables[0].Rows[0]["sRemake"].ToString();
                if (ds.Tables[0].Rows[0]["sAppendTime"].ToString() != "")
                {
                    model.sAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["sAppendTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StorageClassID"].ToString() != "")
                {
                    model.StorageClassID = int.Parse(ds.Tables[0].Rows[0]["StorageClassID"].ToString());
                }
                model.StorageName = ds.Tables[0].Rows[0]["storageName"].ToString();
                if (ds.Tables[0].Rows[0]["sState"].ToString() != "")
                {
                    model.sState = int.Parse(ds.Tables[0].Rows[0]["sState"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#19
0
        /// <summary>
        /// 删除一个对象
        /// </summary>
        /// <param name="GrainID">主键</param>
        /// <returns></returns>
        public static bool DeleteStorageInfo(StorageInfo info)
        {
            bool   rst    = false;
            string sqlStr = "DELETE FROM Storage WHERE GrainID=" + info.GrainID;
            int    rows   = DBManager.ExecuteUpdate(sqlStr);

            if (rows > 0)
            {
                rst = true;
            }
            return(rst);
        }
示例#20
0
        public OleStorageFile(Path oleStorageFilePath)
        {
            int checkResult = NativeMethods.StgIsStorageFile(oleStorageFilePath.FullPathString);

            if (checkResult != 0)
            {
                throw new ArgumentException("The specified file is not an OLE Structured Storage file.");
            }
            _oleStorageFilePath = oleStorageFilePath;
            _storageRoot        = GetStorageRoot(_oleStorageFilePath);
            _isDisposed         = false;
        }
示例#21
0
        private bool AreTargetSlotsBlocked(Item item, byte toSlot, StorageInfo toStorage, bool[,] usedSlots)
        {
            for (var i = toStorage.StartIndex; i < toStorage.EndIndex; i++)
            {
                if (this.IsTargetSlotBlocked(item, toSlot, toStorage, usedSlots))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#22
0
        private StorageInfo GetStorageInfo(Player player, Storages storageType)
        {
            StorageInfo result;

            switch (storageType)
            {
            case Storages.Inventory:
                result = new StorageInfo
                {
                    Rows       = InventoryRows,
                    StartIndex = EquippableSlotsCount,
                    EndIndex   = (byte)(EquippableSlotsCount + GetInventorySize(player)),
                    Storage    = player.Inventory
                };
                break;

            case Storages.PersonalStore:
                result = new StorageInfo
                {
                    Rows       = StoreRows,
                    StartIndex = FirstStoreItemSlotIndex,
                    EndIndex   = (byte)(FirstStoreItemSlotIndex + StoreSize),
                    Storage    = player.ShopStorage
                };
                break;

            case Storages.Vault:
                result = new StorageInfo
                {
                    Rows       = WarehouseRows,
                    EndIndex   = WarehouseSize,
                    Storage    = player.Vault,
                    StartIndex = 0
                };
                break;

            case Storages.Trade:
            case Storages.ChaosMachine:
                result = new StorageInfo
                {
                    Storage    = player.TemporaryStorage,
                    Rows       = TemporaryStorageRows,
                    EndIndex   = TemporaryStorageSize,
                    StartIndex = 0
                };
                break;

            default:
                throw new NotImplementedException($"Moving to {storageType} is not implemented.");
            }

            return(result);
        }
示例#23
0
 private void FormMain_Load(object sender, EventArgs e)
 {
     try
     {
         _storage = StorageInfoLoader.Load();
         ReloadInfo();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, ErrorConstants.CRITICAL_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
 /// <exception cref="System.IO.IOException"/>
 public virtual void DoUpgrade(string journalId, StorageInfo sInfo)
 {
     try
     {
         rpcProxy.DoUpgrade(NullController, ((QJournalProtocolProtos.DoUpgradeRequestProto
                                              )QJournalProtocolProtos.DoUpgradeRequestProto.NewBuilder().SetJid(ConvertJournalId
                                                                                                                    (journalId)).SetSInfo(PBHelper.Convert(sInfo)).Build()));
     }
     catch (ServiceException e)
     {
         throw ProtobufHelper.GetRemoteException(e);
     }
 }
示例#25
0
        public virtual QuorumCall <AsyncLogger, bool> CanRollBack(StorageInfo storage, StorageInfo
                                                                  prevStorage, int targetLayoutVersion)
        {
            IDictionary <AsyncLogger, ListenableFuture <bool> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <bool> future = logger.CanRollBack(storage, prevStorage, targetLayoutVersion
                                                                    );
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
示例#26
0
        // ---
        // TODO: Can't use `Serialization.Collections` utilities because can't
        // implement `INetSerializable` on `Item.Kind` or `Option<Item.Kind>`.
        // For now we'll just do it manually.

        private void SerializeData(NetDataWriter writer)
        {
            int count = data.Count;

            writer.Put(count);
            foreach (KeyValuePair <Item.Kind, StorageInfo> pair in data)
            {
                Item.Kind   itemKind    = pair.Key;
                StorageInfo storageInfo = pair.Value;
                writer.Put((int)pair.Key);
                storageInfo.Serialize(writer);
            }
        }
示例#27
0
        private void DeserializeData(NetDataReader reader)
        {
            int count = reader.GetInt();

            data = new Dictionary <Item.Kind, StorageInfo>(count);
            for (int i = 0; i < count; i++)
            {
                var         itemKind    = (Item.Kind)reader.GetInt();
                StorageInfo storageInfo = new StorageInfo();
                storageInfo.Deserialize(reader);
                data.Add(itemKind, storageInfo);
            }
        }
示例#28
0
        public virtual void TestRegistrationWithDifferentSoftwareVersions()
        {
            Configuration conf = new HdfsConfiguration();

            conf.Set(DFSConfigKeys.DfsDatanodeMinSupportedNamenodeVersionKey, "3.0.0");
            conf.Set(DFSConfigKeys.DfsNamenodeMinSupportedDatanodeVersionKey, "3.0.0");
            MiniDFSCluster cluster = null;

            try
            {
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(0).Build();
                NamenodeProtocols rpcServer = cluster.GetNameNodeRpc();
                long        nnCTime         = cluster.GetNamesystem().GetFSImage().GetStorage().GetCTime();
                StorageInfo mockStorageInfo = Org.Mockito.Mockito.Mock <StorageInfo>();
                Org.Mockito.Mockito.DoReturn(nnCTime).When(mockStorageInfo).GetCTime();
                DatanodeRegistration mockDnReg = Org.Mockito.Mockito.Mock <DatanodeRegistration>();
                Org.Mockito.Mockito.DoReturn(HdfsConstants.DatanodeLayoutVersion).When(mockDnReg)
                .GetVersion();
                Org.Mockito.Mockito.DoReturn("127.0.0.1").When(mockDnReg).GetIpAddr();
                Org.Mockito.Mockito.DoReturn(123).When(mockDnReg).GetXferPort();
                Org.Mockito.Mockito.DoReturn("fake-storage-id").When(mockDnReg).GetDatanodeUuid();
                Org.Mockito.Mockito.DoReturn(mockStorageInfo).When(mockDnReg).GetStorageInfo();
                // Should succeed when software versions are the same.
                Org.Mockito.Mockito.DoReturn("3.0.0").When(mockDnReg).GetSoftwareVersion();
                rpcServer.RegisterDatanode(mockDnReg);
                // Should succeed when software version of DN is above minimum required by NN.
                Org.Mockito.Mockito.DoReturn("4.0.0").When(mockDnReg).GetSoftwareVersion();
                rpcServer.RegisterDatanode(mockDnReg);
                // Should fail when software version of DN is below minimum required by NN.
                Org.Mockito.Mockito.DoReturn("2.0.0").When(mockDnReg).GetSoftwareVersion();
                try
                {
                    rpcServer.RegisterDatanode(mockDnReg);
                    NUnit.Framework.Assert.Fail("Should not have been able to register DN with too-low version."
                                                );
                }
                catch (IncorrectVersionException ive)
                {
                    GenericTestUtils.AssertExceptionContains("The reported DataNode version is too low"
                                                             , ive);
                    Log.Info("Got expected exception", ive);
                }
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
示例#29
0
        /// <summary>
        /// Gets the current value if its not == null or calls the provided function
        /// to create a new value.
        /// </summary>
        public T GetOrCreate(Func <T> func)
        {
            Assert.NotNull(func);

            StorageInfo si  = GetStorageInfo();
            T           res = si.Value;

            if (res == null)
            {
                si.Value = res = func();
            }

            return(res);
        }
示例#30
0
 public StructuredStorageRoot(Stream stream)
 {
     try
     {
         _storageRoot
             = (StorageInfo)InvokeStorageRootMethod(
                   null, "CreateOnStream", stream);
     }
     catch (Exception ex)
     {
         throw new StructuredStorageException(
                   "Cannot get StructuredStorageRoot", ex);
     }
 }
示例#31
0
        private void SetUsedSlots(StorageInfo toStorage, Item blockingItem, bool[,] usedSlots)
        {
            int columnIndex = (blockingItem.ItemSlot - toStorage.StartIndex) % RowSize;
            int rowIndex    = (blockingItem.ItemSlot - toStorage.StartIndex) / RowSize;

            // Set all taken slots of this item to true
            for (int r = rowIndex; r < rowIndex + blockingItem.Definition.Height; r++)
            {
                for (int c = columnIndex; c < columnIndex + blockingItem.Definition.Width; c++)
                {
                    usedSlots[r, c] = true;
                }
            }
        }
示例#32
0
        public static void Run()
        {
            while (Nagme.Globals.programRunning) {

                DriveInfo[] drives = DriveInfo.GetDrives ();
                List<StorageInfo> storeInfo = new List<StorageInfo>();

                foreach (DriveInfo drive in drives) {

                    if (drive.DriveType == DriveType.Fixed) {

                        StorageInfo tmpStore = new StorageInfo();

                        System.Console.WriteLine ("Drive Root: " + drive.RootDirectory);
                        System.Console.WriteLine ("Drive Size: " + drive.TotalSize);
                        System.Console.WriteLine ("Free Space: " + drive.TotalFreeSpace);

                        tmpStore.RootDirectory = drive.RootDirectory.ToString();
                        tmpStore.VolumeLabel = drive.VolumeLabel.ToString();
                        tmpStore.TotalSize = (int)(drive.TotalSize/1024/1024);
                        tmpStore.TotalFreeSize = (int)(drive.TotalFreeSpace/1024/1024);

                        storeInfo.Add(tmpStore);

                    }
                }

                INagMe register = (INagMe)XmlRpcProxyGen.Create(typeof(INagMe));
                register.Url = Nagme.Globals.xmlrpcAddress();
                if(register.updateDriveInfo(storeInfo.ToArray(), Nagme.Globals.DeviceID(), Nagme.Globals.DevicePassword())){
                    Console.WriteLine("Updated Storage Info");
                }else{
                    Console.WriteLine("Failed Storage General Info");
                }

                Console.WriteLine("");
                System.Threading.Thread.Sleep (60000);

            }
        }
 private StorageInfo GetStorageDeviceInfo(IDevice device)
 {
     StorageInfo info;
     if ((device.StorageDevices == null) || (device.StorageDevices.Count < 1))
     {
         info = new StorageInfo();
         this.currentStorageArea = "";
         this.OnPropertyChanged("CurrentStorageArea");
         return info;
     }
     if ((this.CurrentStorageArea == null) || !device.StorageDevices.TryGetValue(this.CurrentStorageArea, out info))
     {
         info = device.StorageDevices.FirstOrDefault<KeyValuePair<string, StorageInfo>>().Value;
         this.currentStorageArea = device.StorageDevices.FirstOrDefault<KeyValuePair<string, StorageInfo>>().Key;
         this.OnPropertyChanged("CurrentStorageArea");
     }
     return info;
 }