void ListBucketWebResponse(object sender, ResponseEventArgs args) { AmazonS3Exception result = args.Response as AmazonS3Exception; S3Common.client.OnS3Response -= ListBucketWebResponse; if (null != result) { S3ErrorResponse(result); return; } ListBucketsResponse response = args.Response as ListBucketsResponse; this.Dispatcher.BeginInvoke(() => { BucketNames.Clear(); this.BucketNameSelected = false; response.Buckets.ToList().ForEach(b => BucketNames.Add(b.BucketName)); }); }
internal static string CreateNewProject(string projectName, string userEmail, string clientId, int compilerVersion, ProjectType projectType = ProjectType.NEWPROJECT, ProjectStatus projectStatus = ProjectStatus.IDLE) { try { if (_kitsuneServer == null) { InitializeConnection(); } var kitsuneProjectCollection = _kitsuneDatabase.GetCollection <KitsuneProject>(KitsuneProjectsCollectionName); var projectId = ObjectId.GenerateNewId().ToString(); DateTime datetime = DateTime.Now; #region Create Kitsune Project BucketNames bucketNames = new BucketNames { source = AmazonAWSConstants.SourceBucketName, demo = AmazonAWSConstants.DemoBucketName, placeholder = AmazonAWSConstants.PlaceHolderBucketName, production = AmazonAWSConstants.ProductionBucketName }; KitsuneProject newProject = new KitsuneProject() { CreatedOn = datetime, UpdatedOn = datetime, IsArchived = false, ProjectId = projectId, ProjectName = projectName, UserEmail = userEmail, BucketNames = bucketNames, ProjectType = projectType, ProjectStatus = projectStatus, PublishedVersion = 0, Version = 1, CompilerVersion = compilerVersion }; kitsuneProjectCollection.InsertOne(newProject); #endregion #region Create Default Customer try { CreateDefaultWebsite(projectId, projectName, userEmail, clientId); } catch (Exception ex) { //Log Error creating New Customer } #endregion #region Create Settings File if (!CreateDefaultSettingsFile(projectId)) { //TODO Log error creating default settings file } #endregion #region Create Default Resources var projectResourceCreated = CreateDefaultStaticIndexResource(projectId); #endregion #region SendDeveloperEmail if (!string.IsNullOrEmpty(projectName)) { var UserCollection = _kitsuneDatabase.GetCollection <UserModel>(KitsuneUserCollectionName); var WebsiteCollection = _kitsuneDatabase.GetCollection <KitsuneWebsiteCollection>(KitsuneWebsiteCollectionName); var WebsiteUserCollection = _kitsuneDatabase.GetCollection <KitsuneWebsiteUserCollection>(KitsuneWebsiteUserCollectionName); var websiteDetail = WebsiteCollection.Find(x => x.ProjectId == projectId).FirstOrDefault(); if (websiteDetail != null) { string websiteId = websiteDetail._id; KitsuneWebsiteUserCollection websiteUser = WebsiteUserCollection.Find(x => x.WebsiteId.Equals(websiteId)).SortBy(x => x.CreatedOn).FirstOrDefault(); if (websiteUser != null) { string username = websiteUser.UserName; string password = websiteUser.Password; string developerId = websiteUser.DeveloperId; if (!String.IsNullOrEmpty(developerId)) { var userDetails = UserCollection.Find(x => x._id.Equals(developerId)).FirstOrDefault(); if (userDetails != null) { Dictionary <string, string> optionalParameters = new Dictionary <string, string> { { EnvConstants.Constants.EmailParam_KAdminUserName, websiteUser.UserName }, { EnvConstants.Constants.EmailParam_KAdminPassword, websiteUser.Password } }; optionalParameters[EnvConstants.Constants.EmailParam_KAdminUrl] = string.Format(EnvConstants.Constants.KAdminBaseUrl, websiteDetail.WebsiteUrl).ToLower(); optionalParameters[EnvConstants.Constants.EmailParam_ProjectName] = projectName; ///TODO : Put first name once its added on user creation optionalParameters[EnvConstants.Constants.EmailParam_DeveloperName] = userDetails.DisplayName; EmailHelper emailHelper = new EmailHelper(); emailHelper.SendGetKitsuneEmail(string.Empty, userDetails.UserName, MailType.DEFAULT_CUSTOMER_KADMIN_CREDENTIALS, null, optionalParameters); } } } } } #endregion return(projectId); } catch (Exception ex) { throw ex; } }