public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath == Url)
            {
                ThreadStore.UpdateThreadStoreStats();
                ThreadStoreStats stats = ThreadStore.StoreStats;

                JsonArray ja = new JsonArray();

                IEnumerable<string> boards = Program.ValidBoards.Keys;

                for (int i = 0, j = boards.Count(); i < j; i++)
                {
                    string boardName = boards.ElementAt(i);
                    int threadCount = stats[boardName];

                    if (threadCount > 0)
                    {
                        JsonArray inner = new JsonArray();

                        inner.Add(boardName);
                        inner.Add(threadCount);

                        ja.Add(inner);
                    }
                }

                WriteJsonResponse(response, ja.ToString());
                return true;
            }

            return false;
        }
Beispiel #2
0
 public void AddNullValueViaIList()
 {
     IList list = new JsonArray();
     list.Add(null);
     Assert.AreEqual(1, list.Count);
     Assert.IsNull(list[0]);
 }
Beispiel #3
0
 public void AddNullValue()
 {
     JsonArray a = new JsonArray();
     a.Add(null);
     Assert.AreEqual(1, a.Count);
     Assert.IsNull(a[0]);
 }
Beispiel #4
0
    public Jayrock.Json.JsonArray getFileJsonArray()
    {
        DatabaseAccess dbAccess = new DatabaseAccess();

        Jayrock.Json.JsonArray  images = new Jayrock.Json.JsonArray();
        Jayrock.Json.JsonObject image;
        System.Data.DataTable   dt;
        string sql = string.Format(" select ID, Name FileName, Description from [File] where parentid = {0}  order by ID ", ID.ToString());

        dbAccess.open();
        try
        {
            dt = dbAccess.select(sql);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            dbAccess.close();
        }

        foreach (System.Data.DataRow row in dt.Rows)
        {
            image = new Jayrock.Json.JsonObject();
            foreach (System.Data.DataColumn col in dt.Columns)
            {
                image.Accumulate(col.ColumnName.ToLower(), row[col.ColumnName]);
            }
            images.Add(image);
        }

        return(images);
    }
Beispiel #5
0
    public Jayrock.Json.JsonArray getSystemLinkList()
    {
        Jayrock.Json.JsonArray  ja = new Jayrock.Json.JsonArray();
        Jayrock.Json.JsonObject jo;
        string sql = "select ID, name, link from OtherSystemLink";

        dbAccess.open();

        try
        {
            System.Data.DataTable dt = dbAccess.select(sql);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                jo = new JsonObject();
                foreach (System.Data.DataColumn col in dt.Columns)
                {
                    jo.Accumulate(col.ColumnName.ToLower(), dr[col.ColumnName].ToString());
                }
                ja.Add(jo);
            }
        }
        catch
        {
            throw;
        }
        finally
        {
            dbAccess.close();
        }

        return(ja);
    }
        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath.StartsWith(Url))
            {
                string day_number = request.QueryString[UrlParameters.DayNumber].Value;

                int dayNumber = 0;

                DateTime day = DateTime.Now;

                if (Int32.TryParse(day_number, out dayNumber))
                {
                    day = new DateTime(day.Year, 1, 1);

                    dayNumber--;

                    if (!DateTime.IsLeapYear(day.Year) && dayNumber == 365)
                    {
                        dayNumber--;
                    }

                    day = day.AddDays(dayNumber);
                }

                var sdata = NetworkUsageCounter.GetDayStats(day);

                JsonArray ja = new JsonArray();

                for (int i = 0; i < sdata.Length; i++)
                {
                    double t = sdata[i].Value / 1024 / 1024;

                    JsonArray inner = new JsonArray();

                    inner.Add(sdata[i].Key);
                    inner.Add(Math.Round(t, 2, MidpointRounding.AwayFromZero));

                    ja.Add(inner);
                }

                WriteJsonResponse(response, ja.ToString());
                return true;
            }

            return false;
        }
Beispiel #7
0
 public void ContentsClearedBeforeImporting()
 {
     JsonArray a = new JsonArray();
     a.Add(new object());
     Assert.AreEqual(1, a.Length);
     a.Import(new JsonTextReader(new StringReader("[123]")));
     Assert.AreEqual(1, a.Length);
 }
Beispiel #8
0
        public override string GetString(IEnumerable<IFreeDocument> datas)
        {
            var nodeGroup = new JsonArray();

            foreach (IFreeDocument data in datas)
            {

                nodeGroup.Add(GetJsonObject(data));
            }
            return nodeGroup.ToString();
        }
 public void ImportIsExceptionSafe()
 {
     JsonArray a = new JsonArray();
     object o = new object();
     a.Add(o);
     
     try
     {
         a.Import(new JsonTextReader(new StringReader("[123,456,")));
     }
     catch (JsonException)
     {
     }
     
     Assert.AreEqual(1, a.Count);
     Assert.AreSame(o, a[0]);
 }
Beispiel #10
0
    public Jayrock.Json.JsonArray getImageJsonArray()
    {
        DatabaseAccess dbAccess = new DatabaseAccess();

        Jayrock.Json.JsonArray  images = new Jayrock.Json.JsonArray();
        Jayrock.Json.JsonObject image;

        System.Data.DataTable dt;
        string sql = "select ID, FileName, MIME from [Image] where Category = '"
                     + GlobalSetting.ArticleCategory.Event
                     + "' and ParentID = " + ID.ToString();

        dbAccess.open();
        try
        {
            dt = dbAccess.select(sql);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            dbAccess.close();
        }

        foreach (System.Data.DataRow row in dt.Rows)
        {
            image = new Jayrock.Json.JsonObject();
            foreach (System.Data.DataColumn col in dt.Columns)
            {
                image.Accumulate(col.ColumnName.ToLower(), row[col.ColumnName]);
            }
            images.Add(image);
        }

        return(images);
    }
Beispiel #11
0
		private JsonArray GetPanelsArray()
		{
			object propertyValue = ControlInfo.Properties.GetPropertyValue("DesignTimeTabs");
			if (propertyValue == null || propertyValue.Equals(""))
			{
				JsonArray panels = new JsonArray();
				panels.Add(new JsonObject(new string[] { "id", "selected" }, new string[] { "tabPanel1", "false" }));
				return panels;
			}
			else
			{
				return JsonConvert.Import(propertyValue as string) as JsonArray;
			}
		}
Beispiel #12
0
 private void ShowCourseModule(HttpContext context)
 {
     int RowCount = 0;
     int PageCount = 0;
     BLL.Tao.Modules mbll = new BLL.Tao.Modules();
     string strCid = context.Request.Params["cid"];
     string strIndex = context.Request.Params["PageIndex"];
     int PageIndex = Common.Globals.SafeInt(strIndex, 1);
     int PageSize = 10;
     JsonObject json = new JsonObject();
     List<Maticsoft.Model.Tao.Modules> list = mbll.GetCourseList(int.Parse(strCid), out RowCount, out PageCount, PageIndex, PageSize);
     if (list.Count > 0)
     {
         JsonArray data = new JsonArray();
         list.ForEach(info => data.Add(new JsonObject(
             new string[] { "Sequence", "ModuleName", "TrueName", "TimeDuration", "Price", "ModuleID" },
             new object[] { info.Sequence, info.ModuleName, info.TrueName, info.TimeDuration, info.Price, info.ModuleID }
             )));
         json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
         json.Put("ROWCOUNT", RowCount);
         json.Put("PAGECOUNT", PageCount);
         json.Put(TAO_KEY_DATA, data);
     }
     else
     {
         json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
     }
     context.Response.Write(json.ToString());
 }
 public void SaveListViewProperties(ListView listView)
 {
     JsonArray widths = new JsonArray();
     JsonArray indexes = new JsonArray();
     foreach (ColumnHeader column in listView.Columns)
     {
         widths.Add(column.Width);
         indexes.Add(column.DisplayIndex);
     }
     LocalSettings settings = Program.Settings;
     settings.SetObject(CONFKEYPREFIX_LISTVIEW_WIDTHS + listView.Name, widths.ToString());
     settings.SetObject(CONFKEYPREFIX_LISTVIEW_INDEXES + listView.Name, indexes.ToString());
     lock (listView)
     {
         IListViewItemSorter listViewItemSorter = (IListViewItemSorter)listView.ListViewItemSorter;
         settings.SetObject(CONFKEYPREFIX_LISTVIEW_SORTINDEX + listView.Name, listViewItemSorter.Order == SortOrder.Descending ? -listViewItemSorter.SortColumn : listViewItemSorter.SortColumn);
     }
 }
 private void SetFilesItemState(string datatype)
 {
     JsonArray array = new JsonArray();
     lock (filesListView)
     {
         lock (filesListView.Items)
         {
             foreach (FileListViewItem item in filesListView.SelectedItems)
             {
                 array.Add(item.FileIndex);
             }
         }
     }
     DispatchFilesUpdate(datatype, array);
 }
Beispiel #15
0
 public virtual object InvokeArray(Type returnType, string[] method, object[] args)
 {
     if (method == null)
         throw new ArgumentNullException("method");
     if (method.Length == 0)
         throw new ArgumentException(null, "method");
     if (returnType == null)
         throw new ArgumentNullException("returnType");
     try
     {
         var request = GetWebRequest(new Uri(Url));
         request.Method = "POST";
         var utf8EmitBom = new UTF8Encoding(false);
         using (var stream = request.GetRequestStream())
         using (var writer = new StreamWriter(stream, utf8EmitBom))
         {
             var calls = new JsonArray();
             var i = 0;
             foreach (var meth in method)
             {
                 var call = new JsonObject();
                 call["id"] = ++_id;
                 call["jsonrpc"] = "2.0";
                 call["method"] = method[i];
                 if (args[i] != null)
                     call["params"] = args[i];
                 calls.Add(call);
                 i++;
             }
             Logger.Instance().Log("RPC",calls.ToString());
             JsonConvert.Export(calls, writer);
         }
         object ret;
         using (var response = GetWebResponse(request))
         using (var stream = response.GetResponseStream())
         using (var reader = new StreamReader(stream, Encoding.UTF8))
             ret = OnResponseArray(JsonText.CreateReader(reader), returnType);
         return ret;
     }
     catch (WebException ex)
     {
         throw new JsonException("Invalid JSON-RPC response. It contains neither a result nor error : " + ex.Message);
     }
 }
Beispiel #16
0
        /// <summary>
        /// 根据分类ID查询课程信息
        /// </summary>
        /// <param name="context"></param>
        private void GetCourseByCateID(HttpContext context)
        {
            int RowCount = 0;
            int PageCount = 0;

            string strId = context.Request.Params["cateID"];
            string strPi = context.Request.Params["pageIndex"];
            int intPi = 0;
            if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
            {
                intPi = 1;
            }
            int intPz = 7;
            int OrderType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["SortT"], 0);
            int courseType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["CourseType"], 0);
            string strTime = context.Request.Params["TimeStr"];

            JsonObject json = new JsonObject();
            if (!string.IsNullOrEmpty(strId))
            {
                int CID = Common.Globals.SafeInt(strId, -1);
                if (courseType == 1)
                {
                    List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByCateId(out RowCount, out PageCount, CID, intPi, intPz, OrderType, strTime, courseType);
                    if (list.Count > 0)
                    {
                        JsonArray data = new JsonArray();
                        list.ForEach(info => data.Add(
                            new JsonObject(
                                new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
                                new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
                                )));
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                        json.Put(TAO_KEY_DATA, data);
                    }
                }
                else if (courseType == 2)
                {
                    BLL.Tao.OffLineCourse bll = new BLL.Tao.OffLineCourse();
                    List<Maticsoft.Model.Tao.SearchCourse> Offlist = bll.GetListByCateId(out RowCount, out PageCount, CID, intPi, intPz, OrderType, strTime);
                    if (Offlist.Count > 0)
                    {
                        JsonArray data = new JsonArray();
                        Offlist.ForEach(info => data.Add(
                            new JsonObject(
                                new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId", "BookCount" },
                                new object[] { info.Courseid, info.Coursename, info.StartTime.ToString("yyyy-MM-dd"), info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId,info.BookCount }
                                )));
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                        json.Put(TAO_KEY_DATA, data);
                    }
                }
                else
                {
                    List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByCateId(out RowCount, out PageCount, CID, intPi, intPz, OrderType, strTime, courseType);
                    if (list.Count > 0)
                    {
                        JsonArray data = new JsonArray();
                        list.ForEach(info => data.Add(
                            new JsonObject(
                                new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
                                new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
                                )));
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                        json.Put(TAO_KEY_DATA, data);
                    }
                }
                json.Put("ROWCOUNT", RowCount);
                json.Put("PAGECOUNT", PageCount);
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }
Beispiel #17
0
        /// <summary>
        /// 根据关键字查询课程信息
        /// </summary>
        /// <param name="context"></param>
        private void GetTeachInfo(HttpContext context)
        {
            BLL.SysManage.UsersExp ubll = new BLL.SysManage.UsersExp();

            string uid = context.Request.Params["uid"];
            JsonObject json = new JsonObject();
            if (!string.IsNullOrEmpty(uid))
            {
                List<Maticsoft.Model.UserExp.UsersExp> list = ubll.GetModelList(int.Parse(uid));
                if (list.Count > 0)
                {
                    JsonArray data = new JsonArray();
                    list.ForEach(info => data.Add(
                        new JsonObject(
                            new string[] { "UserAvatar", "Tags" },
                            new object[] { info.UserAvatar, info.Tags }
                            )));
                    json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                    json.Put(TAO_KEY_DATA, data);
                }
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }
Beispiel #18
0
        /// <summary>
        /// 根据关键字查询课程信息
        /// </summary>
        /// <param name="context"></param>
        private void GetCourseByKEY(HttpContext context)
        {
            int RowCount = 0;
            int PageCount = 0;

            string strIKey = context.Request.Params["StrKey"];
            string strPi = context.Request.Params["pageIndex"];
            int intPi = 0;
            if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
            {
                intPi = 1;
            }
            int intPz = 7;
            int OrderType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["SortT"], 0);
            int courseType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["CourseType"], 0);
            string strTime = context.Request.Params["TimeStr"];

            int? deptid = null;
            if (context.Request.Params["DPT"] != "null")
            {
                deptid = Maticsoft.Common.Globals.SafeInt(context.Request.Params["DPT"], -1);
            }

            JsonObject json = new JsonObject();
            if (!string.IsNullOrEmpty(strIKey))
            {
                List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByKEY(out RowCount, out PageCount, strIKey, intPi, intPz, OrderType, strTime, courseType, deptid);
                if (list.Count > 0)
                {
                    JsonArray data = new JsonArray();
                    list.ForEach(info => data.Add(
                        new JsonObject(
                            new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
                            new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
                            )));
                    json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                    json.Put(TAO_KEY_DATA, data);
                }
                json.Put("ROWCOUNT", RowCount);
                json.Put("PAGECOUNT", PageCount);
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }
Beispiel #19
0
 private void OffLineCourse(HttpContext context)
 {
     List<Maticsoft.Model.Tao.OffLineCourse> list = OffLinebll.GetModelList();
     JsonObject json = new JsonObject();
     if (list.Count > 0)
     {
         JsonArray data = new JsonArray();
         list.ForEach(info => data.Add(
             new JsonObject(
                 new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "CategoryId", "RegionID" },
                 new object[] { info.CourseID, info.CourseName, info.StartTime.ToString("yyyy-MM-dd"), info.CoursePrice, info.PV, info.CreatedUserID, info.ImageURL, info.CategoryId, info.RegionID }
                 )));
         json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
         json.Put(TAO_KEY_DATA, data);
     }
     else
     {
         json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
     }
     context.Response.Write(json.ToString());
 }
Beispiel #20
0
 private void RecommendedCourse(HttpContext context)
 {
     List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetRecommendedCourseList(4);
     JsonObject json = new JsonObject();
     if (list.Count > 0)
     {
         JsonArray data = new JsonArray();
         list.ForEach(info => data.Add(
             new JsonObject(
                 new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
                 new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
                 )));
         json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
         json.Put(TAO_KEY_DATA, data);
     }
     else
     {
         json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
     }
     context.Response.Write(json.ToString());
 }
Beispiel #21
0
 private void JoinComment(HttpContext context)
 {
     string strPid = context.Request.Params["ParentID"];
     JsonObject json = new JsonObject();
     List<Maticsoft.Model.Tao.Comment> list = bll.GetChildComment(int.Parse(strPid));
     if (list != null)
     {
         JsonArray data = new JsonArray();
         list.ForEach(info => data.Add(new JsonObject(
             new string[] { "CommentID", "OrderID", "CourseID", "ModuleID", "UserID", "CommentInfo", "CommentDate", "ParentID", "Score", "Status" },
             new object[] { info.CommentID, info.OrderID, info.CourseID, info.ModuleID, info.UserID, info.Comments, info.CommentDate.ToString("yyyy-MM-dd HH:mm:ss"), info.ParentID, info.Score, info.Status }
             )));
         json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
         json.Put(TAO_KEY_DATA, data);
     }
     else
     {
         json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
     }
     context.Response.Write(json.ToString());
 }
Beispiel #22
0
        private void InsertComment(HttpContext context)
        {
            JsonObject json = new JsonObject();
            string strMid = context.Request.Params["Mid"];
            string strCid = context.Request.Params["Cid"];
            string strUid = context.Request.Params["Uid"];
            string strPid = context.Request.Params["Pid"];//
            string strCtype = context.Request.Params["Ctype"];

            string strContent = context.Request.Params["Con"];
            if (!string.IsNullOrEmpty(strMid) && !string.IsNullOrEmpty(strCid) && !string.IsNullOrEmpty(strUid) && !string.IsNullOrEmpty(strPid))
            {
                Model.Tao.Comment model = new Model.Tao.Comment();
                model.CourseID = int.Parse(strCid);
                if (strMid != "null")
                {
                    model.ModuleID = int.Parse(strMid);
                }
                model.UserID = int.Parse(strUid);
                model.ParentID = int.Parse(strPid);
                model.Comments = strContent;
                model.Status = 1;
                model.CommentDate = DateTime.Now;
                model.Type = Common.Globals.SafeInt(strCtype, 0);
                int comId = bll.Add(model);
                if (comId > 0)
                {
                    List<Maticsoft.Model.Tao.Comment> list = bll.GetModelList(comId);
                    if (list.Count > 0)
                    {
                        JsonArray data = new JsonArray();
                        list.ForEach(info => data.Add(new JsonObject(
                            new string[] { "CommentID", "OrderID", "CourseID", "ModuleID", "UserID", "CommentInfo", "CommentDate", "ParentID", "Score", "Status" },
                            new object[] { info.CommentID, info.OrderID, info.CourseID, info.ModuleID, info.UserID, info.Comments, info.CommentDate.ToString("yyyy-MM-dd HH:mm:ss"), info.ParentID, info.Score, info.Status }
                            )));
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                        json.Put(TAO_KEY_DATA, data);
                    }
                    else
                    {
                        json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
                    }
                }
                else
                {
                    json.Put(TAO_KEY_STATUS, TAO_STATUS_ERROR);
                }
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_ERROR);
            }
            context.Response.Write(json.ToString());
        }
Beispiel #23
0
 private void HotKey(HttpContext context)
 {
     JsonObject json = new JsonObject();
     List<Maticsoft.Model.Tao.Courses> list = coursesBLL.GetHotKey();
     if (list != null)
     {
         JsonArray data = new JsonArray();
         list.ForEach(info => data.Add(new JsonObject(
             new string[] { "Tags" },
             new object[] { info.Tags }
             )));
         json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
         json.Put(TAO_KEY_DATA, data);
     }
     else
     {
         json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
     }
     context.Response.Write(json.ToString());
 }
Beispiel #24
0
        /// <summary>
        /// Accumulate values under a key. It is similar to the Put method except
        /// that if there is already an object stored under the key then a
        /// JsonArray is stored under the key to hold all of the accumulated values.
        /// If there is already a JsonArray, then the new value is appended to it.
        /// In contrast, the Put method replaces the previous value.
        /// </summary>

        public virtual JsonObject Accumulate(string name, object value)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            object current = InnerHashtable[name];

            if (current == null)
            {
                JsonArray array = new JsonArray();
                Put(name, array.Add(value));
            }
            else if(current is JsonArray)
            {
                Put(name, ((JsonArray)current).Add(value));
            }
            else
            {
                throw new JsonException("JSONObject[" + name +
                    "] is not a JSONArray.");
            }
            return this;
        }
Beispiel #25
0
        private void TradeLsit(HttpContext context,string action)
        {
            int RowCount = 0;
            int PageCount = 0;
            decimal Balance = 0.0M;
            JsonObject json = new JsonObject();
            string strID = context.Request.Params["UserId"];
            int uid = Common.Globals.SafeInt(strID, 0);

            string strIndex = context.Request.Params["PageIndex"];
            int PageIndex = Common.Globals.SafeInt(strIndex, 1);
            int PageSize = 10;
            List<Model.Tao.TradeDetails> list = null;
            if (action == "currentMon")
            {
                 list = bll.GetListByUId(out RowCount, out PageCount, out Balance, uid, PageIndex, PageSize, true);
            }
            else
            {
                list = bll.GetListByUId(out RowCount, out PageCount, out Balance, uid, PageIndex, PageSize, false);
            }
            if (list.Count > 0)
            {
                JsonArray data = new JsonArray();
                list.ForEach(info => data.Add(new JsonObject(
                   new string[] { "ID", "DataTime", "InCome", "Pay", "Balance", "Remark" },
                   new object[] { info.ID, info.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), info.TradeAmount, info.Pay, info.Balance, info.Remark }
                   )));
                json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                json.Put(TAO_KEY_DATA, data);
                json.Put("ROWCOUNT", RowCount);
                json.Put("PAGECOUNT", PageCount);
                json.Put("BALANCE", Balance);
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }
Beispiel #26
0
        private object Node2Item(object dic)
        {
            JsonObject js = new JsonObject();
            if (dic is IFreeDocument)
            {
                var res = (dic as IFreeDocument).DictSerialize();
                js.AddRange(res);
                var fre = dic as FreeDocument;
                if (fre != null)
                {
                    if (fre.Children != null)
                    {
                        JsonArray array = new JsonArray();
                        foreach (var child in fre.Children)
                        {
                            array.Add(Node2Item(child));
                        }
                        if (!js.HasMembers)
                            return array;
                        js.Add("Children", array);
                    }
                }
            }
            else
            {
                return dic;
            }

            return js;
        }
Beispiel #27
0
        /// <summary>
        /// 根据关键字查询课程信息
        /// </summary>
        /// <param name="context"></param>
        private void GetTeacherByKEY(HttpContext context)
        {
            BLL.SysManage.UsersExp ubll = new BLL.SysManage.UsersExp();
            int RowCount = 0;
            int PageCount = 0;

            string strIKey = context.Request.Params["StrKey"];
            string strPi = context.Request.Params["pageIndex"];
            int intPi = 0;
            if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
            {
                intPi = 1;
            }
            int intPz = 7;

            JsonObject json = new JsonObject();
            if (!string.IsNullOrEmpty(strIKey))
            {
                List<Maticsoft.Model.SysManage.Users> list = ubll.GetListByTeacherkey(out RowCount, out PageCount, strIKey, intPi, intPz);
                if (list.Count > 0)
                {
                    JsonArray data = new JsonArray();
                    list.ForEach(info => data.Add(
                        new JsonObject(
                            new string[] { "UserID", "UesrName", "TrueName" },
                            new object[] { info.UserID, info.UserName, info.TrueName }
                            )));
                    json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                    json.Put(TAO_KEY_DATA, data);
                }
                json.Put("ROWCOUNT", RowCount);
                json.Put("PAGECOUNT", PageCount);
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }
        /// <summary>
        /// Accumulate values under a key. It is similar to the Put method except
        /// that if there is already an object stored under the key then a
        /// JArray is stored under the key to hold all of the accumulated values.
        /// If there is already a JArray, then the new value is appended to it.
        /// In contrast, the Put method replaces the previous value.
        /// </summary>

        public virtual JsonObject Accumulate(string name, object value)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            object current = InnerHashtable[name];

            if (current == null)
            {
                Put(name, value);
            }
            else 
            {
                IList values = current as IList;
                
                if (values != null)
                {
                    values.Add(value);
                }
                else
                {
                    values = new JsonArray();
                    values.Add(current);
                    values.Add(value);
                    Put(name, values);
                }
            }

            return this;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            JsonArray wanted = new JsonArray();
            JsonArray unwanted = new JsonArray();
            JsonArray high = new JsonArray();
            JsonArray normal = new JsonArray();
            JsonArray low = new JsonArray();
            foreach (ListViewItem item in listView1.Items)
            {
                if (!item.Checked)
                    unwanted.Add(item.Index);
                else
                    wanted.Add(item.Index);

                if (item.SubItems[3].Text.Equals(OtherStrings.High))
                    high.Add(item.Index);
                else if (item.SubItems[3].Text.Equals(OtherStrings.Low))
                    low.Add(item.Index);
                else
                    normal.Add(item.Index);
            }
            JsonObject request = Requests.TorrentAddByFile(
                path,
                Program.Settings.DeleteTorrentWhenAdding,
                high.Count > 0 ? high : null,
                normal.Count > 0 ? normal : null,
                low.Count > 0 ? low : null,
                wanted.Count > 0 ? wanted : null,
                unwanted.Count > 0 ? unwanted : null,
                checkBox1.Checked ? comboBox1.Text : null,
                checkBox2.Checked ? (int)numericUpDown1.Value : -1,
                checkBox3.Checked
            );
            Program.Settings.Current.AddDestinationPath(comboBox1.Text);
            Program.Form.SetupAction(CommandFactory.RequestAsync(request));
            Close();
        }
 public void AddDestinationPath(string path)
 {
     if (profileConfMap.ContainsKey(REGKEY_DESTINATION_PATH_HISTORY))
     {
         try
         {
             JsonArray oldArray = (JsonArray)JsonConvert.Import((string)profileConfMap[REGKEY_DESTINATION_PATH_HISTORY]);
             JsonArray newArray = new JsonArray();
             newArray.Add(path);
             for (int i = 0; i < oldArray.Length && newArray.Length < 5; i++)
             {
                 string oldString = (string)oldArray[i];
                 if (oldString != path)
                     newArray.Add(oldString);
             }
             profileConfMap[REGKEY_DESTINATION_PATH_HISTORY] = newArray.ToString();
         }
         catch
         {
             profileConfMap[REGKEY_DESTINATION_PATH_HISTORY] = (new JsonArray(new string[] { path })).ToString();
         }
     }
     else
     {
         profileConfMap.Add(REGKEY_DESTINATION_PATH_HISTORY, (new JsonArray(new string[] { path })).ToString());
     }
 }
Beispiel #31
0
 private void TeacherRecommended(HttpContext context)
 {
     string topStr = context.Request.Params["TopNum"];
     int topNum = Common.Globals.SafeInt(topStr, 0);
     BLL.UserExp.UsersExp userBll = new BLL.UserExp.UsersExp();
     DataSet ds = userBll.GetReTeacher(topNum);
     JsonObject json = new JsonObject();
     if (ds != null)
     {
         if (ds.Tables[0].Rows.Count > 0)
         {
             JsonArray data = new JsonArray();
             data.Add(ds.Tables[0]);
             json.Put(TAO_KEY_DATA, data);
             json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
         }
         else
         {
             json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
         }
     }
     else
     {
         json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
     }
     context.Response.Write(json.ToString());
 }
Beispiel #32
0
        private void RelateTeacherCourse(HttpContext context)
        {
            int RowCount = 0;
            int PageCount = 0;

            string strId = context.Request.Params["CateId"];
            string strPi = context.Request.Params["pageIndex"];
            int intPi = 0;
            if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
            {
                intPi = 1;
            }
            int intPz = Maticsoft.Common.Globals.SafeInt(context.Request.Params["pageSize"], 1);
            JsonObject json = new JsonObject();
            if (!string.IsNullOrEmpty(strId))
            {
                List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByTeacherID(out RowCount, out PageCount, int.Parse(strId), intPi, intPz);
                if (list.Count > 0)
                {
                    JsonArray data = new JsonArray();
                    list.ForEach(info => data.Add(
                        new JsonObject(
                            new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
                            new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
                            )));
                    json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                    json.Put(TAO_KEY_DATA, data);
                }
                json.Put("ROWCOUNT", RowCount);
                json.Put("PAGECOUNT", PageCount);
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }
Beispiel #33
0
        private void FirstPageCommen(HttpContext context)
        {
            int RowCount = 0;
            int PageCount = 0;
            JsonObject json = new JsonObject();

            string strIndex = context.Request.Params["PageIndex"];
            page.PageIndex = Common.Globals.SafeInt(strIndex, 1);
            page.PageSize = 10;
            List<Maticsoft.Model.Tao.Comment> list = bll.GetCommentList(out RowCount, out PageCount, page, -1);
            if (list.Count > 0)
            {
                JsonArray data = new JsonArray();
                list.ForEach(info => data.Add(new JsonObject(
                    new string[] { "CommentID", "OrderID", "CourseID", "ModuleID", "UserID", "CommentInfo", "CommentDate", "ParentID", "Score", "Status", "CCount" },
                    new object[] { info.CommentID, info.OrderID, info.CourseID, info.ModuleID, info.UserID, info.Comments, info.CommentDate.ToString("yyyy-MM-dd HH:mm:ss"), info.ParentID, info.Score, info.Status, info.CCount }
                    )));
                json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
                json.Put(TAO_KEY_DATA, data);
                json.Put("ROWCOUNT", RowCount);
                json.Put("PAGECOUNT", PageCount);
            }
            else
            {
                json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
            }
            context.Response.Write(json.ToString());
        }