Esempio n. 1
0
        public void CloseProject()
        {
            if (hunter != null)
            {
                hunter.CloseHunter();
            }

            if (Paused)
            {
                Toogle();
            }

            hunter          = null;
            miPause.Enabled = false;
            miOpen.Visible  = true;
            miClose.Visible = false;

            foreach (var m in tsStrategies)
            {
                m.Enabled = true;
            }

            DownloadedList.Clear();
            AbandonFileList.Clear();
            AbandonLinkList.Clear();
            ExceptionList.Clear();
            WriteMessage("任务已关闭。");
            Text = "Hunter 3";
        }
Esempio n. 2
0
        public static ResultData TestByteCount(int maxByteCode, string filePath)
        {
            var result = new ResultData();

            byte[] bytes = File.ReadAllBytes(filePath);
            for (int i = 0; i < bytes.Length; i++)
            {
                var val = bytes[i];
                if (ExceptionList.ToList().Exists(x => x == val))
                {
                    result.ExceptionByteCount += 1;
                }
                else
                {
                    if (val > maxByteCode)
                    {
                        result.HighCodeByteCount += 1;
                    }

                    if (val <= maxByteCode)
                    {
                        result.StandardByteCount += 1;
                    }
                }
            }

            return(result);
        }
Esempio n. 3
0
 internal void AddException(string mask)
 {
     if (!ExceptionList.Contains(mask))
     {
         ExceptionList.Add(mask);
         OnExceptionChange(mask, false);
     }
 }
Esempio n. 4
0
 private void RemoveException(string mask)
 {
     if (ExceptionList.Contains(mask))
     {
         ExceptionList.Remove(mask);
         OnExceptionChange(mask, false);
     }
 }
Esempio n. 5
0
 public void setException(ExceptionInfo exceptionInfo)
 {
     if (exceptionInfo == null)
     {
         ExceptionList = new List <ExceptionInfo>();
     }
     ExceptionList.Add(exceptionInfo);
 }
Esempio n. 6
0
 public void AddException(Exception ex)
 {
     if (ExceptionList == null)
     {
         ExceptionList = new List <Exception>();
     }
     ExceptionList.Add(ex);
 }
 internal new void AddException(Exception exception)
 {
     // ArgumentNullException is not really accurate as the object which is dereferenced should already have been validated
     if (exception is ArgumentNullException nullException)
     {
         ExceptionList.Add(new ArgumentException(nullException.Message, nullException.ParamName));
     }
     ExceptionList.Add(exception);
 }
Esempio n. 8
0
 public void CancelShift(DateTime date)
 {
     if (ExceptionList.All(exep => exep.StartTime != date)) // toggle shift as canceled
     {
         ExceptionList.Add(ShiftTime.ShiftTimeFactory(date, _duration, false, false, this));
     }
     else // toggle shift to not canceled
     {
         ExceptionList.Remove(ExceptionList.FirstOrDefault(exep => exep.StartTime == date));
     }
 }
Esempio n. 9
0
 public void AddException(Exception exception)
 {
     try
     {
         ExceptionList.Add(exception);
         errorHandlingHelper.SetError(exception);
     }
     catch (Exception ex)
     {
     }
 }
 internal int ElmUnregisterException(int exceptionId)
 {
     foreach (Exception _ in ExceptionList)
     {
         if (_.exceptionId == exceptionId)
         {
             ExceptionList.Remove(_); // remove the temporary object from the list
             return(0);
         }
     }
     return(1); // exception ID not found
 }
Esempio n. 11
0
        //x.Equals(default) && y.Equals(default) (y/x are left on their default values)
        //though x.Equals(null) is better form, many fields and properties are set to seomthing besides null on construction and can never be null (short of reflection as we do below). So By testing
        //against the original value rather than null, we save ourselves a lot of boilerplate in the Equals method.
        public void Equal_SecondFieldIsNull_ReturnsFalse()
        {
            T itemToGetFieldsFrom = CreateNewCloneable();
            IEnumerable <FieldInfo> fieldInfos = GetAllFields(itemToGetFieldsFrom);

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                T itemWithFieldToChange = CreateNewCloneable();
                T itemWithDefaultField  = CreateNewCloneable();
                Assert.That(itemWithFieldToChange, Is.EqualTo(itemWithDefaultField).Using <T>(Compare), "The two items were not equal on creation. You may need to override Equals(object other).");
                string fieldName = fieldInfo.Name;
                if (fieldInfo.Name.Contains("<"))
                {
                    var splitResult = fieldInfo.Name.Split(new[] { '<', '>' });
                    fieldName = splitResult[1];
                }
                if (ExceptionList.Contains("|" + fieldName + "|") || EqualsExceptionList.Contains("|" + fieldName + "|"))
                {
                    continue;
                }
                ValuesToSet valueToSet = null;
                try
                {
                    valueToSet = DefaultValuesForTypes.Single(dv => dv.TypeOfValueToSet == fieldInfo.FieldType);
                }
                catch (InvalidOperationException)
                {
                    Assert.Fail(
                        "Unhandled field type - please update the test to handle type \"{0}\". The field that uses this type is \"{1}\".",
                        fieldInfo.FieldType.Name, fieldName);
                }
                //This conditional is here in case the ValueToSet is identical to the fields default value.
                //That way developers who inherit this test case don't have to worry about what the fields default value is.
                //It also works around an issue with bool values. If you have two fields that are initialized with different
                //values (i.e. one is true and the other false) this will ensure that the value is chosen which is not equal
                //to the default value and the test therefor has a chance of succeeding.
                if (valueToSet.ValueToSet.Equals(fieldInfo.GetValue(itemWithDefaultField)))
                {
                    fieldInfo.SetValue(itemWithFieldToChange, valueToSet.NotEqualValueToSet);
                }
                else
                {
                    fieldInfo.SetValue(itemWithFieldToChange, valueToSet.ValueToSet);
                }
                Assert.AreNotEqual(itemWithFieldToChange, itemWithDefaultField, "Field \"{0}\" is not evaluated in Equals(T other) or the ValueToSet is equal to the fields default value. Please update Equals(T other) or add the field name to the ExceptionList or EqualsExceptionList property.", fieldName);
                Assert.AreNotEqual(itemWithDefaultField, itemWithFieldToChange, "Field \"{0}\" is not evaluated in Equals(T other) or the ValueToSet is equal to the fields default value. Please update Equals(T other) or add the field name to the ExceptionList or EqualsExceptionList property.", fieldName);
            }
        }
Esempio n. 12
0
        public double Hours(DateTime day)
        {
            if (ExceptionList.Any(ex => ex.IsActive == false && SameDay(ex.StartTime, day)))
            {
                return(0);
            }

            var exception = ExceptionList.FirstOrDefault(ex => ex.IsOvertime && SameDay(ex.StartTime, day));

            if (exception != null)
            {
                return(exception.Duration.TotalHours + Duration.TotalHours);
            }

            return(Duration.TotalHours);
        }
        internal int ElmRegisterException(string exceptionName, int exceptionId, string exceptionMessage, int exceptionSeverity, bool showDetailedInformation = false) // internal exception registration (pseudo-constructor for Exception struct)
        {
            Exception _ = new Exception();                                                                                                                             // create temporary struct object for configuring the exception and then add it to the list and abandon the variable forever, sending it to the orphanage in the process, where it will then proceed to being killed at the hands of the GC. Rip baby variable.

            if (ExceptionList == null)
            {
                ShlHardError("ExceptionList f****d", 3);
            }

            _.exceptionName     = exceptionName;
            _.exceptionId       = exceptionId;
            _.exceptionMessage  = exceptionMessage;
            _.exceptionSeverity = exceptionSeverity;
            ExceptionList.Add(_);
            // _ dies here
            return(0);
        }
Esempio n. 14
0
        /*** public void Add( MediaFile mf, bool downloadArtwork = true) ***/
        // Scans the MediaFile and attempts to query the AcoustID API given a MediaFile object
        // * If successful, it will map the file name to the results in the MediaFileWritableResults dictionary<string, WriteableResults>
        // * If the query is unsuccessful a blank WriteableResult will be mapped
        // * Will also attempt to overwrite an existing key only if the ScanFile is successful

        // By default, this function will also attempt to download artwork from using http://coverartarchive.org/release/ + [MusicBrain ReleaseID]
        // This option will slow scanning down, significantly increase the memory footprint, and consume a significant amount of bandwidth
        // as it will cause this function to make the query, parse the JSON result and attempt to download and render the artwork.
        public void Add(MediaFile mf, bool downloadArtwork = true)
        {
            try
            {
                if (!MediaFileWritableResults.ContainsKey(mf.FileName))
                {
                    var scanMediaFile = MusicFingerPrinter.ScanSingleMediaFile(mf.FileName);

                    if (!MediaFileWritableResults.ContainsKey(mf.FileName))
                    {
                        if (scanMediaFile != null)
                        {
                            MediaFileWritableResults.Add(mf.FileName, scanMediaFile.Item3);
                            GetWriteableResultMediaFile.Add(scanMediaFile.Item3, mf);
                        }
                        else
                        {
                            MediaFileWritableResults.Add(mf.FileName, new WriteableResult(mf));
                        }
                    }
                    else if (MediaFileWritableResults.ContainsKey(mf.FileName))
                    {
                        if (scanMediaFile != null)
                        {
                            MediaFileWritableResults [mf.FileName] = scanMediaFile.Item3;
                            GetWriteableResultMediaFile.Add(scanMediaFile.Item3, mf);
                        }
                    }

                    if (downloadArtwork == true)
                    {
                        SetArtwork(mf);
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                ExceptionList.Add(new Tuple <string, string>("Add -> " + mf.FileName + ", downloadArtwork -> " + downloadArtwork.ToString(), ex.Message + System.Environment.NewLine + ex.StackTrace + System.Environment.NewLine + ex.StackTrace));
            }
        }
Esempio n. 15
0
        public static List <ByteData> GetOffenderData(int maxCount, string filePath)
        {
            var byteDataList = new List <ByteData>();

            byte[] bytes = File.ReadAllBytes(filePath);
            for (int i = 0; i < bytes.Length; i++)
            {
                var val = bytes[i];
                if (val > maxCount && !ExceptionList.ToList().Exists(x => x == val) || OffenderList.ToList().Exists(x => x == val))
                {
                    var result = new ByteData();
                    result.Byte  = val;
                    result.Index = i;
                    byteDataList.Add(result);
                }
            }

            return(byteDataList);
        }
Esempio n. 16
0
        public Tuple <string, string, WriteableResult, bool> ScanSingleMediaFile(string fileName, bool queryArtwork = true)
        {
            try
            {
                var getFileAudioFingerPrint      = AcoustID.fingerPrintScanner.FingerPrint(fileName);
                var queryMetaDataFromFingerPrint = AcoustID.QueryAPI(AcoustID.DEFAULT_METADATA_QUERY, getFileAudioFingerPrint);

                JSON_Result     jsonSerializedObject = JsonConvert.DeserializeObject <JSON_Result>(queryMetaDataFromFingerPrint);
                WriteableResult writeableResult      = new WriteableResult(jsonSerializedObject, fileName, queryArtwork, 4);

                int    indexOfFinalDirectory = fileName.LastIndexOf("\\") + 1;
                string partialFileName       = fileName.Substring(indexOfFinalDirectory);
                Tuple <string, string, WriteableResult, bool> ScanItem = new Tuple <string, string, WriteableResult, bool>(fileName, partialFileName, writeableResult, false);
                return(ScanItem);
            }
            catch (Exception ex)
            {
                ExceptionList.Add(new Tuple <string, string>(fileName, ex.Message + System.Environment.NewLine + ex.StackTrace));
                return(null);
            }
        }
Esempio n. 17
0
        /*** public void SetArtwork(MediaFile mf) ***/
        // *
        // *
        // *
        public void SetArtwork(MediaFile mf)
        {
            if (MediaFileWritableResults.ContainsKey(mf.FileName))
            {
                var wrOptions = MediaFileWritableResults [mf.FileName].WriteableResultOptions;

                foreach (var wr in wrOptions)
                {
                    if (ReleaseIDToImageData.ContainsKey(wr.ReleaseID))
                    {
                        // Do nothing, already mapped
                    }
                    else if (wr.ImageSourceURL != null)
                    {
                        try
                        {
                            var request  = WebRequest.Create(wr.ImageSourceURL);
                            var response = (HttpWebResponse)request.GetResponse( );

                            if (response.StatusCode == HttpStatusCode.OK && response.ResponseUri != null)
                            {
                                WebClient client = new WebClient( );

                                byte [] data = client.DownloadData(response.ResponseUri);
                                ReleaseIDToImageData.Add(wr.ReleaseID, data);
                            }
                            else
                            {
                                ExceptionList.Add(new Tuple <string, string>(wr.ImageSourceURL, response.StatusCode.ToString()));
                            }
                        }
                        catch (Exception ex)
                        {
                            ExceptionList.Add(new Tuple <string, string>(mf.FileName, ex.Message + System.Environment.NewLine + ex.StackTrace));
                        }
                    }
                }
            }
        }
Esempio n. 18
0
        public void CloneCopiesAllNeededMembers()
        {
            T clonable = CreateNewCloneable();
            IEnumerable <FieldInfo> fieldInfos = GetAllFields(clonable);

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                string fieldName = fieldInfo.Name;
                if (fieldInfo.Name.Contains("<"))
                {
                    var splitResult = fieldInfo.Name.Split(new[] { '<', '>' });
                    fieldName = splitResult[1];
                }
                if (ExceptionList.Contains("|" + fieldName + "|"))
                {
                    continue;
                }
                object defaultValue = null;
                try
                {
                    defaultValue = DefaultValuesForTypes.Single(dv => dv.TypeOfValueToSet == fieldInfo.FieldType).ValueToSet;
                }
                catch (InvalidOperationException)
                {
                    Assert.Fail("Unhandled field type - please update the test to handle type \"{0}\". The field that uses this type is \"{1}\".", fieldInfo.FieldType.Name, fieldName);
                }

                fieldInfo.SetValue(clonable, defaultValue);

                var theClone = Convert.ChangeType(clonable.Clone(), clonable.GetType());
                if (fieldInfo.GetValue(clonable).GetType() != typeof(string))                  //strings are special in .net so we won't worry about checking them here.
                {
                    Assert.AreNotSame(fieldInfo.GetValue(clonable), fieldInfo.GetValue(theClone),
                                      "The field \"{0}\" refers to the same object, it was not copied.", fieldName);
                }
                Assert.AreEqual(defaultValue, fieldInfo.GetValue(theClone), "Field \"{0}\" not copied on Clone()", fieldName);
            }
        }
Esempio n. 19
0
        //x.Equals(y) && y.Equals(x) where x==y
        public void Equal_ItemsAreEqual_ReturnsTrue()
        {
            T itemToGetFieldsFrom = CreateNewCloneable();
            IEnumerable <FieldInfo> fieldInfos = GetAllFields(itemToGetFieldsFrom);

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                T item        = CreateNewCloneable();
                T unequalItem = CreateNewCloneable();
                Assert.That(item, Is.EqualTo(unequalItem).Using <T>(Compare), "The two items were not equal on creation. You may need to override Equals(object other).");
                var fieldName = fieldInfo.Name;
                if (fieldInfo.Name.Contains("<"))
                {
                    var splitResult = fieldInfo.Name.Split(new[] { '<', '>' });
                    fieldName = splitResult[1];
                }
                if (ExceptionList.Contains("|" + fieldName + "|") || EqualsExceptionList.Contains("|" + fieldName + "|"))
                {
                    continue;
                }
                ValuesToSet valueToSet = null;
                try
                {
                    valueToSet = DefaultValuesForTypes.Single(dv => dv.TypeOfValueToSet == fieldInfo.FieldType);
                }
                catch (InvalidOperationException)
                {
                    Assert.Fail(
                        "Unhandled field type - please update the test to handle type \"{0}\". The field that uses this type is \"{1}\".",
                        fieldInfo.FieldType.Name, fieldName);
                }
                fieldInfo.SetValue(item, valueToSet.ValueToSet);
                fieldInfo.SetValue(unequalItem, valueToSet.ValueToSet);
                Assert.That(item, Is.EqualTo(unequalItem).Using <T>(Compare), "Field \"{0}\" is not evaluated in Equals(T other). Please update Equals(T other) or add the field name to the ExceptionList or EqualsExceptionList property.", fieldName);
                Assert.That(unequalItem, Is.EqualTo(item).Using <T>(Compare), "Field \"{0}\" is not evaluated in Equals(T other). Please update Equals(T other) or add the field name to the ExceptionList or EqualsExceptionList property.", fieldName);
            }
        }
Esempio n. 20
0
        protected override void Execute(NativeActivityContext context)
        {
            _productList   = new ConcurrentQueue <Product>();
            _failedItems   = new ConcurrentQueue <IWBPosInput>();
            _exceptionList = new ConcurrentQueue <Exception>();
            _items         = IWBPosList.Get(context);


            _viewService    = IoC.Instance.Resolve <IViewService>();
            _messageBuilder = new StringBuilder();

            using (var mgr = IoC.Instance.Resolve <IBaseManager <IWB> >())
            {
                var iwbId = IWBId.Get(context);
                var iwb   = mgr.Get(iwbId);
                if (iwb.MandantID != null)
                {
                    _partnerId = iwb.MandantID.Value;
                }
            }

            // падать тут ничего не должно
            try
            {
                ProcessCreateProduct(context);
            }
            catch (Exception ex)
            {
                _exceptionList.Enqueue(ex);
                _messageBuilder.AppendLine("Процесс был прерван. " + ExceptionHelper.GetErrorMessage(ex));
            }

            ErrorMessage.Set(context, _messageBuilder.Length > 0 ? _messageBuilder.ToString() : string.Empty);
            Result.Set(context, _productList.ToList());
            FailedIWBPosList.Set(context, _failedItems.ToList());
            ExceptionList.Set(context, _exceptionList.ToList());
        }
Esempio n. 21
0
        private void WriteException(Exception ex)
        {
            try
            {
                Exceptions++;
                lbExceptions.Text = strExceptions + Exceptions;

                String exMsg  = "[异常 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] " + ex.Message;
                String exMsg2 = "[异常 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] " + ex.StackTrace;
                ExceptionList.Add(exMsg);
                if (ExceptionList.Count > 100)
                {
                    ExceptionList.RemoveAt(0);
                }
                if (cbViewExceptions.Checked)
                {
                    hunterTextBox.WriteLine(exMsg, HunterConfig.ColorException);
#if DEBUG
                    hunterTextBox.WriteLine(exMsg2, HunterConfig.ColorException);
#endif
                }
            }
            catch { }
        }
Esempio n. 22
0
 public void ClearExceptions()
 {
     ExceptionList.Clear();
 }
Esempio n. 23
0
        private ExceptionList EnsureOperationInputArguments()
        {
            var result = new ExceptionList();

            if (string.IsNullOrWhiteSpace(SourcePath))
            {
                result.Add(new ApplicationException("The SourcePath must not be null. Operation failed."));
            }

            if (!File.Exists(SourcePath))
            {
                result.Add(new ApplicationException(
                    "The SourcePath could not be found. It is missing or the user is not authorized to access it."));
            }

            if (string.IsNullOrWhiteSpace(DestinationPath))
            {
                result.Add(new ApplicationException("The DestinationPath must not be null. Operation failed."));
            }

            if (!File.Exists(SourcePath))
            {
                result.Add(new ApplicationException(
                    "The DestinationPath could not be found. It is missing or the user is not authorized to access it."));
            }

            return result;
        }
Esempio n. 24
0
 public bool Exists(ExceptionResourceKeys key)
 {
     return(ExceptionList.Where(x => x.ResourceKey == key).Count() > 0);
 }
Esempio n. 25
0
 /// <summary>
 ///  Called whenever an error occurs in the controller object
 /// </summary>
 /// <param name="ExceptionData"></param>
 private void Controller_OnException(Exception ExceptionData)
 {
     ExceptionList.Enqueue(ExceptionData);
 }