private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr handle) { ODBC32.RetCode sUCCESS = ODBC32.RetCode.SUCCESS; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { if (HandleState.TransactionInProgress == this._handleState) { sUCCESS = UnsafeNativeMethods.SQLEndTran(base.HandleType, handle, transactionOperation); if ((sUCCESS == ODBC32.RetCode.SUCCESS) || (ODBC32.RetCode.SUCCESS_WITH_INFO == sUCCESS)) { this._handleState = HandleState.Transacted; } Bid.TraceSqlReturn("<odbc.SQLEndTran|API|ODBC|RET> %08X{SQLRETURN}\n", sUCCESS); } if (HandleState.Transacted == this._handleState) { sUCCESS = UnsafeNativeMethods.SQLSetConnectAttrW(handle, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_ON, -5); this._handleState = HandleState.Connected; Bid.TraceSqlReturn("<odbc.SQLSetConnectAttr|API|ODBC|RET> %08X{SQLRETURN}\n", sUCCESS); } } return(sUCCESS); }
public List <SysOffice> GetOfficePermission(string userId, Guid companyId) { try { var hs = new HandleState(); List <SysOffice> results = null; var sysLevel = sysLevelRepository?.Get(lv => lv.UserId == userId && lv.CompanyId == companyId).Select(x => x.OfficeId).ToList(); if (sysLevel == null) { return(null); } if (sysLevel.Count() > 0) { var sysOffice = DataContext.Get(o => sysLevel.Contains(o.Id)).ToList(); results = sysOffice; } return(results); } catch (Exception ex) { return(null); } }
private void OkButton_Click(object sender, RoutedEventArgs e) { if (PlanningFormValidation() && validateTime()) { if (_meetingReservation == null) { _meetingReservation = new MeetingReservation(); //transfered properties _meetingReservation.Date = (DateTime)_reservationDatePicker.SelectedDate; _meetingReservation.MeetingRoom = (MeetingRoom)_meetingCombo.SelectedItem; if (transformDataFromUI()) { HandleState.ChangingData(); DataManager.sort(); ((MainWindow)Application.Current.MainWindow).showReservationsInListBox(); this.Close(); } } else { if (CreateEditReservation()) { updateSelectedForNew(); ((MainWindow)Application.Current.MainWindow).showReservationsInListBox(); this.Close(); } } } }
public HandleState Delete(Guid id) { try { var hs = DataContext.Delete(x => x.Id == id, false); if (hs.Success) { var perGenerals = permissioSampleGeneralRepository.Get(x => x.PermissionId == id); foreach (var item in perGenerals) { permissioSampleGeneralRepository.Delete(x => x.Id == item.Id, false); } var perSpecials = permissioSampleSpecialRepository.Get(x => x.PermissionId == id); foreach (var item in perSpecials) { permissioSampleSpecialRepository.Delete(x => x.Id == item.Id, false); } DataContext.SubmitChanges(); permissioSampleGeneralRepository.SubmitChanges(); permissioSampleSpecialRepository.SubmitChanges(); } return(hs); } catch (Exception ex) { var hs = new HandleState(ex.Message); return(hs); } }
private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr handle) { // must only call this code from ReleaseHandle or DangerousAddRef region ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; // using ConstrainedRegions to make the native ODBC call and change the _handleState RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { if (HandleState.TransactionInProgress == _handleState) { retcode = UnsafeNativeMethods.SQLEndTran(HandleType, handle, transactionOperation); if ((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode)) { _handleState = HandleState.Transacted; } Bid.TraceSqlReturn("<odbc.SQLEndTran|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); } if (HandleState.Transacted == _handleState) // AutoCommitOn { retcode = UnsafeNativeMethods.SQLSetConnectAttrW(handle, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_ON, (Int32)ODBC32.SQL_IS.UINTEGER); _handleState = HandleState.Connected; Bid.TraceSqlReturn("<odbc.SQLSetConnectAttr|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); } } //Overactive assert which fires if handle was allocated - but failed to connect to the server //it can more legitmately fire if transaction failed to rollback - but there isn't much we can do in that situation //Debug.Assert((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState), "not expected HandleState.Connected"); return(retcode); }
private ODBC32.SQLRETURN CompleteTransaction(short transactionOperation, IntPtr handle) { // must only call this code from ReleaseHandle or DangerousAddRef region ODBC32.SQLRETURN retcode = ODBC32.SQLRETURN.SUCCESS; try { } finally { if (HandleState.TransactionInProgress == _handleState) { retcode = Interop.Odbc.SQLEndTran(HandleType, handle, transactionOperation); if ((ODBC32.SQLRETURN.SUCCESS == retcode) || (ODBC32.SQLRETURN.SUCCESS_WITH_INFO == retcode)) { _handleState = HandleState.Transacted; } } if (HandleState.Transacted == _handleState) { // AutoCommitOn retcode = Interop.Odbc.SQLSetConnectAttrW(handle, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_ON, (int)ODBC32.SQL_IS.UINTEGER); _handleState = HandleState.Connected; } } //Overactive assert which fires if handle was allocated - but failed to connect to the server //it can more legitmately fire if transaction failed to rollback - but there isn't much we can do in that situation //Debug.Assert((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState), "not expected HandleState.Connected"); return(retcode); }
void DrawHandle(float y, HandleState handleState = HandleState.Default) { float renderZ = forwardDepth; Material currentHandleMat; switch (handleState) { case HandleState.Highlighted: currentHandleMat = highlightedHandleMat; break; case HandleState.Selected: currentHandleMat = selectedHandleMat; renderZ = forwardDepth * 2; break; default: currentHandleMat = handleMat; break; } Vector3 scale = new Vector3(handleSize.x, handleSize.y, 1); Vector3 pos3D = new Vector3(transform.position.x, y, transform.position.z + renderZ); Matrix4x4 handleMatrix = Matrix4x4.TRS(pos3D, Quaternion.identity, scale); Graphics.DrawMesh(quadMesh, handleMatrix, currentHandleMat, 0); }
public HandleState Add(SysCompanyAddModel model) { try { var userCurrent = currentUser.UserID; var SysCompany = new SysCompanyModel { Code = model.CompanyCode, BunameAbbr = model.CompanyNameVn, BunameVn = model.CompanyNameVn, BunameEn = model.CompanyNameEn, Website = model.Website, Active = model.Status, LogoPath = model.PhotoUrl, Id = Guid.NewGuid() }; SysCompany.DatetimeCreated = SysCompany.DatetimeModified = DateTime.Now; SysCompany.UserCreated = SysCompany.UserModified = userCurrent; var hs = DataContext.Add(SysCompany); if (hs.Success) { model.Id = DataContext.Get(x => x.Code == model.CompanyCode).FirstOrDefault().Id; // lấy ra company vừa tạo. } return(hs); } catch (Exception ex) { var hs = new HandleState(ex); return(hs); } }
public HandleState DeleteCharge(Guid chargeId) { var hs = new HandleState(); try { var charge = DataContext.Where(x => x.Id == chargeId).FirstOrDefault(); if (charge == null) { hs = new HandleState(stringLocalizer[DocumentationLanguageSub.MSG_SURCHARGE_NOT_FOUND].Value); } if (charge != null && (charge.CreditNo != null || charge.Soano != null || charge.DebitNo != null || charge.PaySoano != null)) { hs = new HandleState(stringLocalizer[DocumentationLanguageSub.MSG_SURCHARGE_NOT_ALLOW_DELETED].Value); } else { DataContext.Delete(x => x.Id == chargeId); } } catch (Exception ex) { hs = new HandleState(ex.Message); } return(hs); }
public HandleState DeleteMultiple(List <Guid> listId) { var hs = new HandleState(); try { foreach (var item in listId) { var charge = DataContext.Where(x => x.Id == item).FirstOrDefault(); if (charge == null) { hs = new HandleState(stringLocalizer[DocumentationLanguageSub.MSG_SURCHARGE_NOT_FOUND].Value); return(hs); } if (charge != null && (charge.CreditNo != null || charge.Soano != null || charge.DebitNo != null || charge.PaySoano != null)) { hs = new HandleState(stringLocalizer[DocumentationLanguageSub.MSG_SURCHARGE_NOT_ALLOW_DELETED].Value); return(hs); } hs = DataContext.Delete(x => x.Id == item, false); if (hs.Success == false) { return(hs); } } DataContext.SubmitChanges(); } catch (Exception ex) { hs = new HandleState(ex.Message); } return(hs); }
public IActionResult Delete(string settlementNo) { var isAllowDelete = acctSettlementPaymentService.CheckDeletePermissionBySettlementNo(settlementNo); if (isAllowDelete == false) { return(BadRequest(new ResultHandle { Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value })); } ChangeTrackerHelper.currentUser = currentUser.UserID; HandleState hs = acctSettlementPaymentService.DeleteSettlementPayment(settlementNo); if (hs.Code == 403) { return(BadRequest(new ResultHandle { Status = false, Message = stringLocalizer[LanguageSub.DO_NOT_HAVE_PERMISSION].Value })); } var message = HandleError.GetMessage(hs, Crud.Delete); ResultHandle result = new ResultHandle { Status = hs.Success, Message = stringLocalizer[message].Value }; if (!hs.Success) { return(BadRequest(result)); } return(Ok(result)); }
public HandleState Update(Guid id, SysCompanyAddModel model) { var userCurrent = currentUser.UserID; try { var SysCompanyCurrent = DataContext.First(x => x.Id == id); SysCompanyCurrent.DatetimeCreated = SysCompanyCurrent.DatetimeCreated; SysCompanyCurrent.UserCreated = SysCompanyCurrent.UserCreated; if (SysCompanyCurrent.Code != model.CompanyCode && DataContext.Any(item => item.Code == model.CompanyCode)) { return(new HandleState("Code existed")); } SysCompanyCurrent.DatetimeModified = DateTime.Now; SysCompanyCurrent.UserModified = userCurrent; SysCompanyCurrent.LogoPath = model.PhotoUrl; SysCompanyCurrent.Active = model.Status; SysCompanyCurrent.Code = model.CompanyCode; SysCompanyCurrent.Website = model.Website; SysCompanyCurrent.BunameAbbr = model.CompanyNameAbbr; SysCompanyCurrent.BunameEn = model.CompanyNameEn; SysCompanyCurrent.BunameVn = model.CompanyNameVn; DataContext.Update(SysCompanyCurrent, x => x.Id == id); var hs = new HandleState(); return(hs); } catch (Exception ex) { var hs = new HandleState(ex.Message); return(hs); } }
internal ODBC32.RetCode BeginTransaction(ref System.Data.IsolationLevel isolevel) { ODBC32.RetCode sUCCESS = ODBC32.RetCode.SUCCESS; if (System.Data.IsolationLevel.Unspecified != isolevel) { ODBC32.SQL_ATTR sql_attr; ODBC32.SQL_TRANSACTION sERIALIZABLE; switch (isolevel) { case System.Data.IsolationLevel.RepeatableRead: sERIALIZABLE = ODBC32.SQL_TRANSACTION.REPEATABLE_READ; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.Serializable: sERIALIZABLE = ODBC32.SQL_TRANSACTION.SERIALIZABLE; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.Snapshot: sERIALIZABLE = ODBC32.SQL_TRANSACTION.SNAPSHOT; sql_attr = ODBC32.SQL_ATTR.SQL_COPT_SS_TXN_ISOLATION; break; case System.Data.IsolationLevel.Chaos: throw ODBC.NotSupportedIsolationLevel(isolevel); case System.Data.IsolationLevel.ReadUncommitted: sERIALIZABLE = ODBC32.SQL_TRANSACTION.READ_UNCOMMITTED; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.ReadCommitted: sERIALIZABLE = ODBC32.SQL_TRANSACTION.READ_COMMITTED; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; default: throw ADP.InvalidIsolationLevel(isolevel); } sUCCESS = this.SetConnectionAttribute2(sql_attr, (IntPtr)((long)sERIALIZABLE), -6); if (ODBC32.RetCode.SUCCESS_WITH_INFO == sUCCESS) { isolevel = System.Data.IsolationLevel.Unspecified; } } switch (sUCCESS) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: sUCCESS = this.AutoCommitOff(); this._handleState = HandleState.TransactionInProgress; return(sUCCESS); } return(sUCCESS); }
protected override bool ReleaseHandle() { ODBC32.RetCode code = this.CompleteTransaction(1, base.handle); if ((HandleState.Connected == this._handleState) || (HandleState.TransactionInProgress == this._handleState)) { code = UnsafeNativeMethods.SQLDisconnect(base.handle); this._handleState = HandleState.Allocated; Bid.TraceSqlReturn("<odbc.SQLDisconnect|API|ODBC|RET> %08X{SQLRETURN}\n", code); } return(base.ReleaseHandle()); }
// 9.1 delete center private void deleteMeetingButton_Click(object sender, RoutedEventArgs e) { if (meetingCentresListBox.SelectedItem != null) { if (MessageBox.Show("Do you really want to delete selected Centre?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { DataManager.Centres.Remove(meetingCentresListBox.SelectedItem as MeetingCentre); HandleState.ChangingData(); } } }
private async Task <ResultHandle> WriteFile(DocumentFileUploadModel model) { string fileName = ""; //string folderName = "images"; string path = this.webUrl.Value.Url; try { var list = new List <SysImage>(); /* Kiểm tra các thư mục có tồn tại */ var hs = new HandleState(); ImageHelper.CreateDirectoryFile(model.FolderName, model.JobId.ToString()); List <SysImage> resultUrls = new List <SysImage>(); foreach (var file in model.Files) { fileName = file.FileName; string objectId = model.JobId.ToString(); await ImageHelper.SaveFile(fileName, model.FolderName, objectId, file); string urlImage = path + "/" + model.FolderName + "files/" + objectId + "/" + fileName; var sysImage = new SysImage { Id = Guid.NewGuid(), Url = urlImage, Name = fileName, Folder = model.FolderName ?? "Shipment", ObjectId = model.JobId.ToString(), UserCreated = currentUser.UserName, //admin. UserModified = currentUser.UserName, DateTimeCreated = DateTime.Now, DatetimeModified = DateTime.Now }; resultUrls.Add(sysImage); if (!DataContext.Any(x => x.ObjectId == objectId && x.Url == urlImage)) { list.Add(sysImage); } } if (list.Count > 0) { hs = await DataContext.AddAsync(list); } return(new ResultHandle { Data = resultUrls, Status = hs.Success, Message = hs.Message?.ToString() }); } catch (Exception ex) { return(new ResultHandle { Data = null, Status = false, Message = ex.Message }); } }
public HandleState UpdateStatus(StageComment model) { HandleState result = null; var stage = stages.Find(x => x.Id == model.StageId); if (stage == null) { result = new HandleState(404, "Not found"); } else { stages.First(x => x.Id == model.StageId).Status = model.Status; Comment newComment = null; if (model.Status == StatusEnum.StageStatus.Pending) { newComment = new Comment { Id = Guid.NewGuid(), CommentType = StatusEnum.CommentType.Pending, Content = model.Content, StageId = model.StageId, CreatedDate = DateTime.Now, UserId = user.UserId }; comments.Add(newComment); jobs.First(x => x.Id == stage.JobId).CurrentStageStatus = StatusEnum.JobStatus.Pending; } if (model.Status == StatusEnum.StageStatus.Done) { var list = stages.Where(x => x.JobId == stage.JobId); var countFinish = list.Count(x => x.Status == StatusEnum.StageStatus.Done); if (list.Count() == countFinish) { jobs.First(x => x.Id == stage.JobId).CurrentStageStatus = StatusEnum.JobStatus.Finish; } newComment = new Comment { Id = Guid.NewGuid(), CommentType = StatusEnum.CommentType.Done, Content = model.Content, StageId = model.StageId, CreatedDate = DateTime.Now, UserId = user.UserId }; comments.Add(newComment); } jobs.First(x => x.Id == stage.JobId).CurrentDeadline = stage.EndDate; result = new HandleState(); } return(result); }
void DrawSignalHandles () { for (int i = 0; i < signals.Count; i++) { HandleState handleState = HandleState.Default; if (signals[i] == highlightedSignal) { handleState = HandleState.Highlighted; } if (signals[i] == selectedSignal) { handleState = HandleState.Selected; } DrawHandle (signals[i].transform.position.y, handleState); } }
private void okCentreFormBtn_Click(object sender, RoutedEventArgs e) { if (centreFormValidation() == false) { ; } else { newInputForm(); editInputForm(); HandleState.ChangingData(); _refreshData.Items.Refresh(); } }
public HandleState Delete(Guid id) { try { ChangeTrackerHelper.currentUser = currentUser.UserID; //TODO var hs = DataContext.Delete(x => x.Id == id); return(hs); } catch (Exception ex) { var hs = new HandleState(ex.Message); return(hs); } }
public HandleState AddOrUpdate(CsShippingInstructionModel model) { var result = new HandleState(); var modelUpdate = mapper.Map <CsShippingInstruction>(model); if (DataContext.Any(x => x.JobId == model.JobId)) { result = DataContext.Update(modelUpdate, x => x.JobId == model.JobId); } else { result = DataContext.Add(modelUpdate); } return(result); }
protected override bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once and is non-interrutible. // must call complete the transaction rollback, change handle state, and disconnect the connection CompleteTransaction(ODBC32.SQL_ROLLBACK, handle); if ((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState)) { Interop.Odbc.SQLDisconnect(handle); _handleState = HandleState.Allocated; } Debug.Assert(HandleState.Allocated == _handleState, "not expected HandleState.Allocated"); return(base.ReleaseHandle()); }
private void CheckNames() { for (int i = 0; i < inventory.slots.Length; i++) { if (Input.GetKeyDown(KeyCode.E)) { if (inventory.names[i] == "doorHandel") { doorHandle.SetActive(true); inventory.DeleteItem("doorHandel"); handleState = HandleState.handleOn; } } } }
public HandleState AddMultipleStage(List <OpsStageAssignedEditModel> models, Guid jobId) { var result = new HandleState(); var stagesByJob = DataContext.Get(x => x.JobId == jobId); var listToDelete = stagesByJob.Where(x => !models.Any(model => model.Id == x.Id)); if (listToDelete.Count() > 0) { ChangeTrackerHelper.currentUser = currentUser.UserID; var list = mapper.Map <List <OpsStageAssigned> >(listToDelete); foreach (var item in list) { DataContext.Delete(x => x.Id == item.Id, false); } } foreach (var item in models) { if (item.Id == Guid.Empty) { var assignedItem = mapper.Map <OpsStageAssigned>(item); assignedItem.Id = Guid.NewGuid(); assignedItem.JobId = jobId; assignedItem.Deadline = item.Deadline ?? null; assignedItem.Status = OperationConstants.InSchedule; assignedItem.DatetimeCreated = assignedItem.DatetimeModified = DateTime.Now; assignedItem.UserCreated = currentUser.UserID; DataContext.Add(assignedItem, false); } else { var assignedToUpdate = DataContext.First(x => x.Id == item.Id); assignedToUpdate.UserModified = currentUser.UserID; assignedToUpdate.DatetimeModified = DateTime.Now; assignedToUpdate.OrderNumberProcessed = item.OrderNumberProcessed; DataContext.Update(assignedToUpdate, x => x.Id == assignedToUpdate.Id, false); } } try { DataContext.SubmitChanges(); } catch (Exception ex) { result = new HandleState(ex.Message); } return(result); }
public HandleState AddUser(List <SysUserLevelModel> users) { using (var trans = DataContext.DC.Database.BeginTransaction()) { try { var hsUser = new HandleState(); foreach (var item in users) { //if (item.Id != 0) //{ // item.UserModified = currentUser.UserID; // item.DatetimeModified = DateTime.Now; // hsUser = DataContext.Update(item, x => x.Id == item.Id); //} //else //{ // item.Active = true; // item.GroupId = item.GroupId == 0 ? SystemConstants.SpecialGroup : item.GroupId; // item.DatetimeCreated = item.DatetimeModified = DateTime.Now; // item.UserCreated = item.UserModified = currentUser.UserID; // hsUser = DataContext.Add(item, true); //} if (item.Id == 0) { item.Active = true; item.GroupId = item.GroupId == 0 ? SystemConstants.SpecialGroup : item.GroupId; item.DatetimeCreated = item.DatetimeModified = DateTime.Now; item.UserCreated = item.UserModified = currentUser.UserID; hsUser = DataContext.Add(item, true); } } trans.Commit(); return(hsUser); } catch (Exception ex) { trans.Rollback(); return(new HandleState(ex.Message)); } finally { trans.Dispose(); } } }
override protected bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once and is non-interrutible. ODBC32.RetCode retcode; // must call complete the transaction rollback, change handle state, and disconnect the connection retcode = CompleteTransaction(ODBC32.SQL_ROLLBACK, handle); if ((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState)) { retcode = UnsafeNativeMethods.SQLDisconnect(handle); _handleState = HandleState.Allocated; Bid.TraceSqlReturn("<odbc.SQLDisconnect|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); } Debug.Assert(HandleState.Allocated == _handleState, "not expected HandleState.Allocated"); return(base.ReleaseHandle()); }
public HandleState AddOrUpdateManifest(CsManifestEditModel model) { try { var manifest = mapper.Map <CsManifest>(model); manifest.CreatedDate = DateTime.Now; var hs = new HandleState(); manifest.RefNo = GetManifestNo(model.JobId); if (DataContext.Any(x => x.JobId == model.JobId)) { hs = DataContext.Update(manifest, x => x.JobId == model.JobId); } else { hs = DataContext.Add(manifest); } if (hs.Success) { foreach (var item in model.CsTransactionDetails) { if (item.IsRemoved) { item.ManifestRefNo = null; } else { item.ManifestRefNo = manifest.RefNo; } item.DatetimeModified = DateTime.Now; item.UserModified = manifest.UserCreated; var tranDetail = mapper.Map <CsTransactionDetail>(item); var s = transactionDetailRepository.Update(tranDetail, x => x.Id == tranDetail.Id); } transactionDetailRepository.SubmitChanges(); DataContext.SubmitChanges(); } return(hs); } catch (Exception ex) { var hs = new HandleState(ex.Message); return(hs); } }
private HandleState Add(SysImage sysImage) { try { var userCurrent = "admin"; // TODO sysImage.Id = Guid.NewGuid(); sysImage.DateTimeCreated = sysImage.DatetimeModified = DateTime.Now; sysImage.UserCreated = sysImage.UserModified = userCurrent; var hs = DataContext.Add(sysImage); return(hs); } catch (Exception ex) { var hs = new HandleState(ex); return(hs); } }
public async Task <ResultHandle> WriteFile(IFormFile file, string folderName) { string fileName = ""; //string folderName = "images"; string path = webUrl.Value.Url; try { var extension = "." + file.FileName.Split('.')[file.FileName.Split('.').Length - 1]; //lấy extension fileName = file.FileName; /* Kiểm tra các thư mục có tồn tại */ ImageHelper.CreateDirectoryImage(folderName); await ImageHelper.SaveImage(fileName, folderName, file); string urlImage = path + "/images/" + folderName + "/" + fileName; var result = new { link = urlImage }; var sysImage = new SysImage { Id = Guid.NewGuid(), Url = urlImage, Name = fileName, Folder = folderName ?? "Company" }; HandleState x = Add(sysImage); // lưu db if (x.Success) { return(new ResultHandle { Data = result, Status = x.Success, Message = "" }); } return(new ResultHandle { Data = result, Status = x.Success, Message = "" }); } catch (Exception ex) { var hs = new ResultHandle { Data = null, Status = false, Message = ex.Message }; return(hs); } }
public MainWindow() { // Determine if the app is first time started and load saved data from previous use. if (HandleState.SecondLoading) { return; } else { LoadData.LoadMeetingDataFromFile(@"C:\Users\randj\Dropbox\NET\Projects\Meeting-Centres\MeetingReservation\MeetingLibrary\ExportData.csv"); LoadDataXML.LoadXML(@"C:\Users\randj\Dropbox\NET\Projects\Meeting-Centres\MeetingReservation\DataRepository\Reservations.xml"); HandleState.FirstLoading(); } InitializeComponent(); showCentresInListBox(); RefreshCentres = meetingCentresListBox; RefreshRooms = meetingRoomsListBox; }
private ODBC32.RetCode AutoCommitOff() { ODBC32.RetCode retcode; Debug.Assert(HandleState.Connected <= _handleState, "AutoCommitOff while in wrong state?"); // Avoid runtime injected errors in the following block. // must call SQLSetConnectAttrW and set _handleState RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { retcode = UnsafeNativeMethods.SQLSetConnectAttrW(this, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_OFF, (Int32)ODBC32.SQL_IS.UINTEGER); switch(retcode) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: _handleState = HandleState.Transacted; break; } } ODBC.TraceODBC(3, "SQLSetConnectAttrW", retcode); return retcode; }
private ODBC32.RetCode AutoCommitOff() { ODBC32.RetCode code; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { code = UnsafeNativeMethods.SQLSetConnectAttrW(this, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_OFF, -5); switch (code) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: this._handleState = HandleState.Transacted; break; } } ODBC.TraceODBC(3, "SQLSetConnectAttrW", code); return code; }
// Use this for initialization void Start() { GameManager.instance.farmer = this; ufoTransform = GameManager.instance.UFO.gameObject.transform; path = new NavMeshPath(); farmerBody = gameObject.GetComponent<FarmerNick>(); farmerBrain = new FiniteStateMachine<AIState>(); farmerBrain.PushState(AIState.OBSERVING); runState += Observing; runState += Chasing; runState += Attacking; runState += Stunned; farmerBody.ChangeBubleText (0); }
private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr handle) { ODBC32.RetCode sUCCESS = ODBC32.RetCode.SUCCESS; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { if (HandleState.TransactionInProgress == this._handleState) { sUCCESS = UnsafeNativeMethods.SQLEndTran(base.HandleType, handle, transactionOperation); if ((sUCCESS == ODBC32.RetCode.SUCCESS) || (ODBC32.RetCode.SUCCESS_WITH_INFO == sUCCESS)) { this._handleState = HandleState.Transacted; } Bid.TraceSqlReturn("<odbc.SQLEndTran|API|ODBC|RET> %08X{SQLRETURN}\n", sUCCESS); } if (HandleState.Transacted == this._handleState) { sUCCESS = UnsafeNativeMethods.SQLSetConnectAttrW(handle, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_ON, -5); this._handleState = HandleState.Connected; Bid.TraceSqlReturn("<odbc.SQLSetConnectAttr|API|ODBC|RET> %08X{SQLRETURN}\n", sUCCESS); } } return sUCCESS; }
private ODBC32.RetCode Connect(string connectionString) { ODBC32.RetCode code; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { short num; code = UnsafeNativeMethods.SQLDriverConnectW(this, ADP.PtrZero, connectionString, -3, ADP.PtrZero, 0, out num, 0); switch (code) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: this._handleState = HandleState.Connected; break; } } ODBC.TraceODBC(3, "SQLDriverConnectW", code); return code; }
protected override bool ReleaseHandle() { ODBC32.RetCode code = this.CompleteTransaction(1, base.handle); if ((HandleState.Connected == this._handleState) || (HandleState.TransactionInProgress == this._handleState)) { code = UnsafeNativeMethods.SQLDisconnect(base.handle); this._handleState = HandleState.Allocated; Bid.TraceSqlReturn("<odbc.SQLDisconnect|API|ODBC|RET> %08X{SQLRETURN}\n", code); } return base.ReleaseHandle(); }
internal ODBC32.RetCode BeginTransaction(ref System.Data.IsolationLevel isolevel) { ODBC32.RetCode sUCCESS = ODBC32.RetCode.SUCCESS; if (System.Data.IsolationLevel.Unspecified != isolevel) { ODBC32.SQL_ATTR sql_attr; ODBC32.SQL_TRANSACTION sERIALIZABLE; switch (isolevel) { case System.Data.IsolationLevel.RepeatableRead: sERIALIZABLE = ODBC32.SQL_TRANSACTION.REPEATABLE_READ; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.Serializable: sERIALIZABLE = ODBC32.SQL_TRANSACTION.SERIALIZABLE; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.Snapshot: sERIALIZABLE = ODBC32.SQL_TRANSACTION.SNAPSHOT; sql_attr = ODBC32.SQL_ATTR.SQL_COPT_SS_TXN_ISOLATION; break; case System.Data.IsolationLevel.Chaos: throw ODBC.NotSupportedIsolationLevel(isolevel); case System.Data.IsolationLevel.ReadUncommitted: sERIALIZABLE = ODBC32.SQL_TRANSACTION.READ_UNCOMMITTED; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case System.Data.IsolationLevel.ReadCommitted: sERIALIZABLE = ODBC32.SQL_TRANSACTION.READ_COMMITTED; sql_attr = ODBC32.SQL_ATTR.TXN_ISOLATION; break; default: throw ADP.InvalidIsolationLevel(isolevel); } sUCCESS = this.SetConnectionAttribute2(sql_attr, (IntPtr) ((long) sERIALIZABLE), -6); if (ODBC32.RetCode.SUCCESS_WITH_INFO == sUCCESS) { isolevel = System.Data.IsolationLevel.Unspecified; } } switch (sUCCESS) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: sUCCESS = this.AutoCommitOff(); this._handleState = HandleState.TransactionInProgress; return sUCCESS; } return sUCCESS; }
private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr handle) { // must only call this code from ReleaseHandle or DangerousAddRef region ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; // using ConstrainedRegions to make the native ODBC call and change the _handleState RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { if (HandleState.TransactionInProgress == _handleState) { retcode = UnsafeNativeMethods.SQLEndTran(HandleType, handle, transactionOperation); if((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode)) { _handleState = HandleState.Transacted; } Bid.TraceSqlReturn("<odbc.SQLEndTran|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); } if (HandleState.Transacted == _handleState) { // AutoCommitOn retcode = UnsafeNativeMethods.SQLSetConnectAttrW(handle, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_ON, (Int32)ODBC32.SQL_IS.UINTEGER); _handleState = HandleState.Connected; Bid.TraceSqlReturn("<odbc.SQLSetConnectAttr|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); } } //Overactive assert which fires if handle was allocated - but failed to connect to the server //it can more legitmately fire if transaction failed to rollback - but there isn't much we can do in that situation //Debug.Assert((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState), "not expected HandleState.Connected"); return retcode; }
private ODBC32.RetCode Connect(string connectionString) { Debug.Assert(HandleState.Allocated == _handleState, "SQLDriverConnect while in wrong state?"); ODBC32.RetCode retcode; // Avoid runtime injected errors in the following block. RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { short cbActualSize; retcode = UnsafeNativeMethods.SQLDriverConnectW(this, ADP.PtrZero, connectionString, ODBC32.SQL_NTS, ADP.PtrZero, 0, out cbActualSize, (short)ODBC32.SQL_DRIVER.NOPROMPT); switch(retcode) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: _handleState = HandleState.Connected; break; } } ODBC.TraceODBC(3, "SQLDriverConnectW", retcode); return retcode; }
override protected bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once and is non-interrutible. ODBC32.RetCode retcode; // must call complete the transaction rollback, change handle state, and disconnect the connection retcode = CompleteTransaction(ODBC32.SQL_ROLLBACK, handle); if ((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState)) { retcode = UnsafeNativeMethods.SQLDisconnect(handle); _handleState = HandleState.Allocated; Bid.TraceSqlReturn("<odbc.SQLDisconnect|API|ODBC|RET> %08X{SQLRETURN}\n", retcode); } Debug.Assert(HandleState.Allocated == _handleState, "not expected HandleState.Allocated"); return base.ReleaseHandle(); }
internal ODBC32.RetCode BeginTransaction(ref IsolationLevel isolevel) { ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; ODBC32.SQL_ATTR isolationAttribute; if(IsolationLevel.Unspecified != isolevel) { ODBC32.SQL_TRANSACTION sql_iso; switch(isolevel) { case IsolationLevel.ReadUncommitted: sql_iso = ODBC32.SQL_TRANSACTION.READ_UNCOMMITTED; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.ReadCommitted: sql_iso = ODBC32.SQL_TRANSACTION.READ_COMMITTED; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.RepeatableRead: sql_iso = ODBC32.SQL_TRANSACTION.REPEATABLE_READ; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.Serializable: sql_iso = ODBC32.SQL_TRANSACTION.SERIALIZABLE; isolationAttribute = ODBC32.SQL_ATTR.TXN_ISOLATION; break; case IsolationLevel.Snapshot: sql_iso = ODBC32.SQL_TRANSACTION.SNAPSHOT; // VSDD 414121: Snapshot isolation level must be set through SQL_COPT_SS_TXN_ISOLATION (http://msdn.microsoft.com/en-us/library/ms131709.aspx) isolationAttribute = ODBC32.SQL_ATTR.SQL_COPT_SS_TXN_ISOLATION; break; case IsolationLevel.Chaos: throw ODBC.NotSupportedIsolationLevel(isolevel); default: throw ADP.InvalidIsolationLevel(isolevel); } //Set the isolation level (unless its unspecified) retcode = SetConnectionAttribute2(isolationAttribute, (IntPtr)sql_iso, (Int32)ODBC32.SQL_IS.INTEGER); //Note: The Driver can return success_with_info to indicate it "rolled" the //isolevel to the next higher value. If this is the case, we need to requery //the value if th euser asks for it... //We also still propagate the info, since it could be other info as well... if(ODBC32.RetCode.SUCCESS_WITH_INFO == retcode) { isolevel = IsolationLevel.Unspecified; } } switch(retcode) { case ODBC32.RetCode.SUCCESS: case ODBC32.RetCode.SUCCESS_WITH_INFO: //Turn off auto-commit (which basically starts the transaction) retcode = AutoCommitOff(); _handleState = HandleState.TransactionInProgress; break; } return retcode; }