text:
#pragma once
#include <aws/swf/SWF_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/swf/model/ChildPolicy.h>
#include <aws/swf/model/TaskList.h>
#include <aws/swf/model/WorkflowType.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/swf/model/WorkflowExecution.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
  class JsonValue;
} // namespace Json
} // namespace Utils
namespace SWF
{
namespace Model
{

  /**
   *
Provides details of WorkflowExecutionStarted
   * event.

See Also:
   AWS
   * API Reference

   */
  class AWS_SWF_API WorkflowExecutionStartedEventAttributes
  {
  public:
    WorkflowExecutionStartedEventAttributes();
    WorkflowExecutionStartedEventAttributes(const Aws::Utils::Json::JsonValue& jsonValue);
    WorkflowExecutionStartedEventAttributes& operator=(const Aws::Utils::Json::JsonValue& jsonValue);
    Aws::Utils::Json::JsonValue Jsonize() const;

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline const Aws::String& GetInput() const{ return m_input; }

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline void SetInput(const Aws::String& value) { m_inputHasBeenSet = true; m_input = value; }

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline void SetInput(Aws::String&& value) { m_inputHasBeenSet = true; m_input = std::move(value); }

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline void SetInput(const char* value) { m_inputHasBeenSet = true; m_input.assign(value); }

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline WorkflowExecutionStartedEventAttributes& WithInput(const Aws::String& value) { SetInput(value); return *this;}

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline WorkflowExecutionStartedEventAttributes& WithInput(Aws::String&& value) { SetInput(std::move(value)); return *this;}

    /**
     *
The input provided to the workflow execution (if any).

     */
    inline WorkflowExecutionStartedEventAttributes& WithInput(const char* value) { SetInput(value); return *this;}

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline const Aws::String& GetExecutionStartToCloseTimeout() const{ return m_executionStartToCloseTimeout; }

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline void SetExecutionStartToCloseTimeout(const Aws::String& value) { m_executionStartToCloseTimeoutHasBeenSet = true; m_executionStartToCloseTimeout = value; }

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline void SetExecutionStartToCloseTimeout(Aws::String&& value) { m_executionStartToCloseTimeoutHasBeenSet = true; m_executionStartToCloseTimeout = std::move(value); }

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline void SetExecutionStartToCloseTimeout(const char* value) { m_executionStartToCloseTimeoutHasBeenSet = true; m_executionStartToCloseTimeout.assign(value); }

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline WorkflowExecutionStartedEventAttributes& WithExecutionStartToCloseTimeout(const Aws::String& value) { SetExecutionStartToCloseTimeout(value); return *this;}

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline WorkflowExecutionStartedEventAttributes& WithExecutionStartToCloseTimeout(Aws::String&& value) { SetExecutionStartToCloseTimeout(std::move(value)); return *this;}

    /**
     *
The maximum duration for this workflow execution.

The duration is
     * specified in seconds; an integer greater than or equal to 0. The value "NONE"
     * can be used to specify unlimited duration.

     */
    inline WorkflowExecutionStartedEventAttributes& WithExecutionStartToCloseTimeout(const char* value) { SetExecutionStartToCloseTimeout(value); return *this;}

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline const Aws::String& GetTaskStartToCloseTimeout() const{ return m_taskStartToCloseTimeout; }

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline void SetTaskStartToCloseTimeout(const Aws::String& value) { m_taskStartToCloseTimeoutHasBeenSet = true; m_taskStartToCloseTimeout = value; }

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline void SetTaskStartToCloseTimeout(Aws::String&& value) { m_taskStartToCloseTimeoutHasBeenSet = true; m_taskStartToCloseTimeout = std::move(value); }

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline void SetTaskStartToCloseTimeout(const char* value) { m_taskStartToCloseTimeoutHasBeenSet = true; m_taskStartToCloseTimeout.assign(value); }

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTaskStartToCloseTimeout(const Aws::String& value) { SetTaskStartToCloseTimeout(value); return *this;}

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTaskStartToCloseTimeout(Aws::String&& value) { SetTaskStartToCloseTimeout(std::move(value)); return *this;}

    /**
     *
The maximum duration of decision tasks for this workflow type.

The
     * duration is specified in seconds; an integer greater than or equal to 0. The
     * value "NONE" can be used to specify unlimited duration.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTaskStartToCloseTimeout(const char* value) { SetTaskStartToCloseTimeout(value); return *this;}

    /**
     *
The policy to use for the child workflow executions if this workflow
     * execution is terminated, by calling the TerminateWorkflowExecution action
     * explicitly or due to an expired timeout.

The supported child policies
     * are:

TERMINATE: the child executions will be
     * terminated.

REQUEST_CANCEL: a request to cancel will be
     * attempted for each child execution by recording a
     * WorkflowExecutionCancelRequested event in its history. It is up to
     * the decider to take appropriate actions when it receives an execution history
     * with this event.

ABANDON: no action will be taken. The child
     * executions will continue to run.

     */
    inline const ChildPolicy& GetChildPolicy() const{ return m_childPolicy; }

    /**
     *
The policy to use for the child workflow executions if this workflow
     * execution is terminated, by calling the TerminateWorkflowExecution action
     * explicitly or due to an expired timeout.

The supported child policies
     * are:

TERMINATE: the child executions will be
     * terminated.

REQUEST_CANCEL: a request to cancel will be
     * attempted for each child execution by recording a
     * WorkflowExecutionCancelRequested event in its history. It is up to
     * the decider to take appropriate actions when it receives an execution history
     * with this event.

ABANDON: no action will be taken. The child
     * executions will continue to run.

     */
    inline void SetChildPolicy(const ChildPolicy& value) { m_childPolicyHasBeenSet = true; m_childPolicy = value; }

    /**
     *
The policy to use for the child workflow executions if this workflow
     * execution is terminated, by calling the TerminateWorkflowExecution action
     * explicitly or due to an expired timeout.

The supported child policies
     * are:

TERMINATE: the child executions will be
     * terminated.

REQUEST_CANCEL: a request to cancel will be
     * attempted for each child execution by recording a
     * WorkflowExecutionCancelRequested event in its history. It is up to
     * the decider to take appropriate actions when it receives an execution history
     * with this event.

ABANDON: no action will be taken. The child
     * executions will continue to run.

     */
    inline void SetChildPolicy(ChildPolicy&& value) { m_childPolicyHasBeenSet = true; m_childPolicy = std::move(value); }

    /**
     *
The policy to use for the child workflow executions if this workflow
     * execution is terminated, by calling the TerminateWorkflowExecution action
     * explicitly or due to an expired timeout.

The supported child policies
     * are:

TERMINATE: the child executions will be
     * terminated.

REQUEST_CANCEL: a request to cancel will be
     * attempted for each child execution by recording a
     * WorkflowExecutionCancelRequested event in its history. It is up to
     * the decider to take appropriate actions when it receives an execution history
     * with this event.

ABANDON: no action will be taken. The child
     * executions will continue to run.

     */
    inline WorkflowExecutionStartedEventAttributes& WithChildPolicy(const ChildPolicy& value) { SetChildPolicy(value); return *this;}

    /**
     *
The policy to use for the child workflow executions if this workflow
     * execution is terminated, by calling the TerminateWorkflowExecution action
     * explicitly or due to an expired timeout.

The supported child policies
     * are:

TERMINATE: the child executions will be
     * terminated.

REQUEST_CANCEL: a request to cancel will be
     * attempted for each child execution by recording a
     * WorkflowExecutionCancelRequested event in its history. It is up to
     * the decider to take appropriate actions when it receives an execution history
     * with this event.

ABANDON: no action will be taken. The child
     * executions will continue to run.

     */
    inline WorkflowExecutionStartedEventAttributes& WithChildPolicy(ChildPolicy&& value) { SetChildPolicy(std::move(value)); return *this;}

    /**
     *
The name of the task list for scheduling the decision tasks for this workflow
     * execution.

     */
    inline const TaskList& GetTaskList() const{ return m_taskList; }

    /**
     *
The name of the task list for scheduling the decision tasks for this workflow
     * execution.

     */
    inline void SetTaskList(const TaskList& value) { m_taskListHasBeenSet = true; m_taskList = value; }

    /**
     *
The name of the task list for scheduling the decision tasks for this workflow
     * execution.

     */
    inline void SetTaskList(TaskList&& value) { m_taskListHasBeenSet = true; m_taskList = std::move(value); }

    /**
     *
The name of the task list for scheduling the decision tasks for this workflow
     * execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTaskList(const TaskList& value) { SetTaskList(value); return *this;}

    /**
     *
The name of the task list for scheduling the decision tasks for this workflow
     * execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTaskList(TaskList&& value) { SetTaskList(std::move(value)); return *this;}

    /**
     *
The workflow type of this execution.

     */
    inline const WorkflowType& GetWorkflowType() const{ return m_workflowType; }

    /**
     *
The workflow type of this execution.

     */
    inline void SetWorkflowType(const WorkflowType& value) { m_workflowTypeHasBeenSet = true; m_workflowType = value; }

    /**
     *
The workflow type of this execution.

     */
    inline void SetWorkflowType(WorkflowType&& value) { m_workflowTypeHasBeenSet = true; m_workflowType = std::move(value); }

    /**
     *
The workflow type of this execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithWorkflowType(const WorkflowType& value) { SetWorkflowType(value); return *this;}

    /**
     *
The workflow type of this execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithWorkflowType(WorkflowType&& value) { SetWorkflowType(std::move(value)); return *this;}

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline const Aws::Vector<Aws::String>& GetTagList() const{ return m_tagList; }

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline void SetTagList(const Aws::Vector<Aws::String>& value) { m_tagListHasBeenSet = true; m_tagList = value; }

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline void SetTagList(Aws::Vector<Aws::String>&& value) { m_tagListHasBeenSet = true; m_tagList = std::move(value); }

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTagList(const Aws::Vector<Aws::String>& value) { SetTagList(value); return *this;}

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline WorkflowExecutionStartedEventAttributes& WithTagList(Aws::Vector<Aws::String>&& value) { SetTagList(std::move(value)); return *this;}

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline WorkflowExecutionStartedEventAttributes& AddTagList(const Aws::String& value) { m_tagListHasBeenSet = true; m_tagList.push_back(value); return *this; }

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline WorkflowExecutionStartedEventAttributes& AddTagList(Aws::String&& value) { m_tagListHasBeenSet = true; m_tagList.push_back(std::move(value)); return *this; }

    /**
     *
The list of tags associated with this workflow execution. An execution can
     * have up to 5 tags.

     */
    inline WorkflowExecutionStartedEventAttributes& AddTagList(const char* value) { m_tagListHasBeenSet = true; m_tagList.push_back(value); return *this; }

    inline const Aws::String& GetTaskPriority() const{ return m_taskPriority; }

    inline void SetTaskPriority(const Aws::String& value) { m_taskPriorityHasBeenSet = true; m_taskPriority = value; }

    inline void SetTaskPriority(Aws::String&& value) { m_taskPriorityHasBeenSet = true; m_taskPriority = std::move(value); }

    inline void SetTaskPriority(const char* value) { m_taskPriorityHasBeenSet = true; m_taskPriority.assign(value); }

    inline WorkflowExecutionStartedEventAttributes& WithTaskPriority(const Aws::String& value) { SetTaskPriority(value); return *this;}

    inline WorkflowExecutionStartedEventAttributes& WithTaskPriority(Aws::String&& value) { SetTaskPriority(std::move(value)); return *this;}

    inline WorkflowExecutionStartedEventAttributes& WithTaskPriority(const char* value) { SetTaskPriority(value); return *this;}

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline const Aws::String& GetContinuedExecutionRunId() const{ return m_continuedExecutionRunId; }

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline void SetContinuedExecutionRunId(const Aws::String& value) { m_continuedExecutionRunIdHasBeenSet = true; m_continuedExecutionRunId = value; }

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline void SetContinuedExecutionRunId(Aws::String&& value) { m_continuedExecutionRunIdHasBeenSet = true; m_continuedExecutionRunId = std::move(value); }

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline void SetContinuedExecutionRunId(const char* value) { m_continuedExecutionRunIdHasBeenSet = true; m_continuedExecutionRunId.assign(value); }

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithContinuedExecutionRunId(const Aws::String& value) { SetContinuedExecutionRunId(value); return *this;}

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithContinuedExecutionRunId(Aws::String&& value) { SetContinuedExecutionRunId(std::move(value)); return *this;}

    /**
     *
If this workflow execution was started due to a
     * ContinueAsNewWorkflowExecution decision, then it contains the
     * runId of the previous workflow execution that was closed and
     * continued as this execution.

     */
    inline WorkflowExecutionStartedEventAttributes& WithContinuedExecutionRunId(const char* value) { SetContinuedExecutionRunId(value); return *this;}

    /**
     *
The source workflow execution that started this workflow execution. The
     * member is not set if the workflow execution was not started by a workflow.

     */
    inline const WorkflowExecution& GetParentWorkflowExecution() const{ return m_parentWorkflowExecution; }

    /**
     *
The source workflow execution that started this workflow execution. The
     * member is not set if the workflow execution was not started by a workflow.

     */
    inline void SetParentWorkflowExecution(const WorkflowExecution& value) { m_parentWorkflowExecutionHasBeenSet = true; m_parentWorkflowExecution = value; }

    /**
     *
The source workflow execution that started this workflow execution. The
     * member is not set if the workflow execution was not started by a workflow.

     */
    inline void SetParentWorkflowExecution(WorkflowExecution&& value) { m_parentWorkflowExecutionHasBeenSet = true; m_parentWorkflowExecution = std::move(value); }

    /**
     *
The source workflow execution that started this workflow execution. The
     * member is not set if the workflow execution was not started by a workflow.

     */
    inline WorkflowExecutionStartedEventAttributes& WithParentWorkflowExecution(const WorkflowExecution& value) { SetParentWorkflowExecution(value); return *this;}

    /**
     *
The source workflow execution that started this workflow execution. The
     * member is not set if the workflow execution was not started by a workflow.

     */
    inline WorkflowExecutionStartedEventAttributes& WithParentWorkflowExecution(WorkflowExecution&& value) { SetParentWorkflowExecution(std::move(value)); return *this;}

    /**
     *
The ID of the StartChildWorkflowExecutionInitiated event
     * corresponding to the StartChildWorkflowExecution decision to start
     * this workflow execution. The source event with this ID can be found in the
     * history of the source workflow execution. This information can be useful for
     * diagnosing problems by tracing back the chain of events leading up to this
     * event.

     */
    inline long long GetParentInitiatedEventId() const{ return m_parentInitiatedEventId; }

    /**
     *
The ID of the StartChildWorkflowExecutionInitiated event
     * corresponding to the StartChildWorkflowExecution decision to start
     * this workflow execution. The source event with this ID can be found in the
     * history of the source workflow execution. This information can be useful for
     * diagnosing problems by tracing back the chain of events leading up to this
     * event.

     */
    inline void SetParentInitiatedEventId(long long value) { m_parentInitiatedEventIdHasBeenSet = true; m_parentInitiatedEventId = value; }

    /**
     *
The ID of the StartChildWorkflowExecutionInitiated event
     * corresponding to the StartChildWorkflowExecution decision to start
     * this workflow execution. The source event with this ID can be found in the
     * history of the source workflow execution. This information can be useful for
     * diagnosing problems by tracing back the chain of events leading up to this
     * event.

     */
    inline WorkflowExecutionStartedEventAttributes& WithParentInitiatedEventId(long long value) { SetParentInitiatedEventId(value); return *this;}

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline const Aws::String& GetLambdaRole() const{ return m_lambdaRole; }

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline void SetLambdaRole(const Aws::String& value) { m_lambdaRoleHasBeenSet = true; m_lambdaRole = value; }

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline void SetLambdaRole(Aws::String&& value) { m_lambdaRoleHasBeenSet = true; m_lambdaRole = std::move(value); }

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline void SetLambdaRole(const char* value) { m_lambdaRoleHasBeenSet = true; m_lambdaRole.assign(value); }

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline WorkflowExecutionStartedEventAttributes& WithLambdaRole(const Aws::String& value) { SetLambdaRole(value); return *this;}

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline WorkflowExecutionStartedEventAttributes& WithLambdaRole(Aws::String&& value) { SetLambdaRole(std::move(value)); return *this;}

    /**
     *
The IAM role attached to this workflow execution to use when invoking AWS
     * Lambda functions.

     */
    inline WorkflowExecutionStartedEventAttributes& WithLambdaRole(const char* value) { SetLambdaRole(value); return *this;}

  private:
    Aws::String m_input;
    bool m_inputHasBeenSet;
    Aws::String m_executionStartToCloseTimeout;
    bool m_executionStartToCloseTimeoutHasBeenSet;
    Aws::String m_taskStartToCloseTimeout;
    bool m_taskStartToCloseTimeoutHasBeenSet;
    ChildPolicy m_childPolicy;
    bool m_childPolicyHasBeenSet;
    TaskList m_taskList;
    bool m_taskListHasBeenSet;
    WorkflowType m_workflowType;
    bool m_workflowTypeHasBeenSet;
    Aws::Vector<Aws::String> m_tagList;
    bool m_tagListHasBeenSet;
    Aws::String m_taskPriority;
    bool m_taskPriorityHasBeenSet;
    Aws::String m_continuedExecutionRunId;
    bool m_continuedExecutionRunIdHasBeenSet;
    WorkflowExecution m_parentWorkflowExecution;
    bool m_parentWorkflowExecutionHasBeenSet;
    long long m_parentInitiatedEventId;
    bool m_parentInitiatedEventIdHasBeenSet;
    Aws::String m_lambdaRole;
    bool m_lambdaRoleHasBeenSet;
  };

} // namespace Model
} // namespace SWF
} // namespace Aws


text:
layout: default
---

      {{ content }}

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0"?>
<!DOCTYPE markables SYSTEM "markables.dtd">
<markables xmlns="www.eml.org/NameSpaces/secmark">
<markable id="markable_10009" span="word_12" phrase_type="np"  complex_np="no"  np_form="other"  referentiality="discourse-new"  grammatical_role="sbj"  ambiguity="not_ambig"  dir_speech="text_level" />
<markable id="markable_4" span="word_14..word_15,word_19..word_23" phrase_type="pp"  referentiality="discourse-new"  np_form="indefnp"  complex_np="yes"  grammatical_role="other"  ambiguity="not_ambig"  dir_speech="text_level" />
</markables>


text:
namespace SimpleJudje.Contracts
{
    public interface IDirectoryChanger
    {
        void ChangeCurrentDirectoryRelative(string relativePath);

        void ChangeCurrentDirectoryAbsolute(string absolutePath);
    }
}


text:
"""Define names for all type symbols known in the standard interpreter.

Types that are part of optional modules (e.g. array) are not listed.
"""

import sys

NoneType = type(None)
TypeType = type(NoneType)

IntType = type(0)
LongType = type(0L)
FloatType = type(0.0)
try:
    ComplexType = type(complex(0,1))
except NameError:
    pass

StringType = type('')
UnicodeType = type(u'')
BufferType = type(buffer(''))

TupleType = type(())
ListType = type([])
DictType = DictionaryType = type({})

def _f(): pass
FunctionType = type(_f)
LambdaType = type(lambda: None)         # Same as FunctionType
try:
    CodeType = type(_f.func_code)
except:
    pass

class _C:
    def _m(self): pass
ClassType = type(_C)
UnboundMethodType = type(_C._m)         # Same as MethodType
_x = _C()
InstanceType = type(_x)
MethodType = type(_x._m)

BuiltinFunctionType = type(len)
BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType

ModuleType = type(sys)

try:
    FileType = type(sys.__stdin__)
except:
    pass
XRangeType = type(xrange(0))

try:
    raise TypeError
except TypeError:
    try:
        tb = sys.exc_info()[2]
        TracebackType = type(tb)
        FrameType = type(tb.tb_frame)
    except:
        pass
    tb = None; del tb

SliceType = type(slice(0))
EllipsisType = type(Ellipsis)

del sys, _f, _C, _x                     # Not for export


text:
Have some fun with live data visualisation and mongoDB!

In this demo we collect accelerometer data from smartphones and visualize them live in the browser.
Also the data is saved to mongoDB and we have some short and long(er) term live aggregation examples prepared.
This is meant to be an entertaining talk showing emphasizing on the easiness of making something out of live data.
All you need is included, you can run this on a MacBook wired to a projector.

Yes, the data we collect is useless (privacy)
we just want to have something moving.

You need:
* mongoDB installed
* nodeJS installed
* WIFI
* some smartphone(s)

set up (on a Mac OS X / *nix system):
install the some extra stuff via node's npm:

```
npm i
```

create & start a local mongodb instance, the data folder will be created inside mongodb, make sure port 27017 is not taken already

```
sh mongodb/startDatabase.sh
```

open index.js
and adjust the config if needed

```
config = {
    domain: "localhost", // host your mongodb is running on
    database: "iot_data", // mongodb database name
    mqtthost: "localhost" // optional host your mqtt host is running on
};
```

run the webserver
```
node index.js
```

## Collect accelerometer data ##
make your users go to

http://<IP YOUR NODE SERVER IS RUNNING ON>:3000/ page -> send accelerometer data to node

## visualization of collected data in your local browser ##

http://localhost:3000/cockpit -> show live stream data

http://localhost:3000/cockpit-aggregated -> show aggregated data

originally created for our Mannheim mongoDB MUG
http://www.meetup.com/Mannheim-MongoDB-User-Group/events/218857345/

if you want to go even further and connect live sensors via MQTT check out rgreschner's:
https://github.com/rgreschner/mongodb-iot-mqtt-example

## in your browser ##
![Alt text](README.png "Example")

## on a smartphone ##
![Alt text](USER.png "Smartphone exmaple")


text:
package com.consol.citrus.jms.endpoint;

import com.consol.citrus.context.TestContext;
import com.consol.citrus.exceptions.ActionTimeoutException;
import com.consol.citrus.exceptions.CitrusRuntimeException;
import com.consol.citrus.message.Message;
import com.consol.citrus.message.correlation.CorrelationManager;
import com.consol.citrus.message.correlation.PollingCorrelationManager;
import com.consol.citrus.messaging.ReplyConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.connection.ConnectionFactoryUtils;
import org.springframework.jms.support.JmsUtils;
import org.springframework.jms.support.destination.DynamicDestinationResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import javax.jms.*;

/**
 * @author Christoph Deppisch
 * @since 1.4
 */
public class JmsSyncProducer extends JmsProducer implements ReplyConsumer {

    /** JMS connection */
    private Connection connection = null;

    /** JMS session */
    private Session session = null;

    /** Store of reply messages */
    private CorrelationManager<Message> correlationManager;

    /** Endpoint configuration */
    private final JmsSyncEndpointConfiguration endpointConfiguration;

    /** Logger */
    private static Logger log = LoggerFactory.getLogger(JmsSyncProducer.class);

    /**
     * Default constructor using endpoint configuration.
     * @param name
     * @param endpointConfiguration
     */
    public JmsSyncProducer(String name, JmsSyncEndpointConfiguration endpointConfiguration) {
        super(name, endpointConfiguration);
        this.endpointConfiguration = endpointConfiguration;

        this.correlationManager = new PollingCorrelationManager(endpointConfiguration, "Reply message did not arrive yet");
    }

    @Override
    public void send(Message message, TestContext context) {
        Assert.notNull(message, "Message is empty - unable to send empty message");

        String correlationKeyName = endpointConfiguration.getCorrelator().getCorrelationKeyName(getName());
        String correlationKey = endpointConfiguration.getCorrelator().getCorrelationKey(message);
        correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context);

        context.onOutboundMessage(message);

        MessageProducer messageProducer = null;
        MessageConsumer messageConsumer = null;
        Destination replyToDestination = null;

        try {
            createConnection();
            createSession(connection);

            javax.jms.Message jmsRequest = endpointConfiguration.getMessageConverter().createJmsMessage(message, session, endpointConfiguration, context);
            endpointConfiguration.getMessageConverter().convertOutbound(jmsRequest, message, endpointConfiguration, context);

            Destination destination;
            if (endpointConfiguration.getDestination() != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(endpointConfiguration.getDestination()) + "'");
                }

                destination = endpointConfiguration.getDestination();
            } else if (StringUtils.hasText(endpointConfiguration.getDestinationName())){
                if (endpointConfiguration.getDestinationNameResolver() != null) {
                    destination = resolveDestination(context.replaceDynamicContentInString(endpointConfiguration.getDestinationNameResolver().resolveEndpointUri(message, endpointConfiguration.getDestinationName())));
                } else {
                    destination = resolveDestination(context.replaceDynamicContentInString(endpointConfiguration.getDestinationName()));
                }
            } else if (endpointConfiguration.getJmsTemplate().getDefaultDestination() != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(endpointConfiguration.getJmsTemplate().getDefaultDestination()) + "'");
                }

                destination = endpointConfiguration.getJmsTemplate().getDefaultDestination();
            } else if (StringUtils.hasText(endpointConfiguration.getJmsTemplate().getDefaultDestinationName())) {
                destination = resolveDestination(context.replaceDynamicContentInString(endpointConfiguration.getJmsTemplate().getDefaultDestinationName()));
            } else {
                throw new CitrusRuntimeException("Unable to send message - JMS destination not set");
            }

            messageProducer = session.createProducer(destination);

            replyToDestination = getReplyDestination(session, message);
            if (replyToDestination instanceof TemporaryQueue || replyToDestination instanceof TemporaryTopic) {
                messageConsumer = session.createConsumer(replyToDestination);
            }

            jmsRequest.setJMSReplyTo(replyToDestination);
            messageProducer.send(jmsRequest);

            if (messageConsumer == null) {
                messageConsumer = createMessageConsumer(replyToDestination, jmsRequest.getJMSMessageID());
            }

            log.info("Message was sent to JMS destination: '{}'", endpointConfiguration.getDestinationName(destination));
            log.debug("Receiving reply message on destination: '{}'", replyToDestination);

            javax.jms.Message jmsReplyMessage = (endpointConfiguration.getTimeout() >= 0) ? messageConsumer.receive(endpointConfiguration.getTimeout()) : messageConsumer.receive();

            if (jmsReplyMessage == null) {
                throw new ActionTimeoutException("Reply timed out after " +
                        endpointConfiguration.getTimeout() + "ms. Did not receive reply message on reply destination");
            }

            Message responseMessage = endpointConfiguration.getMessageConverter().convertInbound(jmsReplyMessage, endpointConfiguration, context);

            log.info("Received reply message on JMS destination: '{}'", replyToDestination);

            context.onInboundMessage(responseMessage);

            correlationManager.store(correlationKey, responseMessage);
        } catch (JMSException e) {
            throw new CitrusRuntimeException(e);
        } finally {
            JmsUtils.closeMessageProducer(messageProducer);
            JmsUtils.closeMessageConsumer(messageConsumer);
            deleteTemporaryDestination(replyToDestination);
        }
    }

    @Override
    public Message receive(TestContext context) {
        return receive(correlationManager.getCorrelationKey(
                endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()), context), context);
    }

    @Override
    public Message receive(String selector, TestContext context) {
        return receive(selector, context, endpointConfiguration.getTimeout());
    }

    @Override
    public Message receive(TestContext context, long timeout) {
        return receive(correlationManager.getCorrelationKey(
                endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()), context), context, timeout);
    }

    @Override
    public Message receive(String selector, TestContext context, long timeout) {
        Message message = correlationManager.find(selector, timeout);

        if (message == null) {
            throw new ActionTimeoutException("Action timeout while receiving synchronous reply message on jms destination");
        }

        return message;
    }

    /**
     * Create new JMS connection.
     * @return connection
     * @throws JMSException
     */
    protected void createConnection() throws JMSException {
        if (connection == null) {
            if (!endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof QueueConnectionFactory) {
                connection = ((QueueConnectionFactory) endpointConfiguration.getConnectionFactory()).createQueueConnection();
            } else if (endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof TopicConnectionFactory) {
                connection = ((TopicConnectionFactory) endpointConfiguration.getConnectionFactory()).createTopicConnection();
                connection.setClientID(getName());
            } else {
                log.warn("Not able to create a connection with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" +
                        " when using setting 'publish-subscribe-domain' (=" + endpointConfiguration.isPubSubDomain() + ")");

                connection = endpointConfiguration.getConnectionFactory().createConnection();
            }

            connection.start();
        }
    }

    /**
     * Create new JMS session.
     * @param connection to use for session creation.
     * @return session.
     * @throws JMSException
     */
    protected void createSession(Connection connection) throws JMSException {
        if (session == null) {
            if (!endpointConfiguration.isPubSubDomain() && connection instanceof QueueConnection) {
                session = ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            } else if (endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof TopicConnectionFactory) {
                session = ((TopicConnection) connection).createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            } else {
                log.warn("Not able to create a session with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" +
                        " when using setting 'publish-subscribe-domain' (=" + endpointConfiguration.isPubSubDomain() + ")");

                session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            }
        }
    }

    /**
     * Creates a message consumer on temporary/durable queue or topic. Durable queue/topic destinations
     * require a message selector to be set.
     *
     * @param replyToDestination the reply destination.
     * @param messageId the messageId used for optional message selector.
     * @return
     * @throws JMSException
     */
    private MessageConsumer createMessageConsumer(Destination replyToDestination, String messageId) throws JMSException {
        MessageConsumer messageConsumer;

        if (replyToDestination instanceof Queue) {
            messageConsumer = session.createConsumer(replyToDestination,
                    "JMSCorrelationID = '" + messageId.replaceAll("'", "''") + "'");
        } else {
            messageConsumer = session.createDurableSubscriber((Topic)replyToDestination, getName(),
                    "JMSCorrelationID = '" + messageId.replaceAll("'", "''") + "'", false);
        }

        return messageConsumer;
    }

    /**
     * Delete temporary destinations.
     * @param destination
     */
    private void deleteTemporaryDestination(Destination destination) {
        log.debug("Delete temporary destination: '{}'", destination);

        try {
            if (destination instanceof TemporaryQueue) {
                ((TemporaryQueue) destination).delete();
            } else if (destination instanceof TemporaryTopic) {
                ((TemporaryTopic) destination).delete();
            }
        } catch (JMSException e) {
            log.error("Error while deleting temporary destination '" + destination + "'", e);
        }
    }

    /**
     * Retrieve the reply destination either by injected instance, destination name or
     * by creating a new temporary destination.
     *
     * @param session current JMS session
     * @param message holding possible reply destination in header.
     * @return the reply destination.
     * @throws JMSException
     */
    private Destination getReplyDestination(Session session, Message message) throws JMSException {
        if (message.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL) != null) {
            if (message.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL) instanceof Destination) {
                return (Destination) message.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL);
            } else {
                return resolveDestinationName(message.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL).toString(), session);
            }
        } else if (endpointConfiguration.getReplyDestination() != null) {
            return endpointConfiguration.getReplyDestination();
        } else if (StringUtils.hasText(endpointConfiguration.getReplyDestinationName())) {
            return resolveDestinationName(endpointConfiguration.getReplyDestinationName(), session);
        }

        if (endpointConfiguration.isPubSubDomain() && session instanceof TopicSession){
            return session.createTemporaryTopic();
        } else {
            return session.createTemporaryQueue();
        }
    }

    /**
     * Resolve destination from given name.
     * @param destinationName
     * @return
     * @throws JMSException
     */
    private Destination resolveDestination(String destinationName) throws JMSException {
        if (log.isDebugEnabled()) {
            log.debug("Sending JMS message to destination: '" + destinationName + "'");
        }

        return resolveDestinationName(destinationName, session);
    }

    /**
     * Resolves the destination name from Jms session.
     * @param name
     * @param session
     * @return
     */
    private Destination resolveDestinationName(String name, Session session) throws JMSException {
        if (endpointConfiguration.getDestinationResolver() != null) {
            return endpointConfiguration.getDestinationResolver().resolveDestinationName(session, name, endpointConfiguration.isPubSubDomain());
        }

        return new DynamicDestinationResolver().resolveDestinationName(session, name, endpointConfiguration.isPubSubDomain());
    }

    /**
     * Destroy method closing JMS session and connection
     */
    public void destroy() {
        JmsUtils.closeSession(session);

        if (connection != null) {
            ConnectionFactoryUtils.releaseConnection(connection, endpointConfiguration.getConnectionFactory(), true);
        }
    }

    /**
     * Gets the correlation manager.
     * @return
     */
    public CorrelationManager<Message> getCorrelationManager() {
        return correlationManager;
    }

    /**
     * Sets the correlation manager.
     * @param correlationManager
     */
    public void setCorrelationManager(CorrelationManager<Message> correlationManager) {
        this.correlationManager = correlationManager;
    }
}


text:
require_relative '../dice_expression'
module FifthedSim
  class DivisionNode < DiceExpression

    def initialize(num, div)
      @lhs = num
      @rhs = div
    end

    def value
      @lhs.value / @rhs.value
    end

    def reroll
      self.class.new(@lhs.reroll, @rhs.reroll)
    end

    def distribution
      @lhs.distribution.convolve_divide(@rhs.distribution)
    end

    define_binary_op_equations "/"
  end
end


text:
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/core-pages/core-pages.html">
<link rel="import" href="../bower_components/core-icon-button/core-icon-button.html">
<link rel="import" href="./calendar-month.html">
<link rel="import" href="./calendar-week.html">
<link rel="import" href="./calendar-day.html">
<link rel="import" href="./event-list.html">

<polymer-element name="event-calendar" attributes="curDate events header startHour view" layout vertical>

	<template>

		<template if="{{header != null}}">

				<core-icon-button icon="apps" active?="{{view == 'month'}}" value="month" on-tap="{{viewButtonTapped}}"></core-icon-button>
				<core-icon-button icon="view-week" active?="{{view == 'week'}}" value="week" on-tap="{{viewButtonTapped}}"></core-icon-button>
				<core-icon-button icon="view-day" active?="{{view == 'day'}}" value="day" on-tap="{{viewButtonTapped}}"></core-icon-button>
				<core-icon-button icon="view-list" active?="{{view == 'list'}}" value="list" on-tap="{{viewButtonTapped}}"></core-icon-button>

				<template if="{{view=='month'}}">
					<core-icon-button icon="chevron-left" on-tap="{{monthBack}}"></core-icon-button>

{{formatMonth(curDate)}}

					<core-icon-button icon="chevron-right" on-tap="{{monthForward}}"></core-icon-button>

					<core-icon-button icon="today" on-tap="{{todayTapped}}"></core-icon-button>
				</template>
				<template if="{{view=='week'}}">
					<core-icon-button icon="chevron-left" on-tap="{{weekBack}}"></core-icon-button>

{{formatWeek($.calWeek.days)}}

					<core-icon-button icon="chevron-right" on-tap="{{weekForward}}"></core-icon-button>

					<core-icon-button icon="today" on-tap="{{todayTapped}}"></core-icon-button>
				</template>
				<template if="{{view=='day'}}">
					<core-icon-button icon="chevron-left" on-tap="{{dayBack}}"></core-icon-button>

{{formatDate(curDate)}}

					<core-icon-button icon="chevron-right" on-tap="{{dayForward}}"></core-icon-button>

					<core-icon-button icon="today" on-tap="{{todayTapped}}"></core-icon-button>
				</template>
				<template if="{{view=='list'}}">

Event List

				</template>

			<template if="{{view=='week'}}">

					<template repeat="{{day, idx in $.calWeek.days}}">

{{formatDateInWeek(day)}}

					</template>

			</template>
		</template>
		<core-pages flex selected="{{viewPage[view]}}">
			<calendar-month id="calMonth" curDate="{{curDate}}" events="{{events}}" header="{{header}}"></calendar-month>
			<calendar-week id="calWeek" flex curDate="{{curDate}}" events="{{events}}" header="{{header}}" startHour="{{startHour}}"></calendar-week>
			<calendar-day date="{{curDate}}" events="{{events}}" header="{{header}}" scroll startHour="{{startHour}}"></calendar-day>
			<event-list events="{{events}}" header="{{header}}"></event-list>
		</core-pages>
	</template>

</polymer-element>


text:
package com.jiangge.controller;

import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiangge.pojo.Apps;
import com.jiangge.pojo.Command;
import com.jiangge.pojo.Device;
import com.jiangge.pojo.DeviceTemp;
import com.jiangge.pojo.Profile;
import com.jiangge.service.AppsService;
import com.jiangge.service.CommandService;
import com.jiangge.service.DeviceService;
import com.jiangge.service.DeviceTempService;
import com.jiangge.service.ProfileService;
import com.jiangge.utils.ConfigUtils;
import com.jiangge.utils.MDMTaskUtils;
import com.jiangge.utils.MdmUtils;
import com.jiangge.utils.PushUtils;
import com.jiangge.utils.StringUtils;
import com.jiangge.vo.HttpConst;
import com.jiangge.vo.InstallTypeEnum;
import com.jiangge.vo.MobileBean;
import com.jiangge.vo.PageBean;

@SuppressWarnings("all")
@Controller
@RequestMapping("/api")
public class APIController {

	private DeviceService deviceService;
	private CommandService commandService;
	private AppsService appsService;
	private ProfileService profileService;
	private DeviceTempService deviceTempService;

	/**
	 * 获取mobileconfig下载地址
	 */
	@ResponseBody
	@RequestMapping("/getMobileconfig")
	public MobileBean getMobileconfig(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
	    System.out.println("-------------------getMobileconfig Start---------------");
        String deviceFlag = request.getParameter("deviceFlag")==null?"":request.getParameter("deviceFlag").trim();
        String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
		try{
			if(StringUtils.isEmpty(deviceFlag) || StringUtils.isEmpty(callBack)){
	        	bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc("设参数不完整!");
				bean.setData("");
	        }else{
	        	String uuid = UUID.randomUUID().toString().replaceAll("-", "").toLowerCase();
	        	String url = ConfigUtils.getConfig("BASE_URL")+ConfigUtils.getConfig("DOWN_MOBILECONFIG");
	            String mobileconfig = MessageFormat.format(url,uuid);
	            bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				Map<String,String> params = new HashMap<String,String>();
				params.put("url", mobileconfig);
				params.put("deviceId", uuid);
				bean.setData(params);
				/**保存数据**/
				DeviceTemp deviceTemp = new DeviceTemp();
				deviceTemp.setDeviceFlag(deviceFlag);
				deviceTemp.setCallBack(callBack);
				deviceTemp.setDeviceId(uuid);
				deviceTemp.setId(UUID.randomUUID().toString());
				deviceTempService.save(deviceTemp);
				/**生成描述文件**/
			    String configPath =  request.getRealPath("mdmtool");
			    String tempPath =  request.getRealPath("mdmtool/down");
				MDMTaskUtils.createMobileconfig(configPath, tempPath, uuid);
	        }
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
		System.out.println("-------------------getMobileconfig End---------------");
	    return bean;
	}

	/**
     * 获取设备的ProfileList
     */
    @ResponseBody
	@RequestMapping("/profileList")
    public MobileBean profileList(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                     String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                     String pemPath = request.getRealPath("mdmtool") + pemFile;
                     int pushState = PushUtils.singleMDMPush(pemPath, device);
                     if (pushState == 1) {
                         Command command = new Command();
                         command.setCommand(MdmUtils.ProfileList);
                         command.setDeviceId(deviceId);
                         command.setDoIt("0");
                         command.setCallBack(callBack);
                         commandService.saveOrUpdate(command);
                         bean.setStatus(HttpConst.HTTP_STATUS_200);
         			 	 bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
         				 bean.setData("发送获取设备的ProfileList命令成功!");
                     } else {
                         bean.setStatus(HttpConst.HTTP_STATUS_403);
              			 bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
              		     bean.setData("发送获取设备的ProfileList命令失败!");
                     }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 获取设备的ProvisioningProfileList
     */
    @ResponseBody
	@RequestMapping("/provisioningProfileList")
    public MobileBean provisioningProfileList(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                     String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                     String pemPath = request.getRealPath("mdmtool") + pemFile;
                     int pushState = PushUtils.singleMDMPush(pemPath, device);
                     if (pushState == 1) {
                         Command command = new Command();
                         command.setCommand(MdmUtils.ProvisioningProfileList);
                         command.setDeviceId(deviceId);
                         command.setDoIt("0");
                         command.setCallBack(callBack);
                         commandService.saveOrUpdate(command);
                         bean.setStatus(HttpConst.HTTP_STATUS_200);
         			 	 bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
         				 bean.setData("发送获取设备的ProvisioningProfileList命令成功!");
                     } else {
                         bean.setStatus(HttpConst.HTTP_STATUS_403);
              			 bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
              		     bean.setData("发送获取设备的ProvisioningProfileList命令失败!");
                     }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 获取设备的CertificateList
     */
    @ResponseBody
	@RequestMapping("/certificateList")
    public MobileBean certificateList(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                     String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                     String pemPath = request.getRealPath("mdmtool") + pemFile;
                     int pushState = PushUtils.singleMDMPush(pemPath, device);
                     if (pushState == 1) {
                         Command command = new Command();
                         command.setCommand(MdmUtils.CertificateList);
                         command.setDeviceId(deviceId);
                         command.setDoIt("0");
                         command.setCallBack(callBack);
                         commandService.saveOrUpdate(command);
                         bean.setStatus(HttpConst.HTTP_STATUS_200);
         			 	 bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
         				 bean.setData("发送获取设备的CertificateList命令成功!");
                     } else {
                         bean.setStatus(HttpConst.HTTP_STATUS_403);
              			 bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
              		     bean.setData("发送获取设备的CertificateList命令失败!");
                     }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

	 /**
     * 设备锁屏功能
     */
    @ResponseBody
	@RequestMapping("/deviceLock")
    public MobileBean deviceLock(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                     String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                     String pemPath = request.getRealPath("mdmtool") + pemFile;
                     int pushState = PushUtils.singleMDMPush(pemPath, device);
                     if (pushState == 1) {
                         Command command = new Command();
                         command.setCommand(MdmUtils.Lock);
                         command.setDeviceId(deviceId);
                         command.setDoIt("0");
                         command.setCallBack(callBack);
                         commandService.saveOrUpdate(command);
                         bean.setStatus(HttpConst.HTTP_STATUS_200);
         			 	 bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
         				 bean.setData("发送设备锁屏命令成功!");
                     } else {
                         bean.setStatus(HttpConst.HTTP_STATUS_403);
              			 bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
              		     bean.setData("发送设备锁屏命令失败!");
                     }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 擦除设备数据功能
     */
    @ResponseBody
    @RequestMapping("/deviceErase")
    public MobileBean deviceErase(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                    String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                    String pemPath = request.getRealPath("mdmtool") + pemFile;
                    int pushState = PushUtils.singleMDMPush(pemPath, device);
                    if (pushState == 1) {
                        Command command = new Command();
                        command.setCommand(MdmUtils.Erase);
                        command.setDeviceId(deviceId);
                        command.setDoIt("0");
                        command.setCallBack(callBack);
                        commandService.saveOrUpdate(command);
                        bean.setStatus(HttpConst.HTTP_STATUS_200);
        			 	bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
        				bean.setData("发送擦除设备数据命令成功!");
                    } else {
                        bean.setStatus(HttpConst.HTTP_STATUS_403);
             			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
             		    bean.setData("发送擦除设备数据命令失败!");
                    }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 获取设备信息
     */
    @ResponseBody
    @RequestMapping("/getInfo")
    public MobileBean getInfo(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
    		String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
    		String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
	        /**检查参数是否完整**/
	        if(StringUtils.isNotEmpty(deviceId)){
	        	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
	            if(null==device){
	            	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
	            }else{
	                String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
	                String pemPath = request.getRealPath("mdmtool") + pemFile;
	                int pushState = PushUtils.singleMDMPush(pemPath, device);
	                if (pushState == 1) {
	                    Command command = new Command();
	                    command.setCommand(MdmUtils.Info);
	                    command.setDeviceId(deviceId);
	                    command.setDoIt("0");
	                    command.setCallBack(callBack);
	                    commandService.saveOrUpdate(command);
	                    bean.setStatus(HttpConst.HTTP_STATUS_200);
        			 	bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
        				bean.setData("发送查询设备信息命令成功!");
	                } else {
	                    bean.setStatus(HttpConst.HTTP_STATUS_403);
             			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
             		    bean.setData("发送查询设备信息命令失败!");
	                }
	            }
	        }else{
	        	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
	        }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 清除设备密码功能
     */
    @ResponseBody
    @RequestMapping("/clearPasscode")
    public MobileBean clearPasscode(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                     String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                     String pemPath = request.getRealPath("mdmtool") + pemFile;
                     int pushState = PushUtils.singleMDMPush(pemPath, device);
                     if (pushState == 1) {
                         Command command = new Command();
                         command.setCommand(MdmUtils.Clear);
                         command.setDeviceId(deviceId);
                         command.setDoIt("0");
                         command.setCallBack(callBack);
                         commandService.saveOrUpdate(command);
                         bean.setStatus(HttpConst.HTTP_STATUS_200);
         			 	 bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
         				 bean.setData("发送清除设备密码命令成功!");
                     } else {
                         bean.setStatus(HttpConst.HTTP_STATUS_403);
              			 bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
              			 bean.setData("发送清除设备密码命令失败!");
                     }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 获取设备已经安装的app信息
     */
    @ResponseBody
    @RequestMapping("/getApps")
    public MobileBean getApps(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                    String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                    String pemPath = request.getRealPath("mdmtool") + pemFile;
                    int pushState = PushUtils.singleMDMPush(pemPath, device);
                    if (pushState == 1) {
                        Command command = new Command();
                        command.setCommand(MdmUtils.Apps);
                        command.setDeviceId(deviceId);
                        command.setDoIt("0");
                        command.setCtype("All");
                        command.setCallBack(callBack);
                        commandService.saveOrUpdate(command);
                        bean.setStatus(HttpConst.HTTP_STATUS_200);
        				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
        				bean.setData("发送获取APP应用列表命令成功!");
                    } else {
                        bean.setStatus(HttpConst.HTTP_STATUS_403);
             			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
             			bean.setData("发送获取APP应用列表命令失败!");
                    }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 获取设备已经安装的可管控的app信息
     */
    @ResponseBody
    @RequestMapping("/getManagedApps")
    public MobileBean getManagedApps(HttpServletRequest request,HttpServletResponse response){
    	MobileBean bean = new MobileBean();
    	try{
            String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null==device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                    String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                    String pemPath = request.getRealPath("mdmtool") + pemFile;
                    int pushState = PushUtils.singleMDMPush(pemPath, device);
                    if (pushState == 1) {
                        Command command = new Command();
                        command.setCommand(MdmUtils.Apps);
                        command.setDeviceId(deviceId);
                        command.setDoIt("0");
                        command.setCtype("ManagedAppsOnly");
                        command.setCallBack(callBack);
                        commandService.saveOrUpdate(command);
                        bean.setStatus(HttpConst.HTTP_STATUS_200);
        				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
        				bean.setData("发送获取APP应用列表命令成功!");
                    } else {
                        bean.setStatus(HttpConst.HTTP_STATUS_403);
             			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
             			bean.setData("发送获取APP应用列表命令失败!");
                    }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 设备安装APP
     */
    @ResponseBody
    @RequestMapping("/installApp")
    public MobileBean installApp(HttpServletRequest request,HttpServletResponse response) {
    	MobileBean bean = new MobileBean();
    	try{
    		String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String ctype = request.getParameter("ctype")==null?"":request.getParameter("ctype").trim();
            String cvalue = request.getParameter("cvalue")==null?"":request.getParameter("cvalue").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            String newctype = InstallTypeEnum.getCode(ctype);
            /**检查参数是否完整**/
            if(StringUtils.isNotEmpty(deviceId) && StringUtils.isNotEmpty(newctype) && StringUtils.isNotEmpty(cvalue)){
                Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null == device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                    String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                    String pemPath = request.getRealPath("mdmtool") + pemFile;
                    int pushState = PushUtils.singleMDMPush(pemPath, device);
                    if (pushState == 1) {
                        Command command = new Command();
                        command.setCommand(MdmUtils.Install);
                        command.setDeviceId(deviceId);
                        command.setDoIt("0");
                        command.setCtype(ctype);
                        command.setCvalue(cvalue);
                        command.setCallBack(callBack);
                        commandService.saveOrUpdate(command);
                        bean.setStatus(HttpConst.HTTP_STATUS_200);
        				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
        				bean.setData("发送安装APP应用命令成功!");
                    } else {
                        bean.setStatus(HttpConst.HTTP_STATUS_403);
             			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
             			bean.setData("发送安装APP应用命令失败!");
                    }
                }
            }else{
            	bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /**
     * 设备卸载APP
     */
    @ResponseBody
    @RequestMapping("/removeApp")
    public MobileBean removeApp(HttpServletRequest request,HttpServletResponse response) {
    	MobileBean bean = new MobileBean();
    	try{
    		String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
            String identifier = request.getParameter("identifier")==null?"":request.getParameter("identifier").trim();
            String callBack = request.getParameter("callBack")==null?"":request.getParameter("callBack").trim();
            if(StringUtils.isNotEmpty(deviceId) && StringUtils.isNotEmpty(identifier)){
            	Device device = deviceService.getDeviceByHql("from Device where deviceId = ? ", deviceId);
                if(null == device){
                	bean.setStatus(HttpConst.HTTP_STATUS_403);
         			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
         			bean.setData("设备数据不存在!");
                }else{
                    String pemFile = ConfigUtils.getConfig("APNS_P12MDM");
                    String pemPath = request.getRealPath("mdmtool") + pemFile;
                    int pushState = PushUtils.singleMDMPush(pemPath, device);
                    if (pushState == 1) {
                        Command command = new Command();
                        command.setCommand(MdmUtils.Remove);
                        command.setDeviceId(deviceId);
                        command.setDoIt("0");
                        command.setCvalue(identifier);
                        command.setCallBack(callBack);
                        commandService.saveOrUpdate(command);
                        bean.setStatus(HttpConst.HTTP_STATUS_200);
        				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
        				bean.setData("发送卸载APP应用命令成功!");
                    } else {
                        bean.setStatus(HttpConst.HTTP_STATUS_403);
             			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
             			bean.setData("发送卸载APP应用命令失败!");
                    }
                }
            }else{
                bean.setStatus(HttpConst.HTTP_STATUS_403);
    			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
    			bean.setData("请求参数不完整!");
            }
    	}catch(Exception e){
    		e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
    	}
        return bean;
    }

    /********************************以下是获取设备本地数据*********************************/

    /**
	 * 获取消息日志详情
	 */
	@ResponseBody
	@RequestMapping("/getLogInfo")
	public MobileBean getLogInfo(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String id = request.getParameter("id")==null?"":request.getParameter("id");
			if(StringUtils.isNotEmpty(id)){
				Command command = commandService.getCommandById(id);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(command);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("id不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 删除消息日志
	 */
	@ResponseBody
	@RequestMapping("/deleteLog")
	public MobileBean deleteLog(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String id = request.getParameter("id")==null?"":request.getParameter("id");
			if(StringUtils.isNotEmpty(id)){
				commandService.deleteCommandById(id);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(null);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("id不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 分页获取命令日志列表
	 */
	@ResponseBody
	@RequestMapping("/getLogList")
	public MobileBean getLogList(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String hql = "from Command order by createTime desc";
			int pageIndex = request.getParameter("pageIndex")==null?1:Integer.parseInt(request.getParameter("pageIndex"));
			int pageSize = request.getParameter("pageSize")==null?10:Integer.parseInt(request.getParameter("pageSize"));
			List<Command> list = commandService.pageQuery(hql, pageIndex, pageSize);
			int count = commandService.getCount("select count(A.id) as number from Command A");
			int totalPageNum = (int) (count / pageSize);
			if (count % pageSize != 0) {
				totalPageNum++;
			}
			PageBean pageList = new PageBean(pageIndex,totalPageNum,count,list);
			bean.setStatus(HttpConst.HTTP_STATUS_200);
			bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
			bean.setData(pageList);
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 根据设备ID获取命令日志列表
	 */
	@ResponseBody
	@RequestMapping("/getLogListByDeviceId")
	public MobileBean getLogListByDeviceId(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String hql = "from Command where deviceId = ? order by createTime desc";
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId").trim();
			List<Command> list = commandService.getAllCommandByHql(hql, deviceId);
			bean.setStatus(HttpConst.HTTP_STATUS_200);
			bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
			bean.setData(list);
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 更改设备标签
	 */
	@ResponseBody
	@RequestMapping("/updateDeviceFlag")
	public MobileBean updateDeviceFlag(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId");
			String deviceFlag = request.getParameter("deviceFlag")==null?"":request.getParameter("deviceFlag");
			if(StringUtils.isNotEmpty(deviceId)){
				String hql = "from Device where deviceId = ?";
				Device device = deviceService.getDeviceByHql(hql, deviceId);
				device.setDeviceFlag(deviceFlag);
				deviceService.saveOrUpdate(device);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(null);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("deviceId或者deviceFlag不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
		return bean;

	}

	/**
	 * 设备移除
	 */
	@ResponseBody
	@RequestMapping("/removeDevice")
	public MobileBean removeDevice(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId");
			if(StringUtils.isNotEmpty(deviceId)){
				deviceService.deleteDeviceByDeviceId(deviceId);
				appsService.deleteAppsByDeviceId(deviceId);
				commandService.deleteCommandByDeviceId(deviceId);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(null);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("deviceId不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
		return bean;
	}

	/**
	 * 设备详情
	 */
	@ResponseBody
	@RequestMapping("/getDeviceInfo")
	public MobileBean getDeviceInfo(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId");
			if(StringUtils.isNotEmpty(deviceId)){
				Map<String,Object> values = new HashMap<String,Object>();
				String hql = "from Device where deviceId = ?";
				Device device = deviceService.getDeviceByHql(hql, deviceId);
				List<Apps> appList = appsService.getAppsListByHql("from Apps where deviceId = '"+deviceId+"' order by createTime desc");
				values.put("device", device);
				values.put("appList", appList);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(values);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("deviceId不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 分页获取设备数据列表
	 */
	@ResponseBody
	@RequestMapping("/getDeviceList")
	public MobileBean getDeviceList(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String hql = "from Device order by createTime desc";
			int pageIndex = request.getParameter("pageIndex")==null?1:Integer.parseInt(request.getParameter("pageIndex"));
			int pageSize = request.getParameter("pageSize")==null?10:Integer.parseInt(request.getParameter("pageSize"));
			List<Device> list = deviceService.pageQuery(hql, pageIndex, pageSize);
			int count = deviceService.getCount("select count(A.id) as number from Device A");
			int totalPageNum = (int) (count / pageSize);
			if (count % pageSize != 0) {
				totalPageNum++;
			}
			PageBean pageList = new PageBean(pageIndex,totalPageNum,count,list);
			bean.setStatus(HttpConst.HTTP_STATUS_200);
			bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
			bean.setData(pageList);
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 设备的ProfileList
	 */
	@ResponseBody
	@RequestMapping("/getDeviceProfileList")
	public MobileBean getDeviceProfileList(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId");
			if(StringUtils.isNotEmpty(deviceId)){
				String hql = "from Profile where deviceId = ? and ctype = ?";
				Profile profile = profileService.getProfileByHql(hql, deviceId , MdmUtils.ProfileList);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(profile);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("deviceId不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 设备的ProvisioningProfileList
	 */
	@ResponseBody
	@RequestMapping("/getDeviceProvisioningProfileList")
	public MobileBean getDeviceProvisioningProfileList(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId");
			if(StringUtils.isNotEmpty(deviceId)){
				String hql = "from Profile where deviceId = ? and ctype = ?";
				Profile profile = profileService.getProfileByHql(hql, deviceId , MdmUtils.ProvisioningProfileList);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(profile);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("deviceId不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

	/**
	 * 设备的CertificateList
	 */
	@ResponseBody
	@RequestMapping("/getDeviceCertificateList")
	public MobileBean getDeviceCertificateList(HttpServletRequest request,HttpServletResponse response){
		MobileBean bean = new MobileBean();
		try{
			String deviceId = request.getParameter("deviceId")==null?"":request.getParameter("deviceId");
			if(StringUtils.isNotEmpty(deviceId)){
				String hql = "from Profile where deviceId = ? and ctype = ?";
				Profile profile = profileService.getProfileByHql(hql, deviceId , MdmUtils.CertificateList);
				bean.setStatus(HttpConst.HTTP_STATUS_200);
				bean.setDesc(HttpConst.HTTP_STATUS_SUCCESS);
				bean.setData(profile);
			}else{
				bean.setStatus(HttpConst.HTTP_STATUS_403);
				bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
				bean.setData("deviceId不能为空");
			}
		}catch(Exception e){
			e.printStackTrace();
			bean.setStatus(HttpConst.HTTP_STATUS_403);
			bean.setDesc(HttpConst.HTTP_STATUS_FAILURE);
			bean.setData("出错了:"+e.getMessage());
		}
	    return bean;
	}

    /****************************************************************/
	public DeviceService getDeviceService() {
		return deviceService;
	}
	@Resource
	public void setDeviceService(DeviceService deviceService) {
		this.deviceService = deviceService;
	}

	public DeviceTempService getDeviceTempService() {
		return deviceTempService;
	}
	@Resource
	public void setDeviceTempService(DeviceTempService deviceTempService) {
		this.deviceTempService = deviceTempService;
	}

	public CommandService getCommandService() {
		return commandService;
	}
	@Resource
	public void setCommandService(CommandService commandService) {
		this.commandService = commandService;
	}
	public AppsService getAppsService() {
		return appsService;
	}
	@Resource
	public void setAppsService(AppsService appsService) {
		this.appsService = appsService;
	}
	public ProfileService getProfileService() {
		return profileService;
	}
	@Resource
	public void setProfileService(ProfileService profileService) {
		this.profileService = profileService;
	}

}