示例#1
0
        private Intervention GetIntervention(Intervention request)
        {
            var          id    = request?.Id;
            Intervention ret   = null;
            var          query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetVisibleFields <Intervention>(currentUser, "Intervention", request.VisibleFields);

            DocEntityIntervention entity = null;

            if (id.HasValue)
            {
                entity = DocEntityIntervention.GetIntervention(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No Intervention found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
示例#2
0
        private ReconcileDocument GetReconcileDocument(ReconcileDocument request)
        {
            var id = request?.Id;
            ReconcileDocument ret = null;
            var query             = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <ReconcileDocument>(currentUser, "ReconcileDocument", request.Select);

            DocEntityReconcileDocument entity = null;

            if (id.HasValue)
            {
                entity = DocEntityReconcileDocument.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No ReconcileDocument found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
        private LookupTableBinding GetLookupTableBinding(LookupTableBinding request)
        {
            var id = request?.Id;
            LookupTableBinding ret = null;
            var query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <LookupTableBinding>(currentUser, "LookupTableBinding", request.Select);

            DocEntityLookupTableBinding entity = null;

            if (id.HasValue)
            {
                entity = DocEntityLookupTableBinding.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No LookupTableBinding found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
示例#4
0
        public Favorite Post(FavoriteCopy request)
        {
            Favorite ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityFavorite.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pScope = entity.Scope;
                    var copy   = new DocEntityFavorite(ssn)
                    {
                        Hash    = Guid.NewGuid()
                        , Scope = pScope
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#5
0
        private UnitConversionRules GetUnitConversionRules(UnitConversionRules request)
        {
            var id = request?.Id;
            UnitConversionRules ret = null;
            var query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <UnitConversionRules>(currentUser, "UnitConversionRules", request.Select);

            DocEntityUnitConversionRules entity = null;

            if (id.HasValue)
            {
                entity = DocEntityUnitConversionRules.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No UnitConversionRules found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
示例#6
0
        public AuditDelta Post(AuditDeltaCopy request)
        {
            AuditDelta ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityAuditDelta.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pAudit = entity.Audit;
                    var pDelta = entity.Delta;
                    var copy   = new DocEntityAuditDelta(ssn)
                    {
                        Hash    = Guid.NewGuid()
                        , Audit = pAudit
                        , Delta = pDelta
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#7
0
        private TimeCard GetTimeCard(TimeCard request)
        {
            var      id    = request?.Id;
            TimeCard ret   = null;
            var      query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <TimeCard>(currentUser, "TimeCard", request.Select);

            DocEntityTimeCard entity = null;

            if (id.HasValue)
            {
                entity = DocEntityTimeCard.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No TimeCard found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
示例#8
0
        public TimeCard Post(TimeCard request)
        {
            if (request == null)
            {
                throw new HttpError(HttpStatusCode.NotFound, "Request cannot be null.");
            }

            request.Select = request.Select ?? new List <string>();

            TimeCard ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    if (!DocPermissionFactory.HasPermissionTryAdd(currentUser, "TimeCard"))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    ret = _AssignValues(request, DocConstantPermission.ADD, ssn);
                });
            }
            return(ret);
        }
示例#9
0
        public void Delete(Intervention request)
        {
            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    if (!(request?.Id > 0))
                    {
                        throw new HttpError(HttpStatusCode.NotFound, $"No Id provided for delete.");
                    }

                    var en = DocEntityIntervention.GetIntervention(request?.Id);
                    if (null == en)
                    {
                        throw new HttpError(HttpStatusCode.NotFound, $"No Intervention could be found for Id {request?.Id}.");
                    }
                    if (en.IsRemoved)
                    {
                        return;
                    }

                    if (!DocPermissionFactory.HasPermission(en, currentUser, DocConstantPermission.DELETE))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have DELETE permission for this route.");
                    }

                    en.Remove();

                    DocCacheClient.RemoveSearch(DocConstantModelName.INTERVENTION);
                    DocCacheClient.RemoveById(request.Id);
                });
            }
        }
示例#10
0
        public Intervention Post(Intervention request)
        {
            if (request == null)
            {
                throw new HttpError(HttpStatusCode.NotFound, "Request cannot be null.");
            }

            request.VisibleFields = request.VisibleFields ?? new List <string>();

            Intervention ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    if (!DocPermissionFactory.HasPermissionTryAdd(currentUser, "Intervention"))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    ret = _AssignValues(request, DocConstantPermission.ADD, ssn);
                });
            }
            return(ret);
        }
示例#11
0
        private AttributeInterval GetAttributeInterval(AttributeInterval request)
        {
            var id = request?.Id;
            AttributeInterval ret = null;
            var query             = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <AttributeInterval>(currentUser, "AttributeInterval", request.Select);

            DocEntityAttributeInterval entity = null;

            if (id.HasValue)
            {
                entity = DocEntityAttributeInterval.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No AttributeInterval found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
示例#12
0
        public VariableRule Post(VariableRuleCopy request)
        {
            VariableRule ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityVariableRule.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pChildren   = entity.Children.ToList();
                    var pDefinition = entity.Definition;
                    var pInstances  = entity.Instances.ToList();
                    var pName       = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pOwner  = entity.Owner;
                    var pRule   = entity.Rule;
                    var pScopes = entity.Scopes.ToList();
                    var pType   = entity.Type;
                    var copy    = new DocEntityVariableRule(ssn)
                    {
                        Hash         = Guid.NewGuid()
                        , Definition = pDefinition
                        , Name       = pName
                        , Owner      = pOwner
                        , Rule       = pRule
                        , Type       = pType
                    };
                    foreach (var item in pChildren)
                    {
                        entity.Children.Add(item);
                    }

                    foreach (var item in pInstances)
                    {
                        entity.Instances.Add(item);
                    }

                    foreach (var item in pScopes)
                    {
                        entity.Scopes.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#13
0
        private BackgroundTaskItem GetBackgroundTaskItem(BackgroundTaskItem request)
        {
            var id = request?.Id;
            BackgroundTaskItem ret = null;
            var query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <BackgroundTaskItem>(currentUser, "BackgroundTaskItem", request.Select);

            DocEntityBackgroundTaskItem entity = null;

            if (id.HasValue)
            {
                entity = DocEntityBackgroundTaskItem.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No BackgroundTaskItem found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
示例#14
0
        public File Post(FileCopy request)
        {
            File ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityFile.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pCost      = entity.Cost;
                    var pFileLabel = entity.FileLabel;
                    if (!DocTools.IsNullOrEmpty(pFileLabel))
                    {
                        pFileLabel += " (Copy)";
                    }
                    var pFileName = entity.FileName;
                    if (!DocTools.IsNullOrEmpty(pFileName))
                    {
                        pFileName += " (Copy)";
                    }
                    var pOriginalFileName = entity.OriginalFileName;
                    if (!DocTools.IsNullOrEmpty(pOriginalFileName))
                    {
                        pOriginalFileName += " (Copy)";
                    }
                    var pRights = entity.Rights;
                    var pScopes = entity.Scopes.ToList();
                    var pSource = entity.Source;
                    var pType   = entity.Type;
                    var copy    = new DocEntityFile(ssn)
                    {
                        Hash               = Guid.NewGuid()
                        , Cost             = pCost
                        , FileLabel        = pFileLabel
                        , FileName         = pFileName
                        , OriginalFileName = pOriginalFileName
                        , Rights           = pRights
                        , Source           = pSource
                        , Type             = pType
                    };
                    foreach (var item in pScopes)
                    {
                        entity.Scopes.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#15
0
        public Junction Post(JunctionCopy request)
        {
            Junction ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityJunction.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pChildren  = entity.Children.ToList();
                    var pData      = entity.Data;
                    var pOwnerId   = entity.OwnerId;
                    var pOwnerType = entity.OwnerType;
                    if (!DocTools.IsNullOrEmpty(pOwnerType))
                    {
                        pOwnerType += " (Copy)";
                    }
                    var pParent     = entity.Parent;
                    var pTargetId   = entity.TargetId;
                    var pTargetType = entity.TargetType;
                    if (!DocTools.IsNullOrEmpty(pTargetType))
                    {
                        pTargetType += " (Copy)";
                    }
                    var pType = entity.Type;
                    var pUser = entity.User;
                    var copy  = new DocEntityJunction(ssn)
                    {
                        Hash         = Guid.NewGuid()
                        , Data       = pData
                        , OwnerId    = pOwnerId
                        , OwnerType  = pOwnerType
                        , Parent     = pParent
                        , TargetId   = pTargetId
                        , TargetType = pTargetType
                        , Type       = pType
                        , User       = pUser
                    };
                    foreach (var item in pChildren)
                    {
                        entity.Children.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#16
0
        public Broadcast Post(BroadcastCopy request)
        {
            Broadcast ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityBroadcast.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pApp          = entity.App;
                    var pConfluenceId = entity.ConfluenceId;
                    if (!DocTools.IsNullOrEmpty(pConfluenceId))
                    {
                        pConfluenceId += " (Copy)";
                    }
                    var pName = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pReprocess   = entity.Reprocess;
                    var pReprocessed = entity.Reprocessed;
                    var pScopes      = entity.Scopes.ToList();
                    var pStatus      = entity.Status;
                    var pType        = entity.Type;
                    var copy         = new DocEntityBroadcast(ssn)
                    {
                        Hash           = Guid.NewGuid()
                        , App          = pApp
                        , ConfluenceId = pConfluenceId
                        , Name         = pName
                        , Reprocess    = pReprocess
                        , Reprocessed  = pReprocessed
                        , Status       = pStatus
                        , Type         = pType
                    };
                    foreach (var item in pScopes)
                    {
                        entity.Scopes.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#17
0
        public LookupTable Post(LookupTableCopy request)
        {
            LookupTable ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityLookupTable.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pBindings   = entity.Bindings.ToList();
                    var pCategories = entity.Categories.ToList();
                    var pDocuments  = entity.Documents.ToList();
                    var pEnum       = entity.Enum;
                    var pName       = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var copy = new DocEntityLookupTable(ssn)
                    {
                        Hash   = Guid.NewGuid()
                        , Enum = pEnum
                        , Name = pName
                    };
                    foreach (var item in pBindings)
                    {
                        entity.Bindings.Add(item);
                    }

                    foreach (var item in pCategories)
                    {
                        entity.Categories.Add(item);
                    }

                    foreach (var item in pDocuments)
                    {
                        entity.Documents.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#18
0
        public Division Post(DivisionCopy request)
        {
            Division ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityDivision.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pClient        = entity.Client;
                    var pDefaultLocale = entity.DefaultLocale;
                    var pDocumentSets  = entity.DocumentSets.ToList();
                    var pName          = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pRole     = entity.Role;
                    var pSettings = entity.Settings;
                    var pUsers    = entity.Users.ToList();
                    var copy      = new DocEntityDivision(ssn)
                    {
                        Hash            = Guid.NewGuid()
                        , Client        = pClient
                        , DefaultLocale = pDefaultLocale
                        , Name          = pName
                        , Role          = pRole
                        , Settings      = pSettings
                    };
                    foreach (var item in pDocumentSets)
                    {
                        entity.DocumentSets.Add(item);
                    }

                    foreach (var item in pUsers)
                    {
                        entity.Users.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#19
0
        public WorkflowTask Post(WorkflowTaskCopy request)
        {
            WorkflowTask ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityWorkflowTask.GetWorkflowTask(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pAssignee    = entity.Assignee;
                    var pData        = entity.Data;
                    var pDescription = entity.Description;
                    if (!DocTools.IsNullOrEmpty(pDescription))
                    {
                        pDescription += " (Copy)";
                    }
                    var pDueDate  = entity.DueDate;
                    var pReporter = entity.Reporter;
                    var pStatus   = entity.Status;
                    var pType     = entity.Type;
                    var pWorkflow = entity.Workflow;
                    #region Custom Before copyWorkflowTask
                    #endregion Custom Before copyWorkflowTask
                    var copy = new DocEntityWorkflowTask(ssn)
                    {
                        Hash          = Guid.NewGuid()
                        , Assignee    = pAssignee
                        , Data        = pData
                        , Description = pDescription
                        , DueDate     = pDueDate
                        , Reporter    = pReporter
                        , Status      = pStatus
                        , Type        = pType
                        , Workflow    = pWorkflow
                    };

                    #region Custom After copyWorkflowTask
                    #endregion Custom After copyWorkflowTask
                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#20
0
        public Rating Post(RatingCopy request)
        {
            Rating ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityRating.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pAssignee    = entity.Assignee;
                    var pData        = entity.Data;
                    var pDescription = entity.Description;
                    if (!DocTools.IsNullOrEmpty(pDescription))
                    {
                        pDescription += " (Copy)";
                    }
                    var pDocument       = entity.Document;
                    var pDueDate        = entity.DueDate;
                    var pRating         = entity.Rating;
                    var pReasonRejected = entity.ReasonRejected;
                    var pReporter       = entity.Reporter;
                    var pType           = entity.Type;
                    var pWorkflow       = entity.Workflow;
                    var copy            = new DocEntityRating(ssn)
                    {
                        Hash             = Guid.NewGuid()
                        , Assignee       = pAssignee
                        , Data           = pData
                        , Description    = pDescription
                        , Document       = pDocument
                        , DueDate        = pDueDate
                        , Rating         = pRating
                        , ReasonRejected = pReasonRejected
                        , Reporter       = pReporter
                        , Type           = pType
                        , Workflow       = pWorkflow
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
        public LookupTableBinding Post(LookupTableBindingCopy request)
        {
            LookupTableBinding ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityLookupTableBinding.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pBinding   = entity.Binding;
                    var pBoundName = entity.BoundName;
                    if (!DocTools.IsNullOrEmpty(pBoundName))
                    {
                        pBoundName += " (Copy)";
                    }
                    var pLookupTable = entity.LookupTable;
                    var pScope       = entity.Scope;
                    var pSynonyms    = entity.Synonyms.ToList();
                    var pWorkflows   = entity.Workflows.ToList();
                    var copy         = new DocEntityLookupTableBinding(ssn)
                    {
                        Hash          = Guid.NewGuid()
                        , Binding     = pBinding
                        , BoundName   = pBoundName
                        , LookupTable = pLookupTable
                        , Scope       = pScope
                    };
                    foreach (var item in pSynonyms)
                    {
                        entity.Synonyms.Add(item);
                    }

                    foreach (var item in pWorkflows)
                    {
                        entity.Workflows.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#22
0
        public TimeCard Post(TimeCardCopy request)
        {
            TimeCard ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityTimeCard.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pDescription = entity.Description;
                    if (!DocTools.IsNullOrEmpty(pDescription))
                    {
                        pDescription += " (Copy)";
                    }
                    var pDocument    = entity.Document;
                    var pEnd         = entity.End;
                    var pProject     = entity.Project;
                    var pReferenceId = entity.ReferenceId;
                    var pStart       = entity.Start;
                    var pStatus      = entity.Status;
                    var pUser        = entity.User;
                    var pWorkType    = entity.WorkType;
                    var copy         = new DocEntityTimeCard(ssn)
                    {
                        Hash          = Guid.NewGuid()
                        , Description = pDescription
                        , Document    = pDocument
                        , End         = pEnd
                        , Project     = pProject
                        , ReferenceId = pReferenceId
                        , Start       = pStart
                        , Status      = pStatus
                        , User        = pUser
                        , WorkType    = pWorkType
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#23
0
        public QueueChannel Post(QueueChannelCopy request)
        {
            QueueChannel ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityQueueChannel.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pAutoDelete     = entity.AutoDelete;
                    var pBackgroundTask = entity.BackgroundTask;
                    var pDescription    = entity.Description;
                    if (!DocTools.IsNullOrEmpty(pDescription))
                    {
                        pDescription += " (Copy)";
                    }
                    var pDurable   = entity.Durable;
                    var pEnabled   = entity.Enabled;
                    var pExclusive = entity.Exclusive;
                    var pName      = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var copy = new DocEntityQueueChannel(ssn)
                    {
                        Hash             = Guid.NewGuid()
                        , AutoDelete     = pAutoDelete
                        , BackgroundTask = pBackgroundTask
                        , Description    = pDescription
                        , Durable        = pDurable
                        , Enabled        = pEnabled
                        , Exclusive      = pExclusive
                        , Name           = pName
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#24
0
        public Intervention Post(InterventionCopy request)
        {
            Intervention ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityIntervention.GetIntervention(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pDocumentSets = entity.DocumentSets.ToList();
                    var pName         = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pURI = entity.URI;
                    if (!DocTools.IsNullOrEmpty(pURI))
                    {
                        pURI += " (Copy)";
                    }
                    #region Custom Before copyIntervention
                    #endregion Custom Before copyIntervention
                    var copy = new DocEntityIntervention(ssn)
                    {
                        Hash   = Guid.NewGuid()
                        , Name = pName
                        , URI  = pURI
                    };
                    foreach (var item in pDocumentSets)
                    {
                        entity.DocumentSets.Add(item);
                    }

                    #region Custom After copyIntervention
                    #endregion Custom After copyIntervention
                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#25
0
        public History Post(HistoryCopy request)
        {
            History ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityHistory.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pApp           = entity.App;
                    var pDocumentSet   = entity.DocumentSet;
                    var pImpersonation = entity.Impersonation;
                    var pPage          = entity.Page;
                    var pURL           = entity.URL;
                    if (!DocTools.IsNullOrEmpty(pURL))
                    {
                        pURL += " (Copy)";
                    }
                    var pUser        = entity.User;
                    var pUserSession = entity.UserSession;
                    var pWorkflow    = entity.Workflow;
                    var copy         = new DocEntityHistory(ssn)
                    {
                        Hash            = Guid.NewGuid()
                        , App           = pApp
                        , DocumentSet   = pDocumentSet
                        , Impersonation = pImpersonation
                        , Page          = pPage
                        , URL           = pURL
                        , User          = pUser
                        , UserSession   = pUserSession
                        , Workflow      = pWorkflow
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#26
0
        public Attribute Post(AttributeCopy request)
        {
            Attribute ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityAttribute.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pAttributeName    = entity.AttributeName;
                    var pAttributeType    = entity.AttributeType;
                    var pInterval         = entity.Interval;
                    var pIsCharacteristic = entity.IsCharacteristic;
                    var pIsOutcome        = entity.IsOutcome;
                    var pIsPositive       = entity.IsPositive;
                    var pUniqueKey        = entity.UniqueKey;
                    if (!DocTools.IsNullOrEmpty(pUniqueKey))
                    {
                        pUniqueKey += " (Copy)";
                    }
                    var pValueType = entity.ValueType;
                    var copy       = new DocEntityAttribute(ssn)
                    {
                        Hash               = Guid.NewGuid()
                        , AttributeName    = pAttributeName
                        , AttributeType    = pAttributeType
                        , Interval         = pInterval
                        , IsCharacteristic = pIsCharacteristic
                        , IsOutcome        = pIsOutcome
                        , IsPositive       = pIsPositive
                        , UniqueKey        = pUniqueKey
                        , ValueType        = pValueType
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#27
0
        public TermSynonym Post(TermSynonymCopy request)
        {
            TermSynonym ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityTermSynonym.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pApproved  = entity.Approved;
                    var pBindings  = entity.Bindings.ToList();
                    var pMaster    = entity.Master;
                    var pPreferred = entity.Preferred;
                    var pScope     = entity.Scope;
                    var pSynonym   = entity.Synonym;
                    if (!DocTools.IsNullOrEmpty(pSynonym))
                    {
                        pSynonym += " (Copy)";
                    }
                    var copy = new DocEntityTermSynonym(ssn)
                    {
                        Hash        = Guid.NewGuid()
                        , Approved  = pApproved
                        , Master    = pMaster
                        , Preferred = pPreferred
                        , Scope     = pScope
                        , Synonym   = pSynonym
                    };
                    foreach (var item in pBindings)
                    {
                        entity.Bindings.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#28
0
        public Locale Post(LocaleCopy request)
        {
            Locale ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityLocale.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pCountry = entity.Country;
                    if (!DocTools.IsNullOrEmpty(pCountry))
                    {
                        pCountry += " (Copy)";
                    }
                    var pLanguage = entity.Language;
                    if (!DocTools.IsNullOrEmpty(pLanguage))
                    {
                        pLanguage += " (Copy)";
                    }
                    var pTimeZone = entity.TimeZone;
                    if (!DocTools.IsNullOrEmpty(pTimeZone))
                    {
                        pTimeZone += " (Copy)";
                    }
                    var copy = new DocEntityLocale(ssn)
                    {
                        Hash       = Guid.NewGuid()
                        , Country  = pCountry
                        , Language = pLanguage
                        , TimeZone = pTimeZone
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#29
0
        public WorkflowComment Post(WorkflowCommentCopy request)
        {
            WorkflowComment ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityWorkflowComment.GetWorkflowComment(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pChildren = entity.Children.ToList();
                    var pParent   = entity.Parent;
                    var pText     = entity.Text;
                    var pUser     = entity.User;
                    var pWorkflow = entity.Workflow;
                    #region Custom Before copyWorkflowComment
                    #endregion Custom Before copyWorkflowComment
                    var copy = new DocEntityWorkflowComment(ssn)
                    {
                        Hash       = Guid.NewGuid()
                        , Parent   = pParent
                        , Text     = pText
                        , User     = pUser
                        , Workflow = pWorkflow
                    };
                    foreach (var item in pChildren)
                    {
                        entity.Children.Add(item);
                    }

                    #region Custom After copyWorkflowComment
                    #endregion Custom After copyWorkflowComment
                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }
示例#30
0
        public UnitConversionRules Post(UnitConversionRulesCopy request)
        {
            UnitConversionRules ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityUnitConversionRules.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pDestinationUnit = entity.DestinationUnit;
                    var pIsDefault       = entity.IsDefault;
                    var pIsDestinationSi = entity.IsDestinationSi;
                    var pModifierTerm    = entity.ModifierTerm;
                    var pMultiplier      = entity.Multiplier;
                    var pParent          = entity.Parent;
                    var pRootTerm        = entity.RootTerm;
                    var pSourceUnit      = entity.SourceUnit;
                    var copy             = new DocEntityUnitConversionRules(ssn)
                    {
                        Hash = Guid.NewGuid()
                        , DestinationUnit = pDestinationUnit
                        , IsDefault       = pIsDefault
                        , IsDestinationSi = pIsDestinationSi
                        , ModifierTerm    = pModifierTerm
                        , Multiplier      = pMultiplier
                        , Parent          = pParent
                        , RootTerm        = pRootTerm
                        , SourceUnit      = pSourceUnit
                    };

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }