public Project AddUnauthorizePartner(KeyValuePair <string, string> pair, RestViewModal modal) { PrService service = new PrService() { Services = modal.Services, UserName = pair.Key, Password = pair.Value, }; service.Request = new List <ProjectServer>(); var projectSerice = new ProjectServer() { UserName = pair.Key, Password = pair.Value, Url = modal.Url }; service.Request.Add(projectSerice); Project newProject = new Project() { ProjectService = new List <PrService>() { service }, IsActive = false, DateTime = DateTime.Now, PrjectStatus = AuthModel.Enum.UserStatus.NotActivated, }; Add(newProject); return(newProject); }
public List <PSHPDP> GetAllPDP() { List <PSHPDP> lstPDP = new List <PSHPDP>(); using (var clientContext = new ClientContext(_PWAUrl)) { clientContext.Credentials = new System.Net.NetworkCredential(_UserName, _Password); var projectContext = new ProjectServer(clientContext); var objPDPCollection = projectContext.ProjectDetailPages; clientContext.Load(objPDPCollection); clientContext.ExecuteQuery(); if (objPDPCollection.AreItemsAvailable) { foreach (ProjectDetailPage oPage in objPDPCollection) { lstPDP.Add(new PSHPDP() { PDPName = oPage.Name, PDPGuid = oPage.Id }); } } } return(lstPDP); }
public string AddPhase(string PhaseName, string Description) { string success = string.Empty; try { using (var clientContext = new ClientContext(_PWAUrl)) { clientContext.Credentials = new System.Net.NetworkCredential(_UserName, _Password); var projectContext = new ProjectServer(clientContext); clientContext.Load(projectContext.Phases); clientContext.ExecuteQuery(); PhaseCreationInformation objPhaseCreation = new PhaseCreationInformation(); objPhaseCreation.Name = PhaseName; objPhaseCreation.Description = Description; projectContext.Phases.Add(objPhaseCreation); projectContext.Phases.Update(); clientContext.ExecuteQuery(); success = "Success"; } } catch (Exception ex) { success = ex.Message; } return(success); }
public IEnumerator RefreshProjectListCoroutine() { onProjectsRefreshBegin?.Invoke(); m_Projects.Clear(); ProjectServer.Init(); var user = ProjectServer.UnityUser; var projects = new List <Project>(); if (user != null) { // Use ContinueWith to make sure the task doesn't throw var task = Task.Run(() => ProjectServer.Client.ListProjects(user, m_LocalStorage)).ContinueWith(t => t); while (!task.IsCompleted) { yield return(null); } var listTask = task.Result; if (listTask.IsFaulted) { Debug.LogException(listTask.Exception); onError?.Invoke(listTask.Exception); onProjectsRefreshEnd?.Invoke(); yield break; } var result = listTask.Result; if (result.Status == UnityProjectCollection.StatusOption.AuthenticationError) { // NOTE: Keep on going, we may be able to display offline data } else if (result.Status == UnityProjectCollection.StatusOption.ComplianceError) { onError?.Invoke(new ProjectListRefreshException(result.ErrorMessage, result.Status)); // NOTE: Keep on going, we may be able to display offline data } else if (result.Status != UnityProjectCollection.StatusOption.Success) { // Log error with details but report simplified message in `onError` event Debug.LogError($"Project list refresh failed: {result.ErrorMessage}"); onError?.Invoke(new ProjectListRefreshException($"Could not connect to Reflect cloud service, check your internet connection.", result.Status)); // NOTE: Keep on going, we may be able to display offline data } projects.AddRange(listTask.Result.Select(p => new Project(p))); } projects.ForEach(p => UpdateProjectInternal(p, true)); var projectIds = projects.Select(p => p.serverProjectId); var removedProjectIds = m_Projects.Keys.Except(projectIds).ToList(); removedProjectIds.ForEach(RemoveProjectInternal); onProjectsRefreshEnd?.Invoke(); }
FileBasedProject SetupServerProjectLocalCopy(Guid projectId, string locationOfLocalCopy) { Uri serverAddress = new Uri("http://myServerAddress:80"); ProjectServer server = new ProjectServer(serverAddress, false, "MyUser", "MyPassword"); FileBasedProject project = server.OpenProject(projectId, locationOfLocalCopy); return(project); }
public async Task <IRestResponse> Send(ProjectServer server, RestViewModal model) { var client = CreateClient(server.Url, model); ParseServer(server, model, client); var request = CreateRequest(model); return(client.Execute(request)); }
public string AddPDP2Stage(List <PDPStageMapping> Mapping) { string success = string.Empty; try { using (var clientContext = new ClientContext(_PWAUrl)) { clientContext.Credentials = new System.Net.NetworkCredential(_UserName, _Password); var projectContext = new ProjectServer(clientContext); var objPDPCollection = projectContext.ProjectDetailPages; clientContext.Load(objPDPCollection); clientContext.Load(projectContext.Stages); clientContext.ExecuteQuery(); if (objPDPCollection.AreItemsAvailable) { foreach (PDPStageMapping objmap in Mapping) { ProjectDetailPage objNewPage = objPDPCollection.GetByGuid(objmap.PDPId); Stage stage = projectContext.Stages.GetByGuid(objmap.StageId); clientContext.Load(objNewPage); clientContext.Load(stage); clientContext.ExecuteQuery(); clientContext.Load(stage.ProjectDetailPages); clientContext.ExecuteQuery(); Guid pdpGuid = objNewPage.Id; int objOldStageDetail = stage.ProjectDetailPages.Where(x => x.Id == pdpGuid).Count(); if (objOldStageDetail == 0) { StageDetailPageCreationInformation objPDPCreationInfo = new StageDetailPageCreationInformation(); objPDPCreationInfo.Id = pdpGuid; objPDPCreationInfo.Position = 1; objPDPCreationInfo.RequiresAttention = false; objPDPCreationInfo.Description = objNewPage.Name; StageDetailPage objStageDetail = stage.ProjectDetailPages.Add(objPDPCreationInfo); projectContext.Stages.Update(); clientContext.ExecuteQuery(); success = "Success"; } } } } } catch (Exception ex) { success = ex.Message; } return(success); }
void DeleteProjectFromServer(Guid projectId) { #region "DeleteProjectFromServer" Uri serverAddress = new Uri("http://myServerAddress:80"); ProjectServer server = new ProjectServer(serverAddress, false, "MyUser", "MyPassword"); server.DeleteProject(projectId); #endregion }
public async Task <IRestResponse> Send(ProjectServer server, RestViewModal model, SendModal sms) { var client = CreateClient(server.Url, model); ParseServer(server, model, client); RestRequest request = new RestRequest(Method.POST); request.AddJsonBody(sms); return(client.Execute(request)); }
public void GetAllProjects() { using (var clientContext = new ClientContext(_PWAUrl)) { clientContext.Credentials = new System.Net.NetworkCredential(_UserName, _Password); var projectContext = new ProjectServer(clientContext); clientContext.Load(projectContext.Projects); clientContext.ExecuteQuery(); } }
ServerProjectInfo ViewProjectByQualifiedName() { #region "ViewProjectByQualifiedName" Uri serverAddress = new Uri("http://myServerAddress:80"); ProjectServer server = new ProjectServer(serverAddress, false, "MyUser", "MyPassword"); ServerProjectInfo project = server.GetServerProject("/MyOrganization/MyProject"); #endregion return(project); }
ServerProjectInfo[] ViewProjectsOnServer() { #region "ViewProjectsOnServer" Uri serverAddress = new Uri("http://myServerAddress:80"); string organizationPath = "/LocationOnServerToStartListFrom"; ProjectServer server = new ProjectServer(serverAddress, false, "MyUser", "MyPassword"); ServerProjectInfo[] projects = server.GetServerProjects(organizationPath, true, false); #endregion return(projects); }
public ActionResult Index(int?id) { string vid = Request["vid"]; if (vid == null || vid.ToString().Trim() == "") { vid = ""; } ScadaFlowModel model = new ScadaFlowModel(); if (vid == "") { string para = Request.QueryString["id"].Split('?')[0]; string[] idarray = Request.QueryString["id"].Split('?').Length >= 2 ? Request.QueryString["id"].Split('?')[1].Split('=') : null; string idstr = "0"; if (idarray != null && idarray.Length >= 2) { idstr = Request.QueryString["id"].Split('?')[1].Split('=')[1]; } else { idstr = id.ToString(); } if (para != null && para != "") { id = int.Parse(para); } } ScadaFlowProjectModel Project = ProjectServer.GetById(id.Value); if (Project != null && vid == "") { ScadaFlowViewModel view = ViewServer.GetByWhere(" where ProjectId='" + Project.ProjectId + "'").First(); model.Project = Project; model.MainView = view; } else if (vid != "") { ScadaFlowViewModel view = ViewServer.GetByWhere(" where ViewId='" + vid + "'").First(); if (view != null) { Project = ProjectServer.GetByWhere(" where ProjectId='" + view.ProjectId + "'").First(); model.Project = Project; model.MainView = view; } } return(View(model)); }
public string AddStage(string StageName, string Description, Guid PhaseId, Guid WorkflowStatusPageId, List <PSHPDP> listPDPs) { string success = string.Empty; try { using (var clientContext = new ClientContext(_PWAUrl)) { clientContext.Credentials = new System.Net.NetworkCredential(_UserName, _Password); var projectContext = new ProjectServer(clientContext); var objPDPCollection = projectContext.ProjectDetailPages; clientContext.Load(objPDPCollection); clientContext.Load(projectContext.Stages); clientContext.ExecuteQuery(); List <StageDetailPageCreationInformation> listPDPCreationInfo = new List <StageDetailPageCreationInformation>(); foreach (PSHPDP objPDP in listPDPs) { StageDetailPageCreationInformation objPDPCreationInfo = new StageDetailPageCreationInformation(); objPDPCreationInfo.Id = objPDP.PDPGuid; objPDPCreationInfo.Position = 1; objPDPCreationInfo.RequiresAttention = false; objPDPCreationInfo.Description = objPDP.PDPName; listPDPCreationInfo.Add(objPDPCreationInfo); } StageCreationInformation objStgCreation = new StageCreationInformation(); objStgCreation.Name = StageName; objStgCreation.Description = Description; objStgCreation.PhaseId = PhaseId; objStgCreation.WorkflowStatusPageId = WorkflowStatusPageId; objStgCreation.ProjectDetailPages = listPDPCreationInfo; projectContext.Stages.Add(objStgCreation); projectContext.Stages.Update(); clientContext.ExecuteQuery(); success = "Success"; } } catch (Exception ex) { success = ex.Message; } return(success); }
static int Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: codesync <config_file>"); return(1); } FileInfo fileInfo = new FileInfo(args[0]); if (!fileInfo.Exists) { Console.WriteLine($"Can't access file at {args[0]}."); return(1); } string directoryPath = new FileInfo(args[0]).DirectoryName; string absoluteConfigPath = Path.GetFullPath(args[0]); Directory.SetCurrentDirectory(directoryPath); Console.WriteLine($"Set working directory to {directoryPath}."); string configContents = File.ReadAllText(absoluteConfigPath); config = JsonConvert.DeserializeObject <Config>(configContents); config.FileLocation = args[0]; Console.WriteLine($"Config loaded from {args[0]}."); ValidationResult validationResult = config.Validate(); if (!validationResult.Valid) { Console.WriteLine("Malformed config: {0}", validationResult.Message); Console.ReadLine(); return(1); } ProjectServer server = new ProjectServer(config); Console.WriteLine($"CodeSync server starting on port {config.Port}."); server.Start(); return(0); }
void LookForAProjectAndCreateWorkSpace() { #region "LookForAProjectAndCreateWorkSpace" string rootLocalProjectLocation = @"C:\Projects\"; Uri serverAddress = new Uri("http://myServerAddress:80"); ProjectServer server = new ProjectServer(serverAddress, false, "MyUser", "MyPassword"); ServerProjectInfo projectInfo = server.GetServerProject("/MyOrganizationName/MyProjectName"); FileBasedProject project; if (projectInfo != null) { project = server.OpenProject(projectInfo.ProjectId, rootLocalProjectLocation + projectInfo.Name); } #endregion }
public List <PSHPhase> GetAllPhases() { List <PSHPhase> lstPhases = new List <PSHPhase>(); using (var clientContext = new ClientContext(_PWAUrl)) { clientContext.Credentials = new System.Net.NetworkCredential(_UserName, _Password); var projectContext = new ProjectServer(clientContext); //var objPDPCollection = projectContext.ProjectDetailPages; clientContext.Load(projectContext.Phases); clientContext.ExecuteQuery(); foreach (Phase oPhase in projectContext.Phases) { lstPhases.Add(new PSHPhase() { PhaseGuid = oPhase.Id, PhaseName = oPhase.Name }); } } return(lstPhases); }
void ServerPuttingItAllTogether() { const string tmServerPrefix = "sdltm."; string localcopylocation = @"C:\Projects\"; string serverName = "http://myServerAddress:80"; Uri serverAddress = new Uri(serverName); string organizationPath = "/MyOrganizationPath"; ProjectServer server = new ProjectServer(serverAddress, false, "MyUser", "MyPassword"); ServerProjectInfo projectInfo = server.GetServerProject("/MyOrganization/MyProject"); FileBasedProject project; if (projectInfo != null) { project = server.OpenProject(projectInfo.ProjectId, localcopylocation + projectInfo.Name); ProjectFile[] sourceFiles = project.GetSourceLanguageFiles(); project.UndoCheckoutFiles(sourceFiles.GetIds()); //Add a server based translation provider Uri tmAddress = new Uri(String.Format("{0}{1}{2}/{3}", tmServerPrefix, serverAddress, organizationPath, "UnitTestTm")); TranslationProviderConfiguration tmConfig = project.GetTranslationProviderConfiguration(); tmConfig.Entries.Add ( new TranslationProviderCascadeEntry ( new TranslationProviderReference(tmAddress), true, true, true, 0 ) ); //The credentials for a server based TM are keyed to the server address without path or tm name project.Credentials.AddCredential(serverAddress, "user=sa;password=sa;type=CustomUser"); project.UpdateTranslationProviderConfiguration(tmConfig); List <TaskStatusEventArgs> taskStatusEventArgsList = new List <TaskStatusEventArgs>(); List <MessageEventArgs> messageEventArgsList = new List <MessageEventArgs>(); // Run tasks for source files to create target files AutomaticTask scanTask = project.RunAutomaticTask( sourceFiles.GetIds(), AutomaticTaskTemplateIds.Scan, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); AutomaticTask convertTask = project.RunAutomaticTask( sourceFiles.GetIds(), AutomaticTaskTemplateIds.ConvertToTranslatableFormat, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); AutomaticTask copyToTargetTask = project.RunAutomaticTask( sourceFiles.GetIds(), AutomaticTaskTemplateIds.CopyToTargetLanguages, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); // Run tasks for target files ProjectFile[] targetFiles = project.GetTargetLanguageFiles(); AutomaticTask perfectMatchTask = project.RunAutomaticTask( targetFiles.GetIds(), AutomaticTaskTemplateIds.PerfectMatch, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); AutomaticTask analyseTask = project.RunAutomaticTask( targetFiles.GetIds(), AutomaticTaskTemplateIds.AnalyzeFiles, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); AutomaticTask preTranslateTask = project.RunAutomaticTask( targetFiles.GetIds(), AutomaticTaskTemplateIds.PreTranslateFiles, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); AutomaticTask populateProjTmTask = project.RunAutomaticTask( targetFiles.GetIds(), AutomaticTaskTemplateIds.PopulateProjectTranslationMemories, (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs), (sender, messageArgs) => messageEventArgsList.Add(messageArgs)); //Check in the new target files targetFiles = project.GetTargetLanguageFiles(); project.CheckinFiles(targetFiles.GetIds(), "Target Files Created and Pre-translated", null); //Save the project back to disk project.Save(); } }
public void ParseServer(ProjectServer server, RestViewModal model, RestClient client) { }
public void Cancel() { ProjectServer.Cleanup(); }
public JsonResult Login(loginModel model) { string username = model.username, password = model.password, viewId = model.viewId, projId = model.projId; AjaxResult error = new AjaxResult { state = ResultType.error.ToString(), message = "登录失败" }; AjaxResult success = new AjaxResult { state = ResultType.success.ToString(), message = "登录成功" }; var result = error.SetMsg("禁止登录"); LogonLogModel logEntity = new LogonLogModel(); logEntity.LogType = DbLogType.Login.ToString(); try { ScadaFlowProjectModel Project = null; if (viewId != null && viewId != "" && viewId != "0") { ScadaFlowViewModel view = ViewServer.GetByWhere(" where ViewId='" + viewId + "'").First(); if (view != null) { Project = ProjectServer.GetByWhere(" where ProjectId='" + view.ProjectId + "'").First(); model.projId = Project.Id.ToString(); model.viewId = view.ViewId; } string nickname = ""; bool isUser = ProjectServer.LoginOn(username, password, Project.Id.ToString(), out nickname); if (isUser == true) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = 0; operatorModel.Account = username; operatorModel.RealName = nickname; operatorModel.HeadIcon = ""; operatorModel.RoleId = 0; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(Net.Ip); OperatorFlowProvider.Provider.AddCurrent(operatorModel); logEntity.Account = username; logEntity.RealName = nickname; logEntity.Description = Project.Title + "(" + Project.Id + ")工程的 " + nickname + "登陆成功!"; LogonLogService.WriteDbLog(logEntity); result = success.SetMsg(nickname + "登陆成功"); result.data = Json(model).Data; return(Json(result)); } else { result = error.SetMsg("用户名或密码错误"); return(Json(result)); } } else { logEntity.Account = username; logEntity.RealName = username; logEntity.Description = "登录失败,登录页面不存在"; LogonLogService.WriteDbLog(logEntity); result = error.SetMsg(logEntity.Description); return(Json(result)); } } catch (Exception ex) { logEntity.Account = username; logEntity.RealName = username; logEntity.Description = "登录失败," + ex.Message; LogonLogService.WriteDbLog(logEntity); result = error.SetMsg(logEntity.Description); return(Json(result)); } }
public async Task <IRestResponse> Send(ProjectServer server, RestViewModal modal) { return(await _req.Send(server, modal)); }