Пример #1
0
        private static void Add7018Entry(GeoPoint corner, Tuple <Int32, Int32> index)
        {
            if (!InvalidSheets.Any(x => x.Equals(index)))
            {
                Double standardExtend  = 15.0 / 60.0;
                Double latitudeExtend  = standardExtend;
                Double longitudeExtend = standardExtend;

                GeoPoint actualCorner = new GeoPoint(corner);
                switch (index.Item2)
                {
                case 1:
                    actualCorner.Longitude += standardExtend;
                    break;

                case 2:
                    actualCorner.Longitude += standardExtend;
                    actualCorner.Latitude  -= standardExtend;
                    break;

                case 3:
                    actualCorner.Latitude -= standardExtend;
                    break;

                case 4:
                    break;
                }
                if (SheetsLongitude18Minutes.Any(x => x.Equals(index)))
                {
                    longitudeExtend = 18.0 / 60.0;
                }
                if (SheetsLongitude17Minutes.Any(x => x.Equals(index)))
                {
                    longitudeExtend = 17.0 / 60.0;
                }
                if (SheetsLongitude20Minutes.Any(x => x.Equals(index)))
                {
                    longitudeExtend = 20.0 / 60.0;
                }
                if (SheetsLatitude18_16Minutes.Any(x => x.Equals(index)))
                {
                    latitudeExtend = 18.0 / 60.0 + 16.0 / 3600.0;
                }
                if (SheetsShifted3MinutesEast.Any(x => x.Equals(index)))
                {
                    actualCorner.Longitude += 3.0 / 60.0;
                }
                if (SheetsShifted5MinutesWest.Any(x => x.Equals(index)))
                {
                    actualCorner.Longitude -= 5.0 / 60.0;
                }
                if (SheetsShifted5MinutesEast.Any(x => x.Equals(index)))
                {
                    actualCorner.Longitude += 5.0 / 60.0;
                }
                if (SheetsShifted6MinutesEast.Any(x => x.Equals(index)))
                {
                    actualCorner.Longitude += 6.0 / 60.0;
                }
                if (SheetsShifted7Minutes30SecondsEast.Any(x => x.Equals(index)))
                {
                    actualCorner.Longitude += 7.5 / 60.0;
                }
                if (SheetsShifted7MinutesWest.Any(x => x.Equals(index)))
                {
                    actualCorner.Longitude -= 7.0 / 60.0;
                }
                if (SheetsShifted3_16MinutesNorth.Any(x => x.Equals(index)))
                {
                    actualCorner.Latitude += 3.0 / 60.0 + 16.0 / 3600.0;
                }
                if (SheetsShifted5MinutesSouth.Any(x => x.Equals(index)))
                {
                    actualCorner.Latitude -= 5.0 / 60.0;
                }

                MapIndexL7018.Add(new RtsdMapFrame(actualCorner, latitudeExtend, longitudeExtend, index));
            }
        }
Пример #2
0
        private async Task IncludingReferencesToDependencyXml(IOrganizationServiceExtented service, List <SelectedFile> selectedFiles)
        {
            TupleList <SelectedFile, WebResource> list = new TupleList <SelectedFile, WebResource>();

            // Репозиторий для работы с веб-ресурсами
            WebResourceRepository webResourceRepository = new WebResourceRepository(service);

            bool allForOther = false;

            var groups = selectedFiles.GroupBy(sel => sel.Extension);

            foreach (var gr in groups)
            {
                var names = gr.Select(sel => sel.FriendlyFilePath).ToArray();

                var dict = webResourceRepository.FindMultiple(gr.Key, names);

                foreach (var selectedFile in gr)
                {
                    if (!File.Exists(selectedFile.FilePath))
                    {
                        this._iWriteToOutput.WriteToOutput(service.ConnectionData, "File not founded: {0}", selectedFile.FilePath);
                        continue;
                    }

                    this._iWriteToOutput.WriteToOutput(service.ConnectionData, "Try to find web-resource by name: {0}. Searching...", selectedFile.Name);

                    string key = selectedFile.FriendlyFilePath.ToLower();

                    var contentFile = Convert.ToBase64String(File.ReadAllBytes(selectedFile.FilePath));

                    var webresource = WebResourceRepository.FindWebResourceInDictionary(dict, key, gr.Key);

                    if (webresource != null)
                    {
                        this._iWriteToOutput.WriteToOutput(service.ConnectionData, "WebResource founded by name. WebResourceId: {0} Name: {1}", webresource.Id, webresource.Name);
                    }

                    if (webresource == null)
                    {
                        if (selectedFile.FileName.StartsWith(service.ConnectionData.Name + "."))
                        {
                            string newFileName = selectedFile.FileName.Replace(service.ConnectionData.Name + ".", string.Empty);

                            string newFilePath = Path.Combine(Path.GetDirectoryName(selectedFile.FilePath), newFileName);

                            var newSelectedFile = new SelectedFile(newFilePath, selectedFile.SolutionDirectoryPath);

                            var newDict = webResourceRepository.FindMultiple(newSelectedFile.Extension, new[] { newSelectedFile.FriendlyFilePath });

                            webresource = WebResourceRepository.FindWebResourceInDictionary(newDict, newSelectedFile.FriendlyFilePath.ToLower(), newSelectedFile.Extension);

                            if (webresource != null)
                            {
                                this._iWriteToOutput.WriteToOutput(service.ConnectionData, "WebResource founded by name with Connection Prefix. WebResourceId: {0} Name: {1}", webresource.Id, webresource.Name);
                            }
                        }
                    }

                    if (webresource == null)
                    {
                        this._iWriteToOutput.WriteToOutput(service.ConnectionData, "WebResource not founded by name. FileName: {0}. Open linking dialog...", selectedFile.Name);

                        Guid?webId = service.ConnectionData.GetLastLinkForFile(selectedFile.FriendlyFilePath);

                        bool?dialogResult          = null;
                        Guid?selectedWebResourceId = null;

                        var t = new Thread(() =>
                        {
                            try
                            {
                                var form = new Views.WindowWebResourceSelectOrCreate(this._iWriteToOutput, service, selectedFile, webId);
                                form.ShowCreateButton(allForOther);

                                dialogResult = form.ShowDialog();

                                allForOther = form.ForAllOther;

                                selectedWebResourceId = form.SelectedWebResourceId;
                            }
                            catch (Exception ex)
                            {
                                DTEHelper.WriteExceptionToOutput(service.ConnectionData, ex);
                            }
                        });
                        t.SetApartmentState(ApartmentState.STA);
                        t.Start();

                        t.Join();

                        if (string.IsNullOrEmpty(service.ConnectionData?.LastSelectedSolutionsUniqueName?.FirstOrDefault()))
                        {
                            allForOther = false;
                        }

                        service.ConnectionData.Save();

                        if (dialogResult.GetValueOrDefault())
                        {
                            if (selectedWebResourceId.HasValue)
                            {
                                webresource = await webResourceRepository.GetByIdAsync(selectedWebResourceId.Value);
                            }
                            else
                            {
                                this._iWriteToOutput.WriteToOutput(service.ConnectionData, "!Warning. WebResource not linked. name: {0}.", selectedFile.Name);
                            }
                        }
                        else
                        {
                            this._iWriteToOutput.WriteToOutput(service.ConnectionData, "Updating Content and Publishing was cancelled.");
                            return;
                        }
                    }

                    if (webresource != null)
                    {
                        // Запоминается файл
                        service.ConnectionData.AddMapping(webresource.Id, selectedFile.FriendlyFilePath);

                        list.Add(selectedFile, webresource);
                    }
                }
            }

            //Сохранение настроек после публикации
            service.ConnectionData.Save();

            if (!list.Any())
            {
                return;
            }

            List <WebResource> webResourceToPublish = new List <WebResource>();

            PublishActionsRepository repository = new PublishActionsRepository(service);
            await repository.PublishWebResourcesAsync(webResourceToPublish.Select(e => e.Id));
        }
Пример #3
0
 public override bool HasResourcesToSuspend()
 {
     return(_workspaces.Any(w => w.Item2.HasResourcesToSuspend()));
 }