Esempio n. 1
0
        /// <summary>
        /// time out for SwitchToWF
        /// </summary>
        /// <param name="session"></param>
        /// <param name="sessionKeyValue"></param>
        /// <param name="timeout">Second unit</param>
        /// <returns></returns>
        public static Session SwitchToWF(Session session,
                                                           Dictionary<string, object> sessionKeyValue,
                                                           int timeout)
        {
            if (session == null)
            {
                throw new Exception("No Session !!");
            }

            if (sessionKeyValue != null)
            {
                foreach (KeyValuePair<string, object> item in sessionKeyValue)
                {
                    session.AddValue(item.Key, item.Value);
                }
            }
            bool hasTimeOut = false;
            session.Exception = null;
            DateTime now = DateTime.Now;
            hasTimeOut =!session.SwitchToWorkFlow(timeout*1000);
            if (hasTimeOut)
            {
                throw new Exception(string.Format("[TimeOut] SessionKey:{0} Line:{1} Editor:{2} Station:{3} TimeOut:{4} Cdt:{5} waiting wf timeout!!!",
                                                                      session.Key, session.Line??"",session.Editor??"", session.Station, timeout.ToString(), now.ToString("yyyyMMdd HH:mm:ss.fff")));
            }
            else
            {
                if (session.Exception != null)
                {
                    if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        session.ResumeWorkFlow();
                    }
                    throw session.Exception;
                }
            }

            return session;
        }
Esempio n. 2
0
        public static Session SwitchToWF(Session session,
                                                       Dictionary<string, object> sessionKeyValue)
        {
            if (session == null)
            {
                throw new Exception("No Session !!");
            }

            if (sessionKeyValue != null)
            {
                foreach (KeyValuePair<string, object> item in sessionKeyValue)
                {
                    session.AddValue(item.Key, item.Value);
                }
            }
            session.Exception = null;
            session.SwitchToWorkFlow();
            if (session.Exception != null)
            {
                if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                {
                    session.ResumeWorkFlow();
                }
                throw session.Exception;
            }
            return session;
        }