コード例 #1
0
        public JsonResult LoadProject2()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("https://localhost:44320/api/")
            };

            client.DefaultRequestHeaders.Add("Authorization", HttpContext.Session.GetString(("JWToken")));

            ProjectJson project      = null;
            var         responseTask = client.GetAsync("Project/");

            responseTask.Wait();
            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var json = JsonConvert.DeserializeObject(result.Content.ReadAsStringAsync().Result).ToString();
                project = JsonConvert.DeserializeObject <ProjectJson>(json);
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Server Error");
            }
            return(Json(project));
        }
コード例 #2
0
        public void ImportMissingWorkspaceAndClient()
        {
            RunAsync(async delegate {
                var projectJson = new ProjectJson()
                {
                    Id          = 3,
                    Name        = "Github",
                    WorkspaceId = 1,
                    ClientId    = 2,
                    ModifiedAt  = new DateTime(2014, 1, 3),
                };

                var projectData = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, projectJson));
                Assert.AreNotEqual(Guid.Empty, projectData.WorkspaceId);

                var workspaceRows = await DataStore.Table <WorkspaceData> ().QueryAsync(m => m.Id == projectData.WorkspaceId);
                var workspaceData = workspaceRows.FirstOrDefault();
                Assert.IsNotNull(workspaceData);
                Assert.IsNotNull(workspaceData.RemoteId);
                Assert.AreEqual(DateTime.MinValue, workspaceData.ModifiedAt);

                var clientRows = await DataStore.Table <ClientData> ().QueryAsync(m => m.Id == projectData.ClientId);
                var clientData = clientRows.FirstOrDefault();
                Assert.IsNotNull(clientData);
                Assert.IsNotNull(clientData.RemoteId);
                Assert.AreEqual(DateTime.MinValue, clientData.ModifiedAt);
            });
        }
コード例 #3
0
        public static void SetPipelines(AzureDataFactoryProject projectNode, ProjectJson projectJson)
        {
            if (projectNode?.Pipelines != null)
            {
                List <PipelineJson> pipelines = new();

                foreach (Pipeline pipeline in projectNode.Pipelines)
                {
                    PipelineJson pipelineJson = new();
                    pipelineJson.Name = pipeline.Name;

                    PropertyJson propertyJson = new();

                    ActivityGenerator.SetActivities(pipeline, propertyJson);

                    SetParameters(pipeline, propertyJson);
                    SetVariables(pipeline, propertyJson);

                    pipelineJson.Properties = propertyJson;
                    pipelines.Add(pipelineJson);
                }

                projectJson.Pipelines = pipelines;
            }
        }
コード例 #4
0
        public static ProjectData Import(this ProjectJson json, IDataStoreContext ctx,
                                         Guid?localIdHint = null, ProjectData mergeBase = null)
        {
            var converter = ServiceContainer.Resolve <ProjectJsonConverter> ();

            return(converter.Import(ctx, json, localIdHint, mergeBase));
        }
コード例 #5
0
        public ProjectData Import (IDataStoreContext ctx, ProjectJson json, Guid? localIdHint = null, ProjectData mergeBase = null)
        {
            var data = GetByRemoteId<ProjectData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ProjectMerger (mergeBase) : null;
            if (merger != null && data != null)
                merger.Add (new ProjectData (data));

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ProjectData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                data = ctx.Put (data);
            }

            return data;
        }
コード例 #6
0
        public bool WriteProjectJsonFile()
        {
            ProjectJson projectJson = new ProjectJson(this.dependencies, this.framework, this.runtimes);
            string      jsonContent;

            // AGPL License
#if NETSTANDARD
            JsonSerializerOptions options = new JsonSerializerOptions
            {
                WriteIndented = true
            };

            jsonContent = JsonSerializer.Serialize(projectJson, typeof(ProjectJson), options);
#else
            jsonContent = new JavaScriptSerializer().Serialize(projectJson);
#endif

            try
            {
                if (File.Exists(ProjectJsonFilePath))
                {
                    File.Delete(ProjectJsonFilePath);
                }

                File.WriteAllText(ProjectJsonFilePath, jsonContent);
            }
            catch (Exception ex)
            {
                OnExceptionThrown(ex);

                return(false);
            }

            return(true);
        }
コード例 #7
0
        public void ImportPastDeleted()
        {
            RunAsync(async delegate {
                var workspaceData = await DataStore.PutAsync(new WorkspaceData()
                {
                    RemoteId   = 1,
                    Name       = "Test",
                    ModifiedAt = new DateTime(2014, 1, 2),
                });
                var projectData = await DataStore.PutAsync(new ProjectData()
                {
                    RemoteId    = 3,
                    Name        = "Hosting",
                    Color       = 2,
                    IsActive    = true,
                    WorkspaceId = workspaceData.Id,
                    ModifiedAt  = new DateTime(2014, 1, 3),
                });

                var projectJson = new ProjectJson()
                {
                    Id        = 2,
                    DeletedAt = new DateTime(2014, 1, 2),
                };

                var ret = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, projectJson));
                Assert.IsNull(ret);

                var rows = await DataStore.Table <ProjectData> ().QueryAsync(m => m.Id == projectData.Id);
                Assert.That(rows, Has.Exactly(0).Count);
            });
        }
コード例 #8
0
        public static ProjectJson GetProjectMetadataJson(AttributesJson attributes = null)
        {
            ProjectJson projectJson = new ProjectJson {
                Attributes = attributes ?? GetAttributesJson()
            };

            return(projectJson);
        }
コード例 #9
0
        public static MetadataJson GetMetadataJson(
            InstanceJson instance = null,
            ProjectJson project   = null)
        {
            MetadataJson metadataJson = new MetadataJson
            {
                Instance = instance ?? GetInstanceMetadataJson(),
                Project  = project ?? GetProjectMetadataJson()
            };

            return(metadataJson);
        }
コード例 #10
0
        private static string GetProjectJson(CreateProject project, ProjectJson type)
        {
            var template = string.Empty;
            List<string> references = new List<string>();

            switch (type)
            {
                case ProjectJson.BusinessCodeGenerator:
                    template = Resources.CSharp.ProjectJsonCodeGenerator;
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Contract");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Entity");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Resource");
                    break;
                case ProjectJson.BusinessConcrete:
                    template = Resources.CSharp.ProjectJsonConcrete;
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Contract");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Data");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Entity");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Resource");
                    break;
                case ProjectJson.BusinessContract:
                    template = Resources.CSharp.ProjectJsonContract;
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Entity");
                    break;
                case ProjectJson.BusinessData:
                    template = Resources.CSharp.ProjectJsonData;
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Entity");
                    break;
                case ProjectJson.BusinessEntity:
                    template = Resources.CSharp.ProjectJsonEntity;
                    break;
                case ProjectJson.BusinessFactory:
                    template = Resources.CSharp.ProjectJsonFactory;
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Concrete");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Contract");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Data");
                    references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Entity");
                    break;
                case ProjectJson.BusinessResource:
                    template = Resources.CSharp.ProjectJsonResource;
                    break;
                case ProjectJson.ViewWebSimple:
                    template = Resources.CSharp.ProjectJsonEntity;
                    break;
                case ProjectJson.BusinessTest:
                    template = Resources.CSharp.ProjectJsonTest;
                    break;
                default:
                    break;
            }

            return CommandExtencionsCommon.MergeProjectJson(template, references);
        }
コード例 #11
0
        // PUT api/<controller>/5
        public string Put([FromBody] ProjectJson para)
        {
            Debug.Write("Put");
            var work = new List <string>();

            work.Add(para.Item);
            work.Add(para.Func);
            work.Add(para.Json);
            XmlDocument xmlDoc = makeXmlDoc("PUT" + "[" + string.Join("][", work) + "]");

            return(xmlDoc.OuterXml);
        }
コード例 #12
0
        public void ImportUpdated()
        {
            RunAsync(async delegate {
                var workspaceData = await DataStore.PutAsync(new WorkspaceData()
                {
                    RemoteId   = 1,
                    Name       = "Test",
                    ModifiedAt = new
                                 DateTime(2014, 1, 2),
                });
                var clientData = await DataStore.PutAsync(new ClientData()
                {
                    RemoteId    = 2,
                    Name        = "Github",
                    WorkspaceId = workspaceData.Id,
                    ModifiedAt  = new DateTime(2014, 1, 3),
                });
                var projectData = await DataStore.PutAsync(new ProjectData()
                {
                    RemoteId    = 2,
                    Name        = "",
                    WorkspaceId = workspaceData.Id,
                    ClientId    = clientData.Id,
                    ModifiedAt  = new DateTime(2014, 1, 2, 10, 0, 0, DateTimeKind.Utc),
                });
                var projectJson = new ProjectJson()
                {
                    Id          = 3,
                    Name        = "Hosting",
                    WorkspaceId = 1,
                    ClientId    = 2,
                    ModifiedAt  = new DateTime(2014, 1, 2, 10, 1, 0, DateTimeKind.Utc).ToLocalTime(),  // JSON deserialized to local
                };

                projectData = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, projectJson));
                Assert.AreNotEqual(Guid.Empty, projectData.Id);
                Assert.AreEqual(3, projectData.RemoteId);
                Assert.AreEqual("Hosting", projectData.Name);
                Assert.AreEqual(new DateTime(2014, 1, 2, 10, 1, 0, DateTimeKind.Utc), projectData.ModifiedAt);
                Assert.AreEqual(workspaceData.Id, projectData.WorkspaceId);
                Assert.AreEqual(clientData.Id, projectData.ClientId);
                Assert.IsFalse(projectData.IsDirty);
                Assert.IsFalse(projectData.RemoteRejected);
                Assert.IsNull(projectData.DeletedAt);
            });

            // Warn the user that the test result might be invalid
            if (TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes >= 0)
            {
                Assert.Inconclusive("The test machine timezone should be set to GTM-1 or less to test datetime comparison.");
            }
        }
コード例 #13
0
        public ProjectData Import(IDataStoreContext ctx, ProjectJson json, Guid?localIdHint = null, ProjectData mergeBase = null)
        {
            var log = ServiceContainer.Resolve <ILogger> ();

            var data = GetByRemoteId <ProjectData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ProjectMerger(mergeBase) : null;

            if (merger != null && data != null)
            {
                merger.Add(new ProjectData(data));
            }

            if (json.DeletedAt.HasValue)
            {
                if (data != null)
                {
                    log.Info(Tag, "Deleting local data for {0}.", data.ToIdString());
                    ctx.Delete(data);
                    data = null;
                }
            }
            else if (merger != null || ShouldOverwrite(data, json))
            {
                data = data ?? new ProjectData();
                ImportJson(ctx, data, json);

                if (merger != null)
                {
                    merger.Add(data);
                    data = merger.Result;
                }

                if (merger != null)
                {
                    log.Info(Tag, "Importing {0}, merging with local data.", data.ToIdString());
                }
                else
                {
                    log.Info(Tag, "Importing {0}, replacing local data.", data.ToIdString());
                }

                data = ctx.Put(data);
            }
            else
            {
                log.Info(Tag, "Skipping import of {0}.", json.ToIdString());
            }

            return(data);
        }
コード例 #14
0
        public void Write(Project project, Stream stream)
        {
            ProjectJson json = new ProjectJson(project);

            JsonSerializer serializer = new JsonSerializer();

            serializer.Formatting        = Formatting.Indented;
            serializer.NullValueHandling = NullValueHandling.Ignore;
            using (StreamWriter streamWriter = new StreamWriter(stream))
                using (JsonWriter jsonWriter = new JsonTextWriter(streamWriter))
                {
                    serializer.Serialize(jsonWriter, json);
                }
        }
コード例 #15
0
ファイル: ProjectJsonConverter.cs プロジェクト: jblj/mobile
        public ProjectData Import (IDataStoreContext ctx, ProjectJson json, Guid? localIdHint = null, bool forceUpdate = false)
        {
            var data = GetByRemoteId<ProjectData> (ctx, json.Id.Value, localIdHint);

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (data == null || forceUpdate || data.ModifiedAt < json.ModifiedAt) {
                data = data ?? new ProjectData ();
                Merge (ctx, data, json);
                data = ctx.Put (data);
            }

            return data;
        }
コード例 #16
0
        public static Project Convert(ProjectJson projectJson)
        {
            var project = new Project
            {
                Id          = projectJson.Id,
                Anons       = projectJson.Anons,
                Content     = projectJson.Content,
                CreatedAt   = projectJson.CreatedAt,
                Description = projectJson.Description,
                Keywords    = projectJson.Keywords,
                Title       = projectJson.Title,
                UpdatedAt   = projectJson.UpdatedAt,
                Image       = $"http://lab.websokol.ru/{projectJson.Image}"
            };

            return(project);
        }
コード例 #17
0
        public static void CreateAzureDataFactoryJson(AzureDataFactoryProject projectNode)
        {
            ProjectJson projectJson = ProjectGenerator.SetProjectJson(projectNode);

            string projectOutputPath = Path.Combine(Properties.Instance.OutputDirectory !, projectNode.Name);

            var options = new JsonSerializerOptions
            {
                WriteIndented        = true,
                IgnoreNullValues     = true,
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };

            WriteJson(projectJson.DataSets, projectOutputPath, options);
            WriteJson(projectJson.LinkedServices, projectOutputPath, options);
            WriteJson(projectJson.Pipelines, projectOutputPath, options);
        }
コード例 #18
0
        public void Save(string path)
        {
            var projectFile = new FileInfo(path);

            projectFile.Directory.Create();

            var xml = GetXML();

            File.WriteAllText(path, xml.ToString());

            if (ProjectJson != null)
            {
                var jsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(
                    projectFile.Directory.FullName,
                    Path.GetFileNameWithoutExtension(ProjectPath));

                File.WriteAllText(jsonPath, ProjectJson.ToString());
            }
        }
コード例 #19
0
        public static void SetLinkedServices(AzureDataFactoryProject projectNode, ProjectJson projectJson)
        {
            if (projectNode?.LinkedServices != null)
            {
                List <LinkedServiceJson> linkedServices = new();

                foreach (LinkedService linkedService in projectNode.LinkedServices)
                {
                    LinkedServiceJson linkedServiceJson = new();
                    linkedServiceJson.Name = linkedService.Name;

                    SetLinkedServiceProperties(linkedService, linkedServiceJson);

                    linkedServices.Add(linkedServiceJson);
                }

                projectJson.LinkedServices = linkedServices;
            }
        }
コード例 #20
0
        public static void SetDataSets(AzureDataFactoryProject projectNode, ProjectJson projectJson)
        {
            if (projectNode?.DataSets != null)
            {
                List <DataSetJson> datasets = new();

                foreach (DataSet dataset in projectNode.DataSets)
                {
                    DataSetJson datasetJson = new();

                    datasetJson.Name = dataset.Name;

                    SetDataSetProperties(dataset, datasetJson);

                    datasets.Add(datasetJson);
                }

                projectJson.DataSets = datasets;
            }
        }
コード例 #21
0
        public void ImportUpdatedOverwriteRejectedLocal()
        {
            RunAsync(async delegate {
                var workspaceData = await DataStore.PutAsync(new WorkspaceData()
                {
                    RemoteId   = 1,
                    Name       = "Test",
                    ModifiedAt = new
                                 DateTime(2014, 1, 2),
                });
                var clientData = await DataStore.PutAsync(new ClientData()
                {
                    RemoteId    = 2,
                    Name        = "Github",
                    WorkspaceId = workspaceData.Id,
                    ModifiedAt  = new DateTime(2014, 1, 3),
                });
                var projectData = await DataStore.PutAsync(new ProjectData()
                {
                    RemoteId       = 2,
                    Name           = "",
                    WorkspaceId    = workspaceData.Id,
                    ClientId       = clientData.Id,
                    ModifiedAt     = new DateTime(2014, 1, 2, 10, 1, 0, DateTimeKind.Utc),
                    IsDirty        = true,
                    RemoteRejected = true,
                });
                var projectJson = new ProjectJson()
                {
                    Id          = 3,
                    Name        = "Hosting",
                    WorkspaceId = 1,
                    ClientId    = 2,
                    ModifiedAt  = new DateTime(2014, 1, 2, 10, 0, 0, DateTimeKind.Utc).ToLocalTime(),
                };

                projectData = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, projectJson));
                Assert.AreEqual("Hosting", projectData.Name);
                Assert.AreEqual(new DateTime(2014, 1, 2, 10, 0, 0, DateTimeKind.Utc), projectData.ModifiedAt);
            });
        }
コード例 #22
0
        private static void ImportJson (IDataStoreContext ctx, ProjectData data, ProjectJson json)
        {
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);
            var clientId = GetLocalId<ClientData> (ctx, json.ClientId);

            data.Name = json.Name;
            try {
                data.Color = Convert.ToInt32 (json.Color);
            } catch {
                data.Color = ProjectModel.DefaultColor;
            }
            data.IsActive = json.IsActive;
            data.IsBillable = json.IsBillable;
            data.IsPrivate = json.IsPrivate;
            data.IsTemplate = json.IsTemplate;
            data.UseTasksEstimate = json.UseTasksEstimate;
            data.WorkspaceId = workspaceId;
            data.ClientId = clientId;

            ImportCommonJson (data, json);
        }
コード例 #23
0
        private static void ImportJson(IDataStoreContext ctx, ProjectData data, ProjectJson json)
        {
            var workspaceId = GetLocalId <WorkspaceData> (ctx, json.WorkspaceId);
            var clientId    = GetLocalId <ClientData> (ctx, json.ClientId);

            data.Name = json.Name;
            try {
                data.Color = Convert.ToInt32(json.Color);
            } catch {
                data.Color = ProjectModel.DefaultColor;
            }
            data.IsActive         = json.IsActive;
            data.IsBillable       = json.IsBillable;
            data.IsPrivate        = json.IsPrivate;
            data.IsTemplate       = json.IsTemplate;
            data.UseTasksEstimate = json.UseTasksEstimate;
            data.WorkspaceId      = workspaceId;
            data.ClientId         = clientId;

            ImportCommonJson(data, json);
        }
コード例 #24
0
        public void ImportNew()
        {
            RunAsync(async delegate {
                var workspaceData = await DataStore.PutAsync(new WorkspaceData()
                {
                    RemoteId   = 1,
                    Name       = "Test",
                    ModifiedAt = new
                                 DateTime(2014, 1, 2),
                });
                var clientData = await DataStore.PutAsync(new ClientData()
                {
                    RemoteId    = 2,
                    Name        = "Github",
                    WorkspaceId = workspaceData.Id,
                    ModifiedAt  = new DateTime(2014, 1, 3),
                });

                var projectJson = new ProjectJson()
                {
                    Id          = 3,
                    Name        = "Hosting",
                    WorkspaceId = 1,
                    ClientId    = 2,
                    ModifiedAt  = new DateTime(2014, 1, 3),
                };

                var projectData = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, projectJson));
                Assert.AreNotEqual(Guid.Empty, projectData.Id);
                Assert.AreEqual(3, projectData.RemoteId);
                Assert.AreEqual("Hosting", projectData.Name);
                Assert.AreEqual(new DateTime(2014, 1, 3), projectData.ModifiedAt);
                Assert.AreEqual(workspaceData.Id, projectData.WorkspaceId);
                Assert.AreEqual(clientData.Id, projectData.ClientId);
                Assert.IsFalse(projectData.IsDirty);
                Assert.IsFalse(projectData.RemoteRejected);
                Assert.IsNull(projectData.DeletedAt);
            });
        }
コード例 #25
0
        public ProjectData Import (IDataStoreContext ctx, ProjectJson json, Guid? localIdHint = null, ProjectData mergeBase = null)
        {
            var log = ServiceContainer.Resolve<ILogger> ();

            var data = GetByRemoteId<ProjectData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ProjectMerger (mergeBase) : null;
            if (merger != null && data != null) {
                merger.Add (new ProjectData (data));
            }

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    log.Info (Tag, "Deleting local data for {0}.", data.ToIdString ());
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ProjectData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                if (merger != null) {
                    log.Info (Tag, "Importing {0}, merging with local data.", data.ToIdString ());
                } else {
                    log.Info (Tag, "Importing {0}, replacing local data.", data.ToIdString ());
                }

                data = ctx.Put (data);
            } else {
                log.Info (Tag, "Skipping import of {0}.", json.ToIdString ());
            }

            return data;
        }
コード例 #26
0
        // POST api/<controller>

        public string Post([FromBody] ProjectJson para)
        {
            Debug.Write("Post");


            HttpContext context = HttpContext.Current;
            var         Request = context.Request;
            var         work1   = Request.UrlReferrer.Host;
            var         work2   = Request.UrlReferrer.LocalPath;
            var         work3   = Request.UrlReferrer.Port;
            ////Debug.Write(work);

            var work = new List <string>();

            work.Add(para.Item);
            work.Add(para.Func);
            work.Add(para.Json);

            XmlDocument xmlDoc = makeXmlDoc("POST" + "[" + string.Join("][", work) + "]");

            return(xmlDoc.OuterXml);
        }
コード例 #27
0
        public bool WriteProjectJsonFile()
        {
            ProjectJson projectJson = new ProjectJson(this.dependencies, this.framework, this.runtimes);
            string      jsonContent = new JavaScriptSerializer().Serialize(projectJson);

            try
            {
                if (File.Exists(ProjectJsonFilePath))
                {
                    File.Delete(ProjectJsonFilePath);
                }

                File.WriteAllText(ProjectJsonFilePath, jsonContent);
            }
            catch (Exception ex)
            {
                OnExceptionThrown(ex);

                return(false);
            }

            return(true);
        }
コード例 #28
0
        public Project Read(string path)
        {
            ProjectJson projectJson = JsonConvert.DeserializeObject <ProjectJson>(File.ReadAllText(path));

            return(projectJson.Generate(path));
        }
コード例 #29
0
        public Task DeleteProject(ProjectJson jsonObject)
        {
            var url = new Uri(v8Url, String.Format("projects/{0}", jsonObject.Id.Value.ToString()));

            return(DeleteObject(url));
        }
コード例 #30
0
        public Task <ProjectJson> CreateProject(ProjectJson jsonObject)
        {
            var url = new Uri(v8Url, "projects");

            return(CreateObject(url, jsonObject));
        }
コード例 #31
0
        public override bool Execute()
        {
            var baseResult = base.Execute();

            if (baseResult == false)
            {
                return(false);
            }

            TapAssetDir = this.GetAssetDir();
            if (String.IsNullOrEmpty(TapAssetDir))
            {
                Log.LogError($"{Consts.TapAssetsDir} folder not found, exiting");
                return(false);
            }


            var securitySettings = this.GetSecurity();

            if (securitySettings == null)
            {
                Log.LogError($"{Consts.TapSecurityFile} file not set, please see solution root and complete");
                return(false);
            }

            TapAppId = new TaskItem(_tapSetting.TapAppId);

            var token = this.Login(securitySettings);

            if (token == null)
            {
                Log.LogError("Authentication failure");
                return(false);
            }

            var unmodifedProjectName = ProjectName.Replace(Consts.ModifiedProjectNameExtra, String.Empty);
            var url = String.Concat(TapSettings.GetMetadata(MetadataType.TapEndpoint), Consts.TapClientEndpoint, "?", "tapAppId=", _tapSetting.TapAppId, "&projectName=", unmodifedProjectName, "&buildConfiguration=", BuildConfiguration);

            LogInformation("Loading tap build config from '{0}'", url);

            string jsonClientConfig = null;

            try
            {
                using (WebClient client = new WebClient())
                {
                    client.SetWebClientHeaders(token);

                    jsonClientConfig = client.DownloadString(url);
                    LogInformation("Successfully loaded tap build config from '{0}', recieved '{1}'", url, jsonClientConfig.Length);
                    LogDebug("Json data recieved\n{0}", jsonClientConfig);
                    //write to file
                    //deserialise now (extension method)
                    //return object
                }
            }
            catch (WebException ex) {
                var response = ex.Response as HttpWebResponse;
                if (response == null)
                {
                    Log.LogError($"Unknown server api error {response.StatusCode.ToString()}, exiting");
                    //Log.LogErrorFromException(ex);
                    return(false);
                }

                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    Log.LogError($"Build configuration or Tap App Id not found on server, exiting");
                    TapShouldContinue = bool.FalseString;
                    return(false);
                }

                //TODO load client config from projects if no web available and run anyway
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex);
                return(false);
            }


            ClientConfigDto clientConfigDto = this.GetClientConfig(jsonClientConfig);

            if (clientConfigDto == null)
            {
                return(false);
            }

            if (clientConfigDto.AppIcon.Succeeded == false ||
                clientConfigDto.Splash.Succeeded == false)
            {
                foreach (var message in clientConfigDto.AppIcon.Messages.Where(x => x.MessageImportanceTypeValue ==
                                                                               MessageImportanceType.Error.Value))
                {
                    Log.LogError(message.MessageBody);
                }
                foreach (var message in clientConfigDto.Splash.Messages.Where(x => x.MessageImportanceTypeValue ==
                                                                              MessageImportanceType.Error.Value))
                {
                    Log.LogError(message.MessageBody);
                }
                return(false);
            }

            MediaAccessKey = new TaskItem(clientConfigDto.MediaAccessKey);
            //this is not quite identical in base

            var projectsConfig = this.GetProjectsConfig();

            var projectConfig = projectsConfig.Projects.FirstOrDefault(x => x.BuildConfiguration == BuildConfiguration);

            if (projectConfig == null)
            {
                projectConfig = new ProjectJson();
                projectsConfig.Projects.Add(projectConfig);
            }

            projectConfig.BuildConfiguration = BuildConfiguration;
            projectConfig.ClientConfig       = clientConfigDto;
            if (!this.SaveProjects(projectsConfig))
            {
                return(false);
            }

            //this is identical in base

            AssetCatalogueName = this.GetAssetCatalogueName(projectConfig.ClientConfig, TargetFrameworkIdentifier);

            BuildConfigHolderOutput  = this.GetHolderOutput(projectConfig.ClientConfig.BuildConfig, "Build config");
            PackagingHolderOutput    = this.GetHolderOutput(projectConfig.ClientConfig.Packaging, "Packaging");
            AppIconHolderOutput      = this.GetHolderOutput(projectConfig.ClientConfig.AppIcon, "App icon");
            SplashHolderOutput       = this.GetHolderOutput(projectConfig.ClientConfig.Splash, "Splash");
            FileExchangeHolderOutput = this.GetHolderOutput(projectConfig.ClientConfig.FileExchange, "FileExchange");

            AppIconFieldOutput = this.GetMediaFieldOutput(projectConfig.ClientConfig.AppIcon.Fields, AssetCatalogueName, projectConfig.ClientConfig, AppIconHolderOutput);

            SplashFieldOutput = this.GetMediaFieldOutput(projectConfig.ClientConfig.Splash.Fields, AssetCatalogueName, projectConfig.ClientConfig, SplashHolderOutput);

            PackagingFieldOutput = this.GetStringFieldOutput(projectConfig.ClientConfig.Packaging.Fields, PackagingHolderOutput);

            FileExchangeFieldOutput = this.GetFileExchangeFieldOutput(projectConfig.ClientConfig.FileExchange.Fields, FileExchangeHolderOutput);

            return(true);
        }
コード例 #32
0
 public static CreateProject AddCSharpProjectJson(this CreateProject project, ProjectJson type)
 {
     CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "project.json") { Template = GetProjectJson(project, type) });
     project.Add(file);
     return project;
 }
コード例 #33
0
ファイル: Workspace.cs プロジェクト: kutselabskii/Citrus
 public void SaveCurrentProject()
 {
     ProjectJson.RewriteOrigin();
 }