Exemplo n.º 1
0
 public GroupBlackoutDisplay(string groupName, BlackoutInterval blackout) : this()
 {
     this.GroupName = groupName;
     this.StartDate = new DateTime?(blackout.StartDate);
     this.EndDate   = new DateTime?(blackout.EndDate);
     this.Reason    = blackout.Reason;
 }
Exemplo n.º 2
0
        protected override void InternalProcessRecord()
        {
            SetGroupBlackout.< > c__DisplayClass1 CS$ < > 8__locals1 = new SetGroupBlackout.< > c__DisplayClass1();
            CS$ < > 8__locals1.toUpdate = null;
            string parameterSetName;

            if ((parameterSetName = base.ParameterSetName) != null)
            {
                if (!(parameterSetName == "SingleGroupBlackoutUpdate"))
                {
                    if (parameterSetName == "MultiGroupBlackoutUpdate")
                    {
                        Dictionary <string, List <BlackoutInterval> > dictionary = new Dictionary <string, List <BlackoutInterval> >();
                        foreach (PSObject psobject in this.GroupBlackouts)
                        {
                            string   key    = base.GetPropertyValue(psobject.Properties, "GroupName").ToString();
                            string   reason = base.GetPropertyValue(psobject.Properties, "Reason").ToString();
                            DateTime startDate;
                            DateTime.TryParse(base.GetPropertyValue(psobject.Properties, "StartDate").ToString(), out startDate);
                            DateTime endDate;
                            DateTime.TryParse(base.GetPropertyValue(psobject.Properties, "EndDate").ToString(), out endDate);
                            if (dictionary.ContainsKey(key))
                            {
                                if (dictionary[key].Count >= 20)
                                {
                                    base.ThrowTerminatingError(new PSArgumentException("Cannot update more than 20 BlackoutIntervals per group"), ErrorCategory.InvalidArgument, this.GroupBlackouts);
                                }
                                dictionary[key].Add(new BlackoutInterval(startDate, endDate, reason));
                            }
                            else
                            {
                                dictionary.Add(key, new List <BlackoutInterval>
                                {
                                    new BlackoutInterval(startDate, endDate, reason)
                                });
                            }
                        }
                        List <GroupBlackout> list = new List <GroupBlackout>();
                        foreach (KeyValuePair <string, List <BlackoutInterval> > keyValuePair in dictionary)
                        {
                            list.Add(new GroupBlackout(keyValuePair.Key, keyValuePair.Value.ToArray()));
                        }
                        CS$ < > 8__locals1.toUpdate = list.ToArray();
                    }
                }
                else
                {
                    BlackoutInterval[] intervals;
                    if (this.BlackoutIntervals == null)
                    {
                        BlackoutInterval blackoutInterval = new BlackoutInterval(this.StartDate, this.EndDate, this.Reason);
                        intervals = new BlackoutInterval[]
                        {
                            blackoutInterval
                        };
                    }
                    else
                    {
                        intervals = this.BlackoutIntervals;
                    }
                    GroupBlackout groupBlackout = new GroupBlackout(this.Group, intervals);
                    CS$ < > 8__locals1.toUpdate = new GroupBlackout[]
                    {
                        groupBlackout
                    };
                }
            }
            using (ProxyWrapper <UpgradeSchedulingConstraintsClient, IUpgradeSchedulingConstraints> workloadClient = new ProxyWrapper <UpgradeSchedulingConstraintsClient, IUpgradeSchedulingConstraints>(base.WorkloadUri, base.Certificate))
            {
                workloadClient.CallSymphony(delegate
                {
                    workloadClient.Proxy.UpdateBlackout(CS$ < > 8__locals1.toUpdate);
                }, base.WorkloadUri.ToString());