Example #1
0
        /// <summary>
        /// 初始化流程定义Id
        /// </summary>
        /// <param name="flInstance">流程</param>
        /// <param name="clientInfo">ClientInfo</param>
        public void InitFLDefinitionId(FLInstance flInstance, object[] clientInfo)
        {
            string flTypeName = flInstance.RootFLActivity.Name;
            string flDefinition = flInstance.GetFLDefinitionXml().InnerXml;
            string flTypeId = Global.GetFLTypeId(flTypeName, flDefinition, clientInfo);

            _flDefinitionId = new Guid(flTypeId);
        }
Example #2
0
        /// <summary>
        /// 修改流程定义
        /// </summary>
        /// <param name="flInstance">流程</param>
        /// <param name="clientInfo">ClientInfo</param>
        public static void ModifyFLInstanceDefinition(FLInstance flInstance, object[] clientInfo)
        {
            string flTypeName = flInstance.RootFLActivity.Name;
            string flDefinition = flInstance.GetFLDefinitionXml().InnerXml;
            string flTypeId = Global.GetFLTypeId(flTypeName, flDefinition, clientInfo);

            string sql = MODIFY_FLINSTANCESTATE + MODIFY_TODO;
            sql = string.Format(sql, flInstance.FLInstanceId, flTypeId);

            object o = clientInfo[0];
            object[] os = (object[])o;
            string dbAlias = os[2].ToString();

            DbConnectionType dbConnectionType = DbConnectionType.SqlClient;
            //string connString = GetConnectionString(dbAlias, out dbConnectionType, true);
            if (dbConnectionType == DbConnectionType.OleDb || dbConnectionType == DbConnectionType.Informix
                || dbConnectionType == DbConnectionType.Odbc)
            {
                sql = sql.Replace("@State", "?");
            }
            else if (dbConnectionType == DbConnectionType.OracleClient)
            {
                sql = sql.Replace("@State", ":State");
            }

            IDbConnection conn = AllocateConnection(dbAlias, true, clientInfo);
            //IDbConnection conn = AllocateConnection(dbConnectionType, connString);
            IDbCommand cmd = AllocateCommand(conn, sql);

            MemoryStream stream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, flInstance);

            IDataParameter state = null;
            if (dbConnectionType == DbConnectionType.OleDb)
            {
                state = AllocateParameter(cmd, "?", DbType.Binary);
                (state as OleDbParameter).OleDbType = OleDbType.LongVarBinary;
                state.Value = stream.GetBuffer();
            }
            else if (dbConnectionType == DbConnectionType.OracleClient)
            {
                state = AllocateParameter(cmd, ":State", DbType.Binary);
                (state as OracleParameter).OracleType = OracleType.Blob;
                state.Value = stream.GetBuffer();
            }
            else if (dbConnectionType == DbConnectionType.Odbc)
            {
                state = AllocateParameter(cmd, "?", DbType.Binary);
                (state as OdbcParameter).OdbcType = OdbcType.Binary;
                state.Value = stream.GetBuffer();
            }
            else if (dbConnectionType == DbConnectionType.Informix)
            {
                state = AllocateParameter(cmd, "?", DbType.Binary);
                state.Value = stream.GetBuffer();
            }
            else
            {
                state = AllocateParameter(cmd, "@State", DbType.Binary);
                state.Value = stream.GetBuffer();
            }

            cmd.Parameters.Add(state);

            if (cmd.Connection.State == ConnectionState.Closed)
            {
                cmd.Connection.Open();
            }

            if (dbConnectionType == DbConnectionType.Informix || dbConnectionType == DbConnectionType.Odbc)
            {
                cmd.CommandText = String.Format(MODIFY_FLINSTANCESTATE, flInstance.FLInstanceId).Replace("@State", "?");
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();

                IDbCommand cmd1 = AllocateCommand(conn, String.Format(MODIFY_TODO, flInstance.FLInstanceId, flTypeId));
                if (cmd1.Connection.State == ConnectionState.Closed)
                {
                    cmd1.Connection.Open();
                }
                cmd1.ExecuteNonQuery();
                cmd1.Connection.Close();
            }
            else
            {
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();
            }
        }
Example #3
0
        /// <summary>
        /// �����
        /// </summary>
        /// <param name="flInstance">����</param>
        /// <param name="isFirstUnload">�Ƿ��һ��ж��</param>
        private void UnloadFLInstance(FLInstance flInstance, bool isFirstUnload)
        {
            Guid flInstanceId = flInstance.FLInstanceId;
            object[] clientInfo = flInstance.GetClientInfo();
            if (clientInfo == null)
            {
                throw new Exception("FLRuntime.UnloadFLInstance");
            }

            object o = GetService(typeof(FLPersistenceService));
            if (o != null)
            {
                FLPersistenceService flPersistenceService = (FLPersistenceService)o;
                if (isFirstUnload)
                {
                    Guid flDefiniationId = flInstance.FLDefinitionId;
                    flPersistenceService.PersistenceFLDefinition(flDefiniationId, flInstance.FLDefinition.Name, flInstance.GetFLDefinitionXml().InnerXml, clientInfo);
                }
                flPersistenceService.PersistenceFL(flInstance, clientInfo);
            }

            flInstance = null;
        }