Пример #1
0
        protected async Task RunTestAsync(Func <OperationContext, ColdStorage, DisposableDirectory, Task> funcAsync)
        {
            var context   = new OperationContext(new Context(Logger));
            var directory = new DisposableDirectory(FileSystem);

            ColdStorageSettings coldStorageSettings = new ColdStorageSettings(directory.Path.Path, "1MB");

            TestDistributedContentCopier copier = DistributedContentCopierTests.CreateMocks(
                new MemoryFileSystem(TestSystemClock.Instance),
                directory.CreateRandomFileName(),
                TimeSpan.FromSeconds(1)).Item1;

            var store = new ColdStorage(FileSystem, coldStorageSettings, copier);

            try
            {
                Assert.False(store.StartupStarted);
                Assert.False(store.StartupCompleted);
                Assert.False(store.ShutdownStarted);
                Assert.False(store.ShutdownCompleted);

                await store.StartupAsync(context).ShouldBeSuccess();

                await funcAsync(context, store, directory);
            }
            finally
            {
                await store.ShutdownAsync(context).ShouldBeSuccess();
            }

            Assert.True(store.StartupStarted);
            Assert.True(store.StartupCompleted);
            Assert.True(store.ShutdownStarted);
            Assert.True(store.ShutdownCompleted);
        }
Пример #2
0
        /// <summary>
        /// 获取冷藏载体列表
        /// </summary>
        /// <returns></returns>
        public static List <ColdStorage> GetStorageList(string storageName)
        {
            List <ColdStorage> list = new List <ColdStorage>();

            try
            {
                string sql = "select Id,storageName,storageType,driver,driverTel,remark,createAt from c2lp_storage";
                if (!string.IsNullOrEmpty(storageName))
                {
                    sql += " where storageName like '%" + storageName + "%' or storageName='" + storageName + "'";
                }
                DataSet ds = _SqlHelp.ExecuteDataSet(sql, System.Data.CommandType.Text);
                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        ColdStorage cs = new ColdStorage();
                        cs.Id          = Convert.ToInt32(row["Id"]);
                        cs.storageName = row["StorageName"].ToString();
                        cs.storageType = Convert.ToInt32(row["StorageType"]);
                        cs.driver      = row["Driver"] is DBNull ? "" : row["Driver"].ToString();
                        cs.driverTel   = row["driverTel"] is DBNull ? "" : row["driverTel"].ToString();
                        cs.remark      = row["remark"] is DBNull ? "" : row["remark"].ToString();
                        cs.createAt    = row["createAt"].ToString();
                        list.Add(cs);
                    }
                }
            }
            catch
            {
            }
            return(list);
        }
Пример #3
0
        /// <summary>
        /// 获取所有冷藏载体信息_Scan
        /// </summary>
        /// <returns></returns>
        public static Hashtable GetAllStorageScan()
        {
            Hashtable list = new Hashtable();

            try
            {
                string  sql = "select storageId,storageName,storageType from c2lp_storage_scan order by storageType";
                DataSet ds  = _SqlHelp.ExecuteDataSet(sql, CommandType.Text);
                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        ColdStorage cs = new ColdStorage();
                        cs.Id          = Convert.ToInt32(row["storageId"]);
                        cs.storageName = row["StorageName"].ToString();
                        cs.storageType = Convert.ToInt32(row["StorageType"]);
                        if (list.Contains(cs.Id))
                        {
                            list[cs.Id] = cs;
                        }
                        else
                        {
                            list.Add(cs.Id, cs);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            return(list);
        }
Пример #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            ColdStorage select = (ColdStorage)cboStorage.SelectedItem;

            if (select == null)
            {
                MessageBox.Show("请选择一个车载或冷库作为当前设备的冷藏载体!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            Common._StorageName = select.storageName.Replace("[默认]", "");
            btnCancel_Click(sender, e);
        }
Пример #5
0
 /// <summary>
 /// 加载载体信息
 /// </summary>
 private void LoadStorageInfo()
 {
     try
     {
         List <ColdStorage> list = StorageServer.GetStorageList(Common._StorageName);
         if (list.Count() == 0)
         {
             throw new Exception("本地数据不存在该冷藏载体!");
         }
         _StorageInfo = list[0];
     }
     catch (Exception ex)
     {
         throw new Exception("加载冷藏载体信息失败:" + ex.Message);
     }
 }
 /// <nodoc />
 public DistributedContentSession(
     string name,
     IContentSession inner,
     IContentLocationStore contentLocationStore,
     DistributedContentCopier contentCopier,
     DistributedContentStore distributedStore,
     MachineLocation localMachineLocation,
     ColdStorage coldStorage,
     DistributedContentStoreSettings settings = default)
     : base(
         name,
         inner,
         contentLocationStore,
         contentCopier,
         distributedStore,
         localMachineLocation,
         coldStorage,
         settings)
 {
 }