public override void ExecuteCmdlet() { ExecutionBlock(() => { if (!this.IsParameterBound(c => c.EndDate)) { WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); EndDate = StartDate.AddYears(1); } if (this.IsParameterBound(c => c.ServicePrincipalObject)) { ObjectId = ServicePrincipalObject.Id; } if (this.IsParameterBound(c => c.ServicePrincipalName)) { ObjectId = ActiveDirectoryClient.GetObjectIdFromSPN(ServicePrincipalName); } if (Password != null && Password.Length > 0) { string decodedPassword = SecureStringExtensions.ConvertToString(Password); // Create object for password credential var passwordCredential = new PasswordCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = Guid.NewGuid().ToString(), Value = decodedPassword }; if (ShouldProcess(target: ObjectId.ToString(), action: string.Format("Adding a new password to service principal with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateSpPasswordCredential(ObjectId, passwordCredential)); } } else if (this.IsParameterBound(c => c.CertValue)) { // Create object for key credential var keyCredential = new KeyCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = Guid.NewGuid().ToString(), Value = CertValue, Type = "AsymmetricX509Cert", Usage = "Verify" }; if (ShouldProcess(target: ObjectId.ToString(), action: string.Format("Adding a new caertificate to service principal with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateSpKeyCredential(ObjectId, keyCredential)); } } else { throw new InvalidOperationException("No valid keyCredential or passwordCredential to update!!"); } }); }
public Deposit ( int percent, decimal value, AccrualsInterval interv, int periods ) { Percent = percent; Value = value; Interval = interv; StartDate = DateTime.Now; LastAccrual = StartDate; switch (interv) { case AccrualsInterval.minute: FinishDate = StartDate.AddMinutes(periods); break; case AccrualsInterval.month: FinishDate = StartDate.AddMonths(periods); break; case AccrualsInterval.year: FinishDate = StartDate.AddYears(periods); break; } }
public AssetItemViewModel() { Title = "新建"; _model = new AssetItem(); StartDate = DateTime.Today; EndDate = StartDate.AddYears(1); }
public Fund() { this.StartDate = new DateTime(DateTime.Now.Year, 1, 1); this.EndDate = StartDate.AddYears(1); this.OtherServicesMax = 100; this.HomecareMin = 0; this.AdminMax = 100; }
public static DateTimeSpan CompareDates(DateTime StartDate, DateTime EndDate) { DateTimeSpan R = new DateTimeSpan(); if (StartDate.Equals(EndDate)) { return(new DateTimeSpan()); } bool Later; if (Later = StartDate > EndDate) { DateTime D = StartDate; StartDate = EndDate; EndDate = D; } // Calculate Date Stuff for (DateTime D = StartDate.AddYears(1); D < EndDate; D = D.AddYears(1), R.Years++) { ; } if (R.Years > 0) { StartDate = StartDate.AddYears(R.Years); } for (DateTime D = StartDate.AddMonths(1); D < EndDate; D = D.AddMonths(1), R.Months++) { ; } if (R.Months > 0) { StartDate = StartDate.AddMonths(R.Months); } for (DateTime D = StartDate.AddDays(1); D < EndDate; D = D.AddDays(1), R.Days++) { ; } if (R.Days > 0) { StartDate = StartDate.AddDays(R.Days); } // Calculate Time Stuff TimeSpan T1 = EndDate - StartDate; R.Hours = T1.Hours; R.Minutes = T1.Minutes; R.Seconds = T1.Seconds; R.Milliseconds = T1.Milliseconds; // Return answer. Negate values if the Start Date was later than the End Date if (Later) { return(new DateTimeSpan(-R.Years, -R.Months, -R.Days, -R.Hours, -R.Minutes, -R.Seconds, -R.Milliseconds)); } return(R); }
public override void ExecuteCmdlet() { ExecutionBlock(() => { EndDate = StartDate.AddYears(1); if (this.IsParameterBound(c => c.ApplicationObject)) { ObjectId = ApplicationObject.ObjectId; } else if (this.IsParameterBound(c => c.ApplicationId)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); } else if (this.IsParameterBound(c => c.DisplayName)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); } if (Password != null && Password.Length > 0) { string decodedPassword = SecureStringExtensions.ConvertToString(Password); // Create object for password credential var passwordCredential = new PasswordCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = Guid.NewGuid().ToString(), Value = decodedPassword }; if (ShouldProcess(target: ObjectId.ToString(), action: string.Format("Adding a new password to application with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateAppPasswordCredential(ObjectId, passwordCredential)); } } else if (this.IsParameterBound(c => c.CertValue)) { // Create object for key credential var keyCredential = new KeyCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = Guid.NewGuid().ToString(), Value = CertValue, Type = "AsymmetricX509Cert", Usage = "Verify" }; if (ShouldProcess(target: ObjectId.ToString(), action: string.Format("Adding a new certificate to application with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateAppKeyCredential(ObjectId, keyCredential)); } } else { throw new InvalidOperationException("No valid keyCredential or passowrdCredential to update!!"); } }); }
public FeedPoll() { FeedType = FeedType.Poll; PollType = FeedPollType.SimpleAnswer; StartDate = TenantUtil.DateTimeNow(); EndDate = StartDate.AddYears(100); Variants = new List <FeedPollVariant>(); Answers = new List <FeedPollAnswer>(); }
public SimulatorApp() { IConfiguration config = new ConfigurationBuilder().SetBasePath(Path.Combine(AppContext.BaseDirectory)) .AddJsonFile("appsettings.json", true, true) .Build(); int timeSpend = Convert.ToInt32(config.GetSection("SimulationDayLife").Value); EndDate = StartDate.AddDays(timeSpend); PoultryList = new List <IPoultry>() { new Poultry() { BirthDate = StartDate.AddYears(-1), isMale = true, isPregnant = false, PoultryEnum = (int)PoultryEnum.Rabbit }, new Poultry() { BirthDate = StartDate.AddYears(-1), isMale = false, isPregnant = false, PoultryEnum = (int)PoultryEnum.Rabbit } }; }
private IList <MasterFIRecord> GetPrevSalesboardCount() { DateTime prevStartDate = DateHelper.FirstDayOfTheMonth(StartDate.AddYears(-1)); DateTime prevEndDate = DateHelper.LastDayOfTheMonth(StartDate.AddYears(-1)); IList <MasterFIRecord> mRecs = context.MasterFIs .Where(m => m.status != 6 && //No Wholesale ((m.delvdate >= prevStartDate && m.delvdate <= prevEndDate) || (m.delvdate == new DateTime(1900, 1, 1) && m.salesdate >= prevStartDate && m.salesdate <= prevEndDate))) .Select(d => new MasterFIRecord { RecordType = "M", Record = d }).ToList(); var ret = mRecs.Union(context.MasterFIs.Where(m => m.status != 6 && m.unwinddate >= prevStartDate && m.unwinddate <= prevEndDate) .Select(d => new MasterFIRecord { RecordType = "U", Record = d }).ToList()); return(ret.ToList()); }
public ConsoleApplication(ICoopSimulation coopSimulation) { IConfiguration config = new ConfigurationBuilder().SetBasePath(Path.Combine(AppContext.BaseDirectory)) .AddJsonFile("appsettings.json", true, true) .Build(); SimulationCyclesInMonth = Convert.ToInt32(config.GetSection("SimulationCyclesInMonth").Value); _coopSimulation = coopSimulation; _coopSimulation.Time = StartDate; _coopSimulation.Population = new HashSet <IFowl>() { new FemaleRabbit(_coopSimulation) { BirthDate = StartDate.AddYears(-1) }, new MaleRabbit(_coopSimulation) { BirthDate = StartDate.AddYears(-1) }, }; EndDate = StartDate.AddMonths(SimulationCyclesInMonth); }
private void CreateSimpleServicePrincipal() { var subscriptionId = DefaultProfile.DefaultContext.Subscription.Id; if (!this.IsParameterBound(c => c.Scope)) { Scope = string.Format("/subscriptions/{0}", subscriptionId); WriteVerbose(string.Format("No scope provided - using the default scope '{0}'", Scope)); } AuthorizationClient.ValidateScope(Scope, true); if (!this.IsParameterBound(c => c.Role)) { Role = "Contributor"; WriteVerbose(string.Format("No role provided - using the default role '{0}'", Role)); } if (!this.IsParameterBound(c => c.StartDate)) { DateTime currentTime = DateTime.UtcNow; StartDate = currentTime; WriteVerbose("No start date provided - using the current time as default."); } if (!this.IsParameterBound(c => c.EndDate)) { EndDate = StartDate.AddYears(1); WriteVerbose("No end date provided - using the default value of one year after the start date."); } if (!this.IsParameterBound(c => c.DisplayName)) { DisplayName = "azure-powershell-" + StartDate.ToString("MM-dd-yyyy-HH-mm-ss"); WriteVerbose(string.Format("No display name provided - using the default display name of '{0}'", DisplayName)); } var identifierUri = "http://" + DisplayName; // Handle credentials if (!this.IsParameterBound(c => c.Password)) { // If no credentials provided, set the password to a randomly generated GUID Password = Guid.NewGuid().ToString().ConvertToSecureString(); } // Create an application and get the applicationId var passwordCredential = new PSADPasswordCredential() { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), Password = SecureStringExtensions.ConvertToString(Password) }; if (!this.IsParameterBound(c => c.ApplicationId)) { CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters { DisplayName = DisplayName, IdentifierUris = new[] { identifierUri }, HomePage = identifierUri, PasswordCredentials = new PSADPasswordCredential[] { passwordCredential } }; if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName))) { var application = ActiveDirectoryClient.CreateApplication(appParameters); ApplicationId = application.ApplicationId; WriteVerbose(string.Format("No application id provided - created new AD application with application id '{0}'", ApplicationId)); } } CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters { ApplicationId = ApplicationId, AccountEnabled = true, PasswordCredentials = new PSADPasswordCredential[] { passwordCredential } }; if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId))) { var servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters); WriteObject(servicePrincipal); if (this.IsParameterBound(c => c.SkipAssignment)) { WriteVerbose("Skipping role assignment for the service principal."); return; } FilterRoleAssignmentsOptions parameters = new FilterRoleAssignmentsOptions() { Scope = this.Scope, RoleDefinitionName = this.Role, ADObjectFilter = new ADObjectFilterOptions { SPN = servicePrincipal.ApplicationId.ToString(), Id = servicePrincipal.Id.ToString() }, ResourceIdentifier = new ResourceIdentifier() { Subscription = subscriptionId }, CanDelegate = false }; for (var i = 0; i < 6; i++) { try { TestMockSupport.Delay(5000); PoliciesClient.CreateRoleAssignment(parameters); var ra = PoliciesClient.FilterRoleAssignments(parameters, subscriptionId); if (ra != null) { WriteVerbose(string.Format("Role assignment with role '{0}' and scope '{1}' successfully created for the created service principal.", this.Role, this.Scope)); break; } } catch (Exception) { // Do nothing } } } }
public FiscalYear AddYears(int years) { return(new FiscalYear(StartDate.AddYears(years))); }
private void CreateBillsForDateRange() { var days = (EndDate - StartDate).TotalDays; double dayCount = 0.0; var spacings = 0; //weeks, months, fortnights, 4weeks etc NewBills.Clear(); switch (DueDateFrequency) { case DueDateFrequencies.OneWeek: while (dayCount <= days) { dayCount = (StartDate.AddDays((spacings + 1) * 7) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddDays(7 * i))); } break; case DueDateFrequencies.TwoWeek: while (dayCount <= days) { dayCount = (StartDate.AddDays((spacings + 1) * 14) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddDays(14 * i))); } break; case DueDateFrequencies.FourWeek: while (dayCount <= days) { dayCount = (StartDate.AddDays((spacings + 1) * 28) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddDays(28 * i))); } break; case DueDateFrequencies.Monthly: while (dayCount <= days) { dayCount = (StartDate.AddMonths(spacings + 1) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddMonths(i))); } break; case DueDateFrequencies.Quarterly: while (dayCount <= days) { dayCount = (StartDate.AddMonths(3 * (spacings + 1)) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddMonths(3 * i))); } break; case DueDateFrequencies.SemiAnnually: while (dayCount <= days) { dayCount = (StartDate.AddMonths(6 * (spacings + 1)) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddMonths(6 * i))); } break; case DueDateFrequencies.Yearly: while (dayCount <= days) { dayCount = (StartDate.AddYears(spacings + 1) - StartDate).TotalDays; spacings++; } for (int i = 0; i < spacings; i++) { NewBills.Add(new NewMultiBillViewModel(i + 1, StartDate.AddYears(i))); } break; default: break; } RaisePropertyChanged(nameof(BillCount)); }
private void OnStartOfSimulation(object sender, EventArgs e) { // Open the weather file and read its contents. DateTime firstDateInFile; DateTime lastDateInFile; var file = new ApsimTextFile(); try { file.Open(FileName); data = file.ToTable(); firstDateInFile = file.FirstDate; lastDateInFile = file.LastDate; Latitude = Convert.ToDouble(file.Constant("Latitude").Value); if (file.Constant("TAV") == null) { throw new Exception("TAV not specified in weather file."); } Tav = Convert.ToDouble(file.Constant("TAV").Value); if (file.Constant("AMP") == null) { throw new Exception("AMP not specified in weather file."); } Amp = Convert.ToDouble(file.Constant("Amp").Value); if (file.Constant("CO2") != null) { CO2 = Convert.ToDouble(file.Constant("CO2").Value); } else { CO2 = 350; } } finally { file.Close(); } // Make sure some data was read. if (data.Rows.Count == 0) { throw new Exception($"No weather data found in file {FileName}"); } // Parse the user input start date into a StartDate. DateTime date; if (DateTime.TryParse(StartDateOfSimulation, out date)) { StartDate = date; } else { throw new Exception($"Invalid start date specified in WeatherRandomiser {StartDateOfSimulation}"); } // If sampling method is random then create an array of random years. if (TypeOfSampling == RandomiserTypeEnum.RandomSampler) { // Make sure user has entered number of years. if (NumYears <= 0) { throw new Exception("The number of years to sample from the weather file hasn't been speciifed."); } // Determine the year range to sample from. var firstYearToSampleFrom = firstDateInFile.Year; var lastYearToSampleFrom = lastDateInFile.Year - 1; if (firstDateInFile > StartDate) { firstYearToSampleFrom++; } // Randomly sample from the weather record for the required number of years. Years = new double[NumYears]; var random = new Random(); for (int i = 0; i < NumYears; i++) { Years[i] = random.Next(firstYearToSampleFrom, lastYearToSampleFrom); } } if (Years == null || Years.Length == 0) { throw new Exception("No years specified in WeatherRandomiser"); } EndDate = StartDate.AddYears(Years.Length).AddDays(-1); currentYearIndex = -1; }
/// <summary> /// scan all people pto or signal people /// </summary> private void InitControls() { //if (list.Where(t => t.ModuleID == allid).Count() == 0 && (UserInfo.ID + "" != ddlUsers.SelectedValue))//防止在手动修改链接参数 //{ // ddlUsers.SelectedValue = UserInfo.ID + ""; //} DateTime StartDate; DateTime EndDate; if (!DateTime.TryParse(QS("year"), out StartDate)) { if (QS("year") == "-1") { StartDate = MinDate; EndDate = new DateTime(2200, 1, 1); } else { StartDate = new DateTime(DateTime.Now.Year, 1, 1); EndDate = StartDate.AddYears(1).AddDays(-1); } } else { EndDate = StartDate.AddYears(1).AddDays(-1); } if (this.ReportView == "DetailView") { rptHoursView.Visible = false; rptListReport.Visible = true; List <PtoView> ptoViews = PtosHelper.ReGeneratePtos(int.Parse(ddlProject.SelectedValue), StartDate, EndDate, int.Parse(ddlUsers.SelectedValue), OrderBy, OrderDirection, DefaultOrderBy); #region Special order if (OrderBy == "Hours") { if (OrderDirection.ToUpper() == "ASC") { ptoViews = ptoViews.OrderBy(t => t.Hours).ToList(); } else { ptoViews = ptoViews.OrderByDescending(t => t.Hours).ToList(); } } if (OrderBy == "Remaining") { if (OrderDirection.ToUpper() == "ASC") { ptoViews = ptoViews.OrderBy(t => t.Remaining).ToList(); } else { ptoViews = ptoViews.OrderByDescending(t => t.Remaining).ToList(); } } #endregion rptListReport.DataSource = ptoViews; rptListReport.DataBind(); if (ptoViews.Count == 0) { trNoListRecord.Visible = true; } } else if (this.ReportView == "HoursView") { rptListReport.Visible = false; rptHoursView.Visible = true; DataTable dt = _tsApp.QueryReportTotalHoursByProject( int.Parse(ddlProject.SelectedValue), int.Parse(ddlUsers.SelectedValue), StartDate, EndDate, OrderBy, OrderDirection); rptHoursView.DataSource = dt; rptHoursView.DataBind(); if (dt.Rows.Count == 0) { trNoHourRecord.Visible = true; } } else { rptListReport.Visible = false; rptHoursView.Visible = false; } }
public override void ExecuteCmdlet() { ExecutionBlock(() => { if (!this.IsParameterBound(c => c.EndDate)) { WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); EndDate = StartDate.AddYears(1); } if (this.IsParameterBound(c => c.ApplicationObject)) { ObjectId = ApplicationObject.ObjectId; } else if (this.IsParameterBound(c => c.ApplicationId)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); } else if (this.IsParameterBound(c => c.DisplayName)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); } if (Password != null && Password.Length > 0) { string decodedPassword = SecureStringExtensions.ConvertToString(Password); // Create object for password credential var passwordCredential = new PasswordCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), Value = decodedPassword }; if (!String.IsNullOrEmpty(CustomKeyIdentifier)) { passwordCredential.CustomKeyIdentifier = Encoding.UTF8.GetBytes(CustomKeyIdentifier); } if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new password to application with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateAppPasswordCredential(ObjectId, passwordCredential)); } } else if (CertValue != null) { // Create object for key credential var keyCredential = new KeyCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), Value = CertValue, Type = "AsymmetricX509Cert", Usage = "Verify", CustomKeyIdentifier = CustomKeyIdentifier }; if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new certificate to application with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateAppKeyCredential(ObjectId, keyCredential)); } } else { throw new InvalidOperationException("No valid keyCredential or passwordCredential to update!!"); } }); }
public override void ExecuteCmdlet() { ExecutionBlock(() => { if (this.ParameterSetName == SimpleParameterSet) { CreateSimpleServicePrincipal(); return; } if (!this.IsParameterBound(c => c.EndDate)) { WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); EndDate = StartDate.AddYears(1); } if (this.IsParameterBound(c => c.ApplicationObject)) { ApplicationId = ApplicationObject.ApplicationId; DisplayName = ApplicationObject.DisplayName; } if (ApplicationId == Guid.Empty) { string uri = "http://" + DisplayName.Trim().Replace(' ', '_'); // Create an application and get the applicationId CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters { DisplayName = DisplayName, IdentifierUris = new[] { uri }, HomePage = uri }; if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName))) { var application = ActiveDirectoryClient.CreateApplication(appParameters); ApplicationId = application.ApplicationId; } } CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters { ApplicationId = ApplicationId, AccountEnabled = true }; if (this.IsParameterBound(c => c.Password)) { string decodedPassword = SecureStringExtensions.ConvertToString(Password); createParameters.PasswordCredentials = new PSADPasswordCredential[] { new PSADPasswordCredential { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), Password = decodedPassword } }; } else if (this.IsParameterBound(c => c.PasswordCredential)) { createParameters.PasswordCredentials = PasswordCredential; } else if (this.IsParameterBound(c => c.CertValue)) { createParameters.KeyCredentials = new PSADKeyCredential[] { new PSADKeyCredential { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), CertValue = CertValue } }; } else if (this.IsParameterBound(c => c.KeyCredential)) { createParameters.KeyCredentials = KeyCredential; } if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId))) { var servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters); WriteObject(servicePrincipal); } }); }
public DateTimePeriod AddYears(int years) { return(new DateTimePeriod(StartDate.AddYears(years), EndDate.AddYears(years))); }
protected void ButtonShowReport_Click(object sender, EventArgs e) { string CustomerId, LocationName, ReportName, DataSetName, URL; DateTime StartDate, EndDate, StartDate1, EndDate1, StartDate2, EndDate2, StartDate3, EndDate3; StartDate = CalendarControlStartPeriod.SelectedDate; EndDate = CalendarControlEndPeriod.SelectedDate; if (BulletedListDateSelection.SelectedValue == "Today") { StartDate = Common.CurrentClientDate(Session); EndDate = Common.CurrentClientDate(Session); } if (BulletedListDateSelection.SelectedValue == "Yesterday") { StartDate = Common.CurrentClientDate(Session).AddDays(-1); EndDate = Common.CurrentClientDate(Session).AddDays(-1); } if (BulletedListDateSelection.SelectedValue == "ThisMonth") { DateTime BaseDate = new DateTime(Common.CurrentClientDate(Session).Year, Common.CurrentClientDate(Session).Month, 1); StartDate = BaseDate; EndDate = BaseDate.AddMonths(1).AddDays(-1); } if (BulletedListDateSelection.SelectedValue == "PreviousMonth") { DateTime BaseDate = new DateTime(Common.CurrentClientDate(Session).Year, Common.CurrentClientDate(Session).Month, 1); StartDate = BaseDate.AddMonths(-1); EndDate = BaseDate.AddDays(-1); } if (BulletedListDateSelection.SelectedValue == "ThisYear") { StartDate = new DateTime(Common.CurrentClientDate(Session).Year, 1, 1); EndDate = Common.CurrentClientDate(Session); } if (BulletedListDateSelection.SelectedValue == "All") { StartDate = new DateTime(2000, 1, 1); EndDate = new DateTime(2100, 1, 1); } StartDate1 = StartDate.AddYears(-1); EndDate1 = EndDate.AddYears(-1); StartDate2 = StartDate.AddYears(-2); EndDate2 = EndDate.AddYears(-2); StartDate3 = StartDate.AddYears(-3); EndDate3 = EndDate.AddYears(-3); LocationName = ComboBoxSelectedLocation.Text; CustomerId = ""; if (RadioButtonListCustomerSelection.SelectedValue == "Select") { CustomerId = ComboBoxCustomerSelection.SelectedValue; } ReportName = ""; DataSetName = ""; switch (RadioButtonListReportType.SelectedValue) { case "All": ReportName = "ReportComparisonTotals"; DataSetName = "DataSetComparisonTotals"; break; case "Material": ReportName = "ReportComparisonMaterialTotals"; DataSetName = "DataSetComparisonMaterialTotals"; break; case "Customer": ReportName = "ReportComparisonCustomerTotals"; DataSetName = "DataSetComparisonCustomerTotals"; break; } // load up the iframe URL = "WebFormPopup.aspx?UC=ShowReport&d=" + DataSetName + "&r=" + ReportName + "&CustomerId=" + CustomerId + "&LocationName=" + LocationName + "&StartDate=" + StartDate.ToString() + "&EndDate=" + EndDate.ToString() + "&StartDate1=" + StartDate1.ToString() + "&EndDate1=" + EndDate1.ToString() + "&StartDate2=" + StartDate2.ToString() + "&EndDate2=" + EndDate2.ToString() + "&StartDate3=" + StartDate3.ToString() + "&EndDate3=" + EndDate3.ToString(); LabelURL.Text = URL; FrameShowReport.Attributes["src"] = URL; }
private void CreateSimpleServicePrincipal() { var subscriptionId = DefaultContext.Subscription?.Id; if (!this.IsParameterBound(c => c.StartDate)) { DateTime currentTime = DateTime.UtcNow; StartDate = currentTime; WriteVerbose("No start date provided - using the current time as default."); } if (!this.IsParameterBound(c => c.EndDate)) { EndDate = StartDate.AddYears(1); WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); } if (!this.IsParameterBound(c => c.DisplayName)) { DisplayName = "azure-powershell-" + StartDate.ToString("MM-dd-yyyy-HH-mm-ss"); WriteVerbose(string.Format("No display name provided - using the default display name of '{0}'", DisplayName)); } var identifierUri = "http://" + DisplayName; bool printPassword = false; bool printUseExistingSecret = true; // Handle credentials var Password = Guid.NewGuid().ToString().ConvertToSecureString(); // Create an application and get the applicationId if (!this.IsParameterBound(c => c.ApplicationId)) { printUseExistingSecret = false; CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters { DisplayName = DisplayName, IdentifierUris = new[] { identifierUri }, HomePage = identifierUri, PasswordCredentials = new PSADPasswordCredential[] { new PSADPasswordCredential() { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), Password = SecureStringExtensions.ConvertToString(Password) } } }; if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName))) { var application = ActiveDirectoryClient.CreateApplication(appParameters); ApplicationId = application.ApplicationId; WriteVerbose(string.Format("No application id provided - created new AD application with application id '{0}'", ApplicationId)); printPassword = true; } } CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters { ApplicationId = ApplicationId, AccountEnabled = true, }; var shouldProcessMessage = string.Format("Adding a new service principal to be associated with an application " + "having AppId '{0}' with no permissions.", createParameters.ApplicationId); if (!SkipRoleAssignment()) { if (!this.IsParameterBound(c => c.Scope)) { Scope = string.Format("/subscriptions/{0}", subscriptionId); WriteVerbose(string.Format("No scope provided - using the default scope '{0}'", Scope)); } AuthorizationClient.ValidateScope(Scope, true); if (!this.IsParameterBound(c => c.Role)) { Role = "Contributor"; WriteVerbose(string.Format("No role provided - using the default role '{0}'", Role)); } shouldProcessMessage = string.Format("Adding a new service principal to be associated with an application " + "having AppId '{0}' with '{1}' role over scope '{2}'.", createParameters.ApplicationId, this.Role, this.Scope); } if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: shouldProcessMessage)) { PSADServicePrincipalWrapper servicePrincipal = new PSADServicePrincipalWrapper(ActiveDirectoryClient.CreateServicePrincipal(createParameters)); if (printPassword) { servicePrincipal.Secret = Password; } else if (printUseExistingSecret) { WriteVerbose(String.Format(ProjectResources.ServicePrincipalCreatedWithCredentials, ApplicationId)); } WriteObject(servicePrincipal); if (SkipRoleAssignment()) { WriteVerbose("Skipping role assignment for the service principal."); return; } WriteWarning(string.Format("Assigning role '{0}' over scope '{1}' to the new service principal.", this.Role, this.Scope)); FilterRoleAssignmentsOptions parameters = new FilterRoleAssignmentsOptions() { Scope = this.Scope, RoleDefinitionName = this.Role, ADObjectFilter = new ADObjectFilterOptions { SPN = servicePrincipal.ApplicationId.ToString(), Id = servicePrincipal.Id.ToString() }, ResourceIdentifier = new ResourceIdentifier() { Subscription = subscriptionId }, CanDelegate = false }; for (var i = 0; i < 6; i++) { try { TestMockSupport.Delay(5000); PoliciesClient.CreateRoleAssignment(parameters); var ra = PoliciesClient.FilterRoleAssignments(parameters, subscriptionId); if (ra != null) { WriteVerbose(string.Format("Role assignment with role '{0}' and scope '{1}' successfully created for the created service principal.", this.Role, this.Scope)); break; } } catch (Exception) { // Do nothing } } } }
protected void Page_Load(object sender, EventArgs e) { int userID = QS("user", 0); int projectID = QS("project", 0); if (userID == 0 || projectID == 0) { this.Alert("Current Page get an error,please check your argument!", "/Pto/Pto.aspx?viewmodel=detailmodel"); } UserApplication userApp = new UserApplication(); this.SelectedUser = userApp.GetUser(userID); ProjectApplication projApp = new ProjectApplication(); this.SelectedProject = projApp.Get(projectID); //DateTime startDate = DateTime.MinValue; //DateTime endDate = DateTime.MinValue; //DateTime.TryParse(Request.QueryString["startdate"], out startDate); //DateTime.TryParse(Request.QueryString["enddate"], out endDate); DateTime StartDate; DateTime EndDate; if (!DateTime.TryParse(Request.QueryString["year"], out StartDate)) { StartDate = new DateTime(1753, 1, 1); EndDate = new DateTime(2200, 1, 1);; } else { EndDate = StartDate.AddYears(1).AddDays(-1); } _eventsApplication = new EventsApplication(); DataTable evdt = _eventsApplication.GetPtoByProjectUser(projectID, userID, StartDate, EndDate); IList <PtoUserView> eventPtolist = ModelConvertHelper <PtoUserView> .ConvertToModel(evdt); List <PtoUserDetailView> ptoUserDetailViews = new List <PtoUserDetailView>(); if (eventPtolist != null && eventPtolist.Count > 0) { foreach (var t in eventPtolist) { PtoUserDetailView ptoUserDetailView = new PtoUserDetailView { Title = t.Title, Name = t.Name, Details = t.Details }; double hours = 0; if (t.Office == "CN") { #region if (t.AllDay) { if (t.ToDay.Date == t.FromDay.Date) { hours += 8; } else { var days = t.ToDay.Day - t.FromDay.Day + 1; hours = hours + days * 8; } ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(8).AddMinutes(30); ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(17).AddMinutes(30); } if (!t.AllDay) { var fromTime = t.FromTime.Split(':'); var toTime = t.ToTime.Split(':'); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "HH:mm"; var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat); var workTime = Convert.ToDateTime("8:30", dtFormat); var restTimeBegin = Convert.ToDateTime("12:30", dtFormat); var restTimeEnd = Convert.ToDateTime("13:30", dtFormat); var closeTime = Convert.ToDateTime("17:30", dtFormat); if (t.FromTimeType == 2) { if (fromTimeHour <= 5) { fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12); } } if (t.FromTimeType == 1) { if (fromTimeHour == 12) { fromTimeDate = workTime; } } if (t.ToTimeType == 2) { if (toTimeHour <= 5) { toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12); } if (5 < toTimeHour && toTimeHour < 12) { toTimeDate = closeTime; } } if (toTimeDate < restTimeBegin) { hours = hours + (toTimeDate - fromTimeDate).TotalHours; } if (toTimeDate > restTimeEnd) { hours = hours + (restTimeBegin - fromTimeDate).TotalHours; hours = hours + (toTimeDate - restTimeEnd).TotalHours; } if (t.FromTimeType == 1) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddMinutes(fromtimeMinutes); } else { if (fromTimeHour <= 5) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes); } } if (t.ToTimeType == 1) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddMinutes(toTimeMinutes); } else { if (toTimeHour <= 5) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddHours(12).AddMinutes(toTimeMinutes); } if (toTimeHour > 5 && toTimeHour < 12) { ptoUserDetailView.ToDay = closeTime; } if (toTimeHour == 12) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(12).AddMinutes(toTimeMinutes); } } } #endregion } else { var workTimes = _eventsApplication.GetWorkTime(t.UserID); var worksViews = workTimes.Select(k => new WorkTimeView { FromTime = k.FromTime, ToTime = k.ToTime, FromTimeType = k.FromTimeType, ToTimeType = k.ToTimeType }).OrderBy(c => c.FromDate).ToList(); if (!worksViews.Any()) { #region if (t.AllDay) { if (t.ToDay.Date == t.FromDay.Date) { hours += 8; } else { var days = t.ToDay.Day - t.FromDay.Day + 1; hours = hours + days * 8; } ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(8).AddMinutes(30); ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(17).AddMinutes(30); } if (!t.AllDay) { var fromTime = t.FromTime.Split(':'); var toTime = t.ToTime.Split(':'); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "HH:mm"; var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat); var workTime = Convert.ToDateTime("8:30", dtFormat); var restTimeBegin = Convert.ToDateTime("12:30", dtFormat); var restTimeEnd = Convert.ToDateTime("13:30", dtFormat); var closeTime = Convert.ToDateTime("17:30", dtFormat); if (t.FromTimeType == 2) { if (fromTimeHour <= 5) { fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12); } } if (t.FromTimeType == 1) { if (fromTimeHour == 12) { fromTimeDate = workTime; } } if (t.ToTimeType == 2) { if (toTimeHour <= 5) { toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12); } if (5 < toTimeHour && toTimeHour < 12) { toTimeDate = closeTime; } } if (toTimeDate < restTimeBegin) { hours = hours + (toTimeDate - fromTimeDate).TotalHours; } if (toTimeDate > restTimeEnd) { hours = hours + (restTimeBegin - fromTimeDate).TotalHours; hours = hours + (toTimeDate - restTimeEnd).TotalHours; } if (t.FromTimeType == 1) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddMinutes(fromtimeMinutes); } else { if (fromTimeHour <= 5) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes); } } if (t.ToTimeType == 1) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddMinutes(toTimeMinutes); } else { if (toTimeHour <= 5) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddHours(12).AddMinutes(toTimeMinutes); } if (toTimeHour > 5 && toTimeHour < 12) { ptoUserDetailView.ToDay = closeTime; } if (toTimeHour == 12) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(12).AddMinutes(toTimeMinutes); } } } #endregion } else { var mindate = worksViews.Min(x => x.FromDate); var maxdate = worksViews.Max(x => x.ToDate); #region if (t.AllDay) { if (t.ToDay.Date == t.FromDay.Date) { hours += 8; } else { var days = t.ToDay.Day - t.FromDay.Day + 1; hours = hours + days * 8; } ptoUserDetailView.FromDay = mindate; ptoUserDetailView.ToDay = maxdate; } else { #region DateTimeFormatInfo dtFormat = new DateTimeFormatInfo { ShortDatePattern = "HH:mm" }; var fromTime = t.FromTime.Split(':'); var toTime = t.ToTime.Split(':'); var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat); foreach (var g in worksViews) { var workTime = g.FromDate; var closeTime = g.ToDate; switch (t.FromTimeType) { case 1: fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime("00:" + fromtimeMinutes, dtFormat) : Convert.ToDateTime(t.FromTime, dtFormat); break; case 2: fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime(t.FromTime, dtFormat) : Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12); break; } switch (t.ToTimeType) { case 1: toTimeDate = toTimeHour == 12 ? Convert.ToDateTime("00:" + toTimeMinutes, dtFormat) : Convert.ToDateTime(t.ToTime, dtFormat); break; case 2: toTimeDate = toTimeHour == 12 ? Convert.ToDateTime(t.ToTime, dtFormat) : Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12); break; } if (fromTimeDate <= workTime && closeTime <= toTimeDate) { if ((closeTime - workTime).TotalHours < 0) { continue; } hours = hours + (closeTime - workTime).TotalHours; } if (fromTimeDate <= workTime && closeTime > toTimeDate) { if ((toTimeDate - workTime).TotalHours < 0) { continue; } hours = hours + (toTimeDate - workTime).TotalHours; } if (fromTimeDate > workTime && closeTime <= toTimeDate) { if ((closeTime - fromTimeDate).TotalHours < 0) { continue; } hours = hours + (closeTime - fromTimeDate).TotalHours; } if (fromTimeDate > workTime && closeTime > toTimeDate) { if ((toTimeDate - fromTimeDate).TotalHours < 0) { continue; } hours = hours + (toTimeDate - fromTimeDate).TotalHours; } } ptoUserDetailView.FromDay = t.FromTimeType == 1 ? t.FromDay.Date.AddHours(fromTimeHour == 12 ? 0 : fromTimeHour).AddMinutes(fromtimeMinutes) : t.FromDay.Date.AddHours(fromTimeHour == 12 ? 0 : fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes); ptoUserDetailView.ToDay = t.ToTimeType == 1 ? t.ToDay.Date.AddHours(toTimeHour == 12 ? 0 : toTimeHour).AddMinutes(toTimeMinutes) : t.ToDay.Date.AddHours(toTimeHour == 12 ? 0 : toTimeHour).AddHours(12).AddMinutes(toTimeMinutes); #endregion } #endregion } } ptoUserDetailView.Hours = hours; ptoUserDetailViews.Add(ptoUserDetailView); } this.ptoDetail.DataSource = ptoUserDetailViews; this.ptoDetail.DataBind(); } else { ShowFailMessageToClient("There is no records "); } litUserName.Text = SelectedUser.FirstName + " " + SelectedUser.LastName; if (ptoUserDetailViews.Any()) { foreach (var t in ptoUserDetailViews) { _totalHours += t.Hours; } } litTotalhours.Text = _totalHours.ToString("#0.00") + " h"; }
public override void ExecuteCmdlet() { ExecutionBlock(() => { if (!this.IsParameterBound(c => c.EndDate)) { WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); EndDate = StartDate.AddYears(1); } if (this.IsParameterBound(c => c.ServicePrincipalObject)) { ObjectId = ServicePrincipalObject.Id; } if (this.IsParameterBound(c => c.ServicePrincipalName)) { ObjectId = ActiveDirectoryClient.GetObjectIdFromSPN(ServicePrincipalName); } if (this.IsParameterBound(c => c.CertValue)) { // Create object for key credential var keyCredential = new KeyCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), Value = CertValue, Type = "AsymmetricX509Cert", Usage = "Verify" }; if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new caertificate to service principal with objectId {0}", ObjectId))) { WriteObject(ActiveDirectoryClient.CreateSpKeyCredential(ObjectId, keyCredential)); } } else { // If no credentials provided, set the password to a randomly generated GUID var Password = Guid.NewGuid().ToString().ConvertToSecureString(); string decodedPassword = SecureStringExtensions.ConvertToString(Password); var passwordCredential = new PasswordCredential() { EndDate = EndDate, StartDate = StartDate, KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), Value = decodedPassword }; if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new password to service principal with objectId {0}", ObjectId))) { var spCred = new PSADCredentialWrapper(ActiveDirectoryClient.CreateSpPasswordCredential(ObjectId, passwordCredential)); spCred.Secret = Password; WriteObject(spCred); } } }); }
public void ExecuteSaveCollateral(object obj) { using (CreditsFirmsContext context = new CreditsFirmsContext()) { if (valAgreement && valClient && valDate && valSum && Currency != null && TypeCollateral != null && !string.IsNullOrWhiteSpace(CreditAgreement) && FormCollateral != null && (!string.IsNullOrWhiteSpace(FirmId) || !string.IsNullOrWhiteSpace(PersonId))) { Collateral colRequest; if (Flag == true) { colRequest = (Collateral)context.Collaterals.FirstOrDefault(c => c.Collateral_agreement == CollateralAgreement); } else { colRequest = new Collateral(); } colRequest.Collateral_agreement = CollateralAgreement; colRequest.Start_date = StartDate; colRequest.End_date = EndDate; colRequest.Currency_Id = Currency.Currency_Id; colRequest.Sum = double.Parse(SumText); colRequest.Description = Description; colRequest.TypeId = TypeCollateral.TypeId; colRequest.FormId = FormCollateral.FormId; colRequest.Credit_agreement = CreditAgreement; if (FirmId != null) { colRequest.Id_Firm = FirmId; } else if (PersonId != null) { colRequest.Id_Person = PersonId; } if (Flag == false) { Monitoring_collateral monitoringAdd = new Monitoring_collateral(); monitoringAdd.Collateral_agreement = CollateralAgreement; monitoringAdd.Previous_date = StartDate; if (TypeCollateral.TypeId == 99551 || TypeCollateral.TypeId == 99552) { monitoringAdd.Planned_date = StartDate.AddYears(1); } if (TypeCollateral.TypeId == 99553) { monitoringAdd.Planned_date = StartDate.AddMonths(3); } context.Monitoring_collateral.Add(monitoringAdd); context.Collaterals.Add(colRequest); } context.SaveChanges(); CloseWnd(this, new EventArgs()); MessageBox.Show("Операция проведена успешно", "Договор обеспечения", MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show("Не все поля заполены корректно", "Ошибка при регистрации договора", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public override void ExecuteCmdlet() { WriteWarningWithTimestamp("New-AzAdServicePrincipal will no longer assign role 'Contributor' to new created service principal by default"); ExecutionBlock(() => { //safe gauard for login status, check if DefaultContext not existed, PSInvalidOperationException will be thrown var CheckDefaultContext = DefaultContext; if (this.ParameterSetName == SimpleParameterSet) { CreateSimpleServicePrincipal(); return; } if (!this.IsParameterBound(c => c.EndDate)) { WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); EndDate = StartDate.AddYears(1); } if (this.IsParameterBound(c => c.ApplicationObject)) { ApplicationId = ApplicationObject.ApplicationId; DisplayName = ApplicationObject.DisplayName; } if (ApplicationId == Guid.Empty) { // Create an application and get the applicationId CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters(); if (this.IsParameterBound(c => c.DisplayName) && !string.IsNullOrEmpty(DisplayName)) { string uri = "http://" + HttpUtility.UrlEncode(DisplayName.Trim()); appParameters.IdentifierUris = new string[] { }; appParameters.DisplayName = DisplayName; } if (this.IsParameterBound(c => c.PasswordCredential)) { appParameters.PasswordCredentials = PasswordCredential; } else if (this.IsParameterBound(c => c.CertValue)) { appParameters.KeyCredentials = new PSADKeyCredential[] { new PSADKeyCredential { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), CertValue = CertValue } }; } else if (this.IsParameterBound(c => c.KeyCredential)) { appParameters.KeyCredentials = KeyCredential; } if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName))) { var application = ActiveDirectoryClient.CreateApplication(appParameters); ApplicationId = application.ApplicationId; } } CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters { ApplicationId = ApplicationId, AccountEnabled = true }; if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId))) { var servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters); WriteObject(servicePrincipal); } }); }
public override void ExecuteCmdlet() { if (!this.IsParameterBound(c => c.EndDate)) { WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); EndDate = StartDate.AddYears(1); } CreatePSApplicationParameters createParameters = new CreatePSApplicationParameters { DisplayName = DisplayName, HomePage = HomePage, IdentifierUris = IdentifierUris, ReplyUrls = ReplyUrls, AvailableToOtherTenants = AvailableToOtherTenants }; switch (ParameterSetName) { case ParameterSet.ApplicationWithPasswordPlain: string decodedPassword = SecureStringExtensions.ConvertToString(Password); createParameters.PasswordCredentials = new PSADPasswordCredential[] { new PSADPasswordCredential { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), Password = decodedPassword } }; break; case ParameterSet.ApplicationWithPasswordCredential: createParameters.PasswordCredentials = PasswordCredentials; break; case ParameterSet.ApplicationWithKeyPlain: createParameters.KeyCredentials = new PSADKeyCredential[] { new PSADKeyCredential { StartDate = StartDate, EndDate = EndDate, KeyId = Guid.NewGuid(), CertValue = CertValue } }; break; case ParameterSet.ApplicationWithKeyCredential: createParameters.KeyCredentials = KeyCredentials; break; } ExecutionBlock(() => { if (ShouldProcess(target: createParameters.DisplayName, action: string.Format("Adding a new application with display name '{0}'", createParameters.DisplayName))) { WriteObject(ActiveDirectoryClient.CreateApplication(createParameters)); } }); }
//get next fifty years of dates assuming no schedule will be longer than that private DateTime LastPossibleDate() { return(StartDate.AddYears(50)); }