Esempio n. 1
0
    /******************************\
    * TIMER                        *
    *------------------------------*
    * Counts down 3 seconds then   *
    * sets the ErrorState to None. *
    \******************************/
    void threeSecTimer(float dTime)
    {
        if (timeRemaining >= 0f)
        {
            timeRemaining -= dTime;
        }

        if (timeRemaining < 0f)
        {
            errorState = ErrorState.None;
        }
    }
Esempio n. 2
0
        public static ErrorDialog Create(string title, string message, ErrorState errorState)
        {
            var dialog=new ErrorDialog() {
                ErrorState=errorState
            };

            dialog.labelErrorTitle.Text=title;
            dialog.labelErrorTitle.Show();
            dialog.labelErrorMessage.Text=message;
            dialog.labelErrorMessage.Show();
            return dialog;
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the ComponentStatus property of thie GifComponent.
        /// </summary>
        /// <param name="errorState">
        /// A member of the Gif.Components.ErrorState enumeration.
        /// </param>
        /// <param name="errorMessage">
        /// An error message associated with the error state.
        /// </param>
        protected void SetStatus(ErrorState errorState, string errorMessage)
        {
            ErrorState newState   = _status.ErrorState | errorState;
            string     newMessage = _status.ErrorMessage;

            if (!String.IsNullOrEmpty(newMessage))
            {
                newMessage += Environment.NewLine;
            }
            newMessage += errorMessage;
            _status     = new GifComponentStatus(newState, newMessage);
        }
Esempio n. 4
0
        public static ErrorState GetErrorState()
        {
            ErrorState ec = _errorState;

            if (ec == null)
            {
                ec          = new ErrorState();
                _errorState = ec;
            }

            return(ec);
        }
Esempio n. 5
0
        public void ACButtonClick()
        {
            /* Method invoked in class construction and when the "AC" button is pressed.
             * Resets the calculator to its initial state. */

            DisplayString         = "0";
            result                = 0.0;
            selectedOperator      = Operator.Undefined;
            errorState            = ErrorState.None;
            lastDepButtonPressed  = ButtonType.AC;
            lastDepButtonPressed2 = ButtonType.AC;
        }
Esempio n. 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="signature">
        /// The GIF signature which identifies a GIF stream.
        /// Should contain the fixed value "GIF".
        /// </param>
        /// <param name="gifVersion">
        /// The version of the GIF standard used by this stream.
        /// </param>
        public GifHeader(string signature, string gifVersion)
        {
            _signature  = signature;
            _gifVersion = gifVersion;

            if (_signature != "GIF")
            {
                string     errorInfo = "Bad signature: " + _signature;
                ErrorState status    = ErrorState.BadSignature;
                SetStatus(status, errorInfo);
            }
        }
Esempio n. 7
0
 public void OnEnd()
 {
     try
     {
         OnStart();
     }
     catch (Exception ex)
     {
         Complete(ErrorState.Capture(ex));
         return;
     }
     Complete();
 }
Esempio n. 8
0
 public void Print()
 {
     try
     {
         State.AddCash(this);
     }
     catch (Exception exception)
     {
         Error = exception.Message;
         State = new ErrorState();
         State.PrintError(this);
     }
 }
Esempio n. 9
0
        private ErrorState CreateErrorState()
        {
            var input = new ErrorStateInput();
            var state = new ErrorState(input);

            var backClickedTransition = new OnEventTransition(GameState.StateName);

            input.BackClickedEvent += backClickedTransition.ChangeState;

            state.AddTransitions(backClickedTransition);

            return(state);
        }
Esempio n. 10
0
        private static string Request(string type, string key, [NotNull] IReadOnlyDictionary <string, string> additData)
        {
            string url        = $@"http://rucaptcha.com/{type}.php?key={key}&soft_id=2362&json=1";
            string apiRequest = string.Empty;

            foreach (KeyValuePair <string, string> param in additData)
            {
                url = url + "&" + param.Key + "=" + param.Value;
            }

            for (int i = 0; i < _attepmts; i++)
            {
                if (GetResponse(ExtRequest.Get(url), out apiRequest))
                {
                    return(apiRequest);
                }

                ErrorState errorState = GetErrorInfo(apiRequest, out int timeout, out string errorText);

                if (errorState.HasFlag(ErrorState.Unknown))
                {
                    throw new UnknownCaptchaSolverErrorException(errorText);
                }
                if (errorState.HasFlag(ErrorState.Critical))
                {
                    throw new CaptchaSolverErrorException(apiRequest, errorText);
                }
                if (errorState.HasFlag(ErrorState.LowBet))
                {
                    throw new CaptchaSolverErrorException(apiRequest, errorText); // TODO Доработать логику с подстройкой цены
                }
                if (errorState.HasFlag(ErrorState.CaptchaNotReady))
                {
                    if (additData.TryGetValue("method", out string v) && v == "userrecaptcha")
                    {
                        timeout = 15000; // TODO Переделать на получение из конфига + добавить сохранение в него
                    }
                    else
                    {
                        timeout = 5000;
                    }
                }

                if (timeout != 0)
                {
                    Thread.Sleep(timeout);
                }
            }

            throw new Exception("Попытки истекли.\n" + apiRequest);
        }
    void Start()
    {
        GameObject errorStateObject = GameObject.Find("ErrorState");
        if (errorStateObject != null)
            this.errorState = errorStateObject.GetComponent<ErrorState>();

        Debug.Log("My menustate is : " + this.menuState);

        Input.simulateMouseWithTouches = true;

        GUIText text = this.ipAddress.GetComponentInChildren<GUIText>();

        text.text = Network.player.ipAddress;
    }
Esempio n. 12
0
        /// <summary>
        /// Populates the form object.
        /// </summary>
        /// <returns>Success state.</returns>
        public ErrorState Populate()
        {
            ErrorState errorState = PopulateModuleComboBox();

            if (errorState != ErrorState.Success)
            {
                return(errorState);
            }

            PopulateSoundCheckBox();
            PopulateAnimatedPreviewsCheckBox();

            return(ErrorState.Success);
        }
Esempio n. 13
0
        public Command(IPart id, IPart hostID, IPart target, IPart order, IPart data, Timestamp timestamp)
        {
            _executeValidation = Validate;
            ID         = id;
            HostID     = hostID;
            Target     = target;
            Order      = order;
            Data       = data;
            Timestamp  = timestamp;
            ErrorState = ErrorState.Unchecked();

            SetUpStateToValidationMap();
            SetupPartCollection(ID, HostID, Target, Order, Data);
        }
Esempio n. 14
0
            internal static ErrorState Get(string registryKey, out string cdKey)
            {
                cdKey = null;
                ErrorState errorState = Reg.IsValidAsErrorState(registryKey);

                if (errorState != ErrorState.None)
                {
                    return(errorState);
                }

                cdKey = Registry.GetValue(registryKey, "codkey", string.Empty).ToString();

                return(ErrorState.None);
            }
 private async Task DoFinalWork(StageAsyncResult result)
 {
     try
     {
         await _state.OriginalTask;
         _state.CallContext.OnEnd();
         CallContextAsyncResult.End(_state.CallContext.AsyncResult);
         result.TryComplete();
     }
     catch (Exception ex)
     {
         _state.CallContext.AbortIfHeaderSent();
         result.Fail(ErrorState.Capture(ex));
     }
 }
Esempio n. 16
0
        public void When_informed_by_DeviceHandler_about_new_received_confirmation_type_command_provides_proper_confirmation_to_ResponseAwaiterDispatch()
        {
            Order receivedOrder = null;

            ProtocolHandler.OrderReceived += (_, order) => receivedOrder = order;

            RaiseNewCommandEventOnDevice(CommandsTestObjects.GetProperTestCommand_order("ID01"));
            RaiseNewCommandEventOnDevice(CommandsTestObjects.GetProperTestCommand_confirmation("ID01"));
            var receivedConfirmation = ResponseAwaiterDispatch.ConfirmationOf(receivedOrder);

            Assert.True(receivedOrder.ID == receivedConfirmation.Confirms);
            Assert.IsType <ErrorState>(receivedConfirmation.ContainedErrors);
            Assert.True(receivedConfirmation.IsValid);
            Assert.True(receivedConfirmation.ContainedErrors == ErrorState.Unchecked().Valid());
        }
Esempio n. 17
0
 public static void MergeError(this ModelStateDictionary modelState, ErrorState errorState)
 {
     if (errorState.ErrorItems.Count > 0)
     {
         var localizationRepository = InstanceLocator.Current.GetInstance <IModelErrorLocalizationRepository>();
         foreach (var errorItem in errorState.ErrorItems)
         {
             modelState.AddModelError(string.Empty, string.Format(localizationRepository.GetValue(errorItem.Key), errorItem.Parameters.ToArray()));
         }
     }
     else if (!string.IsNullOrEmpty(errorState.ExceptionMessage))
     {
         modelState.AddModelError(string.Empty, errorState.ExceptionMessage);
     }
 }
Esempio n. 18
0
        private ErrorState GetErrorState()
        {
            ErrorState SubscribeErrorState = subscribeClient.GetErrorState();
            ErrorState PublishErrorState   = publishClient.GetErrorState();

            if (SubscribeErrorState == ErrorState.Permanent || PublishErrorState == ErrorState.Permanent)
            {
                return(ErrorState.Permanent);
            }
            if (SubscribeErrorState == ErrorState.Temporary || PublishErrorState == ErrorState.Temporary)
            {
                return(ErrorState.Temporary);
            }
            return(ErrorState.None);
        }
Esempio n. 19
0
        public void GetUsage()
        {
            // Override current culture
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-ca");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-ca");

            string html = GetHTML();

            if (string.IsNullOrEmpty(html))
            {
                _errorState = ErrorState.HTTP;
                return;
            }

            _errorState = ParseHTML(html) ? ErrorState.OK : ErrorState.Match;
        }
Esempio n. 20
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (ErrorLine == null ? 0 : ErrorLine.GetHashCode());
         hash = hash * 23 + (ErrorMessage == null ? 0 : ErrorMessage.GetHashCode());
         hash = hash * 23 + (ErrorNumber == default(int) ? 0 : ErrorNumber.GetHashCode());
         hash = hash * 23 + (ErrorProcedure == null ? 0 : ErrorProcedure.GetHashCode());
         hash = hash * 23 + (ErrorSeverity == null ? 0 : ErrorSeverity.GetHashCode());
         hash = hash * 23 + (ErrorState == null ? 0 : ErrorState.GetHashCode());
         hash = hash * 23 + (ErrorTime == default(DateTime) ? 0 : ErrorTime.GetHashCode());
         hash = hash * 23 + (UserName == null ? 0 : UserName.GetHashCode());
         return(hash);
     }
 }
Esempio n. 21
0
        public void Complete(bool completedSynchronously, ErrorState errorState)
        {
            _errorState = errorState;

            CompletedSynchronously = completedSynchronously;

            _isCompleted = true;
            try
            {
                Interlocked.Exchange(ref _callback, SecondAsyncCallback).Invoke(this);
            }
            catch (Exception ex)
            {
                Trace.WriteError(Resources.Trace_OwinCallContextCallbackException, ex);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="inputStream">
        /// A <see cref="System.IO.Stream"/> containing the data to create the
        /// GifHeader.
        /// </param>
        /// <param name="xmlDebugging">
        /// A boolean value indicating whether or not an XML document should be
        /// created showing how the GIF stream was decoded.
        /// </param>
        public GifHeader(Stream inputStream, bool xmlDebugging)
            : base(xmlDebugging)
        {
            StringBuilder sb = new StringBuilder();

            int[] bytesRead = new int[6];
            // Read 6 bytes from the GIF stream
            // These should contain the signature and GIF version.
            bool endOfFile = false;

            for (int i = 0; i < 6; i++)
            {
                int nextByte = Read(inputStream);
                if (nextByte == -1)
                {
                    if (endOfFile == false)
                    {
                        SetStatus(ErrorState.EndOfInputStream,
                                  "Bytes read: " + i);
                        endOfFile = true;
                    }
                    nextByte = 0;
                }
                sb.Append((char)nextByte);
                if (this.XmlDebugging)
                {
                    bytesRead[i] = nextByte;
                }
            }

            string headerString = sb.ToString();

            WriteDebugXmlByteValues("BytesRead", bytesRead);

            _signature = headerString.Substring(0, 3);
            WriteDebugXmlElement("Signature", _signature);
            _gifVersion = headerString.Substring(3, 3);
            WriteDebugXmlElement("GifVersion", _gifVersion);
            if (_signature != "GIF")
            {
                string     errorInfo = "Bad signature: " + _signature;
                ErrorState status    = ErrorState.BadSignature;
                SetStatus(status, errorInfo);
            }

            WriteDebugXmlFinish();
        }
        public void CanLogError()
        {
            var errorLogger          = new ErrorLogger(mockDeviceInfo.Object, mockErrorService.Object);
            var exceptionThatOccured = new Exception();
            var mockErrorState       = new ErrorState(exceptionThatOccured, "Inside some component.");

            mockDeviceInfo.SetupGet(x => x.Idiom).Returns(Idiom.Phone);
            mockDeviceInfo.SetupGet(x => x.Model).Returns("Model");
            mockDeviceInfo.SetupGet(x => x.Platform).Returns(Platform.Android);
            mockDeviceInfo.SetupGet(x => x.Version).Returns("Version");
            mockDeviceInfo.SetupGet(x => x.VersionNumber).Returns(new Version("8.0"));

            var deviceInfo = new DeviceInfo
            {
                Idiom         = "Phone",
                Model         = "Model",
                Platform      = "Android",
                Version       = "Version",
                VersionNumber = "8.0"
            };

            var errorInfo = new ErrorInfo
            {
                WhereOccurred    = mockErrorState.WhereOccurred,
                ClassName        = nameof(mockErrorState.Error),
                DeviceInfo       = deviceInfo,
                Message          = mockErrorState.Error.Message,
                StackTraceString = mockErrorState.Error.StackTrace
            };

            errorLogger.LogErrorAsync(mockErrorState);

            mockErrorService.Verify(errorService => errorService.SendErrorInformationAsync(
                                        It.Is <ErrorInfo>(x =>
                                                          x.ClassName == errorInfo.ClassName &&
                                                          x.Message == errorInfo.Message &&
                                                          x.StackTraceString == errorInfo.StackTraceString &&
                                                          x.WhereOccurred == errorInfo.WhereOccurred &&
                                                          x.DeviceInfo.Idiom.Equals(errorInfo.DeviceInfo.Idiom) &&
                                                          x.DeviceInfo.Model.Equals(errorInfo.DeviceInfo.Model) &&
                                                          x.DeviceInfo.Platform.Equals(errorInfo.DeviceInfo.Platform) &&
                                                          x.DeviceInfo.Version.Equals(errorInfo.DeviceInfo.Version) &&
                                                          x.DeviceInfo.VersionNumber.Equals(errorInfo.DeviceInfo.VersionNumber))
                                        ),
                                    Times.Once()
                                    );
        }
        /// <summary>
        /// Convert this exception to a string
        /// </summary>
        public override string ToString()
        {
            StringBuilder exceptionString = new StringBuilder(this.Message);

            exceptionString.AppendFormat("\r\nAt State {0}\r\n", ErrorState.ToString());
            exceptionString.Append("--- DATA SEGMENT ---\r\n");

            if (DataSegment != null)
            {
                foreach (KeyValuePair <string, object> kv in DataSegment)
                {
                    exceptionString.AppendFormat("{0} = {1}", kv.Key, kv.Value.ToString());
                }
            }

            return(exceptionString.ToString());
        }
Esempio n. 25
0
        public void ThrowFormattedApiResponse(ErrorState errorState, string fieldName)
        {
            ErrorModel errorModel = new ErrorModel();

            errorModel.ErrorCode        = errorState.ErrorCode;
            errorModel.Field            = fieldName;
            errorModel.Documentation    = "https://developer.example.com/docs" + errorState.DocumentationPath;
            errorModel.DeveloperMessage = string.Format(errorState.DeveloperMessageTemplate, fieldName);
            errorModel.UserMessage      = errorState.UserMessage;

            var responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(JsonConvert.SerializeObject(errorModel, Formatting.Indented))
            };

            throw new HttpResponseException(responseMessage);
        }
Esempio n. 26
0
        public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object extraData)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }

            try
            {
                OwinAppContext appContext = _appAccessor.Invoke();

                if (appContext == null)
                {
                    throw new EntryPointNotFoundException(Resources.Exception_NoOwinEntryPointFound);
                }

                // REVIEW: the httpContext.Request.RequestContext may be used here if public property unassigned?
                RequestContext requestContext  = _requestContext ?? new RequestContext(httpContext, new RouteData());
                string         requestPathBase = _pathBase;
                string         requestPath     = _requestPath ?? httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(1) + httpContext.Request.PathInfo;

                OwinCallContext callContext = appContext.CreateCallContext(
                    requestContext,
                    requestPathBase,
                    requestPath,
                    callback,
                    extraData);

                try
                {
                    callContext.Execute();
                }
                catch (Exception ex)
                {
                    callContext.AsyncResult.Complete(true, ErrorState.Capture(ex));
                }
                return(callContext.AsyncResult);
            }
            catch (Exception ex)
            {
                var failedAsyncResult = new CallContextAsyncResult(null, callback, extraData);
                failedAsyncResult.Complete(true, ErrorState.Capture(ex));
                return(failedAsyncResult);
            }
        }
Esempio n. 27
0
        public static void Logout(ErrorState errorState = ErrorState.OK) //Logout function, everything that needs to be done when logging out will be in here, errorstate defaults to OK if no params passed
        {
            ((NoticesControl)GetControl("NoticesControl")).Logout();
            ((UserDetails)GetControl("UserDetailsControl")).Logout();
            ((TimetableControl)GetControl("TimetableControl")).Logout();

            HideAll();
            SetControlVisibility(GetControl("LoginControl"), true);

            if (errorState == ErrorState.InvalidDetails) //If logout reason is due to invalid details
            {
                ((LoginControl)GetControl("LoginControl")).ShowLoginError();
            }
            if (errorState == ErrorState.Unknown) //If logout is due to unknown error
            {
                MessageBox.Show("Unknown Error occured, please try again.");
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Displays an appropriate error message.
        /// </summary>
        /// <param name="errorState">ErrorState to display message for.</param>
        /// <returns>DialogResult</returns>
        public static DialogResult DisplayError(ErrorState errorState)
        {
            switch (errorState)
            {
            case ErrorState.SelectedModuleNotFound:
                return(MessageBox.Show(
                           "This software does not provide settings for your\n\r" +
                           "currently selected After Dark module.\n\r\n\r" +
                           "Do you want to continue?",
                           "Unsupported Module found",
                           MessageBoxButtons.YesNo,
                           MessageBoxIcon.Warning,
                           MessageBoxDefaultButton.Button2
                           ));
            }

            return(DialogResult.None);
        }
Esempio n. 29
0
 public ApplicationState(
     IImmutableDictionary <PermissionName, AsyncOperationState <PermissionStatus, Unit> > permissionsDictionary,
     Stack <PageName> navigationStack,
     Settings settings,
     PlacesData placesData,
     DeviceData deviceData,
     ErrorState error,
     UserState userState
     )
 {
     PermissionsDictionary = permissionsDictionary;
     NavigationStack       = navigationStack;
     Settings   = settings;
     PlacesData = placesData;
     DeviceData = deviceData;
     Error      = error;
     UserState  = userState;
 }
Esempio n. 30
0
 //--------------------------------------------------------
 //	LoadImage
 //		Load Images from new image list
 //--------------------------------------------------------
 protected void LoadImage()
 {
     newImageList.Clear();
     foreach (string path in dragPathList)
     {
         Image temp = new Bitmap(path);
         temp.Tag = path;
         newImageList.Add(temp);
     }
     if (errorState == ErrorState.NotRoot)
     {
         // Give Warning to User
         string    text      = "Image is not in root directory, only share palettes that have images in root directory";
         ErrorForm errorForm = new ErrorForm(text);
         errorForm.ShowDialog();
         errorState = ErrorState.Default;
     }
 }
Esempio n. 31
0
 public virtual void KernelPanic(ErrorState error, Exception cause)
 {
     foreach (KernelEventHandler handler in _kernelEventHandlers)
     {
         try
         {
             handler.KernelPanic(error);
         }
         catch (Exception e)
         {
             if (cause != null)
             {
                 e.addSuppressed(cause);
             }
             _log.error("FATAL: Error while handling kernel panic.", e);
         }
     }
 }
Esempio n. 32
0
 /// <summary>
 ///  Report an error to the user using the game's error panel
 ///  The panel also reports the stacktrace from the location of the error
 /// </summary>
 /// <param name="message"></param> The error message for the user>
 /// <param name="state"<>/param> The state the error handler should be set to>
 /// <returns></returns>
 public void ReportError(string message, ErrorState state)
 {
     if (!errorUIInitialized)
     {
         Awake();
     }
     ErrorState = state;
     if (errorUI != null)
     {
         errorUI.setErrorMessage(message);
         errorUI.setStackTrace(Environment.StackTrace);
         errorUI.OpenUI();
     }
     else
     {
         EmergencyExit("Error UI Script Not Found");
     }
 }
Esempio n. 33
0
        private static IErrorState Validate(object instance, Type type)
        {
            List<EntityMemberMapping> memberMappings;
            var key = type.FullName ;
            if (!EntityMemberMappingCache.TryGetValue(key, out memberMappings))
            {
                memberMappings = (from prop in type.GetGetMembers()
                                  from attribute in prop.Member.GetAttributes<ValidationAttribute>(true)
                                  select new EntityMemberMapping(prop, attribute))
                                  .ToList();
                EntityMemberMappingCache.Add(key, memberMappings);
            }

            var state = new ErrorState();
            memberMappings.Where(m => !m.IsValid(instance))
                .ForEach(m => state.AddError(m.Name, m.ErrorMessage()));

            return state;
        }
Esempio n. 34
0
 private static void Log(ErrorState state, string text, LoggingOptions options)
 {
     var logBox = LoggingConfiguration.LoggingBox;
     if (logBox.InvokeRequired)
         logBox.Invoke(new Action<ErrorState, string, LoggingOptions>(Log), new object[] {state, text, options});
     else
     {
         var time = DateTime.Now.ToString("dd-MM-yy HH:mm:ss");
         var color = state != ErrorState.INFO && options.Colored
             ? (state == ErrorState.ERROR ? Color.Red : Color.Orange)
             : Color.Black;
         var finalstring = string.Format(options.UseTimeAndStatePrefix ? "[{0}][{1}][{2}] {3}" : "{3}",
             LoggingConfiguration.ProductName, state, time,
             text);
         Console.WriteLine(finalstring);
         if (logBox == null) return;
         logBox.SelectionStart = logBox.TextLength;
         logBox.SelectionLength = 0;
         logBox.SelectionColor = color;
         logBox.AppendText(string.Format(string.IsNullOrEmpty(logBox.Text) ? "{0}" : "\n{0}", finalstring));
         logBox.SelectionColor = logBox.ForeColor;
         logBox.ScrollToCaret();
     }
 }
 /// <summary>
 /// Tests whether the error state of this component or any of its member
 /// components contains the supplied member of the ErrorState 
 /// enumeration.
 /// </summary>
 /// <param name="state">
 /// The error state to look for in the current instance's state.
 /// </param>
 /// <returns>
 /// True if the current instance's error state includes the supplied
 /// error state, otherwise false.
 /// </returns>
 public bool TestState( ErrorState state )
 {
     return( ConsolidatedState & state ) == state;
 }
Esempio n. 36
0
 public static void ResetErrorState()
 {
     threadToListenerMap = new Dictionary<Thread, IANTLRErrorListener>();
     ErrorState ec = new ErrorState();
     threadToErrorStateMap[Thread.CurrentThread] = ec;
 }
Esempio n. 37
0
        public void NewOrder()
        {
            _processingError = ErrorState.None;
            try
            {
                //Fulfillment Line Items
                var LineItemVendors = new List<string>();
                var LineItemCount = 0;

                //Evergreen flags
                var evergreenRequired = false;
                //Midwest flags
                var midwestRequired = false;
                //Kurt Adler flags
                var kurtAdlerRequired = false;
                //Roman Flags
                var romanRequired = false;
                //Allstate Floral Flags
                var allstateRequired = false;
                //Allstate Floral Flags
                var melroseRequired = false;
                //SPI Flags
                var spiRequired = false;
                //Jessie Steele Flags
                var jessieSteeleRequired = false;
                //Vickerman Flags
                var vickermanRequired = false;
                //Atticus Flags
                var atticusRequired = false;
                //Il Bere Flags
                var ilBereRequired = false;
                //Trans Ocean Flags
                var transOceanRequired = false;
                //LipLidz Flags
                var lipLidzRequired = false;
                //Picnic TIme Flags
                var picnicTimeRequired = false;
                //Deco Breeze Flags
                var decoBreezeRequired = false;
                //Trend Lab Flags
                var trendLabRequired = false;
                //Pkolino Flags
                var pkolinoRequired = false;
                //Kid Kraft Flags
                var kidKraftRequired = false;
                //Fun Furnishings Flags
                var funFurnishingsRequired = false;

                //General use flags
                var orderNumber = string.Empty;
                var duplicateOrder = true;

                //Send response to prevent timeout (Shopify will resend after 5 seconds)
                HttpContext.ApplicationInstance.Context.ApplicationInstance.CompleteRequest();

                using (var streamReader = new StreamReader(Request.InputStream))
                {
                    if (streamReader != null)
                    {
                        var responseJson = streamReader.ReadToEnd();

                        using (var memoryStream = new MemoryStream(Encoding.Unicode.GetBytes(responseJson)))
                        {
                            //Deserialize JSON
                            DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(Order));
                            var orderObject = (Order)jsonSerializer.ReadObject(memoryStream);

                            if (orderObject != null)
                            {
                                //Check for duplicate order number
                                lock (Supplier._mongoLock)
                                {
                                    //Query Mongo DB, lock to ensure order is written before next query occurs
                                    duplicateOrder = MongoDb.WasOrderProcessed(orderObject.id, orderObject.created_at);
                                }

                                if (duplicateOrder)
                                {
                                    return;
                                }

                                Log.WriteInfoLog("Processing New Order (ref: #" + orderObject.id + ")");
                                orderNumber = orderObject.id;
                                //Determine which suppliers are in the order
                                foreach (var item in orderObject.line_items)
                                {
                                    switch (item.sku.Substring(0, 2))
                                    {
                                        case Supplier.EvergreenPrefix:
                                            //Evergreen Prefix
                                            if (!evergreenRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            evergreenRequired = true;
                                            break;
                                        case Supplier.MidwestPrefix:
                                            //Midwest Prefix
                                            if (!midwestRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            midwestRequired = true;
                                            break;
                                        case Supplier.KurtAdlerPrefix:
                                            //Kurt Adler Prefix
                                            if (!kurtAdlerRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            kurtAdlerRequired = true;
                                            break;
                                        case Supplier.RomanPrefix:
                                            //Roman Prefix
                                            if (!romanRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            romanRequired = true;
                                            break;
                                        case Supplier.AllstatePrefix:
                                            //Allstate Prefix
                                            if (!allstateRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            allstateRequired = true;
                                            break;
                                        case Supplier.MelrosePrefix:
                                            //Melrose Prefix
                                            if (!melroseRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            melroseRequired = true;
                                            break;
                                        case Supplier.SpiPrefix:
                                            //SPI Prefix
                                            if (!spiRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            spiRequired = true;
                                            break;
                                        case Supplier.JessieSteelePrefix:
                                            //Jessie Steele Prefix
                                            if (!jessieSteeleRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            jessieSteeleRequired = true;
                                            break;
                                        case Supplier.VickermanPrefix:
                                            //Vickerman Prefix
                                            if (!vickermanRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            vickermanRequired = true;
                                            break;
                                        case Supplier.AtticusPrefix:
                                            //Atticus Prefix
                                            if (!atticusRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            atticusRequired = true;
                                            break;
                                        case Supplier.IlBerePrefix:
                                            //Il Bere Prefix
                                            if (!ilBereRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            ilBereRequired = true;
                                            break;
                                        case Supplier.TransOceanPrefix:
                                            //Trans Ocean Prefix
                                            if (!transOceanRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            transOceanRequired = true;
                                            break;
                                        case Supplier.LipLidzPrefix:
                                            //LipLidz Prefix
                                            if (!lipLidzRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            lipLidzRequired = true;
                                            break;
                                        case Supplier.PicnicTimePrefix:
                                            //Picnic Time Prefix
                                            if (!picnicTimeRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            picnicTimeRequired = true;
                                            break;
                                        case Supplier.DecoBreezePrefix:
                                            //Deco Breeze Prefix
                                            if (!decoBreezeRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            decoBreezeRequired = true;
                                            break;
                                        case Supplier.TrendLabPrefix:
                                            //Trend Lab Prefix
                                            if (!trendLabRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            trendLabRequired = true;
                                            break;
                                        case Supplier.PkolinoPrefix:
                                            //Pkolino Prefix
                                            if (!pkolinoRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            pkolinoRequired = true;
                                            break;
                                        case Supplier.KidKraftPrefix:
                                            //Kid Kraft Prefix
                                            if (!kidKraftRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            kidKraftRequired = true;
                                            break;
                                        case Supplier.FunFurnishingsPrefix:
                                            //Fun Furnishings Prefix
                                            if (!funFurnishingsRequired)
                                            {
                                                LineItemCount++;
                                            }
                                            funFurnishingsRequired = true;
                                            break;
                                        case Supplier.SantasWrapPrefix:
                                            //Internal Fulfillment, Ignore
                                            break;
                                        default:
                                            //Unknown Prefix
                                            Log.WriteInfoLog("Unknown prefix detected");
                                            _processingError = ErrorState.SupplierNotFound;
                                            break;
                                    }
                                }

                                //Call necessary methods to send orders
                                if (evergreenRequired)
                                {
                                    //Evergreen item(s) in order
                                    var evergreenProvider = new EvergreenProvider();
                                    if (evergreenProvider.ProcessEvergreenOrder(orderObject))
                                    {
                                        //Evergreen order sent successfully
                                        Log.WriteInfoLog("Evergreen order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Evergreen items in order
                                        LineItemVendors.Add("Evergreen");
                                    }
                                    else
                                    {
                                        //Error processing Evergreen order
                                        Log.WriteInfoLog("Error occured while processing Evergreen order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (midwestRequired)
                                {
                                    //Midwest item(s) in order
                                    var midwestProvider = new MidwestProvider();
                                    if (midwestProvider.ProcessOrder(orderObject))
                                    {
                                        //Midwest order sent successfully
                                        Log.WriteInfoLog("Midwest order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Midwest items in order
                                        LineItemVendors.Add("Midwest CBK");
                                    }
                                    else
                                    {
                                        //Error processing Midwest order
                                        Log.WriteInfoLog("Error occured while processing Midwest order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (allstateRequired)
                                {
                                    //Allstate item(s) in order
                                    var allstateProvider = new AllstateFloralProvider();
                                    if (allstateProvider.ProcessOrder(orderObject))
                                    {
                                        //Allstate order sent successfully
                                        Log.WriteInfoLog("Allstate order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Allstate items in order
                                        LineItemVendors.Add("Allstate");
                                    }
                                    else
                                    {
                                        //Error processing Midwest order
                                        Log.WriteInfoLog("Error occured while processing Allstate order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (melroseRequired)
                                {
                                    //Melrose item(s) in order
                                    var melroseProvider = new MelroseProvider();
                                    if (melroseProvider.ProcessOrder(orderObject))
                                    {
                                        //Melrose order sent successfully
                                        Log.WriteInfoLog("Melrose order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Melrose items in order
                                        LineItemVendors.Add("Melrose");
                                    }
                                    else
                                    {
                                        //Error processing Melrose order
                                        Log.WriteInfoLog("Error occured while processing Melrose order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (kurtAdlerRequired)
                                {
                                    //Kurt Adler item(s) in order
                                    var kurtAdlerProvider = new KurtAdlerProvider();
                                    if (kurtAdlerProvider.ProcessOrder(orderObject))
                                    {
                                        //Kurt Adler order sent successfully
                                        Log.WriteInfoLog("Kurt Adler order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Kurt Adler items in order
                                        LineItemVendors.Add("Kurt Adler");
                                    }
                                    else
                                    {
                                        //Error processing Kurt Adler order
                                        Log.WriteInfoLog("Error occured while processing Kurt Adler order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (spiRequired)
                                {
                                    //SPI item(s) in order
                                    var spiProvider = new SpiProvider();
                                    if (spiProvider.ProcessOrder(orderObject))
                                    {
                                        //SPI order sent successfully
                                        Log.WriteInfoLog("SPI order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for SPI items in order
                                        LineItemVendors.Add("SPI");
                                    }
                                    else
                                    {
                                        //Error processing SPI order
                                        Log.WriteInfoLog("Error occured while processing SPI order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (jessieSteeleRequired)
                                {
                                    //Jessie Steele item(s) in order
                                    var jessieSteeleProvider = new JessieSteeleProvider();
                                    if (jessieSteeleProvider.ProcessOrder(orderObject))
                                    {
                                        //Jessie Steele order sent successfully
                                        Log.WriteInfoLog("Jessie Steele order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Jessie Steele items in order
                                        LineItemVendors.Add("Jessie Steele");
                                    }
                                    else
                                    {
                                        //Error processing Jessie Steele order
                                        Log.WriteInfoLog("Error occured while processing Jessie Steele order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (vickermanRequired)
                                {
                                    //Vickerman item(s) in order
                                    var vickermanProvider = new VickermanProvider();
                                    if (vickermanProvider.ProcessOrder(orderObject))
                                    {
                                        //Vickerman order sent successfully
                                        Log.WriteInfoLog("Vickerman order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Vickerman items in order
                                        LineItemVendors.Add("Vickerman");
                                    }
                                    else
                                    {
                                        //Error processing Vickerman order
                                        Log.WriteInfoLog("Error occured while processing Vickerman order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (atticusRequired)
                                {
                                    //Atticus item(s) in order
                                    var atticusProvider = new AtticusProvider();
                                    if (atticusProvider.ProcessOrder(orderObject))
                                    {
                                        //Atticus order sent successfully
                                        Log.WriteInfoLog("Atticus order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Atticus items in order
                                        LineItemVendors.Add("Atticus");
                                    }
                                    else
                                    {
                                        //Error processing Atticus order
                                        Log.WriteInfoLog("Error occured while processing Atticus order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (ilBereRequired)
                                {
                                    //Il Bere item(s) in order
                                    var ilBereProvider = new IlBereProvider();
                                    if (ilBereProvider.ProcessOrder(orderObject))
                                    {
                                        //Il Bere order sent successfully
                                        Log.WriteInfoLog("Il Bere order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Il Bere items in order
                                        LineItemVendors.Add("Il Bere");
                                    }
                                    else
                                    {
                                        //Error processing Il Bere order
                                        Log.WriteInfoLog("Error occured while processing Il Bere order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (transOceanRequired)
                                {
                                    //Trans Ocean item(s) in order
                                    var transOceanProvider = new TransOceanProvider();
                                    if (transOceanProvider.ProcessOrder(orderObject))
                                    {
                                        //Trans Ocean order sent successfully
                                        Log.WriteInfoLog("Trans Ocean order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Trans Ocean items in order
                                        LineItemVendors.Add("Trans Ocean");
                                    }
                                    else
                                    {
                                        //Error processing Trans Ocean order
                                        Log.WriteInfoLog("Error occured while processing Trans Ocean order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (lipLidzRequired)
                                {
                                    //LipLidz item(s) in order
                                    var lipLidzProvider = new LipLidzProvider();
                                    if (lipLidzProvider.ProcessOrder(orderObject))
                                    {
                                        //LipLidz order sent successfully
                                        Log.WriteInfoLog("LipLidz order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for LipLidz items in order
                                        LineItemVendors.Add("LipLidz");
                                    }
                                    else
                                    {
                                        //Error processing LipLidz order
                                        Log.WriteInfoLog("Error occured while processing LipLidz order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (picnicTimeRequired)
                                {
                                    //Picnic Time item(s) in order
                                    var picnicTimeProvider = new PicnicTimeProvider();
                                    if (picnicTimeProvider.ProcessOrder(orderObject))
                                    {
                                        //Picnic Time order sent successfully
                                        Log.WriteInfoLog("Picnic Time order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Picnic Time items in order
                                        LineItemVendors.Add("Picnic Time");
                                    }
                                    else
                                    {
                                        //Error processing Picnic Time order
                                        Log.WriteInfoLog("Error occured while processing Picnic Time order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (decoBreezeRequired)
                                {
                                    //Deco Breeze item(s) in order
                                    var decoBreezeProvider = new DecoBreezeProvider();
                                    if (decoBreezeProvider.ProcessOrder(orderObject))
                                    {
                                        //Deco Breeze order sent successfully
                                        Log.WriteInfoLog("Deco Breeze order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Deco Breeze items in order
                                        LineItemVendors.Add("Deco Breeze");
                                    }
                                    else
                                    {
                                        //Error processing Deco Breeze order
                                        Log.WriteInfoLog("Error occured while processing Deco Breeze order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (trendLabRequired)
                                {
                                    //Trend Lab item(s) in order
                                    var trendLabProvider = new TrendLabProvider();
                                    if (trendLabProvider.ProcessOrder(orderObject))
                                    {
                                        //Trend Lab order sent successfully
                                        Log.WriteInfoLog("Trend Lab order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Trend Lab items in order
                                        LineItemVendors.Add("Trend Lab");
                                    }
                                    else
                                    {
                                        //Error processing Trend Lab order
                                        Log.WriteInfoLog("Error occured while processing Trend Lab order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (pkolinoRequired)
                                {
                                    //Pkolino item(s) in order
                                    var pkolinoProvider = new PkolinoProvider();
                                    if (pkolinoProvider.ProcessOrder(orderObject))
                                    {
                                        //Pkolino order sent successfully
                                        Log.WriteInfoLog("Pkolino order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Pkolino items in order
                                        LineItemVendors.Add("Pkolino");
                                    }
                                    else
                                    {
                                        //Error processing Pkolino order
                                        Log.WriteInfoLog("Error occured while processing Pkolino order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (kidKraftRequired)
                                {
                                    //Kid Kraft item(s) in order
                                    var kidKraftProvider = new KidKraftProvider();
                                    if (kidKraftProvider.ProcessOrder(orderObject))
                                    {
                                        //Kid Kraft order sent successfully
                                        Log.WriteInfoLog("Kid Kraft order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Kid Kraft items in order
                                        LineItemVendors.Add("Kid Kraft");
                                    }
                                    else
                                    {
                                        //Error processing Kid Kraft order
                                        Log.WriteInfoLog("Error occured while processing Kid Kraft order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (funFurnishingsRequired)
                                {
                                    //Fun Furnishings item(s) in order
                                    var funFurnishingsProvider = new FunFurnishingsProvider();
                                    if (funFurnishingsProvider.ProcessOrder(orderObject))
                                    {
                                        //Fun Furnishings order sent successfully
                                        Log.WriteInfoLog("Fun Furnishings order sent successfully (ref: #" + orderNumber + ")");
                                        //Update Shopify fulfillment status for Fun Furnishings items in order
                                        LineItemVendors.Add("Fun Furnishings");
                                    }
                                    else
                                    {
                                        //Error processing Fun Furnishings order
                                        Log.WriteInfoLog("Error occured while processing Fun Furnishings order (ref: #" + orderNumber + ")");
                                        _processingError = ErrorState.OrderProcessingError;
                                    }
                                }
                                if (romanRequired)
                                {
                                    //Roman item(s) in order
                                }
                                PushFulfillmentUpdate(LineItemVendors, orderNumber, LineItemCount);
                            }
                            else
                            {
                                //Unable to deserialize JSON
                                Log.WriteInfoLog("Unable to deserialize JSON");
                                _processingError = ErrorState.OrderProcessingError;
                            }
                        }
                    }
                    else
                    {
                        //Unable to read stream
                        Log.WriteInfoLog("Unable to read input stream");
                        _processingError = ErrorState.OrderProcessingError;
                    }
                }
            }
            catch(Exception ex)
            {
                //Something went wrong
                Log.WriteErrorLog(ex);
                _processingError = ErrorState.ServerError;
            }
            ErrorHandler(_processingError);
        }
Esempio n. 38
0
        public static ErrorState GetErrorState()
        {
            ErrorState ec = _errorState;
            if ( ec == null )
            {
                ec = new ErrorState();
                _errorState = ec;
            }

            return ec;
        }
Esempio n. 39
0
 /// <summary>
 /// Initializes a new instance of the <c>NLiteException</c> class with the specified
 /// error message and the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The message that describes the error.</param>
 /// <param name="innerException">The inner exception that is the cause of this exception.</param>
 public NLiteException(string message, Exception innerException)
     : base(message, innerException)
 {
     var nliteException = innerException as NLiteException;
     ErrorState = nliteException == null ? new ErrorState() : nliteException.ErrorState;
 }
Esempio n. 40
0
 /// <summary>
 /// Initializes a new instance of the <c>NLiteException</c> class.
 /// </summary>
 public NLiteException() : base() { ErrorState = new ErrorState(); }
Esempio n. 41
0
 private void ErrorHandler(ErrorState error)
 {
     try
     {
         //Send Notifications for processing errors
         if (error != ErrorState.None)
         {
             //Send email to default recepient
             MailgunAgent.SendNotificationEmail(Convert.ToString(error), false);
             //Send email to default backup recepient
             MailgunAgent.SendNotificationEmail(Convert.ToString(error), true);
         }
     }
     catch (Exception ex)
     {
         Log.WriteErrorLog(ex);
     }
 }
Esempio n. 42
0
    void Start()
    {
        this.errorState = GameObject.Find("ErrorState").GetComponent<ErrorState>();

        this.parentObject = this.transform.parent.gameObject;

        this.menuState = GameObject.Find("MenuState").GetComponent<MenuState>();

        this.resetName();
    }
Esempio n. 43
0
 public static ErrorState GetErrorState()
 {
     ErrorState ec;
     threadToErrorStateMap.TryGetValue(Thread.CurrentThread, out ec);
     if ( ec == null )
     {
         ec = new ErrorState();
         threadToErrorStateMap[Thread.CurrentThread] = ec;
     }
     return ec;
 }
Esempio n. 44
0
        private static IErrorState Validate(object instance, Type type, Type metadataType)
        {
            List<EntityMemberMapping> memberMappings;

            var key = type.FullName + "|" + metadataType.FullName;
            if (!EntityMemberMappingCache.TryGetValue(key, out memberMappings))
            {
                var items = from m in type.GetGetMembers()
                            let p = metadataType.GetMember(m.Name).FirstOrDefault()
                            where p != null
                            select new { MetadataMember = p, MemberModel = m };
                memberMappings =( from m in items
                                 from attribute in m.MetadataMember.GetAttributes<ValidationAttribute>(true)
                                 select new EntityMemberMapping(m.MemberModel, attribute))
                                 .ToList();
                EntityMemberMappingCache.Add(key, memberMappings);

            }

            var state = new ErrorState();
            memberMappings.Where(m => !m.IsValid(instance))
                .ForEach(m => state.AddError(m.Name, m.ErrorMessage()));

            return state;
        }
 /// <summary>
 /// Writes the latest error state and error message to the debug XML
 /// stream.
 /// </summary>
 /// <param name="errorState">The component's latest error state</param>
 /// <param name="errorMessage">The associated error message</param>
 /// <remarks>
 /// There is no need to call this from derived classes as it is called
 /// by the SetStatus method.
 /// </remarks>
 private void WriteDebugXmlErrorState( ErrorState errorState, 
     string errorMessage)
 {
     if( _xmlDebugging )
     {
         WriteDebugXmlElement( "ErrorState", errorState.ToString() );
         WriteDebugXmlElement( "ErrorMessage", errorMessage );
     }
 }
        /// <summary>
        /// Sets the ComponentStatus property of thie GifComponent.
        /// </summary>
        /// <param name="errorState">
        /// A member of the Gif.Components.ErrorState enumeration.
        /// </param>
        /// <param name="errorMessage">
        /// An error message associated with the error state.
        /// </param>
        protected void SetStatus( ErrorState errorState, string errorMessage )
        {
            ErrorState newState = _status.ErrorState | errorState;
            string newMessage = _status.ErrorMessage;
            if( !String.IsNullOrEmpty( newMessage ) )
            {
                newMessage += Environment.NewLine;
            }
            newMessage += errorMessage;
            _status = new GifComponentStatus( newState, newMessage );

            if( _xmlDebugging )
            {
                WriteDebugXmlErrorState( errorState, errorMessage );
            }
        }
Esempio n. 47
0
        private void PushFulfillmentUpdate(List<string> itemId, string orderNumber, int count)
        {
            try
            {
                if (itemId.Count() > 0)
                {
                    //Send updated information to Shopify via API
                    var json = string.Empty;
                    var apiString = "https://" + Supplier.ShopName + ".myshopify.com/admin/orders/" + orderNumber + ".json";
                    var httpWebRequest = (HttpWebRequest)WebRequest.Create(apiString);
                    httpWebRequest.Credentials = new NetworkCredential(Supplier.ApiKey, Supplier.Password);
                    httpWebRequest.ContentType = "application/json";
                    httpWebRequest.Method = "PUT";
                    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                    {
                        if (itemId.Count == count)
                        {
                            json = "{\"order\": {\"id\": " + orderNumber + ", \"note\": \"POs were sent to vendors successfully.\"}}";
                        }
                        else
                        {
                            json = "{\"order\": {\"id\": " + orderNumber + ", \"note\": \"The Fulfillment Service encountered a problem with this order.  Please talk to IT (Richard) for additional details.\"}}";
                        }

                        streamWriter.Write(json);
                        streamWriter.Flush();
                        streamWriter.Close();
                        using (var myHttpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
                        {
                            if (myHttpWebResponse.StatusCode != HttpStatusCode.OK)
                            {
                                //Problem sending HTTP POST request
                                Log.WriteInfoLog("Problem sending HTTP POST request to Shopify");
                                _processingError = ErrorState.FulfillmentUpdateError;
                            }
                            else
                            {
                                //Fulfillment status updated on Shopify
                                Log.WriteInfoLog("Fulfillment status updated on Shopify (ref: #" + orderNumber + ")");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteErrorLog(ex);
            }
        }
Esempio n. 48
0
 public static ErrorState GetErrorState()
 {
     ErrorState ec =
         (ErrorState)threadToErrorStateMap.get( Thread.CurrentThread );
     if ( ec == null )
     {
         ec = new ErrorState();
         threadToErrorStateMap[Thread.CurrentThread] = ec;
     }
     return ec;
 }
Esempio n. 49
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="errorState">
		/// A member of the Gif.Components.ErrorState enumeration.
		/// </param>
		/// <param name="errorMessage">
		/// Any error message associated with the error state.
		/// </param>
		public GifComponentStatus( ErrorState errorState, string errorMessage )
		{
			_errorState = errorState;
			_errorMessage = errorMessage;
		}
Esempio n. 50
0
 public ServiceResponse(Exception ex)
 {
     ErrorState = new ErrorState();
     exceptions = new List<Exception>();
     AddException(ex);
 }
Esempio n. 51
0
 /// <summary>
 /// Initializes a new instance of the <c>NLiteException</c> class with the specified
 /// error message.
 /// </summary>
 /// <param name="message">The message that describes the error.</param>
 public NLiteException(string message) : base(message) { ErrorState = new ErrorState(); }
Esempio n. 52
0
 private void PublishErrorStateChanged(ErrorState state, Exception error)
 {
     if (state == ErrorState.Permanent)
         subscribeClient.PermanentError();
     onErrorStateChange(GetErrorState(), error);
 }
    void Start()
    {
        this.errorState = GameObject.Find("ErrorState").GetComponent<ErrorState>();

        this.parentObject = this.transform.parent.gameObject;

        this.menuState = GameObject.Find("MenuState").GetComponent<MenuState>();

        this.guiPosition = new Rect(
            Screen.width / 2 - this.boxWidth / 2,
            Screen.height / 2 - this.boxHeight / 2,
            this.boxWidth,
            this.boxHeight);

        this.textFieldPosition = new Rect(
            this.guiPosition.x + this.borderWidth,
            this.guiPosition.y + this.guiPosition.height / 3,
            this.guiPosition.width - 2 * this.borderWidth,
            this.guiPosition.height / 3);

        this.btnOkPosition = new Rect(
            this.guiPosition.x + this.borderWidth,
            this.guiPosition.y + (this.guiPosition.height / 3) * 2,
            (this.guiPosition.width - 2 * this.borderWidth) / 2,
            this.guiPosition.height / 3);

        this.btnEscPosition = new Rect(
            this.guiPosition.x + this.borderWidth * 2 + this.btnOkPosition.width,
            this.guiPosition.y + (this.guiPosition.height / 3) * 2,
            (this.guiPosition.width - 2 * this.borderWidth) / 2,
            this.guiPosition.height / 3);

        this.enableGui = false;
    }
Esempio n. 54
0
 /// <summary>
 /// 
 /// </summary>
 public ServiceResponse()
 {
     ErrorState = new ErrorState();
     exceptions = new List<Exception>();
 }
Esempio n. 55
0
 public static void ResetErrorState()
 {
     _errorState = new ErrorState();
 }
Esempio n. 56
0
 private void Err(ErrorState state)
 {
     if (OnError != null)
     {
         OnError(state);
     }
 }
 /// <summary>
 /// Allows the component's status to be set via its SetStatus method.
 /// This is only accesible to derived types.
 /// </summary>
 /// <param name="state"></param>
 /// <param name="message"></param>
 public void SetMyStatus( ErrorState state, string message )
 {
     SetStatus( state, message );
 }
Esempio n. 58
0
    void Start()
    {
        GameObject errorStateObject = GameObject.Find("ErrorState");
        if (errorStateObject != null)
            this.errorState = errorStateObject.GetComponent<ErrorState>();

        GameObject otherMenuState = GameObject.Find("MenuState");
        if (otherMenuState != this.gameObject && otherMenuState != null)
        {
            UnityEngine.Object.Destroy(this.gameObject.GetComponent<NetworkView>());
            UnityEngine.Object.Destroy(this);
            if (this.name == "MenuState")
                UnityEngine.Object.Destroy(this.gameObject);
        }

        //#if UNITY_STANDALONE || UNITY_EDITOR

        this.playerName = System.Environment.MachineName;

        //#endif
    }
Esempio n. 59
0
 public ErrorEventArgs(ErrorState errorState, string errorMessage)
 {
     ErrorState = errorState;
     ErrorMessage = errorMessage;
 }
Esempio n. 60
0
	public void FixedUpdate() {  
		if(this.aiCar!=null&&this.aiCar.GetTopSpeed()>1f) {
			if(this.currentErrorState==null) {
				if(this.aiCar!=null&&UnityEngine.Random.Range(0f,50f)<this.aiCar.GetHumanError()) {
					currentErrorState = new ErrorState(this.aiCar.GetHumanError(),this);
					speedCornerBeforeError = this.aiCar.GetCorneringSpeedFactor();
					this.breakAggressionBeforeError = this.aiCar.GetAggressivenessOnBrake();
					this.backToLineBeforeError = this.aiCar.backToLineIncrement; 
					
				}
			} else {
				currentErrorState.framesOfError--;
				this.aiCar.SetCorneringSpeedFactor(speedCornerBeforeError*currentErrorState.corneringSpeedEffector);
				this.aiCar.backToLineIncrement = currentErrorState.backToLineError;
				this.aiCar.SetAggressivenessOnBrake(this.currentErrorState.brakeAggressionEffector);
				if(currentErrorState.framesOfError==0) {
					currentErrorState = null;
					this.aiCar.SetCorneringSpeedFactor(speedCornerBeforeError);
					this.aiCar.backToLineIncrement = backToLineBeforeError;
					this.aiCar.SetAggressivenessOnBrake(this.breakAggressionBeforeError);
				} else
					this.aiCar.SetCorneringSpeedFactor(speedCornerBeforeError*currentErrorState.corneringSpeedEffector);
			}
			
			engineTempMonitor.Update(this.aiDriveTrain,this.aiCar,this.aiInput,this);
		/*	this.fatigue -= this.staminaDecrementer;
			fatigueCount++;
			if(fatigueCount%40==0&&aiCar!=null) {
				//if(fatigue>0)
					//this.aiCar.SetHumanError(500000f+(this.driverRecord.humanError*(this.fatigue/this.driverRecord.stamina)));
					//this.aiCar.SetHumanError(this.driverRecord.humanError+(this.driverRecord.humanError*(this.fatigue/this.driverRecord.stamina)));
			}*/
		}
	}