コード例 #1
0
ファイル: CommentControl.cs プロジェクト: renyh1013/dp2
        // 删除一个评注记录
        public static int DeleteCommentInfo(
            Page page,
            LibraryChannel channel,
            string strBiblioRecPath,
            string strCommentRecPath,
            byte[] timestamp,
            out string strError)
        {
            strError = "";

            LoginState loginstate = GlobalUtil.GetLoginState(page);
            if (loginstate == LoginState.NotLogin)
            {
                strError = "尚未登录, 不能删除评注";
                return -1;
            }
            if (loginstate == LoginState.Public)
            {
                strError = "访客身份, 不能删除评注";
                return -1;
            }

            OpacApplication app = (OpacApplication)page.Application["app"];
            SessionInfo sessioninfo = (SessionInfo)page.Session["sessioninfo"];

            Debug.Assert(String.IsNullOrEmpty(sessioninfo.UserID) == false, "");

            EntityInfo info = new EntityInfo();
            info.RefID = Guid.NewGuid().ToString();

            // string strTargetBiblioRecID = ResPath.GetRecordId(strBiblioRecPath);


            info.Action = "delete";
            info.NewRecPath = "";
            info.OldRecPath = strCommentRecPath;
            info.NewRecord = "";
            info.NewTimestamp = null;

            info.OldRecord = "";
            info.OldTimestamp = timestamp;

            // 
            EntityInfo[] comments = new EntityInfo[1];
            comments[0] = info;

            EntityInfo[] errorinfos = null;

            long lRet = // sessioninfo.Channel.
                channel.SetComments(
                null,
                strBiblioRecPath,
                comments,
                out errorinfos,
                out strError);
            if (lRet == -1)
            {
                return -1;
            }

            if (errorinfos != null && errorinfos.Length > 0)
            {
                int nErrorCount = 0;
                for (int i = 0; i < errorinfos.Length; i++)
                {
                    EntityInfo error = errorinfos[i];
                    if (error.ErrorCode != ErrorCodeValue.NoError)
                    {
                        if (String.IsNullOrEmpty(strError) == false)
                            strError += "; ";
                        strError += errorinfos[0].ErrorInfo;
                        nErrorCount++;
                    }
                    else
                    {
                        //strNewCommentRecPath = error.NewRecPath;
                        //strNewXml = error.NewRecord;
                        //baNewTimestamp = error.NewTimestamp;
                    }
                }
                if (nErrorCount > 0)
                {
                    return -1;
                }
            }

            return 1;
        }