We all know that we can create workflows using SharePoint designer as well as visual studio. However there are so many differences between creating workflow in each of them.
Let us explore the difference between SPD workflow and VS workflow.




SharePoint Kings,Technosavvy guys hunting SharePoint Challenges... SharePoint 2013, SharePoint 2010, MOSS 2007, Windows Workflow Foundation, Project Server and Other Related Technologies.
private void button8_Click(object sender, EventArgs e)
{
DownloadListItems.Lists objLists = new EncryptAndDecrypt.DownloadListItems.Lists();
objLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
objLists.Url = "{site-url}/_vti_bin/lists.asmx";
XmlNode node = objLists.GetAttachmentCollection("DummyList", "7");
DataSet ds = new DataSet();
using (XmlNodeReader reader = new XmlNodeReader(node))
{
ds.ReadXml(reader);
}
DataTable dtAttachment = ds.Tables[0];
for (int iCnt = 0; iCnt <= dtAttachment.Rows.Count - 1; iCnt++)
{
string sourceUrl = Convert.ToString(dtAttachment.Rows[iCnt]["Attachment_Text"]);
int strLastIndx = sourceUrl.LastIndexOf(@"/");
string FileName = sourceUrl.Substring(strLastIndx + 1);
using (WebClient client = new WebClient())
{
client.UseDefaultCredentials = true;
byte[] response = client.DownloadData(sourceUrl);
FileStream fStream = new FileStream(@"C:\DummyListAttachments\" + FileName, FileMode.Create, FileAccess.ReadWrite);
fStream.Write(response, 0, response.Length);
fStream.Close();
}
}
}
private void button7_Click(object sender, EventArgs e)
{
string strFilePath= textBox1.Text;
if (!File.Exists(strFilePath))
{
throw new ArgumentException(String.Format("{0} does not exist",
strFilePath), "srcUrl");
}
FileStream Stream = File.OpenRead(strFilePath);
string fileName = Stream.Name.Substring(3);
byte[] contents = new byte[Stream.Length];
Stream.Read(contents, 0, (int)Stream.Length);
Stream.Close();
DownloadListItems.Lists objLists = new EncryptAndDecrypt.DownloadListItems.Lists();
objLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
objLists.Url = "{site url}/_vti_bin/lists.asmx";
try
{
string addAttach = objLists.AddAttachment("DummyList", "7", fileName, contents);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
}
}
<script type="text/javascript" src="{site URL}/Shared%20Documents/jquery-latest.js">
</script>
$(document).ready(function() {
//Below function makes sure that if the status is not suspended in edit mode, it disables the reason text //area
var text = $("select[title$='Status'] :selected").text();
if(text != "Suspended")
{
$("textarea[title$='Reason'] ").attr('disabled', true);
}
$("select[title$='Status']").change(function()
{
var text = $("select[title$='Status'] :selected").text();
if(text == "Suspended")
{
alert('you must provide reason for suspending this order');
$("input[value$='OK']").attr('disabled', true);
$("textarea[title$='Reason'] ").attr('disabled', false);
}
else
{
$("input[value$='OK']").attr('disabled', false);
$("textarea[title$='Reason'] ").attr('disabled', true);
}
});
$("textarea[title$='Reason']").blur(function()
{
var text = $("textarea[title$='Reason'] ").text();
if(text.length <= 0)
{
$("input[value$='OK']").attr('disabled', true);
}
else
{
$("input[value$='OK']").attr('disabled', false);
}
});
});
</script>
private void button6_Click(object sender, EventArgs e)
{
string strQuery = "<Method ID='1' Cmd='New'>" +
"<Field Name='Title'>" + "Title Test" + "</Field>" +
"<Field Name='Price'>" + 12000 + "</Field>" +
"<Field Name='Group'>" + "GroupB" + "</Field></Method>";
DownloadListItems.Lists objLists = new EncryptAndDecrypt.DownloadListItems.Lists();
objLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
objLists.Url = "{site url}/_vti_bin/lists.asmx";
String listName = "DummyList";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.SetAttribute("ListVersion", "1");
elBatch.InnerXml = strQuery;
XmlNode ndReturn = objLists.UpdateListItems(listName, elBatch);
string result = ndReturn.OuterXml.ToString();
}
private void button5_Click(object sender, EventArgs e)
{
DownloadSharePointDocument.Copy copyService = new EncryptAndDecrypt.DownloadSharePointDocument.Copy();
copyService.Url = "{url}/" + "_vti_bin/copy.asmx";
copyService.Credentials = System.Net.CredentialCache.DefaultCredentials;
string[] DestinationUrl = (“url goes here” };
string strSource = @"C:\SmartSurvey.pdf";
DownloadSharePointDocument.CopyResult FirstResult = new DownloadSharePointDocument.CopyResult();
DownloadSharePointDocument.CopyResult SecondResult = new DownloadSharePointDocument.CopyResult();
DownloadSharePointDocument.CopyResult[] ArrayOfResult = { FirstResult, SecondResult };
DownloadSharePointDocument.FieldInformation fFiledInfo = new DownloadSharePointDocument.FieldInformation();
fFiledInfo.DisplayName = "Description";
fFiledInfo.Type = DownloadSharePointDocument.FieldType.Text;
fFiledInfo.Value = "This is the test description";
DownloadSharePointDocument.FieldInformation[] fFiledInfoArray = { fFiledInfo };
FileStream objStream = new FileStream(strSource, FileMode.Open, FileAccess.Read);
byte[] Contents = new Byte[objStream.Length];
byte[] r = new Byte[objStream.Length];
int Read= objStream.Read(Contents, 0, Convert.ToInt32(objStream.Length));
objStream.Close();
uint copyresult = copyService.CopyIntoItems(strSource, DestinationUrl, fFiledInfoArray, Contents, out ArrayOfResult);
}
private void button3_Click(object sender, EventArgs e)
{
XmlDocument xmldoc = new System.Xml.XmlDocument();
string URL = "";
string FileName = "";
DownloadListItems.Lists objLists = new EncryptAndDecrypt.DownloadListItems.Lists();
objLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
objLists.Url = "{siteurl}/_vti_bin/lists.asmx";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode xmlQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode xmlViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode xmlQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
xmlQueryOptions.InnerXml = "<ViewAttributes Scope='RecursiveAll' IncludeRootFolder='True' />";
xmlViewFields.InnerXml = "";
xmlQuery.InnerXml = "";
try
{
XmlNode xmlListItems = objLists.GetListItems("Shared Documents", null, xmlQuery, xmlViewFields, null, xmlQueryOptions, null); //change the document library name to your document library
XmlNodeList oNodes = xmlListItems.ChildNodes;
foreach (XmlNode node in oNodes)
{
XmlNodeReader Reader = new XmlNodeReader(node);
while (Reader.Read())
{
if (Reader["ows_EncodedAbsUrl"] != null && Reader["ows_LinkFilename"] != null)
{
URL = Reader["ows_EncodedAbsUrl"].ToString();
FileName = Reader["ows_LinkFilename"].ToString();
CopyAndSaveAttachment(URL, FileName);
}
}
}
Console.ReadLine();
}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw ex;
}
}
public static void CopyAndSaveAttachment(string URL, string FileName)
{
HttpWebRequest request;
HttpWebResponse response = null;
try
{
request = (HttpWebRequest)WebRequest.Create(URL);
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Timeout = 10000;
request.AllowWriteStreamBuffering = false;
response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
//Write to disk
FileStream fs = new FileStream(@"C:\DownLoads\" + FileName, FileMode.Create);
byte[] read = new byte[4096];
int count = s.Read(read, 0, read.Length);
while (count > 0)
{
fs.Write(read, 0, count);
count = s.Read(read, 0, read.Length);
}
//Close everything
fs.Close();
s.Close();
response.Close();
}
catch (Exception ex)
{
throw ex;
}
}