Beispiel #1
0
 /// <summary>
 /// 删除选中的项目
 /// </summary>
 /// <param name="select"></param>
 public void DeleteStoreStruct(params string[] select)
 {
     using (StoreAccess access = new StoreAccess(true))
     {
         string strSQL = string.Empty;
         try
         {
             access.Open();
             access.BeginTransaction();
             if (select[0] == "全部删除")
             {
                 strSQL = access.CommandFormate("DELETE FROM [dbo].[Table_Warehouse]");
                 access.Delete(strSQL);
             }
             else
             {
                 strSQL = access.CommandFormate("DELETE FROM [dbo].[Table_Warehouse] WHERE [Row] = {0}Row AND [Column] = {0}Column AND [Layer] = {0}Layer");
                 access.Delete(strSQL, parmater =>
                 {
                     parmater.Add(parmater.CreateParameter("Row", select[1]));
                     parmater.Add(parmater.CreateParameter("Column", select[2]));
                     parmater.Add(parmater.CreateParameter("Layer", select[3]));
                 });
             }
             access.Commit();
         }
         catch (DbException dbe)
         {
             LogBusiness.RecordLog("管理员", dbe.Message, "删除仓库结构数据操作异常");
         }
     }
 }
Beispiel #2
0
        public void ExecuteLogin_LogsIn_AndRaisesLoggedInEvent()
        {
            _viewModel.SatelliteAddress = "europe-west-1.tardigrade.io:7777";
            _viewModel.Secret           = "mySecret";
            _viewModel.SecretVerify     = "mySecretVerify";
            _viewModel.ApiKey           = "apiKey";
            StoreAccess access = new StoreAccess("myAccess");
            SuccessfullyLoggedInMessage loggedInMessage = new SuccessfullyLoggedInMessage();

            _storeAccessServiceMock.Setup(s => s.GenerateAccessFromLogin(Moq.It.Is <LoginData>(l => l.ApiKey == _viewModel.ApiKey &&
                                                                                               l.SatelliteAddress == _viewModel.SatelliteAddress &&
                                                                                               l.Secret == _viewModel.Secret))).Returns(access).Verifiable();

            _loginServiceMock.Setup(s => s.Login(access)).Returns(true).Verifiable();

            _eventAggregator.Setup(s => s.GetEvent <SuccessfullyLoggedInMessage>()).Returns(loggedInMessage).Verifiable();

            _viewModel.LoginCommand.Execute();

            Assert.IsFalse(_viewModel.LoginFailed);

            _storeAccessServiceMock.Verify();
            _loginServiceMock.Verify();
            _eventAggregator.Verify();
        }
Beispiel #3
0
        private static StoreAccess Access(ManagementData management)
        {
            StoreAccess access = new StoreAccess();

            management.KernelData.DataSourceManager.addListener(access);
            return(access);
        }
Beispiel #4
0
        public async Task InitAsync(StoreAccess storeAccess)
        {
            int tryCount = 0;

            Books.Clear();
            _storeAccess = storeAccess;
            try
            {
                try
                {
                    tryCount++;
                    BookShelf = await _bookShelfService.LoadBookShelfAsync(storeAccess);
                }catch (Exception ex)
                {
                    tryCount++;
                    await Task.Delay(1000).ConfigureAwait(false);

                    BookShelf = await _bookShelfService.LoadBookShelfAsync(storeAccess);
                }

                foreach (var bookReference in BookShelf.Content)
                {
                    var bookVM = await BookViewModel.CreateAsync(_bookService, _eventAggregator, bookReference);

                    Books.Add(bookVM);
                }
            }
            catch (NoBookShelfExistsException ex)
            {
                _eventAggregator.GetEvent <NoBookShelfExistsMessage>().Publish(new Tuple <StoreAccess, string>(storeAccess, ex.Message + " - " + ex.AccessGrant + " - " + ex.AdditionalError + " - " + ex.StoreKey + " - " + tryCount.ToString() + " - " + ex.StackTrace));
            }
        }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void execute(final org.neo4j.kernel.api.direct.DirectStoreAccess directStoreAccess, final org.neo4j.consistency.checking.CheckDecorator decorator, final org.neo4j.consistency.store.RecordAccess recordAccess, final org.neo4j.consistency.report.InconsistencyReport report, org.neo4j.consistency.checking.cache.CacheAccess cacheAccess, org.neo4j.consistency.report.ConsistencyReporter.Monitor reportMonitor) throws ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        internal virtual void Execute(DirectStoreAccess directStoreAccess, CheckDecorator decorator, RecordAccess recordAccess, InconsistencyReport report, CacheAccess cacheAccess, ConsistencyReporter.Monitor reportMonitor)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.consistency.report.ConsistencyReporter reporter = new org.neo4j.consistency.report.ConsistencyReporter(recordAccess, report, reportMonitor);
            ConsistencyReporter reporter          = new ConsistencyReporter(recordAccess, report, reportMonitor);
            StoreProcessor      processEverything = new StoreProcessor(decorator, reporter, Stage_Fields.SequentialForward, cacheAccess);

            ProgressMonitorFactory.MultiPartBuilder progress = _progressFactory.multipleParts("Full Consistency Check");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.store.StoreAccess nativeStores = directStoreAccess.nativeStores();
            StoreAccess nativeStores = directStoreAccess.NativeStores();

            try
            {
                using (IndexAccessors indexes = new IndexAccessors(directStoreAccess.Indexes(), nativeStores.SchemaStore, _samplingConfig))
                {
                    MultiPassStore.Factory multiPass   = new MultiPassStore.Factory(decorator, recordAccess, cacheAccess, report, reportMonitor);
                    ConsistencyCheckTasks  taskCreator = new ConsistencyCheckTasks(progress, processEverything, nativeStores, _statistics, cacheAccess, directStoreAccess.LabelScanStore(), indexes, directStoreAccess.TokenHolders(), multiPass, reporter, _threads);

                    if (_checkIndexStructure)
                    {
                        ConsistencyCheckIndexStructure(directStoreAccess.LabelScanStore(), indexes, reporter, _progressFactory);
                    }

                    IList <ConsistencyCheckerTask> tasks = taskCreator.CreateTasksForFullCheck(_checkLabelScanStore, _checkIndexes, _checkGraph);
                    progress.Build();
                    TaskExecutor.Execute(tasks, decorator.prepare);
                }
            }
            catch (Exception e)
            {
                throw new ConsistencyCheckIncompleteException(e);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 仓库结构修改
        /// </summary>
        public int StoreStructUpdate(params string[] store)
        {
            int count = 0;

            using (StoreAccess access = new StoreAccess(true))
            {
                try
                {
                    access.Open();
                    access.BeginTransaction();
                    string strSQL = access.CommandFormate("UPDATE [dbo].[Table_Warehouse] SET [StoreStaus] = {0}StoreStaus,[Type]={0}Type WHERE [Row]={0}Row AND [Column]={0}Column AND [Layer]={0}Layer");
                    count = access.Update(strSQL, (parmarter) =>
                    {
                        parmarter.Add(parmarter.CreateParameter("StoreStaus", store[0]));
                        parmarter.Add(parmarter.CreateParameter("Type", store[1]));
                        parmarter.Add(parmarter.CreateParameter("Row", store[2]));
                        parmarter.Add(parmarter.CreateParameter("Column", store[3]));
                        parmarter.Add(parmarter.CreateParameter("Layer", store[4]));
                    });
                    access.Commit();
                }
                catch (DbException ex)
                {
                    LogBusiness.RecordLog("管理员", ex.Message, "修改仓库结构数据操作异常");
                    access.RollBack();
                    access.Close();
                }
            }
            return(count);
        }
        public async Task InitAsync(StoreAccess storeAccess, BookShareReference bookShareReference)
        {
            _storeAccess        = storeAccess;
            _bookShareReference = bookShareReference;

            BookShare = await _bookShareStoreService.LoadBookShareAsync(_bookShareReference);
        }
Beispiel #8
0
 public static LoginResult Login(string account, string password, out User loginUser)
 {
     loginUser = null;
     using (StoreAccess access = new StoreAccess())
     {
         try
         {
             User user = access.Login(account, password);
             if (user == null)
             {
                 return(LoginResult.ValidateError);
             }
             else
             {
                 loginUser = user;
                 return(LoginResult.Success);
             }
         }
         catch (DbException err)
         {
             return(LoginResult.NetError);
         }
         finally
         {
             access.Close();
         }
     }
 }
Beispiel #9
0
 internal CountsBuilderDecorator(StoreAccess storeAccess)
 {
     this._storeAccess                     = storeAccess;
     this._nodeStore                       = storeAccess.RawNeoStores.NodeStore;
     this._nodeCountBuildCondition         = new MultiPassAvoidanceCondition <NodeRecord>(0);
     this._relationshipCountBuildCondition = new MultiPassAvoidanceCondition <RelationshipRecord>(1);
 }
Beispiel #10
0
 internal RelationshipCounts(StoreAccess storeAccess, MutableObjectLongMap <CountsKey> counts, System.Predicate <RelationshipRecord> countUpdateCondition, OwningRecordCheck <RelationshipRecord, ConsistencyReport_RelationshipConsistencyReport> inner)
 {
     this.NodeStore            = storeAccess.RawNeoStores.NodeStore;
     this.Counts               = counts;
     this.CountUpdateCondition = countUpdateCondition;
     this.Inner = inner;
 }
Beispiel #11
0
        /// <summary>
        /// 删除用户怇
        /// </summary>
        /// <param name="acount"></param>
        /// <param name="type">1:条件删除 2:全部删除</param>
        /// <returns></returns>
        public int DeleteAcount(object acount, int type)
        {
            int    num = 0;
            string sql = string.Empty;

            if (type == 1)
            {
                sql = string.Format("DELETE FROM [Table_User] WHERE [Id] = {0}", acount);
            }
            else
            {
                sql = "DELETE FROM [Table_User]";
            }
            using (StoreAccess access = new StoreAccess(true))
            {
                try
                {
                    access.Open();
                    access.BeginTransaction();
                    num = access.Delete(sql);
                    access.Commit();
                }
                catch (Exception ex)
                {
                    access.RollBack();
                    access.Close();
                }
            }
            return(num);
        }
Beispiel #12
0
 /// <summary>
 /// 加载主界面数据
 /// </summary>
 /// <returns></returns>
 public DataTable LoadUserAcount()
 {
     using (StoreAccess access = new StoreAccess())
     {
         return(access.ToDataTable <User>(access.Select <User>()));
     }
 }
 public void Init()
 {
     _storeAccess          = new StoreAccess("use this access");
     _bookShelfServiceMock = new Moq.Mock <IBookShelfService>();
     _eventAggregator      = new Moq.Mock <IEventAggregator>();
     _viewModel            = new CreateBookShelfViewModel(_bookShelfServiceMock.Object, _eventAggregator.Object);
 }
Beispiel #14
0
        private void GenerateInitialData()
        {
            GraphDatabaseBuilder builder = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_directory.databaseDir());
            GraphDatabaseAPI     graphDb = ( GraphDatabaseAPI )builder.SetConfig(GraphDatabaseSettings.record_format, _formatName).setConfig(GraphDatabaseSettings.label_block_size, "60").setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            try
            {
                GenerateInitialData(graphDb);
                StoreAccess stores = (new StoreAccess(graphDb.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores())).initialize();
                _schemaId     = stores.SchemaStore.HighId;
                _nodeId       = stores.NodeStore.HighId;
                _labelId      = ( int )stores.LabelTokenStore.HighId;
                _nodeLabelsId = stores.NodeDynamicLabelStore.HighId;
                _relId        = stores.RelationshipStore.HighId;
                _relGroupId   = stores.RelationshipGroupStore.HighId;
                _propId       = ( int )stores.PropertyStore.HighId;
                _stringPropId = stores.StringStore.HighId;
                _arrayPropId  = stores.ArrayStore.HighId;
                _relTypeId    = ( int )stores.RelationshipTypeTokenStore.HighId;
                _propKeyId    = ( int )stores.PropertyKeyNameStore.HighId;
            }
            finally
            {
                graphDb.Shutdown();
            }
        }
Beispiel #15
0
 /// <summary>
 /// 必须按照格式【什么人,干什么事,什么类型】
 /// </summary>
 /// <param name="log"></param>
 public static void RecordLog(string logs1, string logs2, string logs3)
 {
     using (StoreAccess access = new StoreAccess(true))
     {
         try
         {
             string strSQL = access.CommandFormate("INSERT INTO [Table_Log] ([Logtime] ,[LogUser],[Remark],[Type]) VALUES ({0}Logtime,{0}LogUser,{0}Remark,{0}Type)");
             access.Open();
             access.BeginTransaction();
             access.Insert(strSQL, parmater =>
             {
                 parmater.Add(parmater.CreateParameter("Logtime", DateTime.Now));
                 parmater.Add(parmater.CreateParameter("LogUser", logs1));
                 parmater.Add(parmater.CreateParameter("Remark", logs2));
                 parmater.Add(parmater.CreateParameter("Type", logs3));
             });
             access.Commit();
         }
         catch (DbException db)
         {
             access.RollBack();
             access.Close();
         }
     }
 }
Beispiel #16
0
 public List <VerifyRecode> GetMaterial(string code)
 {
     using (StoreAccess access = new StoreAccess())
     {
         string strSQL = string.Format("SELECT * FROM [Table_VerifyRecode] WHERE [Barcode] = '{0}'", code);
         return(access.Select <VerifyRecode>(strSQL));
     }
 }
Beispiel #17
0
 public DataTable GetInfomation(string code)
 {
     using (StoreAccess accesss = new StoreAccess())
     {
         string strSQL = string.Format("SELECT [MaterialNumber],[MaterialName], [Result],[Iquantity],[Batch],[SupplierName] FROM [Table_InvoiceVerify] WHERE [InvoiceNumber] = '{0}'", code);
         return(accesss.ExcuteTable(strSQL));
     }
 }
Beispiel #18
0
 /// <summary>
 /// 查询仓库结构
 /// </summary>
 /// <returns></returns>
 public DataTable GetStoreStructure()
 {
     using (StoreAccess access = new StoreAccess())
     {
         string strSQL = "SELECT [Row],[Column],[Layer],[StoreStaus],[MaxCount],[Status],[Type] FROM [WMS_Manager].[dbo].[Table_Warehouse]";
         return(access.ExcuteTable(strSQL));
     }
 }
Beispiel #19
0
 internal StoreProcessorTask(string name, Statistics statistics, int threads, RecordStore <R> store, StoreAccess storeAccess, string builderPrefix, ProgressMonitorFactory.MultiPartBuilder builder, CacheAccess cacheAccess, StoreProcessor processor, QueueDistribution distribution) : base(name, statistics, threads)
 {
     this._store            = store;
     this._storeAccess      = storeAccess;
     this._cacheAccess      = cacheAccess;
     this._processor        = processor;
     this._distribution     = distribution;
     this._progressListener = builder.ProgressForPart(name + IndexedPartName(store.StorageFile.Name, builderPrefix), store.HighId);
 }
Beispiel #20
0
        public StoreDetail CreateStore(string userId, string subscriptionId, string label)
        {
            var context = GetAccountsContext();

            var account = context.Accounts.FirstOrDefault(a => a.UserTokens.Any(t => t.Id.Equals(userId)));

            if (account == null)
            {
                throw new AccountsRepositoryException(AccountsRepositoryException.UserAccountNotFound,
                                                      "No registered account found for user");
            }

            var subscription =
                context.Subscriptions.FirstOrDefault(s => s.Account.Equals(account) && s.Id.Equals(subscriptionId));

            if (subscription == null)
            {
                throw new AccountsRepositoryException(AccountsRepositoryException.InvalidSubscriptionId,
                                                      "The user does not own a subscription with the the specified ID");
            }

            var storeContainerId = Guid.NewGuid().ToString();

            if (subscription.StoreCount >= subscription.StoreCountLimit)
            {
                throw new AccountsRepositoryException(AccountsRepositoryException.StoreCountLimitReached,
                                                      "Subscription store count limit reached");
            }
            subscription.StoreCount++;
            var store = new Store
            {
                CurrentSize    = 0,
                IsLimited      = false,
                SizeLimit      = subscription.StoreSizeLimit,
                StoreContainer = storeContainerId,
                Subscription   = subscription,
                Label          = label
            };

            context.Stores.Add(store);

            var storeAccess = new StoreAccess
            {
                Grantee    = account,
                GrantLevel =
                    (int)
                    (StoreAccessLevel.Read | StoreAccessLevel.Write | StoreAccessLevel.Admin |
                     StoreAccessLevel.Export),
                AccessStore = store
            };

            context.StoreAccesss.Add(storeAccess);

            context.SaveChanges();
            return(new StoreDetail(store));
        }
Beispiel #21
0
 /// <summary>
 /// 获得账户信息
 /// </summary>
 /// <param name="userAcount"></param>
 /// <returns></returns>
 public List <User> GetUserForAcount(object userAcount)
 {
     using (StoreAccess access = new StoreAccess())
     {
         string strSQL = access.CommandFormate("SELECT [Name],[Remark],[Access] FROM [Table_User] WHERE Id = {0}Id");
         return(access.ExcuteSelect <User>(strSQL, parameter =>
         {
             parameter.Add(parameter.CreateParameter("Id", Convert.ToInt32(userAcount)));
         }));
     }
 }
Beispiel #22
0
 /// <summary>
 /// 通过物料编码获取相关信息
 /// </summary>
 /// <param name="materialNumber">物料编码</param>
 /// <param name="code">到货编号</param>
 /// <returns></returns>
 public List <InvoiceVerify> GetMaterialMaeeage(string materialNumber, string code)
 {
     using (StoreAccess access = new StoreAccess())
     {
         string strSQL = access.CommandFormate("SELECT * FROM [Table_InvoiceVerify] WHERE [InvoiceNumber] = {0}InvoiceNumber AND [MaterialNumber] = {0}MaterialNumber");
         return(access.ExcuteSelect <InvoiceVerify>(strSQL, parmater =>
         {
             parmater.Add(parmater.CreateParameter("InvoiceNumber", code));
             parmater.Add(parmater.CreateParameter("MaterialNumber", materialNumber));
         }));
     }
 }
Beispiel #23
0
        public MandatoryProperties(StoreAccess storeAccess)
        {
            this._storeAccess = storeAccess;
            SchemaStorage schemaStorage = new SchemaStorage(storeAccess.SchemaStore);

            foreach (ConstraintRule rule in ConstraintsIgnoringMalformed(schemaStorage))
            {
                if (rule.ConstraintDescriptor.enforcesPropertyExistence())
                {
                    rule.Schema().processWith(constraintRecorder);
                }
            }
        }
Beispiel #24
0
        public DataTable GetOutStoreMessage()
        {
            List <InStoreDetails> list  = new List <InStoreDetails>();
            DataTable             table = null;

            using (BaseAccess access = new BaseAccess())
            {
                string strSQL = "select distinct c.invcode 子件编码, a.mocode 订单号,d.cinvname 子件名称,d.cinvstd 子件规格, d.cInvDefine4 as 批次,e.ccomunitname 计量单位,sum(c.baseqtyN)as 基本用量,sum(c.qty)as 应领数量,d.cInvDefine4 as 库位,d.cInvDefine4 as 缺料量 from mom_order a,mom_orderdetail b, mom_moallocate c,INVENTORY d,computationunit e where a.moid=b.moid and b.modid=c.modid and c.invcode=d.cinvcode and d.ccomunitcode=e.ccomunitcode and a.MoCode ='A0000022373' group by c.invcode,a.mocode,d.cinvname,d.cinvstd,e.ccomunitname,d.iDrawBatch,d.cInvDefine4";
                table = access.ExcuteTable(strSQL);
            }
            using (StoreAccess access = new StoreAccess())
            {
                foreach (DataRow item in table.Rows)
                {
                    string strSQL = string.Format("SELECT * FROM [Table_InStoreDetails] WHERE [MaterialCode]= '{0}' ORDER BY Time ASC ", item["子件编码"]);
                    list = access.Select <InStoreDetails>(strSQL).Where(o => o.Count >= (decimal)item["应领数量"]).ToList <InStoreDetails>();
                    if (list.Count >= 1)
                    {
                        item["库位"]  = list[0].VirifyCode;
                        item["批次"]  = list[0].Batch;
                        item["缺料量"] = 0;
                    }
                    else
                    {
                        list = access.Select <InStoreDetails>(strSQL);
                        if (list.Count == 1)
                        {
                            item["库位"]  = list[0].VirifyCode;
                            item["批次"]  = list[0].Batch;
                            item["缺料量"] = (decimal)item["应领数量"] - list[0].Count;
                        }
                        else
                        {
                            for (int i = 0; i < list.Count; i++)
                            {
                                if (list[i].Count++ <= (decimal)item["应领数量"])
                                {
                                    item["库位"] += string.Concat(list[i].VirifyCode, ",");
                                    item["批次"] += string.Concat(list[i].Batch, ",");
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return(table);
        }
Beispiel #25
0
 internal ConsistencyCheckTasks(ProgressMonitorFactory.MultiPartBuilder multiPartBuilder, StoreProcessor defaultProcessor, StoreAccess nativeStores, Statistics statistics, CacheAccess cacheAccess, LabelScanStore labelScanStore, IndexAccessors indexes, TokenHolders tokenHolders, MultiPassStore.Factory multiPass, ConsistencyReporter reporter, int numberOfThreads)
 {
     this._multiPartBuilder = multiPartBuilder;
     this._defaultProcessor = defaultProcessor;
     this._nativeStores     = nativeStores;
     this._statistics       = statistics;
     this._cacheAccess      = cacheAccess;
     this._tokenHolders     = tokenHolders;
     this._multiPass        = multiPass;
     this._reporter         = reporter;
     this._labelScanStore   = labelScanStore;
     this._indexes          = indexes;
     this._numberOfThreads  = numberOfThreads;
 }
        public async Task ImportBookCommand_RaisesError_OnImportFail()
        {
            StoreAccess        storeAccess        = new StoreAccess();
            BookShareReference bookShareReference = new BookShareReference();
            BookShare          bookShare          = new BookShare();

            _bookShelfService.Setup(s => s.AddSharedBookToBookShelfAndSaveAsync(storeAccess, bookShareReference)).Returns(Task.FromResult(false)).Verifiable();
            _bookShareStoreService.Setup(s => s.LoadBookShareAsync(bookShareReference)).Returns(Task.FromResult(bookShare)).Verifiable();

            await _viewModel.InitAsync(storeAccess, bookShareReference);

            _eventAggregatorMock.Setup(s => s.GetEvent <ErrorMessage>()).Returns(new ErrorMessage()).Verifiable();
            _viewModel.ImportBookCommand.Execute();

            _eventAggregatorMock.Verify();
            _bookShareStoreService.Verify();
        }
        public void ExecuteSaveBookShare_SavesAndPublishesMessage()
        {
            BookReference      bookReference      = new BookReference();
            StoreAccess        storeAccess        = new StoreAccess();
            BookShareReference bookShareReference = new BookShareReference();

            _viewModel.ContributorName            = "Tim";
            _viewModel.BookName                   = "MyBook";
            _viewModel.AccessRights.CanAddEntries = true;

            _bookShelfServiceMock.Setup(s => s.ShareBookAsync(storeAccess, bookReference, _viewModel.ContributorName, _viewModel.AccessRights, _viewModel.BookName)).Returns(Task.FromResult(bookShareReference)).Verifiable();
            _eventAggregator.Setup(s => s.GetEvent <BookShareSavedMessage>()).Returns(new BookShareSavedMessage()).Verifiable();

            _viewModel.Init(storeAccess, bookReference);
            _viewModel.SaveBookShareCommand.Execute();

            _eventAggregator.Verify();
        }
Beispiel #28
0
        public async Task <IActionResult> SetStoreAccess(long id, StoreAccess access)
        {
            var user = await _userService.FindByIdAsync(id);

            if (user != null)
            {
                user.StoreAccess = access;
                await _userService.UpdateAsync(user);

                TempData.AddAlert(AlertMode.Notify, AlertType.Success, $"\"{user.StoreName}\" store access was mark as {user.StoreAccess.GetEnumText()}.");
            }
            else
            {
                TempData.AddAlert(AlertMode.Notify, AlertType.Error, $"User does not exist.");
            }

            return(RedirectToAction(nameof(Index)));
        }
        public void ExecuteSaveBookShare_RaisesError_IfBookShareCouldNotBeCreated()
        {
            BookReference      bookReference      = new BookReference();
            StoreAccess        storeAccess        = new StoreAccess();
            BookShareReference bookShareReference = new BookShareReference();

            _viewModel.ContributorName            = "Tim";
            _viewModel.BookName                   = "MyBook";
            _viewModel.AccessRights.CanAddEntries = true;

            _eventAggregator.Setup(s => s.GetEvent <ErrorMessage>()).Returns(new ErrorMessage()).Verifiable();
            _bookShelfServiceMock.Setup(s => s.ShareBookAsync(storeAccess, bookReference, _viewModel.ContributorName, _viewModel.AccessRights, _viewModel.BookName)).Throws(new BookShareCouldNotBeSavedException()).Verifiable();

            _viewModel.Init(storeAccess, bookReference);
            _viewModel.SaveBookShareCommand.Execute();

            _eventAggregator.Verify();
            _bookShelfServiceMock.Verify();
        }
Beispiel #30
0
        /// <summary>
        /// 保存到货数据
        /// </summary>
        /// <param name="invoice"></param>
        public int SaveDataToCaeche(List <InvoiceVerify> invoice)
        {
            int num = 0;

            using (StoreAccess access = new StoreAccess(true))
            {
                try
                {
                    access.Open();
                    access.BeginTransaction();
                    for (int i = 0; i < invoice.Count; i++)
                    {
                        num += access.Insert(invoice[i]);
                        //string strSQL = access.CommandFormate("INSERT INTO [Table_InvoiceVerify] ([InvoiceNumber],[SupplierCode],[Result],[MaterialNumber],[MaterialName],[Count],[Batch],[Barcode],[Time],[Iquantity]) VALUES ({0}InvoiceNumber,{0}SupplierCode,{0}Result,{0}MaterialNumber,{0}MaterialName,{0}Count,{0}Batch,{0}Barcode,{0}Time,{0}Iquantity)");
                        //access.Insert(strSQL, paramater =>
                        //{
                        //    paramater.Add(paramater.CreateParameter("Barcode", invoice[i].Barcode));
                        //    paramater.Add(paramater.CreateParameter("InvoiceNumber", invoice[i].InvoiceNumber));
                        //    paramater.Add(paramater.CreateParameter("SupplierCode", invoice[i].SupplierCode));
                        //    paramater.Add(paramater.CreateParameter("Result", invoice[i].Result));
                        //    paramater.Add(paramater.CreateParameter("MaterialNumber", invoice[i].MaterialNumber));
                        //    paramater.Add(paramater.CreateParameter("MaterialName", invoice[i].MaterialName));
                        //    paramater.Add(paramater.CreateParameter("Count", invoice[i].Count));
                        //    paramater.Add(paramater.CreateParameter("Batch", invoice[i].Batch));
                        //    paramater.Add(paramater.CreateParameter("Time", invoice[i].Time));
                        //    paramater.Add(paramater.CreateParameter("Iquantity", invoice[i].Iquantity));
                        //});
                    }
                    access.Commit();
                }
                catch (DbException ex)
                {
                    LogBusiness.RecordLog(userAcount, "保存到货数据异常" + ex.Message, "保存到货数据");
                    access.RollBack();
                    access.Close();
                    MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //throw;
                }
                return(num);
            }
        }