public static AjaxResponse ChangeExampleInformationQueryItemListPerPageRowCountTo(string data) { AjaxResponse ajaxResponse = new AjaxResponse(); try { Dictionary <String, String> dssData = rf.RF.GlobalClass.Utils.Convert.JSONToObject <Dictionary <String, String> >(Uri.UnescapeDataString(data)); //ajaxResponse = "{status:'failure',message:'查询失败',data:{a:'A'}}"; ajaxResponse.status = RequestBus.RetCode.success.ToString(); ajaxResponse.message = ""; Location location = new Location(); //location.protocol = "http:"; //location.hostname = "localhost"; //location.port = "1352"; //location.pathname = ""; location.search = "?view=ViewEL&ChangeExampleInformationQueryItemListPerPageRowCountTo="; //location.hash = ""; ajaxResponse.location = location; Dictionary <string, List <Dictionary <string, string> > > ajaxResponseData = new Dictionary <string, List <Dictionary <string, string> > >(); ajaxResponseData["info"] = (new List <Dictionary <string, string> > { new Dictionary <string, string> { { "author", "dear.will" } } }); ajaxResponseData[RequestBus.Param("jumpdata")] = new List <Dictionary <string, string> > { dssData }; ajaxResponse.jumpingData = dssData; ajaxResponse.data = ajaxResponseData; } catch (Exception ex) { } return(ajaxResponse); }
protected void ViewEL_Activate(object sender, EventArgs e) { Dictionary <String, String> dssPostPut = RequestBus.GetPostPutData(Request: Request); InitValueFromRequest(dssPostPut: dssPostPut); DrawItemListTable(dssPostPut: dssPostPut); }
private void DrawItemListTable(Dictionary <String, String> dssPostPut = null) { #region prepare data for table DataTable dt = new DataTable("ExampleItem", "ExampleList"); dssPostPut = dssPostPut ?? RequestBus.GetPostPutData(Request: Request); string jumpdata = RequestBus.Param("jumpdata"); List <Dictionary <string, string> > ldss = new List <Dictionary <string, string> >(); string tableExampleInformationQueryItemListPerPageRowCount = dssPostPut.TryGetValue("ChangeExampleInformationQueryItemListPerPageRowCountTo", out tmpStr) ? tmpStr : "5"; string tableExampleInformationQueryItemListCurrPageNum = "1"; #region set data to the view string exampleType = vEL_QExampleType.Text = dssPostPut.TryGetValue("QExampleType", out exampleType) ? exampleType : String.Empty; tableExampleInformationQueryItemListPerPageRowCount = vELTableExampleInformationQueryItemList_PerPageRowCount.Text = dssPostPut.TryGetValue("vELTableExampleInformationQueryItemListPerPageRowCount", out tmpStr) ? tmpStr : tableExampleInformationQueryItemListPerPageRowCount; tableExampleInformationQueryItemListCurrPageNum = vELTableExampleInformationQueryItemList_CurrPageNum.Text = dssPostPut.TryGetValue("vELTableExampleInformationQueryItemListCurrPageNum", out tmpStr) ? tmpStr : tableExampleInformationQueryItemListCurrPageNum; string tableExampleInformationQueryItemListPageTotalCount = vELTableExampleInformationQueryItemList_PageTotalCount.Text = dssPostPut.TryGetValue("vELTableExampleInformationQueryItemListPerPageRowCount", out tmpStr) ? tmpStr : tableExampleInformationQueryItemListCurrPageNum; string tableExampleInformationQueryItemListRowTotalCount = vELTableExampleInformationQueryItemList_RowTotalCount.Text = dssPostPut.TryGetValue("vELTableExampleInformationQueryItemListRowTotalCount", out tmpStr) ? tmpStr : "X"; #endregion int perPageRowCount = int.TryParse(tableExampleInformationQueryItemListPerPageRowCount, out perPageRowCount) ? perPageRowCount : 5; /* * Use RFDataTable to deal with the data. * */ RFDataTable rfdteiqil = new RFDataTable("vELTableExampleInformationQueryItemList", request: Request, response: Response); rfdteiqil.BeforePageChange += new RFDataTable.BeforePageChangeHandler(rfdteiqil_BeforePageChange); rfdteiqil.WhenPageChange += new RFDataTable.WhenPageChangeHandler(rfdteiqil_WhenPageChange); rfdteiqil.AfterPageChange += new RFDataTable.AfterPageChangeHandler(rfdteiqil_AfterPageChange); dataSet.Tables.Add( rfdteiqil.ChangePageTo( currPage: tableExampleInformationQueryItemListCurrPageNum, perPageRowCount: perPageRowCount.ToString(), dssPostData: dssPostPut, dataTableName: "TableExampleInformationQueryItemList", dataTableNamespace: "ExampleList", columnKeyIDPair: new Dictionary <string, string> { { "RowCount", "id" } , { "Code", "code" } , { "Name", "name" } , { "Status", "status" } , { "Description", "description" } } , t: vELTableExampleInformationQueryItemList ) ); #endregion #region draw data table with data try { RF.GlobalClass.WebForm.fillTableAccordingToData(vELTableExampleInformationQueryItemList, dataSet.Tables["TableExampleInformationQueryItemList", "ExampleList"]); } catch (Exception ex) { } #endregion }
/// <summary> /// Used to turn to authorizable page, will check before response the page url. /// </summary> /// <param name="viewID">the target view</param> /// <param name="moduleID">authorization module id</param> /// <param name="invalidMessage">message for failing the authorization checking </param> /// <param name="dssParam">param from the client can be in post or put</param> /// <param name="result">the result</param> public void TurnToAuthorizablePage(String viewID, String moduleID, String invalidMessage = "", Dictionary <string, string> dssParam = null, AjaxResponse result = null, String successPowerID = "01") { Dictionary <string, AjaxResponse> dsar = new Dictionary <string, AjaxResponse>(); try { // Dictionary<string, string> dss = RequestBus.GetPutData(Request:Request); dssParam = dssParam ?? new Dictionary <string, string>(); ModuleID = moduleID; #if !DEBUG if (successPowerID == RequestPowerID() && null == result) { #endif result = new WAExample.AjaxResponse(); //result = "{status:'failure',message:'查询失败',data:{a:'A'}}"; result.status = "success"; // result.message = "查询成功"; Location location = new Location(); //location.protocol = "http:"; //location.hostname = "localhost"; //location.port = "1352"; //location.pathname = ""; location.search = "?view=" + viewID; //"?ChangeModificationListPerPageRowCountTo="; //location.hash = ""; result.location = location; Dictionary <string, List <Dictionary <string, string> > > resultData = new Dictionary <string, List <Dictionary <string, string> > >(); resultData["a"] = (new List <Dictionary <string, string> > { new Dictionary <string, string> { { "a", "A" } } }); resultData[RequestBus.Param("jumpdata")] = (new List <Dictionary <string, string> > { dssParam }); result.data = resultData; #if !DEBUG } else { result = new WAExample.AjaxResponse(); result.status = "success"; result.message = invalidMessage ?? "尚无此权限"; } #endif dsar["d"] = result; } catch (Exception ex) { WAExample.AjaxResponse ar = new AjaxResponse(); ar.status = "failure"; ar.message = "系统异常,请稍后再试。"; // ex.Message; dsar["d"] = ar; } Response.ClearContent(); Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dsar)); Response.End(); }
/// <summary> /// 获取Session /// </summary> public void RequestUserSession(string sessionName = "user") { RequestBus rb = new RequestBus(); rb.SetSession(); UserSession = (UserSession)RF.GlobalClass.Utils.Convert .JSONToObject((HttpContext.Current.Session[sessionName] ?? "") .ToString(), type: typeof(UserSession)); //UserSession = (UserSession)JsonConvert // .DeserializeObject((HttpContext.Current.Session["user"] ?? "") // .ToString(), typeof(UserSession)); }
/// <summary> /// Get Jumping Data From post/put result which is encoded. /// </summary> /// <param name="dss"></param> /// <param name="jumpingData"></param> /// <returns></returns> /// <example> /// <code language="C#" description=""> /// resultData[RequestBus.Param("jumpdata")] = RequestBus.GetJumpingData(dss, jumpingData:"jumpdata"); /// ajaxResponse.data = resultData; /// </code> /// </example> public static List <Dictionary <string, string> > GetDecodedJumpingData(Dictionary <string, string> dss, string jumpingData = "jumpdata") { List <Dictionary <string, string> > ldss = new List <Dictionary <string, string> >(); string jumpData = dss.TryGetValue(RequestBus.Param(jumpingData), out jumpData) ? jumpData : String.Empty; try { ldss = (List <Dictionary <string, string> >)RF.GlobalClass.Utils.Convert.JSONToObject(System.Web.HttpUtility.HtmlDecode(jumpData), type: typeof(List <Dictionary <string, string> >), mode: "array"); } catch (Exception ex) { } return(ldss ?? new List <Dictionary <String, String> >()); }
/// <summary> /// Get data for table list /// </summary> /// <param name="tableName"></param> /// <param name="tableNameSpace"></param> /// <param name="tableCurrPageNum"></param> /// <param name="tablePerPageRowCount"></param> /// <param name="beforePageChange"></param> /// <param name="whenPageChange"></param> /// <param name="afterPageChange"></param> /// <param name="request"></param> /// <param name="response"></param> /// <param name="table"></param> /// <param name="columnKeyIDPair"></param> /// <param name="perPageRowCountControl"></param> /// <param name="currPageNumControl"></param> /// <param name="pageTatolCountControl"></param> /// <param name="rowTotalCountControl"></param> /// <param name="perPageRowCountName"></param> /// <param name="currPageNumName"></param> /// <param name="pageTotalCountName"></param> /// <param name="rowTotalCountName"></param> /// <param name="jumpingDataName"></param> /// <param name="perPageRowCountParamName"></param> /// <param name="dataSet"></param> /// <example> /// <code language="CSharp" description=""> /// WebAppOffice.GB.WebReference.getDataForListTable(tableName: "", tableNameSpace: "", tableCurrPageNum: "1", tablePerPageRowCount: "10", /// beforePageChange: (new WebAppOffice.RFDataTable.BeforePageChangeHandler(rfdtarql_BeforePageChange)), /// whenPageChange: (new WebAppOffice.RFDataTable.WhenPageChangeHandler(rfdtarql_WhenPageChange)), /// afterPageChange: (new WebAppOffice.RFDataTable.AfterPageChangeHandler(rfdtarql_AfterPageChange)), /// request: Request, response: Response, /// table: v2_TableInformationQueryItemList, /// columnKeyIDPair: new Dictionary<string, string> { /// { "Code", "dptid" }, { "Name", "dptdes" }, /// { "Address", "adr1" }, { "PhoneNumber", "tel" }, /// {"Section","prtdptid"},{"EffectsRadius","jl"}, /// {"MasterName","xm"},{"MasterPhoneNumber","sj"}, /// {"SectionDirectorName","prtdz"},{"SectionDirectorPhoneNumber","prtdztel"} }, /// perPageRowCountControl: v2_TableInformationQueryItemList_PerPageRowCount, /// currPageNumControl: v2_TableInformationQueryItemList_CurrPageNum, /// pageTatolCountControl: v2_TableInformationQueryItemList_PageTotalCount, /// rowTotalCountControl: v2_TableInformationQueryItemList_RowTotalCount, /// perPageRowCountName: "PerPageRowCount", /// currPageNumName: "CurrPageNum", /// pageTotalCountName: "pageTotalCount", /// rowTotalCountName: "RowTotalCount", /// jumpingDataName: "jumpdata", /// perPageRowCountParamName: "PerPageRowCount", dataSet:dataSet); /// </code> /// </example> public static void getDataForListTable(string tableName, string tableNameSpace, string tableCurrPageNum, string tablePerPageRowCount, RFDataTable.BeforePageChangeHandler beforePageChange, RFDataTable.WhenPageChangeHandler whenPageChange, RFDataTable.AfterPageChangeHandler afterPageChange, HttpRequest request, HttpResponse response, System.Web.UI.WebControls.Table table, Dictionary <string, string> columnKeyIDPair, System.Web.UI.WebControls.DropDownList perPageRowCountControl, System.Web.UI.WebControls.TextBox currPageNumControl, System.Web.UI.WebControls.Label pageTatolCountControl, System.Web.UI.WebControls.Label rowTotalCountControl, string perPageRowCountName, string currPageNumName, string pageTotalCountName, string rowTotalCountName, string jumpingDataName, string perPageRowCountParamName, System.Data.DataSet dataSet, RFDataTable rfDataTable) { Dictionary <string, string> dssPost = new Dictionary <string, string>(); Dictionary <string, string> dssPut = RequestBus.GetPutData(request); Dictionary <String, List <Dictionary <string, string> > > dsldssPost = RequestBus.GetPostData <Dictionary <String, List <Dictionary <string, string> > > >(request); AjaxResponse ar = new AjaxResponse(); ar.data = dsldssPost; string jumpdata = RequestBus.Param(jumpingDataName); List <Dictionary <string, string> > ldss = new List <Dictionary <string, string> >(); rfDataTable = rfDataTable ?? new RFDataTable(tableName, request: request, response: response); rfDataTable.Name = tableName ?? rfDataTable.Name; tableName = rfDataTable.Name; if (null != dsldssPost && ((dsldssPost.TryGetValue(jumpdata, out ldss)) || dsldssPost.ContainsKey(tableName + perPageRowCountParamName))) { #region set data to the view // ldss[0].TryGetValue("", out jumpdata); dssPost = (ldss.Count > 0 ? (ldss[0] ?? dssPost) : dssPost); dssPut.ToList().ForEach(x => dssPost[x.Key] = dssPost.ContainsKey(x.Key) ? dssPost[x.Key] : x.Value); //string beginDate = v0_BeginDate.Text = dssPost.TryGetValue("BeginDate", out beginDate) ? beginDate : String.Empty; //string endDate = v0_EndDate.Text = dssPost.TryGetValue("EndDate", out endDate) ? endDate : String.Empty; perPageRowCountControl.Text = tablePerPageRowCount ?? perPageRowCountControl.Text; tablePerPageRowCount = perPageRowCountControl.Text = dssPost.TryGetValue(tableName + perPageRowCountName, out tablePerPageRowCount) ? tablePerPageRowCount : perPageRowCountControl.Text; tableCurrPageNum = currPageNumControl.Text = dssPost.TryGetValue(tableName + currPageNumName, out tableCurrPageNum) ? tableCurrPageNum : tableCurrPageNum; string TablePageTotalCount = pageTatolCountControl.Text = dssPost.TryGetValue(tableName + pageTotalCountName, out TablePageTotalCount) ? TablePageTotalCount : tableCurrPageNum; string TableRowTotalCount = rowTotalCountControl.Text = dssPost.TryGetValue(tableName + rowTotalCountName, out TableRowTotalCount) ? TableRowTotalCount : "X"; #endregion } else { } int perPageRowCount = int.TryParse(tablePerPageRowCount, out perPageRowCount) ? perPageRowCount : 5; rfDataTable.BeforePageChange += new RFDataTable.BeforePageChangeHandler(beforePageChange); rfDataTable.WhenPageChange += new RFDataTable.WhenPageChangeHandler(whenPageChange); rfDataTable.AfterPageChange += new RFDataTable.AfterPageChangeHandler(afterPageChange); dataSet.Tables.Add(rfDataTable.ChangePageTo( currPage: tableCurrPageNum, perPageRowCount: perPageRowCount.ToString(), dssPostData: dssPost, dataTableName: tableName, dataTableNamespace: tableNameSpace, columnKeyIDPair: columnKeyIDPair, t: table)); }
/// <summary> /// 获取权限 /// </summary> /// <param name="signName"></param> /// public string RequestPowerID(string moduleID = "") { string resultStr = ""; moduleID = "" == moduleID ? ModuleID : moduleID; //string jsonText = @"{""empid"":'"+userSession.empid+@"',""mdlid"":'0018',""clsid"":'getPWR',""TimeStamp"":'2013-11-13 10:42:35',""OpenName"":'rfOaService',""Sign"":'" + signName + @"',""MethodName"":'redforce'}"; string pwrid = (UserSession.empid == "47" ? "01" : ""); string jsonText = GetJsonTextWithSignName("GetPwr" , @"{""empid"":'" + UserSession.empid + @"',""mdlid"":'" + moduleID + @"',""clsid"":'getPWR'" + @",""TimeStamp"":'" + RequestBus.GetDateTimeString(DateTime.Now) + @"',""OpenName"":'" + OpenName + @"',""Sign"":'" + SignName + @"',""MethodName"":'" + MethodName + @"'}"); //Response.Write(nm.GetPwr(jsonText).Obj); //SRExample.ResultMsg resultMsg = (new GB.WebReference(response: Response)) // .GetSRExampleResultMsg("ExampleData", jsonText); string interfaceName = "GetPowerInfo"; jsonText = GetJsonTextWithSignName(methodName: interfaceName, jsonText: ""); SRExample.ResultMsg resultMsg = (new GB.WebReference(response: Response)) .GetResultMsg <SRExample.ServiceSoapClient, Func <SRExample.ServiceSoapClient, String, SRExample.ResultMsg>, SRExample.ResultMsg>(serviceSoapClient: new SRExample.ServiceSoapClient(), interfaceName: interfaceName, jsonText: jsonText); if (null != resultMsg && null != resultMsg.Obj) { if ("00" == resultMsg.RetCode) { RequestBus.ConvertResultMsgObj(resultMsg.Obj); List <Dictionary <string, string> > power = RequestBus.ConvertResultMsgObj(resultMsg.Obj); //Power power = (Power)RequestBus.JsonConvertDeserializeObject(resultMsg.Obj.ToString(), type:typeof(Power)) ?? new Power(); resultStr = 0 == power.Count ? pwrid : (power[0]["powerID"] ?? pwrid).ToString().Trim() ?? pwrid; } else { resultStr = ""; } } else { } PowerID = resultStr; return(resultStr); }
/// <summary> /// 获取ServiceReference查询结果。 /// </summary> /// <typeparam name="T">serviceSOAPClient</typeparam> /// <typeparam name="U">Func<></typeparam> /// <typeparam name="V">ResultMsg</typeparam> /// <param name="serviceSoapClient"></param> /// <param name="interfaceName"></param> /// <param name="jsonText"></param> /// <param name="obj">passengers</param> /// <param name="specifiedFields"></param> /// <param name="keyIDpair"></param> /// <returns></returns> internal V GetResultMsg <T, U, V>(T serviceSoapClient, string interfaceName, string jsonText = "", RequestBus.Passengers obj = null, Dictionary <string, string> specifiedFields = null, Dictionary <string, string> keyIDpair = null) { V resultMsg = default(V); Type type = String.Empty.GetType(); try { if (null != obj) { GB.Authorization gba = new Authorization(); jsonText = gba.GetJsonTextWithSignName(methodName: interfaceName, jsonText: String.Empty, methodParamObjectArray: new object[] { obj, specifiedFields, keyIDpair }); // Response.Write(jsonText); } else { } var gim = GetInterfaceMethod <T, V, Func <T, String, V> >(interfaceName: interfaceName); //"[{\"RetCode\":\"00\",\"RetMsg\": \"OK\",\"obj\":\"[{powerID:\"\"00\"\"}, {powerID:\"\"01\"\"}]\"}]" resultMsg = gim(serviceSoapClient, jsonText); } catch (Exception Exception) { throw Exception; } try { if (null == resultMsg) { Response.ClearContent(); RequestBus.ajaxResponseOfResultMsgNull(Response: Response); Response.End(); return(resultMsg); } else { } } catch (Exception ex) { } return(resultMsg); }
private void DrawItemDropDownList() { Dictionary <String, String> dssPostPut = RequestBus.GetPostPutData(Request: Request); SRExample.ResultMsg resultMsg = GetExampleType(); if (resultMsg.RetCode != RequestBus.RetCode.success.ToString()) { return; } else { } Dictionary <String, List <Dictionary <String, String> > > dsldss = RequestBus.ConvertResultMsgProperty <Dictionary <String, List <Dictionary <String, String> > > >(resultMsg.Obj); List <Dictionary <String, String> > ldss = RequestBus.ConvertResultMsgObj(resultMsg.Obj); ldss = dsldss.TryGetValue(RFDataTable.ServiceResultMsg.DataRecordsName, out ldss) ? ldss : ldss; GB.WebControl.DropDownListBindData(ddl: vEQ_QExampleTypeList, ldss: ldss, dataTextField: "name", dataValueField: "code"); string exampleType = vEQ_QExampleTypeList.SelectedValue = dssPostPut.TryGetValue("QExampleType", out exampleType) ? exampleType : vEQ_QExampleTypeList.SelectedValue; }
/// <summary> /// 获取SRExample查询结果。 /// </summary> /// <param name="p"></param> /// <param name="jsonText"></param> /// <param name="obj"></param> /// <param name="specifiedFields"></param> /// <param name="keyIDpair"></param> /// <returns></returns> internal SRExample.ResultMsg GetSRExampleResultMsg(string serviceName = "", string methodName = "", string jsonText = "", RequestBus.Passengers obj = null, Dictionary <string, string> specifiedFields = null, Dictionary <string, string> keyIDpair = null) { Type t = typeof(SRExample.ResultMsg); SRExample.ServiceSoapClient ssc = new SRExample.ServiceSoapClient(); SRExample.ResultMsg resultMsg = null; try { if (null != obj) { GB.Authorization gba = new Authorization(); // jsonText = gba.GetJsonTextWithSignName("WPWeb", obj: obj, specifiedFields: specifiedFields, keyIDpair: keyIDpair); jsonText = gba.GetJsonTextWithSignName(serviceName: serviceName, methodName: methodName, methodParamObjectArray: new object[] { obj, specifiedFields, keyIDpair }); // Response.Write(jsonText); } else { } resultMsg = (RF.GlobalClass.Utils.Do.MagicMethod <SRExample.ServiceSoapClient, Func <SRExample.ServiceSoapClient, String, SRExample.ResultMsg> >(typeof(SRExample.ServiceSoapClient).GetMethod(methodName, new[] { typeof(string) })))(ssc, jsonText) as SRExample.ResultMsg; } catch (Exception Exception) { throw Exception; } try { if (null == resultMsg) { Response.ClearContent(); RequestBus.ajaxResponseOfResultMsgNull(Response: Response); Response.End(); return(resultMsg); } else { } } catch (Exception ex) { } return(resultMsg); }
/// <summary> /// Fill the Result Data to dsldssData /// </summary> /// <param name="resultMsg"></param> /// <param name="currPage"></param> /// <param name="perPageRowCount"></param> /// <returns></returns> public Dictionary <string, List <Dictionary <string, string> > > fillResultDataToResultDict(ServiceResultMsg resultMsg, String currPage = "1", String perPageRowCount = "5") { Dictionary <string, List <Dictionary <string, string> > > resultData = new Dictionary <string, List <Dictionary <string, string> > >(); try { Dictionary <String, List <Dictionary <String, String> > > dldss = RequestBus.ConvertResultMsgProperty <Dictionary <String, List <Dictionary <String, String> > > >(resultMsg.Obj); List <Dictionary <String, String> > ldss = dldss.TryGetValue(ServiceResultMsg.DataRecordsName, out ldss) ? ldss : ldss; resultData[Name] = ldss; ldss = dldss.TryGetValue(ServiceResultMsg.DataInfoName, out ldss) ? ldss : ldss; string recordCount = "", pageCount = "", currentPage = ""; ldss.ForEach(delegate(Dictionary <string, string> _dss) { _dss.TryGetValue(ServiceResultMsg.RecordCountName, out recordCount); _dss.TryGetValue(ServiceResultMsg.PageCountName, out pageCount); _dss.TryGetValue(ServiceResultMsg.CurrentPageName, out currentPage); }); currentPage = currentPage ?? currPage; int currentPageIndex = 0; int.TryParse(currentPage.Trim(), out currentPageIndex); currentPageIndex = --currentPageIndex; int rowTotalCount = 0; int pageTotalCount = 0; int.TryParse(recordCount.Trim(), out rowTotalCount); pageCount = pageCount == "0" ? "1" : pageCount; int.TryParse(pageCount.Trim(), out pageTotalCount); resultData[InfoName] = (new List <Dictionary <string, string> > { new Dictionary <string, string> { { RowTotalCountKey, recordCount }, { PerPageRowCountKey, Math.Max(int.Parse(perPageRowCount), (0 == pageTotalCount? 0: ((rowTotalCount) / (pageTotalCount) + (0 == (rowTotalCount) % (pageTotalCount)?0:1)))).ToString() }, { PageTotalCountKey, pageCount }, { CurrPageIndexKey, currentPageIndex.ToString() }, { CurrPageNumKey, currentPage }, { RowCheckedStatusKey, "false" } } }); } catch (Exception ex) { } return(resultData); }
/// <summary> /// 获取签名 /// </summary> /// <param name="p">functionName:GetPwr/GetInfoLst/</param> /// <param name="jsonText"></param> /// <returns></returns> public virtual string GetSignName(string p, string jsonText = "") { string resultStr = ""; // string jsonText = @"{""empid"":'502',""mdlid"":'0018',""clsid"":'getPWR',""TimeStamp"":'2013-11-13 10:42:35',""OpenName"":'rfOaService',""Sign"":'9D91A0B958DDA93C9F848046E481CB53',""MethodName"":'redforce'}"; jsonText = jsonText ?? @"{""empid"":'" + UserSession.empid + @"',""mdlid"":'" + ModuleID + @"',""clsid"":'" + UserSession.log + @"',""TimeStamp"":'" + RequestBus.GetDateTimeString(DateTime.Now) + @"',""OpenName"":'" + OpenName + @"',""Sign"":'9D91A0B958DDA93C9F848046E481CB53'" + @",""MethodName"":'" + MethodName + @"'}"; switch (p) { case "GetPwr": //resultStr = RequestBus.DirGetRequestStr(jsonText); break; case "GetInfoLst": //resultStr = RequestBus.NoteDirGetRequest(jsonText); break; case "GetReplyFlg": //resultStr = RequestBus.GetReadNoteFlgSig(jsonText); break; case "SetReplyFlg": //resultStr = RequestBus.GetReadNoteFlgSig(jsonText); break; case "ReadSingNote": //resultStr = RequestBus.SingNoteDirSig(jsonText); break; default: break; } #if DEBUG && PRTRESULTMSG Response.Write(resultStr); #endif return(resultStr); }
protected void Page_Load(object sender, EventArgs e) { Dictionary <string, string> dss = RequestBus.GetPutData(Request: Request); string moduleIDStr = String.Empty; if (!dss.TryGetValue("PageRoleID", out moduleIDStr)) { moduleIDStr = ModuleID.Value; } else { ModuleID.Value = moduleIDStr; vEQ_ModuleID.Text = moduleIDStr; vEL_ModuleID.Text = moduleIDStr; } GBA = RequestBus.getGBA(Response: Response, moduleID: moduleIDStr, openName: "WangZhi", methodName: ""); // getGBA(Response, ModuleID.Value); GBW = RequestBus.getGBW(Response: Response); // getGBW(Response); dataSet = new DataSet(); if (!IsPostBack) { InitPage(); } else { ReLoadPage(); } try { IEV = RF.GlobalClass.Utils.WebBrowser.getInternetExplorerVersion(Request); WV = float.Parse(RF.GlobalClass.Utils.WebBrowser.getPlatform(Request).ToString()); GBW.CheckIEBrowser(Request: Request); } catch (Exception ex) { // Response.Write(ex.Message); } }
void btnSendRequest_Click(object sender, EventArgs e) { Dictionary <string, string> specifiedFields = new Dictionary <string, string>(); Dictionary <string, string> keyIDPair = new Dictionary <string, string>(); cc.Controls.Select(delegate(Control c) { string t = ((TextBox)c).Text; string cID = c.ID; if (dssKeyIDPair.ContainsValue(cID)) { cID = dssKeyIDPair.Keys.Where(delegate(string _i) { return(dssKeyIDPair[_i] == cID); }).FirstOrDefault <string>(); } else { } passengers.GetType().GetProperty(cID).SetValue(passengers, t, null); keyIDPair[cID] = c.ID; if (cID != "Sign") { if ((form1.FindControl("cb_" + c.ID) as CheckBox).Checked) { specifiedFields[c.ID] = (c as TextBox).ToolTip ?? String.Empty; if (String.IsNullOrEmpty(specifiedFields[c.ID])) { // openWith.Add(c.ID, t); } else { // openWith.Add(specifiedFields[c.ID], t); } } else { // openWith.Add(c.ID, t); } } else { } return(c); }).ToArray(); string sign = String.Empty; ((Dictionary <string, string>)RF.GlobalClass.Utils.Convert.JSONToObject(GBA.GetJsonTextWithSignName(methodName: ((DropDownList)form1.FindControl("InterfaceName")).Text, methodParamObjectArray: new Object [] { passengers, specifiedFields, keyIDPair }), type: typeof(Dictionary <string, string>))).TryGetValue("Sign", out sign); ((TextBox)form1.FindControl("Sign")).Text = sign; passengers.passenger0 = sign; // SRExample.ResultMsg resultMsg = GBW.GetSRExampleResultMsg(((DropDownList)form1.FindControl("InterfaceName")).Text, obj: passengers, specifiedFields: specifiedFields, keyIDpair: keyIDPair); #region test string @namespace = "WAExample"; AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes()) .Where(t => t.IsClass && t.Namespace == @namespace && t.Name == serviceName).FirstOrDefault(); var q = from t in System.Reflection.Assembly.GetExecutingAssembly().GetTypes() where t.IsClass && t.Namespace == @namespace && t.Name == serviceName select t; q.ToList().ForEach(t => Console.WriteLine(t.Name)); #endregion GB.Authorization gba = new WAExample.GB.Authorization(); string jsonText = gba.GetJsonTextWithSignName(methodName: interfaceName, jsonText: String.Empty, methodParamObjectArray: new object[] { passengers, specifiedFields, keyIDPair }); var gim = GBW.GetInterfaceMethod <SRExample.ServiceSoapClient, SRExample.ResultMsg, Func <SRExample.ServiceSoapClient, String, SRExample.ResultMsg> >(interfaceName: ((DropDownList)form1.FindControl("InterfaceName")).Text); SRExample.ResultMsg resultMsg = gim(new SRExample.ServiceSoapClient(), jsonText); resultMsg = GBW.GetResultMsg <SRExample.ServiceSoapClient , Func <SRExample.ServiceSoapClient, String, SRExample.ResultMsg> , SRExample.ResultMsg > (serviceSoapClient: new SRExample.ServiceSoapClient(), interfaceName: ((DropDownList)form1.FindControl("InterfaceName")).Text, jsonText: "", obj: passengers, specifiedFields: specifiedFields, keyIDpair: keyIDPair) as SRExample.ResultMsg; resultMsg = GBW.GetResultMsg <SRExample.ServiceSoapClient , Func <SRExample.ServiceSoapClient, String, SRExample.ResultMsg> , SRExample.ResultMsg > (serviceSoapClient: new SRExample.ServiceSoapClient() , interfaceName: ((DropDownList)form1.FindControl("InterfaceName")).Text , jsonText: "", obj: passengers , specifiedFields: specifiedFields , keyIDpair: keyIDPair) as SRExample.ResultMsg; if (null != resultMsg) { ((TextBox)form1.FindControl("ResultMsgRetCode")).Text = resultMsg.RetCode; ((TextBox)form1.FindControl("ResultMsgRetMsg")).Text = resultMsg.RetMsg; ((TextBox)form1.FindControl("ResultMsgObj")).Text = RF.GlobalClass.Utils.Convert.ObjectToJSON(RequestBus.ConvertResultMsgObj(resultMsg.Obj)); ((TextBox)form1.FindControl("ResultMsgObjj")).Text = RF.GlobalClass.Utils.Convert.ObjectToJSON(RequestBus.ConvertResultMsgObjj(resultMsg.Obj)); } else { ((TextBox)form1.FindControl("ResultMsgRetCode")).Text = String.Empty; ((TextBox)form1.FindControl("ResultMsgRetMsg")).Text = String.Empty; ((TextBox)form1.FindControl("ResultMsgObj")).Text = String.Empty; } }
protected void Page_Load(object sender, EventArgs e) { GBA = RequestBus.getGBA(Response: Response, moduleID: ModuleID.Value, openName: "rfOaService", methodName: "redforce"); //getGBA(Response, ModuleID.Value); GBW = RequestBus.getGBW(Response: Response); // getGBW(Response); passengers = new RequestBus.Passengers(); Dictionary <string, string> dssPP = RequestBus.GetPostPutData(Request: Request); string tmp = String.Empty; serviceName = dssPP.TryGetValue("serviceName", out tmp) ? tmp : serviceName; interfaceName = dssPP.TryGetValue("interfaceName", out tmp) ? tmp : interfaceName; specifiedFiledSuffixName = dssPP.TryGetValue("specifiedFiledSuffixName", out tmp) ? tmp : specifiedFiledSuffixName; keyIDPairSuffixName = dssPP.TryGetValue("keyIDPairSuffixName", out tmp) ? tmp : keyIDPairSuffixName; Type requestBusType = (new RequestBus()).GetType(); dssSpecifiedFields = RF.GlobalClass.Utils.Do.MagicField <Dictionary <string, string> >((new RequestBus()), serviceName + interfaceName + specifiedFiledSuffixName) ?? RF.GlobalClass.Utils.Do.MagicField <Dictionary <string, string> >((new RequestBus()), serviceName + specifiedFiledSuffixName) ?? dssSpecifiedFields; dssKeyIDPair = RF.GlobalClass.Utils.Do.MagicField <Dictionary <string, string> >((new RequestBus()), serviceName + interfaceName + keyIDPairSuffixName) ?? RF.GlobalClass.Utils.Do.MagicField <Dictionary <string, string> >((new RequestBus()), serviceName + keyIDPairSuffixName) ?? dssKeyIDPair; #region interface name SRExample.ServiceSoapClient rsc = new SRExample.ServiceSoapClient(); DropDownList ddlInterfaceName = new DropDownList(); ddlInterfaceName.ID = "InterfaceName"; ddlInterfaceName.DataTextField = "txt"; ddlInterfaceName.DataValueField = "val"; DataTable dt = new DataTable(); dt.Columns.Add("txt"); dt.Columns.Add("val"); rsc.GetType().GetMethods().Select(x => (x.ReturnType == typeof(SRExample.ResultMsg)) ? (dt.Rows.Add(new object[] { x.Name, x.Name }) == null ? true : true) : false).ToArray(); /* might meet methods with same name and different return type * RF.GlobalClass.Utils.Do.getMethodNamesOfObject(CWRCS).Select(delegate(string name) * { * // CWRCS.GetType().GetMethods().Select(x=> dt.Rows.Add(new object[]{x,x})).ToArray(); * * if (CWRCS.GetType().GetMethod(name).ReturnType == typeof(CheckinWebReference.ResultMsg)) * { * dt.Rows.Add(new object[]{ name, name }); * } * else { } * return name; * }).ToArray(); * */ ddlInterfaceName.DataSource = dt; ddlInterfaceName.DataBind(); ddlInterfaceName.SelectedValue = interfaceName; ddlInterfaceName.TextChanged += new EventHandler(ddlInterfaceName_TextChanged); Label lbInterfaceName = new Label(); lbInterfaceName.Text = "Interface Name:"; form1.Controls.Add(lbInterfaceName); form1.Controls.Add(ddlInterfaceName); #endregion Label lb = new Label(); CheckBox cb = new CheckBox(); TextBox tx = new TextBox(); Panel pl = new Panel(); cc = new RF.GlobalClass.WebForm.ControlCollection(RF.GlobalClass.Utils.Do.getPropertyNamesOfObject(passengers).Select(delegate(string _name) { string name = _name; if (dssKeyIDPair.ContainsKey(_name)) { name = dssKeyIDPair[_name]; } else { } lb = new Label(); lb.Text = name; lb.Style.Add(HtmlTextWriterStyle.Margin, "2px 2px 2px 4px"); cb = new CheckBox(); cb.ID = "cb_" + name; cb.Checked = dssSpecifiedFields.ContainsKey(name); cb.ToolTip = "check to use it creating sign name."; tx = new TextBox(); if (cb.Checked) { tx.ToolTip = dssSpecifiedFields[name] ?? String.Empty; if (!String.IsNullOrEmpty(tx.ToolTip)) { lb.Text = tx.ToolTip; } else { } } else { } tx.ID = name; tx.Style.Add(HtmlTextWriterStyle.Margin, "2px 4px 2px 2px"); switch (_name) { case "empid": tx.Text = GBA.UserSession.empid; break; case "mdlid": tx.Text = GBA.ModuleID; break; case "pwrid": tx.Text = GBA.PowerID; break; case "dptid": tx.Text = GBA.UserSession.dptid; break; case "TimeStamp": tx.Text = RequestBus.GetDateTimeString(DateTime.Now); break; case "openName": tx.Text = GBA.OpenName; break; case "methodName": tx.Text = GBA.MethodName; break; case "Sign": tx.Width = Unit.Pixel(300); tx.ReadOnly = true; break; default: break; } System.Web.UI.HtmlControls.HtmlGenericControl span = new System.Web.UI.HtmlControls.HtmlGenericControl("span"); span.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap"); span.Style.Add(HtmlTextWriterStyle.Display, "inline-block"); span.Controls.Add(lb); span.Controls.Add(cb); span.Controls.Add(tx); form1.Controls.Add(span); return(tx); }).ToArray()); System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap"); div.Style.Add(HtmlTextWriterStyle.Margin, "4px"); Button btn = new Button(); btn.Text = "Generate Sign"; btn.Click += new EventHandler(btnGenerateSign_Click); div.Controls.Add(btn); btn = new Button(); btn.Text = "Send Request"; btn.Click += new EventHandler(btnSendRequest_Click); div.Controls.Add(btn); form1.Controls.Add(div); div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap"); div.Style.Add(HtmlTextWriterStyle.Margin, "4px"); #region result lb = new Label(); lb.Text = "ResultMsg.RetCode:"; div.Controls.Add(lb); tx = new TextBox(); tx.ID = "ResultMsgRetCode"; div.Controls.Add(tx); div.Controls.Add(new Label()); lb = new Label(); lb.Text = "ResultMsg.RetMsg:"; div.Controls.Add(lb); tx = new TextBox(); tx.ID = "ResultMsgRetMsg"; div.Controls.Add(tx); form1.Controls.Add(div); div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap"); div.Style.Add(HtmlTextWriterStyle.Margin, "4px"); lb = new Label(); lb.Text = "ResultMsg.Obj:"; div.Controls.Add(lb); tx = new TextBox(); tx.Rows = 10; tx.ID = "ResultMsgObj"; tx.Width = Unit.Percentage(80.0); tx.TextMode = TextBoxMode.MultiLine; div.Controls.Add(tx); form1.Controls.Add(div); div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap"); div.Style.Add(HtmlTextWriterStyle.Margin, "4px"); lb = new Label(); lb.Text = "ResultMsg.Objj:"; div.Controls.Add(lb); tx = new TextBox(); tx.Rows = 10; tx.ID = "ResultMsgObjj"; tx.Width = Unit.Percentage(80.0); tx.TextMode = TextBoxMode.MultiLine; div.Controls.Add(tx); form1.Controls.Add(div); div = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); div.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap"); div.Style.Add(HtmlTextWriterStyle.Margin, "4px"); div.Controls.Add(new Panel()); lb = new Label(); lb.Text = "Request JSON:"; div.Controls.Add(lb); tx = new TextBox(); tx.Rows = 10; tx.ID = "RequestJSON"; tx.Width = Unit.Percentage(80.0); tx.TextMode = TextBoxMode.MultiLine; div.Controls.Add(tx); form1.Controls.Add(div); #endregion }
/// <summary> /// Combine put data and post data together into Dictionary<string string> /// </summary> /// <param name="Request"></param> /// <returns></returns> public static Dictionary <string, string> GetPostPutData(HttpRequest Request) { Dictionary <string, string> dssPut = RequestBus.GetPutData(Request) ?? new Dictionary <string, string>(); Dictionary <String, List <Dictionary <string, string> > > dsldssPost = null; Dictionary <string, string> dssPost = new Dictionary <string, string>(); #region get post data try { try { string data = RF.GlobalClass.WebForm.getPostData(Request); dssPost = (Dictionary <string, string>)RF.GlobalClass.Utils.Convert.JSONToObject(data, type: typeof(Dictionary <string, string>)); if (null != dssPost && dssPost.ContainsKey("data")) { data = System.Web.HttpUtility.UrlDecode(dssPost["data"], System.Text.Encoding.UTF8); try { dssPost = (Dictionary <string, string>)RF.GlobalClass.Utils.Convert.JSONToObject(data, type: typeof(Dictionary <string, string>)); }catch (Exception ea) { try { dsldssPost = (Dictionary <String, List <Dictionary <string, string> > >)RF.GlobalClass.Utils.Convert.JSONToObject(data, type: typeof(Dictionary <String, List <Dictionary <string, string> > >)); } catch (Exception ex) { } } } else { dssPost = dssPost ?? new Dictionary <String, String>(); } } catch (Exception ex) { } } catch (Exception ex) { } #endregion //AjaxResponse ar = new AjaxResponse(); //ar.data = dsldssPost; string jumpdata = RequestBus.Param("jumpdata"); List <Dictionary <string, string> > ldss = new List <Dictionary <string, string> >(); //Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dssPost)); //Response.Write("##"); //Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dssPut)); //Response.Write("##"); //Response.Write("##"); //Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dsldssPost)); //Response.Write("##"); //Response.Write("##"); //Response.Write("##"); //Response.Write((RF.GlobalClass.Utils.Convert.JSONToObject<Dictionary<String, String>>(Request.Params[jumpdata]) as Dictionary<string, string>)["BusinessClass"]); //{jumpdata:new List<Dictionary<String,String>>(){(RF.GlobalClass.Utils.Convert.JSONToObject<Dictionary<string, string>>(dssPut[jumpdata]) as Dictionary<string, string> )} }) string tmpText = String.Empty; if (null == dsldssPost && dssPut.TryGetValue(jumpdata, out tmpText)) { try { dsldssPost = (new Dictionary <String, List <Dictionary <String, String> > >()); dsldssPost.Add(jumpdata, new List <Dictionary <String, String> >() { (RF.GlobalClass.Utils.Convert.JSONToObject <Dictionary <string, string> >(tmpText) as Dictionary <string, string>) }); } catch (Exception ex) { } } else { } if (null != dsldssPost && dsldssPost.TryGetValue(jumpdata, out ldss)) { try { foreach (KeyValuePair <string, string> _kvp in ldss.FirstOrDefault <Dictionary <String, String> >()) { dssPost[_kvp.Key] = dssPost.ContainsKey(_kvp.Key)? (dssPost[_kvp.Key] ?? _kvp.Value): _kvp.Value; } //tmpText = System.Text.RegularExpressions.Regex.Replace(tmpText, ",\"TableQueryItemListPerPageRowCount.*$", "}"); //dsldssPost = (new Dictionary<String, List<Dictionary<String, String>>>()); //dsldssPost.Add(jumpdata, new List<Dictionary<String, String>>() { (RF.GlobalClass.Utils.Convert.JSONToObject<Dictionary<string, string>>(tmpText) as Dictionary<string, string>) }); } catch (Exception ex) { } } else { } dssPut.ToList().ForEach(x => dssPost[x.Key] = dssPost.ContainsKey(x.Key) ? dssPost[x.Key] : x.Value); return(dssPost); }
protected void MultiViewMenu_Load(object sender, EventArgs e) { Dictionary <string, string> dss = RequestBus.GetPutData(Request: Request); string check = String.Empty; string change = string.Empty; string view = String.Empty; int viewIndex = 0; if (dss.TryGetValue("go", out check)) { switch (check) { default: break; } } else { } if (dss.TryGetValue("do", out check)) { switch (check) { //case "addJobTransfer": // addJobTransfer(); // break; //case "checkJobTransfer": // checkJobTransfer(); //break; default: break; } } //else if (dss.TryGetValue("ChangeExampleInformationQueryItemListPerPageRowCountTo", out change)) //{ // DrawItemListTable(); // // reloadMainInformationQueryItemList(change); //} else if (dss.TryGetValue("ChangeExampleInformationQueryItemListPageTo", out change)) { RFDataTable rfdteiqil = new RFDataTable("vELTableExampleInformationQueryItemList", request: Request, response: Response); rfdteiqil.BeforePageChange += new RFDataTable.BeforePageChangeHandler(rfdteiqil_BeforePageChange); rfdteiqil.WhenPageChange += new RFDataTable.WhenPageChangeHandler(rfdteiqil_WhenPageChange); rfdteiqil.AfterPageChange += new RFDataTable.AfterPageChangeHandler(delegate(object o, RFDataTable.EventArgsForAfterPageChange _e) { return(!rfdteiqil_AfterPageChange(o, _e)); }); rfdteiqil.ChangePageTo(currPage: change , perPageRowCount: "0" , dataTableName: "TableExampleInformationQueryItemList" , dataTableNamespace: "ExampleList" , columnKeyIDPair: new Dictionary <string, string> { { "RowCount", "id" } , { "Code", "code" } , { "Name", "name" } , { "Status", "status" } , { "Description", "description" } }); } else if (dss.TryGetValue("view", out view) && !int.TryParse(view, out viewIndex)) { try { MultiViewMenu.SetActiveView(MultiViewMenu.FindControl(view) as View); } catch (Exception ex) { MultiViewMenu.ActiveViewIndex = viewIndex; } } else { try { int.TryParse(view, out viewIndex); MultiViewMenu.ActiveViewIndex = viewIndex; } catch (Exception ex) { MultiViewMenu.ActiveViewIndex = MultiViewMenu.Views.Count - 1; RequestBus.jumpToAuthorization(Response: Response); } } }
public static string SRExampleGetRequest(object[] objectAry) // object obj, Dictionary<string, string> specifiedFields, Dictionary<string, string> keyIDpair = null}) { Object obj = objectAry.GetValue(0); Dictionary <String, String> specifiedFields = objectAry.GetValue(1) as Dictionary <String, String>; Dictionary <String, String> keyIDpair = objectAry.GetValue(2) as Dictionary <String, String>; Passengers p = obj as Passengers; Dictionary <string, string> openWith = new Dictionary <string, string>(); #region comment /* * 签名: * */ #endregion #region specifiedFields default value specifiedFields = specifiedFields ?? SRExampleGetRequestSpecifiedFields; #endregion keyIDpair = keyIDpair ?? SRExampleGetRequestKeyIDPair; RequestBus.PackagePassengersToDSS(p: p, specifiedFields: specifiedFields, openWith: out openWith, keyIDpair: keyIDpair); p.passenger0 = carfs.CARFSecurer.Program.GetEncrytedMessage("QADHOAEBPEUISDTAPJOPNGOERINRVF", RF.GlobalClass.Utils.Convert.ObjectToJSON(openWith)); #region modified in programming of SRExample p.GetType().GetProperties().Select(delegate(System.Reflection.PropertyInfo pi) { if (keyIDpair.ContainsKey(pi.Name)) { string kipValue = keyIDpair[pi.Name]; if (!openWith.ContainsKey(kipValue) && !String.IsNullOrEmpty(kipValue)) { openWith.Add(kipValue, pi.GetValue(p, null) as String); } else { } //if (specifiedFields.ContainsKey(keyIDpair[pi.Name])) //{ // if (!openWith.ContainsKey(specifiedFields[keyIDpair[pi.Name]])) // { // openWith.Add(specifiedFields[keyIDpair[pi.Name]], pi.GetValue(p, null) as String); // } // else { } //} //else { } } else if (keyIDpair.Count == 0 && !openWith.ContainsKey(pi.Name)) { openWith.Add(pi.Name, pi.GetValue(p, null) as String); } else { } return(pi); }).ToArray(); return(RF.GlobalClass.Utils.Convert.ObjectToJSON(openWith)); // return RF.GlobalClass.Utils.Convert.ObjectToJSON(p); #endregion }
public void _ChangePageTo(string currPage = "0", string perPageRowCount = "0", Dictionary <string, string> dssPostData = null) { try { string date = string.Empty; Dictionary <string, string> dss = RequestBus.GetPostData(Request: Request) ?? dssPostData; AjaxResponse ar = new AjaxResponse(); #region set status ar.status = "success"; // ar.location = new Location(); // ar.location.search = "?view=1&date=" + date; #endregion Dictionary <string, AjaxResponse> dsar = new Dictionary <string, AjaxResponse>(); Dictionary <string, List <Dictionary <string, string> > > resultData = new Dictionary <string, List <Dictionary <string, string> > >(); List <Dictionary <string, string> > ldss = new List <Dictionary <string, string> >(); Boolean carryOnAfterEvent = false; #region TableInfo try { currPage = RequestBus.GetPageNum(currPage, dss: dss, currPageNumKeyName: this.Name + this.CurrPageNumKey, pageTotalCountKeyName: this.Name + this.PageTotalCountKey); perPageRowCount = "0" == perPageRowCount ? (dss.TryGetValue(this.Name + this.PerPageRowCountKey, out perPageRowCount) ? perPageRowCount : "5") : perPageRowCount; this.ResultMsgFromService = RequestPageData(dss, currPageNum: currPage, perPageRowCount: perPageRowCount); #region trigger Before PageChange event EventArgsForBeforePageChange eventArgsForBeforePageChange = new EventArgsForBeforePageChange(dss, currPageNum: currPage, perPageRowCount: perPageRowCount); if (false == OnBeforePageChange(eventArgsForBeforePageChange)) { return; } else { } #endregion RFDataTable.ServiceResultMsg resultMsg = this.ResultMsgFromService; if (null == resultMsg) { } else if ("00" != resultMsg.RetCode) { } else { #region trigger WhenPageChange event EventArgsForWhenPageChange eventArgsForWhenPageChange = new EventArgsForWhenPageChange(this.ResultMsgFromService); carryOnAfterEvent = OnPageChange(eventArgsForWhenPageChange); #endregion if (false != carryOnAfterEvent) { #region fill data to result //ldss = RequestBus.ConvertResultMsgObjj(resultMsg.Obj); // [{"dptid":"合计 ","zs":"1212","ROWSTAT":null},{"dptid":"6156 ","zs":"11","ROWSTAT":null},{"dptid":"1672 ","zs":"8","ROWSTAT":null}] ldss = RequestBus.ConvertResultMsgObjj(resultMsg.Obj); resultData[Name] = ldss; ldss = RequestBus.ConvertResultMsgObj(resultMsg.Obj); // [{"recordcount":"744","pagecount":"248","currentpage":"1"}] string recordCount = "", pageCount = "", currentPage = ""; ldss.ForEach(delegate(Dictionary <string, string> _dss) { _dss.TryGetValue(ServiceResultMsg.RecordCountName, out recordCount); _dss.TryGetValue(ServiceResultMsg.PageCountName, out pageCount); _dss.TryGetValue(ServiceResultMsg.CurrentPageName, out currentPage); }); currentPage = currentPage ?? currPage; int currentPageIndex = 0; int.TryParse(currentPage.Trim(), out currentPageIndex); currentPageIndex = --currentPageIndex; int rowTotalCount = 0; int pageTotalCount = 0; int.TryParse(recordCount.Trim(), out rowTotalCount); pageCount = pageCount == "0" ? "1" : pageCount; int.TryParse(pageCount.Trim(), out pageTotalCount); resultData[InfoName] = (new List <Dictionary <string, string> > { new Dictionary <string, string> { { RowTotalCountKey, recordCount }, { PerPageRowCountKey, Math.Max(int.Parse(perPageRowCount), (0 == pageTotalCount? 0: ((rowTotalCount) / (pageTotalCount) + (0 == (rowTotalCount) % (pageTotalCount)?0:1)))).ToString() }, { PageTotalCountKey, pageCount }, { CurrPageIndexKey, currentPageIndex.ToString() }, { CurrPageNumKey, currentPage }, { RowCheckedStatusKey, "false" } } }); #endregion } else { } } } catch (Exception ex) { } #endregion ar.data = resultData; dsar["d"] = ar; ResultDataToAjaxResponse = ar; #region trigger After PageChange event EventArgsForAfterPageChange eventArgsForAfterPageChange = new EventArgsForAfterPageChange(this.ResultDataToAjaxResponse); carryOnAfterEvent = OnAfterPageChange(eventArgsForAfterPageChange); #endregion if (false != carryOnAfterEvent) { Response.ClearContent(); Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dsar)); // Response.End(); HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client. HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client. HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event. } else { } } catch (Exception ex) { Response.ClearContent(); AjaxResponse ar = new AjaxResponse(); Dictionary <string, AjaxResponse> dsar = new Dictionary <string, AjaxResponse>(); ar.status = "failure"; ar.message = "系统异常,请稍后再试。"; // ex.Message; dsar["d"] = ar; Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dsar)); Response.End(); } }
public System.Data.DataTable ChangePageTo(string currPage = "0", string perPageRowCount = "0", Dictionary <string, string> dssPostData = null, string dataTableName = "DataTableName", string dataTableNamespace = "DataTableNameSpace", Dictionary <string, string> columnKeyIDPair = null, System.Web.UI.WebControls.Table t = null) { #region when dataTable Exist columnKeyIDPair = (null == columnKeyIDPair) ? new Dictionary <string, string>() : columnKeyIDPair; this.DataTable = new System.Data.DataTable(dataTableName, dataTableNamespace); columnKeyIDPair.Select(x => this.DataTable.Columns.Add(x.Key)).ToArray(); #endregion try { string date = string.Empty; Dictionary <string, string> dss = dssPostData ?? RequestBus.GetPostData(Request: Request); AjaxResponse ar = new AjaxResponse(); #region set status ar.status = "success"; // ar.location = new Location(); // ar.location.search = "?view=1&date=" + date; #endregion Dictionary <string, AjaxResponse> dsar = new Dictionary <string, AjaxResponse>(); Dictionary <string, List <Dictionary <string, string> > > resultData = new Dictionary <string, List <Dictionary <string, string> > >(); List <Dictionary <string, string> > ldss = new List <Dictionary <string, string> >(); Boolean carryOnAfterEvent = false; #region TableInfo try { currPage = RequestBus.GetPageNum(currPage, dss: dss, currPageNumKeyName: this.Name + this.CurrPageNumKey, pageTotalCountKeyName: this.Name + this.PageTotalCountKey); perPageRowCount = "0" == perPageRowCount ? (dss.TryGetValue(this.Name + this.PerPageRowCountKey, out perPageRowCount) ? perPageRowCount : "5") : perPageRowCount; this.ResultMsgFromService = RequestPageData(dss, currPageNum: currPage, perPageRowCount: perPageRowCount); #region when dataTable Exist try { // fill table with empty data int _perPageRowCount = int.TryParse(perPageRowCount, out _perPageRowCount) ? _perPageRowCount : 5; System.Data.DataRow dr = this.DataTable.NewRow(); Object[] oAry = new Object[columnKeyIDPair.Count]; while (_perPageRowCount-- > 0) { dr = this.DataTable.NewRow(); dr.ItemArray = oAry.Clone() as Object[]; this.DataTable.Rows.InsertAt(dr, 0); } } catch (Exception exd) { } #endregion #region trigger Before PageChange event EventArgsForBeforePageChange eventArgsForBeforePageChange = new EventArgsForBeforePageChange(dss, currPageNum: currPage, perPageRowCount: perPageRowCount); if (false == OnBeforePageChange(eventArgsForBeforePageChange)) { return(this.DataTable); } else { } #endregion #region when dataTable Exist #endregion RFDataTable.ServiceResultMsg resultMsg = this.ResultMsgFromService; if (null == resultMsg) { } else if (resultMsg.DefaultSuccessRetCode != resultMsg.RetCode) { } else { #region trigger WhenPageChange event EventArgsForWhenPageChange eventArgsForWhenPageChange = new EventArgsForWhenPageChange(this.ResultMsgFromService); carryOnAfterEvent = OnPageChange(eventArgsForWhenPageChange); #endregion if (false != carryOnAfterEvent) { #region fill data to result resultData = fillResultDataToResultDict(resultMsg, currPage: currPage, perPageRowCount: perPageRowCount); /* * //ldss = RequestBus.ConvertResultMsgObjj(resultMsg.Obj); * // [{"dptid":"合计 ","zs":"1212","ROWSTAT":null},{"dptid":"6156 ","zs":"11","ROWSTAT":null},{"dptid":"1672 ","zs":"8","ROWSTAT":null}] * ldss = RequestBus.ConvertResultMsgObjj(resultMsg.Obj); * resultData[Name] = ldss; * ldss = RequestBus.ConvertResultMsgObj(resultMsg.Obj); * // [{"recordcount":"744","pagecount":"248","currentpage":"1"}] * string recordCount = "", pageCount = "", currentPage = ""; * ldss.ForEach(delegate(Dictionary<string, string> _dss) * { * _dss.TryGetValue(ServiceResultMsg.RecordCountName, out recordCount); * _dss.TryGetValue(ServiceResultMsg.PageCountName, out pageCount); * _dss.TryGetValue(ServiceResultMsg.CurrentPageName, out currentPage); * }); * currentPage = currentPage ?? currPage; * int currentPageIndex = 0; * int.TryParse(currentPage.Trim(), out currentPageIndex); * currentPageIndex = --currentPageIndex; * int rowTotalCount = 0; * int pageTotalCount = 0; * int.TryParse(recordCount.Trim(), out rowTotalCount); * pageCount = pageCount == "0" ? "1" : pageCount; * int.TryParse(pageCount.Trim(), out pageTotalCount); * resultData[InfoName] = (new List<Dictionary<string, string>> { new Dictionary<string, string> { * { RowTotalCountKey, recordCount}, * { PerPageRowCountKey, Math.Max(int.Parse(perPageRowCount),(0== pageTotalCount? 0: ((rowTotalCount)/(pageTotalCount)+(0==(rowTotalCount)%(pageTotalCount)?0:1)))).ToString() }, * { PageTotalCountKey,pageCount}, * { CurrPageIndexKey, currentPageIndex.ToString() }, * { CurrPageNumKey, currentPage}, * { RowCheckedStatusKey, "false"} * } }); * */ #endregion } else { } } } catch (Exception ex) { } #endregion ar.data = resultData; dsar["d"] = ar; ResultDataToAjaxResponse = ar; try { int _perPageRowCount = 0; List <Dictionary <string, string> > _ldss = new List <Dictionary <string, string> >(); string perPageRowCountStr = String.Empty; #region when dataTable Exist try { // get table info if (this.ResultDataToAjaxResponse.data.TryGetValue(this.InfoName, out _ldss) && null != t) { System.Web.UI.ITextControl itcCurrPageNum = null; itcCurrPageNum = (t.FindControl(t.ID + "_" + this.CurrPageNumKey) as System.Web.UI.ITextControl); string tableCurrPageNum = itcCurrPageNum.Text = (_ldss.FirstOrDefault().TryGetValue(this.CurrPageNumKey, out tableCurrPageNum) ? tableCurrPageNum : itcCurrPageNum.Text); int.TryParse((_ldss.FirstOrDefault().TryGetValue(this.PerPageRowCountKey, out perPageRowCountStr) ? perPageRowCountStr : "1"), out _perPageRowCount); string tablePageTotalCount = (t.FindControl(t.ID + "_" + this.PageTotalCountKey) as System.Web.UI.ITextControl).Text = (_ldss.FirstOrDefault().TryGetValue(this.PageTotalCountKey, out tablePageTotalCount) ? tablePageTotalCount : itcCurrPageNum.Text); string tablePerageRowCount = (t.FindControl(t.ID + "_" + this.PerPageRowCountKey) as System.Web.UI.ITextControl).Text = (_ldss.FirstOrDefault().TryGetValue(this.PerPageRowCountKey, out tablePerageRowCount) ? tablePerageRowCount : "5"); string tableRowTotalCount = (t.FindControl(t.ID + "_" + this.RowTotalCountKey) as System.Web.UI.ITextControl).Text = (_ldss.FirstOrDefault().TryGetValue(this.RowTotalCountKey, out tableRowTotalCount) ? tableRowTotalCount : "x"); #region set paging button status try { System.Web.UI.WebControls.WebControl itcPageLast = (t.FindControl(t.ID + "_" + this.PageLastKey) as System.Web.UI.WebControls.WebControl); System.Web.UI.WebControls.WebControl itcPageNext = (t.FindControl(t.ID + "_" + this.PageNextKey) as System.Web.UI.WebControls.WebControl); System.Web.UI.WebControls.WebControl itcPageFirst = (t.FindControl(t.ID + "_" + this.PageFirstKey) as System.Web.UI.WebControls.WebControl); System.Web.UI.WebControls.WebControl itcPagePrev = (t.FindControl(t.ID + "_" + this.PagePrevKey) as System.Web.UI.WebControls.WebControl); try { if (int.Parse(tablePageTotalCount) > int.Parse(itcCurrPageNum.Text ?? "0")) { itcPageLast.Enabled = true; itcPageLast.CssClass = itcPageLast.CssClass.Replace("disabled", ""); itcPageNext.Enabled = true; itcPageNext.CssClass = itcPageNext.CssClass.Replace("disabled", ""); } else { } } catch (Exception exe) { } try { if (int.Parse(itcCurrPageNum.Text ?? "0") > 1) { itcPageFirst.Enabled = true; itcPageFirst.CssClass = itcPageFirst.CssClass.Replace("disabled", ""); itcPagePrev.Enabled = true; itcPagePrev.CssClass = itcPagePrev.CssClass.Replace("disabled", ""); } else { } } catch (Exception exe) { } } catch (Exception ex) { } #endregion } else { } } catch (Exception exe) { } #endregion #region trigger After PageChange event EventArgsForAfterPageChange eventArgsForAfterPageChange = new EventArgsForAfterPageChange(this.ResultDataToAjaxResponse); carryOnAfterEvent = OnAfterPageChange(eventArgsForAfterPageChange); #endregion try { // fill the data if (this.ResultDataToAjaxResponse.data.TryGetValue(this.Name, out _ldss)) { this.DataTable.Rows.Clear(); System.Data.DataRow dr = this.DataTable.NewRow(); _ldss.ForEach(delegate(Dictionary <String, String> _dss) { dr = this.DataTable.NewRow(); dr.ItemArray = columnKeyIDPair.Select((KeyValuePair <string, string> x, int i) => { string _tmpStr = _dss.ContainsKey(x.Value) ? _dss[x.Value] : String.Empty; return(_tmpStr); }).ToArray(); this.DataTable.Rows.InsertAt(dr, 0); }); Object[] oAry = new Object[columnKeyIDPair.Count]; if (_perPageRowCount > this.DataTable.Rows.Count) { int tmpCount = _perPageRowCount - this.DataTable.Rows.Count; while (tmpCount-- > 0) { dr = this.DataTable.NewRow(); dr.ItemArray = oAry.Clone() as Object[]; this.DataTable.Rows.InsertAt(dr, 0); } } else { } } else { } } catch (Exception exf) { } } catch (Exception exd) { } if (false != carryOnAfterEvent) { Response.ClearContent(); List <Dictionary <string, string> > _ldss = new List <Dictionary <string, string> >(); if (this.ResultDataToAjaxResponse.data.TryGetValue(this.Name, out _ldss)) { columnKeyIDPair.Select((KeyValuePair <string, string> x, int i) => { RequestBus.ChangeKeyNameOfLDSS(x.Value, x.Key, _ldss); return(x.Value); }).ToArray(); } else { } Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dsar)); // Response.End(); HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client. HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client. HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event. } else { } } catch (Exception ex) { Response.ClearContent(); AjaxResponse ar = new AjaxResponse(); Dictionary <string, AjaxResponse> dsar = new Dictionary <string, AjaxResponse>(); ar.status = "failure"; ar.message = "系统异常,请稍后再试。"; // ex.Message; dsar["d"] = ar; Response.Write(RF.GlobalClass.Utils.Convert.ObjectToJSON(dsar)); Response.End(); } return(this.DataTable); }