|
I think anchoring the ends of the pattern that Griff gave will do what you want:
^[A-HJ-TP-WYZa-z]*$ This says that everything in the string must meet these conditions.
And if an empty string is not permitted, change the asterisk to plus:
^[A-HJ-TP-WYZa-z]+$
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
We both missed that the pattern itself was broken:
^[A-HJ-TP-WYZa-z]*$ should be:
^[A-HJ-NP-WYZa-z]*$
(The T should be N.)
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
See my reply to Griff's comment below.
(I should have replied here...)
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
I don't think there's "direct" way to do that unless you specify the characters in the expression.
Why not simply use [IOX0-9]+ and invert the match condition?
[EDIT]
Of course you will need to handle the case with the lower case characters - either with RegexOptions.IgnoreCase flag or by specifying appropriate characters in the expression itself.
[/EDIT]
Your time will come, if you let it be right.
modified 11-Dec-14 3:46am.
|
|
|
|
|
The anchored expression I gave yesterday (the fixed one with N for T...) works when I test it in Expresso.
It matches only A-Z (except IOX), any lowercase a-z, no digits.
If punctuation is to be allowed, then the negated character class construct would work:
^[^IOX0-9]+$ will fail any string that contains uppercase I,O,X or any digit. Anything else would be allowed.
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
Agent__007 wrote: and invert the match condition?
Of course that would allow "A&A" which doesn't fit the requirements.
|
|
|
|
|
I am new to programming in general and i am working on a creating a macro for Revit 2015. I was able to create the following coding that builds a solution correctly without any errors in Sharpdevelop, but when i run the macro within Revit i get an error. Any help or incite would be greatly appreciated.
Thanks
public void Ranking()
{
Document doc = this.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(ViewSheet));
using(Transaction trans = new Transaction(doc, "DrawinglistRank"))
{
trans.Start();
int sheetRank = 1;
foreach (Element Sheet in collector){
Parameter paramDisc = Sheet.LookupParameter("SHEET DISCIPLINE");
string sheetDiscipline = paramDisc.AsString();
sheetRank+=1;
if(sheetDiscipline == "GENERAL"){
sheetRank=1;
}else if(sheetDiscipline == "ARCHITECTURAL"){
sheetRank=2;
}else if(sheetDiscipline == "MECHANICAL"){
sheetRank=3;
}else if(sheetDiscipline == "ELECTRICAL"){
sheetRank=4;
}else if(sheetDiscipline == "PLUMBING"){
sheetRank=5;
}else if(sheetDiscipline == "FIREPROTECTION"){
sheetRank=6;}
Parameter paramRank = Sheet.LookupParameter("DISCIPLINE_RANK");
paramRank.Set(sheetRank);
trans.Commit();
}
TaskDialog.Show("Drawing List", "Drawing List Has Been Updated");
}
}
|
|
|
|
|
How do you think we can imagine what the error in "Revit" might be ?
I wonder why you aren't asking the question here: [^].
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
William Wydock wrote: I am new to programming in general Then you have chosen a nice complex way to learn.
There'll be an exception, at which point Revit gives a general message. Add a try-catch and log the entire exception (write ex.ToString() to file)
It might be that the document is not set correctly (could be null), that the parameter doesn't exist, or something else. Logging the exception will tell you what went wrong, and where.
Alternatively, you can debug by attaching the IDE to the Revit-process.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
static void Main(string[] args)
{
basictest();
}
//Nested dictionary problem
public static Dictionary<int, Dictionary<DateTime, String>> nestedict5 = new Dictionary<int, Dictionary<DateTime, string>>();
public static void basictest() {
int mk = 7001, nk = 7000; // just select 2 int values one odd(7001) and even(7000) for outer dictionary
DateTime ddn = DateTime.Now; // loop working with Datetime.Now for inner dictionay
Dictionary<DateTime, string> cd = new Dictionary<DateTime, string>();
nestedict5.Add(mk, cd); nestedict5.Add(nk, cd); //adding a new odd and even dictionary to outer dictionary
for (int i = 0; i < 12; i++)
{
ddn = ddn.AddMinutes(1); // adding a minute to time
if (ddn.Minute % 2 != 0) // if minute is odd
{
if (!(nestedict5[mk]).ContainsKey(ddn)) //check if outer dictionary odd key contains this odd minute value
{
(nestedict5[mk]).Add(ddn, "odd"); // add odd string to inner with key of datetime,Minute odd
printvalues(mk); // check results of odd keys in debug windows
}
}
else if (ddn.Minute % 2 == 0) // if ninute is even
{
if (!(nestedict5[nk]).ContainsKey(ddn)) //check if even outer dictionay key contains this even minute value
{
(nestedict5[nk]).Add(ddn, "even"); // add even string to inner with key of Minute even
printvalues(nk); // check results of even keys in debug windows
}
}
}
}
// loop to print odd and even key values in debug window
public static void printvalues(int k)
{
var cc = (nestedict5[k]).Values.ToArray();
var ck = (nestedict5[k]).Keys.ToArray();
for (int i = 0; i < cc.Count(); i++)
{
DateTime dt = ck[i];
String dcandle = cc[i];
Debug.WriteLine(string.Format("pids1:{0},Count{1}, datetime:{2}: ticks:{3}", k * 100 + i, cc.Count(), ck[i], cc[i]));
}
}
Question is at the end of the loop i shall get 6 members in both odd and even minute
whereas due to some error i am getting 12 members in all/both odd and even key outer dictionary help
Here is output in debug windows
pids1:700100,Count1, datetime:12/10/2014 6:39:07 AM: ticks:odd ok
even key results:
pids1:700000,Count2, datetime:12/10/2014 6:39:07 AM: ticks:odd not ok
pids1:700001,Count2, datetime:12/10/2014 6:40:07 AM: ticks:even ok
odd key results:
pids1:700100,Count3, datetime:12/10/2014 6:39:07 AM: ticks:odd ok
pids1:700101,Count3, datetime:12/10/2014 6:40:07 AM: ticks:even not ok
pids1:700102,Count3, datetime:12/10/2014 6:41:07 AM: ticks:odd ok
The problem continue's so on till all loops as odd and even keys appear in both key values!?? which is not desired and only odd key should have odd values and even key even values
pids1:700000,Count4, datetime:12/10/2014 6:39:07 AM: ticks:odd
pids1:700001,Count4, datetime:12/10/2014 6:40:07 AM: ticks:even
pids1:700002,Count4, datetime:12/10/2014 6:41:07 AM: ticks:odd
pids1:700003,Count4, datetime:12/10/2014 6:42:07 AM: ticks:even
-- modified 9-Dec-14 21:13pm.
|
|
|
|
|
namespace CollectionsTest
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Runtime;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Threading;
class Program
{
static void Main(string[] args)
{
basictestc();
}
// loop to print odd and even key values in debug window
public static void printvalue(int k)
{
var cc = (Cnestedict5[k]).Values.ToArray();
var ck = (Cnestedict5[k]).Keys.ToArray();
for (int i = 0; i < cc.Count(); i++)
{
DateTime dt = ck[i];
String dcandle = cc[i];
Debug.WriteLine(string.Format("pids1:{0},Count{1}, datetime:{2}: ticks:{3}", k * 100 + i, cc.Count(), ck[i], cc[i]));
}
}
public static ConcurrentDictionary<int, ConcurrentDictionary<DateTime, String>> Cnestedict5 = new ConcurrentDictionary<int, ConcurrentDictionary<DateTime, string>>();
public static void basictestc()
{
int mk = 7001, nk = 7000;
DateTime ddn = DateTime.Now;
ConcurrentDictionary<DateTime, string> cd = new ConcurrentDictionary<DateTime, string>();
Cnestedict5.TryAdd(mk, cd); Cnestedict5.TryAdd(nk, cd);
for (int i = 0; i < 12; i++)
{
ddn = ddn.AddMinutes(1);
if (ddn.Minute % 2 != 0)
{
Cnestedict5.GetOrAdd(mk, n => new ConcurrentDictionary<DateTime, string>()).TryAdd(ddn, "odd");
printvalue(mk);
}
else if (ddn.Minute % 2 == 0)
{
Cnestedict5.GetOrAdd(nk, n => new ConcurrentDictionary<DateTime, string>()).TryAdd(ddn, "even");
printvalue(nk);
}
}
}
}
}
|
|
|
|
|
Please format your code properly. Also, what is your question?
|
|
|
|
|
now code is working when i replaced line
Cnestedict5.TryAdd(mk, cd); Cnestedict5.TryAdd(nk, cd);
with corrected one (Answer)
Cnestedict5.TryAdd(mk, new ConcurrentDictionary<DateTime, string>()); Cnestedict5.TryAdd(nk, new ConcurrentDictionary<DateTime, string>());
Thanks to all those who came forward to help me solve this problem
|
|
|
|
|
Hi,
I have a situation where I need to show data from database to textboxes. These textboxes has to be dynamically created and can be editable. I am able to create textboxes as follows:
string[] myData = liD1.ToArray();
public void showData()
{
for (int i = 0; i < myData.Length; i++)
{
if (txtMore.FindControl("txtD1StartTime" + i) == null)
{
txtStart1 = new TextBox();
lblStart1 = new Label();
txtStart1.ID = "txtD1S" + i;
lblStart1.ID = "lblD1S" + i;
txtStart1.Text = myData[i].ToString();
lblStart1.AssociatedControlID = txtStart1.ID;
lblStart1.Text = "Data" + i;
txtMore.Controls.Add(lblStart1);
txtMore.Controls.Add(txtStart1);
}
}
}
In my ascx page, I am loading those textboxes in
as follows:
<ul class="txtMore" id="txtMore" runat="server">
</ul>
showData() function is loading data with dynamically created textboxes. This is working fine. Now If i edit textboxes and try to get new data, it is not giving me anything. Actually it couldn't even find that control. Code is as shown below:
public void getData()
{
for (int i = 0; i < myData.Length; i++)
{
TextBox t = txtMore.FindControl("txtD1S" + i) as TextBox;
if (t != null)
{
string temp = t.Text;
}
}
}
Even though I have dynamically loaded textboxes from showData(), in getData(),it is not able to find any control. Please help.
Dhyanga
|
|
|
|
|
You've already posted this question in QA:
problem with dynamicall loaded textbox values[^]
Don't post the same question in multiple places on the same site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm trying to read the buffer modified by the native function ntQueryEaFile.
Here is it's definition :
NTSTATUS NtQueryEaFile
(
HANDLE hFile,
PIO_STATUS_BLOCK iosb,
PVOID buffer,
ULONG length,
BOOLEAN single_entry,
PVOID ea_list,
ULONG ea_list_len,
PULONG ea_index,
BOOLEAN restart
)
I'm having trouble with the PVOID buffer (output buffer). The description reads :
"Caller's allocated buffer for output data. See FILE_FULL_EA_INFORMATION for detailed description of fields avaiable in buffer."
Here is the C++ def of this struct:
typedef struct _FILE_FULL_EA_INFORMATION {
ULONG NextEntryOffset;
UCHAR Flags;
UCHAR EaNameLength;
USHORT EaValueLength;
CHAR EaName[1];
} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
Now my C# code:
[DllImport("ntdll.dll")]
public static extern uint NtQueryEaFile(
Microsoft.Win32.SafeHandles.SafeFileHandle handle,
ref IO_STATUS_BLOCK iosb,
out IntPtr buffer,
uint length,
byte single_entry,
IntPtr eaList,
uint ea_list_len,
IntPtr ea_index,
byte restart
);
public struct FILE_FULL_EA_INFORMATION
{
public uint NextEntryOffset;
public byte Flags;
public byte EaNameLength;
public ushort EaValueLength;
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 1)]
public string EaName;
}
public const int MAX_EA_NAME_LEN = 256;
public const int MAX_EA_VALUE_LEN = 65536;
and the function call :
FILE_FULL_EA_INFORMATION FEAI = new FILE_FULL_EA_INFORMATION();
int EA_BUFSIZ = Marshal.SizeOf(FEAI) + MAX_EA_NAME_LEN + MAX_EA_VALUE_LEN;
IntPtr p_FEAI = Marshal.AllocHGlobal(EA_BUFSIZ);
Marshal.StructureToPtr(FEAI, p_FEAI, false);
status = NtQueryEaFile(hFile, ref ioStatusBlock, out p_FEAI, System.Convert.ToUInt32(EA_BUFSIZ), returnSingleEntry, IntPtr.Zero, 0, IntPtr.Zero, restartScan);
status returns
0xC0000005
STATUS_ACCESS_VIOLATION
Any ideas how to fix this ? Thanks for your help !
|
|
|
|
|
Probably because you have restricted EaName to 1 byte in length. The C++ structure is used only via a pointer, and the item CHAR EaName[1]; is used to show where that item starts, but it may be of any length. You need to ensure that you provide enough space in your C# struct to allow for whatever length of string is to be inserted there.
|
|
|
|
|
The issue comes while generating heavy report after increasing packet size and connection timeout.
microsoft told that it is a bug in the product, for that we need to make hotfixing on our server. I there any another solution to do that if hotfixing is not possible
|
|
|
|
|
I've hit a road block and can't figure out why I am getting this response back. It appears that it connects to the server but it returns:
"System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server server2.domain.local failed with the following error message: An invalid argument was supplied".
I enabled everything I thought on the remote computer:
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}
winrm set winrm/config/client @{TrustedHosts="*"}
I'm trying to remote powershell so I can run Citrix powershell commands from another computer and here is what I have:
try
{
XenDesktop7 xd = new XenDesktop7("http://server2.domain.local:5985/wsman", @"DOMAIN\Administrator", "#######");
string[] blah = xd.GetCatalogs();
foreach (var b in blah)
{
Console.WriteLine(b);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
public CitrixPowershell(string uri, string username, string password)
{
this._connection = GetConnection(uri, username, password);
PSSnapInException snapinException;
_runspace = RunspaceFactory.CreateRunspace(_connection);
_runspace.Open();
_runspace.RunspaceConfiguration.AddPSSnapIn("Citrix.*.Admin.V*", out snapinException);
_powershell = PowerShell.Create();
_powershell.Runspace = _runspace;
}
private WSManConnectionInfo GetConnection(string uri, string username, string password)
{
SecureString pwd = new SecureString();
foreach (char x in password)
pwd.AppendChar(x);
PSCredential ps = new PSCredential(username, pwd);
WSManConnectionInfo wsinfo = new WSManConnectionInfo(false, "server2.domain.local", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.PowerShell", ps);
wsinfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
wsinfo.ProxyAuthentication = AuthenticationMechanism.Negotiate;
return wsinfo;
}
|
|
|
|
|
JD86 wrote: failed with the following error message: An invalid argument was supplied". Somewhere in your application there is a line of code that has a bad parameter. Identify that and you are on your way to a solution.
|
|
|
|
|
|
JD86 wrote: this should be working. Maybe so, but you still need to do some debugging to find out why it isn't.
|
|
|
|
|
Well it turns out the code actually does work. I'm not able to get it to work running it from my Server 2012 R2 lab server but from my 2008 R2 lab server it runs fine. I'll have to do some more investigating but at least I know the code is right!
Thanks!
|
|
|
|
|
How can I create a nested TreeView for Windows 8.1 app , data will be bind at runtime using C#? There is no Treeview Control in Windows 8.1 Development.
|
|
|
|
|
Bhola S. Parit wrote: There is no Treeview Control in Windows 8.1 Development I'm not sure if this will meet your needs, but: [^].
And, when use the term "nested," what does that mean: isn't a TreeView an example of a structure designed to express "nesting" already ?
I don't work with XAML or RT, but I know one developer who uses the GroupedGridView to represent hierarchy: [^].
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|