コード例 #1
0
        public DocumentServiceWrapper(DocumentService documentService)
        {
            _documentService = documentService;
            _documentServiceType = documentService.GetType();

            _getDefaultParentMethod = new Lazy<MethodInfo>(() => _documentServiceType.GetMethod("GetDefaultParent", BindingFlags.Static | BindingFlags.NonPublic));
        }
コード例 #2
0
 public TfsQueryShortcutOpener(DocumentService documentService,
                               IVisualStudioAdapter visualStudioAdapter, TfsQueryShortcutStore store)
 {
     this.documentService = documentService;
     this.visualStudioAdapter = visualStudioAdapter;
     this.store = store;
 }
 private int CreateFolder(DocumentService docSrv, string folderpath)
 {
     String[] foldernames;
     char[] delimiterChars = { '/' };
     foldernames = folderpath.Split('/');
     String thisPath = "";
     Folder filefolder;
     Folder thisfolder;
     thisfolder = docSrv.GetFolderRoot();
     foreach (String foldername in foldernames)
     {
         if (foldername == "$")
         {
             thisfolder = docSrv.GetFolderRoot();
             thisPath = "$";
         }
         else
         {
             thisPath += "/";
             thisPath += foldername;
             try
             {
                 filefolder = docSrv.GetFolderByPath(thisPath);
             }
             catch
             {
                 //Console.WriteLine("Creating folder " + thisPath);
                 filefolder = docSrv.AddFolder(foldername, thisfolder.Id, thisfolder.IsLib);
             }
             thisfolder = filefolder;
         }
     }
     return 0;
 }
コード例 #4
0
ファイル: DocumentsApp.cs プロジェクト: Mehul/DXDocumentsMVC
 public virtual void Initialize()
 {
     Data = new DXDocsMVC.Code.EntityDataService(this);
         FileSystem = new FileSystemService(this);
         Document = new DocumentService(this);
         User = new UserService(this);
         Image = new ImageService(this);
 }
コード例 #5
0
ファイル: WebApiTest.cs プロジェクト: Anthaax/Archi-Vite
 public WebApiTest()
 {
     _professionalService = new ProfessionalService();
     _patientService = new PatientService();
     _userService = new UserService();
     _documentService = new DocumentService();
     _followerService = new FollowerService();
 }
コード例 #6
0
        void DocumentAdded(object sender, DocumentService.DocumentServiceEventArgs e)
        {
            var queryResultsDocument = e.Document as IResultsDocument;

            if ((queryResultsDocument != null) && (queryResultsDocument.QueryDocument == null))
            {
                DocumentCreated(this, new QueryResultsDocumentCreatedEventArgs(queryResultsDocument));
            }
        }
        private List<string> GetFolderStructure(DocumentService docSrv, string folderpath)
        {
            List<string> foldernames;
            Folder filefolder;
            Folder thisfolder;
            thisfolder = docSrv.GetFolderRoot();
            filefolder = docSrv.GetFolderByPath(folderpath);

            foldernames = GetFoldersInFolder(filefolder, docSrv);
            return foldernames;
        }
コード例 #8
0
        public QueryResultsTotalizerController(DocumentService docService, StatusBar statusBar, IVisualStudioAdapter teamExplorer)
        {
            var documentCreationTracker = new QueryResultsDocumentCreationObserver(docService);

            documentCreationTracker.DocumentCreated += (sender, e) =>
            {
                var queryResultsModel = new QueryResultsTotalizerModel(teamExplorer);

                new QueryResultsDocumentSelectionObserver(e.QueryResultsDocument, queryResultsModel);

                new QueryResultsTotalizerView(queryResultsModel, statusBar);
            };
        }
コード例 #9
0
        public ActionResult Create(CommitteeResolutionViewModel model)
        {
            try
            {
                var file = model.attachment;
                if (file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var guid = Guid.NewGuid();
                    var path = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/Uploads/" + guid.ToString() + Path.GetExtension(file.FileName);
                    file.SaveAs(path);

                    using (var unitOfWork = new UnitOfWork(new BankModuleFactory()))
                    {
                        var DocumentService = new DocumentService(unitOfWork);
                        var document = new Document()
                        {
                            DocumentType = BusinessEntities.DocumentTypes.Other,
                            Link = "Uploads/" + guid.ToString() + Path.GetExtension(file.FileName),
                        };
                        model.ProtocolDocument = DocumentService.Add(document);
                        unitOfWork.Commit();
                        model.ProtocolDocumentId = model.ProtocolDocument.Id;
                    }
                }

                if (!ModelState.IsValid)
                {
                    return View(model);
                }

                var result = _controleHelper.CreateEntity<CommitteeResolution, CommitteeResolutionViewModel>(model);
                if (result.Error.Any())
                {
                    ModelState.AddModelError(string.Empty, result.Error.First().ErrorMessage);
                    return View(model);
                }
                return RedirectToAction("Details", new { id = result.Entity.LoanApplicationId });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return View(model);
            }
        }
        private List<string> GetFoldersInFolder(Folder parentFolder, DocumentService docSvc)
		{
            List<string> foldernames = new List<string>();
            List<string> newfoldernames;
            Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false);
			if (folders != null && folders.Length > 0)
			{
				foreach (Folder folder in folders)
				{
                    foldernames.Add(folder.FullName);
                    newfoldernames = GetFoldersInFolder(folder, docSvc);
                    foreach (string newfolder in newfoldernames )
                    {
                        foldernames.Add(newfolder);
                    }
				}
			}
            return foldernames;
		}
コード例 #11
0
ファイル: Tests_DocumentService.cs プロジェクト: naishan/SDDB
        public void DocumentService_GetAsync_DoeNotReturnDocumentsFromWrongProject()
        {
            //Arrange
            var mockDbContextScopeFac = new Mock<IDbContextScopeFactory>();
            var mockDbContextScope = new Mock<IDbContextReadOnlyScope>();
            var mockEfDbContext = new Mock<EFDbContext>();
            mockDbContextScopeFac.Setup(x => x.CreateReadOnly(DbContextScopeOption.JoinExisting)).Returns(mockDbContextScope.Object);
            mockDbContextScope.Setup(x => x.DbContexts.Get<EFDbContext>()).Returns(mockEfDbContext.Object);

            var projectPerson1 = new Person { Id = "dummyUserId1", FirstName = "Firs1", LastName = "Last1" };
            var projectPerson2 = new Person { Id = "dummyUserId2", FirstName = "Firs2", LastName = "Last2" };

            var project1 = new Project { Id = "dummyId1", ProjectName = "Project1", ProjectAltName = "ProjectAlt1", IsActive_bl = true, ProjectCode = "CODE1", 
                ProjectPersons = new List<Person> { projectPerson1 } };
            var project2 = new Project { Id = "dummyId2", ProjectName = "Project2", ProjectAltName = "ProjectAlt2", IsActive_bl = false, ProjectCode = "CODE2", 
                ProjectPersons = new List<Person> { projectPerson2 } };

            var dbEntry1 = new Document { Id = "dummyEntryId1", DocName = "Doc1", DocAltName = "DocAlt1", IsActive_bl = false, Comments = "DummyComments1",
                DocFilePath = "DummyPath1", AssignedToProject = project1 };
            var dbEntry2 = new Document { Id = "dummyEntryId2", DocName = "Doc2", DocAltName = "DocAlt2", IsActive_bl = true, Comments = "DummyComments2",
                DocFilePath = "DummyPath2", AssignedToProject = project2 };
            var dbEntries = (new List<Document> { dbEntry1, dbEntry2 }).AsQueryable();

            var mockDbSet = new Mock<DbSet<Document>>();
            mockDbSet.As<IDbAsyncEnumerable<Document>>().Setup(m => m.GetAsyncEnumerator()).Returns(new MockDbAsyncEnumerator<Document>(dbEntries.GetEnumerator())); 
            mockDbSet.As<IQueryable<Document>>().Setup(m => m.Provider).Returns(new MockDbAsyncQueryProvider<Document>(dbEntries.Provider));
            mockDbSet.As<IQueryable<Document>>().Setup(m => m.Expression).Returns(dbEntries.Expression);
            mockDbSet.As<IQueryable<Document>>().Setup(m => m.ElementType).Returns(dbEntries.ElementType);
            mockDbSet.As<IQueryable<Document>>().Setup(m => m.GetEnumerator()).Returns(dbEntries.GetEnumerator());
            mockDbSet.Setup(x => x.Include(It.IsAny<string>())).Returns(mockDbSet.Object);
            
            mockEfDbContext.Setup(x => x.Documents).Returns(mockDbSet.Object);

            var docService = new DocumentService(mockDbContextScopeFac.Object, projectPerson1.Id);

            //Act
            var resultDocuments = docService.GetAsync(new[] { dbEntry1.Id, dbEntry2.Id }).Result;
            
            //Assert
            Assert.IsTrue(resultDocuments.Count == 0);
        }
コード例 #12
0
        public void RunCommand(string server, string vault, string username, string password, double size)
        {
            SecurityService secSrv = new SecurityService();
            secSrv.SecurityHeaderValue = new VaultFileSize.Security.SecurityHeader();
            secSrv.Url = "http://" + server + "/AutodeskDM/Services/SecurityService.asmx";

            try 
            {
                secSrv.SignIn(username, password, vault);
                DocumentService docSrv = new DocumentService();
                docSrv.SecurityHeaderValue = new VaultFileSize.Document.SecurityHeader();
                docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId;
                docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket;
                docSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentService.asmx";
                Folder root = docSrv.GetFolderRoot();
                PrintFilesInFolder(root, docSrv, size);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.ToString());
                return;
            }
        }
コード例 #13
0
        /// <summary>
        ///     This is the overridden DoAtomicWork() method.
        /// </summary>
        /// <param name="task">A task to be performed.</param>
        /// <param name="jobParameters">Input settings / parameters of the job.</param>
        /// <returns>Status of the operation.</returns>
        protected override bool DoAtomicWork(GlobalReplaceTaskBEO task, GlobalReplaceJobBEO jobParameters)
        {
            bool   isSuccess = false;
            string taskKey   = string.Empty;

            try
            {
                LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), false,
                           LogCategory.Job, null);
                LogMessage(string.Format(Constants.DoAtomicWorkStartMessage, task.TaskNumber), GetType(),
                           Constants.DoAtomicWorkNamespace, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);

                var documentQueryEntity = new DocumentQueryEntity
                {
                    DocumentCount      = task.PageSize,
                    DocumentStartIndex = task.PageNumber * task.PageSize,
                    QueryObject        = task.SearchQueryObject
                };
                documentQueryEntity.IgnoreDocumentSnippet = true;
                documentQueryEntity.TransactionName       = "FindAndReplaceJob - DoAtomicWork";
                ReviewerSearchResults reviewerSearchResults = JobSearchHandler.GetSearchResults(documentQueryEntity);

                LogMessage(string.Format(Constants.SearchDoneForTask, task.TaskNumber), false, LogCategory.Job,
                           null);
                LogMessage(string.Format(Constants.SearchDoneForTask, task.TaskNumber), GetType(),
                           Constants.DoAtomicWorkNamespace, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);

                if (reviewerSearchResults.ResultDocuments != null && reviewerSearchResults.ResultDocuments.Count > 0)
                {
                    foreach (DocumentResult document in reviewerSearchResults.ResultDocuments)
                    {
                        List <RVWDocumentFieldBEO> documentFieldBeoList = GetFieldValuesToUpdate
                                                                              (document, task.ActualString, task.ReplaceString, jobParameters.JobScheduleCreatedBy);
                        if (documentFieldBeoList != null && documentFieldBeoList.Count > 0)
                        {
                            var documentData = new RVWDocumentBEO
                            {
                                MatterId     = document.MatterID,
                                CollectionId = document.CollectionID
                            };
                            taskKey = Constants.CollectionId + document.CollectionID;
                            documentData.DocumentId = document.DocumentID;
                            taskKey += Constants.DocumentId + document.DocumentID;
                            documentData.ModifiedBy   = jobParameters.JobScheduleCreatedBy;
                            documentData.ModifiedDate = DateTime.UtcNow;
                            documentFieldBeoList.SafeForEach(x => documentData.FieldList.Add(x));

                            _mIsFindTextExist = true;
                            //Update the field value information in vault for the appropriate fields matching
                            isSuccess =
                                DocumentService.UpdateDocumentFields(
                                    document.MatterID.ToString(CultureInfo.InvariantCulture), document.CollectionID,
                                    document.DocumentID, documentData);
                            if (!isSuccess)
                            {
                                break;
                            }
                        }
                    }
                }

                CustomNotificationMessage = !_mIsFindTextExist
                    ? string.Format(Constants.SearchTextNotFound, task.ActualString)
                    : string.Format(Constants.SearchTextFound, _mOccurrences);

                LogMessage(string.Format(Constants.DoAtomicWorkCompletedMessage, task.TaskNumber), false,
                           LogCategory.Job, null);
                LogMessage(string.Format(Constants.DoAtomicWorkCompletedMessage, task.TaskNumber), GetType(),
                           Constants.DoAtomicWorkNamespace, EventLogEntryType.Information, jobParameters.JobId,
                           jobParameters.JobRunId);
            }
            catch (EVException ex)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + Constants.DoAtomicWorkFailMessage,
                                 ex.ToUserString() + Constants.TaskNumber + task.TaskNumber, EventLogEntryType.Error);
                LogException(jobParameters.JobId, ex, string.Empty, LogCategory.Task, taskKey,
                             ErrorCodes.ProblemInDoAtomicWork);
            }
            catch (Exception exp)
            {
                EvLog.WriteEntry(Constants.JOB_NAME + Constants.DoAtomicWorkFailMessage,
                                 exp.Message + Constants.TaskNumber + task.TaskNumber, EventLogEntryType.Error);
                LogException(jobParameters.JobId, exp, string.Empty, LogCategory.Task, taskKey,
                             ErrorCodes.ProblemInDoAtomicWork);
            }
            return(isSuccess);
        }
コード例 #14
0
        private void ProcessFilesInFolder(Folder parentFolder, DocumentService docSvc, string rootfolder, Boolean exportdwfs, string property, string propertyvalue, long propid)
        {
            VaultSyncReleased.Document.File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
            if (files != null && files.Length > 0)
            {
                foreach (VaultSyncReleased.Document.File file in files)
                {
                    Boolean matchesprop = false;
                    Console.WriteLine("Checking: " + parentFolder.FullName + "/" + file.Name);
                    Document.PropInst[] fileProperties = docSvc.GetProperties(new long[] { file.Id }, new long[] { propid });
                    if (fileProperties[0].Val != null)
                    {
                        //Console.WriteLine(" Property: " + property + " - " + fileProperties[0].Val.ToString());
                        if (fileProperties[0].Val.ToString() == propertyvalue)
                        {
                            matchesprop = true;
                        }
                    }
                    string outputfile = rootfolder + parentFolder.FullName.Substring(1) + "/" + file.Name;
                    outputfile = outputfile.Replace("/", "\\");
                    if (matchesprop)
                    {
                        int vernum = file.VerNum;
                        VaultSyncReleased.Document.File verFile = docSvc.GetFileByVersion(file.MasterId, vernum);
                        for (int counter = 0; counter < outputfile.Length; counter++)
                        {
                            if (outputfile.Substring(counter, 1) == "\\")
                            {
                                try
                                {
                                    System.IO.Directory.CreateDirectory(outputfile.Substring(0, counter));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.ToString());
                                    Console.WriteLine(outputfile.Substring(0, counter));
                                }
                            }
                        }

                        try
                        {
                            if (System.IO.File.Exists(outputfile))
                            {
                                FileInfo fi = new FileInfo(outputfile);
                                if ((verFile.ModDate == fi.LastWriteTime) && (verFile.FileSize == fi.Length))
                                {
                                    Console.WriteLine("File is uptodate: " + outputfile);
                                }
                                else
                                {
                                    Console.WriteLine("Saving: " + outputfile);
                                    System.IO.File.Delete(outputfile); 
                                    DownloadFileInParts(verFile, docSvc, outputfile);
                                    FileInfo finew = new FileInfo(outputfile);
                                    finew.LastWriteTime = verFile.ModDate;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Saving: " + outputfile);
                                System.IO.File.Delete(outputfile); 
                                DownloadFileInParts(verFile, docSvc, outputfile);
                                FileInfo finew = new FileInfo(outputfile);
                                finew.LastWriteTime = verFile.ModDate;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("ERROR: Saving " + outputfile);
                            Console.WriteLine(ex.Message.ToString());
                        }
                        Console.WriteLine("");
                        //Console.ReadLine();
                    }
                    else
                    {
                        if (System.IO.File.Exists(outputfile))
                        {
                            try
                            {
                                Console.WriteLine("Deleting: " + outputfile);
                                System.IO.File.Delete(outputfile);
                            }
                            catch
                            {
                                Console.WriteLine("ERROR: Deleting " + outputfile);
                            }
                        }
                        Console.WriteLine("");
                    }
                }
            }

            Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false);
            if (folders != null && folders.Length > 0)
            {
                foreach (Folder folder in folders)
                {
                    ProcessFilesInFolder(folder, docSvc, rootfolder, exportdwfs, property, propertyvalue, propid);
                }
            }
        }
コード例 #15
0
        public void RunCommand(string server, string vault, string username, string password, string rootfolder, Boolean exportdwfs, string property, string propertyvalue)
        {
            long propertyid = 0;
            SecurityService secSrv = new SecurityService();
            secSrv.SecurityHeaderValue = new VaultSyncReleased.Security.SecurityHeader();
            secSrv.Url = "http://" + server + "/AutodeskDM/Services/SecurityService.asmx";

            try 
            {
                secSrv.SignIn(username, password, vault);
                DocumentService docSrv = new DocumentService();
                docSrv.SecurityHeaderValue = new VaultSyncReleased.Document.SecurityHeader();
                docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId;
                docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket;
                docSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentService.asmx";
                Folder root = docSrv.GetFolderRoot();
                //root = docSrv.GetFolderByPath("$/Designs/Designs/C690 T3");
                //root = docSrv.GetFolderByPath("$/Amendment");
                Document.PropDef[] defs = docSrv.GetAllPropertyDefinitions();
                foreach (Document.PropDef pd in defs)
                {
                    if (pd.DispName.ToString().ToLower() == property.ToLower())
                    {
                        propertyid = pd.Id;
                    }
                }
                if ((property != "") && (propertyid == 0))
                {
                    Console.WriteLine("Error: Property notdefined in Vault [" + property + "]");
                    Console.WriteLine("Properties that ARE defined in Vault [" + vault + "]:");
                    foreach (Document.PropDef pd in defs)
                    {
                        Console.WriteLine("  " + pd.DispName.ToString());
                    }
                }
                else
                {
                    ProcessFilesInFolder(root, docSrv, rootfolder, exportdwfs, property, propertyvalue, propertyid);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.ToString());
                return;
            }
        }
コード例 #16
0
 protected void Spreadsheet_Init(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Spreadsheet.ReadOnly = DocumentService.CurrentDocumentReadOnly;
         string        currentDocumentId = DocumentService.GetDocumentIdForEditor(CurrentDocument);
         IDocumentInfo openedDocument    = DocumentManager.FindDocument(currentDocumentId);
         if (openedDocument == null)
         {
             if (CurrentDocument.Content == null)
             {
                 Spreadsheet.New();
                 Spreadsheet.DocumentId  = currentDocumentId;
                 CurrentDocument.Content = DocumentsApp.Data.CreateBinaryContent(Spreadsheet.SaveCopy(DocumentService.GetSpreadsheetDocumentFormat(CurrentDocument)));
                 DocumentsApp.Data.SaveChanges();
             }
             else
             {
                 Spreadsheet.Open(
                     currentDocumentId,
                     DocumentService.CurrentSpreadsheetDocumentFormat,
                     () => CurrentDocument.Content.Data);
             }
         }
         else
         {
             Spreadsheet.Open((SpreadsheetDocumentInfo)openedDocument);
         }
     }
 }
コード例 #17
0
ファイル: DocumentServiceTests.cs プロジェクト: neozhu/MrCMS
 public DocumentServiceTests()
 {
     _documentService = new DocumentService(Session, CurrentSite);
 }
コード例 #18
0
 public HomeController(DMContext context)
 {
     documentService = new DocumentService(context);
     categoryService = new CategoryService(context);
 }
コード例 #19
0
        public IActionResult Recommend(string id, [FromBody] PrcRecommendationRequest request, bool isStrict = false)
        {
            if (request == null)
            {
                return(new StatusCodeResult(StatusCodes.Status400BadRequest));
            }
            // If Id is Alias, translate to Id
            if (GlobalStore.ServiceAliases.IsExist(id))
            {
                id = GlobalStore.ServiceAliases.Get(id);
            }

            if (!GlobalStore.ActivatedPrcs.IsExist(id))
            {
                return(new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest, string.Format(ServiceResources.ServiceNotExistsOrNotActivated, ServiceTypeEnum.Prc)));
            }

            if (!string.IsNullOrEmpty(request.TagId) && !GlobalStore.ActivatedPrcs.Get(id).PrcsSettings.Tags.Any(t => t.Id == request.TagId))
            {
                return(new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest, ServiceResources.TheGivenTagIsMissingFromThePRCService));
            }


            var globalStoreDataSet = GlobalStore.DataSets.Get(GlobalStore.ActivatedPrcs.Get(id).PrcsSettings.DataSetName);
            var dataSet            = globalStoreDataSet.DataSet;
            var analyzeQuery       = queryFactory.GetAnalyzeQuery(dataSet.Name);

            var tokens = analyzeQuery.Analyze(request.Text, 1).ToList();
            var text   = string.Join(" ", tokens);

            //tagId meghatározása
            var tagId = string.Empty;

            if (!string.IsNullOrEmpty(request.TagId))
            {
                tagId = request.TagId;
            }
            else
            {
                //ha nincs megadva tagId akkor kiszámoljuk a prc scorer-ekkel
                var allResults = new List <KeyValuePair <string, double> >();
                foreach (var scorerKvp in GlobalStore.ActivatedPrcs.Get(id).PrcScorers)
                {
                    var score = scorerKvp.Value.GetScore(text, 1.7, true);
                    allResults.Add(new KeyValuePair <string, double>(scorerKvp.Key, score));
                }
                var resultsList = allResults.Where(r => r.Value > 0).OrderByDescending(r => r.Value).ToList();
                if (resultsList.Count == 0)
                {
                    return(new OkObjectResult(new List <PrcRecommendationResult>()));
                }
                tagId = resultsList.First().Key;
            }

            var globalStoreDestinationDataSet = GlobalStore.DataSets.Get(GlobalStore.ActivatedPrcs.Get(id).PrcsSettings.DestinationDataSetName);
            var destinationDataSet            = globalStoreDestinationDataSet.DataSet;

            var tagsToTest = new List <string>();

            if (request.Filter?.TagIdList?.Any() == true)
            {
                /*var existingTags = GlobalStore.ActivatedPrcs.Get(id).PrcsSettings.Tags.Select(t => t.Id).Intersect(request.Filter.TagIdList).ToList();
                 * if (existingTags.Count < request.Filter.TagIdList.Count)
                 * {
                 *  var missingTagIds = request.Filter.TagIdList.Except(existingTags).ToList();
                 *  return new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest,
                 *      string.Format(ServiceResources.TheFollowingTagIdsNotExistInTheDataSet_0, string.Join(", ", missingTagIds)));
                 * }*/
                // TODO validate with the destination dataset tags
                tagsToTest = request.Filter.TagIdList;
            }

            var globalSubset = GlobalStore.ActivatedPrcs.Get(id).PrcSubsets[tagId];

            if (globalSubset.WordsWithOccurences == null)
            {
                return(new HttpStatusCodeWithErrorResult(StatusCodes.Status406NotAcceptable, ServiceResources.TheGivenTagHasNoWordsInDictionary));
            }

            var wordsInDic = globalSubset.WordsWithOccurences.Keys.Intersect(tokens).ToList();

            var baseSubset = new Cerebellum.Subset
            {
                AllWordsOccurencesSumInCorpus = globalSubset.AllWordsOccurencesSumInCorpus,
                AllWordsOccurencesSumInTag    = globalSubset.AllWordsOccurencesSumInTag,
                WordsWithOccurences           = wordsInDic.ToDictionary(w => w, w => globalSubset.WordsWithOccurences[w])
            };
            var baseDic = new Cerebellum.Dictionary.TwisterAlgorithm(baseSubset, true, false).GetDictionary();

            if (isStrict)
            {
                var avg = baseDic.Sum(d => d.Value) / baseDic.Count;
                baseDic.Where(d => d.Value < avg).ToList().ForEach(d => baseDic.Remove(d.Key));
            }

            var globalScorer = GlobalStore.ActivatedPrcs.Get(id).PrcScorers[tagId];
            var baseScorer   = new Cerebellum.Scorer.PeSScorer(new Dictionary <int, Dictionary <string, double> > {
                { 1, baseDic }
            });

            var baseScore   = baseScorer.GetScore(text, 1.7);
            var globalScore = globalScorer.GetScore(text, 1.7);

            var results = new List <PrcRecommendationResult>();

            if (baseScore == 0 || globalScore == 0)
            {
                return(new OkObjectResult(results));
            }

            var filterQuery = request.Filter?.Query?.Trim();
            var query       = string.IsNullOrEmpty(filterQuery) ? string.Empty : $"({filterQuery}) AND ";

            // '+ 1' because we give score between 0 and 1 but in elasticsearch that means negative boost
            query = string.Format("{0}({1})", query, string.Join(" ", baseDic.Select(k => $"{k.Key}^{k.Value + 1}")));

            string shouldQuery = null;

            // weighting
            if (request.Weights?.Any() == true)
            {
                shouldQuery = string.Join(" ", request.Weights.Select(k => $"({k.Query})^{k.Value}"));
            }

            var fieldsForRecommendation = GlobalStore.ActivatedPrcs.Get(id).PrcsSettings.FieldsForRecommendation;

            Func <string, bool> isAttachmentField = (field) => globalStoreDestinationDataSet.AttachmentFields.Any(attachmentField =>
                                                                                                                  string.Equals(attachmentField, field, StringComparison.OrdinalIgnoreCase));

            var fieldList = fieldsForRecommendation
                            .Select(field => isAttachmentField(field) ? $"{field}.content" : field)
                            .Select(DocumentQuery.MapDocumentObjectName)
                            .ToList();

            var documentQuery    = queryFactory.GetDocumentQuery(destinationDataSet.Name);
            var documentElastics = new List <DocumentElastic>();
            var scrollResult     = documentQuery
                                   .Filter(query,
                                           tagsToTest,
                                           destinationDataSet.TagField,
                                           request.Count,
                                           null, false,
                                           fieldsForRecommendation,
                                           globalStoreDestinationDataSet.DocumentFields,
                                           DocumentService.GetFieldFilter(globalStoreDestinationDataSet, new List <string> {
                request.NeedDocumentInResult ? "*" : globalStoreDestinationDataSet.DataSet.IdField
            }),
                                           null, null, null,
                                           shouldQuery);

            documentElastics.AddRange(scrollResult.Items);

            var docIdsWithScore = new ConcurrentDictionary <string, double>(new Dictionary <string, double>());
            var wordQuery       = queryFactory.GetWordQuery(destinationDataSet.Name);

            Parallel.ForEach(documentElastics, parallelService.ParallelOptions(), docElastic =>
            {
                var wwo = wordQuery.GetWordsWithOccurences(new List <string> {
                    docElastic.Id
                }, fieldList, 1);
                var actualCleanedText = string.Join(" ", wwo.Select(w => string.Join(" ", Enumerable.Repeat(w.Key, w.Value.Tag))));

                var actualBaseScore = baseScorer.GetScore(actualCleanedText, 1.7);
                if (actualBaseScore == 0)
                {
                    return;
                }

                var actualGlobalScore = globalScorer.GetScore(actualCleanedText, 1.7);
                if (actualGlobalScore == 0)
                {
                    return;
                }

                var finalScore = (actualBaseScore / baseScore) / (actualGlobalScore / globalScore);
                docIdsWithScore.TryAdd(docElastic.Id, finalScore);
            });

            var resultDic = docIdsWithScore.OrderByDescending(rd => rd.Value).ToList();

            if (request.Count != 0 && resultDic.Count > request.Count)
            {
                resultDic = resultDic.Take(request.Count).ToList();
            }

            var docsDic = request.NeedDocumentInResult
                ? resultDic.Select(r => documentElastics.First(d => d.Id == r.Key)).ToDictionary(d => d.Id, d => d)
                : null;

            return(new OkObjectResult(resultDic.Select(kvp => new PrcRecommendationResult
            {
                DocumentId = kvp.Key,
                Score = kvp.Value,
                Document = request.NeedDocumentInResult ? docsDic[kvp.Key].DocumentObject : null
            })));
        }
コード例 #20
0
        private void Save()
        {
            Auction      = AuctionPrimaryDataVM.Auction;
            Auction.Date = DatesRegulationVM.Order.Auction.Date;

            if (Auction.Id == 0)
            {
                if (string.IsNullOrEmpty(Auction.Number))
                {
                    MessagesService.Show("Сохранение аукциона", "Аукцион не может быть сохранен, так как не имеет номера");
                    return;
                }

                Auction.OwnerId      = 1;
                Auction.signStatusId = 1;

                try {
                    Auction.RegulationId = DatesRegulationVM.CreateRegulation();
                } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка при сохранении дат"); return; }

                try {
                    Auction.FilesListId = DocumentService.CreateFilesList("Файлы аукциона №" + Auction.Number);
                } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка во время занесения данных аукциона"); return; }

                try {
                    Auction.Id = AuctionService.CreateAuction(Auction);
                } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка при сохранении аукциона"); return; }

                if (OrderDetailsVM.Order.id != 0)
                {
                    // Update order
                }
                else
                {
                    // Create order
                    order.customerid = Auction.CustomerId;
                    order.auctionId  = Auction.Id;
                    order.statusId   = 4;
                    order.Number     = Auction.Number;
                    order.siteId     = Auction.SiteId;
                    order.Date       = DatesRegulationVM.Order.Date;

                    try {
                        order.filesListId = DocumentService.CreateFilesList("Файлы заявки №" + order.Number);
                    } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка во время занесения данных заявки"); return; }

                    try {
                        order.id = AuctionService.CreateOrder(order);
                    } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка при создании заявки"); return; }
                }

                Init();
            }
            else
            {
                try {
                    DatesRegulationVM.UpdateRegulation(Auction.RegulationId);
                } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка при сохранении дат"); return; }

                try {
                    AuctionService.UpdateAuction(Auction);
                } catch { MessagesService.Show("Сохранение аукциона", "Произошла ошибка при сохранении аукциона"); return; }
            }

            MessagesService.Show("Сохранение аукциона", "Аукциона успешно сохранен");
        }
コード例 #21
0
 protected override void RemoveSearchableDocuments(Document document)
 {
     DocumentService.RemoveSearchableDocumentFromStorage(document);
 }
コード例 #22
0
 private void InitServices()
 {
     userService           = new UserService(config);
     authenticationService = new OAuth2TokenService(config);
     documentService       = new DocumentService(config);
 }
コード例 #23
0
        /// <summary>
        /// Creates an instance of <see cref="MonstersViewModel"/>
        /// </summary>
        public MonstersViewModel(Compendium compendium, MonsterSearchService monsterSearchService, MonsterSearchInput monsterSearchInput,
                                 StringService stringService, DialogService dialogService, XMLImporter xmlImporter, XMLExporter xmlExporter, DocumentService documentService)
        {
            _compendium           = compendium;
            _monsterSearchService = monsterSearchService;
            _monsterSearchInput   = monsterSearchInput;
            _stringService        = stringService;
            _dialogService        = dialogService;
            _xmlImporter          = xmlImporter;
            _xmlExporter          = xmlExporter;
            _documentService      = documentService;

            _selectMonsterCommand     = new RelayCommand(obj => true, obj => SelectMonster(obj as MonsterListItemViewModel));
            _editMonsterCommand       = new RelayCommand(obj => true, obj => EditMonster(obj as MonsterViewModel));
            _exportMonsterCommand     = new RelayCommand(obj => true, obj => ExportMonster(obj as MonsterViewModel));
            _cancelEditMonsterCommand = new RelayCommand(obj => true, obj => CancelEditMonster());
            _saveEditMonsterCommand   = new RelayCommand(obj => HasUnsavedChanges, obj => SaveEditMonster());
            _resetFiltersCommand      = new RelayCommand(obj => true, obj => InitializeSearch());
            _addCommand            = new RelayCommand(obj => true, obj => Add());
            _copyCommand           = new RelayCommand(obj => _selectedMonster != null, obj => Copy());
            _deleteCommand         = new RelayCommand(obj => _selectedMonster != null, obj => Delete());
            _importCommand         = new RelayCommand(obj => true, obj => Import());
            _selectNextCommand     = new RelayCommand(obj => true, obj => SelectNext());
            _selectPreviousCommand = new RelayCommand(obj => true, obj => SelectPrevious());

            Search();
        }
コード例 #24
0
        private void ProcessFilesInFolder(Folder parentFolder, DocumentService docSvc, DocumentServiceExtensions docExSvc, string lifecycledef, string state, long lcid, long lcstate, Boolean force, string comment)
        {
            Autodesk.Connectivity.WebServices.File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
            if (files != null && files.Length > 0)
            {
                foreach (Autodesk.Connectivity.WebServices.File file in files)
                {
                    Console.WriteLine("");
                    Console.WriteLine(" " + parentFolder.FullName + "/" + file.Name);
                    Console.WriteLine("  Master ID   : " + String.Format("{0:0}", file.MasterId));
                    Console.WriteLine("  LifeCycle ID: " + file.FileLfCyc.LfCycDefId.ToString());
                    Console.WriteLine("      State   : " + file.FileLfCyc.LfCycStateName);
                    if (file.FileLfCyc.LfCycDefId != -1)
                    {
                        if (force) 
                            Console.WriteLine("  LifeCycle is already set: Forcing change");
                        else
                            Console.WriteLine("  LifeCycle is already set: Use -force to change");
                        
                    }
                    if ((file.FileLfCyc.LfCycDefId == -1) || (force))
                    {
                        try
                        {
                            docExSvc.UpdateFileLifeCycleDefinitions(new long[] { file.MasterId }, new long[] { lcid }, new long[] { lcstate }, comment);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("ERROR: Changing LifeCycle " + parentFolder.FullName + "/" + file.Name + " (New LifeCycle - " + lifecycledef + ")");
                            Console.WriteLine(ex.Message.ToString());
                        }
                        finally 
                        {
                        }
                    }
#if DEBUG
                    Console.WriteLine("Press enter ...");
                    Console.ReadLine();
#endif
                }
            }

            Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false);
            if (folders != null && folders.Length > 0)
            {
                foreach (Folder folder in folders)
                {
                    ProcessFilesInFolder(folder, docSvc, docExSvc, lifecycledef, state, lcid, lcstate, force, comment);
                }
            }
        }
 public DocumentModel(DocumentService documentService)
 {
     DocumentService = documentService;
 }
コード例 #26
0
 private void GetFilesInFolder(Folder parentFolder, DocumentService docSvc, string filepath, Int32 fileversion, string checkinfile)
 {
     File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
     if (files != null && files.Length > 0)
     {
         foreach (File file in files)
         {
             if (parentFolder.FullName + "/" + file.Name == filepath)
             {
                 for (int vernum = file.VerNum; vernum >= 1; vernum--)
                 {
                     File verFile = docSvc.GetFileByVersion(file.MasterId, vernum);
                     if (vernum == fileversion)
                     {
                         Console.WriteLine(String.Format("{0,12:0,0}", verFile.FileSize) + " " + parentFolder.FullName + "/" + verFile.Name + " (Version " + vernum.ToString() + ")");
                         Console.WriteLine("Writing to " + checkinfile);
                         byte[] bytes;
                         for (int counter = 0; counter < checkinfile.Length; counter++)
                         {
                             if (checkinfile.Substring(counter,1) == "\\")
                             {
                                 try 
                                 {
                                     System.IO.Directory.CreateDirectory(checkinfile.Substring(0,counter));
                                 }
                                 catch (Exception ex)
                                 {
                                     Console.WriteLine(ex.ToString());
                                     Console.WriteLine(checkinfile.Substring(0, counter));
                                 }
                             }
                         }
                         
                         string fileName = docSvc.DownloadFile(verFile.Id, true, out bytes);
                         System.IO.File.WriteAllBytes(checkinfile, bytes);
                     }
                 }
             }
         }
     }
 }
コード例 #27
0
        private void PrintFilesInFolder(Folder parentFolder, DocumentService docSvc, Int32 size, Int32 maxpath)
        {
            Document.File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
            if (files != null && files.Length > 0)
            {
                foreach (Document.File file in files)
                {
                    for (int vernum = file.VerNum; vernum >= 1; vernum--)
                    {
                        Document.File verFile = docSvc.GetFileByVersion(file.MasterId, vernum);
                        Int32 filepathlength = parentFolder.FullName.Length + verFile.Name.Length + size;
                        if (filepathlength >= maxpath)
                        {
                            Console.WriteLine(String.Format("{0,4:0,0}", filepathlength) + " chars: " + parentFolder.FullName + "/" + verFile.Name + " (Version " + vernum.ToString() + ")");
                        }
                    } 
                }
            }

            Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false);
            if (folders != null && folders.Length > 0)
            {
                foreach (Folder folder in folders)
                {
                    PrintFilesInFolder(folder, docSvc, size, maxpath);
                }
            }
        }
コード例 #28
0
        private int IsFileInFolder(Folder parentFolder, DocumentService docSvc, string filepath)
        {
            // Returns 0 if not found
            // Returns 1 if found & not checked out
            // Returns 2 if found & checked out to you
            // Returns 3 if found & checked out to someone else

            int flag = 0; 
            File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
            if (files != null && files.Length > 0)
            {
                foreach (File file in files)
                {
                    if (parentFolder.FullName + "/" + file.Name == filepath)
                    {
                        Console.WriteLine(filepath + " is in the vault.");
                        if (file.CheckedOut)
                        {
                            if (file.CkOutUserId == docSvc.SecurityHeaderValue.UserId)
                            {
                                flag = 2;
                            }
                            else
                            {
                                flag = 3;
                            }
                        }
                        else
                        {
                            flag = 1;
                        }
                    }
                }
            }
            return flag;
        }
コード例 #29
0
 public DocCommonShowPageViewModel(INavigationService navigationService, IPageDialogService dialogService, DocumentService docService, SettingsModel settings, HttpService httpService, AppRepository documentsRepository) : base(navigationService, dialogService, docService, settings, httpService, documentsRepository)
 {
 }
コード例 #30
0
 public void RunCommand(string server, string vault, string username, string password, string file, string checkinfile, Boolean printerror, string comment)
 {
     SecurityService secSrv = new SecurityService();
     secSrv.SecurityHeaderValue = new VaultSingleFileCheckin.Security.SecurityHeader();
     secSrv.Url = "http://" + server + "/AutodeskDM/Services/SecurityService.asmx";
     try 
     {
         secSrv.SignIn(username, password, vault);
         DocumentService docSrv = new DocumentService();
         docSrv.SecurityHeaderValue = new VaultSingleFileCheckin.Document.SecurityHeader();
         docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId;
         docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket;
         docSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentService.asmx";
         Folder root = docSrv.GetFolderRoot();
         string filepath = System.IO.Path.GetDirectoryName(file);
         filepath = filepath.Replace("\\", "/");
         CreateFolder(docSrv, filepath);
         Folder filefolder = docSrv.GetFolderByPath(filepath);
         int fileflag = IsFileInFolder(filefolder, docSrv, file);
         //Console.WriteLine("File " + fileflag.ToString());
         byte[] bytes;
         switch (fileflag)
         {
             case 0:
                 Console.WriteLine("File is not in vault");
                 bytes = System.IO.File.ReadAllBytes(checkinfile);
                 File addedfile = docSrv.AddFile(filefolder.Id, System.IO.Path.GetFileName(checkinfile), comment,
                     System.IO.File.GetLastWriteTime(checkinfile), null, null, null, null, null,
                     FileClassification.None, false, bytes);
                 if (addedfile == null)
                 {
                     Console.WriteLine("ERROR: File not checked in to vault");
                 }
                 else
                 {
                     Console.WriteLine("File checked in to vault");
                 }
                 break;
             case 1:
                 Console.WriteLine("File is in vault (not checked out)");
                 File[] files = docSrv.GetLatestFilesByFolderId(filefolder.Id, true);
                 foreach (File afile in files)
                 {           
                     if (filefolder.FullName + "/" + afile.Name == file)
                     {
                         //docSrv.CheckoutFile(filefolder.Id, afile.MasterId,
                         //    Environment.MachineName, Environment.GetEnvironmentVariable("TEMP"), comment,
                         //    true, true, out bytes);
                         docSrv.CheckoutFile(filefolder.Id, afile.Id, CheckoutFileOptions.Master,
                                         Environment.MachineName, "c:\\", "Temporary Checkout",
                                         false, true, out bytes);
                         bytes = System.IO.File.ReadAllBytes(checkinfile);
                         File updatedfile = docSrv.CheckinFile(afile.MasterId, comment,
                             false, System.IO.File.GetLastWriteTime(checkinfile), null, null, null, null, null, false,
                             System.IO.Path.GetFileName(checkinfile), afile.FileClass, afile.Hidden, bytes);
                         if (updatedfile.Id  == afile.Id)
                         {
                             Console.WriteLine("ERROR: File not checked in to vault");
                         }
                         else
                         {
                             Console.WriteLine("File checked in to vault");
                         }
                     }
                 }
                 break;
             case 2:
                 Console.WriteLine("File is in vault (checked out to you)");
                 break;
             default:
                 Console.WriteLine("File is in vault (checked out to someone else)");
                 Console.WriteLine("Cannot check in file");
                 break;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error retrieving file");
         if (printerror)
         {
             Console.WriteLine(ex.ToString());
         }
         return;
     }
 }
コード例 #31
0
        private void DownloadFileInParts(Document.File file, DocumentService docSvc, string outputfile)
        {
            int MAX_BUFFER_SIZE = 1024 * 1024 * 4;    // 49 MB buffer size
            System.IO.FileStream outputStream = null;

            try
            {
                long startByte = 0;
                long endByte;

                // create the output file
                outputStream = System.IO.File.OpenWrite(outputfile);

                // for each loop, the MAX_BUFFER_SIZE number of bytes gets downloaded from the server and written
                // to disk
                while (startByte < file.FileSize)
                {
                    byte[] buffer; 
                    endByte = startByte + MAX_BUFFER_SIZE;
                    if (endByte > file.FileSize)
                        endByte = file.FileSize;

                    // grab the file part from the server
                    buffer = docSvc.DownloadFilePart(file.Id, startByte, endByte, true);

                    // write the data to the file
                    outputStream.Write(buffer, 0, buffer.Length);

                    startByte += buffer.Length;
                }
            }
            finally
            {
                if (outputStream != null)
                    outputStream.Close();
            }
        }
        // Selection changed handler for all of our tabs
        //
//        void propertyTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
//        {
//            MyCustomTabControl tabControl = e.Context.UserControl as MyCustomTabControl;
//            tabControl.SetSelectedObject(e.Context.SelectedObject);
//        }

        // Seed the document service with security ticket and user id.
        // This allows us to call document service methods as the user
        // currently logged into Vault
        //
        public void OnLogOn(IApplication application)
        {
            mDocSvc = new DocumentService();
            mDocSvc.Url = application.VaultContext.RemoteBaseUrl + "DocumentService.asmx";
            mDocSvc.SecurityHeaderValue = new Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader();
            mDocSvc.SecurityHeaderValue.Ticket = application.VaultContext.Ticket;
            mDocSvc.SecurityHeaderValue.UserId = application.VaultContext.UserId;
        }
コード例 #33
0
 public WorkItemSelectionService(DTE dte, DocumentService documentService, IVisualStudioAdapter visualStudioAdapter)
 {
     this.dte = dte;
     this.documentService = documentService;
     this.visualStudioAdapter = visualStudioAdapter;
 }
コード例 #34
0
        //удаление файла
        private void DeleteButtonClick(int id)
        {
            DocumentService ds = new DocumentService();

            ds.Delete(id);
        }
コード例 #35
0
        private void PrintFilesInFolder(Folder parentFolder, DocumentService docSvc, double size)
        {
            File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
            if (files != null && files.Length > 0)
            {
                foreach (File file in files)
                {
                    if (file.FileSize >= size)
                    {
                        for (int vernum = file.VerNum; vernum >= 1; vernum--)
                        {
                            File verFile = docSvc.GetFileByVersion(file.MasterId, vernum);
                            Console.WriteLine(String.Format("{0,12:0,0}", verFile.FileSize) + " " + parentFolder.FullName + "/" + verFile.Name + " (Version " + vernum.ToString() + ")");
                        }
                    }
                }
            }

            Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false);
            if (folders != null && folders.Length > 0)
            {
                foreach (Folder folder in folders)
                {
                    PrintFilesInFolder(folder, docSvc, size);
                }
            }
        }
コード例 #36
0
 private bool SetDocumentComments(DocumentCommentBEO documentComment)
 {
     try
     {
         var collectionId = documentComment.CollectionId.ToString();
         var documentId = documentComment.DocumentId;
         var matterId = documentComment.MatterId.ToString();
         var documentService = new DocumentService(_session);
         return documentService.AddComment(documentComment, true);
     }
     catch (Exception)
     {
         //LogJobException(ErrorCodes.ErrorDcbImportCreateDocumentComments, String.Format(Constants.ErrorCreateDocumentComments, currentDocumentId),
         //                                                                                                    false,
         //                                                                                                    exp.Message);
         Tracer.Error("Tag Comment Worker: Unable to set the comment to document id: {0}",
                      documentComment.DocumentId);
         return false;
     }
 }
 public void OnLogOff(IApplication application)
 {
     mDocSvc = null;
 }
コード例 #38
0
 public InternalLinkTaskPane()
 {
     InitializeComponent();
     _ds = ServicePool.Instance.GetService <DocumentService>();
 }
コード例 #39
0
ファイル: DocumentAPIShould.cs プロジェクト: RonnyAnc/Papyrus
 public void InitializeRestClientAndService()
 {
     restClient = new RestClient(baseAddress);
     documentService = SubstituteForDocumentService();
 }
コード例 #40
0
ファイル: Program.cs プロジェクト: Javanei/clientes
        public static List<ADSK.File> findByCheckinDate(DocumentService documentService, String checkinDate)
        {
            LOG.imprimeLog(System.DateTime.Now + " ===== findByCheckinDate: [" + checkinDate + "]");
            List<ADSK.File> fileList = new List<ADSK.File>();
            List<ADSK.File> fileListTmp = new List<ADSK.File>();
            List<string> allf = new List<string>();

            ADSK.PropDef prop = GetPropertyDefinition("CheckoutUserName", documentService);
            if (prop != null)
            {
                propid = (int)prop.Id;
                /* Faz a pesquisa */
                string bookmark = string.Empty;
                ADSK.SrchStatus status = null;

                ADSK.SrchCond[] conditions = new ADSK.SrchCond[1];
                conditions[0] = new ADSK.SrchCond();
                conditions[0].SrchOper = Condition.IS_NOT_EMPTY.Code;
                conditions[0].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[0].PropDefId = propid;

                prop = GetPropertyDefinition("ClientFileName", documentService);
                propid = (int)prop.Id;

                /*conditions[1] = new ADSK.SrchCond();
                conditions[1].SrchOper = Condition.CONTAINS.Code;
                conditions[1].SrchTxt = ".idw";
                conditions[1].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[1].PropDefId = propid;
                conditions[1].SrchRule = ADSK.SearchRuleType.May;

                conditions[2] = new ADSK.SrchCond();
                conditions[2].SrchOper = Condition.CONTAINS.Code;
                conditions[2].SrchTxt = ".pdf";
                conditions[2].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[2].PropDefId = propid;
                conditions[2].SrchRule = ADSK.SearchRuleType.May;

                conditions[3] = new ADSK.SrchCond();
                conditions[3].SrchOper = Condition.CONTAINS.Code;
                conditions[3].SrchTxt = ".dwg";
                conditions[3].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[3].PropDefId = propid;
                conditions[3].SrchRule = ADSK.SearchRuleType.May;*/

                while (status == null || fileListTmp.Count < status.TotalHits)
                {
                    ADSK.File[] files = documentService.FindFilesBySearchConditions(
                        conditions, /*SrchCond [] conditions*/
                        null, /*SrchSort [] sortConditions*/
                        folderIds, /*Long [] folderIds*/
                        true, /*Boolean recurseFolders*/
                        true, /*Boolean latestOnly*/
                        ref bookmark, /*[out] String bookmark*/
                        out status /*[out] SrchStatus searchstatus*/
                    );
                    if (files != null)
                    {
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".idw"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".dwg"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".pdf"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        /*
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".pdf") || f.Name.ToLower().EndsWith(".idw") || f.Name.ToLower().EndsWith(".dwg"))
                            {
                                LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ")");
                                fileList.Add(f);
                            }
                        }
                        */
                    }
                }
            }

            /*ADSK.PropDef*/
            prop = GetPropertyDefinition("CheckInDate", documentService);
            if (prop != null)
            {
                fileListTmp = new List<ADSK.File>();
                propid = (int)prop.Id;
                /* Faz a pesquisa */
                string bookmark = string.Empty;
                ADSK.SrchStatus status = null;

                ADSK.SrchCond[] conditions = new ADSK.SrchCond[1];
                conditions[0] = new ADSK.SrchCond();
                conditions[0].SrchOper = Condition.GREATER_THAN_OR_EQUAL.Code /*(long)SrchOperator.GreatherThan*/;
                conditions[0].SrchTxt = checkinDate;
                conditions[0].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[0].PropDefId = propid;

                prop = GetPropertyDefinition("ClientFileName", documentService);
                propid = (int)prop.Id;

                /*conditions[1] = new ADSK.SrchCond();
                conditions[1].SrchOper = Condition.CONTAINS.Code;
                conditions[1].SrchTxt = ".idw";
                conditions[1].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[1].PropDefId = propid;
                conditions[1].SrchRule = ADSK.SearchRuleType.May;

                conditions[2] = new ADSK.SrchCond();
                conditions[2].SrchOper = Condition.CONTAINS.Code;
                conditions[2].SrchTxt = ".pdf";
                conditions[2].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[2].PropDefId = propid;
                conditions[2].SrchRule = ADSK.SearchRuleType.May;

                conditions[3] = new ADSK.SrchCond();
                conditions[3].SrchOper = Condition.CONTAINS.Code;
                conditions[3].SrchTxt = ".dwg";
                conditions[3].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[3].PropDefId = propid;
                conditions[3].SrchRule = ADSK.SearchRuleType.May;*/

                while (status == null || fileListTmp.Count < status.TotalHits)
                {
                    /*ADSK.FileFolder[] folders = documentService.FindFileFoldersBySearchConditions(
                        conditions,
                        null,
                        folderIds,
                        true,
                        true,
                        ref bookmark,
                        out status
                    );

                    if (folders != null)
                    {
                        foreach (ADSK.FileFolder f in folders)
                        {
                            //if (f.File != null)
                            //{
                            fileList.Add(f.File);
                            //}
                        }
                    }*/
                    ADSK.File[] files = documentService.FindFilesBySearchConditions(
                        conditions, /*SrchCond [] conditions*/
                        null, /*SrchSort [] sortConditions*/
                        folderIds, /*Long [] folderIds*/
                        true, /*Boolean recurseFolders*/
                        true, /*Boolean latestOnly*/
                        ref bookmark, /*[out] String bookmark*/
                        out status /*[out] SrchStatus searchstatus*/
                    );
                    if (files != null)
                    {
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".idw"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".dwg"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".pdf"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        /*
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".pdf") || f.Name.ToLower().EndsWith(".idw") || f.Name.ToLower().EndsWith(".dwg"))
                            {
                                if (!fileList.Contains(f))
                                {
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ")");
                                    fileList.Add(f);
                                }
                            }
                        }
                        */
                    }

                    //ADSK.File[] files = documentService.FindFilesBySearchConditions(
                    //    conditions, /*SrchCond [] conditions*/
                    //    null, /*SrchSort [] sortConditions*/
                    //    null, /*Long [] folderIds*/
                    //    true, /*Boolean recurseFolders*/
                    //    true, /*Boolean latestOnly*/
                    //    ref bookmark, /*[out] String bookmark*/
                    //    out status /*[out] SrchStatus searchstatus*/
                    //);

                    //if (files != null)
                    //    fileList.AddRange(files);
                }
            }
            return fileList;
        }
コード例 #41
0
        public QueryResultsDocumentCreationObserver(DocumentService documentService)
        {
            this.documentService = documentService;

            ObserveDocumentCreations();
        }
コード例 #42
0
 public DocumentController()
 {
     service = new DocumentService();
 }
コード例 #43
0
ファイル: DocumentSrvController.cs プロジェクト: naishan/SDDB
 //Constructors---------------------------------------------------------------------------------------------------------//
 public DocumentSrvController(DocumentService docService)
 {
     this.docService = docService;
 }
コード例 #44
0
 public ActionResult <IEnumerable <DocumentStats> > GetDocumentStats()
 {
     return(Ok(DocumentService.GetStats()));
 }