goluda.pl

Nazywam się Paweł Goluda i witam na mojej stronie.
Strona służy prezentacji realizowanych przeze mnie projektów oraz szeroko pojętym moim wynurzeniom ;-D.

[software android] A little piece of SAP for Android

Since two months i'm a happy owner of HTC  Desire which is my first Android powered phone. In this time I had some of excercises for writing applications. Hmm - it is really hard for me because I'm not very friend of Java but if there is no other option... I'm planing to share a little with you about my small applications but this is for the future if I'll find some of free time to do it.

Today will be different topic.

While I was testing my device i discovered it as a very usefull business device, so i have made a try to do a small connection to SAP system. So now i want to share with you results of my work.

First - architecture

Application bases on two elements - one Android app as a GUI and second is a Proxy server which shares connection between SAP and my phone.

I choosed this architecture because of two reasons.

1. Because I dont know how to directly connect SAP from android, and i want to keep some data.

2. Using proxy server is much safer for SAP because user doesn't connect directly SAP and can call only this functions which proxy server serves to the user. It is also save because if you wish to use public network for this connection you don't need to open connections for your SAP server. It is hided behind of my proxy.

Second - idea

My idea is not complicated because it is only a presentation of technology - not a functional application - it is only "one hour study case". So the idea - application can search MARA table for part numbers starting from search string, next shows its list in a ListView. After list is filled then user can select application will search a details of this part which are 3 more example fields from this table.

Third - result

So here is a time for some screenshots.

First point is starting screen:

androidSAP1.PNG

On this screen user has to place searching data for his query - application will search all parts in a system which will starts from a searching string.

Result will looks like this screen:

androidSAP2.PNG

As you can see system has found a parts which maches searching string - in my example application it is searching only first 100 parts.

After selecting one of part and tap it user will see our "detials" window which in my example looks like this one:

androidSAP3.PNG

That's all

The end - conclusion

As i was trying to show you it is possible to use an Android device as a very nice SAP client - specialy if you will also connect it to barcode scanner. All what you need to know is a good knowledge what exactly you want to do. Using my methode you can do almost everything in SAP system - starting from reading tables and queries, calling bapis ending on calling batch input. It can be also very powerfull reporting tool for managers. Everything depends on your imagination.

If you will have a question just write a comment or contact me using contact formular

Please somone leave a comment because i don't know if someone is reading this :-(

[software] First contact with Visual Studio 2010 - no SQL Server 2010 support

This week Microsoft has released its new high cool and extra :) version of Visual Studio 2010. I was waiting for it from long time so i was very exited with it.

I was exited because of two reasons - new entities framerwork and new wpf (I finaly decided to play a little with it).

So Visual Studio 2010 looks very nice - some people tells me that they don't like a colors but it is no problem for me. I like a fonts - i don't like a performance. Microsoft promissed that they will improove a performance of beta version but i don't see this improovement. But doesn't matter - I have a fast laptop so i can work quite comfortable. So my general feelings are very good and I like a new design.

As you probably know - people who knows me better knows this very well - almost all my application uses databases. In fact my business applications works on different databases servers, specially (SQL Server, DB2, Oracle and MySQL), and here i found a very big problem. Microsoft decided to don't support an SQL 2000 in new Visual Studio. Hmm, great idea and I understand that it is very old product and they have a SQL Server 2005 and 2008 in offer but in my company the most important databases stays SQL Server 2000 and there is no plans to upgrade it to highier version now.

So I was extremly disappointed. But - i was supprised that projects converted from Visual Studio 2008 was working on Visual Studio 2010 so i started to think that limitation is only on designer tools not on connector itself. So I started to search internet about idea how to generate Entities Framework (this was interesting me most) and I found EdmGen wchich is a part of .net framework. Cool god place to start. I was testing it a little and it seams to be working. And - yes - it can generate files of sql server 2000 and also it is possible to use it in my project. Great - but EdmGen is a command line tool so is difficult to use. So I decided to create a small tool - only for me to generate a classes.

How tool works? very easy. You have to set connection settings to your server, next search a databases and select your, then enter project name and generate entities files with one button click. My application will start edmgen with necessary parameters and it will create a files. Then you have to add generated files to project and - that's all is working.

In your application you have to use a connection string but it is no problem - my application will tell you how it should be.

Ok, so entities framework classes is generated but i had a problem to use it in code - when i tried to use sub objects i had en exception about reader open - i don't know why this error exist - i'll search it later.

I'm a little bit familiar with Linq2Sql so i decided to check if i can generate dbml file in the same way, and - bingo!!! SqlMetal exist in framework 4 too and works with SQL Server 2000 so i extended my tool about usage of SqlMetal.

And usage is exac the same - you are setting connections click generate dbml button and all you have to do is to add generated file to your project, and also use a connection string.

voli.entitiesFrameworkGenerator.PNG

If you think this application can be usefull for you then feel free to download it

In my work we are all the time changing our database structures so it is i also addes feature to save and load settings - it is uses small xml files with definition of settings

If you will have any suggestions of work of application please use a comments to share it with me

[software] How to send parameters to an application started by ClickOnce

It is always very important question how to publish an application if we want to keep it updated on users pc. There is many update methods but my favorit is ClickOnce. I like it because of two basic reasons:

  1. it is integrated with Visual Studio and is very easy to use
  2. it works

I think it is not a right place to describe how it is working here but if you are interested, just let me know in comments and i'll prepare short description how to use it.

For us it is very important that it is easy possible to run our Windows Forms application directly from web site. We hawe then access to regular Windows Forms application which is alway actual and up to date. Long time it wa enought for me, but latel i was interested in answer of one question. If I can run application from a web site so maybe it is possible to send some data to this application? If you have the same question here is an answer.

First point - how to send parameter to an application

It is very easy. We can use standard get method and send parameters as we are doing it on other web pages. Here is an example

   myApplicationName.application?parameterName=paremeterValue&secondParameterName=SecondParameterValue

How to access parameters from inside of application

To read parameters from inside of application we have to be sure that our application was started from web. To check it we have to make one check.

   ApplicationDeployment.IsNetworkDeployed=true

if IsNetworkDeployed property is set to true that means our application was started from net and we can access parameters

To read parameters we have to parse quesry string used to start our application. It is accessible by

   ApplicationDeployment.CurrentDeployment.ActivationUri.Query

We will receive exact starting url from which we will be able read our parameters. ActivationUri will also give us many other parameters as host or url which we will be able to use to many different behaviours (for example, to protect our application)

I hope it is usefull information for you.

[software] How to control DTS of SQL Server 2000 from inside of application

Some months ago I had a very interesting problem in my work. We were preparing system which uses data from many different sources. My job was to prepare application which will grab data from different servers to SQL Server 2000 and next prepare DBF files for the other system. Our Some of "grabing" tasks was done by DTS definitions on SQL Server - we download data from DB2 Database. My goal was to give an ability to the users to control DTS jobs from inside of my application. Maybe one will had this problem in future so i'd like to share with you my solution.

First i referened my application to set of MsSQL libraries:

  • Microsoft.SqlServer.ConnectionInfo
  • Microsoft.SqlServer.Smo
  • Microsoft.SqlServer.SqlEnum

Next some information.

First what you have to do is to connect to SQL Server:

Dim serv As New Microsoft.SqlServer.Management.Smo.Server(New Microsoft.SqlServer.Management.Common.ServerConnection("Server", "Username", "Password"))

Next you have to read all DTS Jobs and do what you want to do it. To access this jobs you can use this loop:

For Each j As Microsoft.SqlServer.Management.Smo.Agent.Job In serv.JobServer.Jobs

Next

"j" object represents each DTS job registered on server.

The basic methods/properties of DTS objects are:

  • Refresh() - refreshes current job information with sql server
  • Start() - starts job
  • CurrentJobStatus - reads current status of job - you can check if your job is runing or not - remember somone other can run the job when you are thinking that job is stopped. You are reading data for exact time, so somone other can start job from different machine.
  • LastRunDate() - shows date of last job run
  • LastRunOutcome() - shows result of last job execution.

My idea of creating application was this.

I created a user control which contains information of selected job

dtsControl.PNG

Then my application on starts reads all jobs from the server, next creates instance of my control for each job which is found on server (i limited it to the name, because i don't want to cntrol all of them) and add it to form. Rest does my control. This means starts the job and also check current status of job each second. Checking status is important because you need to know when your job has finished it's execution and also if somone other started it. I also changed my "Start job" button behaviour - if control detects that job is runing then button is disabled and you cannot start a job. You can do it only if job is in idle mode.

Here is a part of my control code:

refreshing job

job.Refresh()

Me.Label1.Text = "Status: " + job.CurrentRunStatus.ToString + " last run: " + job.LastRunDate.ToString + If(job.CurrentRunStatus = Microsoft.SqlServer.Management.Smo.Agent.JobExecutionStatus.Idle, " last result: " + job.LastRunOutcome.ToString, "")

If job.CurrentRunStatus = Microsoft.SqlServer.Management.Smo.Agent.JobExecutionStatus.Idle Then

Me.Button1.Enabled = True

Else

Me.Button1.Enabled = False

End If

starting job

job.Refresh()

If job.CurrentRunStatus = Microsoft.SqlServer.Management.Smo.Agent.JobExecutionStatus.Idle Then

Me.Button1.Enabled = False

job.Start()

Me.Timer1_Tick(sender, e)

End If

I hope that this information will help somone of you.

[trick] Google as a free proxy for blocked web pages

If you are working in company which block some of web pages because... noone knows :) but you are very interested to get it it is a very easy trick to open it which can work in your company.

It is veru stupid but google translate service can very easy be used as a http proxy. All you have to do is to open google translate, next enter your address of your web page, select translation from language which is not a language of a page (then system will not change a page) to your language and click translate.

googleTranslateJakoProxy.PNG

In this case we want to open http://allegro.pl it is a polish site so we are choosing translating from english to polish and... It's working.

Simple way is to use direct link to do this, just like this one:

http://translate.googleusercontent.com/translate_c?hl=pl&ie=UTF-8&sl=en&tl=pl&u=http://allegro.pl/

all you have to do is to replace allegro.pl with your address.

Have fun

[software] Update of Voli.ImapPusher

Maybe somone of you knows already my Voli.ImapPusher project. For those of you who don't know it yet I'll explain simple it is my GUI apdate of Imap Pusher service which is available with a source code on the web. Idea of this service is to add IMAP idle functionnality to Pocket Outlook application. My change in this application was only to add gui to it because oryginal was not working ok on my HTC Diamond 2 device.

This service has one problem - it stores connection definition somwhere in registry (i never changed oryginal code in this case) and always when i change a ROM in my device I have to fill all data again. So today i decided to do something with this and i add two small buttons save and load on form of editing details of account.

newImapPusherWindow.PNG

This buttons allows user to save defined settings and then load it from file after new installation.

There is one very important point - password is saved open text - if this is a problem for you please save a data with empty password box.

I also created cab file with new version of application - you can find it here

[youtube] Winter don't want to go but my sons has lot of fun

Today after work my Agnieszka had an idea to go to farm near to Gorzów where owners has lot of animals which you can watch. All you have to do is to bring some food for them with you.

So we placed our sledge into car go to kindergarden for boys and go there. There was small montain there so Oskar and Oliwier had a lot of fun. There was first time in their life when they was able to slide down by themselfs.

[youtube] Winter stopped joking and started to snowing today

Today winter stopped joking with us and started to snowing, so we have real winter here. I made a movie when I was going to shopping center so you can see how it works.

It is also good occasion to see how camera works in HTC Diamond 2 - movie was also tranfered directly from my phone to youtube - it is very supprising function. Do you know that if you are uploading your movie then Diamond doesn't switch off your wifi card when it is in sleep mode (usualy does it)

Ok, now it's time for movie enjoy it

Update 2010-01-10 Today morning i was driving in different place but partialy the same way so you can see it when there is little more light

[Software] Voli.CabGenerator - my solution of problem with a cabWiz and generating cab files for Windows Mobile

As long as I'm writing applications for Windows Mobile and Windows CE devices i have a problem with publishing it. Usualy i'm giving people an exe file with compiled application. This is good solution inside of my company where everybody knows what to do with this files, but sometimes when I want to give my application to somone other i need to have a cab file.And here is a problem. Visual Studio 2008 and 2005 has a special project for smart device cabs but it is not working very well on my configuration. Simply - i can create a project which will generate files for me but it will not work.

Many years ago i created small application which generates inf file for cabwiz for me but it was not working perfectly. So today i decided to little refresh my project and funally generate good and easy working for me tool for generating cab files. Yes i know there are many such tools in internet but noone is working for me.

So what i did.

First i created small clases definition to create "project" files and save all my setting in simple XML file which looks like this:

<?xml version="1.0" encoding="utf-8"?>
<projekt ApplicationName="Voli.MailReader" OutputPath="z:\">
  <plik FileName="Voli.HTCTypeControlsWM6.dll" SourcePath="D:\Documents\Visual Studio 2008\Projects\Voli\Voli.MailReader\Voli.MailReader\bin\Debug\Voli.HTCTypeControlsWM6.dll" CreateShortcut="false" />
  <plik FileName="Voli.MailReader.exe" SourcePath="D:\Documents\Visual Studio 2008\Projects\Voli\Voli.MailReader\Voli.MailReader\bin\Debug\Voli.MailReader.exe" CreateShortcut="true" />
</projekt>

as you see it is not very complicated.

My application looks this way:

Voli.CabGenerator.PNG

Next point was to create an inf file for cabWiz. Example inf file for project desplied abowe is:

[Version]
Signature="$Windows NT$"
Provider="Voli s.c."
CESignature="$Windows CE$"
[CEStrings]
AppName="Voli.MailReader"
InstallDir=%CE1%\%AppName%
[CEDevice]
VersionMin=4.00
VersionMax=6.99
[DefaultInstall]
CEShortcuts=Shortcuts
AddReg=RegKeys
CopyFiles=Files.Common
[SourceDisksNames]
1=,"Common1",,"c:\Temp"
[SourceDisksFiles]
Voli.HTCTypeControlsWM6.dll=1
Voli.MailReader.exe=1
[DestinationDirs]
Files.Common=0,%InstallDir%
Shortcuts=0,%CE2%\Start Menu
[Files.Common]
Voli.HTCTypeControlsWM6.dll,,,0
Voli.MailReader.exe,,,0
[Shortcuts]
Voli.MailReader.exe,0,Voli.MailReader.exe,%CE11%
[RegKeys]
"HKLM","Software\Voli.MailReader","Version","0x00000000","1"

So i have to prepare code for this.

Dim out As New List(Of String)

Dim tempF As String = My.Computer.FileSystem.SpecialDirectories.Temp

Dim directories As New List(Of String)

directories = (From a In p.pliki Group a By a.SourceFolder Into g = Group Select SourceFolder).ToList

out.Add("[Version]")

out.Add("Signature=""$Windows NT$""")

out.Add("Provider=""Voli s.c.""")

out.Add("CESignature=""$Windows CE$""")

out.Add("")

out.Add("[CEStrings]")

out.Add("AppName=""" + p.ApplicationName + """")

out.Add("InstallDir=%CE1%\%AppName%")

out.Add("")

out.Add("[CEDevice]")

out.Add("VersionMin=4.00")

out.Add("VersionMax=6.99")

out.Add("")

out.Add("[DefaultInstall]")

out.Add("CEShortcuts=Shortcuts")

out.Add("AddReg=RegKeys")

out.Add("CopyFiles=Files.Common")

out.Add("")

out.Add("[SourceDisksNames]")

'Next

out.Add("1=,""Common1"",,""" + tempF + """")

out.Add("")

out.Add("[SourceDisksFiles]")

For Each pl In p.pliki

out.Add(pl.FileName + "=1")

Next

out.Add("")

out.Add("[DestinationDirs]")

out.Add("Files.Common=0,%InstallDir%")

out.Add("Shortcuts=0,%CE2%\Start Menu")

out.Add("")

out.Add("[Files.Common]")

For Each pl In p.pliki

out.Add(pl.FileName + ",,,0")

Next

out.Add("")

out.Add("[Shortcuts]")

For Each pl In p.pliki.Where(Function(o) o.CreateShortcut = True)

out.Add(pl.FileName + ",0," + pl.FileName + ",%CE11%")

Next

out.Add("")

out.Add("[RegKeys]")

out.Add("""HKLM"",""Software\" + p.ApplicationName + """,""Version"",""0x00000000"",""1""")

Dim infFile As String = New System.IO.DirectoryInfo(p.OutputPath).Name + "\" + p.ApplicationName + ".inf"

System.IO.File.WriteAllLines(infFile, out.ToArray)

For Each pl In p.pliki

System.IO.File.Copy(pl.SourcePath, tempF + "\" + pl.FileName, True)

Next

Try

Dim sLine = """" + My.Settings.cabWizPath + """ """ + infFile + """ /dest """ + p.OutputPath + """ /err " + New System.IO.DirectoryInfo(p.OutputPath).Name + "\CabWiz.PPC.log"

Shell(sLine.Replace("\\", "\"), AppWinStyle.Hide, True, -1)

Catch ex As Exception

MsgBox(ex.Message)

End Try

For Each pl In p.pliki

System.IO.File.Delete(tempF + "\" + pl.FileName)

Next

Dim info As String = ""

If System.IO.File.Exists(New System.IO.DirectoryInfo(p.OutputPath).Name + "\CabWiz.PPC.log") Then

info = System.IO.File.ReadAllText(New System.IO.DirectoryInfo(p.OutputPath).Name + "\CabWiz.PPC.log")

End If

MsgBox("Ready " + vbCr + info)

My application whas almost ready, but i found big problem - generated inf file was quite ok but cabWiz was not able to generate cab file. After few hours of experimenting and searching internet i found that cabWiz has a problem with long paths for source files, so i decided to make it little shorter and decided to go this way. All files which should be included in cab file are copied to temp folder (which is usualy very short path - at my pc it is c:\temp), next in inf file i'm putting paths to temp folder then starts cab generation process and after that i'm deleting files from temp folder - this simple method (maybe not so very elegant - sorry) solved my generation problem.

If you wish to use my tool for your tests here are ready files but before first use please open Voli.CabGenerator.exe.config file and enter your cabWiz.exe path in configuration section. My example configuration is below

<Voli.CabGenerator.My.MySettings>
            <setting name="cabWizPath" serializeAs="String">
                <value>c:\Program Files (x86)\Microsoft Visual Studio 8\SmartDevices\SDK\SDKTools\cabwiz.exe</value>
            </setting>
        </Voli.CabGenerator.My.MySettings>

If you have any questions or suggestions feel free to write a comment

[Software] Voli.MailReader - one click refreshing of all email mailboxes in Pocket Outlook

Many Windows Mobile users - as I - reads e-mails in its devices. For me it is very important to have an access to all my e-mail boxes. I have two my private and one company. So all the time there is a problem to fast check all mail boxes. I can use my GUI application for imap pusher but in my device keeping all the time connection consumes lot of power. So i can check my mails manualy - it's not a prbolem, but i have to click send/receive buttons for each account.

Today I decided to create small application which will do everything for me.

Here is small screen shoot.

voli.MailReaderScreen.png

As you can see application connects to pocket outlook and reads all email accounts. Next it tells each e-mail account to send/receive messages.

Important is that application ignores ActiveSync account (i don't use it) and Lotus Traveler Mail (this is my company mail and there is Lotus application to receive mails from it).

I decided to show you application code - maybe it will be usefull for somone.

Ok, As you can see there is two soft buttons "Read all mails" (for read process) and "Exit" for quiting application. There is also list box with information about current status.

To create this application is important to add reference to Microsoft.WindowsMobile.PocketOutlook library.

To write status information i created log function:

Sub log(ByVal t As String)

Me.ListBox1.Items.Add(t)

Me.ListBox1.SelectedIndex = Me.ListBox1.Items.Count - 1

Application.DoEvents()

End Sub

Now procedure started from button "Read all mails" (including update from 2010-01-06)

Dim wait As Integer = 20

log("Accessing outlook")

Dim ou As New Microsoft.WindowsMobile.PocketOutlook.OutlookSession

Dim o = ou.EmailAccounts

log("Found " + o.Count.ToString + " email accounts")

For Each a As Microsoft.WindowsMobile.PocketOutlook.EmailAccount In o

log("Processing " + a.Name)

If a.Name = "ActiveSync" Or a.Name.Contains("Lotus") Then

log("Ignore")

Else

log("Sending send/receive to mailbox")

Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount(a.Name)

Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(a)

Me.Show()

log("Waiting " + wait.ToString + " seconds")

System.Threading.Thread.Sleep(wait * 1000)

End If

Next

log("Finished - now you can close application")

Now explanation:

First application connects to Pocket outlook and creates ou object.

Next create objec o which is collection of all email accounts registered in pocket outlook. For each account application check it's name and if it is not ignored then uses MessagingApplication to synchronize otlook mailbox.

As you can see it is very easy to write.

If you have any questions write me.

Update 2010-01-06:

I'm testing application and i discovered that sometimes if you want to check email - synchronization process of one e-mail box is stopped by another process so i changed my code a little to add 20 second sleep between checking mail boxes. I also changed code to show application back after sending send/receive command to mailbox.

Updated code is up and replaces the old one.

1234
Paweł Goluda