public override ResultOperation SaveValues(DataModel _DataModel, Dictionary <string, DataModel> allSavedEntities = null)
        {
            if (this.ThreadID.HasValue)
            {
                ThreadVariableService threadVariableService = new ThreadVariableService(this.UnitOfWork);
                sysBpmsThreadVariable _ThreadVariable       = threadVariableService.GetInfo(this.ThreadID.Value, this.Variable.ID);
                if (_ThreadVariable == null)
                {
                    _ThreadVariable = new sysBpmsThreadVariable()
                    {
                        ThreadID   = this.ThreadID.Value,
                        VariableID = this.Variable.ID,
                        Value      = this.Variable.VarTypeLU == (int)sysBpmsVariable.e_VarTypeLU.DateTime && _DataModel[this.Variable.Name] != null?
                                     Convert.ToDateTime(_DataModel[this.Variable.Name]).ToString(new CultureInfo("en-US")) : _DataModel[this.Variable.Name].ToStringObj(),
                    };
                    return(threadVariableService.Add(_ThreadVariable));
                }
                else
                {
                    _ThreadVariable.ThreadID   = this.ThreadID.Value;
                    _ThreadVariable.VariableID = this.Variable.ID;
                    _ThreadVariable.Value      = this.Variable.VarTypeLU == (int)sysBpmsVariable.e_VarTypeLU.DateTime && _DataModel[this.Variable.Name] != null?
                                                 Convert.ToDateTime(_DataModel[this.Variable.Name]).ToString(new CultureInfo("en-US")) : _DataModel[this.Variable.Name].ToStringObj();

                    return(threadVariableService.Update(_ThreadVariable));
                }
            }
            else
            {
                return(new ResultOperation());
            }
        }
        public List <DataModel> GetResult( )
        {
            List <DataModel> _DataModel = new List <DataModel>();

            switch ((sysBpmsVariable.e_VarTypeLU)Variable.VarTypeLU)
            {
            case sysBpmsVariable.e_VarTypeLU.List:
                foreach (var item in Variable.Items)
                {
                    DataModel _Data = new DataModel();
                    _Data[nameof(item.Key)]  = item.Key;
                    _Data[nameof(item.Text)] = item.Text;
                    _DataModel.Add(_Data);
                }
                break;

            case sysBpmsVariable.e_VarTypeLU.Integer:
            case sysBpmsVariable.e_VarTypeLU.String:
            case sysBpmsVariable.e_VarTypeLU.Decimal:
            case sysBpmsVariable.e_VarTypeLU.Boolean:
            case sysBpmsVariable.e_VarTypeLU.Uniqueidentifier:
            {
                if (this.ThreadID.HasValue)
                {
                    DataModel             _Data           = new DataModel();
                    sysBpmsThreadVariable _ThreadVariable = new ThreadVariableService(this.UnitOfWork).GetInfo(this.ThreadID.Value, this.Variable.ID);
                    _Data[this.Variable.Name] = _ThreadVariable != null ? _ThreadVariable.Value : null;
                    _DataModel.Add(_Data);
                }
            }
            break;

            case sysBpmsVariable.e_VarTypeLU.DateTime:
            {
                if (this.ThreadID.HasValue)
                {
                    DataModel             _Data           = new DataModel();
                    sysBpmsThreadVariable _ThreadVariable = new ThreadVariableService(this.UnitOfWork).GetInfo(this.ThreadID.Value, this.Variable.ID);
                    _Data[this.Variable.Name] = !string.IsNullOrWhiteSpace(_ThreadVariable?.Value) ? Convert.ToDateTime(_ThreadVariable.Value, new CultureInfo("en-US")) : ((DateTime?)null);
                    _DataModel.Add(_Data);
                }
            }
            break;
            }
            return(_DataModel);
        }
        public ResultOperation Delete(Guid threadId)
        {
            ResultOperation resultOperation = new ResultOperation();

            try
            {
                this.BeginTransaction();

                //Delete sysBpmsDocument
                DocumentService documentService = new DocumentService(base.UnitOfWork);
                foreach (sysBpmsDocument document in documentService.GetList(null, null, null, "", null, null, threadId))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = documentService.Delete(document.GUID);
                    }
                }

                //Delete sysBpmsThreadVariable
                ThreadVariableService threadVariableService = new ThreadVariableService(base.UnitOfWork);
                foreach (sysBpmsThreadVariable sysThreadVariable in threadVariableService.GetList(threadId, null, ""))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = threadVariableService.Delete(sysThreadVariable.ID);
                    }
                }

                //Delete sysBpmsThreadEvent
                ThreadEventService threadEventService = new ThreadEventService(base.UnitOfWork);
                foreach (sysBpmsThreadEvent sysBpmsThreadEvent in threadEventService.GetList(threadId))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = threadEventService.Delete(sysBpmsThreadEvent.ID);
                    }
                }

                //Delete sysBpmsThreadTask
                ThreadTaskService threadTaskService = new ThreadTaskService(base.UnitOfWork);
                foreach (sysBpmsThreadTask sysBpmsThreadTask in threadTaskService.GetList(threadId, null, null, null))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = threadTaskService.Delete(sysBpmsThreadTask.ID);
                    }
                }

                //Delete Thread
                if (resultOperation.IsSuccess)
                {
                    this.UnitOfWork.Repository <IThreadRepository>().Delete(threadId);
                    this.UnitOfWork.Save();
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);
            return(resultOperation);
        }