/// <summary> /// Constructor /// </summary> /// <param name="archivePath">Path of the archive directory</param> /// <param name="contentPath">Path of the source root directory being archived</param> /// <param name="readPreviousArchiveLog">If true, previous archive will be loaded (if found) and only changed files will be (re)archived</param> public Archive(string archivePath, string contentPath, bool readPreviousArchiveLog) { // Compose and set properties this.archivePath = FsService.FormatDirectoryPathString( Path.Join( archivePath, (contentPath.EndsWith("/") ? contentPath.Substring(0, contentPath.Length - 1) : contentPath).Replace(":", "").Replace(' ', '_').Replace('/', ' ') ) ); this.archiveName = String.Format( "{0} ({1:0000}-{2:00}-{3:00} {4:00}-{5:00}-{6:00})", DateTime.UtcNow.ToFileTimeUtc(), DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second ); string path = String.Format("{0}{1}", this.archivePath, this.archiveName); this.archiveFileFullPath = String.Format("{0}.zip", path); // Initialize logs (load previous log firs, or previous will equal current) if (readPreviousArchiveLog) { this.previousLog = ArchiveLog.GetLastArchiveLog(this.archivePath); if (this.previousLog != null) { this.previousLog.ReadAllEntries(); } } this.currentLog = new ArchiveLog(String.Format("{0}.log", path)); }
private void HandleInvoiceService(int invoiceID, string sfInvoiceID, enterprise.QueryResult result) { try { using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr)) { if (result == null || (result != null && result.size == 0)) { return; } IEnumerable <enterprise.Service_Cost__c> serviceList = result.records.Cast <enterprise.Service_Cost__c>(); var svc = new FsService(invoiceID, "Invoice"); List <string> services = new List <string>(); foreach (var sl in serviceList) { services.Add(sl.Id); long estServiceID = CommonMethods.GetMISID(TableName.Fw_Quote_Service, sl.Id, sfInvoiceID, salesForceProjectID); if (estServiceID == 0) { int printOrder = svc.GetQsMaxPrintOrder() + 1; svc.InsertRecord(Convert.ToInt32(sl.Service_Name__r.MIS_Service_Number__c), sl.Service_Cost__c1 == null ? "0" : sl.Service_Cost__c1.ToString(), 1, sl.Service_Detail__c == null ? "" : sl.Service_Detail__c, sl.Service_Name__r.Name, sl.Service_Cost__c1 == null ? "0" : sl.Service_Cost__c1.ToString(), printOrder ); int qs_id = SqlCommon.GetNewlyInsertedRecordID(TableName.Fw_Quote_Service); if (qs_id > 0) { CommonMethods.InsertToMISSalesForceMapping(TableName.Fw_Quote_Service, sl.Id, qs_id.ToString(), sfInvoiceID, salesForceProjectID); } } else { UpdateInvoiceService(estServiceID, sl.Service_Cost__c1, sl.Service_Detail__c, sl.Service_Name__r.Name, Convert.ToInt16(sl.Service_Name__r.MIS_Service_Number__c), sl.Note__c); } } DeleteAllDeletedInvoiceServices(services.ToArray(), sfInvoiceID); LogMethods.Log.Debug("HandleInvoiceService:Debug:" + "Done"); } } catch (Exception e) { LogMethods.Log.Error("HandleInvoiceService:Error:" + e.Message); } }
public ResponseBase AddSketchToAuction(Auction auction, Sketch sketch, Model.File WAVFile, Model.File MP3File) { var res = new ResponseBase(); sketch.CreateDate = DateTime.Now; res.Success = true; if (sketch.Artist == null && sketch.ArtistID != null) { sketch.Artist = _usersRep.GetByID(sketch.ArtistID)?.Artist; } if (res.Success && WAVFile != null) { WAVFile.UserId = sketch.Artist.Id; res = FsService.StoreFile(WAVFile); if (res.Success) { sketch.WAVFile = (res as EntityResponse <Model.File>).Entity; sketch.WAVFileID = sketch.WAVFile.FileId; } } if (res.Success && MP3File != null) { MP3File.UserId = sketch.Artist.Id; res = FsService.StoreFile(MP3File); if (res.Success) { sketch.MP3File = (res as EntityResponse <Model.File>).Entity; sketch.MP3FileID = sketch.MP3File.FileId; } } if (res.Success) { if (auction.Sketches == null) { auction.Sketches = new List <Sketch>(); } auction.Sketches.Add(sketch); return(_auctionSrv.Update(auction)); } return(res); }
private void DeleteServices() { var svc = new FsService(_myID, "Invoice"); svc.DeleteServices(); }
public ResponseBase Add(Music music, Model.File WAVFile, Model.File MP3File) { var res = new ResponseBase(); music.CreateDate = DateTime.Now; res.Success = true; if (music.Tags?.FirstOrDefault() != null) { var tgRes = TagService.GetAll(); res.Success = tgRes.Success; if (res.Success) { music.Tags = tgRes.Entities .Where(dbTag => music.Tags.Any(tag => tag.ID == dbTag.ID)) .ToList(); } else { res.Message = tgRes.Message; } } if (music.Artist?.User?.UserName != null) { music.Artist = _usersRep.GetArtistByName(music.Artist.User.UserName)?.Artist; if (music.Artist == null) { res.Success = false; res.Message = "לא נמצא אמן עם שם זה"; } } if (res.Success && WAVFile != null) { WAVFile.UserId = music.Artist.Id; res = FsService.StoreFile(WAVFile); if (res.Success) { music.WAVFile = (res as EntityResponse <Model.File>).Entity; music.WAVFileID = music.WAVFile.FileId; } } if (res.Success && MP3File != null) { MP3File.UserId = music.Artist.Id; res = FsService.StoreFile(MP3File); if (res.Success) { music.MP3File = (res as EntityResponse <Model.File>).Entity; music.MP3FileID = music.MP3File.FileId; } } if (res.Success) { if (music.MusicLength == TimeSpan.Zero) { res.Success = false; res.Message = "יש להזין אורך יצירה"; } } if (res.Success) { // update async artist report by updating his pdf file _pdfService.ArtistAddMusicAsync(DateTime.Now, music.HebrewName, music.MusicComposer, music.MusicPerformer, music.Exceptions, music.MusicWriter, music.Artist.Id, WebConf.FSBaseRoute); res = base.Add(music); } return(res); }
public ResponseBase Update(Music musicData, int musicId, Model.File WAVFile, Model.File MP3File) { ResponseBase res = this.GetByID(musicId); if (res.Success) { var dbMusic = (res as EntityResponse <Music>).Entity; dbMusic.UpdateDate = DateTime.Now; dbMusic.BPM = musicData.BPM; dbMusic.Comment = musicData.Comment; dbMusic.Copyrights = musicData.Copyrights; dbMusic.CostLevel = musicData.CostLevel; dbMusic.EnglishName = musicData.EnglishName; dbMusic.Exceptions = musicData.Exceptions; dbMusic.HebrewName = musicData.HebrewName; dbMusic.MusicComposer = musicData.MusicComposer; dbMusic.MusicLength = musicData.MusicLength; dbMusic.MusicPerformer = musicData.MusicPerformer; dbMusic.MusicWriter = musicData.MusicWriter; dbMusic.SongText = musicData.SongText; dbMusic.Status = musicData.Status; musicData.Tags = musicData.Tags ?? new List <Tag>(); var addTagList = musicData.Tags .Where(tg => !dbMusic.Tags.Any(dbTg => dbTg.ID == tg.ID)) ?.Select(tg => tg.ID); if (addTagList != null && addTagList.Any()) { res = TagService.GetTagList(addTagList); if (res.Success) { dbMusic.Tags.AddRange((res as EntityAllResponse <Tag>).Entities); } } if (res.Success) { dbMusic.Tags.RemoveAll(tg => !musicData.Tags.Any(x => x.ID == tg.ID)); if (WAVFile != null) { res = FsService.StoreFile(WAVFile); if (res.Success) { if (dbMusic.WAVFile != null) { dbMusic.WAVFile.version = (res as EntityResponse <Model.File>).Entity.version; } else { dbMusic.WAVFile = (res as EntityResponse <Model.File>).Entity; dbMusic.WAVFileID = dbMusic.WAVFile.FileId; } } } } if (res.Success && MP3File != null) { res = FsService.StoreFile(MP3File); if (res.Success) { if (dbMusic.MP3File != null) { dbMusic.MP3File.version = (res as EntityResponse <Model.File>).Entity.version; } else { dbMusic.MP3File = (res as EntityResponse <Model.File>).Entity; dbMusic.MP3FileID = dbMusic.MP3File.FileId; } } } if (res.Success) { res = base.Update(dbMusic); } } return(res); }
public override void DeleteServices() { var svc = new FsService(_myID, "Quote"); svc.DeleteServices(); }