File Locked

Discussions related to custom development with Select.
Post Reply
enendza
Posts: 75
Joined: Wed Oct 16, 2019 12:22 pm

File Locked

Post by enendza »

Hi -

Ever since we upgrade to the 4.6.8 release the file locking issue has escalated and we have to figure out how to clear locks.

Here is the scenario:

Automated process that runs and adds attachments. Automated process runs as a SoftPro user and attachs files using the SDK
Process fails and the order remains locked for OVER 30 minutes.

We had this same problem before 4.6.8, NOT nearly as frequently as we are seeing it now, and the locks would clear themselves a LOT quicker usually around 15 minutes.

PLEASE share with me how to force the lock be removed.

NOTE: We tried to enable Multi-User mode to get past this issue but management reported said it wasn't worth the other bugs that were found we had to disable multi-user.

Any advice is appreciated as.

Emma
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: File Locked

Post by BobRichards »

Sorry for the problems, Emma. I'll have to send this to the 4.6 developers to respond since I don't work with 4.6 much. Unfortunately I don't know when they will respond.

To be clear, this only occurs with the Attachment application? Does this problem occur when using the Select application?
Bob Richards, Senior Software Developer, SoftPro
enendza
Posts: 75
Joined: Wed Oct 16, 2019 12:22 pm

Re: File Locked

Post by enendza »

Bob -

Our automation process only does the one task of appending attachments to a SoftPro order so I don't know if this is an issue across all parts of the application.

Here is the code that is being executed- we check to see if the order is open in the error handler to ensure that we release the lock but it doesn't seem to be working. Any advice that the developers have is appreciated. As it gets later in the month and the business gets busier and busier this becomes a bigger issue

var os = ss.GetService<IOrderStore>();
IOrder order = null;
try
{
var oi = os.Orders
.Where(x => x.Number == document.OrderId.ToString())
.FirstOrDefault();
if (oi == null)
throw new Exception("Order Number is not valid, unable to find order by OrderNumber in the database");

string folderPath = String.Format(@"\\{0}\Attachments\{1}\", oi.Number, document.Folder);
using (order = os.OpenOrder(oi, OrderEditMode.ReadWrite))
{
IAttachmentFolder folderItem = order.Attachments.Items
.Where(t => (string)t.Path.ToLower() == folderPath.ToLower())
.Cast<IAttachmentFolder>()
.FirstOrDefault();

if (folderItem == null)
{
folderItem = order.Attachments.NewFolder();
folderItem.Name = document.Folder;
}

string filePath = Path.Combine(folderPath, Path.GetFileName(document.FileName));

IAttachmentFile fileItem = folderItem.Items
.Where(t => t.Path.ToLower() == filePath.ToLower())
.Cast<IAttachmentFile>()
.FirstOrDefault();

if (fileItem == null)
{
// Attach file.
IAttachmentFile newFile =
folderItem.NewFile(Path.GetFileNameWithoutExtension(document.FileName), file, Path.GetExtension(document.FileName), "", AttachmentSource.Attached);
os.ApplyChanges(order);
}
else
{
string revisionName = Path.GetFileNameWithoutExtension(document.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff") + Path.GetExtension(document.FileName);
IAttachmentFile newFile =
folderItem.NewFile(Path.GetFileNameWithoutExtension(revisionName), file, Path.GetExtension(document.FileName), "", AttachmentSource.Attached);
os.ApplyChanges(order);

}
os.CloseOrder(order);
}
}
catch (Exception ex)
{
if (os != null && order != null)
{
os.CloseOrder(order);
}
throw;
}
}
Post Reply