Log4Net deadlock in AppenderSkeleton.DoAppend - log4net

I use log4net in a multi threaded service. Andat some point unexpectedly the service stops to respond. I checked the dump of the process and the stack is below.
This is the appender configuration :
var roller = new RollingFileAppender();
roller.LockingModel = new MinimalLock();
roller.File = #"logs\Log_Tabsters_" + appName + "_";
roller.DatePattern = "yyyy-MM-dd'.log'";
roller.StaticLogFileName = false;
roller.AppendToFile = true;
roller.RollingStyle = RollingMode.Composite;
roller.Layout = patternLayout;
roller.MaxSizeRollBackups = 10;
roller.MaximumFileSize = "1GB";
roller.ActivateOptions();
var buffer = new BufferingForwardingAppender();
buffer.BufferSize = 100;
buffer.Lossy = false;
buffer.AddAppender(roller);
buffer.ActivateOptions();
hierarchy.Root.AddAppender(buffer);
var console = new ColoredConsoleAppender();
var mappingError = new LevelColors();
mappingError.Level = Level.Error;
mappingError.ForeColor = Colors.White;
mappingError.BackColor = Colors.Red;
console.AddMapping(mappingError);
var mappingWarn = new LevelColors();
mappingWarn.Level = Level.Warn;
mappingWarn.ForeColor = Colors.White;
mappingWarn.BackColor = Colors.Yellow;
console.AddMapping(mappingWarn);
console.Layout = patternLayout;
console.ActivateOptions();
hierarchy.Root.AddAppender(console);
I see that the threads are stuck in DoAppend
the stack trace is
log4net.dll!log4net.Appender.AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent loggingEvent)
log4net.dll!log4net.Util.AppenderAttachedImpl.AppendLoopOnAppenders(log4net.Core.LoggingEvent loggingEvent)
log4net.dll!log4net.Repository.Hierarchy.Logger.CallAppenders(log4net.Core.LoggingEvent loggingEvent)
log4net.dll!log4net.Repository.Hierarchy.Logger.ForcedLog(System.Type callerStackBoundaryDeclaringType, log4net.Core.Level level, object message, System.Exception exception)
log4net.dll!log4net.Repository.Hierarchy.Logger.Log(System.Type callerStackBoundaryDeclaringType, log4net.Core.Level level, object message, System.Exception exception)
log4net.dll!log4net.Core.LogImpl.Warn(object message)
TabstersCore.dll!Tabsters.Logger.AddLog(string module, string log, Tabsters.LogType logType) Line 129

Related

How to create a custom Order Type using customization plug-in (Acumatica)

How to create a custom Order Type using customization plug-in? I used a manual from here. I tried to initialize required filds from exesting order type, but without success. I tried to use Update method on graph as well. Every time I get a common error: Inserting 'Order Type' record raised at least one error. Please review the errors.' and can't see what field the issue is related to. My UpdateDatabase() method:
public override void UpdateDatabase()
{
SOOrderTypeMaint orderTypeGraph = PXGraph.CreateInstance<SOOrderTypeMaint>();
string newOrderTypeName = "SR";
var existingOrderType = orderTypeGraph.soordertype.Search<SOOrderType.orderType>(newOrderTypeName);
if (existingOrderType.Count != 0)
{
WriteLog(string.Format("{0} type already exist", newOrderTypeName));
}
else
{
SOOrderType exempleOrderType = SOOrderType.PK.Find(orderTypeGraph, "SO");
SOOrderTypeOperation exgrid = SOOrderTypeOperation.PK.Find(orderTypeGraph, "SO", "I");
var ourGrid = new SOOrderTypeOperation();
var sROrderType = new SOOrderType();
ourGrid.Operation = exgrid.Operation;
ourGrid.INDocType = exgrid.INDocType;
ourGrid.OrderPlanType = exgrid.OrderPlanType;
ourGrid.ShipmentPlanType = exgrid.ShipmentPlanType;
ourGrid.RequireReasonCode = exgrid.RequireReasonCode;
sROrderType.OrderType = newOrderTypeName;
sROrderType.Descr = "description";
sROrderType.Active = exempleOrderType.Active;
sROrderType.OrderNumberingID = exempleOrderType.OrderNumberingID;
sROrderType.FreightSubID = exempleOrderType.FreightSubID;
sROrderType.DiscountAcctID = exempleOrderType.DiscountAcctID;
sROrderType.DiscountSubID = exempleOrderType.DiscountSubID;
sROrderType.Behavior = exempleOrderType.Behavior;
sROrderType.DefaultOperation = exempleOrderType.DefaultOperation;
sROrderType.ARDocType = exempleOrderType.ARDocType;
sROrderType.AllowQuickProcess = exempleOrderType.AllowQuickProcess;
sROrderType.DiscSubMask = exempleOrderType.DiscSubMask;
sROrderType.CalculateFreight = exempleOrderType.CalculateFreight;
sROrderType.SalesSubMask = exempleOrderType.SalesSubMask;
sROrderType.FreightSubMask = exempleOrderType.FreightSubMask;
sROrderType.FreightAcctID = exempleOrderType.FreightAcctID;
sROrderType.InvoiceNumberingID = exempleOrderType.InvoiceNumberingID;
sROrderType.RequireShipping = exempleOrderType.RequireShipping;
orderTypeGraph.soordertype.Insert(sROrderType);
orderTypeGraph.operations.Insert(ourGrid);
orderTypeGraph.soordertype.Update(sROrderType);
orderTypeGraph.operations.Update(ourGrid);
orderTypeGraph.Save.Press();
WriteLog(string.Format("{0} type has been added", newOrderTypeName));
}
}
Acumatica trace:
8/6/2021 6:27:14 PM Error:
Publishing of a customization project failed with an error CustomizationProjects:TestAssignment2
PX.Data.PXOuterException: Error: Inserting 'Order Type' record raised at least one error. Please review the errors.
at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)
at PX.Data.PXCache`1.PersistInserted(Object row, Boolean bypassInterceptor)
at PX.Data.PXCache`1.Persist(PXDBOperation operation)
at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)
at PX.Data.PXGraph.Persist()
at PX.Data.PXSave`1.d__2.MoveNext()
at PX.Data.PXAction`1.d__33.MoveNext()
at PX.Data.PXAction`1.d__33.MoveNext()
at PX.Data.PXAction`1.PressImpl(Boolean internalCall, Boolean externalCall)
at PX.Data.PXAction`1.Press()
at TestAssignment2.ServiceRepairCreator.UpdateDatabase() in D:\AcumaticaFolder\TestAssignment\App_Data\Projects\TestAssignment2\TestAssignment2\ServiceRepairCreator.cs:line 58
at Customization.CstWebsiteStorage.UpdateDatabaseFromPlugin(CustomizationPlugin plugin, PXPublishOptions options)
at Customization.CstWebsiteStorage.RunPluginsDbUpdate()
at PX.Web.Customization.Controls.Publish.RunPlugins(HttpResponse response)
The problem was in mandatory fields. This method works when u need to create a new order type. Thanks, everyone, for your help.
public override void UpdateDatabase()
{
SOOrderTypeMaint graph = PXGraph.CreateInstance<SOOrderTypeMaint>();
string newOrderTypeName = Constants.serviceRepairOrderType;
var existingOrderType = graph.soordertype.Search<SOOrderType.orderType>(newOrderTypeName);
if (existingOrderType.Count != 0)
{
WriteLog(string.Format("{0} type already exist", newOrderTypeName));
}
else
{
SOOrderType exempleOrderType = SOOrderType.PK.Find(graph, SOOrderTypeConstants.SalesOrder);
var soSRTypeGeneral = graph.soordertype.Insert();
soSRTypeGeneral.OrderType = newOrderTypeName;
soSRTypeGeneral.Descr = "description";
soSRTypeGeneral.Template = exempleOrderType.Template;
soSRTypeGeneral.Behavior = exempleOrderType.Behavior;
soSRTypeGeneral.ARDocType = exempleOrderType.ARDocType;
soSRTypeGeneral.INDocType = exempleOrderType.INDocType;
soSRTypeGeneral.FreightSubID = exempleOrderType.FreightSubID;
soSRTypeGeneral.OrderPlanType = exempleOrderType.OrderPlanType;
soSRTypeGeneral.DiscountSubID = exempleOrderType.DiscountSubID;
soSRTypeGeneral.FreightAcctID = exempleOrderType.FreightAcctID;
soSRTypeGeneral.DiscountAcctID = exempleOrderType.DiscountAcctID;
soSRTypeGeneral.ShipmentPlanType = exempleOrderType.ShipmentPlanType;
soSRTypeGeneral.OrderNumberingID = exempleOrderType.OrderNumberingID;
soSRTypeGeneral.DefaultOperation = exempleOrderType.DefaultOperation;
soSRTypeGeneral.DaysToKeep = exempleOrderType.DaysToKeep;
soSRTypeGeneral.COGSSubMask = exempleOrderType.COGSSubMask;
soSRTypeGeneral.DiscSubMask = exempleOrderType.DiscSubMask;
soSRTypeGeneral.OrderPriority = exempleOrderType.OrderPriority;
soSRTypeGeneral.FreightSubMask = exempleOrderType.FreightSubMask;
soSRTypeGeneral.RequireShipping = exempleOrderType.RequireShipping;
soSRTypeGeneral.DiscAcctDefault = exempleOrderType.DiscAcctDefault;
soSRTypeGeneral.COGSAcctDefault = exempleOrderType.COGSAcctDefault;
soSRTypeGeneral.SupportsApproval = exempleOrderType.SupportsApproval;
soSRTypeGeneral.AllowQuickProcess = exempleOrderType.AllowQuickProcess;
soSRTypeGeneral.FreightAcctDefault = exempleOrderType.FreightAcctDefault;
var soSRTypeTemplate = graph.operations.Insert();
soSRTypeTemplate.OrderType = soSRTypeGeneral.OrderType;
soSRTypeTemplate.Active = true;
soSRTypeTemplate.InvtMult = -1;
soSRTypeTemplate.Operation = "I";
soSRTypeTemplate.INDocType = "INV";
soSRTypeTemplate.OrderPlanType = "60";
soSRTypeTemplate.ShipmentPlanType = "61";
var soSRTypeQuickParam = graph.quickProcessPreset.Insert();
soSRTypeQuickParam.OrderType = soSRTypeGeneral.OrderType;
soSRTypeQuickParam.UpdateIN = true;
soSRTypeQuickParam.CreateShipment = true;
soSRTypeQuickParam.PrepareInvoice = true;
soSRTypeQuickParam.ConfirmShipment = true;
graph.Persist();
WriteLog(string.Format("{0} type has been added", newOrderTypeName));
}
}

I have free DocuSign Signature Appliance Developer Sandbox account.but can not perform signature operation using DssSign

I have a free DocuSign Signature Appliance Developer Sandbox account.I want to use "https://prime.cosigntrial.com:8080/SAPIWS/dss.asmx" and wan to use DssSign service method to create and attach signature to pdf.But it reutrn "urn:oasis:names:tc:dss:1.0:resultmajor:ResponderError".Please help how can I get username and password to create a new signature programmatically and assign to a pdf using DocuSign API
I already download the code samples found Git "docusign-signature-appliance-api-recipes-master" but can not sucess.
//Sign PDF file
public bool SignPDFFile(
string FileToSign,
string UserName,
string Password,
int X,
int Y,
int Width,
int Height,
int Page,
bool isVisible)
{
//Create Request object contains signature parameters
RequestBaseType Req = new RequestBaseType();
Req.OptionalInputs = new RequestBaseTypeOptionalInputs();
//Here Operation Type is set: Verify/Create Signature Field/Sign/etc
Req.OptionalInputs.SignatureType = SignatureTypeFieldCreateSign;
//Configure Create and Sign operation parameters:
Req.OptionalInputs.ClaimedIdentity = new ClaimedIdentity();
Req.OptionalInputs.ClaimedIdentity.Name = new NameIdentifierType();
Req.OptionalInputs.ClaimedIdentity.Name.Value = UserName; //User Name
Req.OptionalInputs.ClaimedIdentity.Name.NameQualifier = " "; //Domain (relevant for Active Directory environment only)
Req.OptionalInputs.ClaimedIdentity.SupportingInfo = new CoSignAuthDataType();
Req.OptionalInputs.ClaimedIdentity.SupportingInfo.LogonPassword = Password; //User Password
Req.OptionalInputs.SAPISigFieldSettings = new SAPISigFieldSettingsType();
Req.OptionalInputs.SAPISigFieldSettings.X = X; //Signature Field X coordinate
Req.OptionalInputs.SAPISigFieldSettings.XSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Y = Y; //Signature Field Y coordinate
Req.OptionalInputs.SAPISigFieldSettings.YSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Page = Page; //Page number the signature field will appear on
Req.OptionalInputs.SAPISigFieldSettings.PageSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Width = Width; //Signature Field width
Req.OptionalInputs.SAPISigFieldSettings.WidthSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Height = Height; //Signature Field Height
Req.OptionalInputs.SAPISigFieldSettings.HeightSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Invisible = !isVisible; //Specifies whether the signature will be visible or not
Req.OptionalInputs.SAPISigFieldSettings.InvisibleSpecified = true;
// Set configuration parameters /////////////////////////////////////////////////////////
int numConfigurationParams = 6;
Req.OptionalInputs.ConfigurationValues = new ConfValueType[numConfigurationParams];
for (int i = 0; i < numConfigurationParams; i++)
{
Req.OptionalInputs.ConfigurationValues[i] = new ConfValueType();
}
// Add reason
Req.OptionalInputs.ConfigurationValues[0].ConfValueID = ConfIDEnum.Reason;
Req.OptionalInputs.ConfigurationValues[0].Item = "I am the author of this document";
// Add TSA:
/*
Req.OptionalInputs.ConfigurationValues[1].ConfValueID = ConfIDEnum.UseTimestamp;
Req.OptionalInputs.ConfigurationValues[1].Item = 1;
Req.OptionalInputs.ConfigurationValues[2].ConfValueID = ConfIDEnum.TimestampURL;
Req.OptionalInputs.ConfigurationValues[2].Item = "http://www.ca-soft.com/request.aspx";
Req.OptionalInputs.ConfigurationValues[3].ConfValueID = ConfIDEnum.TimestampAdditionalBytes;
Req.OptionalInputs.ConfigurationValues[3].Item = 4000;
Req.OptionalInputs.ConfigurationValues[4].ConfValueID = ConfIDEnum.TimestampUser;
Req.OptionalInputs.ConfigurationValues[4].Item = "";
Req.OptionalInputs.ConfigurationValues[5].ConfValueID = ConfIDEnum.TimestampPWD;
Req.OptionalInputs.ConfigurationValues[5].Item = "";
// OCSP (NOTE: Server must contain comodo CA in order to use the following OCSP URL)
Req.OptionalInputs.ConfigurationValues[4].ConfValueID = ConfIDEnum.UseOCSP;
Req.OptionalInputs.ConfigurationValues[4].Item = 1;
Req.OptionalInputs.ConfigurationValues[5].ConfValueID = ConfIDEnum.OCSPURL;
Req.OptionalInputs.ConfigurationValues[5].Item = "ocsp.comodoca.com";
*/
// End setting configuration parameters ////////////////////////////////////////////////
//Set Session ID
Req.RequestID = Guid.NewGuid().ToString();
//Prepare the Data to be signed
DocumentType doc1 = new DocumentType();
DocumentTypeBase64Data b64data = new DocumentTypeBase64Data();
Req.InputDocuments = new RequestBaseTypeInputDocuments();
Req.InputDocuments.Items = new object[1];
b64data.MimeType = "application/pdf"; //Can also be: application/msword, image/tiff, pplication/octet-string (ocsp/tsa are supported in PDF only)
Req.OptionalInputs.ReturnPDFTailOnlySpecified = true;
Req.OptionalInputs.ReturnPDFTailOnly = true;
b64data.Value = ReadFile(FileToSign, true); //Read the file to the Bytes Array
doc1.Item = b64data;
Req.InputDocuments.Items[0] = doc1;
//Call sign service
ResponseBaseType Resp = null;
try
{
// Create the Web Service client object
DSS service = new DSS();
service.Url = "https://prime.cosigntrial.com:8080/SAPIWS/dss.asmx"; //This url is constant and shouldn't be changed
// service.Url = "https://prime-dsa-devctr.docusign.net:8080/sapiws/dss.asmx"; //This url is constant and shouldn't be changed
SignRequest sreq = new SignRequest();
sreq.InputDocuments = Req.InputDocuments;
sreq.OptionalInputs = Req.OptionalInputs;
//Perform Signature operation
Resp = service.DssSign(sreq);
if (Resp.Result.ResultMajor != Success )
{
MessageBox.Show("Error: " + Resp.Result.ResultMajor + " " +
Resp.Result.ResultMinor + " " +
Resp.Result.ResultMessage.Value, "Error");
return false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
if (ex is WebException)
{
WebException we = ex as WebException;
WebResponse webResponse = we.Response;
if (webResponse != null)
MessageBox.Show(we.Response.ToString(), "Web Response");
}
return false;
}
//Handle Reply
DssSignResult sResp = (DssSignResult) Resp;
//object sig = sResp.SignatureObject.Item;
//SignatureObjectTypeBase64Signature sig = (SignatureObjectTypeBase64Signature) sResp.SignatureObject.Item;
DssSignResultSignatureObjectBase64Signature sig = (DssSignResultSignatureObjectBase64Signature)sResp.SignatureObject.Item;
byte[] signature = sig.Value;
return PDFAttachSignature(FileToSign, signature, true); //Attach Signature to the PDF file
}
display error urn:oasis:names:tc:dss:1.0:resultmajor:ResponderError

Log4j 1.x to Log4j 2.1.1 migration issue

I'm trying migrate code to version 2. But, I'm running into some issues with finding an alternative to getCurrentLoggers in log4j 2.1.1
import org.apache.logging.log4j.LogManager.getCurrentLoggers(); does not exist.
private ArrayList<LoggerName> getLoggerList() {
// Generate a list of all the loggers and levels
ArrayList<String> al = new ArrayList<String>();
HashMap<Object, Object> hm = new HashMap<Object, Object>();
ArrayList<LoggerName> list = new ArrayList<LoggerName>();
// Get RootLogger
Logger rootLogger = LogManager.getRootLogger();
String rootLoggerName = rootLogger.getName();
al.add(rootLoggerName);
hm.put(rootLoggerName, rootLogger);
// All Other Loggers ISSUE HERE
Enumeration e = LogManager.getCurrentLoggers();
while (e.hasMoreElements()) {
Logger t1Logger = (Logger) e.nextElement();
String loggerName = t1Logger.getName();
al.add(loggerName);
hm.put(loggerName, t1Logger);
}
String[] alLoggerStr = ((String[]) al.toArray(new String[0]));
Arrays.sort(alLoggerStr);
for (int i=0; i < alLoggerStr.length; i++) {
Logger logger = (Logger) hm.get(alLoggerStr[i]);
String name = logger.getName();
String level = logger.getLevel().toString();
String parent = GenFuncs.EMPTY_STRING;
if (logger.getParent() != null) {
parent = (logger.getParent().getName();
}
LoggerName logData = new LoggerNameImpl(name, parent, level);
list.add(logData);
}
return list;
}
Found answer from Stack Overflow
File configFile = new File("c:\\my_path\\log4j2.xml");
LoggerContext loggerContext = Configurator.initialize("my_config", null, configFile.toURI());
Configuration configuration = loggerContext.getConfiguration();
Collection<LoggerConfig> loggerConfigs = configuration.getLoggers().values();

HttpClient.PostAsync finishes cause of timeout on the second call

I have this code:
var content = new ByteArrayContent(Encoding.ASCII.GetBytes(String.Concat("GET\t", _licencia, "\n")));
var recibido = await _client.PostAsync(fullUri, content);
var response = recibido.StatusCode;
this.IsOnline = response == HttpStatusCode.OK;
string contenido = await recibido.Content.ReadAsStringAsync();
if (this.IsOnline)
{
string data = contenido.TrimEnd();
List<string> transacciones = String.IsNullOrEmpty(data) ? null : data.Split('\n').ToList();
var guardadas = ProcessTransactions(transacciones);
if (guardadas != null)
{
StringBuilder sb = new StringBuilder(String.Concat("OK\t", _licencia, "\n"));
content = new ByteArrayContent(Encoding.ASCII.GetBytes(sb.ToString()));
recibido = await _client.PostAsync(fullUri, content);
Please see the first PostAsync call:
var content = new ByteArrayContent(Encoding.ASCII.GetBytes(String.Concat("GET\t", _licencia, "\n")));
var recibido = await _client.PostAsync(fullUri, content);
In this case, content length is only 34 bytes. So far, so good. Server receives the requirement correctly. But now see the second PostAsync call:
StringBuilder sb = new StringBuilder(String.Concat("OK\t", _licencia, "\n"));
content = new ByteArrayContent(Encoding.ASCII.GetBytes(sb.ToString()));
recibido = await _client.PostAsync(fullUri, content);
In this case, content length is 33 bytes. However, that call gets blocked and finally it throws Task Cancelled Exception. This is because of the timeout, which is defined by the HttpClient to be 1 minute 40 seconds.
Why the second call gets blocked? How can I solve it?
Thanks
Jaime

Azure server not letting me use a NuGet package

I have a website hosted by Azure that includes a Web API which I'm using to develop an android app. I'm trying to upload a media file to the server where it's encoded by a media encoder and saved to a path. The encoder library is called "Media Toolkit" which I found here : https://www.nuget.org/packages/MediaToolkit/1.0.0.3
My server side code looks like this:
[HttpPost]
[Route("upload")]
public async Task<HttpResponseMessage> Upload(uploadFileModel model)
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
if (ModelState.IsValid)
{
string thumbname = "";
string resizedthumbname = Guid.NewGuid() + "_yt.jpg";
string FfmpegPath = Encoding_Settings.FFMPEGPATH;
string tempFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/video"), model.fileName);
string pathToFiles = HttpContext.Current.Server.MapPath("~/video");
string pathToThumbs = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/thumbs");
string finalPath = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/flv");
string resizedthumb = Path.Combine(pathToThumbs, resizedthumbname);
var outputPathVid = new MediaFile { Filename = Path.Combine(finalPath, model.fileName) };
var inputPathVid = new MediaFile { Filename = Path.Combine(pathToFiles, model.fileName) };
int maxWidth = 380;
int maxHeight = 360;
var namewithoutext = Path.GetFileNameWithoutExtension(Path.Combine(pathToFiles, model.fileName));
thumbname = model.VideoThumbName;
string oldthumbpath = Path.Combine(pathToThumbs, thumbname);
var fileName = model.fileName;
try
{
File.WriteAllBytes(tempFilePath, model.data);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
using (var engine = new Engine())
{
engine.GetMetadata(inputPathVid);
// Saves the frame located on the 15th second of the video.
var outputPathThumb = new MediaFile { Filename = Path.Combine(pathToThumbs, thumbname + ".jpg") };
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(0), CustomHeight = 360, CustomWidth = 380 };
engine.GetThumbnail(inputPathVid, outputPathThumb, options);
}
Image image = Image.FromFile(Path.Combine(pathToThumbs, thumbname + ".jpg"));
//var ratioX = (double)maxWidth / image.Width;
//var ratioY = (double)maxHeight / image.Height;
//var ratio = Math.Min(ratioX, ratioY);
var newWidth = (int)(maxWidth);
var newHeight = (int)(maxHeight);
var newImage = new Bitmap(newWidth, newHeight);
Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
Bitmap bmp = new Bitmap(newImage);
bmp.Save(Path.Combine(pathToThumbs, thumbname + "_resized.jpg"));
//File.Delete(Path.Combine(pathToThumbs, thumbname));
using (var engine = new Engine())
{
var conversionOptions = new ConversionOptions
{
VideoSize = VideoSize.Hd720,
AudioSampleRate = AudioSampleRate.Hz44100,
VideoAspectRatio = VideoAspectRatio.Default
};
engine.GetMetadata(inputPathVid);
engine.Convert(inputPathVid, outputPathVid, conversionOptions);
}
File.Delete(tempFilePath);
Video_Struct vd = new Video_Struct();
vd.CategoryID = 0; // store categoryname or term instead of category id
vd.Categories = "";
vd.UserName = model.username;
vd.Title = "";
vd.Description = "";
vd.Tags = "";
vd.Duration = inputPathVid.Metadata.Duration.ToString();
vd.Duration_Sec = Convert.ToInt32(inputPathVid.Metadata.Duration.Seconds.ToString());
vd.OriginalVideoFileName = model.fileName;
vd.VideoFileName = model.fileName;
vd.ThumbFileName = thumbname + "_resized.jpg";
vd.isPrivate = 0;
vd.AuthKey = "";
vd.isEnabled = 1;
vd.Response_VideoID = 0; // video responses
vd.isResponse = 0;
vd.isPublished = 1;
vd.isReviewed = 1;
vd.Thumb_Url = "none";
//vd.FLV_Url = flv_url;
vd.Embed_Script = "";
vd.isExternal = 0; // website own video, 1: embed video
vd.Type = 0;
vd.YoutubeID = "";
vd.isTagsreViewed = 1;
vd.Mode = 0; // filter videos based on website sections
//vd.ContentLength = f_contentlength;
vd.GalleryID = 0;
long videoid = VideoBLL.Process_Info(vd, false);
return result;
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}
}
When the debugger hits the line using (var engine = new Engine()) I get 500 internal server error thrown. I don't get this error testing it on the iis server. Since it works fine on my local server and not on the azure hosted server, I figured it had to do with the Azure service rather than an error in my code. If so is the case then how would I be able to get around this issue? I don't want to use azure blob storage as it would require a lot of changes to my code. Does anyone have any idea what might be the issue.
Any helpful suggestions are appreciated.
Server.MapPath works differently on Azure WebApps - change to:
string pathToFiles = HttpContext.Current.Server.MapPath("~//video");
Also, see this SO post for another approach.

Resources