public LibraryFileSlides GetFileSlidesInfo(CheckUpdateDto data)
        {
            LibraryFileSlides libraryFileSlides = new LibraryFileSlides();

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"{data.ServerInfo.WebClientUrl}{data.ServerInfo.ShortLibraryName}/Default.ashx?m=getslides&fid={data.FileId}&useweb=true?out=xml");

            request.Method = "GET";
            request.Headers.Add("Authorization", data.ServerInfo.AuthHash);
            request.Proxy.Credentials = CredentialCache.DefaultCredentials;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                var responseStream    = Helper.ReadResponseAsStream(response);
                var responseXMLString = Helper.ReadResponseAsString(responseStream);
                libraryFileSlides = Helper.DeserializeXmlResponse <LibraryFileSlides>(responseXMLString);
            }

            return(libraryFileSlides);
        }
Exemple #2
0
        private bool CheckSlidesForUpdates(SlideTagExCollection slideTags, bool isLibraryFile, CheckUpdateDto fileInfo)
        {
            bool updatesExist = false;

            for (int x = 0; x < slideTags.Count; x++)
            {
                SlideTagEx slideTagEx = slideTags[x];
                if (slideTagEx.SlideStatus == TagUpdateStatus.Unknown)
                {
                    LibraryFileSlides libraryFileSlides = null;
                    try
                    {
                        if (fileInfo.FileId == "-1")
                        {
                            fileInfo.FileId = slideTagEx.File.Id.ToString();
                        }

                        libraryFileSlides = _filesService.GetFileSlidesInfo(fileInfo);
                    }
                    catch (Exception ex)
                    {
                        isExcuted = false;
                        return(updatesExist);
                    }

                    if (libraryFileSlides != null)
                    {
                        for (int i = 0; i < libraryFileSlides.Slides.Count; i++)
                        {
                            SlideInfo            librarySlideInfo = libraryFileSlides.Slides[i];
                            SlideTagExCollection findSlideTags;
                            findSlideTags = slideTags.FindBySlideId(fileInfo.ServerInfo.EnvironmentName, fileInfo.ServerInfo.ShortLibraryName, librarySlideInfo.SlideId);

                            if (findSlideTags.Any())
                            {
                                int movedCount = 0;
                                for (int z = 0; z < findSlideTags.Count; z++)
                                {
                                    SlideTagEx foundSlideTag = findSlideTags[z];
                                    if (isLibraryFile && foundSlideTag.PptSlideIndex != librarySlideInfo.SlideNumber)
                                    {
                                        if (z == 0 && movedCount == 0)
                                        {
                                            foundSlideTag.SlideStatus = TagUpdateStatus.Moved;
                                            ++movedCount;
                                        }
                                        else
                                        {
                                            foundSlideTag.SlideStatus = TagUpdateStatus.Added;
                                        }
                                    }
                                    else if (librarySlideInfo.LastModDate <= foundSlideTag.Slide.LastModDate.ToUniversalTime())
                                    {
                                        foundSlideTag.SlideStatus = TagUpdateStatus.NoChange;
                                    }
                                    else
                                    {
                                        foundSlideTag.SlideStatus = TagUpdateStatus.Updated;
                                        updatesExist = true;
                                    }
                                    foundSlideTag.SourceFilename    = librarySlideInfo.FileName;
                                    foundSlideTag.SourceSlideNum    = librarySlideInfo.SlideNumber;
                                    foundSlideTag.SourceLastModDate = (DateTime)librarySlideInfo.LastModDate;
                                }
                            }
                            else if (isLibraryFile)
                            {
                                SlideTagEx newSlideTag = new SlideTagEx(fileInfo.ServerInfo.EnvironmentName, fileInfo.ServerInfo.ShortLibraryName, librarySlideInfo, -1)
                                {
                                    SlideStatus       = TagUpdateStatus.New,
                                    Title             = librarySlideInfo.Title,
                                    SourceFilename    = librarySlideInfo.FileName,
                                    SourceSlideNum    = librarySlideInfo.SlideNumber,
                                    SourceLastModDate = (DateTime)librarySlideInfo.LastModDate
                                };
                                slideTags.Insert(i, newSlideTag);
                                updatesExist = true;
                            }
                        }
                    }

                    foreach (SlideTagEx nextSlideTagEx in slideTags)
                    {
                        if (nextSlideTagEx.SlideStatus == TagUpdateStatus.Unknown)
                        {
                            if (nextSlideTagEx.File.Id == slideTagEx.File.Id &&
                                nextSlideTagEx.Library.ShortName == slideTagEx.Library.ShortName &&
                                nextSlideTagEx.Library.Environment == slideTagEx.Library.Environment)
                            {
                                if (isLibraryFile)
                                {
                                    nextSlideTagEx.SlideStatus = TagUpdateStatus.Added;
                                }
                                else
                                {
                                    updatesExist = true;
                                    nextSlideTagEx.SlideStatus = TagUpdateStatus.MissingOrDeleted;
                                    if (libraryFileSlides != null && libraryFileSlides.Slides.Any())
                                    {
                                        nextSlideTagEx.SourceFilename = libraryFileSlides.Slides[0].FileName;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(updatesExist);
        }