示例#1
0
        public static void Run()
        {
            CrossVersionTracking.Current.Track();

            Crashes.GetErrorAttachment = (report) => ErrorAttachment.AttachmentWithText(CrossVersionTracking.Current.ToString());

            if (!string.IsNullOrEmpty(PrivateKeys.MobileCenter.AppSecret))
            {
                MobileCenter.Start(PrivateKeys.MobileCenter.AppSecret,
                                   typeof(Microsoft.Azure.Mobile.Analytics.Analytics),
                                   typeof(Microsoft.Azure.Mobile.Crashes.Crashes));
            }

            PclExportClient.Configure();

            JsonHttpClient.GlobalHttpMessageHandlerFactory = () => new NativeMessageHandler();

            Settings.RegisterDefaultSettings();

#if __ANDROID__
            Settings.VersionNumber = CrossVersionTracking.Current.CurrentVersion;

            Settings.BuildNumber = CrossVersionTracking.Current.CurrentBuild;
#endif
        }
示例#2
0
 public ErrorAttachment GetErrorAttachment(ErrorReport report)
 {
     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
     {
         if (GetErrorAttachmentLabel != null)
         {
             GetErrorAttachmentLabel.Text = TestStrings.DidGetErrorAttachmentText;
         }
     });
     return(ErrorAttachment.AttachmentWithText("hello"));
 }
        ErrorAttachment ErrorAttachmentForReport(ErrorReport report)
        {
            MobileCenterLog.Info(LogTag, "Getting error attachment for error report");
            string text = "This is an error attachment for Android";

            if (report.iOSDetails != null)
            {
                text = "This is an error attachment for iOS";
            }

            return(ErrorAttachment.AttachmentWithText(text));
        }
示例#4
0
        public async Task <List <AttachmentDTO> > Add(int errorId, HttpRequestMessage request)
        {
            // Check if the request contains multipart/form-data.
            if (!request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = new StreamProvider(root);

            try
            {
                await request.Content.ReadAsMultipartAsync(provider);

                using (UoW)
                {
                    var error       = UoW.Errors.Get(errorId);
                    var attachments = new List <ErrorAttachment>();
                    if (error != null)
                    {
                        foreach (MultipartFileData file in provider.FileData)
                        {
                            var attachment = new ErrorAttachment()
                            {
                                Author           = CurrentUser,
                                Error            = error,
                                UploadDate       = DateTime.UtcNow,
                                OriginalFileName = file.Headers.ContentDisposition.FileName.Replace("\"", string.Empty),
                                FileName         = file.LocalFileName.Substring(file.LocalFileName.LastIndexOf('\\') + 1)
                            };
                            attachments.Add(attachment);
                        }
                        UoW.ErrorAttachments.AddRange(attachments);
                        UoW.Complete();
                    }
                    return(Mapper.Map <List <AttachmentDTO> >(attachments));
                }
            }
            catch (System.Exception e)
            {
                throw new ApplicationOperationException(e.Message, HttpStatusCode.InternalServerError);
            }
        }
        public string SaveMainErrorDetails(ErrorMaster errorObjParam, SolutionMaster solObjParam, ErrorAttachment[] errorImageList,
                                           ErrorAttachment[] solutionImageList, bool isSolutionAddForError, bool isErrorWithSolution, int userId = 1)
        {
            using (TransactionScope scope1 = new TransactionScope())
            {
                try
                {
                    string formattedDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);

                    var ErrorCollection    = mongoDatabaseRunTime.GetCollection <ErrorMaster>("ErrorMaster");
                    var SolutionCollection = mongoDatabaseRunTime.GetCollection <SolutionMaster>("SolutionMaster");

                    int newErrorID    = GetNewErrorID();
                    int newSolutionID = GetNewSolutionID();

                    //To Convert Image array to list
                    List <ErrorAttachment> _ErrorImgList = new List <ErrorAttachment>();
                    List <ErrorAttachment> _SolutionImgList = new List <ErrorAttachment>();
                    ErrorAttachment        _ErrorImgFile, _SolutionImageFile;

                    //To store solutions
                    List <SolutionMaster> _SolutionMasterList = new List <SolutionMaster>();

                    //Images for error
                    if (errorImageList != null)
                    {
                        foreach (var imgMedia in errorImageList)
                        {
                            _ErrorImgFile                   = new ErrorAttachment();
                            _ErrorImgFile.MediaType         = imgMedia.MediaType;
                            _ErrorImgFile.MediaName         = imgMedia.MediaName;
                            _ErrorImgFile.IsErrorAttachment = imgMedia.IsErrorAttachment;
                            _ErrorImgFile.MediaURL          = imgMedia.MediaURL;
                            _ErrorImgFile.ClientId          = errorObjParam.ClientId;
                            _ErrorImgFile.ErrorId           = newErrorID;
                            _ErrorImgFile.IsErrorAttachment = imgMedia.IsErrorAttachment;
                            _ErrorImgFile.MediaMIMEType     = imgMedia.MediaMIMEType;
                            _ErrorImgFile.MediaPath         = imgMedia.MediaPath;
                            _ErrorImgList.Add(_ErrorImgFile);
                        }
                    }

                    //Images for solution
                    if (solutionImageList != null)
                    {
                        foreach (var imgMedia in solutionImageList)
                        {
                            _SolutionImageFile                   = new ErrorAttachment();
                            _SolutionImageFile.MediaType         = imgMedia.MediaType;
                            _SolutionImageFile.MediaName         = imgMedia.MediaName;
                            _SolutionImageFile.MediaURL          = imgMedia.MediaURL;
                            _SolutionImageFile.ClientId          = errorObjParam.ClientId;
                            _SolutionImageFile.ErrorId           = newErrorID;
                            _SolutionImageFile.IsErrorAttachment = imgMedia.IsErrorAttachment;
                            _SolutionImageFile.MediaMIMEType     = imgMedia.MediaMIMEType;
                            _SolutionImageFile.MediaPath         = imgMedia.MediaPath;
                            _SolutionImgList.Add(_SolutionImageFile);
                        }
                    }

                    if (isErrorWithSolution == false && isSolutionAddForError == false)
                    {
                        var errorTuple = new ErrorLogDataAccess.DataClasses.ErrorMaster()
                        {
                            ErrorId          = newErrorID,
                            ErrorCode        = errorObjParam.ErrorCode,
                            DomainId         = errorObjParam.DomainId,
                            FieldId          = errorObjParam.FieldId,
                            ClientId         = errorObjParam.ClientId,
                            ErrorCaption     = errorObjParam.ErrorCaption,
                            ErrorDescription = errorObjParam.ErrorDescription,
                            UserId           = userId,//Must get the userID from session later
                            ErrorLogDate     = formattedDate,
                            ErrorAttachments = _ErrorImgList.ToList(),
                        };

                        ErrorCollection.InsertOneAsync(errorTuple);
                    }
                    else if (isErrorWithSolution == true)
                    {
                        var solutionTuple = new ErrorLogDataAccess.DataClasses.SolutionMaster()
                        {
                            SolutionId       = newSolutionID,
                            SolutionCode     = solObjParam.SolutionCode,
                            ErrorId          = newErrorID,
                            DomainId         = solObjParam.DomainId,
                            FieldId          = solObjParam.FieldId,
                            ClientId         = solObjParam.ClientId,
                            UserId           = userId,
                            SolutionComment  = solObjParam.SolutionComment,
                            SolutionLogDate  = formattedDate,
                            ErrorAttachments = _SolutionImgList.ToList()
                        };

                        _SolutionMasterList.Add(solutionTuple);

                        var errorTuple = new ErrorLogDataAccess.DataClasses.ErrorMaster()
                        {
                            ErrorId          = newErrorID,
                            ErrorCode        = errorObjParam.ErrorCode,
                            DomainId         = errorObjParam.DomainId,
                            FieldId          = errorObjParam.FieldId,
                            ClientId         = errorObjParam.ClientId,
                            ErrorCaption     = errorObjParam.ErrorCaption,
                            ErrorDescription = errorObjParam.ErrorDescription,
                            UserId           = 1,//Must get the userID from session later
                            ErrorLogDate     = formattedDate,
                            ErrorAttachments = _ErrorImgList.ToList(),
                            SolutionMasters  = _SolutionMasterList.ToList()
                        };

                        //First add the error
                        ErrorCollection.InsertOne(errorTuple);

                        //Then add the solution
                        SolutionCollection.InsertOne(solutionTuple);
                    }

                    else if (isSolutionAddForError == true)
                    {
                        //Get the specific error tuple/document ID
                        var errorTupleId = ErrorCollection.AsQueryable()
                                           .Where(a => a.ErrorCode == errorObjParam.ErrorCode)
                                           .FirstOrDefault().ErrorId;

                        //Get the existing solutions for this error
                        _SolutionMasterList = SolutionCollection.AsQueryable()
                                              .Where(a => a.ErrorId == errorTupleId).ToList();

                        var solutionTuple = new ErrorLogDataAccess.DataClasses.SolutionMaster()
                        {
                            SolutionId       = newSolutionID,
                            SolutionCode     = solObjParam.SolutionCode,
                            ErrorId          = errorTupleId,
                            DomainId         = solObjParam.DomainId,
                            FieldId          = solObjParam.FieldId,
                            ClientId         = solObjParam.ClientId,
                            UserId           = userId,
                            SolutionComment  = solObjParam.SolutionComment,
                            SolutionLogDate  = formattedDate,
                            ErrorAttachments = _SolutionImgList.ToList()
                        };

                        _SolutionMasterList.Add(solutionTuple);

                        //Add the solution to the document
                        SolutionCollection.InsertOne(solutionTuple);


                        var filterObj = Builders <ErrorLogDataAccess.DataClasses.ErrorMaster> .Filter.Eq("ErrorCode", errorObjParam.ErrorCode);

                        var updateObj = Builders <ErrorLogDataAccess.DataClasses.ErrorMaster> .Update
                                        .Set("LastUpdatedDate", formattedDate)
                                        .Set("SolutionMasters", _SolutionMasterList)
                                        .CurrentDate("lastModified");

                        //Then update the ErrorMaster document with the updated SolutionMaster list
                        ErrorCollection.UpdateOne(filterObj, updateObj);
                    }


                    scope1.Complete();

                    return(errorObjParam.ErrorCode);
                }
                catch (Exception ex)
                {
                    scope1.Dispose();
                    //return "0000";
                    throw;
                }
            }
        }