Exemplo n.º 1
0
        public ErrorResponse(ExceptionCode code)
        {
            this.Code = code.ToString();

            switch (code)
            {
            case ExceptionCode.Unauthorized:
                this.Message = "You're not authorized or your session has expired.";
                break;

            case ExceptionCode.InternalServerError:
                this.Message = "Oops! Something went wrong.";
                break;

            case ExceptionCode.NotAcceptable:
                this.Message = "The server does not have a current representation that would be acceptable.";
                break;

            case ExceptionCode.MethodNotAllowed:
                this.Message = "The method received in the request-line is not supported by the target resource.";
                break;

            default:
                this.Message = "We can't seem to find the answer you're looking for.";
                break;
            }
        }
Exemplo n.º 2
0
        public void EditProfileExcep(MyPhotosUser editprofile)
        {
            code = ExceptionCode.EditProfile;

            if (editprofile.Name == null || editprofile.Name.Length < 5 || editprofile.Name.Length > 25)
            {
                throw new Exception(Resource.AdSınırlama);
            }
            if (editprofile.Surname == null || editprofile.Surname.Length < 5 || editprofile.Surname.Length > 15)
            {
                throw new Exception(Resource.SoyadıSınırlama);
            }

            if (editprofile.Password == null && editprofile.Password.Length < 5 || editprofile.Password.Length > 25)
            {
                throw new Exception(Resource.ŞifreSınırlama);
            }
            if (editprofile.Email == null || editprofile.Email.Length < 5 || editprofile.Email.Length > 35)
            {
                throw new Exception(Resource.EmailSınırlama);
            }
            if (editprofile.UserName == null || editprofile.UserName.Length < 5 || editprofile.UserName.Length > 15)
            {
                throw new Exception(Resource.KullanıcıAdıSınırlama);
            }

            if (!editprofile.Email.Contains("@"))
            {
                throw new Exception(Resource.EmailFormat);
            }
        }
Exemplo n.º 3
0
    //Checks for a particular type of exception and an Exception msg in the English locale
    private static void CheckException <E>(ExceptionCode test, string error, String msgExpected)
    {
        bool exception = false;

        try
        {
            test();
            error = String.Format("{0} Exception NOT thrown ", error);
        }
        catch (Exception e)
        {
            if (e.GetType() == typeof(E))
            {
                exception = true;
                if (msgExpected != null && System.Globalization.CultureInfo.CurrentUICulture.Name == "en-US" && e.Message != msgExpected)
                {
                    exception = false;
                    error     = String.Format("{0} Message Different: <{1}>", error, e.Message);
                }
            }
            else
            {
                error = String.Format("{0} Exception type: {1}", error, e.GetType().Name);
            }
        }
        Eval(exception, error);
    }
Exemplo n.º 4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="success">是否成功</param>
 /// <param name="message">返回消息</param>
 /// <param name="extend">扩展信息</param>
 /// <param name="ExceptionCode">异常代码信息</param>
 public ActionResult(bool success, string message, object extend, ExceptionCode ExceptionCode)
 {
     this.Success       = success;
     this.Message       = message;
     this.Extend        = extend;
     this.ExceptionCode = ExceptionCode;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="Code">异常代码</param>
 /// <param name="strMessage">异常消息</param>
 /// <param name="strReason">异常原因</param>
 public CException(ExceptionCode Code, String strMessage, String strReason)
     : base(strMessage)
 {
     InitVar();
     _Reason        = strReason;
     _ExceptionCode = Code;
 }
Exemplo n.º 6
0
 private static string GetCodeMessage(ExceptionCode code, string arg0, string arg1)
 {
     if (arg0 == null && arg1 != null)
     {
         arg0 = arg1;
     }
     if (code < 0)
     {
         return(arg0 ?? ExceptionCodes[code][0]);
     }
     string[] msgs;
     if (!ExceptionCodes.TryGetValue(code, out msgs))
     {
         return(ExceptionCodes[ExceptionCode.Unknown][0]);
     }
     if (arg0 == null)
     {
         return(string.Empty);
     }
     if (msgs[1] != null)
     {
         return(string.Format(msgs[1], arg0, arg1));
     }
     else if (string.IsNullOrEmpty(msgs[0]))
     {
         return(arg0);
     }
     else
     {
         return(msgs[0] + ":" + arg0);
     }
 }
        /// <summary>
        /// To the type of the event log entry.
        /// </summary>
        /// <returns>EventLogEntryType.</returns>
        public static EventLogEntryType ToEventLogEntryType(this ExceptionCode exceptionCode)
        {
            EventLogEntryType result = EventLogEntryType.Information;

            if (exceptionCode != null)
            {
                switch (exceptionCode.Major)
                {
                case ExceptionCode.MajorCode.OperationForbidden:
                case ExceptionCode.MajorCode.NullOrInvalidValue:
                case ExceptionCode.MajorCode.ServiceUnavailable:
                case ExceptionCode.MajorCode.OperationFailure:
                case ExceptionCode.MajorCode.NotImplemented:
                    result = EventLogEntryType.Error;
                    break;

                case ExceptionCode.MajorCode.DataConflict:
                case ExceptionCode.MajorCode.CreditNotAfford:
                case ExceptionCode.MajorCode.ResourceNotFound:
                    result = EventLogEntryType.Warning;
                    break;

                default:
                    break;
                }
            }

            return(result);
        }
        public void ProcessRequest(HttpContext context)
        {
            string exceptionCode = context.Request.QueryString["exceptionCode"].Trim().ToUpper();

            _facade = new PerformanceFacade(this.DataProvider);

            string returnValue = "false";

            this.DataProvider.BeginTransaction();
            try
            {
                ExceptionCode exceptionCodeObject = (ExceptionCode)_facade.GetExceptionCode(exceptionCode);
                if (exceptionCodeObject != null)
                {
                    _facade.DeleteExceptionCode(exceptionCodeObject);
                }

                object[] exceptionList = _facade.QueryExceptionEvent(string.Empty, 0, string.Empty, string.Empty, exceptionCode);

                if (exceptionList != null)
                {
                    returnValue = "true";
                }

                this.DataProvider.CommitTransaction();
                context.Response.Write(returnValue);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                context.Response.Write(ex.Message);
            }
        }
Exemplo n.º 9
0
        public CustomException(ExceptionCode exceptionCode, params string[] paramters)
            : base($"{(int)exceptionCode}-{exceptionCode.ToString()}")
        {
            this.ExceptionCode = exceptionCode;

            paramters.ForEach(x => MessageParamters.Add(x));
        }
Exemplo n.º 10
0
 private void InitVar()
 {
     SetExceptionType();
     _Reason          = "";
     _InnerStackTrace = "";
     _Exception       = null;
     _ExceptionCode   = ExceptionCode.UnKownCode;
 }
Exemplo n.º 11
0
 protected void HandleExceptionCode(ExceptionCode code)
 {
     if (code != ExceptionCode.Ok)
     {
         var exceptionData = QueryInterface <Antilatency.InterfaceContract.IExceptionData>();
         throw new Antilatency.InterfaceContract.Exception(code, exceptionData.getMessage());
     }
 }
Exemplo n.º 12
0
        private dynamic OnException(NancyContext ctx, System.Exception ex)
        {
            logic.OnException(ex);
            var code     = ExceptionCode.GetFromException(ex);
            var response = Response.AsJson(new ResponseError(code.errorCode));

            response.StatusCode = (HttpStatusCode)code.httpStatusCode;
            return(response);
        }
Exemplo n.º 13
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="Code">异常代码</param>
 /// <param name="strMessage">异常消息</param>
 /// <param name="e">从这个异常引入的异常</param>
 /// <example>
 /// try
 /// {
 /// ......
 ///
 /// }
 /// catch (Exception e)
 /// {
 ///     CException E = new CException ("Example Exception", e);
 ///     E.Raise();
 /// }
 /// </example>
 public CException(ExceptionCode Code, String strMessage, Exception e)
     : base(strMessage)
 {
     InitVar();
     _Reason          = e.Message;
     _InnerStackTrace = e.StackTrace;
     _ExceptionCode   = Code;
     _Exception       = e;
 }
Exemplo n.º 14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="resultMessageType"></param>
 /// <param name="message"></param>
 /// <param name="data"></param>
 public ApiResult(ExceptionCode resultMessageType, string message = "", dynamic data = null)
 {
     ResponseData = new ResponseData
     {
         Success = resultMessageType,
         Message = message,
         Data    = data
     };
 }
Exemplo n.º 15
0
        private Byte TranslateFromCode(ExceptionCode code)
        {
            if (code == ExceptionCode.Invalid)
            {
                throw new ArgumentException("code");
            }

            return((Byte)code);
        }
 private MenuAlreadyExistsException(
     ExceptionCode exceptionCode,
     OperationCode operationCode,
     Guid correlationId,
     string message
     ) : base((int)exceptionCode, (int)operationCode, correlationId, message)
 {
     HttpStatusCode = (int)ExceptionCodeToHttpStatusCodeConverter.GetHttpStatusCode((int)exceptionCode);
 }
Exemplo n.º 17
0
        public override ExceptionCode Save(DataRow row, string query)
        {
            ExceptionCode error = ExceptionCode.NoError;

            using (SqlCommand cmd = new SqlCommand())
            {
                var connection = new SqlConnection(Application.Current.FindResource("ConnectionString").ToString());
                try
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@labbook_id", row["labbook_id"]);
                    cmd.Parameters.AddWithValue("@date_created", row["date_created"]);
                    cmd.Parameters.AddWithValue("@date_update", row["date_update"]);
                    cmd.Parameters.AddWithValue("@contrast_75", row["contrast_75"]);
                    cmd.Parameters.AddWithValue("@tw_75", row["tw_75"]);
                    cmd.Parameters.AddWithValue("@sp_75", row["sp_75"]);
                    cmd.Parameters.AddWithValue("@contrast_100", row["contrast_100"]);
                    cmd.Parameters.AddWithValue("@tw_100", row["tw_100"]);
                    cmd.Parameters.AddWithValue("@sp_100", row["sp_100"]);
                    cmd.Parameters.AddWithValue("@contrast_150", row["contrast_150"]);
                    cmd.Parameters.AddWithValue("@tw_150", row["tw_150"]);
                    cmd.Parameters.AddWithValue("@sp_150", row["sp_150"]);
                    cmd.Parameters.AddWithValue("@contrast_240", row["contrast_240"]);
                    cmd.Parameters.AddWithValue("@tw_240", row["tw_240"]);
                    cmd.Parameters.AddWithValue("@sp_240", row["sp_240"]);
                    cmd.Parameters.AddWithValue("@other_a_contrast", row["other_a_contrast"]);
                    cmd.Parameters.AddWithValue("@other_a_type", row["other_a_type"]);
                    cmd.Parameters.AddWithValue("@other_b_contrast", row["other_b_contrast"]);
                    cmd.Parameters.AddWithValue("@other_b_type", row["other_b_type"]);
                    cmd.Parameters.AddWithValue("@contrast_class", row["contrast_class"]);
                    cmd.Parameters.AddWithValue("@contrast_yield", row["contrast_yield"]);
                    cmd.Parameters.AddWithValue("@comment", row["comment"]);
                    connection.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    error = ExceptionCode.SqlError;
                    MessageBox.Show("Problem z połączeniem z serwerem. Prawdopodobnie serwer jest wyłączony, błąd w nazwie serwera lub dostępie do bazy: '" + ex.Message + "'. Błąd z poziomu Save Visrepository.",
                                    "Błąd połaczenia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                catch (Exception ex)
                {
                    error = ExceptionCode.SqlConnectionError;
                    MessageBox.Show("Problem z połączeniem z serwerem. Prawdopodobnie serwer jest wyłączony: '" + ex.Message + "'. Błąd z poziomu Save Visrepository.",
                                    "Błąd połączenia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    connection.Close();
                }
            }

            return(error);
        }
Exemplo n.º 18
0
 public OperationFailedException(ExceptionCode exceptionCode,
                                 OperationCode operationCode,
                                 Guid correlationId,
                                 string message)
     : base((int)exceptionCode, (int)operationCode,
            correlationId,
            message)
 {
     HttpStatusCode = (int)ExceptionCodeToHttpStatusCodeConverter.GetHttpStatusCode((int)exceptionCode);
 }
 private DomainRuleViolationException(
     ExceptionCode exceptionCode,
     OperationCode operationCode,
     Guid correlationId,
     string message,
     Exception domainException
     ) : base((int)exceptionCode, (int)operationCode, correlationId, message, domainException)
 {
     HttpStatusCode = (int)ExceptionCodeToHttpStatusCodeConverter.GetHttpStatusCode((int)exceptionCode);
 }
Exemplo n.º 20
0
        /// <summary>
        /// Throws a <see cref="DOMException"/> user exception with the given code and message.
        /// </summary>
        /// <param name="code">The exception code.</param>
        /// <param name="message">The exception message.</param>
        /// <exception cref="PhpUserException"/>
        internal static void Throw(ExceptionCode code, string message)
        {
            ScriptContext context = ScriptContext.CurrentContext;

            DOMException exception = new DOMException(context, true);

            exception.__construct(context, message, (int)code);
            exception._code = code;

            throw new PhpUserException(exception);
        }
Exemplo n.º 21
0
 private void FRMCOLLECTION_Load(object sender, EventArgs e)
 {
     try
     {
         plc     = new PLC(CPU_Type.S7400, "192.168.3.1", 0, 3);
         errCode = plc.Open();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 22
0
        override public ExceptionCode Update(DataRow row, string query)
        {
            ExceptionCode error = ExceptionCode.NoError;

            using (SqlCommand cmd = new SqlCommand())
            {
                var connection = new SqlConnection(Application.Current.FindResource("ConnectionString").ToString());
                try
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@labbook_id", row["labbook_id"]);
                    cmd.Parameters.AddWithValue("@date_created", row["date_created"]);
                    cmd.Parameters.AddWithValue("@date_update", row["date_update"]);
                    cmd.Parameters.AddWithValue("@L_m", row["L_m"]);
                    cmd.Parameters.AddWithValue("@a_m", row["a_m"]);
                    cmd.Parameters.AddWithValue("@b_m", row["b_m"]);
                    cmd.Parameters.AddWithValue("@WI_m", row["WI_m"]);
                    cmd.Parameters.AddWithValue("@YI_m", row["YI_m"]);
                    cmd.Parameters.AddWithValue("@L_s", row["L_s"]);
                    cmd.Parameters.AddWithValue("@a_s", row["a_s"]);
                    cmd.Parameters.AddWithValue("@b_s", row["b_s"]);
                    cmd.Parameters.AddWithValue("@WI_s", row["WI_s"]);
                    cmd.Parameters.AddWithValue("@YI_s", row["YI_s"]);
                    cmd.Parameters.AddWithValue("@X", row["X"]);
                    cmd.Parameters.AddWithValue("@Y", row["Y"]);
                    cmd.Parameters.AddWithValue("@Z", row["Z"]);
                    cmd.Parameters.AddWithValue("@comment", row["comment"]);
                    cmd.Parameters.AddWithValue("@id", row["id"]);
                    connection.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    error = ExceptionCode.SqlError;
                    MessageBox.Show("Problem z połączeniem z serwerem. Prawdopodobnie serwer jest wyłączony, błąd w nazwie serwera lub dostępie do bazy: '" + ex.Message + "'. Błąd z poziomu Update spectro repository.",
                                    "Błąd połaczenia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                catch (Exception ex)
                {
                    error = ExceptionCode.SqlConnectionError;
                    MessageBox.Show("Problem z połączeniem z serwerem. Prawdopodobnie serwer jest wyłączony: '" + ex.Message + "'. Błąd z poziomu Update spectro repository.",
                                    "Błąd połączenia", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    connection.Close();
                }
            }

            return(error);
        }
Exemplo n.º 23
0
 private void btnWriteReal_Click(object sender, EventArgs e)
 {
     try
     {
         //double a = Types.Double.FromDWord((uint)plc.Read("DB90.DBD248"));
         byte[]        values = Types.Double.ToByteArray(double.Parse(txtReadForWrite.Text));
         ExceptionCode ec     = plc.WriteBytes(DataType.DataBlock, 300, 2, values);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 24
0
 private void Exception(ExceptionCode code)
 {
     try
     {
         IP = _errorIp;
         Interrupt(Id);
         Registers[(int)Register.R0] = (int)code;
     }
     catch
     {
         throw new VirtualMachineException(_errorIp, "Exception thrown in exception handler");
     }
 }
Exemplo n.º 25
0
        //protected override void Delete1DomainObjects(ArrayList domainObjects)
        //{
        //    if (_facade == null)
        //    {
        //        _facade = new PerformanceFacade(base.DataProvider);
        //    }
        //    //this._facade.DeleteExceptionCode((ExceptionCode[])domainObjects.ToArray(typeof(ExceptionCode)));

        //    for (int i = 0; i < domainObjects.Count; i++)
        //    {
        //        ExceptionCode exceptionCode = (ExceptionCode)domainObjects[i];
        //        ExceptionEventList = _facade.QueryExceptionEvent(string.Empty, 0, string.Empty, string.Empty, exceptionCode.Code);
        //        if (ExceptionEventList!=null)
        //        {
        //            for (int j = 0; j < ExceptionEventList.Length; j++)
        //            {
        //                _facade.DeleteExceptionEvent((ExceptionEvent)ExceptionEventList[j]);
        //            }
        //        }
        //    }
        //}

        protected void Delete1DomainObjects(object sender, EventArgs e)
        {
            if (_facade == null)
            {
                _facade = new PerformanceFacade(base.DataProvider);
            }
            this.DataProvider.BeginTransaction();
            try
            {
                bool      haveExceptionEvent = false;
                ArrayList array             = this.gridHelper.GetCheckedRows();
                string    exceptionCodeList = string.Empty;
                for (int i = 0; i < array.Count; i++)
                {
                    string        exceptionCode       = ((GridRecord)array[i]).Items.FindItemByKey("ExceptionCode").Value.ToString();
                    ExceptionCode exceptionCodeObject = (ExceptionCode)_facade.GetExceptionCode(exceptionCode);

                    object[] ExceptionEventList = _facade.QueryExceptionEvent(string.Empty, 0, string.Empty, string.Empty, exceptionCode);
                    if (ExceptionEventList != null)
                    {
                        haveExceptionEvent = true;
                        exceptionCodeList += exceptionCode + ",";
                        //for (int j = 0; j < ExceptionEventList.Length; j++)
                        //{
                        //    _facade.DeleteExceptionEvent((ExceptionEvent)ExceptionEventList[j]);
                        //}
                    }
                    else
                    {
                        if (exceptionCodeObject != null)
                        {
                            _facade.DeleteExceptionCode(exceptionCodeObject);
                        }
                    }
                }
                this.DataProvider.CommitTransaction();

                if (haveExceptionEvent)
                {
                    WebInfoPublish.PublishInfo(this, exceptionCodeList + "$Error_ExceptionCode_Cannot_Delete", this.languageComponent1);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_Delete_Domain_Object", ex);
                this.DataProvider.RollbackTransaction();
            }


            this.RequestData();
        }
Exemplo n.º 26
0
        public DebugException(EXCEPTION_RECORD32 ex, bool firstChance)
        {
            this.IsFirstChance = firstChance;
            Message            = GetCodeMessage(Code = ex.Code, out Title);
            this.Address       = ex.ExceptionAddress;
            this.IsContinuable = ex.ExceptionFlags == 0;

            if (ex.ExceptionRecord != IntPtr.Zero)
            {
                var innerExt = new EXCEPTION_RECORD32();
                Marshal.PtrToStructure(ex.ExceptionRecord, innerExt);
                InnerException = new DebugException(innerExt, firstChance);
            }
        }
Exemplo n.º 27
0
        public DebugException(EXCEPTION_RECORD32 ex, bool firstChance)
        {
            this.IsFirstChance = firstChance;
            Message = GetCodeMessage(Code = ex.Code, out Title);
            this.Address = ex.ExceptionAddress;
            this.IsContinuable = ex.ExceptionFlags == 0;

            if (ex.ExceptionRecord != IntPtr.Zero)
            {
                var innerExt = new EXCEPTION_RECORD32();
                Marshal.PtrToStructure(ex.ExceptionRecord, innerExt);
                InnerException = new DebugException(innerExt, firstChance);
            }
        }
Exemplo n.º 28
0
        public void LoginExcep(LoginViewModel login)

        {
            code = ExceptionCode.Login;

            if (login.KullaniciAdi == null || login.KullaniciAdi.Length < 5 || login.KullaniciAdi.Length > 15)
            {
                throw new Exception(Resource.AdSınırlama);
            }

            if (login.Sifre == null || login.Sifre.Length < 5 || login.Sifre.Length > 20)
            {
                throw new Exception(Resource.ŞifreSınırlama);
            }
        }
Exemplo n.º 29
0
 public ExceptionCode WriteStruct(object structValue, int DB)
 {
     try
     {
         byte[]        bytes   = Types.Struct.ToBytes(structValue);
         ExceptionCode errCode = WriteBytes(DataType.DataBlock, DB, 0, bytes);
         return(errCode);
     }
     catch
     {
         lastErrorCode   = ExceptionCode.WriteData;
         lastErrorString = "Fehler beim Schreiben der Daten aufgetreten!";
         return(lastErrorCode);
     }
 }
Exemplo n.º 30
0
 public override string ToString()
 {
     if (ExceptionCode != SLMP_EXCEPTION_CODE_T.RUNTIME_ERROR)
     {
         return(ExceptionCode.ToString());
     }
     else if (RuntimeException != null)
     {
         return(RuntimeException.ToString());
     }
     else
     {
         return("UNDEFINED_RUNTIME_ERROR");
     }
 }
Exemplo n.º 31
0
        protected override void AddDomainObject(object domainObject)
        {
            if (_facade == null)
            {
                _facade = new PerformanceFacade(base.DataProvider);
            }

            ExceptionCode exceptionCode = (ExceptionCode)_facade.GetExceptionCode(FormatHelper.CleanString(this.txtExceptionCodeEdit.Text.ToUpper()));

            if (exceptionCode != null)
            {
                WebInfoPublish.Publish(this, "$The_Same_ExceptionCode_Is_Exist", this.languageComponent1);
                return;
            }
            this._facade.AddExceptionCode((ExceptionCode)domainObject);
        }
Exemplo n.º 32
0
        public ExceptionCode WriteBytes(DataType DataType, int DB, int StartByteAdr, byte[] value)
        {
            byte[] bReceive = new byte[513];
            int    varCount = 0;

            try
            {
                varCount = value.Length;
                // first create the header
                int             packageSize = 35 + value.Length;
                Types.ByteArray package     = new Types.ByteArray(packageSize);

                package.Add(new byte[] { 3, 0, 0 });
                package.Add((byte)packageSize);
                package.Add(new byte[] { 2, 0xf0, 0x80, 0x32, 1, 0, 0 });
                package.Add(Types.Word.ToByteArray((ushort)(varCount - 1)));
                package.Add(new byte[] { 0, 0x0e });
                package.Add(Types.Word.ToByteArray((ushort)(varCount + 4)));
                package.Add(new byte[] { 0x05, 0x01, 0x12, 0x0a, 0x10, 0x02 });
                package.Add(Types.Word.ToByteArray((ushort)varCount));
                package.Add(Types.Word.ToByteArray((ushort)(DB)));
                package.Add((byte)DataType);
                package.Add((byte)0);
                package.Add(Types.Word.ToByteArray((ushort)(StartByteAdr * 8)));
                package.Add(new byte[] { 0, 4 });
                package.Add(Types.Word.ToByteArray((ushort)(varCount * 8)));

                // now join the header and the data
                package.Add(value);

                mSocket.Send(package.array, package.array.Length, SocketFlags.None);

                int numReceived = mSocket.Receive(bReceive, 512, SocketFlags.None);
                if (bReceive[21] != 0xff)
                {
                    throw new Exception(ExceptionCode.WrongNumberReceivedBytes.ToString());
                }

                return(ExceptionCode.ExceptionNo);
            }
            catch
            {
                lastErrorCode   = ExceptionCode.WriteData;
                lastErrorString = "";
                return(lastErrorCode);
            }
        }
Exemplo n.º 33
0
 /// <summary>
 /// Creates an exception from a code and message.
 /// </summary>
 /// <param name="code">Identifiing code of exception.</param>
 /// <param name="message">English debugging message.</param>
 public PiFormatException(ExceptionCode code, string message)
     : base(code, message)
 {
 }
Exemplo n.º 34
0
 public static string GetCodeMessage(ExceptionCode code, out string title)
 {
     switch (code)
     {
         case ExceptionCode.AccessViolation:
             title = "Access violation";
             return @"The thread tried to read from or write to a virtual address for which it does not have the appropriate access.";
         case ExceptionCode.ArrayBoundsExceeded:
             title = "Array bounds exceeded";
             return @"The thread tried to access an array element that is out of bounds and the underlying hardware supports bounds checking.";
         case ExceptionCode.Breakpoint:
             title = "Breakpoint";
             return @"A breakpoint was encountered.";
         case ExceptionCode.DataTypeMisalignment:
             title = "Data type misalignment";
             return @"The thread tried to read or write data that is misaligned on hardware that does not provide alignment. For example, 16-bit values must be aligned on 2-byte boundaries; 32-bit values on 4-byte boundaries, and so on.";
         case ExceptionCode.Float_DenormalOperand:
             title = "Denormal Operand";
             return @"One of the operands in a floating-point operation is denormal. A denormal value is one that is too small to represent as a standard floating-point value.";
         case ExceptionCode.Float_DivideByZero:
             title = "Divide by zero";
             return @"The thread tried to divide a floating-point value by a floating-point divisor of zero.";
         case ExceptionCode.Float_InexactResult:
             title = "Inexact result";
             return @"The result of a floating-point operation cannot be represented exactly as a decimal fraction.";
         case ExceptionCode.Float_InvalidOperation:
             return title = "Invalid floatint-point operation";
         case ExceptionCode.Float_Overflow:
             title = "Float overflow";
             return "The exponent of a floating-point operation is greater than the magnitude allowed by the corresponding type.";
         case ExceptionCode.Float_StackCheck:
             title = "Stack over-/underflow";
             return "The stack overflowed or underflowed as the result of a floating-point operation.";
         case ExceptionCode.Float_Underflow:
             title = "Stack underflow";
             return "The exponent of a floating-point operation is less than the magnitude allowed by the corresponding type.";
         case ExceptionCode.IllegalInstruction:
             title = "Illegal instruction";
             return "The thread tried to execute an invalid instruction.";
         case ExceptionCode.InPageError:
             title = "In-Page error";
             return "The thread tried to access a page that was not present, and the system was unable to load the page. For example, this exception might occur if a network connection is lost while running a program over the network.";
         case ExceptionCode.Integer_DivideByZero:
             title = "Divide by zero";
             return "The thread tried to divide an integer value by an integer divisor of zero.";
         case ExceptionCode.Integer_Overflow:
             title = "Integer overflow";
             return "The result of an integer operation caused a carry out of the most significant bit of the result.";
         case ExceptionCode.InvalidDisposition:
             title = "Invalid disposition";
             return "An exception handler returned an invalid disposition to the exception dispatcher. Programmers using a high-level language such as C should never encounter this exception.";
         case ExceptionCode.NoncontinuableException:
             title = "Noncontinuable exception";
             return "The thread tried to continue execution after a noncontinuable exception occurred.";
         case ExceptionCode.PrivilegedInstruction:
             title = "Privileged instruction";
             return "The thread tried to execute an instruction whose operation is not allowed in the current machine mode.";
         case ExceptionCode.SingleStep:
             title = "Single step";
             return "A trace trap or other single-instruction mechanism signaled that one instruction has been executed.";
         case ExceptionCode.StackOverflow:
             title = "Stack overflow";
             return "The thread used up its stack.";
         default:
             title = null;
             return null;
     }
 }
Exemplo n.º 35
0
 /// <summary>
 /// Creates an exception from a code and message.
 /// </summary>
 /// <param name="code">Identifiing code of exception.</param>
 /// <param name="message">English debugging message.</param>
 public PiSecurityException(ExceptionCode code, string message)
     : base(code, message)
 {
 }
Exemplo n.º 36
0
		/// <summary>
		/// Throws a <see cref="DOMException"/> user exception with the given code.
		/// </summary>
		/// <param name="code">The exception code.</param>
		/// <exception cref="PhpUserException"/>
		internal static void Throw(ExceptionCode code)
		{
			string msg;

			switch (code)
			{
				case ExceptionCode.IndexOutOfBounds: msg = Resources.ErrorIndexOutOfBounds; break;
				case ExceptionCode.StringTooLong: msg = Resources.ErrorStringTooLong; break;
				case ExceptionCode.BadHierarchy: msg = Resources.ErrorBadHierarchy; break;
				case ExceptionCode.WrongDocument: msg = Resources.ErrorWrongDocument; break;
				case ExceptionCode.InvalidCharacter: msg = Resources.ErrorInvalidCharacter; break;
				case ExceptionCode.DataNotAllowed: msg = Resources.ErrorDataNotAllowed; break;
				case ExceptionCode.DomModificationNotAllowed: msg = Resources.ErrorDomModificationNotAllowed; break;
				case ExceptionCode.NotFound: msg = Resources.ErrorNotFound; break;
				case ExceptionCode.NotSupported: msg = Resources.ErrorNotSupported; break;
				case ExceptionCode.AttributeInUse: msg = Resources.ErrorAttributeInUse; break;
				case ExceptionCode.InvalidState: msg = Resources.ErrorInvalidState; break;
				case ExceptionCode.SyntaxError: msg = Resources.ErrorSyntaxError; break;
				case ExceptionCode.ModificationNotAllowed: msg = Resources.ErrorModificationNotAllowed; break;
				case ExceptionCode.NamespaceError: msg = Resources.ErrorNamespaceError; break;
				case ExceptionCode.InvalidAccess: msg = Resources.ErrorInvalidAccess; break;
				case ExceptionCode.ValidationError: msg = Resources.ErrorValidationError; break;

				default:
					throw new InvalidOperationException();
			}

			Throw(code, msg);
		}
Exemplo n.º 37
0
 /// <summary>
 /// Creates an exception from a code and message.
 /// </summary>
 /// <param name="code">Identifiing code of exception.</param>
 /// <param name="message">English debugging message.</param>
 public PiArgumentException(ExceptionCode code, string message)
     : base(code, message)
 {
 }
Exemplo n.º 38
0
 /// <summary>
 /// Creates modbus bad response
 /// </summary>
 /// <param name="device">Slave address</param>
 /// <param name="function">Function</param>
 /// <param name="code">Exception code</param>
 /// <returns>Modbus bad response</returns>
 public static Packet CreateBadResponse(byte device, Function function, ExceptionCode code)
 {
     return CreateCustomPacket(device, (byte)(0x80 | (byte)function), new[] { (byte)code });
 }
Exemplo n.º 39
0
 public ExceptionReport(string Message, ExceptionCode ExceptionCode, string Locator)
     : base(Message)
 {
     this.ExceptionCode = ExceptionCode;
     this.Locator = Locator;
 }
Exemplo n.º 40
0
 public ExceptionReport(ExceptionReport exception, string Message, ExceptionCode ExceptionCode)
     : base(Message, exception)
 {
 }
Exemplo n.º 41
0
 protected ExceptionReport(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     ExceptionCode = (ExceptionCode)info.GetValue("ExceptionCode", typeof(ExceptionCode));
     Locator = (string)info.GetValue("Locator", typeof(string));
 }
Exemplo n.º 42
0
 /// <summary>
 /// 初始化为未知的服务异常
 /// </summary>
 /// <param name="message"></param>
 /// <param name="code"></param>
 public ServiceException(string message, ExceptionCode code)
     : this(message, code, null)
 {
     this.ErrorCode = ExceptionCode.Unknown;
 }
Exemplo n.º 43
0
        public static void ExceptionToDisp(ExceptionCode e, int pos)
        {
            string[] msg = new string[4] { " ", " ", " ", " " };

            switch (e)
            {
                case ExceptionCode.CreditInsufficient:
                    msg[0] = " We are sorry";
                    msg[2] = " Not enough credit";
                    break;
                case ExceptionCode.WrongCalibration:
                    msg[0] = " We are sorry";
                    msg[2] = " Wrong calibration";
                    break;
                case ExceptionCode.CardMissing:
                    msg[0] = " We are sorry";
                    msg[2] = " Card was removed";
                    break;
                case ExceptionCode.ResidueLow:
                    new Bottle().Read(pos);
                    msg[0] = " Lack of wine";
                    msg[2] = " in the bottle";
                    break;
                case ExceptionCode.PositionBlocked:
                    msg[0] = " We are sorry";
                    msg[2] = " Bottle is closed  ";
                    break;
                case ExceptionCode.NoPriceSetted:
                    msg[0] = " We are sorry";
                    msg[2] = " price is not set";
                    break;
                case ExceptionCode.NoVolumeSetted:
                    msg[0] = " We are sorry";
                    msg[2] = " volume is not set";
                    break;
            }

            Buttons.Write(pos, Cmd.Print, 0, 1, 0, 1, msg[0]);
            Buttons.Write(pos, Cmd.Print, 0, 33, 0, 1, msg[2]);

            Thread.Sleep(4000);
        }
Exemplo n.º 44
0
        public static void ExceptionToDisp(ExceptionCode e, int pos)
        {
            string[] msg = new string[4] { " ", " ", " ", " " };

            switch (e)
            {
                case ExceptionCode.CreditInsufficient:
                    msg[0] = " We are sorry";
                    msg[2] = " Not enough credit";
                    break;
                case ExceptionCode.WrongCalibration:
                    msg[0] = " We are sorry";
                    msg[2] = " Wrong calibration";
                    break;
                case ExceptionCode.CardMissing:
                    msg[0] = " We are sorry";
                    msg[2] = " Card was removed";
                    break;
                case ExceptionCode.ResidueLow:
                    new Bottle().Read(pos);
                    msg[0] = "  Not enough for";
                    msg[1] = "     this serve";
                    break;
                case ExceptionCode.PositionBlocked:
                    msg[0] = " We are sorry";
                    msg[2] = " Bottle is closed  ";
                    break;
                case ExceptionCode.NoPriceSetted:
                    msg[0] = " We are sorry";
                    msg[2] = " price is not set";
                    break;
                case ExceptionCode.NoVolumeSetted:
                    msg[0] = " We are sorry";
                    msg[2] = " volume is not set";
                    break;
            }

            for (int i = 0; i < 4; i++)
            {
                if (msg[i] != String.Empty)
                    Buttons.Write(pos, Cmd.Print, 0, ((i * 16) + 1), 0, 1, msg[i]);
            }

            Thread.Sleep(4000);
        }
Exemplo n.º 45
0
 public ExceptionReport(string Message, ExceptionCode ExceptionCode)
     : this(Message, ExceptionCode, "")
 {
 }
Exemplo n.º 46
0
 /// <summary>
 /// Creates an exception from a code and message.
 /// </summary>
 /// <param name="code">Identifiing code of exception.</param>
 /// <param name="message">English debugging message.</param>
 public PiException(ExceptionCode code, string message)
     : base(message)
 {
     Code = code;
 }
Exemplo n.º 47
0
		/// <summary>
		/// Throws a <see cref="DOMException"/> user exception with the given code and message.
		/// </summary>
		/// <param name="code">The exception code.</param>
		/// <param name="message">The exception message.</param>
		/// <exception cref="PhpUserException"/>
		internal static void Throw(ExceptionCode code, string message)
		{
			ScriptContext context = ScriptContext.CurrentContext;

			DOMException exception = new DOMException(context, true);
			exception.__construct(context, message, (int)code);
			exception._code = code;

			throw new PhpUserException(exception);
		}
Exemplo n.º 48
0
 public ExceptionReport(ExceptionCode ExceptionCode, string Locator)
     : this("", ExceptionCode, Locator)
 {
 }
Exemplo n.º 49
0
 /// <summary>
 /// 初始化服务异常
 /// </summary>
 /// <param name="message"></param>
 /// <param name="code"></param>
 /// <param name="inner"></param>
 public ServiceException(string message, ExceptionCode code, Exception inner)
     : base(message, inner)
 {
     this.ErrorCode = code;
 }
Exemplo n.º 50
0
 public ExceptionReport(ExceptionCode ExceptionCode)
     : this("", ExceptionCode, "")
 {
 }
Exemplo n.º 51
0
 public static void Clear()
 {
     card = String.Empty;
     result = String.Empty;
     confirmed = String.Empty;
     exception = String.Empty;
     errcode = ExceptionCode.None;
     uniqueid = string.Empty;
     events = 0;
     dosevolume = 0;
     doseprice = 0;
     RESPONSE_OK = false;
 }