This blog is subject the DISCLAIMER below.

Tuesday, March 23, 2010

How to configure SQL Server for ASP.NET SQL Server Session State <sessionState mode="SQLServer" ../>

On your prompt (doesn’t matter if you’re on the SQL server machine or not), run the below command:

”system root”\Microsoft.NET\Framework\”version number”>aspnet_regsql.exe –S “server” -U sa -P “Password” -ssadd -sstype p
for eg:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
OR
C:\WINNT\Microsoft.NET\Framework\v4.0.21006>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
Now you have ASPState database on your servers with the tables, stored procedures, jobs needed to handle SQL server mode session state.

.. more.

Thursday, February 25, 2010

Shared secrets

This post continues the other approach to secure multi-party computation, which is called "Secret-sharing".

The problem
Consider the problem that, there is a nuclear missile, and there is its launch code. Only the president has that code. But what if the president is unavailable ? We can't trust any of the executives alone. We would require for example that 3 of them can launch the missile, but not any single one of them alone. This is what secret-sharing is about. It's goal is quite different than homomorphic encryption, but it used also for secure multi-party computation.





Which is more secure?
Homomorphic encryption relies on the assumption that it would take long time to crack it. Typically for example, the problem of factoring a very big number. Secret-sharing, on the other hand, is secure in information-theory sense. That means that even if given the entire eternity, you can not break it, simply because there is no information leakage (unlike the other approach where is information leakage with small probability).

Shamir's Secret Sharing
The first to publish about a practical secret sharing scheme was Shamir, in 1979 [1]. It's target is to create $n$ shares of the secret, such that any $k$ shares are sufficient to reconstruct the secret. Each person would be given some shares. The president is allowed to launch the missile alone, so he will have $k$ shares. The executes must be 3, so each one will take $k/3$ shares. The total number of shares is unbounded. Such a scheme is called $(k,n)$ secret-sharing.

What if some shares was stolen ?
If the number of shares stolen were less than $k$, then the other shares can be renewed by adding a random shared secret whose value is zero [2]. The old stolen shares are useless now since their compatible shares were replaced by new ones.

How does it work ?
Shamir's scheme depends on Lagrange Interpolation of polynomials. Using Lagrange interpolation, you can recover a polynomial $f(x)$ of degree $t$, given $t$ pairs $(x_i,y_i)$ such that $y_i=f(x_i)$.

Encoding a secret
To encode a secret value $v$ in a $(k,n)$ secret-sharing scheme, do the following:
- Generate a random polynomial of degree $k$ whose free coefficient is $v$ (that means $f(0)=v$).
- Evaluate the polynomial at $n$ different points $x_1,x_2,..,x_n$
- Each share consists of a pair $(x_i,f(x_i))$

Reconstructing a secret
to reconstruct the secret, collect $k$ shares, and follow the Lagrange interpolation and substitute $x$ by zero. That is we reconstruct the polynomial and evaluate it at zero. The result is $f(0)$, which is $v$. If you have less than $k$ points, the constructed polynomial is wrong and you can not retrieve the secret.

[1] A. Shamir, "How to share a secret," Communications of the ACM, vol. 22, 1979, p. 612–613.
[2] Herzberg, A., Jarecki, S., Krawczyk, H., and Yung, M. 1995. Proactive Secret Sharing Or: How to Cope With Perpetual Leakage. In Proceedings of the 15th Annual international Cryptology Conference on Advances in Cryptology (August 27 - 31, 1995). D. Coppersmith, Ed. Lecture Notes In Computer Science, vol. 963. Springer-Verlag, London, 339-352.

Originally posted to http://fci-h.blogspot.com/. This is just an automatically forwarded copy. (To read the Latex-typeset mathematics correctly, please visit the original post).

.. more.

Replication Error "SQL Server is unable to connect to server.."

If you're working in SQL Server Replication, you may get this message
SQL Server is unable to connect to server 'Your server name'.

SQL Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address, or any other alternate name are not supported. Specify the actual server name, 'Another server name'. (Replication.Utilities)



It always appears as you change the instance name manually or network administrators change the computer name.

Actually your server name still as it's and not changed with above changes so to avoid getting this message you should write these couple of T-SQL scripts every time you do one or all changes on the instance name

SELECT @@SERVERNAME -- you'll get a strange name, you may didn't see it before...
GO
sp_dropserver 'Old server name' -- you got it from pervious select.
GO
sp_addserver 'SQL server instance name','local' -- the name of current instance.
GO
Then, restart the service, and go on you replication work...

.. more.

Sunday, February 14, 2010

Ultimus: JFG can't return with workaround

With Ultimus you have a flexibility to "submit" or "return" any step using Ultimus APIs (EIK) whatever the recipient of that step expect the "Job Function Group" (JFG) and "Group" as it fails in the "return" because the JFG contains more than one user and this is my problem.

I need to return from a step with recipient type JFG have more than one user using EIK.
Note: submitting the step with condition to return back to the previous step is not a solution as I need to keep the status of the returned step as returned.

After asking Ultimus support about this issue they answered me that as per Ultimus BPM Studio Documentation, Page 175:
Any step with multiple recipients from a group or dynamic group cannot
return the task and this is a design behavior.

So I came up with workaround to solve this behavior that allow you to return a step one level back and keep the status of the returned step as returned even the recipient type was JFG.

Assume this case study:
you have two steps one for "officer" who collect some data and then pass this step to "manager" who review the officer's data then submit his task, both steps(Officer & Manager)have "Job Function Group" as a "Recipient Type".

If your business needs is to return the task from manager to officer again if the manager have some comments and needs changes in the officer's data so the problem will come here as the task can't be returned because it's JFG.

To solve this problem you can follow me pattern with fake or dummy step as in the following picture.

1-When the Officer submit the step then he will activate two step Not only the manager step but also the fake(Dummy) step.
2-the straight forward scenario is that the manager will submit the task and raise a flag so the Complete Event of the step will fire as the following:

  • The flag will foreword the manager to the junction step to go throw the normal path.
  • The flag will abort the fake step.

3-if the decision of manager was return to officer then:

  • The manager will submit the step with no valid condition so the submition will do nothing than make the step as not active.
  • Using EIK you can get the fake step by Ultimus Filter and call the Return function so it will return it in the officer step with returned status and that is what we already need to do.

.. more.

Saturday, February 13, 2010

Homomorphic Encryption

We will talk in this post about a very useful cryptographic tool. But lets talk first about the motivation or the problem it solves first.

As the first example, we will introduce the private voting problem:
We want to make an online voting application, no one can know what anyone else has voted (not ever the server itself), but at the end, we will know how many votes each candidate has received. The problem is even harder if there is no "central" trusted server and it is a distributed system which all nodes interact with all others and no one can trust anyone else.

Now, lets introduce homomorphic encryption. Homomorphic encryption, is an encryption system which allows you to do calculations on the encrypted data, without knowing the original text. At the end you will get the encryption of the result, not the result itself.

Caution: the notation used is simplified and there are some details that are not mentioned in order to simplify the presentation.

To make it more elaborate, assume $a, b$ are plain texts, and $E(a), E(b)$, are their encryption. If the encryption system you are using allows for addition, you can then call $Add(E(a),E(b))$ and you will get $E(a+b)$.

Ok, so how can this help us in our voting problem ? We will describe the protocol to show how. There is a node which will start the voting, it is the only node that can decrypt values. He will send his vote $v_1$, either 0 or 1, encrypted to the the next node. The next node will take the encrypted vote and adds his encrypted vote, either 0 or 1, and forwards it to the next one, and so forth, in a ring-like fashion, until it reaches the first node again. The first node will then decrypt and will find the sum of the votes for the first candidate. This is repeated for each candidate.

Homomorphic encryption has a lot more applications, and is more sophisticated that the simplified version mentioned here. For example, it usually has "semantic" security, which means that it is a probabilistic encryption, which means that every time you encrypt the same value, you will get a different cipher text. That is, if two people sent you $E(1)$, you will not be able to know it is the same value just by looking at the cipher text alone. Also, there are encryption schemes that only allows for addition, and others that only allow for multiplication. There is one that allows for addition and only one multiplication. Those who supports unlimited number of addition and multiplication are called "algebraic homomorphic encryption", or "fully homomorphic". So far, fully homomorphic schemes incur very big overhead for practical purposes.

Note that homomorphic properties are usually intended in a cipher. If a cipher had these properties and it was not intended, it is called "malleable" encryption and it is considered a flaw instead. Remarkable homomorphic cryptosystem are RSA, ElGamal, and Paillier.

Note also that these schemes are also asymmetric. So anyone with public key can encrypt a value, but can not decrypt it except with a public key.

References:
- Pascal Paillier: Public-Key Cryptosystems Based on Composite Degree Residuosity Classes. EUROCRYPT 1999:223-238

- http://en.wikipedia.org/wiki/Homomorphic_encryption


Author: Mohammad Alaggan

.. more.

Wednesday, February 03, 2010

Automated build for ATG, Ant or Maven ??

If you are not working with ATG, then, this article will be a waste of time, this article is for those guys working - or in other words suffering - with ATG. The case is you want to automate the build of ATG projects which are not following most of the JEE standards, they are using their own methodology which is not bad, but somehow weird. This article is to discuss whether it is better to use Ant or Maven for the build process of ATG projects.
------------
You can read about Ant here and Maven here.
------------

Well, maven is great tool indeed and i pesonally like it, unlike Ant, maven has knowledge about the whole project and handles alot of work in a declarative way, you just tell maven to compile the project and it compiles it without any configuration, this is due to its knowledge about the project, on the other side, Ant only knows about the build process, you define targets using XML script and define their sequence of execution, each target in an Ant build script does not know about other targets, it executes what you tell it to execute and nothing more, for example; to compile a project using Ant you need to define a compile target and tell it the classpath to use and where to place the .class files. Orginially, Ant did not support any dependency management technique, however, now Ant have a powerfull extension named Ivy which eanbles Ant to resolve project dependcies using maven's way, however, this does not change the main Ant concept of separate targets who do not know anyhing about each other, ivy enables you to tell it what artifacts (jars) you want and is gets it from a repository and places it in a directory.

It is very clear that maven is more advanced, more smart than Ant, but, for ATG projects the story is somehow different, the minimum build process for JEE application is as follows:

1- Checkout code.
2- Compile.
3- Test.
4- Package and deploy.

Maven and Ant works the same for ATG projects for the first step. Starting from the second step we see that to work with maven you need to add your project's artifacts to a repository and configure maven to look up that repository. To package an ATG project - (step 4) - you need ATG to be installed on the build machine to assemble (package) the project, this indicates that the needed artifacts are surely on the same machine you are working on, so the need of a repository is vanished. Why defining a repository while i know that the needed jars are on the build machine for sure. Here, Ant is more flexible and logic to use, you will just define the place of the jars and that's it, you can do this with maven, but you will end up loosing the power of it.

That packaging step makes maven loose its leverage over the prject even more, as in ATG projects the packaging will be done by making maven execute a shell command to run the assembler which is not what maven understands. The generated EAR will be totally outside the scope of maven and to deploy it you will execute another shell command to copy it to the desired location and loosing again the deploy feature of maven. Here also, the build process shows to be more likely an Ant style build.

Testing ATG modules is the most painful, all ATG developers knows the amount of hassle to unit test ATG modules, it is not as direct as spring. In  this step neither Ant or Maven have power points over each other it is bad all along the way and to get it done you need a lot of workarounds related to ATG.

Although you can do it with Maven, Ant is a better fit here as it is designed to handle builds that need flexibility and do not follow the normal and well known build steps.

.. more.

Wednesday, January 20, 2010

Discrete Event Simulators : Simulating Networks

----
Update:
I've been told that this article doesn't present *why* we need discrete event simulators, or what is the problem solved by them.
The problem is, for one example, consider you are developing a peer to peer program, like bittorrent, and you want to try it to see how good it works when 1000 users run it. You can get 1000 of your friends and they'd start the program and there you go (Or use PlanetLab). However if there were a bug, you'd be completely lost how to debug it. Discrete event simulators, "simulate" that there is 1000 users (or more, if you want) on your machine. More than that, they are all in the same "process/thread". So it boils down to a single-threaded application that is so much easier to debug.
Another example is to test a network protocol for example (see NS-2 simulator). You want to modify the "IP" protocol and want to simulate a network of hosts and routers and switches instead of implementing it on the hardware level and testing it in real life. That's what discrete event simulators are useful for.
----

If you are familiar with windows event loop of event-driven applications (GUI, sockets), you know that pretty much applications can be defined in terms of events. We consider here network applications which are mostly defined by a "receive-message" event.

You write your network application and depend on a receive event as a black box to receive messages (ref: Apache Mina). Imagine now we have the same application but we just replaced that black box, instead of the OS socket APIs, we replaced it with a discrete event simulator of the same exact interface.

That interface is just the function send(msg) and a callback function that you provide called receive(msg).

Instead of having the sender and receiver on different machines, they both will be on the same machine and in the same application (it's a "simulation", you want to test them as "if" they were on a real network).

The first application calls send() unsuspectingly, and then the discrete event simulator instead of calling OS APIs to send it on the network card, he just creates a corresponding reception event in the second (receiving) application. And then the second application gets a callback that he has got a message from the first application.

This view is simplified a little bit. We want to model network delay and bandwidth constraints, especially if we are going to simulate3000 peers of bit-torrent for example. There is ns-2, which simulates these metrics using a complete IP stack implementation (IP/TCP). It splits messages into packets, and simulates routers and so . NS-2 is used to test real protocols like WiFi and routing algorithms. However its over head is unacceptable if we want to consider a peer to peer network of 1000 peers (running on the same machine).

Some approaches like peersim, models delay as a random function and not bandwidth. However there are other approaches like MyP2PWorld[1] that models bandwidth but obtains efficiency from approximating the bandwidth constraints on the "message" level not the packet level.

Most discrete event simulators are not designed to test a deployable system and requires implementation using it's own interfaces and tools and then you transform that into a real application. MyP2PWorld[1] was designed to adapt the Apache Mina interface (used in real application). So you can write you own deployable peer to peer application using Apache Mina (event-driven networking), and with a flip of a boolean variable, you test it on a discrete event simulator. So your code you use in simulation is the same code used in deployment.

References:
[1] Roberto Roverso, Mohammed Al-Aggan, Amgad Naiem, Andreas Dahlstrom, Sameh El-Ansary, Mohammed El-Beltagy, Seif Haridi: MyP2PWorld: Highly Reproducible Application-Level Emulation of P2P Systems. SASO Workshops 2008:272-277

.. more.

Wednesday, December 23, 2009

Quantum Computing's potential: impossible to ignore

What's the average time you need to find a certain item in an unsorted list of N=1,000,000 items ? O(N/2) = 500,000. That means on average you have to look at half of them before finding your desired item.

What's the minimum number of steps you need to solve a N-by-N system of linear equations ? at least N steps.

What's the minimum time you need to factor an integer of N bits ? 2^N steps. Cryptographic security relies on this fact.

However all these answers are wrong in quantum computing !
In quantum computing to find an item in an unsorted list of 1,000,000 items you need only Sqrt(1,000,000) = 1000 steps! [1,4]

In quantum computing to solve a system of N linear equations you need Log(N) steps ! [2]

In quantum computing to factor a N-bits integer you need only N steps (logarithmic to the number) ! So if a quantum computer with enough bits (called qubits in quantum computers) all today's encryptions are totally useless !! Your bank account can be stolen in one day. [3,5,6]

Several quantum computes of 5 and 7 qubits have been made to prove it is possible[7]. However not yet practical because they don't have enough qubits yet.

Some quantum cryptography networks have been deployed [8]. Ordinary cryptographic systems promises you that your encrypted text will not be decrypted in less than 1 million years for example. However these quantum cryptography methods are totally unbreakable no matter how much time given (personal opinion of the author, that can be wrong).

Even google is considering using quantum search algorithms and have already bought a quantum computer[1].

They are becoming less and less ignorable nowadays. One day we will wake up to find a complete revolution in computing. They are exponentially faster than ordinary computers in general.

To find a good and easy (and more complete) starting point refer to [9]. However I am going to write a small introduction here.

A quantum bit is the building block of quantum computers as much as the ordinary bit is the basic block of ordinary computers. Although it can not deliver or carry more than 1 bit of data in normal cases[11] (1), but in the intermediate calculation steps it can carry zero and one at the same time.

Basically what that means is that using an array of n qubits, you can deliver or carry any number between 0 and 2^(n-1) just like ordinary computers, but also means that in intermediate steps ur quantum register can carry ALL these numbers at the same time, and you can do calculations on ALL of them simultaneously. That's the concepts used in all quantum algorithms.

For more details I redirect the interested reader to the references mentioned below.

--------FOTENOTES------
(1) Other cases like superdense coding as in [10] uses more advanced techniques and tricks.

-------REFERENCES------

[1] http://www.popsci.com/technology/article/2009-12/google-algorithm-uses-quantum-computing-sort-images-faster-ever
[2] Davide Castelvecchi, _Warp-Speed Algebra_, Scientific American January 2010 Issue, Pages 22-23.
[3] http://spectrum.ieee.org/computing/networks/mother-of-all-quantum-networks-unveiled-in-vienna
[4] http://en.wikipedia.org/wiki/Grover's_algorithm
[5] http://en.wikipedia.org/wiki/Shor's_algorithm
[6] http://alumni.imsa.edu/~matth/quant/299/paper/node19.html
[7] http://en.wikipedia.org/wiki/Timeline_of_quantum_computing
[8] http://spectrum.ieee.org/computing/networks/mother-of-all-quantum-networks-unveiled-in-vienna
[9] http://alumni.imsa.edu/~matth/quant/299/paper/paper.html
[10] http://en.wikipedia.org/wiki/Superdense_coding
[11] http://en.wikipedia.org/wiki/Quantum_information_theory; last modified on 13 November 2009 at 06:53; Quote: "However, despite this, the amount of information that can be retrieved in a single qubit is equal to one bit. It is in the processing of information (quantum computation) that a difference occurs"

.. more.

Monday, December 14, 2009

WSCF.blue v1.0

WSCF.blue is a Visual Studio .NET 2008 add-in that provides the following features:

· A WSDL Wizard that allows the developer to step through the creation of a WSDL from one or more XSDs.

· A Data Contract Generator (similar to XSD.exe, XSDObjectGen.exe and SvcUtil.exe) that generates the .NET equivalent classes of the XSD types.

· A Service/Endpoint Stub (support for self-hosted and web-hosted) Generator and

· A Client Proxy Generator.

· A Generate Data Contract Code feature that supports the selection of multiple XSD/WSDL source files.

· A Paste XML as Schema option that generates a schema for a block of XML in the clipboard.

· Support for C# and VB.NET code generation.

· You can choose if operation methods on your service class will throw a NotImplementedException, call an implementation method in a partial class, or will be defined as abstract methods.

· Force the SOAP actions (Action and ReplyAction) applied to each operation contract follow the standard WCF format

· Errors found while processing the WSDL are reported in a WSCF.blue pane in the Visual Studio Output window.

.. more.

Monday, December 07, 2009

How to Get User Friends\Followers on Twitter

Twitter became very popular social network, all use it for different purposes i.e to expand your network, to market for your products, to be up-to-date with specific technology, or to know what people talking about is.
Developers are users but on Twitter and Facebook they are not regular users, Twitter for example gives you some APIs to develop you own application and extend Twitter with features, it's time for everybody to extend without waiting for creators to do.
I was developing Twitter application two days ago, and I faced a problem to get all user's friends\followers, I used some APIs but unfortunately, they got first 100 friends\followers!! I knew that you can browse user friends\followers for user called "RamyMahrous" like that http://twitter.com/statuses/friends/ramymahrous.xml?
http://twitter.com/statuses/followers/ramymahrous.xml?
But it gets just first 100 friends\followers I browsed some sites but no information, unless I went to Twitter API Wiki and I knew about XML cursor they use every cursor has limited 100 friends\followes means... if "RamyMahrous" has 204 friends so it will be iterated through 3 cursors.
Let's code...
string FriendsXMLFileURL = "http://twitter.com/statuses/friends/{0}.xml?cursor={1}";
string FollowersXMLFileURL = "http://twitter.com/statuses/followers/{0}.xml?cursor={1}";
List < users_list > listUserList = new List < users_list > ();
int index=0;
XmlSerializer Serializer = new XmlSerializer(typeof(users_list));
List < users_list > listUserList = new List < users_list > ();
List < users_listusersuser > users = new List < users_listusersuser > ();
users_list usersList = new users_list();
int index = 0;
string nextCursor = "-1";
while (nextCursor != "0")
{
usersList = (users_list)Serializer.Deserialize(
XmlReader.Create(string.Format(FollowersXMLFileURL, "RamyMahrous", nextCursor)));
listUserList.Add(usersList);
nextCursor = usersList.next_cursor;
}
//user_list class generated based on the xml structure you can save the xml file and generate it
//using XSD please take alook on this post by Shady
http://fci-h.blogspot.com/2009/12/how-to-create-c-class-from-xml-file-via.html
foreach (users_list userlist in listUserList)
{
users.InsertRange(index, userlist.users[0].user);
index += 100;
}
//so now you've list of users you can iterate and do anything with them!
//take a look this brings user friends\followers without providing user password!
Your comments are welcome :)

.. more.

Saturday, December 05, 2009

How to create a C# Class from XML file (via xsd.exe)

A friend asked me a couple of times about how to I created the class I used in “twitter common friends” to handle xml as objects (includes reading & writing back). Actually the tool (xsd.exe) is pretty simple & takes no more than a couple of commands to create the class for me.

It’s just that I usually forget the keywords/parameters & their order (you can create a dataset or class that can be C# or VB, & there’s a couple of other option I never used before). I usually refer to its MSDN page when asked..

So I thought a post would be easier to remember. First you should create the xsd file out of the xml, using the VS command prompt:

xsd myFile.xml

That will create “myFile.xsd”, now to create “myFile.cs”, write the below line:

xsd myFile.xsd /c

Now you can add the cs file to your project & use it as illustrated in my previous post.

.. more.

Saturday, November 28, 2009

Generating DAL using CodeSmith and .Nettiers (step by step)

Here is a post for generating DAL (Data Access layer) using CodeSmith and .Nettiers for any C# project. This post is a part of document guide I have written for a client of my company.


For whom don't know what is Codesmith :
CodeSmith is a software development tool to help you get your job done faster. Technically speaking it is a template driven source code generator that automates the creation of common application source code for any language (C#, Java, VB, PHP, ASP.NET, SQL, etc.).(http://www.codesmithtools.com/)

And .Nettiers :
.netTiers utilizes the power of the best code generation tool available today, CodeSmith. .netTiers generated architecture is custom to your domain, uses familiar patterns, and follows the guidance of Microsoft's recommended patterns and practices. In fact, the .netTiers base architecture is built upon the Microsoft Enterprise Library Application Blocks.(http://nettiers.com/)

Note : these steps captured with CodeSmith 3.2 and .NetTiers but almost versions are the same.

Opening CodeSmith 3.2:

1. After setup the CodeSmith 3.2, open it from the start menu.

2. If you haven’t license, you can continue with the trial version by pressing “Try” button.


3. From the File menu of CodeSmith press “Open” and select the Nettiers.cst inside NetTiers 2.2.0 folder.


4. Open the configuration XML file and change the connection string as in the picture(if you haven't Configuration file or this is first time to work with that drop this step).
5. From the Properties Tab click the open icon then select the configuration XML file(if you haven't Configuration file or this is first time to work with that drop this step).
6. Configure the Properties Tab then Press the run icon.

7. Be sure that no errors in the generated report and open the solution file (generated in the output directory).

8. Build the whole solution.

9. After the build succeed open(your output directory\your RootNameSpace.Data.SqlClient\bin\Debug ) and get the following three DLLs to import them in your own project as the generated DAL (Data Access Layer) .
• your RootNameSpace.Data.dll
• your RootNameSpace.Data.SqlClient.dll
• your RootNameSpace.Entities.dll

Happy Coding :)

.. more.

Wednesday, October 21, 2009

Wondering about Project Managers

I had a couple of issues lately with a PM (Project Manager) at work which made me ask myself a couple of questions & wonder what others might be thinking of it.. I'll give my humble opinion here to start a conversation, coz I badly wanna here how others would answer them.

  • Should PMs know/ask much about technical decisions?
    • IMHO, I thing the answer is NO!! PMs should be asking for less fine details like what's the estimations for doing that option or so.. But they shouldn't be asking why we are using X, or Y technology/approach to tackle a problem.

  • In an agile process, where should PMs stand? What exactly is their Role? Should there be PMs in agile in the first place? Or Should they be replaced by a PO (Product Owner), or -may be- a Scrum Master?
    • That's a question that really confuses me a lot.. I can't give a definite answer.. Should they replace POs.. Hmm. I guess not.. On one hand, a PO should be the one directing the project, knowing what the customer want.. But still, a PO -probably- should have some technical background.. So according to my answer to the previous question, PMs can't replace POs..
    • On the other hand, Replacing a Scrum Master, is a bit too far for PMs, Scrum Master are supposed to be in favor of the development team, ie a facilitator & protector for the dev team; & PMs are notorious of failing to do so.. :D
    • Another option -that just came to me right now- is PMs replacing customer in environments where it's difficult to involve the customer.

I'm desperately waiting for your answers to either of the above questions.. I'm really confused & don't have enough knowledge actually to answer them.
I might be adding other questions but for now that's what is on my mind..

.. more.

Sunday, October 18, 2009

Deploying Reports in Reporting Services Programmatically

May be it's my bad luck may be something else, but I didn't find a complete post how to deploy Reports, and Data Sources in Reporting Services in away like BIDS.

First it's a tool I developed to automate the deployment of BI solution (Creating Data warehouse, installing SSIS packages, creating Jobs, create Cubes and installing reports on Reporting Services Server).

If you don't have time to read and just need to download the tool, here you're
Source Code: http://cid-3e2288e7a8e55f56.skydrive.live.com/self.aspx/Public%20folder/Deploying%20Reports%20in%20Reporting%20Services%20Programmatically.zip

Herein, I'll talk about the last thing which is deploying reports.

P.S: It's my way in designing such task (Installing reports on Reporting Services Server) and it's not standard or anything else just (follow your heart :))



Let's begin, I assume you, me, or anybody else has these 3 XML files one for folders, one for data sources and one for reports.

[caption id="attachment_772" align="aligncenter" width="450" caption="Folders' XML Scheme"]Folders XML File Scheme[/caption]

Name: Folder name to be created on Reporting Services.
ParentFolder: '/' means on the top == no parent folder.

[caption id="attachment_773" align="aligncenter" width="450" caption="Data Sources' XML Scheme"]Data Sources' XML Scheme[/caption]

Name

Folder

Description

HideInListView

Enabled

ConnectionString

Extension

CredentialRetrieval

WindowsCredentials

ImpersonateUser

ImpersonateUserSpecified

Prompt

UserName

Password

EnabledSpecified

Name: Data Source name to be created on Reporting Services.
Folder: The folder in which Data Source should be in, if we use '/' means on the top == no parent folder.
Description: Data Source Description.
HideInListView: True to hide it in the Reporting Services, otherwise False.
Enabled: True to be enabled, otherwise not enabled.
ConnectionString: Data Source connection string.
Extension: Configured according to the provider for more details see below table...






































ProviderExtension
Microsoft SQL ServerSQL
OLE DBOLEDB
Microsoft SQL Server Analysis ServicesOLEDB-MD
OracleORACLE
ODBCODBC
XMLXML
SAP NetWeaver BISAPBW
Hyperion EssbaseESSBASE

CredentialRetrieval: How Data Source will retrieve the credential.
WindowsCredentials: True to use Windows credential otherwise it'd use the credential provided in this XML (Username, and Password).
ImpersonateUser: Indicates whether the report server attempts to impersonate a user by using stored credentials after a data processing extension has established an authenticated connection to a data source.
ImpersonateUserSpecified: Gets or sets a value that indicates whether the ImpersonateUser property is specified.
Prompt: Gets or sets the prompt that the report server displays to the user when prompting for credentials.
UserName: Gets or sets the user name that the report server uses to connect to a data source.
Password: Sets the password that the report server uses to connect to a data source. Write-only.
EnabledSpecified: Gets or sets a value that indicates whether the Enabled property is specified.

More details on these properties http://msdn.microsoft.com/en-us/library/reportservice2005.datasourcedefinition_properties.aspx

[caption id="attachment_774" align="aligncenter" width="450" caption="Reports' XML Scheme"]Reports' XML Scheme[/caption]

Name: Report Name.
Path: .RDL file path.
Folder: The folder in which Report should be in, if we use '/' means on the top == no parent folder.
DataSource: Report's Data Source name of Reporting Services.

And these configuration keys

[caption id="attachment_777" align="aligncenter" width="450" caption="Configuration keys"]Configuration keys[/caption]

ReportsXMLFilePath: Reports' XML File Path
DataSourcesXMLFilePath: Data Sources' XML File Path
FoldersXMLFilePath: Folders' XML File Path
ReportingServerURL: URL of Reporting Services

Open visual studio and create a C# console application (we don't need any interaction with user everything configured in the application configuration file)

From the project main menu Add Web Reference or Add Service Reference then Advanced then Add Web Reference...

[caption id="attachment_778" align="aligncenter" width="450" caption="Add Web Reference"]Add Web Reference[/caption]

[caption id="attachment_779" align="aligncenter" width="450" caption="Add Reporting Services Reference"]Add Reporting Services Reference[/caption]

URL: http://{Server-Name}/reportserver/ReportService.asmx
Web reference name: Give it meaningful name..

What we did is adding web service by which we can talk to Reporting Services to ask it to do something like (create report, create data source, etc...).

Let's write some very simple C# code
We have method called DeployReports this method calls 3 other methods in order (CreateFolders, CreateDataSources, and CreateReports)
/// <summary>

/// Deploys Folders, DataSources, and Reports in Reporting Services by values configured in the application configuration file.

/// </summary>

private void DeployReports()

{

CreateFolders(

ConfigurationSettings.AppSettings["FoldersXMLFilePath"]);

CreateDataSources(

ConfigurationSettings.AppSettings["DataSourcesXMLFilePath"]);

CreateReports(Report.GetReports(

ConfigurationSettings.AppSettings["ReportsXMLFilePath"]));

}



/// <summary>

/// Creates Folder in Reporting Services.

/// </summary>

/// <param name="folderXMLFilePath">XML file path holds folder information.</param>

private void CreateFolders(string folderXMLFilePath)

{

ReportingService reportingServicesClient =

new ReportingService();

reportingServicesClient.Credentials = System.Net.CredentialCache.DefaultCredentials;

XDocument xmlDoc = XDocument.Load(folderXMLFilePath);

try

{

var result = from c in xmlDoc.Descendants("Folder")

select new

{

name = (string)c.Element("Name").Value,

parentFolder = (string)c.Element("ParentFolder").Value

};

foreach (var row in result)

{

reportingServicesClient.CreateFolder(row.name, row.parentFolder, null);

Logging.Log(string.Format("Folder {0} created successfully", row.name));

}

}

catch (Exception er)

{

Logging.Log(er.Message);

}

}

/// <summary>

/// Creates Data Sources in Reporting Services.

/// </summary>

/// <param name="datasourceXMLFilePath">XML file path holds Data Sources information.</param>

private void CreateDataSources(string datasourceXMLFilePath)

{

ReportingService reportingServicesClient =

new ReportingService();

reportingServicesClient.Credentials = System.Net.CredentialCache.DefaultCredentials;

DataSourceDefinition tempDataSource;

XDocument xmlDoc = XDocument.Load(datasourceXMLFilePath);

try

{

var result = from c in xmlDoc.Descendants("DataSource")

select new

{

name = (string)c.Element("Name").Value,

folder = (string)c.Element("Folder").Value,

description = (string)c.Element("Description").Value,

hideInListView = (string)c.Element("HideInListView").Value,

enabled = (string)c.Element("Enabled").Value,

connectionString = (string)c.Element("ConnectionString").Value,

extension = (string)c.Element("Extension").Value,

credentialRetrieval = (string)c.Element("CredentialRetrieval").Value,

windowsCredentials = (string)c.Element("WindowsCredentials").Value,

impersonateUser = (string)c.Element("ImpersonateUser").Value,

impersonateUserSpecified = (string)c.Element("ImpersonateUserSpecified").Value,

prompt = (string)c.Element("Prompt").Value,

userName = (string)c.Element("UserName").Value,

password = (string)c.Element("Password").Value,

enabledSpecified = (string)c.Element("EnabledSpecified").Value

};

foreach (var row in result)

{

CredentialRetrievalEnum credentialRetrieval;

EnumConverter ec =

new EnumConverter(typeof(CredentialRetrievalEnum));

credentialRetrieval = (CredentialRetrievalEnum)ec.ConvertFromString(row.credentialRetrieval);

tempDataSource = new DataSourceDefinition();

tempDataSource.CredentialRetrieval = credentialRetrieval;

tempDataSource.ConnectString = row.connectionString;

tempDataSource.Enabled = bool.Parse(row.enabled);

tempDataSource.EnabledSpecified = bool.Parse(row.enabledSpecified);

tempDataSource.Extension = row.extension;

tempDataSource.ImpersonateUserSpecified = bool.Parse(row.impersonateUserSpecified);

tempDataSource.ImpersonateUser = bool.Parse(row.impersonateUser);

tempDataSource.Prompt = row.prompt;

tempDataSource.WindowsCredentials = bool.Parse(row.windowsCredentials);

//tempDataSource.UserName = row.userName;

//tempDataSource.Password = row.password;

try

{

reportingServicesClient.CreateDataSource(row.name, row.folder, true, tempDataSource,

null);

Logging.Log(string.Format("Data Source {0} has created successfully", row.name));

}

catch (SoapException e)

{

Logging.Log(e.Detail.InnerXml.ToString());

}

}

}

catch (Exception er)

{

Logging.Log(er.Message);

}

}

/// <summary>

/// Creates Reports in Reporting Services.

/// </summary>

/// <param name="reports">XML file path holds Reports information.</param>

private void CreateReports(Report[] reports)

{

ReportingService rsc =

new ReportingService();

rsc.Credentials = System.Net.CredentialCache.DefaultCredentials;

foreach (Report aReport in reports)

{

Byte[] definition = null;

Warning[] warnings = null;

try

{

FileStream stream = File.OpenRead(aReport.Path);

definition = new Byte[stream.Length];

stream.Read(definition, 0, (int)stream.Length);

stream.Close();

}

catch (IOException e)

{

Logging.Log(e.Message);

}

try

{

rsc.CreateReport(aReport.Name, aReport.Folder, true, definition, null);

#region Setting Report Data Source

DataSourceReference reference = new DataSourceReference();

reference.Reference = aReport.DataSource;

DataSource[] dataSources = new DataSource[1];

DataSource ds = new DataSource();

ds.Item = (DataSourceDefinitionOrReference)reference;

ds.Name = aReport.DataSource.Split('/').Last();

dataSources[0] = ds;

rsc.SetReportDataSources(aReport.Folder + "/" + aReport.Name, dataSources);

#endregion

if (warnings != null)

{

foreach (Warning warning in warnings)

{

Logging.Log(string.Format("Report: {0} has warnings", warning.Message));

}

}

else

Logging.Log(string.Format("Report: {0} created successfully with no warnings", aReport.Name));

}

catch (SoapException e)

{

Logging.Log(e.Detail.InnerXml.ToString());

}

}

}


Report\Logger Class will be attached in the Source code...

I don't see any tough code to explain any developer familiar with C# will understand it very well, but if you have any question please feel free to ask me.


.. more.