-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Hornburger
committed
Mar 22, 2024
1 parent
f4f47ad
commit d5a8a61
Showing
8 changed files
with
380 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import {Document, DocumentQuery, model, Model} from "mongoose"; | ||
import {DebugClass} from "../debug"; | ||
import {Constclass} from "../constclass"; | ||
import * as mongoose from "mongoose"; | ||
import {ITeamsfilesstruktur, Teamsfileshema} from "../datenstrukturen/teamsfilesstruktur_server"; | ||
import {Projektpunktshema} from "../datenstrukturen/projektpunktestruktur_server"; | ||
|
||
export class FilesDBClass { | ||
|
||
private Debug: DebugClass; | ||
private Const: Constclass; | ||
|
||
constructor() { | ||
|
||
this.Debug = new DebugClass(); | ||
this.Const = new Constclass(); | ||
} | ||
|
||
public RemoveTeamsfile(teamsfile: ITeamsfilesstruktur) { | ||
|
||
try { | ||
|
||
let FilesmodelClass: mongoose.Model<mongoose.Document>; | ||
|
||
return new Promise((resolve, reject) => { | ||
|
||
FilesmodelClass = model(this.Const.FilescollectionName, Teamsfileshema); | ||
|
||
FilesmodelClass.deleteOne({_id: teamsfile._id} ).then(() => { | ||
|
||
resolve(true); | ||
|
||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
|
||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'FilesDBClass', 'RemoveTeamsfile'); | ||
} | ||
|
||
} | ||
|
||
public ReadFilesliste(projektkey: string, filetype: string): Promise<any> { | ||
|
||
try { | ||
|
||
let FilesmodelClass: mongoose.Model<mongoose.Document>; | ||
let Liste: ITeamsfilesstruktur[] = []; | ||
let Filter: any; | ||
|
||
if(filetype === 'Any') { | ||
|
||
Filter = { Projektkey: projektkey }; | ||
} | ||
else { | ||
|
||
Filter = { Filetyp: filetype }; | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
|
||
FilesmodelClass = model(this.Const.FilescollectionName, Teamsfileshema); | ||
|
||
FilesmodelClass.find(Filter).then((data: any) => { | ||
|
||
data.forEach((teamsfile) => { | ||
|
||
Liste.push(teamsfile._doc); | ||
}); | ||
|
||
resolve(Liste); | ||
|
||
console.log(''); | ||
|
||
}).catch((error: any) => { | ||
|
||
reject(error); | ||
}); | ||
|
||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'FilesDBClass', 'ReadFileliste'); | ||
} | ||
} | ||
|
||
public AddFiles(data: ITeamsfilesstruktur):Promise<any> { | ||
|
||
try { | ||
|
||
let Filesmodel: mongoose.Document; | ||
|
||
return new Promise<any>((resolve, reject) => { | ||
|
||
delete data._id; | ||
|
||
Filesmodel = this.GetFilesModel(data); | ||
|
||
Filesmodel.save().then((result: Document<any>) => { | ||
|
||
resolve(result); | ||
|
||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'FilesDBClass', 'AddFile'); | ||
} | ||
} | ||
|
||
public UpdateFiles(data: ITeamsfilesstruktur):Promise<any> { | ||
|
||
try { | ||
|
||
let FilesmodelClass: mongoose.Model<mongoose.Document>; | ||
|
||
return new Promise<any>((resolve, reject) => { | ||
|
||
FilesmodelClass = model(this.Const.FilescollectionName, Teamsfileshema); | ||
|
||
FilesmodelClass.findById(data._id).then((standort: mongoose.Document) => { | ||
|
||
if(standort) { | ||
|
||
standort.set(data); | ||
standort.save().then((result: Document) => { | ||
|
||
resolve(result); | ||
|
||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
} | ||
else { | ||
|
||
resolve(null); | ||
} | ||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'FilesDBClass', 'UpdateFile'); | ||
} | ||
} | ||
|
||
public GetFilesModel(data: ITeamsfilesstruktur): mongoose.Document { | ||
|
||
try { | ||
|
||
const FilesmodelClass = model(this.Const.FilescollectionName, Teamsfileshema); | ||
const Filesmodel: mongoose.Document = new FilesmodelClass(data); | ||
|
||
return Filesmodel; | ||
} | ||
catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'FilesDBClass', 'GetStandortModel'); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/datenstrukturen/aufgabenpersonenfilterstruktur_server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import mongoose from "mongoose"; | ||
|
||
interface IAufgabenpersonenfilterstruktur { | ||
|
||
Projektkey: string; | ||
PersonenlisteID: string[]; | ||
}; | ||
|
||
const Aufgabenpersonenfiltershema = new mongoose.Schema({ | ||
|
||
Projektkey: {type: String, required: false}, | ||
PersonenlisteID: {type: [String], required: false}, | ||
|
||
}, {_id: false}); | ||
|
||
export { IAufgabenpersonenfilterstruktur, Aufgabenpersonenfiltershema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {IVerfasserstruktur, Verfassershema} from "./verfasserstruktur_server"; | ||
import mongoose from "mongoose"; | ||
|
||
|
||
interface ITeamsfilesstruktur { | ||
|
||
_id: string; | ||
id: string; | ||
name: string; | ||
webUrl: string; | ||
size: number; | ||
ProjektID: string; | ||
Projektkey: string; | ||
ProjektpunktID: string; | ||
Filetyp: string; | ||
Leistungsphase: string; | ||
Zeitstempel: number; | ||
Zeitsting: string; | ||
MimeType: string; | ||
DirectoryID: string; | ||
Beschreibung: string; | ||
Verfasser: IVerfasserstruktur; | ||
}; | ||
|
||
const Teamsfileshema = new mongoose.Schema({ | ||
|
||
id: {type: String, required: false}, | ||
name: {type: String, required: false}, | ||
webUrl: {type: String, required: false}, | ||
size: {type: Number, required: false}, | ||
ProjektID: {type: String, required: false}, | ||
Projektkey: {type: String, required: false}, | ||
ProjektpunktID: {type: String, required: false}, | ||
Filetyp: {type: String, required: false}, | ||
Leistungsphase: {type: String, required: false}, | ||
Zeitstempel: {type: Number, required: false}, | ||
Zeitsting: {type: String, required: false}, | ||
MimeType: {type: String, required: false}, | ||
DirectoryID: {type: String, required: false}, | ||
Beschreibung: {type: String, required: false}, | ||
Verfasser: Verfassershema | ||
}); | ||
|
||
export { ITeamsfilesstruktur, Teamsfileshema }; | ||
|
||
|
||
|
||
|
Oops, something went wrong.