When attempting to validate a journal I use the LedgerJournalEngine ErrorExists for each voucher in the journal. For some reason it doesn't catch all errors in the code but if I use the validate button in the client the errors are in the info log.
Is there a better way to validate a voucher in a journal?
changecompany(ledgerJournalTable.dataAreaId)
{
ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes,NoYes::No);
lje = LedgerJournalEngine::construct(ledgerJournalTable.JournalType);
lje.newJournalActive(ledgerJournalTable,true);
ledgerJournalCheckPost.parmLedgerJournalEngine(lje);
try
{
ledgerJournalCheckPost.run();
}
catch
{
ledgerJournalCheckPost.validate();
while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
{
if(lje.errorExists(ledgerJournalTrans.Voucher))
{
errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
}
}
}
}
So this is what I have come up with, so far it seems to be working as expected. If anyone has a better way please let me know.
changecompany(ledgerJournalTable.dataAreaId)
{
ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::No);
lje = LedgerJournalEngine::construct(ledgerJournalTable.JournalType);
lje.newJournalActive(ledgerJournalTable,true);
ledgerJournalCheckPost.parmLedgerJournalEngine(lje);
try
{
ledgerJournalCheckPost.run();
while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
{
if(lje.errorInJournal() || ledgerJournalCheckPost.numOfErrorsInList()>0)
{
errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
}
}
ledgerJournalCheckPost.parmPost(NoYes::Yes);
ledgerJournalCheckPost.run();
}
catch
{
ledgerJournalCheckPost.validate();
while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
{
if(lje.errorInJournal() || ledgerJournalCheckPost.numOfErrorsInList()>0)
{
errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
}
}
}
ledgerJournalCheckPost = null;
lje = null;
ledgerJournalTrans = null;
ledgerJOurnalTable = null;
}
return errors;
Related
I am trying to programmatically send a Mail/Task/Appointment to a user and I have the problem, that every time I send them the first one will get stuck in my outbox... It seems that the first one sent to Outlook has no/looses its sent-date and will stay forever in my outbox.
Here is the code for example "sending a task notification"
using (MapiSession session = new MapiSession())
{
var item = session.CreateItem(Outlook.OlItemType.olTaskItem) as RDOTaskItem;
[..]
try
{
item.Subject = "SUBJECT";
item.Body = "BODY;
item.StartDate = DateTime.Now;
item.DueDate = DateTime.Now;
item.Recipients.Add("test#mail.com");
item.Recipients.Add("test2#mail.com");
item.Recipients.ResolveAll();
item.Assign();
item.Save();
item.Send();
}
[..]
}
Thanks in advance.
So I am not really shure what is the problem so far...
If all receivers are other persons then myself this should work...
Here is my code for sendig a TaskItem
private void NotifyByTask(OutlookNotificationTypes notificationType)
{
Application app = new Application();
var item = app.CreateItem(OlItemType.olTaskItem) as TaskItem;
try
{
item.Subject = this.Subject;
item.Body = this.Body;
if (this.Start != DateTime.MinValue)
{
item.StartDate = this.Start;
item.ReminderSet = true;
item.ReminderPlaySound = true;
item.ReminderTime = this.Start.AddMinutes(-5);
}
if (this.End != DateTime.MinValue)
{
item.DueDate = this.End;
}
item.PercentComplete = this.PercentComplete;
StringBuilder categories = new StringBuilder();
foreach (String category in this.Categories)
{
categories.Append(category);
}
item.Categories = categories.ToString();
bool sendingToMyself = false;
if (this.NotificationType == OutlookNotificationTypes.TaskRequest)
{
// this will add all recipients and checks if Receiver is yourself
sendingToMyself = item.AddRecipients(this.Recipients, OlMailRecipientType.olTo);
}
if (this.NotificationType == OutlookNotificationTypes.TaskRequest
&& (!sendingToMyself))
{
item.Recipients.ResolveAll();
item.Assign();
item.Save();
item.Send();
}
else
{
item.Save();
//insert element
if (this.ItemSaved != null)
{
Microsoft.Office.Interop.Outlook.MAPIFolder folder =
item.Parent as Microsoft.Office.Interop.Outlook.MAPIFolder;
if (folder != null)
{
try
{
String storeId = folder.StoreID;
String entryId = item.EntryID;
this.ItemSaved(storeId, entryId);
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(folder);
}
}
}
}
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(item);
}
}
I have some old ugly code like this
if(!isLogin)
{
if(confirm("Login first ?"))
{
doLogin();
return;
}
else
{
doStuff1();
doStuff2();
doStuff3();
}
}
else
{
doStuff1();
doStuff2();
doStuff3();
}
For refactoring, here's what I did
if(!isLogin && confirm("Login first ?"))
{
doLogin();
}
else
{
doStuff1();
doStuff2();
doStuff3();
}
I'm not sure... is new code logic equals old part, and possible to make it shorter ?
You need to add return; after doLogin(); to be the same. You could drop the else { and } too, and unindent the three doStuff?() functions:
if (!isLogin && confirm("Login first ?"))
{
doLogin();
return;
}
doStuff1();
doStuff2();
doStuff3();
For HLK testing automation I would like to apply the compatplaylist on my test list.
Generell automation instruction, but no info how to apply a playlist.
One option is to modify the master test list based on the compatplaylist - both are xml based (with the help of Export-HwCertTestCollectionToXml and import-hwcerttestcollectionfromxml),
But maybe somebody already has a solution or knows an offical support for it.
Try this:-
public static PlaylistManager ApplyPlaylist(Project projectname, string playlistpath)
{
PlaylistManager pl_manager = null;
try
{
pl_manager = new PlaylistManager(projectname);
if (pl_manager == null)
Console.WriteLine("Cannot make playlist manager for the project:- {0}", projectname.Name.ToString());
if(pl_manager.IsPlaylistLoaded() == true)
{
Console.WriteLine("Playlist loaded.. unloading ");
pl_manager.UnloadPlaylist();
if (pl_manager.IsPlaylistLoaded() == false)
Console.WriteLine("Unloaded successfully");
}
else
{
if (File.Exists(playlistpath))
{
pl_manager.LoadPlaylist(playlistpath);
if (pl_manager.IsPlaylistLoaded() == false)
Console.WriteLine("Error in applying playlist:- {0}", playlistpath);
else
Console.WriteLine("Loaded playlist:- {0}", playlistpath);
}
else
{
Console.WriteLine("ERROR!Playlist file {0} not found!", playlistpath);
return pl_manager;
}
}
}
catch(Exception e)
{
Console.WriteLine("Exception:-{0}", e.ToString());
}
return pl_manager;
}
I am trying to convert my method to Async. I cannot seem to grasp converting a linq query or foreach loop into a form that is awaitable. I read here on SO that EntityFramework + Linq don’t mix very well asynchronously. Perhaps that is why I could not find a previous Question that matches my needs exactly. Would someone care to point me in the right direction?
private static async Task<decimal> GetLastPriceAsync(string customer, string stockNumber)
{
Debug.WriteLine("Get Last Price Called");
decimal lastCost = 0;
var lastDate = new DateTime(1900, 1, 1);
if (string.IsNullOrEmpty(customer))
{
Debug.WriteLine("There was no customer");
return 0;
}
Debug.WriteLine("We have a customer");
if (string.IsNullOrEmpty(stockNumber))
{
Debug.WriteLine("There was no item");
return 0;
}
Debug.WriteLine("We have a Part Number");
try
{
IEnumerable<SA_HistoryHeader> orders =
DContext.SA_HistoryHeader.Local.Where(c => c.strCustomer == customer);
if (!orders.Any())
{
Debug.WriteLine("No order found.");
return 0;
}
Debug.WriteLine("We have previous Orders Found");
foreach (SA_HistoryHeader thisOrder in orders)
{
Debug.WriteLine("Looping through orders.");
DateTime date = lastDate;
IEnumerable<SA_HistoryDetail> details = thisOrder.SA_HistoryDetail
.Where(i => i.strStock == stockNumber && i.dteLineDate > date && i.bytLineType == 003);
foreach (
SA_HistoryDetail detail in
details.Where(detail => detail != null && !string.IsNullOrEmpty(detail.strDescription)))
{
if (detail.dteLineDate != null)
{
lastDate = (DateTime) detail.dteLineDate;
}
else
{
Debug.WriteLine("Order Date was null");
}
if (detail.curUnitPrice != null)
{
lastCost = (decimal) detail.curUnitPrice;
}
else
{
Debug.WriteLine("Last Cost was null");
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine("Last Price Calc Error: " + ex.InnerException.Message);
}
return lastCost;
}
I have run into a few problems when trying to get the camera to work accordingly... The camera Demo Works on the 8520 device (Has a memory Card) but does not work on the 9780 device (Has No Memory Card) the error given
ERROR Class java.lang.ArrayOutOfBoundsException :index 0>=0
My code Sample:
public class MyScreen extends MainScreen{
Player _p;
VideoControl _videoControl;
FileConnection fileconn;
String PATH;
String GetfileName;
LabelField GetPhotofileName = new LabelField("",LabelField.FOCUSABLE){
protected boolean navigationClick(int status, int time){
Dialog.alert("Clicked");
return true;
}
};
public static boolean SdcardAvailabulity() {
String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
root = (String) e.nextElement();
if( root.equalsIgnoreCase("sdcard/") ) {
}else if( root.equalsIgnoreCase("store/") ) {
}
}
class MySDListener implements FileSystemListener {
public void rootChanged(int state, String rootName) {
if( state == ROOT_ADDED ) {
if( rootName.equalsIgnoreCase("sdcard/") ) {
}
} else if( state == ROOT_REMOVED ) {
}
}
}
return true;
}
protected boolean invokeAction(int action){
boolean handled = super.invokeAction(action);
if(SdcardAvailabulity()){
PATH = System.getProperty("fileconn.dir.memorycard.photos")+"Image_"+System.currentTimeMillis()+".jpg";//here "str" having the current Date and Time;
} else {
// PATH = System.getProperty("file:///store/home/user/pictures/")+"Image_"+System.currentTimeMillis()+".jpg";
PATH = System.getProperty("fileconn.dir.photos")+"Image_"+System.currentTimeMillis()+".jpg";
}
if(!handled){
if(action == ACTION_INVOKE){
try{
byte[] rawImage = _videoControl.getSnapshot(null);
System.out.println("----------1");
fileconn=(FileConnection)Connector.open(PATH);
System.out.println("----------2");
if(fileconn.exists()){
fileconn.delete();
System.out.println("----------3");
}
fileconn.create();
System.out.println("----------4");
OutputStream os=fileconn.openOutputStream();
System.out.println("----------5");
os.write(rawImage);
GetfileName =fileconn.getName();
System.out.println("----------6");
System.out.println("GetfileName----------"+GetfileName);
fileconn.close();
System.out.println("----------7");
os.close();
Status.show("Image is Captured",200);
GetPhotofileName.setText(GetfileName);
System.out.println("----------8");
if(_p!=null)
_p.close();
System.out.println("----------9");
}catch(Exception e){
if(_p!=null){
_p.close();
}
if(fileconn!=null){
try{
fileconn.close();
}catch (IOException e1){
//if the action is other than click the trackwheel(means go to the menu options) then we do nothing;
}
}
}
}
}
return handled;
}
public MyScreen(){
setTitle("Camera App");
try{
System.out.println("Debug------------10");
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
_p.realize();
_videoControl = (VideoControl) _p.getControl("VideoControl");
System.out.println("Debug------------11");
if (_videoControl != null){
Field videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
_videoControl.setDisplayFullScreen(true);
System.out.println("Debug------------12");
_videoControl.setVisible(true);
_p.start();
System.out.println("Debug------------13");
if(videoField != null){
add(videoField);
System.out.println("Debug------------14");
}
}
}catch(Exception e){
if(_p!=null) {
_p.close();
}
Dialog.alert(e.toString());
}
add(GetPhotofileName);
}
}
on the 8520 (Has a Memory Card) the code works fine on the 9780 (Has no Memory Card) the the code stops at "System.out.println("debug---1")", can anyone please tell me if you can see any problem with my code???
public static boolean SdcardAvailabulity() {
String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
root = (String) e.nextElement();
if( root.equalsIgnoreCase("sdcard/") ) {
return true;
}else if( root.equalsIgnoreCase("store/") ) {
return false;
}
}
class MySDListener implements FileSystemListener {
public void rootChanged(int state, String rootName) {
if( state == ROOT_ADDED ) {
if( rootName.equalsIgnoreCase("sdcard/") ) {
}
} else if( state == ROOT_REMOVED ) {
}
}
}
return true;
}
This is the sollution, My "SD card availability" code only returned true which caused the picture not to save when the blackberry had no memory card inserted. # Eugen Martynov Please read through the code and you will see it is there :)