• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SessionInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SessionInfo的典型用法代码示例。如果您正苦于以下问题:C# SessionInfo类的具体用法?C# SessionInfo怎么用?C# SessionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SessionInfo类属于命名空间,在下文中一共展示了SessionInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RegisterClient

        public bool RegisterClient(SessionClass Session, System.Threading.Thread Thread)
        {
            int nIndex = 0;
            int nMaxClients = 0;
            nMaxClients = Int32.Parse(strMaxConnections);
            if (nMaxClients > 0 & ActiveClients >= nMaxClients)
            {
                return false;
            }
            Monitor.Enter(Client);
            for (nIndex = 0; nIndex < LastClient; nIndex++)
            {
                if (Client[nIndex].Session != null) continue;
                Client[nIndex].Session = Session;
                Client[nIndex].Thread = Thread;
                ActiveClients = ActiveClients + 1;
                SetServerStatus(ActiveClients.ToString() + " clients connected to server");
                Monitor.Exit(Client);
                return true;
            }
            Monitor.Exit(Client);
            var NewClient = new SessionInfo[LastClient + 1];
            System.Array.Copy(Client, NewClient, Math.Min(Client.Length, NewClient.Length));
            Client = NewClient;
            Client[LastClient].Session = Session;
            Client[LastClient].Thread = Thread;

            LastClient++;
            ActiveClients++;

            SetServerStatus(ActiveClients.ToString() + " clients connected to server");
            return true;
        }
开发者ID:nditz,项目名称:TMS-SERVER,代码行数:33,代码来源:frmServer.cs


示例2: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         SessionInfo info = new SessionInfo();
         if (!info.getSessionData(IsPostBack, out address, out user, out binding, out hostNameIdentifier, out configName, out hoster, out version, out platform, out hostedID))
             home(false);
         hostNameIdentifier = (string)ViewState["name"];
         configName = (string)ViewState["configname"];
         version = (string)ViewState["version"];
         platform = (string)ViewState["platform"];
         hoster = (string)ViewState["hoster"];
     }
     else
     {
         Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding, out hostNameIdentifier, out configName, out version, out platform, out hoster, false);
         ViewState["name"] = hostNameIdentifier;
         ViewState["configname"] = configName;
         ViewState["version"] = version;
         ViewState["platform"] = platform;
         ViewState["hoster"] = hoster;
     }
     LabelReq.Text = "Measured Page Requests";
     LabelReqDay.Text = "Measured Page Requests Per Day";
     UTC.Text = DateTime.Now.ToUniversalTime().ToString("f") + " (UTC)";
     NodeRepeater.ItemDataBound += new RepeaterItemEventHandler(NodeRepeater_ItemDataBound);
     List<ServiceNode> myNodeMap = null;
     traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
     if (traversePath != null && traversePath.Count > 0)
     {
         if (traversePath[traversePath.Count - 1].MyNode.Status == ConfigSettings.MESSAGE_OFFLINE)
         {
             myNodeMap = new List<ServiceNode>();
             myNodeMap.Add(traversePath[traversePath.Count - 1].MyNode);
             if (traversePath[traversePath.Count - 1].PeerNodes != null)
                 myNodeMap.AddRange(traversePath[traversePath.Count - 1].PeerNodes);
         }
     }
     VirtualHost myVhost=null;
     if (myNodeMap == null)
     {
         myVhost = configProxy.getServiceNodeMap(hostNameIdentifier, configName, traversePath, user);
         if (myVhost == null)
             return;
         myNodeMap = myVhost.ServiceNodes;
     }
     VNODETotalReqs.Text = " (" + myVhost.TotalRequests.ToString() + ")";
     VNODETotalReqsPerDay.Text = " (" + myVhost.RequestsPerDay.ToString() + ")";
     TopNode.PostBackUrl = ConfigSettings.PAGE_NODES;
     ServiceVersion.Text = version;
     ServicePlatform.Text = platform;
     ServiceHoster.Text = hoster;
     TopNodeName.Text = hostNameIdentifier;
     NodeRepeater.DataSource = myNodeMap;
     NodeRepeater.DataBind();
     ReturnLabel.Text = "<a class=\"Return\" href=\"" + ConfigSettings.PAGE_NODES + "\">Return to Home Page</a>";
     GetImageButton.runtimePoweredBy(platform, RuntimePlatform);
 }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:58,代码来源:NodeMap.aspx.cs


示例3: GetSession

 public SessionInfo GetSession()
 {
     if(this.context.Session["user_id"] != null)
     {
         SessionInfo info = new SessionInfo(this.context.Session["user_id"].ToString(), this.context.Session["first_name"].ToString(), this.context.Session["last_name"].ToString(), this.context.Session["is_moderator"].ToString(), this.context.Session["is_uploader"].ToString(), this.context.Session["is_admin"].ToString());
         return info;
     }
     else return null;
 }
开发者ID:dantomosoiu,项目名称:MusicMachine,代码行数:9,代码来源:MySession.cs


示例4: DeleteSession

 /// <summary>
 /// Delete a session for the given session info
 /// </summary>
 /// <param name="session">The session info.</param>
 public void DeleteSession(SessionInfo session)
 {
     lock (SessionsSyncLock)
     {
         if (session == null || string.IsNullOrWhiteSpace(session.SessionId)) return;
         if (m_Sessions.ContainsKey(session.SessionId) == false) return;
         m_Sessions.Remove(session.SessionId);
     }
 }
开发者ID:unosquare,项目名称:embedio,代码行数:13,代码来源:LocalSessionModule.cs


示例5: GetSession

 public SessionInfo GetSession()
 {
     SessionInfo oSession = (SessionInfo)Session[AppConfig.AdminSession];
     if (oSession == null)
     {
         oSession = new SessionInfo();
         Session[AppConfig.AdminSession] = oSession;
     }
     return oSession;
 }
开发者ID:Kjubo,项目名称:luckysign,代码行数:10,代码来源:AdminMaster.master.cs


示例6: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Form.DefaultFocus = ViewTypeHosts.ClientID;
     SessionInfo info = new SessionInfo();
     info.getSessionData(IsPostBack,out address, out user, out binding, out hostNameIdentifier, out configName, out hoster, out version, out platform, out hostedID);
     if (!(Request["version"] == "drilldown"))
         Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding, out hostNameIdentifier, out configName, out version, out platform, out hoster, false);
     else
     {
         hostNameIdentifier = Request["name"];
         configName = Request["cfgSvc"];
     }
     MSMQ.Visible = false;
     ConnectionRepeater.ItemDataBound += new RepeaterItemEventHandler(ConnectionRepeater_ItemDataBound);
     viewTheType = (string)Request["viewType"];
     if (viewTheType == null || viewTheType == "")
         viewTheType = ConfigUtility.HOST_TYPE_CONNECTED_SERVICE.ToString();
     viewType = Convert.ToInt32(viewTheType);
     switch (viewType)
     {
         case ConfigUtility.HOST_TYPE_CONNECTED_SERVICE:
             {
                 ViewTypeHosts.CssClass = "LoginButton";
                 ViewTypeClients.CssClass = "LoginButtonNonSelected";
                 AddConnection.Enabled = true;
                 break;
             }
         case ConfigUtility.HOST_TYPE_CONNECTED_CLIENT_CONFIG:
             {
                 ViewTypeClients.CssClass = "LoginButton";
                 ViewTypeHosts.CssClass = "LoginButtonNonSelected";
                 AddConnection.Enabled = false;
                 break;
             }
     }
     getData();
     postback = "?name=" + hostNameIdentifier + "&cfgSvc=" + configName + "&version=" + version + "&platform=" + platform + "&hoster=" + hoster;
     ConnectionRepeater.DataBind();
     TopNode.PostBackUrl = ConfigSettings.PAGE_NODES;
     ServiceVersion.Text = version;
     ServicePlatform.Text = platform;
     ServiceHoster.Text = hoster;
     TopNodeName.Text = hostNameIdentifier;
     ReturnLabel.Text = "<a class=\"Return\" href=\"" + ConfigSettings.PAGE_NODES + postback + "\">Return to Home Page</a>";
     ViewTypeHosts.PostBackUrl = ConfigSettings.PAGE_CONNECTIONS + postback + "&viewType=" + ConfigUtility.HOST_TYPE_CONNECTED_SERVICE.ToString();
     ViewTypeClients.PostBackUrl = ConfigSettings.PAGE_CONNECTIONS + postback + "&viewType=" + ConfigUtility.HOST_TYPE_CONNECTED_CLIENT_CONFIG.ToString();
     AddConnection.PostBackUrl = ConfigSettings.PAGE_ADD_CONNECTION + postback;
     GetImageButton.runtimePoweredBy(platform, RuntimePlatform);
 }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:49,代码来源:ConnectionPoint.aspx.cs


示例7: HandleReport

        public void HandleReport(SessionInfo report)
        {
            string output = JsonConvert.SerializeObject(report, Formatting.Indented);
            string dir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sessionresults");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            StreamWriter writer =
                new StreamWriter(
                    Path.Combine(
                        dir,
                        new DateTime(report.Timestamp, DateTimeKind.Utc).ToString("yyyyMMdd_HHmmss") + "_" + report.TrackName + "_"
                        + report.SessionName + ".json"));
            writer.Write(output);
            writer.Close();
            writer.Dispose();
        }
开发者ID:flitzi,项目名称:AC_SERVER_APPS,代码行数:19,代码来源:JsonReportWriter.cs


示例8: TestSessionIssuerMethod

        public void TestSessionIssuerMethod()
        {
            SessionTokenIssuer.Instance.SetPurgeTimeout(new TimeSpan(0, 0, 5));

            var session1 = new SessionInfo { Expire = DateTime.UtcNow.AddMinutes(1), Session = Guid.NewGuid().ToString() };
            SessionTokenIssuer.Instance.AddOrUpdate(session1, Guid.NewGuid().ToString());
            var data = SessionTokenIssuer.Instance.Get(session1);
            Assert.IsFalse(string.IsNullOrEmpty(data));
            Assert.IsTrue(SessionTokenIssuer.Instance.Remove(session1));

            Task.Factory.StartNew(Producer);
            Task.Factory.StartNew(Consumer);

            Thread.Sleep(67000);

            Assert.IsTrue(SessionTokenIssuer.Instance.Count <= 10);
            Assert.IsTrue(SessionTokenIssuer.Instance.CountUser <= 10);

            SessionTokenIssuer.Instance.Dispose();
        }
开发者ID:OleksandrKulchytskyi,项目名称:Sharedeployed,代码行数:20,代码来源:SessionIssuerTest.cs


示例9: CreateSession

        /// <summary>
        /// Creates a session ID, registers the session info in the Sessions collection, and returns the appropriate session cookie.
        /// </summary>
        /// <returns>The sessions.</returns>
        private System.Net.Cookie CreateSession()
        {
            lock (SessionsSyncLock)
            {
                var sessionId = Convert.ToBase64String(
                    System.Text.Encoding.UTF8.GetBytes(
                        Guid.NewGuid().ToString() + DateTime.Now.Millisecond.ToString() + DateTime.Now.Ticks.ToString()));
                var sessionCookie = string.IsNullOrWhiteSpace(CookiePath) ?
                new System.Net.Cookie(SessionCookieName, sessionId) :
                new System.Net.Cookie(SessionCookieName, sessionId, CookiePath);

                m_Sessions[sessionId] = new SessionInfo()
                {
                    SessionId = sessionId,
                    DateCreated = DateTime.Now,
                    LastActivity = DateTime.Now
                };

                return sessionCookie;
            }
        }
开发者ID:unosquare,项目名称:embedio,代码行数:25,代码来源:LocalSessionModule.cs


示例10: HandleReport

        public void HandleReport(SessionInfo report)
        {
            string dir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sessionreports");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            string filePath = Path.Combine(dir, new DateTime(report.Timestamp, DateTimeKind.Utc).ToString("yyyyMMdd_HHmmss") + "_" + report.TrackName + "_" + report.SessionName + ".xml");

            DataContractSerializer serializer = new DataContractSerializer(typeof(SessionInfo));

            XmlWriterSettings settings = new XmlWriterSettings()
            {
                Indent = true,
                IndentChars = "\t"
            };

            using (XmlWriter writer = XmlWriter.Create(filePath, settings))
            {
                serializer.WriteObject(writer, report);
            }
        }
开发者ID:flitzi,项目名称:acplugins,代码行数:24,代码来源:XmlSessionReportWriter.cs


示例11: SearchTopLevelArticles

        // 检索顶层文章
        // return:
        //		-1	error
        //		其他 命中数
        private int SearchTopLevelArticles(
            SessionInfo sessioninfo,
            System.Web.UI.Page page,
            out string strError)
        {
            strError = "";

            if (page != null
                && page.Response.IsClientConnected == false)	// 灵敏中断
            {
                strError = "中断";
                return -1;
            }

            // 检索全部评注文章 一定时间范围内的?
            List<string> dbnames = new List<string>();
            for (int i = 0; i < this.ItemDbs.Count; i++)
            {
                ItemDbCfg cfg = this.ItemDbs[i];
                string strDbName = cfg.CommentDbName;
                if (String.IsNullOrEmpty(strDbName) == true)
                    continue;
                dbnames.Add(strDbName);
            }

            DateTime now = DateTime.Now;
            DateTime oneyearbefore = now - new TimeSpan(365, 0, 0, 0);
            string strTime = DateTimeUtil.Rfc1123DateTimeString(oneyearbefore.ToUniversalTime());

            string strQueryXml = "";
            for (int i = 0; i < dbnames.Count; i++)
            {
                string strDbName = dbnames[i];
                string strOneQueryXml = "<target list='" + strDbName + ":" + "最后修改时间'><item><word>"    // <order>DESC</order>
                    + strTime + "</word><match>exact</match><relation>" + StringUtil.GetXmlStringSimple(">=") + "</relation><dataType>number</dataType><maxCount>"
                    + "-1"// Convert.ToString(m_nMaxLineCount)
                    + "</maxCount></item><lang>zh</lang></target>";

                if (i > 0)
                    strQueryXml += "<operator value='OR' />";
                strQueryXml += strOneQueryXml;
            }

            if (dbnames.Count > 0)
                strQueryXml = "<group>" + strQueryXml + "</group>";

            RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl);
            Debug.Assert(channel != null, "Channels.GetChannel 异常");

            if (page != null)
            {
                page.Response.Write("--- begin search ...<br/>");
                page.Response.Flush();
            }

            DateTime time = DateTime.Now;

            long nRet = channel.DoSearch(strQueryXml,
                "default",
                out strError);
            if (nRet == -1)
            {
                strError = "检索时出错: " + strError;
                return -1;
            }

                TimeSpan delta = DateTime.Now - time;
            if (page != null)
            {
                page.Response.Write("search end. hitcount=" + nRet.ToString() + ", time=" + delta.ToString() + "<br/>");
                page.Response.Flush();
            }


            if (nRet == 0)
                return 0;	// not found



            if (page != null
                && page.Response.IsClientConnected == false)	// 灵敏中断
            {
                strError = "中断";
                return -1;
            }
            if (page != null)
            {
                page.Response.Write("--- begin get search result ...<br/>");
                page.Response.Flush();
            }

            time = DateTime.Now;

            List<string> aPath = null;
            nRet = channel.DoGetSearchResult(
                "default",
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppColumn.cs


示例12: CreateCommentColumn

        // [外部调用]
        // 创建内存和物理存储对象
        public int CreateCommentColumn(
            SessionInfo sessioninfo,
            System.Web.UI.Page page,
            out string strError)
        {
            this.m_lockCommentColumn.AcquireWriterLock(m_nCommentColumnLockTimeout);
            try
            {
                strError = "";
                int nRet = 0;

                if (sessioninfo.Account == null
    || StringUtil.IsInList("managecache", sessioninfo.RightsOrigin) == false)
                {
                    strError = "当前帐户不具备 managecache 权限,不能创建栏目缓存";
                    return -1;
                }

                this.CloseCommentColumn();

                if (page != null
                    && page.Response.IsClientConnected == false)	// 灵敏中断
                {
                    strError = "中断";
                    return -1;
                }

                if (this.CommentColumn == null)
                    this.CommentColumn = new ColumnStorage();

                this.CommentColumn.ReadOnly = false;
                this.CommentColumn.m_strBigFileName = this.StorageFileName;
                this.CommentColumn.m_strSmallFileName = this.StorageFileName + ".index";

                this.CommentColumn.Open(true);
                this.CommentColumn.Clear();
                // 检索
                nRet = SearchTopLevelArticles(
                    sessioninfo,
                    page,
                    out strError);
                if (nRet == -1)
                    return -1;

                // 排序
                if (page != null)
                {
                    page.Response.Write("--- begin sort ...<br/>");
                    page.Response.Flush();
                }

                DateTime time = DateTime.Now;

                this.CommentColumn.Sort();

                if (page != null)
                {
                    TimeSpan delta = DateTime.Now - time;
                    page.Response.Write("sort end. time=" + delta.ToString() + "<br/>");
                    page.Response.Flush();
                }

                // 保存物理文件
                string strTemp1;
                string strTemp2;
                this.CommentColumn.Detach(out strTemp1,
                    out strTemp2);

                this.CommentColumn.ReadOnly = true;

                this.CloseCommentColumn();

                // 重新装载
                nRet = LoadCommentColumn(
                    this.StorageFileName,
                    out strError);
                if (nRet == -1)
                    return -1;

                return 0;
            }
            finally
            {
                this.m_lockCommentColumn.ReleaseWriterLock();
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:88,代码来源:AppColumn.cs


示例13: WriteLogixData

		public static WriteDataServiceReply WriteLogixData(SessionInfo si, string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle)
开发者ID:jacobbarsoe,项目名称:ControlLogixNET,代码行数:1,代码来源:LogixServices.cs


示例14: ReadLogixData

        public static ReadDataServiceReply ReadLogixData(SessionInfo si, string tagAddress, ushort elementCount)
        {
            int requestSize = 0;
            ReadDataServiceRequest request = BuildLogixReadDataRequest(tagAddress, elementCount, out requestSize);

            EncapsRRData rrData = new EncapsRRData();
            rrData.CPF = new CommonPacket();
            rrData.CPF.AddressItem = CommonPacketItem.GetConnectedAddressItem(si.ConnectionParameters.O2T_CID);
            rrData.CPF.DataItem = CommonPacketItem.GetConnectedDataItem(request.Pack(), SequenceNumberGenerator.SequenceNumber);
            rrData.Timeout = 2000;

            EncapsReply reply = si.SendUnitData(rrData.CPF.AddressItem, rrData.CPF.DataItem);

            if (reply == null)
                return null;

            if (reply.Status != 0 && reply.Status != 0x06)
            {
                //si.LastSessionError = (int)reply.Status;
                return null;
            }

            return new ReadDataServiceReply(reply);
        }
开发者ID:jacobbarsoe,项目名称:ControlLogixNET,代码行数:24,代码来源:LogixServices.cs


示例15: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     string hostedID = null;
     Page.Form.DefaultFocus = SoaMapButton.ClientID;
     Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding,out hostNameIdentifier, out configName, out theVersion, out thePlatform, out theHoster, true);
     if (IsPostBack)
     {
         SessionInfo info = new SessionInfo();
         info.getSessionData(false, out address, out user, out binding, out hostNameIdentifier, out configName, out theHoster, out theVersion, out thePlatform, out hostedID);
     }
     InProcessRepeater.ItemDataBound += new RepeaterItemEventHandler(InProcessRepeater_ItemDataBound);
     CompositeServicesRepeater.ItemDataBound += new RepeaterItemEventHandler(CompositeServicesRepeater_ItemDataBound);
     List<ServiceConfigurationData> blankData = new List<ServiceConfigurationData>();
     ServiceConfigurationData blankItem = new ServiceConfigurationData();
     blankItem.ServiceHost = "-";
     blankItem.ServiceContract = "-";
     blankItem.Status = "-";
     blankData.Add(blankItem);
     int level;
     string levelString = (string)Request["level"];
     if (levelString == null)
         level = ConfigUtility.CONFIG_LEVEL_BASIC;
     else
     {
         level = Convert.ToInt32(levelString);
     }
     TopNode.PostBackUrl = ConfigSettings.PAGE_NODES;
     string action = Request["action"];
     if (action != "navigate")
     {
         traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
         compositeServiceData = configProxy.getServiceConfiguration(hostNameIdentifier, configName, level, true, traversePath, user);
         if (compositeServiceData != null)
         {
             if (compositeServiceData.Count > 0 && compositeServiceData[0] != null)
             {
                 string postback = "?name=" + compositeServiceData[0].ServiceHost + "&cfgSvc=" + compositeServiceData[0].ConfigServiceImplementationClassName + "&version=" + compositeServiceData[0].ServiceVersion + "&platform=" + compositeServiceData[0].RunTimePlatform + "&hoster=" + compositeServiceData[0].ServiceHoster;
                 Hosted.PostBackUrl = ConfigSettings.PAGE_VHOSTS + postback;
                 Connected.PostBackUrl = ConfigSettings.PAGE_CONNECTED_SERVICES + postback;
                 Connections.PostBackUrl = ConfigSettings.PAGE_CONNECTIONS + postback;
                 Logs.PostBackUrl = ConfigSettings.PAGE_AUDIT + postback;
                 Users.PostBackUrl = ConfigSettings.PAGE_USERS + postback;
                 InProcessRepeater.DataSource = compositeServiceData;
                 InProcessRepeater.DataBind();
                 TopNodeName.Text = hostNameIdentifier;
                 ServiceVersion.Text = theVersion;
                 ServiceHoster.Text = "" + theHoster;
                 ServicePlatform.Text = "" + thePlatform;
                 GetImageButton.runtimePoweredBy(thePlatform, RuntimePlatform);
                 if (compositeServiceData[0].ConnectedServiceConfigurationData != null && compositeServiceData[0].ConnectedServiceConfigurationData.Count > 0)
                 {
                     CompositeServicesRepeater.DataSource = compositeServiceData[0].ConnectedServiceConfigurationData;
                 }
                 else
                 {
                     CompositeServicesRepeater.DataSource = blankData;
                 }
                 CompositeServicesRepeater.DataBind();
             }
             else
                 Response.Redirect(ConfigSettings.PAGE_NODES,true);
         }
         else
         {
             Response.Redirect(ConfigSettings.PAGE_LOGOUT,true);
         }
     }
 }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:68,代码来源:Nodes.aspx.cs


示例16: Any

 public object Any(SessionInfo request)
 {
     var result = SessionAs<AuthUserSession>().ConvertTo<UserSessionInfo>();
     result.ProviderOAuthAccess = null;
     return result;
 }
开发者ID:ServiceStack,项目名称:CISetupWizard,代码行数:6,代码来源:SessionInfoService.cs


示例17: findSessionType

 public SessionInfo findSessionType(SessionInfo.sessionType type)
 {
     int index = sessions.FindIndex(s => s.Type.Equals(type));
     if (index >= 0)
     {
         return SessionList[index];
     }
     else
     {
         return new SessionInfo();
     }
 }
开发者ID:Jeffg24,项目名称:irtvo,代码行数:12,代码来源:datatypes.cs


示例18: WriteToReaderDb

        // 将更新卡户信息完整表(AccountsCompleteInfo_yyyymmdd.xml)写入读者库
        // return:
        //      -1  error
        //      0   succeed
        //      1   中断
        int WriteToReaderDb(string strLocalFilePath,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            XmlNode node = this.App.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhengyuan/replication");

            if (node == null)
            {
                strError = "尚未配置<zhangyuan><replication>参数";
                return -1;
            }

            string strMapDbName = DomUtil.GetAttr(node, "mapDbName");
            if (String.IsNullOrEmpty(strMapDbName) == true)
            {
                strError = "尚未配置<zhangyuan/replication>元素的mapDbName属性";
                return -1;
            }

            Stream file = File.Open(strLocalFilePath,
                FileMode.Open,
                FileAccess.Read);

            if (file.Length == 0)
                return 0;

            try
            {

                XmlTextReader reader = new XmlTextReader(file);

                bool bRet = false;

                // 临时的SessionInfo对象
                SessionInfo sessioninfo = new SessionInfo(this.App);

                // 模拟一个账户
                Account account = new Account();
                account.LoginName = "replication";
                account.Password = "";
                account.Rights = "setreaderinfo";

                account.Type = "";
                account.Barcode = "";
                account.Name = "replication";
                account.UserID = "replication";
                account.RmsUserName = this.App.ManagerUserName;
                account.RmsPassword = this.App.ManagerPassword;

                sessioninfo.Account = account;

                // 找到根
                while (true)
                {
                    try
                    {
                        bRet = reader.Read();
                    }
                    catch (Exception ex)
                    {
                        strError = "读XML文件发生错误: " + ex.Message;
                        return -1;
                    }

                    if (bRet == false)
                    {
                        strError = "没有根元素";
                        return -1;
                    }
                    if (reader.NodeType == XmlNodeType.Element)
                        break;
                }

                for (int i = 0; ; i++)
                {
                    if (this.Stopped == true)
                        return 1;


                    bool bEnd = false;
                    // 第二级元素
                    while (true)
                    {
                        bRet = reader.Read();
                        if (bRet == false)
                        {
                            bEnd = true;  // 结束
                            break;
                        }
                        if (reader.NodeType == XmlNodeType.Element)
                            break;
                    }

//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ZhengyuanReplication.cs


示例19: WriteOneReaderInfo

        // 写入一条数据
        // return:
        //      -1  error
        //      0   已经写入
        //      1   没有必要写入
        int WriteOneReaderInfo(
            SessionInfo sessioninfo,
            string strReaderDbName,
            string strZhengyuanXml,
            out string strError)
        {
            strError = "";

            XmlDocument zhengyuandom = new XmlDocument();

            try
            {
                zhengyuandom.LoadXml(strZhengyuanXml);
            }
            catch (Exception ex)
            {
                strError = "从正元数据中读出的XML片段装入DOM失败: " + ex.Message;
                return -1;
            }

            // AccType
            // 卡户类型
            // 1正式卡,2 临时卡
            string strAccType = DomUtil.GetElementText(zhengyuandom.DocumentElement,
                "ACCTYPE");
            if (strAccType != "1")
            {
                return 1;
            }

            string strBarcode = DomUtil.GetElementText(zhengyuandom.DocumentElement,
                "ACCNUM");
            if (String.IsNullOrEmpty(strBarcode) == true)
            {
                strError = "缺乏<ACCNUM>元素";
                return -1;
            }

            strBarcode = strBarcode.PadLeft(10, '0');

            int nRet = 0;
            string strReaderXml = "";
            string strOutputPath = "";
            byte[] baTimestamp = null;

            // 加读锁
            // 可以避免拿到读者记录处理中途的临时状态
#if DEBUG_LOCK_READER
            this.App.WriteErrorLog("WriteOneReaderInfo 开始为读者加读锁 '" + strBarcode + "'");
#endif
            this.App.ReaderLocks.LockForRead(strBarcode);

            try
            {

                RmsChannel channel = this.RmsChannels.GetChannel(this.App.WsUrl);
                if (channel == null)
                {
                    strError = "get channel error";
                    return -1;
                }

                // 获得读者记录
                // return:
                //      -1  error
                //      0   not found
                //      1   命中1条
                //      >1  命中多于1条
                nRet = this.App.GetReaderRecXml(
                    // this.RmsChannels, // sessioninfo.Channels,
                    channel,
                    strBarcode,
                    out strReaderXml,
                    out strOutputPath,
                    out baTimestamp,
                    out strError);

            }
            finally
            {
                this.App.ReaderLocks.UnlockForRead(strBarcode);
#if DEBUG_LOCK_READER
                this.App.WriteErrorLog("WriteOneReaderInfo 结束为读者加读锁 '" + strBarcode + "'");
#endif
            }

            if (nRet == -1)
                return -1;
            if (nRet > 1)
            {
                strError = "条码号 " + strBarcode + "在读者库群中检索命中 " + nRet.ToString() + " 条,请尽快更正此错误。";
                return -1;
            }

            string strAction = "";
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ZhengyuanReplication.cs


示例20: MergeTwoItemXml

        // DoOperChange()和DoOperMove()的下级函数
        // 合并新旧记录
        // return:
        //      -1  出错
        //      0   正确
        //      1   有部分修改没有兑现。说明在strError中
        public override int MergeTwoItemXml(
            SessionInfo sessioninfo,
            XmlDocument domExist,
            XmlDocument domNew,
            out string strMergedXml,
            out string strError)
        {
            strMergedXml = "";
            strError = "";
            int nRet = 0;

            if (sessioninfo != null
&& sessioninfo.Account != null
&& sessioninfo.UserType == "reader")
            {
                strError = "期库记录不允许读者进行修改";
                return -1;
            }

            // 算法的要点是, 把"新记录"中的要害字段, 覆盖到"已存在记录"中

            /*
            // 要害元素名列表
            string[] element_names = new string[] {
                "parent",
                "state",    // 状态
                "publishTime",  // 出版时间
                "issue",    // 当年期号
                "zong",   // 总期号
                "volume",   // 卷号
                "orderInfo",    // 订购信息
                "comment",  // 注释
                "batchNo"   // 批次号
            };
             * */

            bool bControlled = true;
            {
                XmlNode nodeExistRoot = domExist.DocumentElement.SelectSingleNode("orderInfo");
                if (nodeExistRoot != null)
                {
                    // 是否全部订购信息片断中的馆藏地点都在当前用户管辖之下?
                    // return:
                    //      -1  出错
                    //      0   不是全部都在管辖范围内
                    //      1   都在管辖范围内
                    nRet = IsAllOrderControlled(nodeExistRoot,
                        sessioninfo.LibraryCodeList,
                        out strError);
                    if (nRet == -1)
                        return -1;
                    if (nRet == 0)
                        bControlled = false;
                }

                if (bControlled == true)
                {
                    // 再看新内容是不是也全部在管辖之下
                    XmlNode nodeNewRoot = domNew.DocumentElement.SelectSingleNode("orderInfo");
                    if (nodeNewRoot != null)
                    {
                        // 是否全部订购信息片断中的馆藏地点都在当前用户管辖之下?
                        // return:
                        //      -1  出错
                        //      0   不是全部都在管辖范围内
                        //      1   都在管辖范围内
                        nRet = IsAllOrderControlled(nodeNewRoot,
                            sessioninfo.LibraryCodeList,
                            out strError);
                        if (nRet == -1)
                            return -1;
                        if (nRet == 0)
                            bControlled = false;
                    }
                }
            }

            if (bControlled == true // 控制了全部用到的馆藏地点的情形,也可以修改基本字段。并且具有删除 <orderInfo> 中某些片断的能力,只要新记录中不包含这些片断,就等于删除了
                || sessioninfo.GlobalUser == true) // 只有全局用户才能修改基本字段
            {
                for (int i = 0; i < core_issue_element_names.Length; i++)
                {
                    /*
                    string strTextNew = DomUtil.GetElementText(domNew.DocumentElement,
                        element_names[i]);

                    DomUtil.SetElementText(domExist.DocumentElement,
                        element_names[i], strTextNew);
                     * */
                    // 2009/10/24 changed inner-->outer
                    string strTextNew = DomUtil.GetElementOuterXml(domNew.DocumentElement,
                        core_issue_element_names[i]);

                    DomUtil.SetElementOuterXml(domExist.DocumentElement,
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:IssueItemDatabase.cs



注:本文中的SessionInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SessionNoServer类代码示例发布时间:2022-05-24
下一篇:
C# SessionID类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap