private void DockPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var sp    = sender as DockPanel;
            var grid  = sp.Children[0] as Grid;
            var child = grid.Children[0] as Label;

            SelectKey?.Invoke(sender, child.Content.ToString());
        }
        public override string ToString()
        {
            var showText = "";

            showText += IsSelectCtrl ? "Ctrl+" : "";
            showText += IsSelectShift? "Shift+" : "";
            showText += IsSelectAlt? "Alt+" : "";
            showText += SelectKey.ToString();
            return(showText);
        }
Пример #3
0
        private void XBO_Input_SelectKey(object sender, MouseEventArgs e)
        {
            var lbl = (Label)sender;

            var bEscape = Hooks.LowLevelKeyboardHook.LockEscape;

            Hooks.LowLevelKeyboardHook.LockEscape = false; {
                SelectKey k = new SelectKey(cfg, (string)lbl.Tag);
                k.ShowDialog();
            } Hooks.LowLevelKeyboardHook.LockEscape = bEscape;

            LoadXboxInputButtons();
        }
Пример #4
0
        public virtual object ExecuteInsert(ISqlMapSession session, object parameterObject)
        {
            object       memberValue = null;
            SelectKey    selectKey   = null;
            RequestScope request     = this._statement.Sql.GetRequestScope(this, parameterObject, session);

            if (this._statement is Insert)
            {
                selectKey = ((Insert)this._statement).SelectKey;
            }
            if ((selectKey != null) && !selectKey.isAfter)
            {
                memberValue = this._sqlMap.GetMappedStatement(selectKey.Id).ExecuteQueryForObject(session, parameterObject);
                ObjectProbe.SetMemberValue(parameterObject, selectKey.PropertyName, memberValue, request.DataExchangeFactory.ObjectFactory, request.DataExchangeFactory.AccessorFactory);
            }
            this._preparedCommand.Create(request, session, this.Statement, parameterObject);
            using (IDbCommand command = request.IDbCommand)
            {
                if (this._statement is Insert)
                {
                    command.ExecuteNonQuery();
                }
                else if (((this._statement is Procedure) && (this._statement.ResultClass != null)) && this._sqlMap.TypeHandlerFactory.IsSimpleType(this._statement.ResultClass))
                {
                    IDataParameter parameter = command.CreateParameter();
                    parameter.Direction = ParameterDirection.ReturnValue;
                    command.Parameters.Add(parameter);
                    command.ExecuteNonQuery();
                    memberValue = parameter.Value;
                    memberValue = this._sqlMap.TypeHandlerFactory.GetTypeHandler(this._statement.ResultClass).GetDataBaseValue(memberValue, this._statement.ResultClass);
                }
                else
                {
                    memberValue = command.ExecuteScalar();
                    if ((this._statement.ResultClass != null) && this._sqlMap.TypeHandlerFactory.IsSimpleType(this._statement.ResultClass))
                    {
                        memberValue = this._sqlMap.TypeHandlerFactory.GetTypeHandler(this._statement.ResultClass).GetDataBaseValue(memberValue, this._statement.ResultClass);
                    }
                }
                if ((selectKey != null) && selectKey.isAfter)
                {
                    memberValue = this._sqlMap.GetMappedStatement(selectKey.Id).ExecuteQueryForObject(session, parameterObject);
                    ObjectProbe.SetMemberValue(parameterObject, selectKey.PropertyName, memberValue, request.DataExchangeFactory.ObjectFactory, request.DataExchangeFactory.AccessorFactory);
                }
                this.RetrieveOutputParameters(request, session, command, parameterObject);
            }
            this.RaiseExecuteEvent();
            return(memberValue);
        }
Пример #5
0
        private SelectKey BuildSelectKey(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            SelectKey selectKey = null;

            ConfigurationCollection selectKeys = config.Children.Find(ConfigConstants.ELEMENT_SELECTKEY);

            if (selectKeys.Count > 0)
            {
                IConfiguration selectKeyConfig = selectKeys[0];

                BaseStatementDeSerializer selectKeyDeSerializer = new SelectKeyDeSerializer();
                selectKey = (SelectKey)selectKeyDeSerializer.Deserialize(modelStore, selectKeyConfig, configurationSetting);
            }
            return(selectKey);
        }
Пример #6
0
        /// <summary>
        /// Deserialize a TypeHandler object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="configScope"></param>
        /// <returns></returns>
        public static Insert Deserialize(XmlNode node, ConfigurationScope configScope)
        {
            Insert insert            = new Insert();
            NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);

            insert.CacheModelName  = NodeUtils.GetStringAttribute(prop, "cacheModel");
            insert.ExtendStatement = NodeUtils.GetStringAttribute(prop, "extends");
            insert.Id = NodeUtils.GetStringAttribute(prop, "id");
            insert.ParameterClassName = NodeUtils.GetStringAttribute(prop, "parameterClass");
            insert.ParameterMapName   = NodeUtils.GetStringAttribute(prop, "parameterMap");
            insert.ResultClassName    = NodeUtils.GetStringAttribute(prop, "resultClass");
            insert.ResultMapName      = NodeUtils.GetStringAttribute(prop, "resultMap");
            insert.AllowRemapping     = NodeUtils.GetBooleanAttribute(prop, "remapResults", false);
            insert.ForceDisabledAutoMapCompatibilityMode = NodeUtils.GetBooleanAttribute(prop, "forceDisabledAutoMapCompatibilityMode", false);
            insert.ForceEnableAutoMapCompatibilityMode   = NodeUtils.GetBooleanAttribute(prop, "forceEnableAutoMapCompatibilityMode", false);
            int count = node.ChildNodes.Count;

            for (int i = 0; i < count; i++)
            {
                if (node.ChildNodes[i].LocalName == "generate")
                {
                    Generate            generate = new Generate();
                    NameValueCollection props    = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties);

                    generate.By    = NodeUtils.GetStringAttribute(props, "by");
                    generate.Table = NodeUtils.GetStringAttribute(props, "table");

                    insert.Generate = generate;
                }
                else if (node.ChildNodes[i].LocalName == "selectKey")
                {
                    SelectKey           selectKey = new SelectKey();
                    NameValueCollection props     = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties);

                    selectKey.PropertyName    = NodeUtils.GetStringAttribute(props, "property");
                    selectKey.SelectKeyType   = InsertDeSerializer.ReadSelectKeyType(props["type"]);
                    selectKey.ResultClassName = NodeUtils.GetStringAttribute(props, "resultClass");

                    insert.SelectKey = selectKey;
                }
            }
            return(insert);
        }
Пример #7
0
        /// <summary>
        /// Deserializes the specified configuration in a <see cref="Insert"/> object.
        /// </summary>
        /// <param name="modelStore">The model store.</param>
        /// <param name="config">The config.</param>
        /// <param name="configurationSetting"></param>
        /// <returns></returns>
        public override IStatement Deserialize(IModelStore modelStore, IConfiguration config, ConfigurationSetting configurationSetting)
        {
            BaseDeserialize(modelStore, config, configurationSetting);

            SelectKey selectKey = BuildSelectKey(modelStore, config, configurationSetting);

            return(new Insert(
                       id,
                       parameterClass,
                       parameterMap,
                       resultClass,
                       resultsMap,
                       null,
                       null,
                       cacheModel,
                       remapResults,
                       extendsName,
                       selectKey,
                       sqlSource,
                       preserveWhitespace
                       ));
        }
Пример #8
0
 protected override void Execute(CodeActivityContext context)
 {
     try
     {
         var azureSqlConnector = new AzureSqlConnector(Db.Get(context), User.Get(context), Password.Get(context), Host.Get(context));
         var value             = azureSqlConnector.UpdateInto(Table.Get(context), Columns.Get(context).Split(';')
                                                              , Values.Get(context).Split(';'), SelectKey.Get(context), SelectValue.Get(context));;
         Response.Set(context, JsonConvert.SerializeObject(new { item = value }));
     }
     catch (Exception e)
     {
         Error.Set(context, e.Message);
     }
 }
        /// <summary>
        /// Execute an insert statement. Fill the parameter object with
        /// the ouput parameters if any, also could return the insert generated key
        /// </summary>
        /// <param name="session">The session</param>
        /// <param name="parameterObject">The parameter object used to fill the statement.</param>
        /// <returns>Can return the insert generated key.</returns>
        public virtual object ExecuteInsert(ISession session, object parameterObject)
        {
            return(Execute(PreInsertEventKey, PostInsertEventKey, session, parameterObject,
                           (r, p) =>
            {
                #region RunInsert

                object generatedKey = null;
                SelectKey selectKeyStatement = null;

                if (statement is Insert)
                {
                    selectKeyStatement = ((Insert)statement).SelectKey;
                }

                if (selectKeyStatement != null && !selectKeyStatement.isAfter)
                {
                    IMappedStatement mappedStatement = modelStore.GetMappedStatement(selectKeyStatement.Id);
                    generatedKey = mappedStatement.ExecuteQueryForObject(session, p, null);

                    ObjectProbe.SetMemberValue(p, selectKeyStatement.PropertyName, generatedKey,
                                               r.DataExchangeFactory.ObjectFactory,
                                               r.DataExchangeFactory.AccessorFactory);
                }

                preparedCommand.Create(r, session, Statement, p);

                using (IDbCommand command = r.IDbCommand)
                {
                    if (statement is Insert)
                    {
                        command.ExecuteNonQuery();
                    }
                    // Retrieve output parameter if the result class is specified
                    else if (statement is Procedure && (statement.ResultClass != null) &&
                             modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(statement.ResultClass))
                    {
                        IDataParameter returnValueParameter = command.CreateParameter();
                        returnValueParameter.Direction = ParameterDirection.ReturnValue;
                        command.Parameters.Add(returnValueParameter);

                        command.ExecuteNonQuery();
                        generatedKey = returnValueParameter.Value;

                        ITypeHandler typeHandler = modelStore.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(statement.ResultClass);
                        generatedKey = typeHandler.GetDataBaseValue(generatedKey, statement.ResultClass);
                    }
                    else
                    {
                        generatedKey = command.ExecuteScalar();
                        if ((statement.ResultClass != null) &&
                            modelStore.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(statement.ResultClass))
                        {
                            ITypeHandler typeHandler = modelStore.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(statement.ResultClass);
                            generatedKey = typeHandler.GetDataBaseValue(generatedKey, statement.ResultClass);
                        }
                    }

                    if (selectKeyStatement != null && selectKeyStatement.isAfter)
                    {
                        IMappedStatement mappedStatement = modelStore.GetMappedStatement(selectKeyStatement.Id);
                        generatedKey = mappedStatement.ExecuteQueryForObject(session, p, null);

                        ObjectProbe.SetMemberValue(p, selectKeyStatement.PropertyName, generatedKey,
                                                   r.DataExchangeFactory.ObjectFactory,
                                                   r.DataExchangeFactory.AccessorFactory);
                    }

                    RetrieveOutputParameters(r, session, command, p);
                }

                // ???
                return generatedKey;

                #endregion
            }));
        }