Ejemplo n.º 1
0
        protected string HandlerTotalCountRequest()
        {
            StringBuilder sbResult = new StringBuilder();
            try
            {
                string strjson = string.Empty;

                CY.CSTS.Core.Business.UnitSearchJson json = null;

                if (CY.Utility.Common.RequestUtility.IsGet)
                {
                    strjson = CY.Utility.Common.RequestUtility.GetQueryString("json");
                }
                else if (CY.Utility.Common.RequestUtility.IsPost)
                {
                    strjson = CY.Utility.Common.RequestUtility.GetFormString("json");
                }

                if (!string.IsNullOrEmpty(strjson))
                {
                    json = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strjson) as CY.CSTS.Core.Business.UnitSearchJson;
                }
                else
                {
                    json = new CY.CSTS.Core.Business.UnitSearchJson();
                }

                long Count = CY.CSTS.Core.Business.UnitInfo.GetUnitCount(json);

                sbResult.Append("{");
                sbResult.Append(string.Format("success:true,num:{0}", Count));
                sbResult.Append("}");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return sbResult.ToString();
        }
Ejemplo n.º 2
0
        protected string HandlerSearchPettion()
        {
            System.Text.StringBuilder sbResult = new System.Text.StringBuilder();
            System.Text.StringBuilder sbContent = new System.Text.StringBuilder();
            try
            {
                // declare

                string strpagesize = string.Empty;
                string strpagenum = string.Empty;
                string strJson = string.Empty;

                int pagesize = default(int);
                int pagenum = default(int);
                long totalcount = default(long);

                if (CY.Utility.Common.RequestUtility.IsGet)
                {
                    strpagesize = CY.Utility.Common.RequestUtility.GetQueryString("pagesize");
                    strpagenum = CY.Utility.Common.RequestUtility.GetQueryString("pagenum");
                    strJson = CY.Utility.Common.RequestUtility.GetQueryString("condition");
                }
                else if (CY.Utility.Common.RequestUtility.IsPost)
                {
                    strpagesize = CY.Utility.Common.RequestUtility.GetFormString("pagesize");
                    strpagenum = CY.Utility.Common.RequestUtility.GetFormString("pagenum");
                    strJson = CY.Utility.Common.RequestUtility.GetFormString("condition");
                }

                if (string.IsNullOrEmpty(strpagesize) || string.IsNullOrEmpty(strpagenum) || string.IsNullOrEmpty(strJson))
                {
                    return sbResult.Append("{success:fasle,action:'none',status:'none',msg:'输入参数错误请检查!'}").ToString();
                }

                if (!CY.Utility.Common.ParseUtility.TryParseInt32(strpagesize, out pagesize) || pagesize <= 0 || !CY.Utility.Common.ParseUtility.TryParseInt32(strpagenum, out pagenum) || pagenum <= 0)
                {
                    return sbResult.Append("{success:fasle,action:'none',status:'none',msg:'输入参数错误请检查!'}").ToString();
                }

                if (string.IsNullOrEmpty(strJson))
                {
                    return sbResult.Append("{success:fasle,action:'none',status:'none',msg:'输入参数错误请检查!'}").ToString();
                }

                json = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strJson, typeof(CY.CSTS.Core.Business.UnitSearchJson)) as CY.CSTS.Core.Business.UnitSearchJson;

                if (json == null)
                {
                    return sbResult.Append("{success:fasle,action:'none',status:'none',msg:'搜索参数错误请检查输入是否有误!'}").ToString();
                }

                paginginfo.CurrentPage = pagenum;
                paginginfo.PageSize = pagesize;

                totalcount = CY.CSTS.Core.Business.UnitInfo.GetUnitCount(json);

                List<CY.CSTS.Core.Business.UnitInfo> units = CY.CSTS.Core.Business.UnitInfo.SelectUnitinfoBySearchConditionPageInfo(json, paginginfo);
                if (units != null)
                {

                    sbContent.Append("results:[");
                    foreach (CY.CSTS.Core.Business.UnitInfo unit in units)
                    {
                        List<CY.CSTS.Core.Business.Annex> annexex = CY.CSTS.Core.Business.Annex.SelectAnnexByContentID(unit.Id);
                        string imgUrl = null;
                        if (annexex != null)
                        {
                           // imgUrl = (annexex.Where(item => item. == CY.Utility.Common.AnnexUtility.ImgAnnexType) != null) ? annexex.Where(item => item.ContentType == CY.Utility.Common.AnnexUtility.ImgAnnexType).First().AnnexURI : string.Empty;
                        }
                        sbContent.Append("{");
                        sbContent.Append(string.Format("id:'{0}'", unit.Id));
                        sbContent.Append(string.Format(",name:'{0}'", unit.UnitName));
                        sbContent.Append(string.Format(",alias:'{0}'", unit.Alias));
                        sbContent.Append(string.Format(",code:'{0}'", unit.WorkCode));
                        sbContent.Append(string.Format(",address:'{0}'", unit.Address));
                        sbContent.Append(string.Format(",tel:'{0}'", unit.Tel));
                        sbContent.Append(string.Format(",fax:'{0}'", unit.Fax));
                        sbContent.Append(string.Format(",email:'{0}'", unit.Email));
                        sbContent.Append(string.Format(",submitdate:'{0}'", unit.CreatDate.ToString("yyyy年MM月dd")));
                        sbContent.Append(string.Format(",updatedate:'{0}'", unit.UpdateDate.ToString("yyyy年MM月dd")));
                        sbContent.Append(string.Format(",img:'{0}'", imgUrl));
                        sbContent.Append("},");
                    }
                    if (units.Count > 0)
                    {
                        sbContent.Remove(sbContent.Length - 1, 1);
                    }
                    sbContent.Append("]");
                }
                sbResult.Append("{");
                sbResult.Append("success:true,");
                sbResult.Append("action:'update',");
                sbResult.Append("status:'update',");
                sbResult.Append("msg:'success',");
                sbResult.Append(sbContent.ToString());
                sbResult.Append("}");

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
            return sbResult.ToString();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  Unit Info List N Type list
        /// </summary>
        /// <returns></returns>
        protected string HandlerRequest()
        {
            StringBuilder sbResult = new StringBuilder();
            try
            {
                string strjson = string.Empty;

                string strpageinfo = string.Empty;

                CY.CSTS.Core.Business.UnitSearchJson json = null;

                CY.CSTS.Core.Business.PagingInfo pageinfo = null;

                if (CY.Utility.Common.RequestUtility.IsGet)
                {
                    strjson = CY.Utility.Common.RequestUtility.GetQueryString("json");
                    strpageinfo = CY.Utility.Common.RequestUtility.GetQueryString("pageinfo");
                }
                else if (CY.Utility.Common.RequestUtility.IsPost)
                {
                    strjson = CY.Utility.Common.RequestUtility.GetFormString("json");
                    strpageinfo = CY.Utility.Common.RequestUtility.GetFormString("pageinfo");
                }

                if (!string.IsNullOrEmpty(strjson))
                {
                    json = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strjson, typeof(CY.CSTS.Core.Business.UnitSearchJson)) as CY.CSTS.Core.Business.UnitSearchJson;

                }
                else
                {
                    json = new CY.CSTS.Core.Business.UnitSearchJson();
                }

                if (!string.IsNullOrEmpty(strpageinfo))
                {
                    pageinfo = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strpageinfo, typeof(CY.CSTS.Core.Business.PagingInfo)) as CY.CSTS.Core.Business.PagingInfo;
                }
                else
                {
                    pageinfo = new CY.CSTS.Core.Business.PagingInfo();
                }

                sbResult.Append("{");
                sbResult.Append("success:true");
                sbResult.Append(string.Format(",list:{0}", ConstructorUnit(json, pageinfo)));
                sbResult.Append("}");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return sbResult.ToString();
        }