public string GetMultimediaObject(GetMultimediaObject_Request request) { List <string> errors; GetMultimediaObject_Response response = GetMultimediaObject(request, out errors); string result = SerializeResponse(response, errors); return(result); }
public string MultimediaObjectUrlClicked(GetMultimediaObject_Request request, int id, int statusCode) { var ret = ""; try { StaticClicked(request, id, statusCode); } catch (Exception e) { ret = e.Message; } return(ret); }
public int GetMultimediaObjectBytes(string sessionId, int id, string Data0, string Data1, string Data2, string Data3, DateTime date, int requestType) { List <string> errors = null; try { var request = new GetMultimediaObject_Request { ID = id, SessionId = sessionId, Data0 = Data0, Data1 = Data1, Data2 = Data2, Data3 = Data3, RequestDate = date, RequestSource = requestType }; // pobranie obiektu multimedialnego var response = GetMultimediaObject(request, out errors); if (response != null) { // jeśli podczas pobrania obiektu wystąpiły błędy, zapisujemy je do pliku z logami if (errors != null && errors.Any()) { foreach (var error in response.ErrorMessage) { SaveMessageInLogFile(error); } errors.Clear(); } // jeśli istnieje plik obiektu multimedialnego, zwracamy go w postaci bajtów if (response.File != null && response.File.Contents != null) { Context.Response.ContentType = response.File.MimeType; Context.Response.BinaryWrite(response.File.Contents); Context.Response.StatusCode = 200; return(1); } } } catch (Exception ex) { var hierarchy = new List <Exception>(); ExceptionsHandlingHelper.HierarchizeError(ex, ref hierarchy); if (hierarchy.Count > 0) { if (errors == null) { errors = new List <string>(); } errors.AddRange(hierarchy.Select(s => s.Message + Environment.NewLine + s.StackTrace).Distinct().AsEnumerable()); } SaveErrorInLogFile(ex); } return(0); }
private void StaticClicked(GetMultimediaObject_Request request, int id, int statusCode) { var errors = new List <string>(); var hierarchy = new List <Exception>(); try { if (request != null) { var selectionRequest = new MultimediaObjectSelection.MultimediaObjectsSelectionParams { Data0 = request.Data0, Data1 = request.Data1, Data2 = request.Data2, Data3 = request.Data3, ID = id, RequestDate = DateTime.Now, SessionId = request.SessionId, RequestSource = (int) (System.Web.HttpContext.Current.Request.UserAgent == null ? Statistic.RequestSourceType.Desktop : Statistic.RequestSourceType.WWW), RequestIP = HttpContext.Current.Request.UserHostAddress }; using (var ctx = new AdServContext()) { var repositories = EFRepositorySet.CreateRepositorySet(ctx); try { var mos = new MultimediaObjectSelection(repositories); const string key = "FILESTREAM_OPTION"; var urlKey = ConfigurationManager.AppSettings[key]; if (urlKey != null && !string.IsNullOrEmpty(urlKey)) { bool filestreamOption; bool.TryParse(urlKey, out filestreamOption); } mos.SaveStatisticsEntry(selectionRequest, new AdFile { ID = id, StatusCode = statusCode }, true); } catch (Exception ex) { ExceptionsHandlingHelper.HierarchizeError(ex, ref hierarchy); if (hierarchy.Count > 0) { errors.AddRange(hierarchy.Select(s => s.Message + Environment.NewLine + s.StackTrace).Distinct().AsEnumerable()); } SaveErrorInLogFile(selectionRequest, ex); } } } else { errors.Add("Parametr requesta nie może być nullem."); } } catch (Exception ex) { ExceptionsHandlingHelper.HierarchizeError(ex, ref hierarchy); if (hierarchy.Count > 0) { errors.AddRange(hierarchy.Select(s => s.Message + Environment.NewLine + s.StackTrace).Distinct().AsEnumerable()); } SaveErrorInLogFile(ex); } }