Пример #1
0
    public static GetSupportingFilesResponse GetSupportingFiles(string pid)
    {
        APIWrapper api = null;

        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
        {
            api = new APIWrapper(Membership.GetUser().UserName, null);
        }
        else
        {
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);
        }

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");
        if (md == null)
        {
            return(new GetSupportingFilesResponse(false));
        }

        PermissionsManager prm = new PermissionsManager();

        MembershipUser user = Membership.GetUser();

        ModelPermissionLevel Permission = prm.GetPermissionLevel(user != null ? user.UserName:vwarDAL.DefaultUsers.Anonymous[0], pid);

        prm.Dispose();

        GetSupportingFilesResponse response = new GetSupportingFilesResponse(true);

        response.DownloadAllowed = Permission >= ModelPermissionLevel.Fetchable;
        response.EditAllowed     = Permission >= ModelPermissionLevel.Editable;
        response.files           = new vwarDAL.SupportingFile[md.SupportingFiles.Count];
        for (int i = 0; i < md.SupportingFiles.Count; i++)
        {
            response.files[i] = new vwarDAL.SupportingFile(md.SupportingFiles[i].Filename, md.SupportingFiles[i].Description, "");
        }
        return(response);
    }
Пример #2
0
    public static GetSupportingFilesResponse GetSupportingFiles(string pid)
    {
        APIWrapper api = null;
        if (Membership.GetUser() != null && Membership.GetUser().IsApproved)
            api = new APIWrapper(Membership.GetUser().UserName, null);
        else
            api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null);

        vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00");
        if (md == null)
        {
            return new GetSupportingFilesResponse(false);
        }

        PermissionsManager prm = new PermissionsManager();

        MembershipUser user = Membership.GetUser();

        ModelPermissionLevel Permission = prm.GetPermissionLevel(user != null ? user.UserName:vwarDAL.DefaultUsers.Anonymous[0], pid);
        prm.Dispose();

        GetSupportingFilesResponse response = new GetSupportingFilesResponse(true);
        response.DownloadAllowed = Permission >= ModelPermissionLevel.Fetchable;
        response.EditAllowed = Permission >= ModelPermissionLevel.Editable;
        response.files = new vwarDAL.SupportingFile[md.SupportingFiles.Count];
        for(int i=0; i<md.SupportingFiles.Count; i++)
        {
            response.files[i] = new vwarDAL.SupportingFile(md.SupportingFiles[i].Filename, md.SupportingFiles[i].Description, "");
        }
        return response;
    }