예제 #1
0
        public void Setup()
        {
            var dbFactory = new DbFactory();
            _dumpRepo = new Repository<DumpXml>(dbFactory);

            var patientSchema = InterviewReader.GetSchemaFromResources(typeof(XmlInterview).Assembly,
                                                                       XmlPatientsXSDResourcePath);
            _settings = InterviewReader.CreateSchemaSettings(patientSchema);
        }
        public void Setup()
        {
            // Normally I would trust the EF doing the right job
            // and I'll mock most these repositories

            var dbFactory = new DbFactory();
            _nokRepo = new Repository<NextOfKin>(dbFactory);
            _gpRepo  = new Repository<GpDetails>(dbFactory);
            _patientRepo = new PatientRepository(dbFactory, _gpRepo);
            _interviewRepository = new PatientInterviewRepository(dbFactory, _patientRepo);

            var patientSchema = InterviewReader.GetSchemaFromResources(typeof(XmlInterview).Assembly, XmlPatientsXSDResourcePath);
            var settings = InterviewReader.CreateSchemaSettings(patientSchema);

            XmlInterview interviews;
            using (var fileStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(XmlPatientsPath))
            {
                interviews = InterviewReader.DeserializeXmlInterview(fileStream, settings);
            }

            _xmlInterview = interviews.ToPatientInterview();
            _gpForTest = _xmlInterview.Patients.First().GpDetails;
            _interviewRepository.Save(_xmlInterview);
        }
예제 #3
0
 SqlSugarClient DbContext;//注入数据库操作类
 public SelectHelper(DbFactory factory)
 {
     DbContext = factory.GetDbContext();
 }
예제 #4
0
 public void SaveValidationRules(List <ValidateRule> validateRules)
 {
     using var db = DbFactory.OpenDbConnection();
     db.SaveAll(validateRules);
     ClearValidationSourceCache();
 }
 internal BuchungDataManager(DbFactory aDb)
 {
     this.mDb = aDb;
 }
예제 #6
0
 public void BeginTransaction()
 {
     m_Transaction = DbFactory.CreateDbTransaction();
 }
예제 #7
0
        /// <summary>
        /// 车辆出厂
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="Note"></param>
        /// <param name="type"></param>
        public void CarOut(string keyValue, string Note, int type, List <PersongpsEntity> pergps)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                List <CarUserFileImgEntity>       dellist   = new List <CarUserFileImgEntity>();//离场
                Repository <CarUserFileImgEntity> caruserdb = new Repository <CarUserFileImgEntity>(DbFactory.Base());
                if (type == 0)
                {//拜访车辆
                    Repository <VisitcarEntity> inlogdb = new Repository <VisitcarEntity>(DbFactory.Base());
                    VisitcarEntity old = inlogdb.FindEntity(keyValue);
                    //old.OutTime = DateTime.Now;
                    //old.State = 4;
                    old.Issubmit = 1;
                    old.Note     = Note;
                    old.Modify(old.ID);
                    Repository <PersongpsEntity> pgpsinlogdb = new Repository <PersongpsEntity>(DbFactory.Base());
                    List <PersongpsEntity>       pgps        = pgpsinlogdb.IQueryable(it => it.VID == keyValue && it.State == 0).ToList();
                    foreach (PersongpsEntity item in pergps)
                    {
                        if (item.UserName == "车辆" && item.State == 1)
                        {//车辆出厂但跟随人员部分未出厂
                            old.Issubmit = 2;
                            //List<PersongpsEntity> list = pgpsinlogdb.IQueryable(it => it.VID == keyValue && it.State == 0).ToList();
                            //if (list.Count == 0)
                            //{//子表所有人员都出厂修改主表出厂状态
                            //    old.OutTime = DateTime.Now;
                            //    old.State = 4;
                            //}
                        }
                        else
                        {//人员
                            PersongpsEntity entity = pgpsinlogdb.FindEntity(item.ID);
                            if (entity != null)
                            {
                                entity.Issubmit = 1;
                                entity.State    = item.State;
                                entity.Modify(item.ID);
                                if (item.State == 1)
                                {
                                    entity.OutTime = DateTime.Now;
                                    var carentity = caruserdb.IQueryable(it => it.Baseid == keyValue && it.Username == entity.UserName).ToList();
                                    dellist.AddRange(carentity);
                                }
                                pgps.Add(entity);
                            }
                        }
                        if (pergps.Where(t => t.State == 1).ToList().Count == pergps.Count)
                        {//子表所有人员都出厂修改主表出厂状态
                            old.OutTime = DateTime.Now;
                            old.State   = 4;
                        }
                    }
                    res.Update <VisitcarEntity>(old);
                    res.Update <PersongpsEntity>(pgps);
                }
                else if (type == 1)
                {
                    //将该车1小时内的打卡记录都变为已进场
                    Repository <OperticketmanagerEntity> inlogdb = new Repository <OperticketmanagerEntity>(DbFactory.Base());
                    OperticketmanagerEntity old = inlogdb.FindEntity(keyValue);
                    old.ExamineStatus = 4;
                    old.OutDate       = DateTime.Now;
                    old.PassRemark    = Note;
                    old.Modify(old.ID);
                    res.Update <OperticketmanagerEntity>(old);
                }
                else
                {//危化品车辆
                    //将该车1小时内的打卡记录都变为已进场
                    Repository <HazardouscarEntity> inlogdb = new Repository <HazardouscarEntity>(DbFactory.Base());
                    HazardouscarEntity old = inlogdb.FindEntity(keyValue);
                    //old.OutTime = DateTime.Now;
                    //old.State = 4;
                    old.Note     = Note;
                    old.Issubmit = 1;
                    old.Modify(old.ID);
                    Repository <PersongpsEntity> pgpsinlogdb = new Repository <PersongpsEntity>(DbFactory.Base());
                    List <PersongpsEntity>       pgps        = new List <PersongpsEntity>();
                    foreach (PersongpsEntity item in pergps)
                    {
                        if (item.UserName == "车辆" && item.State == 1)
                        {//车辆出厂但跟随人员部分未出厂
                            old.Issubmit = 2;
                        }
                        else
                        {//人员
                            PersongpsEntity entity = pgpsinlogdb.FindEntity(item.ID);
                            if (entity != null)
                            {
                                entity.Issubmit = 1;
                                entity.State    = item.State;
                                entity.Modify(item.ID);
                                if (item.State == 1)
                                {
                                    entity.OutTime = DateTime.Now;
                                    var carentity = caruserdb.IQueryable(it => it.Baseid == keyValue && it.Username == entity.UserName).ToList();
                                    dellist.AddRange(carentity);
                                }
                                pgps.Add(entity);
                            }
                        }
                        if (pergps.Where(t => t.State == 1).ToList().Count == pergps.Count)
                        {//子表所有人员都出厂修改主表出厂状态
                            old.OutTime = DateTime.Now;
                            old.State   = 4;
                        }
                    }
                    res.Update <HazardouscarEntity>(old);
                    res.Update <PersongpsEntity>(pgps);
                }
                Repository <CargpsEntity> cgpsinlogdb = new Repository <CargpsEntity>(DbFactory.Base());
                List <CargpsEntity>       cgps        = cgpsinlogdb.IQueryable(it => it.AID == keyValue && it.Status == 0).ToList();
                if (cgps.Count > 0)
                {
                    for (int i = 0; i < cgps.Count; i++)
                    {
                        cgps[i].Status  = 1;
                        cgps[i].EndTime = DateTime.Now;
                        cgps[i].Modify(cgps[i].ID);
                    }
                    res.Update <CargpsEntity>(cgps);
                }

                //车辆违章记录处理
                Repository <CarviolationEntity> violinlogdb = new Repository <CarviolationEntity>(DbFactory.Base());
                List <CarviolationEntity>       violation   = violinlogdb.IQueryable(it => it.CID == keyValue && it.IsProcess == 0).ToList();
                if (violation.Count > 0)
                {
                    for (int i = 0; i < violation.Count; i++)
                    {
                        violation[i].IsProcess      = 1;
                        violation[i].ProcessMeasure = Note;
                        violation[i].Modify(violation[i].ID);
                    }
                    res.Update <CarviolationEntity>(violation);
                }

                res.Commit();
                DeleteUserHiK(dellist, 1);
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
예제 #8
0
 public PageRepository(DbFactory dbFactory) : base(dbFactory)
 {
 }
예제 #9
0
 public UnitOfWork()
 {
     _context = DbFactory.GetCurrentDbContext();
 }
예제 #10
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, VisitcarEntity entity)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         Repository <CarUserFileImgEntity> caruserdb = new Repository <CarUserFileImgEntity>(DbFactory.Base());
         List <CarUserFileImgEntity>       list      = caruserdb.IQueryable(it => it.Baseid == keyValue).ToList();
         entity.Modify(keyValue);
         this.BaseRepository().Update(entity);
         //if (entity.State == 3)
         //{//审批通过 (下发入场权限)
         //    DataItemDetailService data = new DataItemDetailService();
         //    var pitem = data.GetItemValue("Hikappkey");
         //    var baseurl = data.GetItemValue("HikBaseUrl");
         //    string Key = string.Empty;
         //    string Signature = string.Empty;
         //    if (!string.IsNullOrEmpty(pitem))
         //    {
         //        Key = pitem.Split('|')[0];
         //        Signature = pitem.Split('|')[1];
         //    }
         //    UploadUserlimits(list, baseurl, Key, Signature);
         //}
         if (entity.State == 99)
         {//拒绝入场(删除海康平台对于用户)
             DeleteUserHiK(list);
         }
     }
     else
     {
         SaveUserFileImgForm(entity);
     }
 }
예제 #11
0
 public void InitSchema()
 {
     using var db = DbFactory.OpenDbConnection();
     db.CreateTableIfNotExists <ValidateRule>();
 }
예제 #12
0
        /// <summary>
        /// 根据当前部门id获取层级显示部门
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public string GetDeptName(string deptid)
        {
            try
            {
                Repository <DepartmentEntity> deptdb = new Repository <DepartmentEntity>(DbFactory.Base());
                string           deptsql             = string.Format("select * from base_Department  where departmentid ='{0}' ", deptid);
                DepartmentEntity dept     = deptdb.FindList(deptsql).FirstOrDefault();
                string           deptname = "";
                bool             flag     = true;
                while (dept != null && flag)
                {
                    if (deptname == "")
                    {
                        deptname = dept.FullName;
                    }
                    else
                    {
                        deptname = dept.FullName + "|" + deptname;
                    }

                    if (dept.Nature == "班组" || dept.Nature == "专业")
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = false;
                    }

                    Repository <DepartmentEntity> Newdeptdb = new Repository <DepartmentEntity>(DbFactory.Base());
                    string newsql = string.Format("select * from base_Department  where departmentid ='{0}' ",
                                                  dept.ParentId);
                    dept = Newdeptdb.FindList(newsql).FirstOrDefault();
                }

                return(deptname);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
예제 #13
0
 /// <summary>
 /// 设置仓储服务
 /// </summary>
 /// <param name="conString">参数</param>
 /// <param name="dbType">数据库类型</param>
 /// <param name="entityNamespace">命名空间</param>
 private void SetService(string conString, DatabaseType?dbType, string entityNamespace)
 {
     Service = DbFactory.GetRepository(conString, dbType, entityNamespace);
 }
예제 #14
0
        protected override void RunCallback()
        {
            CompanyDTO company   = null;
            var        dbFactory = new DbFactory();
            var        time      = new TimeService(dbFactory);
            var        log       = GetLogger();

            var now = time.GetAppNowTime();

            if (!time.IsBusinessDay(now))
            {
                return;
            }

            using (var db = dbFactory.GetRDb())
            {
                company = db.Companies.GetByIdWithSettingsAsDto(CompanyId);
            }

            var fromAddressList = new CompanyAddressService(company);
            var serviceFactory  = new ServiceFactory();
            var pdfMaker        = new PdfMakerByIText(GetLogger());
            var actionService   = new SystemActionService(log, time);
            var addressService  = new AddressService(null,
                                                     fromAddressList.GetReturnAddress(MarketIdentifier.Empty()),
                                                     fromAddressList.GetPickupAddress(MarketIdentifier.Empty()));
            var emailSmtpSettings   = SettingsBuilder.GetSmtpSettingsFromCompany(company, AppSettings.IsDebug, AppSettings.IsSampleLabels);
            var emailService        = new EmailService(GetLogger(), emailSmtpSettings, addressService);
            var weigthService       = new WeightService();
            var orderHistoryService = new OrderHistoryService(log, time, dbFactory);
            var batchManager        = new BatchManager(log, time, orderHistoryService, weigthService);

            var labelBatchService = new LabelBatchService(dbFactory,
                                                          actionService,
                                                          log,
                                                          time,
                                                          weigthService,
                                                          serviceFactory,
                                                          emailService,
                                                          batchManager,
                                                          pdfMaker,
                                                          addressService,
                                                          orderHistoryService,
                                                          AppSettings.DefaultCustomType,
                                                          AppSettings.LabelDirectory,
                                                          AppSettings.ReserveDirectory,
                                                          AppSettings.TemplateDirectory,
                                                          new LabelBatchService.Config()
            {
                PrintErrorsToEmails = new[] { company.SellerEmail, company.SellerWarehouseEmailAddress },
                PrintErrorsCCEmails = new[] { EmailHelper.RaananEmail, EmailHelper.SupportDgtexEmail },
            },
                                                          AppSettings.IsSampleLabels);


            var autoPurchaseService = new LabelAutoBuyService(dbFactory,
                                                              log,
                                                              time,
                                                              batchManager,
                                                              labelBatchService,
                                                              actionService,
                                                              emailService,
                                                              weigthService,
                                                              company.Id);

            autoPurchaseService.PurchaseForSameDay();
        }
예제 #15
0
 public BaseService(ILogger <T> logger, IOptions <AppSettings> appSettings)
 {
     AppSettings = appSettings.Value;
     DbFactory   = new DbFactory <T>(logger, appSettings);
 }
예제 #16
0
 public StaticRepository(DbFactory dbFactory, ContextFactory contextFactory)
 {
     DbFactory      = dbFactory;
     ContextFactory = contextFactory;
     EfUnitOfWork   = new StaticUnitOfWork <TEntity>(contextFactory, dbFactory);
 }
예제 #17
0
 /// <summary>
 /// 定义仓储(基础库)
 /// </summary>
 /// <returns></returns>
 public IRepository BaseRepository()
 {
     return(new Repository(DbFactory.GetIDatabase()));
 }
예제 #18
0
 public CommentItemViewComponent(DbFactory dbFactory, ZanService zanService)
 {
     this.dbFactory  = dbFactory ?? throw new ArgumentNullException(nameof(dbFactory));
     this.zanService = zanService ?? throw new ArgumentNullException(nameof(zanService));
 }
예제 #19
0
 public void DeleteValidationRules(params int[] ids)
 {
     using var db = DbFactory.OpenDbConnection();
     db.DeleteByIds <ValidateRule>(ids);
     ClearValidationSourceCache();
 }
예제 #20
0
        /// <summary>
        /// 初始化拜访\危化品\物料车辆
        /// </summary>
        /// <returns></returns>
        public List <CarAlgorithmEntity> IniVHOCar()
        {
            //将该车1小时内的打卡记录都变为已进场
            Repository <CarAlgorithmEntity> inlogdb = new Repository <CarAlgorithmEntity>(DbFactory.Base());
            string sql = string.Format(
                "select * from (select ID,carno,gpsid,gpsname,linename,'3' as type,'0' as State,'' as GoodsName from bis_visitcar where state='3'" +
                "union all" +
                " select ID,carno,gpsid,gpsname,HazardousName as linename,'5' as type,'0' as State,'' as GoodsName from bis_hazardouscar where state='3')");
            List <CarAlgorithmEntity>            CarList = inlogdb.FindList(sql).ToList();
            Repository <OperticketmanagerEntity> wldb    = new Repository <OperticketmanagerEntity>(DbFactory.Base());
            List <OperticketmanagerEntity>       wllist  = wldb.IQueryable(it => it.ExamineStatus == 3).ToList();

            if (wllist.Count > 0)
            {
                foreach (var op in wllist)
                {
                    CarAlgorithmEntity Car = new CarAlgorithmEntity();
                    Car.CarNo   = op.Platenumber;
                    Car.GPSID   = op.GpsId;
                    Car.GPSName = op.GpsName;
                    Car.ID      = op.ID;
                    Car.State   = 0;
                    Car.Type    = 4;
                    string Dress = op.Dress;
                    Car.GoodsName = Dress;
                    int    ISwharf       = op.ISwharf;
                    string Transporttype = op.Transporttype;
                    if (Transporttype == "提货")
                    {
                        Car.LineName = op.Dress + Transporttype;
                        if (ISwharf == 1)
                        {
                            Car.LineName += "(码头)";
                        }
                    }
                    else
                    {
                        if (ISwharf == 1)
                        {
                            Car.LineName = "物料转运(码头)";
                        }
                        else
                        {
                            Car.LineName = "转运(纯称重)";
                        }
                    }
                    CarList.Add(Car);
                }
            }

            return(CarList);
        }
예제 #21
0
 public void Clear()
 {
     using var db = DbFactory.OpenDbConnection();
     db.DeleteAll <ValidateRule>();
     Cache?.RemoveByPattern(nameof(IValidationSource) + ".*");
 }
예제 #22
0
        /// <summary>
        /// 改变GPS绑定信息
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        /// <param name="pgpslist"></param>
        public void ChangeGps(string keyValue, VisitcarEntity entity, List <PersongpsEntity> pgpslist)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                //将该车1小时内的打卡记录都变为已进场
                Repository <VisitcarEntity> inlogdb = new Repository <VisitcarEntity>(DbFactory.Base());
                VisitcarEntity old      = inlogdb.FindEntity(keyValue);
                bool           isupdate = false;//是否修改
                if (old.GPSID != entity.GPSID)
                {
                    isupdate = true;
                }
                old.GPSID   = entity.GPSID;
                old.GPSNAME = entity.GPSNAME;
                old.Modify(keyValue);
                if (old.State == 1)
                {
                    old.State = 2;
                    if (pgpslist != null)
                    {
                        for (int i = 0; i < pgpslist.Count; i++)
                        {
                            pgpslist[i].InTime   = DateTime.Now;
                            pgpslist[i].State    = 0;
                            pgpslist[i].Type     = 0;
                            pgpslist[i].VID      = old.ID;
                            pgpslist[i].UserName = pgpslist[i].UserName.Substring(0, pgpslist[i].UserName.IndexOf(':'));
                            pgpslist[i].Create();
                        }
                        res.Insert <PersongpsEntity>(pgpslist);
                    }

                    CargpsEntity cgps = new CargpsEntity();
                    cgps.AID     = old.ID;
                    cgps.CarNo   = old.CarNo;
                    cgps.GpsId   = old.GPSID;
                    cgps.GpsName = old.GPSNAME;
                    cgps.Status  = 0;
                    cgps.Type    = 1;
                    cgps.Create();

                    res.Insert <CargpsEntity>(cgps);
                }
                else
                {
                    string sql = "";
                    if (pgpslist != null)
                    {
                        for (int i = 0; i < pgpslist.Count; i++)
                        {
                            sql += "update bis_persongps set gpsid='" + pgpslist[i].GPSID + "' , gpsname='" +
                                   pgpslist[i].GPSNAME + "' where id='" + pgpslist[i].ID + "'";
                            res.ExecuteBySql(sql);
                        }
                    }

                    if (isupdate)
                    {
                        Repository <CargpsEntity> Carinlogdb = new Repository <CargpsEntity>(DbFactory.Base());
                        CargpsEntity Car = Carinlogdb.IQueryable(it => it.AID == old.ID && it.Status == 0).FirstOrDefault();
                        Car.GpsId   = old.GPSID;
                        Car.GpsName = old.GPSNAME;
                        Car.Modify(Car.ID);
                        res.Update <CargpsEntity>(Car);
                    }
                }
                res.Update <VisitcarEntity>(old);
                res.Commit();
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
예제 #23
0
 public void RemoveItemForm(string keyValue)
 {
     DbFactory.Base().Delete <CheckItemsEntity>(keyValue);
 }
예제 #24
0
        /// <summary>
        /// 改变GPS绑定信息
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        /// <param name="pgpslist"></param>
        public void WlChangeGps(string keyValue, OperticketmanagerEntity entity)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                //将该车1小时内的打卡记录都变为已进场
                Repository <OperticketmanagerEntity> inlogdb = new Repository <OperticketmanagerEntity>(DbFactory.Base());
                OperticketmanagerEntity old = inlogdb.FindEntity(keyValue);
                bool isupdate = false;//是否修改
                if (old.GpsId != entity.GpsId)
                {
                    isupdate = true;
                }
                old.GpsId   = entity.GpsId;
                old.GpsName = entity.GpsName;
                old.Modify(keyValue);
                if (old.ExamineStatus == 1)
                {
                    old.ExamineStatus = 2;


                    CargpsEntity cgps = new CargpsEntity();
                    cgps.AID     = old.ID;
                    cgps.CarNo   = old.Platenumber;
                    cgps.GpsId   = old.GpsId;
                    cgps.GpsName = old.GpsName;
                    cgps.Status  = 0;
                    cgps.Type    = 1;
                    cgps.Create();
                    res.Insert <CargpsEntity>(cgps);
                }
                else
                {
                    if (isupdate)
                    {
                        Repository <CargpsEntity> Carinlogdb = new Repository <CargpsEntity>(DbFactory.Base());
                        CargpsEntity Car = Carinlogdb.IQueryable(it => it.AID == old.ID && it.Status == 0).FirstOrDefault();
                        Car.GpsId   = old.GpsId;
                        Car.GpsName = old.GpsName;
                        Car.Modify(Car.ID);
                        res.Update <CargpsEntity>(Car);
                    }
                }
                res.Update <OperticketmanagerEntity>(old);
                res.Commit();
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
예제 #25
0
 public CheckItemsEntity GetItemEntity(string keyValue)
 {
     return(DbFactory.Base().FindEntity <CheckItemsEntity>(keyValue));
 }
예제 #26
0
 protected IDbConnection GetConnection()
 {
     return(DbFactory.Open());
 }
예제 #27
0
        /// <summary>
        /// 审核订单
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public int Audit(PurchaseOrderEntity order)
        {
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            try
            {
                PurchaseOrderEntity purchaseOrder = DataFactory.Database().FindEntity <PurchaseOrderEntity>(order.OrderId);
                if (purchaseOrder == null)
                {
                    throw new Exception("采购单不存在");
                }

                StringBuilder strSql = new StringBuilder();
                strSql.Append(@"UPDATE dbo.PurchaseOrder
                            SET Status = 1, ModifyUserId = @ModifyUserId,
                                ModifyUserName = @ModifyUserName, ModifyDate = @ModifyDate
                            WHERE OrderId = @OrderId
                                AND Status = 0");
                List <DbParameter> parameter = new List <DbParameter>();
                parameter.Add(DbFactory.CreateDbParameter("@ModifyUserId", order.ModifyUserId));
                parameter.Add(DbFactory.CreateDbParameter("@ModifyUserName", order.ModifyUserName));
                parameter.Add(DbFactory.CreateDbParameter("@ModifyDate", order.ModifyDate));
                parameter.Add(DbFactory.CreateDbParameter("@OrderId", order.OrderId));
                int result = database.ExecuteBySql(strSql, parameter.ToArray(), isOpenTrans);
                if (result > 0)
                {
                    string userId = ManageProvider.Provider.Current().UserId;

                    ReceiptEntity entity = new ReceiptEntity();
                    entity.ReceiptId   = CommonHelper.GetGuid;
                    entity.ReceiptNo   = _codeRuleBLL.GetBillCode(userId, "Receipt");
                    entity.ReceiptDate = purchaseOrder.OrderDate;
                    entity.ReceiptType = 1;
                    entity.WarehouseId = purchaseOrder.WarehouseId;
                    entity.MerchantId  = purchaseOrder.MerchantId;
                    entity.SourceNo    = purchaseOrder.OrderNo;
                    entity.Status      = 0;
                    entity.Create();

                    database.Insert(entity, isOpenTrans);

                    List <PurchaseOrderItemEntity> orderItemList = GetOrderItemList(order.OrderId);

                    foreach (PurchaseOrderItemEntity item in orderItemList)
                    {
                        var orderItem = new ReceiptItemEntity();
                        orderItem.Create();
                        orderItem.ReceiptId   = entity.ReceiptId;
                        orderItem.ProductId   = item.ProductId;
                        orderItem.Code        = item.Code;
                        orderItem.ProductName = item.ProductName;
                        orderItem.Qty         = item.Qty;
                        database.Insert(orderItem, isOpenTrans);
                    }
                }
                database.Commit();
                return(result);
            }
            catch
            {
                database.Rollback();
                return(-1);
            }
        }
예제 #28
0
 public ModifyRoleInfo()
 {
     repository = DbFactory.Repository <RoleInfoRepository>(false);
 }
예제 #29
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, TransferEntity entity)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                Repository <UserEntity> inlogdb = new Repository <UserEntity>(DbFactory.Base());
                string     sql  = string.Format("select * from base_user  where userid ='{0}' ", entity.UserId);
                UserEntity user = inlogdb.FindList(sql).FirstOrDefault();
                Repository <DepartmentEntity> deptdb = new Repository <DepartmentEntity>(DbFactory.Base());
                string           deptsql             = string.Format("select * from base_Department  where departmentid ='{0}' ", entity.OutDeptId);
                DepartmentEntity dept = deptdb.FindList(deptsql).FirstOrDefault();

                if (entity.IsConfirm == 0 || keyValue != "")
                {
                    if (keyValue == "")
                    {
                        entity.Create();
                        entity.OutDeptCode    = dept.EnCode;
                        entity.CreateUserName = OperatorProvider.Provider.Current().UserName;
                        res.Insert <TransferEntity>(entity);
                    }
                    else
                    {
                        entity.Modify(keyValue);
                        //confirm为2的时候表示已完成
                        entity.IsConfirm = 2;
                        res.Update <TransferEntity>(entity);
                    }

                    //根据部门id获取所属机构Code
                    Repository <DepartmentEntity> organdb = new Repository <DepartmentEntity>(DbFactory.Base());
                    string organsql = string.Format("select * from base_department  where   departmentid='{0}' ",
                                                    dept.OrganizeId);
                    DepartmentEntity organ = organdb.FindList(organsql).FirstOrDefault();
                    user.OrganizeCode = organ.EnCode;


                    if (entity.OutJobId != null && entity.OutJobId != "")
                    {
                        string postcode = "";
                        Repository <RoleEntity> postdb = new Repository <RoleEntity>(DbFactory.Base());
                        string postsql = string.Format("select * from base_role where category=3 ");
                        IEnumerable <RoleEntity> rlist = postdb.FindList(postsql);
                        string[] Postids = entity.OutJobId.Split(',');
                        for (int i = 0; i < Postids.Length; i++)
                        {
                            RoleEntity ro = rlist.Where(it => it.RoleId == Postids[i]).FirstOrDefault();
                            if (ro != null)
                            {
                                if (postcode == "")
                                {
                                    postcode = ro.EnCode;
                                }
                                else
                                {
                                    postcode += "," + ro.EnCode;
                                }
                            }
                        }

                        user.PostCode = postcode;
                        user.PostName = entity.OutJobName;
                        user.PostId   = entity.OutJobId;
                    }
                    else
                    {
                        user.PostCode = "";
                        user.PostName = "";
                        user.PostId   = "";
                    }

                    //如果不需要确认 则直接修改用户的部门 岗位 职务信息

                    user.DutyId         = entity.OutPostId;
                    user.DutyName       = entity.OutPostName;
                    user.DepartmentId   = entity.OutDeptId;
                    user.DepartmentCode = dept.EnCode;

                    #region 给转岗用户赋默认角色
                    string roleName = "";
                    string roleId   = "";
                    Repository <RoleEntity> roledb = new Repository <RoleEntity>(DbFactory.Base());
                    //如果选择的是厂级部门的话,角色会默认追加“厂级部门用户”
                    if (!(string.IsNullOrEmpty(user.DepartmentId) || user.DepartmentId == "undefined"))
                    {
                        Repository <DepartmentEntity> roledeptandb = new Repository <DepartmentEntity>(DbFactory.Base());
                        if (roledeptandb.FindEntity(user.DepartmentId).IsOrg == 1)
                        {
                            roleName += "厂级部门用户,";


                            var expression = LinqExtensions.True <RoleEntity>();
                            expression = expression.And(t => t.Category == 1).And(t => t.EnabledMark == 1).And(t => t.DeleteMark == 0);
                            RoleEntity cj = roledb.IQueryable(expression).OrderByDescending(t => t.CreateDate).ToList().Where(a => a.FullName == "厂级部门用户").FirstOrDefault();
                            if (cj != null)
                            {
                                roleId += cj.RoleId + ",";
                            }
                        }
                    }


                    var expression1 = LinqExtensions.True <RoleEntity>();
                    expression1 = expression1.And(t => t.Category == 2).And(t => t.EnabledMark == 1).And(t => t.DeleteMark == 0);
                    IEnumerable <RoleEntity> role = roledb.IQueryable(expression1).OrderByDescending(t => t.CreateDate).ToList().Where(a => a.RoleId == user.DutyId);
                    RoleEntity roleentity         = role.FirstOrDefault();
                    if (roleentity != null)
                    {
                        roleName += roleentity.RoleNames;
                        roleId   += roleentity.RoleIds;
                    }
                    user.RoleId   = roleId;
                    user.RoleName = roleName;
                    #endregion

                    #region 默认添加 角色、岗位、职位
                    res.Delete <UserRelationEntity>(t => t.IsDefault == 1 && t.UserId == user.UserId);
                    List <UserRelationEntity> userRelationEntitys = new List <UserRelationEntity>();
                    var    currUser = OperatorProvider.Provider.Current();
                    string uid      = currUser == null ? "" : currUser.UserId;
                    string uname    = currUser == null ? "" : currUser.UserName;
                    //用户
                    userRelationEntitys.Add(new UserRelationEntity
                    {
                        Category       = 6,
                        UserRelationId = Guid.NewGuid().ToString(),
                        UserId         = user.UserId,
                        ObjectId       = user.UserId,
                        CreateDate     = DateTime.Now,
                        CreateUserId   = uid,
                        CreateUserName = uname,
                        IsDefault      = 1,
                    });
                    //角色
                    string[] arr = user.RoleId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string item in arr)
                    {
                        userRelationEntitys.Add(new UserRelationEntity
                        {
                            Category       = 2,
                            UserRelationId = Guid.NewGuid().ToString(),
                            UserId         = user.UserId,
                            ObjectId       = item,
                            CreateDate     = DateTime.Now,
                            CreateUserId   = uid,
                            CreateUserName = uname,
                            IsDefault      = 1,
                        });
                    }
                    //岗位
                    if (!string.IsNullOrEmpty(user.DutyId))
                    {
                        userRelationEntitys.Add(new UserRelationEntity
                        {
                            Category       = 3,
                            UserRelationId = Guid.NewGuid().ToString(),
                            UserId         = user.UserId,
                            ObjectId       = user.DutyId,
                            CreateDate     = DateTime.Now,
                            CreateUserId   = uid,
                            CreateUserName = uname,
                            IsDefault      = 1,
                        });
                    }
                    //职位
                    if (!string.IsNullOrEmpty(user.PostId))
                    {
                        userRelationEntitys.Add(new UserRelationEntity
                        {
                            Category       = 4,
                            UserRelationId = Guid.NewGuid().ToString(),
                            UserId         = user.UserId,
                            ObjectId       = user.PostId,
                            CreateDate     = DateTime.Now,
                            CreateUserId   = uid,
                            CreateUserName = uname,
                            IsDefault      = 1,
                        });
                    }
                    res.Insert <UserRelationEntity>(userRelationEntitys);
                    #endregion


                    user.OrganizeId = dept.OrganizeId;
                    user.IsTransfer = 0;
                    //转岗完成将记录加入到记录表中
                    Repository <WorkRecordEntity> workdb = new Repository <WorkRecordEntity>(DbFactory.Base());
                    //找到之前没有结尾的工作记录填写结束时间
                    string Worksql = string.Format("update BIS_WORKRECORD set leavetime=to_date('{2}','yyyy-mm-dd hh24:mi:ss') where id=(select id  from (select id from BIS_WORKRECORD t where userid='{0}' and deptid='{1}'  and WorkType=1 and LeaveTime =to_date('0001-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss')  order by createdate desc) a where rownum=1) ", user.UserId, entity.InDeptId, entity.TransferTime);
                    res.ExecuteBySql(Worksql);

                    #region 如果是班组将部门名称转换成 部门/班组
                    Repository <DepartmentEntity> deptdb1 = new Repository <DepartmentEntity>(DbFactory.Base());
                    string           deptsql1             = string.Format("select * from base_Department  where departmentid ='{0}' ", entity.OutDeptId);
                    DepartmentEntity dept1    = deptdb1.FindList(deptsql1).FirstOrDefault();
                    string           DeptName = "";
                    bool             flag     = true;
                    while (dept1 != null && flag)
                    {
                        if (DeptName == null || DeptName == "")
                        {
                            DeptName = dept1.FullName;
                        }
                        else
                        {
                            if (dept1.FullName != DeptName)//班组同步过来的信息会本身会有名称 会出现xx|xx重复数据
                            {
                                DeptName = dept1.FullName + "|" + DeptName;
                            }
                        }

                        if (dept1.Nature == "班组" || dept1.Nature == "专业")
                        {
                            flag = true;
                        }
                        else
                        {
                            flag = false;
                        }

                        Repository <DepartmentEntity> Newdeptdb = new Repository <DepartmentEntity>(DbFactory.Base());
                        string newsql = string.Format("select * from base_Department  where departmentid ='{0}' ", dept1.ParentId);
                        dept1 = Newdeptdb.FindList(newsql).FirstOrDefault();
                    }
                    #endregion
                    //新增一条新的岗位记录
                    WorkRecordEntity workEntity = new WorkRecordEntity
                    {
                        Id           = Guid.NewGuid().ToString(),
                        DeptCode     = user.DepartmentCode,
                        DeptId       = user.DepartmentId,
                        EnterDate    = Convert.ToDateTime(entity.TransferTime),
                        UserId       = user.UserId,
                        UserName     = user.RealName,
                        DeptName     = DeptName,
                        PostName     = user.DutyName,
                        CreateDate   = DateTime.Now,
                        CreateUserId = OperatorProvider.Provider.Current().UserId,
                        OrganizeName = organ.FullName,
                        JobName      = user.PostName,
                        WorkType     = 1
                    };
                    res.Insert <WorkRecordEntity>(workEntity);
                }
                else
                {
                    entity.Create();
                    entity.OutDeptCode    = dept.EnCode;
                    entity.CreateUserName = OperatorProvider.Provider.Current().UserName;
                    res.Insert <TransferEntity>(entity);
                    //如果需要确认则修改用户状态
                    user.IsTransfer = 1;
                }
                if (!string.IsNullOrEmpty(user.DepartmentId))
                {
                    DepartmentEntity depart = new BaseManage.DepartmentService().GetEntity(user.DepartmentId);
                    if (depart != null)
                    {
                        //重新处理承包商级用户关联的部门信息
                        if (depart.Nature == "承包商")
                        {
                            sql = string.Format("select d.departmentid,d.encode from BASE_DEPARTMENT d where d.parentid=(select t.departmentid from BASE_DEPARTMENT t where t.organizeid='{0}' and t.description='外包工程承包商') and instr('{1}',d.encode)>0", user.OrganizeId, depart.EnCode);
                            DataTable dtDept = BaseRepository().FindTable(sql);
                            if (dtDept.Rows.Count > 0)
                            {
                                user.NickName = depart.DepartmentId; //存储承包商或下属部门的Id
                            }
                        }
                        else
                        {
                            user.NickName = user.DepartmentId;
                        }
                    }
                }
                user.Modify(user.UserId);
                res.Update <UserEntity>(user);
                res.Commit();
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
예제 #30
0
        protected override IDbAccessor CreateAccessor(out string key, AccessorExtension extensions)
        {
            var filename = key = Path.GetTempFileName();
            var accessor = DbFactory.CreateAccessor(
                DbAccessorType.SqLite, extensions, () => new SQLiteConnection(String.Format("Data Source={0};Version=3;New=True", filename))
                );

            accessor.Execute(@"
                CREATE TABLE MyTable
                (
                   [MyIdentity] INTEGER PRIMARY KEY AUTOINCREMENT,
                   [MyString] TEXT NULL,
                   [MyNumber] INTEGER NOT NULL
                );

                CREATE TABLE MyChildren
                (
                   [HisIdentity] INTEGER,
                   [MyString] TEXT NULL
                );

                CREATE TABLE MyFriend
                (
                   [MyIdentity] INTEGER PRIMARY KEY AUTOINCREMENT,
                   [MyString] TEXT NULL,
                   [MyNumber] INTEGER NOT NULL
                );

                INSERT INTO MyTable VALUES (null, 'One', 1);
                INSERT INTO MyTable VALUES (null, 'Two', 2);
                INSERT INTO MyTable VALUES (null, 'Three', 3);

                INSERT INTO MyChildren VALUES (1, 'Child 1/3');
                INSERT INTO MyChildren VALUES (1, 'Child 2/3');
                INSERT INTO MyChildren VALUES (1, 'Child 3/3');
                INSERT INTO MyChildren VALUES (3, 'Child 1/1');

                CREATE TABLE [NullableTest] (
                  [Value1] INT NULL
                );

                INSERT INTO [NullableTest] VALUES (null);
                INSERT INTO [NullableTest] VALUES (1);
                INSERT INTO [NullableTest] VALUES (null);
                INSERT INTO [NullableTest] VALUES (2);

                CREATE TABLE MyNopkTable
                (
                   [MyString] TEXT NULL,
                   [MyNumber] INTEGER NOT NULL
                );

                INSERT INTO MyNopkTable VALUES ('One', 1);
                INSERT INTO MyNopkTable VALUES ('Two', 2);
                INSERT INTO MyNopkTable VALUES ('Three', 3);
                ");

            //accessor.Log = Console.Out;

            return(accessor);
        }
예제 #31
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <returns></returns>
        public TransferEntity GetUsertraEntity(string keyValue)
        {
            string sql =
                string.Format("select * from bis_transfer where IsConfirm=1 and userid='{0}' order by CreateDate desc",
                              keyValue);
            TransferEntity tr = this.BaseRepository().FindList(sql).FirstOrDefault();

            Repository <DepartmentEntity> deptdb = new Repository <DepartmentEntity>(DbFactory.Base());
            string           deptsql             = string.Format("select * from base_Department  where departmentid ='{0}' ", tr.OutDeptId);
            DepartmentEntity dept = deptdb.FindList(deptsql).FirstOrDefault();
            bool             flag = true;

            while (dept != null && flag)
            {
                if (tr.OutDeptName == null || tr.OutDeptName == "")
                {
                    tr.OutDeptName = dept.FullName;
                }
                else
                {
                    if (dept.FullName != tr.OutDeptName)//班组同步过来的信息会本身会有名称 会出现xx|xx重复数据
                    {
                        tr.OutDeptName = dept.FullName + "|" + tr.OutDeptName;
                    }
                }

                if (dept.Nature == "班组" || dept.Nature == "专业")
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }

                Repository <DepartmentEntity> Newdeptdb = new Repository <DepartmentEntity>(DbFactory.Base());
                string newsql = string.Format("select * from base_Department  where departmentid ='{0}' ", dept.ParentId);
                dept = Newdeptdb.FindList(newsql).FirstOrDefault();
            }

            return(tr);
        }
예제 #32
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void AppSaveForm(string keyValue, TransferEntity entity, string Userid)
        {
            //开始事物
            var res = DbFactory.Base().BeginTrans();

            try
            {
                Repository <UserEntity> inlogdb = new Repository <UserEntity>(DbFactory.Base());
                string     sql  = string.Format("select * from base_user  where userid ='{0}' ", entity.UserId);
                UserEntity user = inlogdb.FindList(sql).FirstOrDefault();
                inlogdb = new Repository <UserEntity>(DbFactory.Base());
                string     Currentsql  = string.Format("select * from base_user  where userid ='{0}' ", Userid);
                UserEntity Currentuser = inlogdb.FindList(Currentsql).FirstOrDefault();

                Repository <DepartmentEntity> deptdb = new Repository <DepartmentEntity>(DbFactory.Base());
                string           deptsql             = string.Format("select * from base_Department  where departmentid ='{0}' ", entity.OutDeptId);
                DepartmentEntity dept = deptdb.FindList(deptsql).FirstOrDefault();

                if (keyValue == "0")
                {
                    //entity.TID = Guid.NewGuid().ToString();
                    entity.CreateDate         = DateTime.Now;
                    entity.CreateUserId       = Userid;
                    entity.CreateUserDeptCode = Currentuser.DepartmentCode;
                    entity.CreateUserOrgCode  = Currentuser.OrganizeCode;
                    entity.OutDeptCode        = dept.EnCode;
                    entity.CreateUserName     = Currentuser.RealName;
                    res.Insert <TransferEntity>(entity);
                }
                else
                {
                    Repository <TransferEntity> trandb = new Repository <TransferEntity>(DbFactory.Base());
                    string         transql             = string.Format("select * from bis_Transfer where Tid='{0}' ", entity.TID);
                    TransferEntity tran = trandb.FindList(transql).FirstOrDefault();

                    tran.OutDeptCode  = entity.OutDeptCode;
                    tran.OutDeptId    = entity.OutDeptId;
                    tran.OutDeptName  = entity.OutDeptName;
                    tran.OutJobId     = entity.OutJobId;
                    tran.OutJobName   = entity.OutJobName;
                    tran.OutPostId    = entity.OutPostId;
                    tran.OutPostName  = entity.OutPostName;
                    tran.TransferTime = entity.TransferTime;
                    tran.UserId       = entity.UserId;
                    tran.UserName     = entity.UserName;
                    //entity.TID = keyValue;
                    tran.ModifyDate   = DateTime.Now;
                    tran.ModifyUserId = Userid;
                    res.Update <TransferEntity>(tran);
                }

                if (entity.IsConfirm == 0 || entity.IsConfirm == 2)
                {
                    //根据部门id获取所属机构Code
                    Repository <DepartmentEntity> organdb = new Repository <DepartmentEntity>(DbFactory.Base());
                    string organsql = string.Format("select * from base_department  where   departmentid='{0}' ",
                                                    dept.OrganizeId);
                    DepartmentEntity organ = organdb.FindList(organsql).FirstOrDefault();
                    user.OrganizeCode = organ.EnCode;

                    if (entity.OutJobId != null && entity.OutJobId != "")
                    {
                        string postcode = "";
                        Repository <RoleEntity> postdb = new Repository <RoleEntity>(DbFactory.Base());
                        string postsql = string.Format("select * from base_role where category=3 ");
                        IEnumerable <RoleEntity> rlist = postdb.FindList(postsql);
                        string[] Postids = entity.OutJobId.Split(',');
                        for (int i = 0; i < Postids.Length; i++)
                        {
                            RoleEntity ro = rlist.Where(it => it.RoleId == Postids[i]).FirstOrDefault();
                            if (ro != null)
                            {
                                if (postcode == "")
                                {
                                    postcode = ro.EnCode;
                                }
                                else
                                {
                                    postcode += "," + ro.EnCode;
                                }
                            }
                        }

                        user.PostCode = postcode;
                    }

                    //如果不需要确认 则直接修改用户的部门 岗位 职务信息
                    user.PostName       = entity.OutJobName;
                    user.PostId         = entity.OutJobId;
                    user.DutyId         = entity.OutPostId;
                    user.DutyName       = entity.OutPostName;
                    user.DepartmentId   = entity.OutDeptId;
                    user.DepartmentCode = dept.EnCode;
                    user.OrganizeId     = dept.OrganizeId;
                    user.IsTransfer     = 0;

                    #region 给转岗用户赋默认角色
                    string roleName = "";
                    string roleId   = "";
                    Repository <RoleEntity> roledb = new Repository <RoleEntity>(DbFactory.Base());
                    //如果选择的是厂级部门的话,角色会默认追加“厂级部门用户”
                    if (!(string.IsNullOrEmpty(user.DepartmentId) || user.DepartmentId == "undefined"))
                    {
                        Repository <DepartmentEntity> roledeptandb = new Repository <DepartmentEntity>(DbFactory.Base());
                        if (roledeptandb.FindEntity(user.DepartmentId).IsOrg == 1)
                        {
                            roleName += "厂级部门用户,";


                            var expression = LinqExtensions.True <RoleEntity>();
                            expression = expression.And(t => t.Category == 1).And(t => t.EnabledMark == 1).And(t => t.DeleteMark == 0);
                            RoleEntity cj = roledb.IQueryable(expression).OrderByDescending(t => t.CreateDate).ToList().Where(a => a.FullName == "厂级部门用户").FirstOrDefault();
                            if (cj != null)
                            {
                                roleId += cj.RoleId + ",";
                            }
                        }
                    }


                    var expression1 = LinqExtensions.True <RoleEntity>();
                    expression1 = expression1.And(t => t.Category == 2).And(t => t.EnabledMark == 1).And(t => t.DeleteMark == 0);
                    IEnumerable <RoleEntity> role = roledb.IQueryable(expression1).OrderByDescending(t => t.CreateDate).ToList().Where(a => a.RoleId == user.DutyId);
                    RoleEntity roleentity         = role.FirstOrDefault();
                    if (roleentity != null)
                    {
                        roleName += roleentity.RoleNames;
                        roleId   += roleentity.RoleIds;
                    }
                    user.RoleId   = roleId;
                    user.RoleName = roleName;
                    #endregion

                    #region 默认添加 角色、岗位、职位
                    res.Delete <UserRelationEntity>(t => t.IsDefault == 1 && t.UserId == user.UserId);
                    List <UserRelationEntity> userRelationEntitys = new List <UserRelationEntity>();
                    var    currUser = OperatorProvider.Provider.Current();
                    string uid      = currUser == null ? "" : currUser.UserId;
                    string uname    = currUser == null ? "" : currUser.UserName;
                    //用户
                    userRelationEntitys.Add(new UserRelationEntity
                    {
                        Category       = 6,
                        UserRelationId = Guid.NewGuid().ToString(),
                        UserId         = user.UserId,
                        ObjectId       = user.UserId,
                        CreateDate     = DateTime.Now,
                        CreateUserId   = uid,
                        CreateUserName = uname,
                        IsDefault      = 1,
                    });
                    //角色
                    string[] arr = user.RoleId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string item in arr)
                    {
                        userRelationEntitys.Add(new UserRelationEntity
                        {
                            Category       = 2,
                            UserRelationId = Guid.NewGuid().ToString(),
                            UserId         = user.UserId,
                            ObjectId       = item,
                            CreateDate     = DateTime.Now,
                            CreateUserId   = uid,
                            CreateUserName = uname,
                            IsDefault      = 1,
                        });
                    }
                    //岗位
                    if (!string.IsNullOrEmpty(user.DutyId))
                    {
                        userRelationEntitys.Add(new UserRelationEntity
                        {
                            Category       = 3,
                            UserRelationId = Guid.NewGuid().ToString(),
                            UserId         = user.UserId,
                            ObjectId       = user.DutyId,
                            CreateDate     = DateTime.Now,
                            CreateUserId   = uid,
                            CreateUserName = uname,
                            IsDefault      = 1,
                        });
                    }
                    //职位
                    if (!string.IsNullOrEmpty(user.PostId))
                    {
                        userRelationEntitys.Add(new UserRelationEntity
                        {
                            Category       = 4,
                            UserRelationId = Guid.NewGuid().ToString(),
                            UserId         = user.UserId,
                            ObjectId       = user.PostId,
                            CreateDate     = DateTime.Now,
                            CreateUserId   = uid,
                            CreateUserName = uname,
                            IsDefault      = 1,
                        });
                    }
                    res.Insert <UserRelationEntity>(userRelationEntitys);
                    #endregion

                    //转岗完成将记录加入到记录表中
                    Repository <WorkRecordEntity> workdb = new Repository <WorkRecordEntity>(DbFactory.Base());
                    //找到之前没有结尾的工作记录填写结束时间
                    string Worksql = string.Format("update BIS_WORKRECORD set leavetime=to_date('{2}','yyyy-mm-dd hh24:mi:ss') where id=(select id  from (select id from BIS_WORKRECORD t where userid='{0}' and deptid='{1}'  and WorkType=1 and LeaveTime =to_date('0001-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss')  order by createdate desc) a where rownum=1) ", user.UserId, entity.InDeptId, entity.TransferTime);
                    res.ExecuteBySql(Worksql);
                    //新增一条新的岗位记录
                    WorkRecordEntity workEntity = new WorkRecordEntity
                    {
                        Id           = Guid.NewGuid().ToString(),
                        DeptCode     = user.DepartmentCode,
                        DeptId       = user.DepartmentId,
                        EnterDate    = Convert.ToDateTime(entity.TransferTime),
                        UserId       = user.UserId,
                        UserName     = user.RealName,
                        DeptName     = entity.OutDeptName,
                        PostName     = user.DutyName,
                        CreateDate   = DateTime.Now,
                        CreateUserId = Userid,
                        OrganizeName = organ.FullName,
                        JobName      = user.PostName,
                        WorkType     = 1
                    };
                    res.Insert <WorkRecordEntity>(workEntity);
                }
                else
                {
                    //如果需要确认则修改用户状态
                    user.IsTransfer = 1;
                }
                user.Modify(user.UserId);
                res.Update <UserEntity>(user);
                res.Commit();
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
예제 #33
0
        private void Initialize()
        {
            this._provider = DbProviderEnum.SqlServer;
            this.m_factory = new SqlDbFactory();

            this._queries = 0;
            this._connected = false;
        }