AcUtils
A high performance abstraction layer for AccuRev
Locks.cs

Show the locks on streams listed in Locks.exe.config.

See also
AcLocks constructor, LockStreams.cs, PromoRights.cs
Locks.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="Streams" type="AcUtils.StreamsSection, AcUtils, Version=1.6.4.0, Culture=neutral, PublicKeyToken=26470c2daf5c2e2f, processorArchitecture=MSIL" />
</configSections>
<Streams>
<streams>
<add stream="MARS_MAINT" />
<add stream="JUPITER_DEV4" />
<add stream="NEPTUNE_UAT" />
</streams>
</Streams>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
/* Copyright (C) 2016-2018 Verizon. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
// Required references: AcUtils.dll, System.configuration
using System;
using System.Configuration;
using System.Linq;
using AcUtils;
namespace Locks
{
class Program
{
private static StreamsCollection _selStreams;
static int Main()
{
bool ret = false; // assume failure
StreamsSection streamsConfigSection = ConfigurationManager.GetSection("Streams") as StreamsSection;
if (streamsConfigSection == null)
Console.WriteLine("Error creating StreamsSection");
else
{
_selStreams = streamsConfigSection.Streams;
Task<bool> pini = promoRightsAsync();
ret = pini.Result;
}
return (ret) ? 0 : 1;
}
public static async Task<bool> promoRightsAsync()
{
AcLocks locks = new AcLocks();
if (!(await locks.initAsync(_selStreams))) return false;
// list them ordered by stream name then 'To' lock followed by 'From' lock
foreach (AcLock lk in locks.OrderBy(n => n.Name).ThenByDescending(n => n.Kind))
Console.WriteLine(lk);
return true;
}
}
}