示例#1
0
    // ajax请求获得栏目内容
    // chat.aspx?action=getinfo&room=xxx&date=xxx&start=xxx&maxlines=xxx
    void DoGetInfo(bool bIsManager)
    {
        string strError = "";
        int nRet = 0;

        GetResultInfo result_info = new GetResultInfo();

        string strRoom = this.Request["room"];
        if (string.IsNullOrEmpty(strRoom) == true)
            strRoom = "default";
        else
        {
            DecodeUri(ref strRoom);
        }

        string strStart = this.Request["start"];
        string strMaxLines = this.Request["max_lines"];
        string strDate = this.Request["date"];

        if (string.IsNullOrEmpty(strStart) == true)
        {
            result_info.ErrorString = "未指定 result_offset 参数";
            goto END_GETINFO;
        }
        long lStart = 0;
        Int64.TryParse(strStart, out lStart);
        int nMaxLines = 4096;
        Int32.TryParse(strMaxLines, out nMaxLines);

        ChatInfo info = null;

        Debug.WriteLine("GetBatchTaskInfo()");

        bool bDisplayAllIP = false;
        if (bIsManager == true)
            bDisplayAllIP = true;

        nRet = app.GetChatInfo(
            MergeRights(sessioninfo.RightsOrigin, sessioninfo.SsoRights),
            strRoom,
            strDate,
            lStart,
            nMaxLines,
            bDisplayAllIP,
            out info,
            out strError);
        if (nRet == -1)
        {
            result_info.ErrorString = strError;
            goto END_GETINFO;
        }

        result_info.Name = info.Name;
        // result_info.MaxResultBytes = info.MaxResultBytes;
        result_info.ResultText = info.ResultText;
        result_info.NextStart = info.NextStart;
        result_info.TotalLines = info.TotalLines;
        result_info.ResultVersion = info.ResultVersion;

    END_GETINFO:
        /*
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ChatResultInfo));

        MemoryStream ms = new MemoryStream();
        ser.WriteObject(ms, result_info);
        string strResult = Encoding.UTF8.GetString(ms.ToArray());
        ms.Close();
         * */

        this.Response.Write(GetResultString(result_info));
        this.Response.End();
    }
示例#2
0
    // ajax请求获得栏目内容
    // chat.aspx?action=getinfo&room=xxx&date=xxx&start=xxx&maxlines=xxx
    void DoGetInfo(bool bIsManager)
    {
        string strError = "";
        int    nRet     = 0;

        GetResultInfo result_info = new GetResultInfo();

        string strRoom = this.Request["room"];

        if (string.IsNullOrEmpty(strRoom) == true)
        {
            strRoom = "default";
        }
        else
        {
            DecodeUri(ref strRoom);
        }

        string strStart    = this.Request["start"];
        string strMaxLines = this.Request["max_lines"];
        string strDate     = this.Request["date"];

        if (string.IsNullOrEmpty(strStart) == true)
        {
            result_info.ErrorString = "未指定 result_offset 参数";
            goto END_GETINFO;
        }
        long lStart = 0;

        Int64.TryParse(strStart, out lStart);
        int nMaxLines = 4096;

        Int32.TryParse(strMaxLines, out nMaxLines);

        ChatInfo info = null;

        Debug.WriteLine("GetBatchTaskInfo()");

        bool bDisplayAllIP = false;

        if (bIsManager == true)
        {
            bDisplayAllIP = true;
        }

        // return:
        //      -1  error
        //      0   file not found
        //      1   succeed
        nRet = app.GetChatInfo(
            MergeRights(sessioninfo.RightsOrigin, sessioninfo.SsoRights),
            strRoom,
            strDate,
            lStart,
            nMaxLines,
            bDisplayAllIP,
            out info,
            out strError);
        if (nRet == -1 || nRet == 0)
        {
            result_info.ErrorString = strError;
            goto END_GETINFO;
        }

        result_info.Name = info.Name;
        // result_info.MaxResultBytes = info.MaxResultBytes;
        result_info.ResultText    = info.ResultText;
        result_info.NextStart     = info.NextStart;
        result_info.TotalLines    = info.TotalLines;
        result_info.ResultVersion = info.ResultVersion;

END_GETINFO:

        /*
         * DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ChatResultInfo));
         *
         * MemoryStream ms = new MemoryStream();
         * ser.WriteObject(ms, result_info);
         * string strResult = Encoding.UTF8.GetString(ms.ToArray());
         * ms.Close();
         * */

        this.Response.Write(GetResultString(result_info));
        this.Response.End();
    }