Hello
I am considering such scenario - one web service for appointments and multi-client schedulers.
I have created asp.net page with radscheduler and webservice binding.
Now I am trying to use this web service for winforms scheduler (I am performing some operations in web service so solution with direct db access is unacceptable for me and I would like to have everything in one piece, in web service).
So I am trying to get appointments from this web service - unfortunately it is JSON service so it is not so easy..
I can't deserialize such method in forms client
public
List<AppointmentData> GetJSONScheduler(SchedulerInfo schedulerInfo)
I am suceesfully invoke this method (but I have to make some modifications in JSON string before send it) and I can't deserialize return List
I have been trying:
DataContractJsonSerializer dJSON =
new
DataContractJsonSerializer(
typeof
(List<AppointmentData>);
List<AppointmentData> sr = (List<AppointmentData>)dJSON.ReadObject(str);
//str is response from HttpWebResponse
JavaScriptSerializer jscriptDeserializer =
new
JavaScriptSerializer();
jscriptDeserializer.RecursionLimit = 100;
List<AppointmentData> srResult = jscriptDeserializer.Deserialize<List<AppointmentData>>(sbResponse.ToString());
//sbResponse is StringBuilder made from GetResponseStream() of HttpWebResponse
Do you have any advices?
Thanks in advance
Regards
I created two web solutions, A and B. And I added a data entry web form (DataEntery.aspx) into Solution A, with third party user controls and form authentication.
I want to use the web page DataEntery.aspx into solution B. What is the best method for it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
public partial class TestPages_TestComboCheckBoxes : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
//this is name of combo
rcbMitkanKav.ItemTemplate = new ItemTemplate();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
LoadData();
}
protected void rcbMitkanKav_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
{
DataTable dtMitkanimKavim = new DataTable();
const string MethodName = "SearchPopWindow.rcbMitkanKav_ItemsRequested";
int UserErrorCode = 6;
try
{
string sComboText = e.Text;
//pattern to search
string sSearchLetter = "";
if (sComboText == "")
{
sSearchLetter = "";
}
if (sComboText != "")
{
sSearchLetter = sComboText;
}
try
{
if (sSearchLetter.Length <
3
)
return;
int
queryId
=
1
;
dtMitkanimKavim
=
GetSearchResultByWord
(sSearchLetter, queryId);
int
itemsPerRequest
=
30
;
int
itemOffset
= e.NumberOfItems;
int
endOffset
=
itemOffset
+ itemsPerRequest;
if (endOffset > dtMitkanimKavim.Rows.Count)
{
endOffset = dtMitkanimKavim.Rows.Count;
}
if (endOffset == dtMitkanimKavim.Rows.Count)
{
e.EndOfItems = true;
}
else
{
e.EndOfItems = false;
}
rcbMitkanKav.DataSource = dtMitkanimKavim;
rcbMitkanKav.DataBind();
}
catch
{
e.Message = "××× ×Ø×©××××Ŗ";
}
}
catch (Exception ex)
{
throw ex;
}
}
private void LoadData()
{
try
{
///here code to load data from database int a table and save it in Session
}
catch (Exception ex)
{
throw ex;
}
}
/// <
summary
>
///
/// </
summary
>
/// <
param
name
=
"sSearchWord"
>curren input</
param
>
/// <
param
name
=
"queryId"
></
param
>
/// <
returns
></
returns
>
public DataTable GetSearchResultByWord(string sSearchWord, int queryId)
{
DataTable dt = new DataTable();
//build new datable is contain two columns
dt.Columns.Add("ComboValue");
dt.Columns.Add("ComboText");
DataRow newRow = null;
string currentValue = string.Empty;
///array of rows from a table according to current input sSearchWord
DataRow[] drSelected = null;
///replace "'" to sql select
if (sSearchWord.Contains("'"))
sSearchWord = sSearchWord.Replace("'", "''");
try
{
drSelected = SessionManager.dtMitkanimKavim.Select("NameReferenceId LIKE '" + "%" + sSearchWord + "%" + "'") as DataRow[];
//add array to new datable
foreach (DataRow row in drSelected)
{
dt.Rows.Add(row);
}
}
catch (Exception ex)
{
throw ex;
}
return dt;
}
}
class ItemTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
CheckBox chk = new CheckBox();
//chk.ID = "chk1";
chk.Attributes.Add("onclick", "SetCheckedStateToServer()");
Label lbl = new Label();
Table table = new Table();
TableRow mainRow = new TableRow();
TableCell cell1 = new TableCell();
cell1.Controls.Add(chk);
cell1.DataBinding += new EventHandler(cell1_DataBinding);
mainRow.Cells.Add(cell1);
TableCell cell2 = new TableCell();
cell2.Controls.Add(lbl);
cell2.DataBinding += new EventHandler(cell2_DataBinding);
mainRow.Cells.Add(cell2);
table.Rows.Add(mainRow);
container.Controls.Add(table);
}
private void cell1_DataBinding(object sender, EventArgs e)
{
TableCell target = (TableCell)sender;
(target.Controls[0] as CheckBox).Checked = true;
}
private void cell2_DataBinding(object sender, EventArgs e)
{
TableCell target = (TableCell)sender;
RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer;
(target.Controls[0] as Label).Text =
((DataRowView)(item.DataItem)).Row[1].ToString();
}
}