public virtual T Initialize <T> ( )
            where T : class
        {
            Guard.ArgumentNotNull(GattServiceUuid,
                                  nameof(GattServiceUuid));

            var(service, characteristicsResultWrapper) = Device.GattServices
                                                         .FirstOrDefault(x => x.Key.Uuid ==
                                                                         GattServiceUuid);

            if (service == null)
            {
                foreach (var service1 in Device.GattServices)
                {
                    Logger.Information($"Service: DeviceId = {service1.Key.DeviceId}, Uuid = {service1.Key.Uuid}");

                    foreach (var characteristic in service1.Value.Characteristics)
                    {
                        Logger.Information($"Characteristic: {characteristic.ServiceUuid} {characteristic.Uuid} {characteristic.UserDescription}");
                    }
                }
                throw new ArgumentException("Failed, can't find GattDeviceService for " +
                                            $"UUID {GattServiceUuid}",
                                            nameof(GattServiceUuid));
            }

            Logger.Information($"Found GattDeviceService with UUID {GattServiceUuid}");

            Characteristics = ProviderFactory.Create(characteristicsResultWrapper);

            WithMapping <T> ( );

            return(this as T);
        }
Exemple #2
0
        /// <summary>
        /// 卡片挂失
        /// </summary>
        /// <param name="info"></param>
        /// <param name="reason"></param>
        /// <param name="lostCardCost"></param>
        /// <param name="paymode"></param>
        /// <param name="keepParkingStatus">是否保持数据库中的卡片运行状态</param>
        public CommandResult CardLoss(CardInfo info, string reason, decimal lostCardCost, PaymentMode paymode, bool keepParkingStatus)
        {
            string                op       = OperatorInfo.CurrentOperator.OperatorName;
            string                station  = WorkStationInfo.CurrentStation.StationName;
            IUnitWork             unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            CardLostRestoreRecord record   = new CardLostRestoreRecord
            {
                CardID          = info.CardID,
                OwnerName       = info.OwnerName,
                CardCertificate = info.CardCertificate,
                CarPlate        = info.CarPlate,
                CardStatus      = (byte)info.Status, //保存卡片的原有卡状态
                LostDateTime    = DateTime.Now,
                LostOperator    = op,
                LostStation     = station,
                LostMemo        = reason,
                LostCardCost    = lostCardCost,
                PaymentMode     = paymode
            };
            ICardLostRestoreRecordProvider lostProvider = ProviderFactory.Create <ICardLostRestoreRecordProvider>(_RepoUri);

            info.Lost();
            lostProvider.Insert(record, unitWork);
            if (keepParkingStatus)
            {
                UpdateCard(info, unitWork);
            }
            else
            {
                UpdateCardAll(info, unitWork);
            }
            return(unitWork.Commit());
        }
Exemple #3
0
        /// <summary>
        /// 卡片解禁
        /// </summary>
        /// <param name="info"></param>
        /// <param name="reason"></param>
        /// <param name="keepParkingStatus">是否保持卡片运行状态</param>
        /// <returns></returns>
        public CommandResult CardEnable(CardInfo info, string reason, bool keepParkingStatus)
        {
            string    op                   = OperatorInfo.CurrentOperator.OperatorName;
            string    station              = WorkStationInfo.CurrentStation.StationName;
            IUnitWork unitWork             = ProviderFactory.Create <IUnitWork>(_RepoUri);
            CardDisableEnableRecord record = new CardDisableEnableRecord
            {
                CardID          = info.CardID,
                EnableDateTime  = DateTime.Now,
                EnableOperator  = op,
                EnableStationID = station,
                EnableMemo      = reason,
            };
            ICardDisableEnableRecordProvider recordProvider = ProviderFactory.Create <ICardDisableEnableRecordProvider>(_RepoUri);

            recordProvider.Insert(record, unitWork);
            info.Enable();
            if (keepParkingStatus)
            {
                UpdateCard(info, unitWork);
            }
            else
            {
                UpdateCardAll(info, unitWork);
            }
            return(unitWork.Commit());
        }
        public CommandResult AddReadLog(string deviceID, DateTime dt, decimal value)
        {
            var device = GetByID(deviceID).QueryObject;

            if (device != null)
            {
                var           provider = ProviderFactory.Create <IProvider <Device, string> >(RepoUri);
                IUnitWork     unitWork = provider.CreateUnitWork();
                DeviceReadLog log      = null;
                if (device.LastDate.HasValue && device.LastValue < value)
                {
                    log = new DeviceReadLog()
                    {
                        ID         = Guid.NewGuid(),
                        DeviceID   = device.ID,
                        DeviceName = device.Name,
                        DeviceType = device.DeviceType,
                        ReadDate   = dt,
                        ReadValue  = value,
                        LastDate   = device.LastDate.Value,
                        LastValue  = device.LastValue.Value,
                        Amount     = value - device.LastValue.Value
                    };
                    ProviderFactory.Create <IProvider <DeviceReadLog, Guid> >(RepoUri).Insert(log, unitWork);
                }
                var clone = device.Clone();
                clone.LastDate  = dt;
                clone.LastValue = log != null ? (clone.LastValue + log.Amount) : value; //记录设备上次的读数时以记录里实际扣除的数为准
                provider.Update(clone, device, unitWork);
                return(unitWork.Commit());
            }
            return(new CommandResult(ResultCode.Fail, "没有找到符合条件的设备"));
        }
Exemple #5
0
        /// <summary>
        /// 保存卡片以及嵌套车场进出事件
        /// </summary>
        /// <param name="card"></param>
        /// <param name="report"></param>
        /// <returns></returns>
        public CommandResult SaveCardAndNestedEvent(CardInfo card, CardEventReport report)
        {
            //内嵌车场事件只改变卡片的停车状态

            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            CardInfo  info     = card.Clone();

            //卡片状态保持用数据库中的状态
            info.ParkingStatus = report.ParkingStatus;
            if (!report.IsExitEvent)
            {
                info.LastNestParkDateTime = report.EventDateTime;                       //如果是入场事件,则更新卡片的最后进入内车场时间
            }
            _Provider.Update(info, card, unitWork);

            ICardEventProvider icp = ProviderFactory.Create <ICardEventProvider>(_RepoUri);

            if (report.IsExitEvent) //如果是入内车场,则不记录最后刷卡时间,如果是出内车场,则保存上次时间
            {
                report.LastDateTime = card.LastNestParkDateTime;
            }
            else
            {
                report.LastDateTime = null;
            }
            icp.Insert((new CardEventRecord(report)), unitWork);
            CommandResult ret = unitWork.Commit();

            if (ret.Result == ResultCode.Successful) //如果成功,则改变卡片状态
            {
                //卡片状态保持用数据库中的状态
                card.ParkingStatus = report.ParkingStatus;
            }
            return(ret);
        }
Exemple #6
0
        public CommandResult Register(string userWX, string publicWX, string studentID)
        {
            if (new StudentIDValidator().IsValid(studentID) == false)
            {
                return(new CommandResult(ResultCode.Fail, "学号格式不正确,只能包函字母或数字"));
            }
            var id       = WXBinding.CreateBindingID(userWX, publicWX);
            var original = GetByID(id).QueryObject;

            if (original == null)
            {
                WXBinding b = new WXBinding()
                {
                    ID = id, UserWX = userWX, PublicWX = publicWX, StudentID = studentID, UpdateDate = DateTime.Now
                };
                return(ProviderFactory.Create <IProvider <WXBinding, string> >(RepoUri).Insert(b));
            }
            else
            {
                WXBinding b = new WXBinding()
                {
                    ID = id, UserWX = userWX, PublicWX = publicWX, StudentID = studentID, UpdateDate = DateTime.Now
                };
                return(ProviderFactory.Create <IProvider <WXBinding, string> >(RepoUri).Update(b, original));
            }
        }
Exemple #7
0
        /// <summary>
        /// 获取某个客户收款单的金额分配明细
        /// </summary>
        /// <param name="paymentID"></param>
        /// <returns></returns>
        public QueryResultList <CustomerPaymentAssign> GetAssigns(string paymentID)
        {
            CustomerPaymentAssignSearchCondition con = new CustomerPaymentAssignSearchCondition();

            con.PaymentID = paymentID;
            return(ProviderFactory.Create <IProvider <CustomerPaymentAssign, Guid> >(RepoUri).GetItems(con));
        }
Exemple #8
0
        /// <summary>
        /// 下载附件
        /// </summary>
        /// <param name="header">要下载的附件头部</param>
        /// <param name="path">附件保存的路径</param>
        /// <returns></returns>
        public CommandResult Download(AttachmentHeader header, string path)
        {
            QueryResult <Attachment> ret = ProviderFactory.Create <IProvider <Attachment, Guid> >(_RepoUri).GetByID(header.ID);
            Attachment a = ret.QueryObject;

            if (a != null && a.Value != null)
            {
                try
                {
                    using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
                    {
                        fs.Write(a.Value, 0, a.Value.Length);
                    }
                    return(new CommandResult(ResultCode.Successful, "ok"));
                }
                catch (Exception ex)
                {
                    return(new CommandResult(ResultCode.Fail, ex.Message));
                }
            }
            else
            {
                return(new CommandResult(ret.Result, ret.Message));
            }
        }
        private void UpdateDatabase(IDbConnection connection, Plugin plugin)
        {
            var assembly = plugin.GetType().Assembly;

            logger.Info("update database: {0}", assembly.FullName);

            // todo: sql
            var provider = ProviderFactory.Create <SqlServerCeTransformationProvider>(connection, null);

            //var provider = ProviderFactory.Create<SqlServerTransformationProvider>(connection, null);

            using (var migrator = new Migrator(provider, assembly))
            {
                // запрещаем выполнять миграции, для которых не указано "пространство имен"
                if (migrator.AvailableMigrations.Any())
                {
                    var migrationsInfo = assembly.GetCustomAttribute <MigrationAssemblyAttribute>();

                    if (migrationsInfo == null || string.IsNullOrWhiteSpace(migrationsInfo.Key))
                    {
                        logger.Error("assembly {0} contains invalid migration info", assembly.FullName);
                    }
                }

                migrator.Migrate();
            }
        }
        public void TestCreateWithDefaultOptions()
        {
            AmqpProvider provider = ProviderFactory.Create(new Uri("amqp://localhost:5672")) as AmqpProvider;

            Assert.IsNotNull(provider);
            Assert.AreEqual(AmqpProvider.DEFAULT_MAX_HANDLE, provider.MaxHandle);
        }
Exemple #11
0
 /// <summary>
 /// 上传附件
 /// </summary>
 /// <param name="header">上传的附件头</param>
 /// <param name="path">附件所在的路径</param>
 /// <returns></returns>
 public CommandResult Upload(AttachmentHeader header, string path)
 {
     try
     {
         if (!File.Exists(path))
         {
             return(new CommandResult(ResultCode.Fail, string.Format("文件\"{0}\"不存在", path)));
         }
         byte[] bs = null;
         using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
         {
             if (fs.Length <= MAXFILENAME)
             {
                 bs          = new byte[fs.Length];
                 fs.Position = 0;
                 fs.Read(bs, 0, (int)fs.Length);
                 IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
                 ProviderFactory.Create <IProvider <AttachmentHeader, Guid> >(_RepoUri).Insert(header, unitWork); //插入附件头
                 Attachment a = new Attachment();
                 a.ID    = header.ID;
                 a.Value = bs;
                 ProviderFactory.Create <IProvider <Attachment, Guid> >(_RepoUri).Insert(a, unitWork); //插入附件内容
                 return(unitWork.Commit());
             }
             else
             {
                 return(new CommandResult(ResultCode.Fail, string.Format("文件\"{0}\" 太大,不能上传,如果要上传此文件,请先更改系统最大上传文件大小", path)));
             }
         }
     }
     catch (Exception ex)
     {
         return(new CommandResult(ResultCode.Fail, ex.Message));
     }
 }
        public void TestCreateWithOptions()
        {
            Uri configured = new Uri(baseUri +
                                     "?failover.initialReconnectDelay=" + (FailoverProvider.DEFAULT_INITIAL_RECONNECT_DELAY + 1) +
                                     "&failover.reconnectDelay=" + (FailoverProvider.DEFAULT_RECONNECT_DELAY + 2) +
                                     "&failover.maxReconnectDelay=" + (FailoverProvider.DEFAULT_MAX_RECONNECT_DELAY + 3) +
                                     "&failover.startupMaxReconnectAttempts=" + (FailoverProvider.DEFAULT_STARTUP_MAX_RECONNECT_ATTEMPTS + 4) +
                                     "&failover.maxReconnectAttempts=" + (FailoverProvider.DEFAULT_MAX_RECONNECT_ATTEMPTS + 5) +
                                     "&failover.warnAfterReconnectAttempts=" + (FailoverProvider.DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS + 6) +
                                     "&failover.useReconnectBackOff=" + (!FailoverProvider.DEFAULT_USE_RECONNECT_BACKOFF) +
                                     "&failover.reconnectBackOffMultiplier=" + (FailoverProvider.DEFAULT_RECONNECT_BACKOFF_MULTIPLIER + 1.0d));

            FailoverProvider failover = ProviderFactory.Create(configured) as FailoverProvider;

            Assert.IsNotNull(failover);

            Assert.AreEqual(FailoverProvider.DEFAULT_INITIAL_RECONNECT_DELAY + 1, failover.InitialReconnectDelay);
            Assert.AreEqual(FailoverProvider.DEFAULT_RECONNECT_DELAY + 2, failover.ReconnectDelay);
            Assert.AreEqual(FailoverProvider.DEFAULT_MAX_RECONNECT_DELAY + 3, failover.MaxReconnectDelay);
            Assert.AreEqual(FailoverProvider.DEFAULT_STARTUP_MAX_RECONNECT_ATTEMPTS + 4, failover.StartupMaxReconnectAttempts);
            Assert.AreEqual(FailoverProvider.DEFAULT_MAX_RECONNECT_ATTEMPTS + 5, failover.MaxReconnectAttempts);
            Assert.AreEqual(FailoverProvider.DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS + 6, failover.WarnAfterReconnectAttempts);
            Assert.AreEqual(!FailoverProvider.DEFAULT_USE_RECONNECT_BACKOFF, failover.UseReconnectBackOff);
            Assert.AreEqual(FailoverProvider.DEFAULT_RECONNECT_BACKOFF_MULTIPLIER + 1.0d, failover.ReconnectBackOffMultiplier, 0.0);
        }
        public void TestCreateMockProvider()
        {
            ProviderFactory.RegisterProviderFactory("mock", new MockProviderFactory());
            IProvider provider = ProviderFactory.Create(new Uri("mock://localhost:5000"));

            Assert.That(provider, Is.InstanceOf <MockProvider>());
        }
        public override CommandResult Add(InventoryCheckRecord info)
        {
            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);
            ProductInventorySearchCondition con = new ProductInventorySearchCondition();

            con.ProductID   = info.ProductID;
            con.WareHouseID = info.WarehouseID;
            List <ProductInventory> items = ProviderFactory.Create <IProvider <ProductInventory, Guid> >(RepoUri).GetItems(con).QueryObjects;

            if (items == null || items.Count == 0)
            {
                throw new Exception("没有该产品的库存项");
            }
            ProductInventory pi = items[0];

            if (info.Inventory != pi.Count)
            {
                throw new Exception("产品库存有改动,请重新操作");
            }
            if (info.CheckCount > pi.Count) //盘盈
            {
                InventoryIn(info, unitWork);
            }
            else if (info.CheckCount < pi.Count)  //盘亏
            {
                InventoryOut(info, UserSettings.Current.InventoryOutType, unitWork);
            }
            ProviderFactory.Create <IProvider <InventoryCheckRecord, Guid> >(RepoUri).Insert(info, unitWork);
            return(unitWork.Commit());
        }
 /// <summary>
 /// 上传本地数据服务类
 /// </summary>
 /// <param name="repoUri">本地数据库</param>
 /// <param name="databaseUri">上传到的数据库</param>
 public LDB_UpdateLoaclDataService(string repoUri, string databaseUri)
 {
     _Provider            = LDB_ProviderFactory.Create <LDB_ICardPaymentRecordProvider>(repoUri);
     _CardPaymentProvider = ProviderFactory.Create <ICardPaymentRecordProvider>(databaseUri);
     _DataBaseUri         = databaseUri;
     _UpdateInterval      = 5;
 }
        public string CreateADeptID(Department parent)
        {
            List <Department> depts    = ProviderFactory.Create <IDepartmentProvider>(_RepoUri).GetItems(null).QueryObjects;
            List <Department> children = null;

            if (parent == null)
            {
                children = depts.Where(item => string.IsNullOrEmpty(item.ParentID)).ToList();
            }
            else
            {
                children = depts.Where(item => item.ParentID == parent.ID).ToList();
            }
            string parentID = parent == null ? string.Empty : parent.ID;

            for (int i = 1; i < 100; i++)
            {
                string childID = parentID + i.ToString("D2");
                if (!children.Exists(item => item.ID == childID))
                {
                    return(childID);
                }
            }
            return(string.Empty);
        }
Exemple #17
0
        public CommandResult ShiftArrange(int staffID, DateTime dt, List <Shift> shifts)
        {
            IShiftArrangeProvider       provider = ProviderFactory.Create <IShiftArrangeProvider>(_RepoUri);
            ShiftArrangeSearchCondition con      = new ShiftArrangeSearchCondition();

            con.StaffID   = staffID;
            con.ShiftDate = new DatetimeRange(dt, dt);
            List <ShiftArrange> items    = provider.GetItems(con).QueryObjects;
            IUnitWork           unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            foreach (ShiftArrange item in items)
            {
                provider.Delete(item, unitWork);
            }
            if (shifts != null && shifts.Count > 0)
            {
                foreach (Shift item in shifts)
                {
                    ShiftArrange sa = new Model.ShiftArrange()
                    {
                        StaffID   = staffID,
                        ShiftID   = item.ID,
                        ShiftDate = dt
                    };
                    provider.Insert(sa, unitWork);
                }
            }
            return(unitWork.Commit());
        }
        public void UpdateOldStyleSchemaInfo()
        {
            // строка подключения
            string constr = ConfigurationManager.AppSettings["SqlServerConnectionString"];

            Require.IsNotNullOrEmpty(constr, "Connection string \"SqlServerConnectionString\" is not exist");


            // провайдер
            using (var provider = ProviderFactory.Create <SqlServerTransformationProvider>(constr))
            {
                if (provider.TableExists("SchemaInfo"))
                {
                    provider.RemoveTable("SchemaInfo");
                }

                // добавляем таблицу для версий, имеющую старую структуру
                provider.AddTable("SchemaInfo", new Column("Version", DbType.Int64, ColumnProperty.PrimaryKey));
                provider.Insert("SchemaInfo", new[] { "Version" }, new[] { "1" });

                Assert.AreEqual(1, provider.GetAppliedMigrations().Count);

                string sql = provider.FormatSql("SELECT {0:NAME}, {1:NAME} FROM {2:NAME}", "AssemblyKey", "Version", "SchemaInfo");
                using (IDataReader reader = provider.ExecuteReader(sql))
                {
                    Assert.IsTrue(reader.Read());
                    Assert.AreEqual(string.Empty, reader[0]);
                    Assert.AreEqual(1, Convert.ToInt32(reader[1]));
                    Assert.IsFalse(reader.Read());
                }

                provider.RemoveTable("SchemaInfo");
            }
        }
Exemple #19
0
        /// <summary>
        /// 获取服务器时间
        /// </summary>
        /// <returns></returns>
        protected virtual DateTime?GetServerDateTime()
        {
            DateTime?dt = null;

            ProviderFactory.Create <IServerDatetimeProvider>(RepoUri).GetServerDateTime(out dt);
            return(dt);
        }
Exemple #20
0
        /// <summary>
        /// 获取参数,如果不存在,返回空
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetParameter <T>() where T : class, new()
        {
            Parameter p = ProviderFactory.Create <IParameterProvider>(_RepoUri).GetByID(typeof(T).FullName).QueryObject;

            if (p == null || string.IsNullOrEmpty(p.Value))
            {
                return(null);
            }
            try
            {
                XmlSerializer ser = new XmlSerializer(typeof(T));
                using (StringReader sr = new StringReader(p.Value))
                {
                    object obj = ser.Deserialize(sr);
                    if (obj != null)
                    {
                        return(obj as T);
                    }
                }
            }
            catch (Exception ex)
            {
                LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }
            return(null);
        }
        /// <summary>
        /// 建立库存
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public CommandResult CreateInventory(ProductInventory info)
        {
            ProductInventorySearchCondition con = new ProductInventorySearchCondition()
            {
                ProductID = info.ProductID, WareHouseID = info.WareHouseID
            };
            List <ProductInventory> items = ProviderFactory.Create <IProvider <ProductInventory, Guid> >(RepoUri).GetItems(con).QueryObjects;

            if (items != null && items.Count > 0)
            {
                return(new CommandResult(ResultCode.Fail, "库存项已经存在,如果想要更新库库数量,请通过盘点或收货单收货"));
            }
            ProductInventoryItem pii = new ProductInventoryItem()
            {
                ID             = Guid.NewGuid(),
                ProductID      = info.ProductID,
                WareHouseID    = info.WareHouseID,
                Unit           = info.Unit,
                Price          = info.Amount / info.Count,
                Count          = info.Count,
                AddDate        = DateTime.Now,
                InventorySheet = "初始库存"
            };

            return(ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Insert(pii));
        }
        /// <summary>
        /// 增加考勤结果,此用户在此时间段内的所以考勤结果都清除,再写入新结果
        /// </summary>
        /// <param name="staffID"></param>
        /// <param name="range"></param>
        /// <param name="arranges"></param>
        /// <returns></returns>
        public CommandResult Add(int staffID, DatetimeRange range, List <AttendanceResult> arranges)
        {
            IAttendanceResultProvider            provider = ProviderFactory.Create <IAttendanceResultProvider>(_RepoUri);
            StaffAttendanceResultSearchCondition con      = new StaffAttendanceResultSearchCondition();

            con.Staff = new List <int>();
            con.Staff.Add(staffID);
            con.ShiftDate = range;
            List <AttendanceResult> items = provider.GetItems(con).QueryObjects;
            IUnitWork unitWork            = ProviderFactory.Create <IUnitWork>(_RepoUri);

            foreach (AttendanceResult item in items)
            {
                provider.Delete(item, unitWork);
            }
            if (arranges != null && arranges.Count > 0)
            {
                foreach (AttendanceResult item in arranges)
                {
                    if (item.AbsentItems != null && item.AbsentItems.Count > 0)
                    {
                        item.AbsentItems.ForEach(it => it.ResultID = item.ID);
                    }
                    provider.Insert(item, unitWork);
                }
            }
            return(unitWork.Commit());
        }
Exemple #23
0
 private void SyncCardEventThread()
 {
     ShowMessage("启动事件上传线程");
     while (true)
     {
         try
         {
             IECardRecordProvider provider = ProviderFactory.Create <IECardRecordProvider>(AppSettings.CurrentSetting.ParkConnect);
             List <ECardRecord>   records  = provider.GetAll().QueryObjects;
             if (records != null && records.Count > 0)
             {
                 foreach (ECardRecord record in records)
                 {
                     bool ret = SyncToECar(record);
                     provider.Delete(record);
                 }
             }
         }
         catch (Exception ex)
         {
             Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
         }
         Thread.Sleep(5000);
     }
 }
Exemple #24
0
        /// <summary>
        /// 获取某个人员的所有生物识别模板
        /// </summary>
        /// <param name="staffID"></param>
        /// <returns></returns>
        public QueryResultList <StaffBioTemplate> GetBioTemplates(int staffID)
        {
            StaffBioTemplateSearchCondition con = new StaffBioTemplateSearchCondition();

            con.StaffID = staffID;
            return(ProviderFactory.Create <IStaffBioTemplateProvider>(_RepoUri).GetItems(con));
        }
Exemple #25
0
 /// <summary>
 /// 删除卡片
 /// </summary>
 public CommandResult DeleteCard(CardInfo info)
 {
     if (info.Status == CardStatus.Enabled && !info.IsTempCard && !info.IsManagedCard)
     {
         throw new InvalidOperationException(Resource1.CardBll_CannotDelete);
     }
     else
     {
         string           op       = OperatorInfo.CurrentOperator.OperatorName;
         string           station  = WorkStationInfo.CurrentStation.StationName;
         IUnitWork        unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
         CardDeleteRecord record   = new CardDeleteRecord
         {
             CardID          = info.CardID,
             OwnerName       = info.OwnerName,
             CardCertificate = info.CardCertificate,
             CarPlate        = info.CarPlate,
             DeleteDateTime  = DateTime.Now,
             CardType        = info.CardType,
             Balance         = info.Balance,
             ValidDate       = info.ValidDate,
             Deposit         = info.Deposit,
             OperatorID      = op,
             StationID       = station
         };
         ICardDeleteRecordProvider icdp = ProviderFactory.Create <ICardDeleteRecordProvider>(_RepoUri);
         icdp.Insert(record, unitWork);
         _Provider.Delete(info, unitWork);
         return(unitWork.Commit());
     }
 }
Exemple #26
0
        public CommandResult DeletePhoto(int staffID)
        {
            StaffPhoto sp = new StaffPhoto();

            sp.StaffID = staffID;
            return(ProviderFactory.Create <IStaffPhotoProvider>(_RepoUri).Delete(sp));
        }
Exemple #27
0
        /// <summary>
        /// 卡片延期
        /// </summary>
        /// <param name="info"></param>
        /// <param name="newValidDate"></param>
        /// <param name="paymentMode"></param>
        /// <param name="money"></param>
        /// <param name="memo"></param>
        /// <param name="keepParkingStatus">是否保持卡片运行状态</param>
        /// <returns></returns>
        public CommandResult CardDefer(CardInfo info, DateTime newValidDate, PaymentMode paymentMode, decimal money, string memo, bool keepParkingStatus)
        {
            string          op       = OperatorInfo.CurrentOperator.OperatorName;
            string          station  = WorkStationInfo.CurrentStation.StationName;
            IUnitWork       unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            CardDeferRecord record   = new CardDeferRecord
            {
                CardID          = info.CardID,
                OwnerName       = info.OwnerName,
                CardCertificate = info.CardCertificate,
                CarPlate        = info.CarPlate,
                OriginalDate    = info.ValidDate,
                CurrentDate     = newValidDate,
                DeferDateTime   = DateTime.Now,
                PaymentMode     = paymentMode,
                DeferMoney      = money,
                OperatorID      = op,
                StationID       = station,
                Memo            = memo
            };
            ICardDeferRecordProvider recordProvider = ProviderFactory.Create <ICardDeferRecordProvider>(_RepoUri);

            recordProvider.Insert(record, unitWork);
            info.ValidDate = newValidDate;
            if (keepParkingStatus)
            {
                UpdateCard(info, unitWork);
            }
            else
            {
                //写卡模式以卡片运行状态为准
                UpdateCardAll(info, unitWork);
            }
            return(unitWork.Commit());
        }
Exemple #28
0
        /// <summary>
        /// 优惠券使用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="proxyID"></param>
        /// <returns></returns>
        public CommandResult AssignTo(string id, string proxyID)
        {
            YouhuiQuan item = GetByID(id).QueryObject;

            if (item == null)
            {
                return(new CommandResult(ResultCode.Fail, string.Format("ID={0} 的优惠券不存在", id)));
            }
            if (!string.IsNullOrEmpty(item.Proxy))
            {
                return(new CommandResult(ResultCode.Fail, string.Format("ID={0} 的优惠券已经被使用", id)));
            }
            CompanyInfo proxy = ProviderFactory.Create <IProvider <CompanyInfo, string> >(RepoUri).GetByID(proxyID).QueryObject;

            if (proxy == null)
            {
                return(new CommandResult(ResultCode.Fail, string.Format("ID={0} 的代理商不存在", proxyID)));
            }
            YouhuiQuan original = item.Clone();

            item.Proxy       = proxyID;
            item.ComsumeDate = DateTime.Now;
            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);

            ProviderFactory.Create <IProvider <YouhuiQuan, string> >(RepoUri).Update(item, original, unitWork);
            return(unitWork.Commit());
        }
Exemple #29
0
        /// <summary>
        /// 卡片回收
        /// </summary>
        /// <param name="info"></param>
        /// <param name="recycleMoney"></param>
        /// <param name="memo"></param>
        /// <param name="keepParkingStatus">是否保持卡片运行状态</param>
        /// <returns></returns>
        public CommandResult CardRecycle(CardInfo info, decimal recycleMoney, string memo, bool keepParkingStatus)
        {
            string            op       = OperatorInfo.CurrentOperator.OperatorName;
            string            station  = WorkStationInfo.CurrentStation.StationName;
            IUnitWork         unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            CardRecycleRecord record   = new CardRecycleRecord
            {
                CardID          = info.CardID,
                OwnerName       = info.OwnerName,
                CardCertificate = info.CardCertificate,
                CarPlate        = info.CarPlate,
                RecycleDateTime = DateTime.Now,
                CardType        = info.CardType,
                Balance         = info.Balance,
                ValidDate       = info.ValidDate,
                Deposit         = info.Deposit,
                RecycleMoney    = recycleMoney,
                OperatorID      = op,
                StationID       = station,
                Memo            = memo
            };
            ICardRecycleRecordProvider recordProvider = ProviderFactory.Create <ICardRecycleRecordProvider>(_RepoUri);

            recordProvider.Insert(record, unitWork);
            info.Recycle();
            if (keepParkingStatus)
            {
                UpdateCard(info, unitWork);
            }
            else
            {
                UpdateCardAll(info, unitWork);
            }
            return(unitWork.Commit());
        }
Exemple #30
0
        /// <summary>
        /// 取消客户收款和应收款已核销项
        /// </summary>
        /// <param name="assign"></param>
        /// <returns></returns>
        public CommandResult UndoAssign(CustomerPaymentAssign assign)
        {
            if (assign == null)
            {
                return(new CommandResult(ResultCode.Fail, "没有分配项"));
            }
            IUnitWork       unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);
            CustomerPayment cp       = ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).GetByID(assign.PaymentID).QueryObject;

            if (cp != null && cp.Assigned >= assign.Amount)
            {
                CustomerReceivable cr = ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).GetByID(assign.ReceivableID).QueryObject;
                if (cr != null && cr.Haspaid >= assign.Amount)
                {
                    CustomerPayment    cp1 = cp.Clone() as CustomerPayment;
                    CustomerReceivable cr1 = cr.Clone() as CustomerReceivable;
                    cp.Assigned -= assign.Amount;
                    cr.Haspaid  -= assign.Amount;
                    ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).Update(cp, cp1, unitWork);
                    ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Update(cr, cr1, unitWork);
                    ProviderFactory.Create <IProvider <CustomerPaymentAssign, Guid> >(RepoUri).Delete(assign, unitWork);
                }
            }
            return(unitWork.Commit());
        }