public async Task <IActionResult> Edit(RepairStatusUpdateDTO repairStatusUpdateDTO) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RepairStatus repairStatus = new RepairStatus { Id = repairStatusUpdateDTO.Id, Name = repairStatusUpdateDTO.Name }; var result = await _repairStatusService.UpdateAsync(repairStatus); if (result == -1) { return(BadRequest("Error update")); } return(Ok(repairStatus)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <bool> Delete(RepairStatus RepairStatus) { if (await ValidateId(RepairStatus)) { } return(RepairStatus.IsValidated); }
public JsonResult EditStatus(RepairStatus model) { try { WorkingStatusManager.EditRepairStatus(model); //re-initial data Repair model2 = RepairManager.GetById(model.kRepairId); //Inform all connected clients var clientName = User.Identity.Name; Task.Factory.StartNew(() => { var clients = Hub.GetClients <RealTimeJTableDemoHub>(); clients.RecordUpdated(clientName, model2); }); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public async Task <IActionResult> Edit(RepairStatusUpdateDTO repairStatusUpdateDTO) { try { if (!ModelState.IsValid) { return(View(repairStatusUpdateDTO)); } RepairStatus repairStatus = new RepairStatus { Id = repairStatusUpdateDTO.Id, Name = repairStatusUpdateDTO.Name }; var result = await _repairStatusService.UpdateAsync(repairStatus); if (result == -1) { ModelState.AddModelError("", "Error update"); return(View(repairStatusUpdateDTO)); } return(RedirectToAction("Index")); } catch (Exception ex) { return(View("Error", ex)); } }
public static void Edit(RepairStatus model) { using (DataContext db = new DataContext()) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { RepairStatus repairStatus = db.RepairStatuses.Find(id); db.RepairStatuses.Remove(repairStatus); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void Create(RepairStatus model) { using (DataContext db = new DataContext()) { db.RepairStatuies.Add(model); db.SaveChanges(); } }
public RepairTicket_RepairStatusDTO(RepairStatus RepairStatus) { this.Id = RepairStatus.Id; this.Name = RepairStatus.Name; this.Code = RepairStatus.Code; this.Errors = RepairStatus.Errors; }
public ActionResult Edit([Bind(Include = "RepairStatusId,Status")] RepairStatus repairStatus) { if (ModelState.IsValid) { db.Entry(repairStatus).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(repairStatus)); }
public async Task <RepairStatus> Get(long Id) { RepairStatus RepairStatus = await UOW.RepairStatusRepository.Get(Id); if (RepairStatus == null) { return(null); } return(RepairStatus); }
public IActionResult Edit(RepairStatus repairStatus) { var model = new RepairStatusUpdateDTO { Id = repairStatus.Id, Name = repairStatus.Name }; return(View(model)); }
public Customer_RepairStatusDTO(RepairStatus RepairStatus) { this.Id = RepairStatus.Id; this.Name = RepairStatus.Name; this.Code = RepairStatus.Code; this.Errors = RepairStatus.Errors; }
public ActionResult Create([Bind(Include = "RepairStatusId,Status")] RepairStatus repairStatus) { if (ModelState.IsValid) { db.RepairStatuses.Add(repairStatus); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(repairStatus)); }
//public static List<WorkingStatus> GetByRole(string text) //{ // using (DataContext db = new DataContext()) // { // if (text == "Admin" || text == "SuperUser") // { // return db.WorkingStatus // .OrderBy(m => m.iDefault) // .OrderBy(m => m.sDescription) // .ToList(); // } // else // { // return db.WorkingStatus // .OrderBy(m => m.iDefault) // .OrderBy(m => m.sDescription) // .Where(m => m.iDefault == (int)Working.Repair || m.iDefault == (int)Working.Claim || m.iDefault == (int)Working.QC) // .ToList(); // } // } //} public static void EditRepairStatus(RepairStatus model) { using (DataContext db = new DataContext()) { db.Database.ExecuteSqlCommand("UpdateWorkingStatus @RepairId, @WorkingStatusId, @StaffId", new SqlParameter("RepairId", model.kRepairId), new SqlParameter("WorkingStatusId", model.kWorkingStatusId), new SqlParameter("StaffId", model.kStaffId) ); } }
/// <summary> /// 获得某类维修记录的总页数(企业号使用) /// </summary> /// <param name="sta">需要获取的记录状态(获取 全部状态=0,提交=5,受理=10,处理完成待评价=20,完成=99)</param> /// <param name="count">每页的数量</param> /// <returns></returns> public int GetAllPageCount(RepairStatus sta, int count) { var db = new ModelContext(); if (sta == RepairStatus.Unknow) { return(db.RepairSet.Count() / count + 1); } else { return(db.RepairSet.Where(item => item.Status == sta).Count() / count + 1); } }
// GET: RepairStatus/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RepairStatus repairStatus = db.RepairStatuses.Find(id); if (repairStatus == null) { return(HttpNotFound()); } return(View(repairStatus)); }
/// <summary> /// 获得维修记录(用于企业号) /// </summary> /// <param name="sta">需要获取的记录状态(获取 全部状态=0,提交=5,受理=10,处理完成待评价=20,完成=99)</param> /// <param name="count">每页的数量</param> /// <param name="page">当前页数(从0开始计数)</param> /// <returns></returns> public IEnumerable <Repair> GetHistoryRepair(RepairStatus status, int count, int page) { var db = new ModelContext(); int skip = count * page; if (status == RepairStatus.Unknow) { return(db.RepairSet.OrderByDescending(item => item.CreateDate).Skip(skip).Take(count)); } else { return(db.RepairSet.Where(item => item.Status == status).OrderByDescending(item => item.CreateDate).Skip(skip).Take(count)); } }
/// <summary> /// 获得维修记录 /// </summary> /// <param name="openid"></param> /// <param name="status">需要获取的记录状态(提交=5,受理=10,处理完成待评价=20,完成=99 ,未知=0)</param> /// <param name="count">每页数量</param> /// <param name="page">当前页数(从0开始计数)</param> /// <returns></returns> public IEnumerable <Repair> GetHistoryRepair(string openid, RepairStatus status, int count, int page) { var wuser = WechatHelper.CheckOpenid(openid); var user = WechatHelper.CheckUser(wuser); if (user == null) { return(null); } var db = new ModelContext(); int skip = count * page; return(db.RepairSet.Where(item => item.UserId == user.UserInfoId && item.Status == status).OrderByDescending(item => item.CreateDate).Skip(skip).Take(count)); }
public async Task <RepairStatus> Get(long Id) { RepairStatus RepairStatus = await DataContext.RepairStatus.AsNoTracking() .Where(x => x.Id == Id) .Select(x => new RepairStatus() { Id = x.Id, Name = x.Name, Code = x.Code, }).FirstOrDefaultAsync(); if (RepairStatus == null) { return(null); } return(RepairStatus); }
/// <summary> /// Constructor /// </summary> public Repair(int id, string sn, string model, string type, string lineid, string station, RepairStatus status, /*int returnID,*/ string editor, string testlogid, int logId, DateTime cdt, DateTime udt) { this._id = id; this._sn = sn; this._model = model; this._type = type; this._lineid = lineid; this._station = station; this._status = status; //this._returnID = returnID; this._editor = editor; this._testLogID = testlogid; this._logId = logId; this._cdt = cdt; this._udt = udt; this._tracker.MarkAsAdded(this); }
public async Task <bool> ValidateId(RepairStatus RepairStatus) { RepairStatusFilter RepairStatusFilter = new RepairStatusFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = RepairStatus.Id }, Selects = RepairStatusSelect.Id }; int count = await UOW.RepairStatusRepository.Count(RepairStatusFilter); if (count == 0) { RepairStatus.AddError(nameof(RepairStatusValidator), nameof(RepairStatus.Id), ErrorCode.IdNotExisted); } return(count == 1); }
/// <summary> /// 获得某类维修记录的总页数(企业号使用) /// </summary> /// <param name="sta">需要获取的记录状态(获取 全部状态=0,提交=5,受理=10,处理完成待评价=20,完成=99)</param> /// <param name="count">每页的数量</param> /// <returns></returns> public int GetAllPageCount(RepairStatus sta, int count, string openid) { var db = new ModelContext(); var wuser = WechatHelper.CheckOpenid(openid); var user = WechatHelper.CheckUser(wuser); if (user == null) { return(0); } var set = db.RepairSet.Where(item => item.UserId == user.UserInfoId); if (sta == RepairStatus.Unknow) { return(set.Count() / count + 1); } else { return(set.Where(item => item.Status == sta).Count() / count + 1); } }
void Start() { // required to create the association when we instantiate prefabs statusController = GameObject.Find("_StatusController"); ship = GameObject.Find("shipChassis"); //set up array of repair points repairPositionsCount = 0; foreach (Transform child in GameObject.Find("RepairPoints").transform) { repairPositions[repairPositionsCount] = child.transform; repairPositionsCount++; } if (repairPositions.Length == 0) { Debug.LogError("No repair points in array"); } currentState = droneState.lifting; previousRepairPoint = gameObject.transform.position; repairStatus = statusController.GetComponent <RepairStatus>(); SetRandomisations(); }
/// <summary> /// 获得维修记录 手机 /// </summary> /// <param name="phone"></param> /// <param name="count"></param> /// <param name="page"></param> /// <returns></returns> public IEnumerable <Repair> GetHistoryRepairByPhone(string phone, RepairStatus status, int count, int page) { var db = new ModelContext(); UserInfo user = db.UserInfo.FirstOrDefault(item => item.PhoneNumber == phone); //获取config中记录的需要显示的历史纪录数量。 if (user == null) { return(null); } var ownhis = ( from r in db.RepairSet where r.UserId == user.UserInfoId && r.Status == status orderby r.CreateDate descending select r).Skip(count * page).Take(count * (page + 1)); foreach (var item in ownhis) { item.IsUserself = true; } return(ownhis); }
public static void UpdateDat(ThreadWorker thWrk) { try { _thWrk = thWrk; if (_thWrk == null) { return; } _thWrk.Report(new bgwText("Clearing DB Status")); RepairStatus.ReportStatusReset(DB.DirTree); _datCount = 0; _thWrk.Report(new bgwText("Finding Dats")); RvFile datRoot = new RvFile(FileType.Dir) { Name = "RomVault", DatStatus = DatStatus.InDatCollect }; // build a datRoot tree of the DAT's in DatRoot, and count how many dats are found if (!RecursiveDatTree(datRoot, out _datCount)) { _thWrk.Report(new bgwText("Dat Update Complete")); _thWrk.Finished = true; _thWrk = null; return; } _thWrk.Report(new bgwText("Scanning Dats")); _datsProcessed = 0; // now compare the database DAT's with datRoot removing any old DAT's RemoveOldDats(DB.DirTree.Child(0), datRoot); // next clean up the File status removing any old DAT's RemoveOldDatsCleanUpFiles(DB.DirTree.Child(0)); _thWrk.Report(new bgwSetRange(_datCount - 1)); // next add in new DAT and update the files UpdateDatList(DB.DirTree.Child(0), datRoot); // finally remove any unneeded directories from the TreeView RemoveOldTree(DB.DirTree.Child(0)); _thWrk.Report(new bgwText("Updating Cache")); DB.Write(); _thWrk.Report(new bgwText("Dat Update Complete")); _thWrk.Finished = true; _thWrk = null; } catch (Exception exc) { ReportError.UnhandledExceptionHandler(exc); _thWrk?.Report(new bgwText("Updating Cache")); DB.Write(); _thWrk?.Report(new bgwText("Complete")); if (_thWrk != null) { _thWrk.Finished = true; } _thWrk = null; } }
public static void ScanFiles(ThreadWorker thWrk) { try { _thWrk = thWrk; if (_thWrk == null) { return; } _progressCounter = 0; Stopwatch sw = new Stopwatch(); sw.Reset(); sw.Start(); _thWrk.Report(new bgwSetRange(12)); _thWrk.Report(new bgwText("Clearing DB Status")); _thWrk.Report(_progressCounter++); RepairStatus.ReportStatusReset(DB.DirTree); ResetFileGroups(DB.DirTree); _thWrk.Report(new bgwText("Getting Selected Files")); _thWrk.Report(_progressCounter++); Debug.WriteLine("Start " + sw.ElapsedMilliseconds); List <RvFile> filesGot = new List <RvFile>(); List <RvFile> filesMissing = new List <RvFile>(); GetSelectedFiles(DB.DirTree, true, filesGot, filesMissing); Debug.WriteLine("GetSelected " + sw.ElapsedMilliseconds); _thWrk.Report(new bgwText("Sorting on CRC")); _thWrk.Report(_progressCounter++); RvFile[] filesGotSortedCRC = FindFixesSort.SortCRC(filesGot); Debug.WriteLine("SortCRC " + sw.ElapsedMilliseconds); // take the fileGot list and fileGroups list // this groups all the got files using there CRC _thWrk.Report(new bgwText("Index creation on got CRC")); _thWrk.Report(_progressCounter++); MergeGotFiles(filesGotSortedCRC, out FileGroup[] fileGroupsCRCSorted); Debug.WriteLine("Merge " + sw.ElapsedMilliseconds); _thWrk.Report(new bgwText("Index creation on got SHA1")); _thWrk.Report(_progressCounter++); FindFixesSort.SortFamily(fileGroupsCRCSorted, FindSHA1, FamilySortSHA1, out FileGroup[] fileGroupsSHA1Sorted); _thWrk.Report(new bgwText("Index creation on got MD5")); _thWrk.Report(_progressCounter++); FindFixesSort.SortFamily(fileGroupsCRCSorted, FindMD5, FamilySortMD5, out FileGroup[] fileGroupsMD5Sorted); // next make another sorted list of got files on the AltCRC // these are the same FileGroup classes as in the fileGroupsCRCSorted List, just sorted by AltCRC // if the files does not have an altCRC then it is not added to this list. _thWrk.Report(new bgwText("Index creation on got AltCRC")); _thWrk.Report(_progressCounter++); FindFixesSort.SortFamily(fileGroupsCRCSorted, FindAltCRC, FamilySortAltCRC, out FileGroup[] fileGroupsAltCRCSorted); _thWrk.Report(new bgwText("Index creation on got AltSHA1")); _thWrk.Report(_progressCounter++); FindFixesSort.SortFamily(fileGroupsCRCSorted, FindAltSHA1, FamilySortAltSHA1, out FileGroup[] fileGroupsAltSHA1Sorted); _thWrk.Report(new bgwText("Index creation on got AltMD5")); _thWrk.Report(_progressCounter++); FindFixesSort.SortFamily(fileGroupsCRCSorted, FindAltMD5, FamilySortAltMD5, out FileGroup[] fileGroupsAltMD5Sorted); _thWrk.Report(new bgwText("Merging in missing file list")); _thWrk.Report(_progressCounter++); // try and merge the missing File list into the FileGroup classes // using the altCRC sorted list and then the CRCSorted list MergeInMissingFiles(fileGroupsCRCSorted, fileGroupsSHA1Sorted, fileGroupsMD5Sorted, fileGroupsAltCRCSorted, fileGroupsAltSHA1Sorted, fileGroupsAltMD5Sorted, filesMissing); int totalAfterMerge = fileGroupsCRCSorted.Length; _thWrk.Report(new bgwText("Finding Fixes")); _thWrk.Report(_progressCounter++); FindFixesListCheck.GroupListCheck(fileGroupsCRCSorted); _thWrk.Report(new bgwText("Complete (Unique Files " + totalAfterMerge + ")")); _thWrk.Finished = true; _thWrk = null; } catch (Exception exc) { ReportError.UnhandledExceptionHandler(exc); _thWrk?.Report(new bgwText("Updating Cache")); DB.Write(); _thWrk?.Report(new bgwText("Complete")); if (_thWrk != null) { _thWrk.Finished = true; } _thWrk = null; } }
internal override void Update(BehaviorUpdateContext context) { if (Master == null) { // TODO: Should this ever be null? return; } var masterIsMoving = Master.ModelConditionFlags.Get(ModelConditionFlag.Moving); var masterHealthPercent = Master.HealthPercentage; var offsetToMaster = Master.Translation - _gameObject.Translation; var distanceToMaster = offsetToMaster.Vector2XY().Length(); if (!masterIsMoving && (masterHealthPercent < (Fix64)(_moduleData.RepairWhenBelowHealthPercent / 100.0) || _repairStatus != RepairStatus.INITIAL)) { // repair master var isMoving = _gameObject.ModelConditionFlags.Get(ModelConditionFlag.Moving); switch (_repairStatus) { case RepairStatus.INITIAL: // go to master if (distanceToMaster > 1.0) { _gameObject.AIUpdate.SetTargetPoint(Master.Translation); _repairStatus = RepairStatus.GOING_TO_MASTER; } _gameObject.AIUpdate.SetLocomotor(LocomotorSetType.Panic); break; case RepairStatus.GOING_TO_MASTER: if (!isMoving) { _repairStatus = RepairStatus.READY; var readyDuration = context.GameContext.GetRandomLogicFrameSpan(_moduleData.RepairMinReadyTime, _moduleData.RepairMaxReadyTime); _waitUntil = context.LogicFrame + readyDuration; } break; case RepairStatus.READY: if (context.LogicFrame >= _waitUntil) { var range = (float)(context.GameContext.Random.NextDouble() * _moduleData.RepairRange); var height = (float)(context.GameContext.Random.NextDouble() * (_moduleData.RepairMaxAltitude - _moduleData.RepairMinAltitude) + _moduleData.RepairMinAltitude); var angle = (float)(context.GameContext.Random.NextDouble() * (Math.PI * 2)); var offset = Vector3.Transform(new Vector3(range, 0.0f, height), Quaternion.CreateFromAxisAngle(Vector3.UnitZ, angle)); _gameObject.AIUpdate.SetTargetPoint(Master.Translation + offset); _repairStatus = RepairStatus.IN_TRANSITION; } break; case RepairStatus.IN_TRANSITION: if (!isMoving) { var(modelInstance, bone) = _gameObject.Drawable.FindBone(_moduleData.RepairWeldingFXBone); var transform = modelInstance.AbsoluteBoneTransforms[bone.Index]; _particleTemplate ??= context.GameContext.AssetLoadContext.AssetStore.FXParticleSystemTemplates.GetByName(_moduleData.RepairWeldingSys); var particleSystem = context.GameContext.ParticleSystems.Create( _particleTemplate, transform); particleSystem.Activate(); var weldDuration = context.GameContext.GetRandomLogicFrameSpan(_moduleData.RepairMinWeldTime, _moduleData.RepairMaxWeldTime); _waitUntil = context.LogicFrame + weldDuration; _repairStatus = RepairStatus.WELDING; } break; case RepairStatus.WELDING: if (context.LogicFrame >= _waitUntil) { _repairStatus = RepairStatus.READY; } break; } switch (_repairStatus) { case RepairStatus.ZIP_AROUND: case RepairStatus.IN_TRANSITION: case RepairStatus.WELDING: Master.Health += (Fix64)(_moduleData.RepairRatePerSecond / Game.LogicFramesPerSecond); if (Master.Health > Master.MaxHealth) { Master.Health = Master.MaxHealth; _repairStatus = RepairStatus.INITIAL; _gameObject.AIUpdate.SetLocomotor(LocomotorSetType.Normal); } break; } } else if (_gameObject.ModelConditionFlags.Get(ModelConditionFlag.Attacking)) { // stay near target var target = _gameObject.CurrentWeapon.CurrentTarget.GetTargetObject(); if (target != null) { var offsetToTarget = target.Translation - _gameObject.Translation; var distanceToTarget = offsetToTarget.Length(); if (_gameObject.AIUpdate.TargetPoints.Count == 0 && distanceToTarget > _moduleData.AttackWanderRange) { _gameObject.AIUpdate.SetTargetPoint(Master.Translation); } } } else { // stay near master var maxRange = _moduleData.GuardMaxRange; if (masterIsMoving) { maxRange = _moduleData.ScoutRange; } else if (Master.ModelConditionFlags.Get(ModelConditionFlag.Guarding)) { maxRange = _moduleData.GuardWanderRange; } else if (Master.ModelConditionFlags.Get(ModelConditionFlag.Attacking)) { maxRange = _moduleData.AttackRange; } if (_gameObject.AIUpdate.TargetPoints.Count == 0 && distanceToMaster > maxRange) { _gameObject.AIUpdate.SetTargetPoint(Master.Translation); } } if (_moduleData.DieOnMastersDeath && Master.ModelConditionFlags.Get(ModelConditionFlag.Dying)) { _gameObject.Die(DeathType.Exploded); } }
private static void StartUpCode(ThreadWorker e) { RepairStatus.InitStatusCheck(); Settings.rvSettings = Settings.SetDefaults(); DB.Read(e); }
public static void ScanFiles(ThreadWorker e) { #if !DEBUG try { #endif _fileErrorAbort = false; _cacheSaveTimer = new Stopwatch(); _cacheSaveTimer.Reset(); if (Settings.rvSettings.CacheSaveTimerEnabled) { _cacheSaveTimer.Start(); } _thWrk = e; if (_thWrk == null) { return; } _thWrk.Report(new bgwText("Clearing DB Status")); RepairStatus.ReportStatusReset(DB.DirRoot); _thWrk.Report(new bgwText("Finding Dir's to Scan")); //Next get a list of all the directories to be scanned List <RvFile> lstDir = new List <RvFile>(); DBHelper.GetSelectedDirListStart(ref lstDir, StartAt); _thWrk.Report(new bgwText("Scanning Dir's")); _thWrk.Report(new bgwSetRange(lstDir.Count)); //Scan the list of directories. for (int i = 0; i < lstDir.Count; i++) { _thWrk.Report(i + 1); _thWrk.Report(new bgwText("Scanning Dir : " + lstDir[i].FullName)); string lDir = lstDir[i].FullName; Console.WriteLine(lDir); if (Directory.Exists(lDir)) { lstDir[i].GotStatus = GotStatus.Got; CheckADir(lstDir[i], true); } else { MarkAsMissing(lstDir[i]); } if (_thWrk.CancellationPending || _fileErrorAbort) { break; } } _thWrk.Report(new bgwText("Updating Cache")); DB.Write(); _thWrk.Report(new bgwText("File Scan Complete")); _thWrk.Finished = true; _thWrk = null; #if !DEBUG } catch (Exception exc) { ReportError.UnhandledExceptionHandler(exc); _thWrk?.Report(new bgwText("Updating Cache")); DB.Write(); _thWrk?.Report(new bgwText("Complete")); if (_thWrk != null) { _thWrk.Finished = true; } _thWrk = null; } #endif }
public ActionResult Create(BookingClaimViewModel model, FormCollection collection) { try { //initial working status var workingStatusId = WorkingStatusManager.GetAll().Where(m => m.iDefault == (int)Working.Claiming).SingleOrDefault(); if (model.Product != null) { model.Product.Brand = BrandManager.GetById(model.Product.kBrandId); } model.Product.ProductType = ProductTypeManager.GetById(model.Product.kProductTypeId); #region SAVE CUSTOMER var insCount = InsuranceManager.GetCountDuplicate(model.Insurance.sInsuranceName.Trim()); if (insCount.Count <= 0) { Insurance insurance = new Insurance { kInsuranceId = Guid.NewGuid(), sInsuranceName = model.Insurance.sInsuranceName, sAddress1 = model.Insurance.sAddress1, sCity = model.Insurance.sCity, sZip = model.Insurance.sZip, sPhone = model.Insurance.sPhone, sMobile = model.Insurance.sMobile, sFax = model.Insurance.sFax, sEmailAddress = model.Insurance.sEmailAddress }; InsuranceManager.Create(insurance); model.Claim.Insurance = insurance; } else { model.Claim.Insurance = insCount[0]; } #endregion #region SAVE Brand var brandCount = BrandManager.GetCountDuplicate(model.Product.Brand.sBrandName.Trim()); if (brandCount.Count <= 0) { Brand brand = new Brand { kBrandId = Guid.NewGuid(), sBrandName = model.Product.Brand.sBrandName }; BrandManager.Create(brand); model.Product.Brand = brand; } else { model.Product.Brand = brandCount[0]; } #endregion #region SAVE Product Type var productTypeCount = ProductTypeManager.GetCountDuplicate(model.Product.ProductType.sDescription.Trim()); if (productTypeCount.Count <= 0) { ProductType productType = new ProductType { kProductTypeId = Guid.NewGuid(), sDescription = model.Product.ProductType.sDescription }; ProductTypeManager.Create(productType); model.Product.ProductType = productType; } else { model.Product.ProductType = productTypeCount[0]; } #endregion #region SAVE PRODUCT var productCount = ProductManager.GetCountDuplicate( model.Product.sProductName.Trim() //, model.Product.Brand.sBrandName.Trim() //, model.Product.ProductType.sDescription.Trim() ); if (productCount.Count <= 0) { Product product = new Product { kProductId = Guid.NewGuid(), kProductTypeId = productTypeCount.SingleOrDefault().kProductTypeId, kBrandId = brandCount.SingleOrDefault().kBrandId, sProductName = model.Product.sProductName, sProductModel = model.Product.sProductModel }; ProductManager.Create(product); model.Product = product; } else { model.Product = productCount[0]; } #endregion #region SAVE CLAIM BOOKING var repair = RepairManager.GetByRepairNo(model.Claim.sRepairNo ?? ""); //initial booking first character string char_number = CharBooking.C.ToString(); Claim claim = new Claim(); claim.dtDateUpdate = DateTime.Now; claim.kClaimId = Guid.NewGuid(); claim.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; claim.kOwnerId = repair.kOwnerId ?? (Guid)Membership.GetUser().ProviderUserKey; claim.kInsuranceId = model.Claim.Insurance.kInsuranceId; claim.kProductId = model.Product.kProductId; claim.sRepairNo = model.Claim.sRepairNo; claim.sClaimNo = String.Format("{0}{1}", char_number, ClaimNextItemNoManager.GetNextItemNo()); claim.sSerial = model.Claim.sSerial; if (model.Claim.dtInsuranceExpire != null) { claim.dtInsuranceExpire = model.Claim.dtInsuranceExpire.Value.AddYears(-543); } model.Claim = claim; ClaimManager.Create(model.Claim); ClaimNextItemNoManager.IncreaseNextItemNo(); #region also pdate repair side repair.dtDateUpdate = DateTime.Now; repair.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; RepairManager.Edit(repair); #endregion #endregion #region SAVE REPAIR WORKING STATUS ClaimStatus claimStatus = new ClaimStatus { kClaimStatusId = Guid.NewGuid(), kWorkingStatusId = workingStatusId.kWorkingStatusId, kStaffId = (Guid)Membership.GetUser().ProviderUserKey, kClaimId = model.Claim.kClaimId }; ClaimStatusManager.Create(claimStatus); #endregion #region UPDATE REPAIR WORKING STATUS if (!String.IsNullOrEmpty(model.Claim.sRepairNo)) { repair = RepairManager.GetByRepairNo(model.Claim.sRepairNo); RepairStatus repairStatus = new RepairStatus { kRepairStatusId = Guid.NewGuid(), kWorkingStatusId = workingStatusId.kWorkingStatusId, kStaffId = (Guid)Membership.GetUser().ProviderUserKey, kRepairId = repair.kRepairId }; RepairStatusManager.Create(repairStatus); } #endregion #region SAVE CAUSE OF CLAIM //initial cause string keyname; string keyvalue; int countvalue = 0; for (int i = 0; i <= collection.Count - 1; i++) { keyname = collection.AllKeys[i]; keyvalue = collection[i]; if (keyname.Contains("cause")) { countvalue++; } } if (countvalue > 1) { model.ClaimCauses = new List <ClaimCause>(); for (int i = 1; i <= countvalue / 4; i++) { ClaimCause claimCause = new ClaimCause(); claimCause.kClaimCauseId = Guid.NewGuid(); claimCause.kClaimId = model.Claim.kClaimId; claimCause.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; claimCause.sDescription = collection[String.Format("cause_description_{0}", i)]; claimCause.sNote = collection[String.Format("cause_note_{0}", i)]; if (!String.IsNullOrEmpty(claimCause.sDescription)) { int qty = 0; if (int.TryParse(collection[String.Format("cause_qty_{0}", i)], out qty)) { claimCause.iQty = qty; } Decimal price = 0; if (Decimal.TryParse(collection[String.Format("cause_price_{0}", i)], out price)) { claimCause.dPrice = price; } model.ClaimCauses.Add(claimCause); ClaimCourseManager.Create(claimCause); } } } if (model.ClaimCauses != null) { foreach (var item in model.ClaimCauses) { var causeCount = CauseManager.GetCountDuplicate(item.sDescription.Trim()); if (causeCount <= 0) { Cause cause = new Cause { kCauseId = Guid.NewGuid(), sDescription = item.sDescription.Trim() }; CauseManager.Create(cause); } } } #endregion } catch (Exception ex) { return(RedirectToAction("Error", "Home")); } Claim model2 = ClaimManager.GetById(model.Claim.kClaimId); //create remind for history RemindHistory remind = new RemindHistory { sRemind = model2.vMessage, kStaffId = model2.kStaffId }; RemindHistoryManager.Create(remind); var clientName = User.Identity.Name; Task.Factory.StartNew(() => { var clients = Hub.GetClients <RealTimeJTableDemoHub>(); clients.RecordCreated(clientName, model2); }); return(RedirectToAction("Index")); }
public JsonResult EditClaim(Claim claim_sending, ClaimStatus status_sending) { try { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." })); } Repair repair = null; Claim itemFound = ClaimManager.GetById(claim_sending.kClaimId); if (itemFound == null) { return(Json(new { Result = "ERROR", Message = "Item Not Found" })); } if (itemFound.IsComplete == true) { return(Json(new { Result = "ERROR", Message = "ปิด job!" })); } var status = WorkingStatusManager.GetById(status_sending.kWorkingStatusId); if (status.iDefault == (int)Working.ConfirmRepair && claim_sending.IsRecieved != true) { return(Json(new { Result = "ERROR", Message = "ตรวจรับสินค้า!" })); } bool isStatusChange = false; if (status_sending.kWorkingStatusId != itemFound.kWorkingStatusId) { #region update claim status side if (status.iDefault == (int)Working.ConfirmRepair) { status_sending.kStaffId = itemFound.kOwnerId.Value; } else { status_sending.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; } status_sending.dtDateAdd = DateTime.Now; status_sending.kClaimStatusId = Guid.NewGuid(); ClaimStatusManager.Create(status_sending); #endregion #region also update repair status side if (!String.IsNullOrEmpty(itemFound.sRepairNo)) { repair = RepairManager.GetByRepairNo(itemFound.sRepairNo); RepairStatus repairStatus = new RepairStatus { kStaffId = itemFound.kOwnerId.Value, kRepairId = repair.kRepairId, kWorkingStatusId = status_sending.kWorkingStatusId, kRepairStatusId = Guid.NewGuid() }; RepairStatusManager.Create(repairStatus); } #endregion isStatusChange = true; } #region update claim //assign claim itemFound.dtDateUpdate = DateTime.Now; itemFound.IsRecieved = claim_sending.IsRecieved; itemFound.IsNoCredit = claim_sending.IsNoCredit; if (isStatusChange) { itemFound.kStaffId = itemFound.kOwnerId.Value; } ClaimManager.Edit(itemFound); #endregion #region update repair if (isStatusChange) { if (repair != null) { repair.kStaffId = status_sending.kStaffId; } RepairManager.Edit(repair); } #endregion if (isStatusChange) { //create remind for history RemindHistory remind = new RemindHistory { sRemind = itemFound.vMessage, kStaffId = itemFound.kOwnerId.Value }; RemindHistoryManager.Create(remind); var clientName = User.Identity.Name; Task.Factory.StartNew(() => { var clients = Hub.GetClients <RealTimeJTableDemoHub>(); clients.RecordUpdated(clientName, itemFound); }); } return(Json(new { Result = "OK", Records = itemFound })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
/// <summary> /// 设置维修状态 /// </summary> /// <param name="status">维修状态</param> public void SetStatus(RepairStatus status) { this._tracker.MarkAsModified(this); this._status = status; }
public Repair(int id, string sn, string model, string type, string lineid, string station, RepairStatus status, /*int returnID,*/ IList<RepairDefect> defects, string editor, string testlogid, int logId, DateTime cdt, DateTime udt) { this._id = id; this._sn = sn; this._model = model; this._type = type; this._lineid = lineid; this._station = station; this._status = status; //this._returnID = returnID; this._editor = editor; this._testLogID = testlogid; this._logId = logId; this._cdt = cdt; this._udt = udt; this._tracker.MarkAsAdded(this); _defects = new List<RepairDefect>(); foreach (var defect in defects) { defect.Tracker = this._tracker.Merge(defect.Tracker); this._defects.Add(defect); this._tracker.MarkAsAdded(defect); this._tracker.MarkAsModified(this); } }