public DeleteResult<tblM_Position> Execute(int positionPK, DeleteMethod deleteMethod) { tblM_Position position = Db.tblM_Position.Find(positionPK); if (position == null) { return new DeleteResult<tblM_Position>() { Success = false, Message = $"Id '{positionPK}' is not found.", Record = null }; } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(position); break; case DeleteMethod.Hard: HardDelete(position); break; default: break; } Db.SaveChanges(); return new DeleteResult<tblM_Position>() { Success = true, Message = $"Position with Id '{positionPK}' successfully deleted.", Record = position }; }
public DeleteResult<tblM_Kota> Execute(int kotaPK, DeleteMethod deleteMethod) { tblM_Kota kota = Db.tblM_Kota.Find(kotaPK); if (kota == null) { return new DeleteResult<tblM_Kota>() { Success = false, Message = $"Id '{kotaPK}' is not found.", Record = null }; } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(kota); break; case DeleteMethod.Hard: HardDelete(kota); break; default: break; } Db.SaveChanges(); return new DeleteResult<tblM_Kota>() { Success = true, Message = $"Kota with Id '{kotaPK}' successfully deleted.", Record = kota }; }
public Result DeleteMethod(DeleteMethod deleteMethod) { long idToDelete = deleteMethod.Id; int numberOfRemovedItems = methodsMemoryDatabase.RemoveAll(m => m.Id == idToDelete); if (numberOfRemovedItems == 0) { return(Result.Fail("The method you are trying to delete does not exist")); } return(Result.Ok()); }
public IActionResult DeleteMethod(long id) { long loggedInUserId = GetLoggedInUserIdMockUp(); if (loggedInUserId == -1) { return(Unauthorized()); } DeleteMethod deleteMethod = new DeleteMethod(id, loggedInUserId); _kafkaProducer.Produce(deleteMethod, METHODS_TOPIC); return(Ok("Currently processing your request...")); }
public static bool LogicLoop(bool continueRun) { // Prompt user for action Console.WriteLine("Would you like to add a customer (add), delete a customer (delete), view all customers (view), or exit (exit)?"); string programAction = Console.ReadLine(); Console.WriteLine(); // Add, View, Delete, Exit if (programAction == "add" || programAction == "Add") { // Add method AddMethod.Add(); return(continueRun); } else if (programAction == "view" || programAction == "View") { // View method ViewMethod.View(); return(continueRun); } else if (programAction == "delete" || programAction == "Delete") { // Delete method DeleteMethod.Delete(); return(continueRun); } else if (programAction == "exit" || programAction == "Exit") { // Exit program continueRun = false; return(continueRun); } else { // Show error, return to loop Console.WriteLine("Command not found."); Console.WriteLine(); return(continueRun); } }
public DeleteResult <int> Execute(int userPK, DeleteMethod deleteMethod) { tblM_User user = Db.tblM_User.Find(userPK); if (user == null) { return(new DeleteResult <int>() { Success = false, Message = $"Id '{userPK}' is not found.", Record = user.User_PK }); } var deleteUserDetailResult = new UserDetailDeleteHandler(Db, User).Execute(user.UserDetail_FK, deleteMethod); if (deleteUserDetailResult.Success) { switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(user); break; case DeleteMethod.Hard: HardDelete(user); break; default: break; } Db.SaveChanges(); } return(new DeleteResult <int>() { Success = true, Message = $"User with Id '{userPK}' successfully deleted.", Record = user.User_PK }); }
private void HandleDeleteMethod(DeleteMethod deleteMethod) { Result deletionResult = _repository.DeleteMethod(deleteMethod); if (deletionResult.IsFailure) { MethodDeletionFailed failedMethodDeletion = new MethodDeletionFailed( deletionResult.Error, deleteMethod.LoggedInUserId, deleteMethod.SagaId ); _kafkaProducer.Produce(failedMethodDeletion, METHODS_TOPIC); return; } MethodDeleted deletedMethod = new MethodDeleted(deleteMethod.Id, deleteMethod.LoggedInUserId, deleteMethod.SagaId); _kafkaProducer.Produce(deletedMethod, METHODS_TOPIC); }
public DeleteResult <tblM_BTS> Execute(int btsPK, DeleteMethod deleteMethod) { tblM_BTS bts = Db.tblM_BTS.Find(btsPK); if (bts == null) { return(new DeleteResult <tblM_BTS>() { Success = false, Message = $"Id '{btsPK}' is not found.", Record = null }); } DeleteBTSTechnologies(btsPK); switch (deleteMethod) { case DeleteMethod.Soft: BTSSoftDelete(bts); break; case DeleteMethod.Hard: BTSHardDelete(bts); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_BTS>() { Success = true, Message = $"BTS with Id '{btsPK}' successfully deleted.", Record = bts }); }
public DeleteResult <tblM_Aset> Execute(int asetPK, DeleteMethod deleteMethod) { tblM_Aset aset = Db.tblM_Aset.Find(asetPK); if (aset == null) { return(new DeleteResult <tblM_Aset>() { Success = false, Message = $"Id '{asetPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(aset); break; case DeleteMethod.Hard: HardDelete(aset); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_Aset>() { Success = true, Message = $"Aset with Id '{asetPK}' successfully deleted.", Record = aset }); }
public DeleteResult <tblM_Cabang> Execute(int cabangPK, DeleteMethod deleteMethod) { tblM_Cabang cabang = Db.tblM_Cabang.Find(cabangPK); if (cabang == null) { return(new DeleteResult <tblM_Cabang>() { Success = false, Message = $"Id '{cabangPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(cabang); break; case DeleteMethod.Hard: HardDelete(cabang); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_Cabang>() { Success = true, Message = $"Cabang with Id '{cabangPK}' successfully deleted.", Record = cabang }); }
public DeleteResult <tblM_Menu> Execute(int menuPK, DeleteMethod deleteMethod) { tblM_Menu menu = Db.tblM_Menu.Find(menuPK); if (menu == null) { return(new DeleteResult <tblM_Menu>() { Success = false, Message = $"Id '{menuPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(menu); break; case DeleteMethod.Hard: HardDelete(menu); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_Menu>() { Success = true, Message = $"Menu with Id '{menuPK}' successfully deleted.", Record = menu }); }
public DeleteResult <tblM_DeliveryArea> Execute(int deliveryAreaPK, DeleteMethod deleteMethod) { tblM_DeliveryArea deliveryArea = Db.tblM_DeliveryArea.Find(deliveryAreaPK); if (deliveryArea == null) { return(new DeleteResult <tblM_DeliveryArea>() { Success = false, Message = $"Id '{deliveryAreaPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(deliveryArea); break; case DeleteMethod.Hard: HardDelete(deliveryArea); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_DeliveryArea>() { Success = true, Message = $"DeliveryArea with Id '{deliveryAreaPK}' successfully deleted.", Record = deliveryArea }); }
public DeleteResult <tblM_IssueType> Execute(int issueTypePK, DeleteMethod deleteMethod) { tblM_IssueType issueType = Db.tblM_IssueType.Find(issueTypePK); if (issueType == null) { return(new DeleteResult <tblM_IssueType>() { Success = false, Message = $"Id '{issueTypePK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(issueType); break; case DeleteMethod.Hard: HardDelete(issueType); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_IssueType>() { Success = true, Message = $"IssueType with Id '{issueTypePK}' successfully deleted.", Record = issueType }); }
public DeleteResult <tblM_CostKategori> Execute(int costKategoriPK, DeleteMethod deleteMethod) { tblM_CostKategori costKategori = Db.tblM_CostKategori.Find(costKategoriPK); if (costKategori == null) { return(new DeleteResult <tblM_CostKategori>() { Success = false, Message = $"Id '{costKategoriPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(costKategori); break; case DeleteMethod.Hard: HardDelete(costKategori); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_CostKategori>() { Success = true, Message = $"CostKategori with Id '{costKategoriPK}' successfully deleted.", Record = costKategori }); }
public DeleteResult <int> Execute(int po_PK, DeleteMethod deleteMethod) { tblT_PO po = Db.tblT_PO.Find(po_PK); if (po == null) { return(new DeleteResult <int>() { Success = false, Message = $"Id '{po_PK}' is not found.", Record = po.PO_PK }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(po); break; case DeleteMethod.Hard: HardDelete(po); break; default: break; } Db.SaveChanges(); return(new DeleteResult <int>() { Success = true, Message = $"PO with Id '{po_PK}' successfully deleted.", Record = po.PO_PK }); }
public DeleteResult <tblM_RoleGroup> Execute(int roleGroupPK, DeleteMethod deleteMethod) { tblM_RoleGroup roleGroup = Db.tblM_RoleGroup.Find(roleGroupPK); if (roleGroup == null) { return(new DeleteResult <tblM_RoleGroup>() { Success = false, Message = $"Id '{roleGroupPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(roleGroup); break; case DeleteMethod.Hard: HardDelete(roleGroup); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_RoleGroup>() { Success = true, Message = $"RoleGroup with Id '{roleGroupPK}' successfully deleted.", Record = roleGroup }); }
public DeleteResult <tblM_Operator> Execute(int _operatorPK, DeleteMethod deleteMethod) { tblM_Operator _operator = Db.tblM_Operator.Find(_operatorPK); if (_operator == null) { return(new DeleteResult <tblM_Operator>() { Success = false, Message = $"Id '{_operatorPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(_operator); break; case DeleteMethod.Hard: HardDelete(_operator); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_Operator>() { Success = true, Message = $"Operator with Id '{_operatorPK}' successfully deleted.", Record = _operator }); }
public DeleteResult <tblM_BTSTechnology> Execute(int btsTechnologyPK, DeleteMethod deleteMethod) { tblM_BTSTechnology btsTechnology = Db.tblM_BTSTechnology.Find(btsTechnologyPK); if (btsTechnology == null) { return(new DeleteResult <tblM_BTSTechnology>() { Success = false, Message = $"Id '{btsTechnologyPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(btsTechnology); break; case DeleteMethod.Hard: HardDelete(btsTechnology); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_BTSTechnology>() { Success = true, Message = $"BTSTechnology with Id '{btsTechnologyPK}' successfully deleted.", Record = btsTechnology }); }
public DeleteResult <tblM_UserDetail> Execute(int userDetailPK, DeleteMethod deleteMethod) { tblM_UserDetail userDetail = Db.tblM_UserDetail.Find(userDetailPK); if (userDetail == null) { return(new DeleteResult <tblM_UserDetail>() { Success = false, Message = $"Id '{userDetailPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(userDetail); break; case DeleteMethod.Hard: HardDelete(userDetail); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_UserDetail>() { Success = true, Message = $"UserDetail with Id '{userDetailPK}' successfully deleted.", Record = userDetail }); }
public DeleteResult <tblM_TipePekerjaan> Execute(int tipePekerjaanPK, DeleteMethod deleteMethod) { tblM_TipePekerjaan tipePekerjaan = Db.tblM_TipePekerjaan.Find(tipePekerjaanPK); if (tipePekerjaan == null) { return(new DeleteResult <tblM_TipePekerjaan>() { Success = false, Message = $"Id '{tipePekerjaanPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(tipePekerjaan); break; case DeleteMethod.Hard: HardDelete(tipePekerjaan); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_TipePekerjaan>() { Success = true, Message = $"TipePekerjaan with Id '{tipePekerjaanPK}' successfully deleted.", Record = tipePekerjaan }); }
public DeleteResult <tblT_SOWTrack> Execute(int sowTrackPK, DeleteMethod deleteMethod) { tblT_SOWTrack sowTrack = Db.tblT_SOWTrack.Find(sowTrackPK); if (sowTrack == null) { return(new DeleteResult <tblT_SOWTrack>() { Success = false, Message = $"Id '{sowTrackPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(sowTrack); break; case DeleteMethod.Hard: HardDelete(sowTrack); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblT_SOWTrack>() { Success = true, Message = $"SOWTrack with Id '{sowTrackPK}' successfully deleted.", Record = sowTrack }); }
public DeleteResult <tblT_CheckIn> Execute(int checkInPK, DeleteMethod deleteMethod) { tblT_CheckIn checkIn = Db.tblT_CheckIn.Find(checkInPK); if (checkIn == null) { return(new DeleteResult <tblT_CheckIn>() { Success = false, Message = $"Id '{checkInPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(checkIn); break; case DeleteMethod.Hard: HardDelete(checkIn); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblT_CheckIn>() { Success = true, Message = $"CheckIn with Id '{checkInPK}' successfully deleted.", Record = checkIn }); }
public DeleteResult <tblT_IzinCuti> Execute(int izinCutiPK, DeleteMethod deleteMethod) { tblT_IzinCuti izinCuti = Db.tblT_IzinCuti.Find(izinCutiPK); if (izinCuti == null) { return(new DeleteResult <tblT_IzinCuti>() { Success = false, Message = $"Id '{izinCutiPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(izinCuti); break; case DeleteMethod.Hard: HardDelete(izinCuti); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblT_IzinCuti>() { Success = true, Message = $"IzinCuti with Id '{izinCutiPK}' successfully deleted.", Record = izinCuti }); }
private static int deleteDesejo(Desejo desejo, DeleteMethod metodo) { SqlConnection conn = null; SqlCommand cmd = null; SqlTransaction trans = null; String strSql; try { conn = new SqlConnection(ConnString); conn.Open(); cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; trans = conn.BeginTransaction(); cmd.Transaction = trans; if (metodo == DeleteMethod.PHYSICAL_DELETION) { strSql = "UPDATE Desejo set id_proposta_aceita = NULL where id_desejo = " + desejo.IdDesejo.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Mensagem where id_proposta IN (SELECT id_proposta from Proposta where id_desejo = " + desejo.IdDesejo.ToString(); strSql += ")"; cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Proposta where id_desejo = " + desejo.IdDesejo.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Avaliacao where id_proposta IN (SELECT id_proposta from Proposta where id_desejo = " + desejo.IdDesejo.ToString(); strSql += ")"; cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from URLDesejo where id_desejo = " + desejo.IdDesejo.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Desejo where id_desejo = " + desejo.IdDesejo.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); trans.Commit(); return 0;//sucesso }//if else { strSql = "UPDATE Desejo set is_deleted_desejo = 1 where id_desejo = " + desejo.IdDesejo.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); trans.Commit(); return 0;//sucesso }//else } catch { trans.Rollback(); return 1;//erro } finally { if (conn != null) conn.Close(); } }//deleteDesejo()
static WmiNetUtilsHelper() { IntPtr zero = IntPtr.Zero; IntPtr hModule = IntPtr.Zero; hModule = LoadLibrary(myDllPath); if (hModule != IntPtr.Zero) { zero = GetProcAddress(hModule, "ResetSecurity"); if (zero != IntPtr.Zero) { ResetSecurity_f = (ResetSecurity)Marshal.GetDelegateForFunctionPointer(zero, typeof(ResetSecurity)); } zero = GetProcAddress(hModule, "SetSecurity"); if (zero != IntPtr.Zero) { SetSecurity_f = (SetSecurity)Marshal.GetDelegateForFunctionPointer(zero, typeof(SetSecurity)); } zero = GetProcAddress(hModule, "BlessIWbemServices"); if (zero != IntPtr.Zero) { BlessIWbemServices_f = (BlessIWbemServices)Marshal.GetDelegateForFunctionPointer(zero, typeof(BlessIWbemServices)); } zero = GetProcAddress(hModule, "BlessIWbemServicesObject"); if (zero != IntPtr.Zero) { BlessIWbemServicesObject_f = (BlessIWbemServicesObject)Marshal.GetDelegateForFunctionPointer(zero, typeof(BlessIWbemServicesObject)); } zero = GetProcAddress(hModule, "GetPropertyHandle"); if (zero != IntPtr.Zero) { GetPropertyHandle_f27 = (GetPropertyHandle)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetPropertyHandle)); } zero = GetProcAddress(hModule, "WritePropertyValue"); if (zero != IntPtr.Zero) { WritePropertyValue_f28 = (WritePropertyValue)Marshal.GetDelegateForFunctionPointer(zero, typeof(WritePropertyValue)); } zero = GetProcAddress(hModule, "Clone"); if (zero != IntPtr.Zero) { Clone_f12 = (Clone)Marshal.GetDelegateForFunctionPointer(zero, typeof(Clone)); } zero = GetProcAddress(hModule, "VerifyClientKey"); if (zero != IntPtr.Zero) { VerifyClientKey_f = (VerifyClientKey)Marshal.GetDelegateForFunctionPointer(zero, typeof(VerifyClientKey)); } zero = GetProcAddress(hModule, "GetQualifierSet"); if (zero != IntPtr.Zero) { GetQualifierSet_f = (GetQualifierSet)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetQualifierSet)); } zero = GetProcAddress(hModule, "Get"); if (zero != IntPtr.Zero) { Get_f = (Get)Marshal.GetDelegateForFunctionPointer(zero, typeof(Get)); } zero = GetProcAddress(hModule, "Put"); if (zero != IntPtr.Zero) { Put_f = (Put)Marshal.GetDelegateForFunctionPointer(zero, typeof(Put)); } zero = GetProcAddress(hModule, "Delete"); if (zero != IntPtr.Zero) { Delete_f = (Delete)Marshal.GetDelegateForFunctionPointer(zero, typeof(Delete)); } zero = GetProcAddress(hModule, "GetNames"); if (zero != IntPtr.Zero) { GetNames_f = (GetNames)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetNames)); } zero = GetProcAddress(hModule, "BeginEnumeration"); if (zero != IntPtr.Zero) { BeginEnumeration_f = (BeginEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(BeginEnumeration)); } zero = GetProcAddress(hModule, "Next"); if (zero != IntPtr.Zero) { Next_f = (Next)Marshal.GetDelegateForFunctionPointer(zero, typeof(Next)); } zero = GetProcAddress(hModule, "EndEnumeration"); if (zero != IntPtr.Zero) { EndEnumeration_f = (EndEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(EndEnumeration)); } zero = GetProcAddress(hModule, "GetPropertyQualifierSet"); if (zero != IntPtr.Zero) { GetPropertyQualifierSet_f = (GetPropertyQualifierSet)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetPropertyQualifierSet)); } zero = GetProcAddress(hModule, "Clone"); if (zero != IntPtr.Zero) { Clone_f = (Clone)Marshal.GetDelegateForFunctionPointer(zero, typeof(Clone)); } zero = GetProcAddress(hModule, "GetObjectText"); if (zero != IntPtr.Zero) { GetObjectText_f = (GetObjectText)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetObjectText)); } zero = GetProcAddress(hModule, "SpawnDerivedClass"); if (zero != IntPtr.Zero) { SpawnDerivedClass_f = (SpawnDerivedClass)Marshal.GetDelegateForFunctionPointer(zero, typeof(SpawnDerivedClass)); } zero = GetProcAddress(hModule, "SpawnInstance"); if (zero != IntPtr.Zero) { SpawnInstance_f = (SpawnInstance)Marshal.GetDelegateForFunctionPointer(zero, typeof(SpawnInstance)); } zero = GetProcAddress(hModule, "CompareTo"); if (zero != IntPtr.Zero) { CompareTo_f = (CompareTo)Marshal.GetDelegateForFunctionPointer(zero, typeof(CompareTo)); } zero = GetProcAddress(hModule, "GetPropertyOrigin"); if (zero != IntPtr.Zero) { GetPropertyOrigin_f = (GetPropertyOrigin)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetPropertyOrigin)); } zero = GetProcAddress(hModule, "InheritsFrom"); if (zero != IntPtr.Zero) { InheritsFrom_f = (InheritsFrom)Marshal.GetDelegateForFunctionPointer(zero, typeof(InheritsFrom)); } zero = GetProcAddress(hModule, "GetMethod"); if (zero != IntPtr.Zero) { GetMethod_f = (GetMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetMethod)); } zero = GetProcAddress(hModule, "PutMethod"); if (zero != IntPtr.Zero) { PutMethod_f = (PutMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(PutMethod)); } zero = GetProcAddress(hModule, "DeleteMethod"); if (zero != IntPtr.Zero) { DeleteMethod_f = (DeleteMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(DeleteMethod)); } zero = GetProcAddress(hModule, "BeginMethodEnumeration"); if (zero != IntPtr.Zero) { BeginMethodEnumeration_f = (BeginMethodEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(BeginMethodEnumeration)); } zero = GetProcAddress(hModule, "NextMethod"); if (zero != IntPtr.Zero) { NextMethod_f = (NextMethod)Marshal.GetDelegateForFunctionPointer(zero, typeof(NextMethod)); } zero = GetProcAddress(hModule, "EndMethodEnumeration"); if (zero != IntPtr.Zero) { EndMethodEnumeration_f = (EndMethodEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(EndMethodEnumeration)); } zero = GetProcAddress(hModule, "GetMethodQualifierSet"); if (zero != IntPtr.Zero) { GetMethodQualifierSet_f = (GetMethodQualifierSet)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetMethodQualifierSet)); } zero = GetProcAddress(hModule, "GetMethodOrigin"); if (zero != IntPtr.Zero) { GetMethodOrigin_f = (GetMethodOrigin)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetMethodOrigin)); } zero = GetProcAddress(hModule, "QualifierSet_Get"); if (zero != IntPtr.Zero) { QualifierGet_f = (QualifierSet_Get)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Get)); } zero = GetProcAddress(hModule, "QualifierSet_Put"); if (zero != IntPtr.Zero) { QualifierPut_f = (QualifierSet_Put)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Put)); } zero = GetProcAddress(hModule, "QualifierSet_Delete"); if (zero != IntPtr.Zero) { QualifierDelete_f = (QualifierSet_Delete)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Delete)); } zero = GetProcAddress(hModule, "QualifierSet_GetNames"); if (zero != IntPtr.Zero) { QualifierGetNames_f = (QualifierSet_GetNames)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_GetNames)); } zero = GetProcAddress(hModule, "QualifierSet_BeginEnumeration"); if (zero != IntPtr.Zero) { QualifierBeginEnumeration_f = (QualifierSet_BeginEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_BeginEnumeration)); } zero = GetProcAddress(hModule, "QualifierSet_Next"); if (zero != IntPtr.Zero) { QualifierNext_f = (QualifierSet_Next)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_Next)); } zero = GetProcAddress(hModule, "QualifierSet_EndEnumeration"); if (zero != IntPtr.Zero) { QualifierEndEnumeration_f = (QualifierSet_EndEnumeration)Marshal.GetDelegateForFunctionPointer(zero, typeof(QualifierSet_EndEnumeration)); } zero = GetProcAddress(hModule, "GetCurrentApartmentType"); if (zero != IntPtr.Zero) { GetCurrentApartmentType_f = (GetCurrentApartmentType)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetCurrentApartmentType)); } zero = GetProcAddress(hModule, "GetDemultiplexedStub"); if (zero != IntPtr.Zero) { GetDemultiplexedStub_f = (GetDemultiplexedStub)Marshal.GetDelegateForFunctionPointer(zero, typeof(GetDemultiplexedStub)); } zero = GetProcAddress(hModule, "CreateInstanceEnumWmi"); if (zero != IntPtr.Zero) { CreateInstanceEnumWmi_f = (CreateInstanceEnumWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(CreateInstanceEnumWmi)); } zero = GetProcAddress(hModule, "CreateClassEnumWmi"); if (zero != IntPtr.Zero) { CreateClassEnumWmi_f = (CreateClassEnumWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(CreateClassEnumWmi)); } zero = GetProcAddress(hModule, "ExecQueryWmi"); if (zero != IntPtr.Zero) { ExecQueryWmi_f = (ExecQueryWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(ExecQueryWmi)); } zero = GetProcAddress(hModule, "ExecNotificationQueryWmi"); if (zero != IntPtr.Zero) { ExecNotificationQueryWmi_f = (ExecNotificationQueryWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(ExecNotificationQueryWmi)); } zero = GetProcAddress(hModule, "PutInstanceWmi"); if (zero != IntPtr.Zero) { PutInstanceWmi_f = (PutInstanceWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(PutInstanceWmi)); } zero = GetProcAddress(hModule, "PutClassWmi"); if (zero != IntPtr.Zero) { PutClassWmi_f = (PutClassWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(PutClassWmi)); } zero = GetProcAddress(hModule, "CloneEnumWbemClassObject"); if (zero != IntPtr.Zero) { CloneEnumWbemClassObject_f = (CloneEnumWbemClassObject)Marshal.GetDelegateForFunctionPointer(zero, typeof(CloneEnumWbemClassObject)); } zero = GetProcAddress(hModule, "ConnectServerWmi"); if (zero != IntPtr.Zero) { ConnectServerWmi_f = (ConnectServerWmi)Marshal.GetDelegateForFunctionPointer(zero, typeof(ConnectServerWmi)); } } }
public DeleteResult <tblM_MappingUserToAuthParam> Execute(int authParamPk, int userPk, DeleteMethod deleteMethod) { tblM_MappingUserToAuthParam mappingUserToAuthParam = Db.tblM_MappingUserToAuthParam.Find(userPk, authParamPk); if (mappingUserToAuthParam == null) { return(new DeleteResult <tblM_MappingUserToAuthParam>() { Success = false, Message = $"Id '{authParamPk} and {userPk}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(mappingUserToAuthParam); break; case DeleteMethod.Hard: HardDelete(mappingUserToAuthParam); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_MappingUserToAuthParam>() { Success = true, Message = $"User member of role group successfully deleted.", Record = mappingUserToAuthParam }); }
static WmiNetUtilsHelper() { myDllPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + "\\wminet_utils.dll"; IntPtr procAddr = IntPtr.Zero; IntPtr loadLibrary = IntPtr.Zero; loadLibrary = LoadLibrary(myDllPath); if( loadLibrary != IntPtr.Zero) { procAddr = GetProcAddress(loadLibrary, "ResetSecurity"); if( procAddr != IntPtr.Zero) { ResetSecurity_f =(ResetSecurity) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ResetSecurity)); } procAddr = GetProcAddress(loadLibrary, "SetSecurity"); if( procAddr != IntPtr.Zero) { SetSecurity_f =(SetSecurity) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(SetSecurity)); } procAddr = GetProcAddress(loadLibrary, "BlessIWbemServices"); if( procAddr != IntPtr.Zero) { BlessIWbemServices_f =(BlessIWbemServices) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BlessIWbemServices)); } procAddr = GetProcAddress(loadLibrary, "BlessIWbemServicesObject"); if( procAddr != IntPtr.Zero) { BlessIWbemServicesObject_f =(BlessIWbemServicesObject) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BlessIWbemServicesObject)); } procAddr = GetProcAddress(loadLibrary, "GetPropertyHandle"); if( procAddr != IntPtr.Zero) { GetPropertyHandle_f27=(GetPropertyHandle) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetPropertyHandle)); } procAddr = GetProcAddress(loadLibrary, "WritePropertyValue"); if( procAddr != IntPtr.Zero) { WritePropertyValue_f28=(WritePropertyValue) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(WritePropertyValue)); } procAddr = GetProcAddress(loadLibrary, "Clone"); if( procAddr != IntPtr.Zero) { Clone_f12=(Clone) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Clone)); } procAddr = GetProcAddress(loadLibrary, "VerifyClientKey"); if( procAddr != IntPtr.Zero) { VerifyClientKey_f =(VerifyClientKey) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(VerifyClientKey)); } procAddr = GetProcAddress(loadLibrary, "GetQualifierSet"); if( procAddr != IntPtr.Zero) { GetQualifierSet_f =(GetQualifierSet) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetQualifierSet)); } procAddr = GetProcAddress(loadLibrary, "Get"); if( procAddr != IntPtr.Zero) { Get_f =(Get) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Get)); } procAddr = GetProcAddress(loadLibrary, "Put"); if( procAddr != IntPtr.Zero) { Put_f =(Put) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Put)); } procAddr = GetProcAddress(loadLibrary, "Delete"); if( procAddr != IntPtr.Zero) { Delete_f =(Delete) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Delete)); } procAddr = GetProcAddress(loadLibrary, "GetNames"); if( procAddr != IntPtr.Zero) { GetNames_f =(GetNames) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetNames)); } procAddr = GetProcAddress(loadLibrary, "BeginEnumeration"); if( procAddr != IntPtr.Zero) { BeginEnumeration_f =(BeginEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BeginEnumeration)); } procAddr = GetProcAddress(loadLibrary, "Next"); if( procAddr != IntPtr.Zero) { Next_f =(Next) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Next)); } procAddr = GetProcAddress(loadLibrary, "EndEnumeration"); if( procAddr != IntPtr.Zero) { EndEnumeration_f =(EndEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(EndEnumeration)); } procAddr = GetProcAddress(loadLibrary, "GetPropertyQualifierSet"); if( procAddr != IntPtr.Zero) { GetPropertyQualifierSet_f =(GetPropertyQualifierSet) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetPropertyQualifierSet)); } procAddr = GetProcAddress(loadLibrary, "Clone"); if( procAddr != IntPtr.Zero) { Clone_f =(Clone) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(Clone)); } procAddr = GetProcAddress(loadLibrary, "GetObjectText"); if( procAddr != IntPtr.Zero) { GetObjectText_f =(GetObjectText) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetObjectText)); } procAddr = GetProcAddress(loadLibrary, "SpawnDerivedClass"); if( procAddr != IntPtr.Zero) { SpawnDerivedClass_f =(SpawnDerivedClass) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(SpawnDerivedClass)); } procAddr = GetProcAddress(loadLibrary, "SpawnInstance"); if( procAddr != IntPtr.Zero) { SpawnInstance_f =(SpawnInstance) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(SpawnInstance)); } procAddr = GetProcAddress(loadLibrary, "CompareTo"); if( procAddr != IntPtr.Zero) { CompareTo_f =(CompareTo) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CompareTo)); } procAddr = GetProcAddress(loadLibrary, "GetPropertyOrigin"); if( procAddr != IntPtr.Zero) { GetPropertyOrigin_f =(GetPropertyOrigin) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetPropertyOrigin)); } procAddr = GetProcAddress(loadLibrary, "InheritsFrom"); if( procAddr != IntPtr.Zero) { InheritsFrom_f =(InheritsFrom) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(InheritsFrom)); } procAddr = GetProcAddress(loadLibrary, "GetMethod"); if( procAddr != IntPtr.Zero) { GetMethod_f =(GetMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetMethod)); } procAddr = GetProcAddress(loadLibrary, "PutMethod"); if( procAddr != IntPtr.Zero) { PutMethod_f =(PutMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(PutMethod)); } procAddr = GetProcAddress(loadLibrary, "DeleteMethod"); if( procAddr != IntPtr.Zero) { DeleteMethod_f =(DeleteMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(DeleteMethod)); } procAddr = GetProcAddress(loadLibrary, "BeginMethodEnumeration"); if( procAddr != IntPtr.Zero) { BeginMethodEnumeration_f =(BeginMethodEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(BeginMethodEnumeration)); } procAddr = GetProcAddress(loadLibrary, "NextMethod"); if( procAddr != IntPtr.Zero) { NextMethod_f =(NextMethod) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(NextMethod)); } procAddr = GetProcAddress(loadLibrary, "EndMethodEnumeration"); if( procAddr != IntPtr.Zero) { EndMethodEnumeration_f =(EndMethodEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(EndMethodEnumeration)); } procAddr = GetProcAddress(loadLibrary, "GetMethodQualifierSet"); if( procAddr != IntPtr.Zero) { GetMethodQualifierSet_f =(GetMethodQualifierSet) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetMethodQualifierSet)); } procAddr = GetProcAddress(loadLibrary, "GetMethodOrigin"); if( procAddr != IntPtr.Zero) { GetMethodOrigin_f =(GetMethodOrigin) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetMethodOrigin)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Get"); if( procAddr != IntPtr.Zero) { QualifierGet_f=(QualifierSet_Get) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Get)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Put"); if( procAddr != IntPtr.Zero) { QualifierPut_f=(QualifierSet_Put) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Put)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Delete"); if( procAddr != IntPtr.Zero) { QualifierDelete_f=(QualifierSet_Delete) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Delete)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_GetNames"); if( procAddr != IntPtr.Zero) { QualifierGetNames_f=(QualifierSet_GetNames) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_GetNames)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_BeginEnumeration"); if( procAddr != IntPtr.Zero) { QualifierBeginEnumeration_f=(QualifierSet_BeginEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_BeginEnumeration)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_Next"); if( procAddr != IntPtr.Zero) { QualifierNext_f=(QualifierSet_Next) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_Next)); } procAddr = GetProcAddress(loadLibrary, "QualifierSet_EndEnumeration"); if( procAddr != IntPtr.Zero) { QualifierEndEnumeration_f=(QualifierSet_EndEnumeration) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(QualifierSet_EndEnumeration)); } procAddr = GetProcAddress(loadLibrary, "GetCurrentApartmentType"); if( procAddr != IntPtr.Zero) { GetCurrentApartmentType_f =(GetCurrentApartmentType) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetCurrentApartmentType)); } procAddr = GetProcAddress(loadLibrary, "GetDemultiplexedStub"); if( procAddr != IntPtr.Zero) { GetDemultiplexedStub_f =(GetDemultiplexedStub) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(GetDemultiplexedStub)); } procAddr = GetProcAddress(loadLibrary, "CreateInstanceEnumWmi"); if( procAddr != IntPtr.Zero) { CreateInstanceEnumWmi_f =(CreateInstanceEnumWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CreateInstanceEnumWmi)); } procAddr = GetProcAddress(loadLibrary, "CreateClassEnumWmi"); if( procAddr != IntPtr.Zero) { CreateClassEnumWmi_f =(CreateClassEnumWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CreateClassEnumWmi)); } procAddr = GetProcAddress(loadLibrary, "ExecQueryWmi"); if( procAddr != IntPtr.Zero) { ExecQueryWmi_f =(ExecQueryWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ExecQueryWmi)); } procAddr = GetProcAddress(loadLibrary, "ExecNotificationQueryWmi"); if( procAddr != IntPtr.Zero) { ExecNotificationQueryWmi_f =(ExecNotificationQueryWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ExecNotificationQueryWmi)); } procAddr = GetProcAddress(loadLibrary, "PutInstanceWmi"); if( procAddr != IntPtr.Zero) { PutInstanceWmi_f =(PutInstanceWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(PutInstanceWmi)); } procAddr = GetProcAddress(loadLibrary, "PutClassWmi"); if( procAddr != IntPtr.Zero) { PutClassWmi_f =(PutClassWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(PutClassWmi)); } procAddr = GetProcAddress(loadLibrary, "CloneEnumWbemClassObject"); if( procAddr != IntPtr.Zero) { CloneEnumWbemClassObject_f =(CloneEnumWbemClassObject) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(CloneEnumWbemClassObject)); } procAddr = GetProcAddress(loadLibrary, "ConnectServerWmi"); if( procAddr != IntPtr.Zero) { ConnectServerWmi_f =(ConnectServerWmi) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(ConnectServerWmi)); } } }
private static int deleteProposta(long idProposta, DeleteMethod metodo) { SqlConnection conn = null; SqlCommand cmd = null; SqlTransaction trans = null; SqlDataReader dr = null; String strSql; try { conn = new SqlConnection(ConnString); conn.Open(); cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; trans = conn.BeginTransaction(); cmd.Transaction = trans; if (metodo == DeleteMethod.PHYSICAL_DELETION) { //faço um select pra dar lock na proposta e evitar deadlocks: strSql = "SELECT id_proposta FROM Proposta where id_proposta = " + idProposta.ToString(); cmd.CommandText = strSql; dr = cmd.ExecuteReader(); dr.Read(); dr.Close(); strSql = "UPDATE Desejo set id_proposta_aceita = NULL where id_proposta_aceita = " + idProposta.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Mensagem where id_proposta = " + idProposta.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Avaliacao where id_proposta = " + idProposta.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); strSql = "DELETE from Proposta where id_proposta = " + idProposta.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); trans.Commit(); return 0;//sucesso } else { strSql = "UPDATE Proposta set is_deleted_proposta = 1 where id_proposta = " + idProposta.ToString(); cmd.CommandText = strSql; cmd.ExecuteNonQuery(); trans.Commit(); return 0; } } catch { if (dr != null) dr.Close(); trans.Rollback(); return 1;//erro } finally { if (conn != null) conn.Close(); } }//deleteProposta()