public bool DeleteQry(string strSql)
        {
            bool result = false;
            int  intRetRows;

            con = new MySqlConnection(strConn);

            try
            {
                cmd = new MySqlCommand(strSql, con);
                con.Open();

                intRetRows = cmd.ExecuteNonQuery();
                if (intRetRows > 0)
                {
                    result = true;
                }
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                CloseConnection();
            }

            return(result);
        }
Exemple #2
0
 static async public void ExceptionMessage(Exception ex, object window)
 {
     try
     {
         //Message
         if (ex.HResult == -2146233088)
         {
             Toaster.ShowError(window as Window, message: MainWindow.resourcemanager.GetString("trNoInternetConnection"), animation: ToasterAnimation.FadeIn);
         }
         else
         {
             Toaster.ShowError(window as Window, message: ex.HResult + " || " + ex.Message, animation: ToasterAnimation.FadeIn);
         }
         ErrorClass errorClass = new ErrorClass();
         errorClass.num          = ex.HResult.ToString();
         errorClass.msg          = ex.Message;
         errorClass.stackTrace   = ex.StackTrace;
         errorClass.targetSite   = ex.TargetSite.ToString();
         errorClass.createUserId = MainWindow.userLogin.userId;
         await errorClass.Save(errorClass);
     }
     catch
     {
     }
 }
        public int UpdateQryRetRows(string sqlStr, MySqlParameter[] commandParameters)
        {
            con = new MySqlConnection(strConn);
            int intRetRows = 0;

            try
            {
                cmd = new MySqlCommand(sqlStr, con);
                con.Open();

                foreach (MySqlParameter p in commandParameters)
                {
                    if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
                    {
                        p.Value = DBNull.Value;
                    }

                    cmd.Parameters.Add(p);
                }

                intRetRows = cmd.ExecuteNonQuery();
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                cmd.Parameters.Clear();
                CloseConnection();
            }
            return(intRetRows);
        }
        public MySqlDataReader SelectQry(MySqlCommand cmdParam)
        {
            MySqlDataReader dataReader = null;

            try
            {
                using (con = new MySqlConnection(strConn))
                {
                    con = new MySqlConnection(strConn);
                    cmdParam.Connection = con;
                    con.Open();
                    dataReader = cmdParam.ExecuteReader(CommandBehavior.CloseConnection);
                    cmdParam.Parameters.Clear();
                }
            }
            catch (Exception err)
            {
                cmdParam.Parameters.Clear();
                CloseConnection();

                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }

            return(dataReader);
        }
        public DataSet SelectAdaptQry(string strSql)
        {
            DataSet dataSet = new DataSet();

            con = new MySqlConnection(strConn);

            try
            {
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                adapter.SelectCommand = new MySqlCommand(strSql, con);
                adapter.Fill(dataSet);
            }
            catch (MySqlException exSql)
            {
                dataSet = null;

                var objErr = new ErrorClass(exSql, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                CloseConnection();
            }

            return(dataSet);
        }
        private Func <BugKind, bool> getPredicate(ErrorClass ec)
        {
            // predicate is based on arg
            Func <BugKind, bool> fn;

            switch (ec)
            {
            case ErrorClass.INCONSISTENT:
                fn = (bk) => IsInconsistentFormulaBug(bk);
                break;

            case ErrorClass.MISSINGFORMULA:
                fn = (bk) => IsMissingFormulaBug(bk);
                break;

            case ErrorClass.WHITESPACE:
                fn = (bk) => IsWhitespaceBug(bk);
                break;

            case ErrorClass.SUSPICIOUS:
                fn = (bk) => IsSuspiciousCell(bk);
                break;

            default:
                throw new ArgumentOutOfRangeException("Don't know predicate for error class = " + ec);
            }
            return(fn);
        }
        /// <summary>
        ///  This method calls stored procedure getallservices to get all available services.
        /// </summary>
        /// <returns></returns>
        public List <Service> GetAllServices()
        {
            var serviceList = new List <Service>();

            try
            {
                using (MySqlCommand cmd = new MySqlCommand("getallservices"))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    Database db = new Database();
                    using (MySqlDataReader dr = db.SelectQry(cmd))
                    {
                        while (dr.Read())
                        {
                            serviceList.Add(new Service()
                            {
                                serviceName   = dr["serviceName"].ToString(),
                                serviceDesc   = dr["servicesDesc"].ToString(),
                                serviceStatus = Int32.Parse(dr["IsActive"].ToString()),
                                id            = Int32.Parse(dr["id"].ToString()),
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                var objErr = new ErrorClass(ex, "");
                objErr.LogException();
            }
            return(serviceList);
        }
Exemple #8
0
        /// <summary>
        /// Creates a valid COM HResult that does not conflict with Microsofts predefined COM HResults (range 0x00000000-0x000001ff).
        /// </summary>
        /// <param name="errorClass"></param>
        /// <param name="code"></param>
        /// <returns>The HResult.</returns>
        internal int CreateHResult(ErrorClass errorClass, int code)
        {
            const int hresultSeverity    = 1 << 31;
            const int hresultCustomer    = 1 << 29;
            const int hresultFacilityItf = 4 << 16;

            switch (errorClass)
            {
            case ErrorClass.ClientApi:
                code = ScaleCode(code, 0, (int)NabtoStatus.ErrorCodeCount - 1);
                break;

            case ErrorClass.Misc:
                code = ScaleCode(code, 7000, 7003);
                break;

            case ErrorClass.Internal:
                code = ScaleCode(code, 1000000, 1000104);
                break;

            case ErrorClass.General:
                code = ScaleCode(code, 2000000, 2000064);
                break;

            case ErrorClass.Configuration:
                code = ScaleCode(code, 3000000, 3000000);
                break;
            }

            code |= (int)errorClass << 8;

            return(hresultSeverity | hresultCustomer | hresultFacilityItf | code);
        }
Exemple #9
0
        internal void RemoveErrorsForEFObject(EFObject efobject, ErrorClass errorClass, int errorCodeToRemove)
        {
            Dictionary <ErrorClass, ICollection <ErrorInfo> > errorClass2ErrorInfo = null;

            _artifacts2Errors.TryGetValue(efobject.Artifact, out errorClass2ErrorInfo);
            if (errorClass2ErrorInfo != null)
            {
                foreach (var errors in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
                {
                    var errorsToRemove = new List <ErrorInfo>();
                    foreach (var errorInfo in errors)
                    {
                        if (errorInfo.ErrorCode == errorCodeToRemove)
                        {
                            errorsToRemove.Add(errorInfo);
                        }
                    }

                    foreach (var errorInfo in errorsToRemove)
                    {
                        errors.Remove(errorInfo);
                    }
                }
            }
        }
        public bool DeleteQry(MySqlCommand cmdParam)
        {
            con = new MySqlConnection(strConn);
            bool result = false;

            try
            {
                cmdParam.Connection = con;
                con.Open();

                int retval = cmdParam.ExecuteNonQuery();

                if (retval > 0)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                cmdParam.Parameters.Clear();
                CloseConnection();
            }
            return(result);
        }
Exemple #11
0
        // take conditions and JSON, decode it, execute..
        static public bool?CheckCondition(List <Condition> fel,
                                          Object cls,              // object with data in it
                                          Variables[] othervars,   // any other variables to present to the condition, in addition to the class variables
                                          out string errlist,      // null if okay..
                                          out ErrorClass errclass,
                                          List <Condition> passed) // null or conditions passed
        {
            errlist  = null;
            errclass = ErrorClass.None;

            Variables valuesneeded = new Variables();

            foreach (Condition fe in fel)        // find all values needed
            {
                fe.IndicateValuesNeeded(ref valuesneeded);
            }

            try
            {
                valuesneeded.GetValuesIndicated(cls);                                          // given the class data, and the list of values needed, add it
                valuesneeded.Add(othervars);
                return(CheckConditions(fel, valuesneeded, out errlist, out errclass, passed)); // and check, passing in the values collected against the conditions to test.
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Bad check condition:" + ex);
                errlist = "class failed to parse";
                return(null);
            }
        }
        /// <summary>
        /// similar to method SelectAdaptQry(MySqlCommand cmdParam) but the parameters of the input MySqlCommand remain intact
        /// </summary>
        public DataSet SelectAdaptQryParamNC(MySqlCommand cmdParam)
        {
            con = new MySqlConnection(strConn);
            DataSet          dataSet = new DataSet();
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            try
            {
                cmdParam.Connection = con;
                //con.Open();
                adapter.SelectCommand = cmdParam;
                adapter.Fill(dataSet);
            }
            catch (MySqlException exSql)
            {
                dataSet = null;
                var objErr = new ErrorClass(exSql, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            catch (Exception err)
            {
                HttpContext.Current.Trace.Warn(err.Message + err.Source);
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                CloseConnection();
            }
            return(dataSet);
        }
        //Added By Ranjeet ||For async || Used for Used car search
        public async Task <DataTable> AsyncGetDataTable(MySqlCommand cmd)
        {
            DataTable dt = new DataTable();
            var       asyncConnectionString = new MySqlConnectionStringBuilder(ConfigurationManager.AppSettings["connectionString"])
            {
                //AsynchronousProcessing = true
            }.ToString();

            using (var conn = new MySqlConnection(asyncConnectionString))
            {
                try
                {
                    Static_count += 1;

                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;

                    await cmd.Connection.OpenAsync().ConfigureAwait(false);

                    using (var reader = await cmd.ExecuteReaderAsync().ConfigureAwait(false))
                    {
                        //Thread.Sleep(2000);
                        dt.Load(reader);
                    }

                    cmd.Connection.Close();
                }
                catch (Exception ex)
                {
                    var objErr = new ErrorClass(ex, "AsyncDb sql: ");
                    objErr.LogException();
                }
            }
            return(dt);
        }
        public string GetInClauseValue(string input, string fieldName, out MySqlParameter[] commandParameters)
        {
            string[] inputArr   = input.Split(',');
            string[] parameters = new string[inputArr.Length];
            commandParameters = null;
            try
            {
                commandParameters = new MySqlParameter[inputArr.Length];

                for (int i = 0; i < inputArr.Length; i++)
                {
                    parameters[i]        = "@" + fieldName + i;
                    commandParameters[i] = new MySqlParameter(parameters[i], inputArr[i]);
                    HttpContext.Current.Trace.Warn(parameters[i].ToString() + " : " + inputArr[i].ToString());
                }

                HttpContext.Current.Trace.Warn(commandParameters.Length.ToString());
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }

            return(string.Join(",", parameters));
        }
        public MySqlDataReader SelectQry(string sqlStr, MySqlParameter[] commandParameters)
        {
            MySqlDataReader dataReader = null;

            con = new MySqlConnection(strConn);

            try
            {
                con.Open();
                cmd = new MySqlCommand(sqlStr, con);
                foreach (MySqlParameter p in commandParameters)
                {
                    if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
                    {
                        p.Value = DBNull.Value;
                    }

                    cmd.Parameters.Add(p);
                }
                dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                cmd.Parameters.Clear();
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                cmd.Parameters.Clear();
                //CloseConnection();
            }
            return(dataReader);
        }
        public string ExecuteScalar(string strSql, MySqlParameter[] commandParameters)
        {
            string val = "";

            con = new MySqlConnection(strConn);

            try
            {
                cmd = new MySqlCommand(strSql, con);
                con.Open();

                foreach (MySqlParameter p in commandParameters)
                {
                    if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
                    {
                        p.Value = DBNull.Value;
                    }

                    cmd.Parameters.Add(p);
                }
                val = Convert.ToString(cmd.ExecuteScalar());
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                cmd.Parameters.Clear();
                CloseConnection();
            }
            return(val);
        }
        public string ExecuteScalar(string strSql)
        {
            string val = "";

            MySqlConnection con;
            MySqlCommand    cmd;

            string conStr = GetConString();

            con = new MySqlConnection(conStr);

            try
            {
                con.Open();
                cmd = new MySqlCommand(strSql, con);
                val = Convert.ToString(cmd.ExecuteScalar());
            }
            catch (Exception err)
            {
                var objErr = new ErrorClass(err, HttpContext.Current.Request.ServerVariables["URL"]);
                objErr.LogException();
            }
            finally
            {
                CloseConnection();
            }
            return(val);
        }
Exemple #18
0
        public static void CreateItem(ErrorClass newItem)
        {
            OperationsOnDatabase odb    = new OperationsOnDatabase();
            HttpClient           client = new HttpClient();

            client.BaseAddress = new Uri(String.Format(SERVICE_URL, SERVICE_PORT));
            odb.AddErrorLogsFromRest(newItem.Loglevel, newItem.ApplicationId, newItem.ErrorText);
            client.PostAsJsonAsync(GET_ACTION, newItem).Wait();
        }
Exemple #19
0
 /// <summary>
 ///     Clear all errors of the given class for all Artifacts in this ArtifactSet.
 /// </summary>
 /// <param name="errorClass"></param>
 internal void ClearErrors(ErrorClass errorClass)
 {
     foreach (var errorClass2ErrorInfo in _artifacts2Errors.Values)
     {
         foreach (var errorList in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
         {
             errorList.Clear();
         }
     }
 }
Exemple #20
0
        internal ICollection <ErrorInfo> GetErrors(ErrorClass errorClass)
        {
            var allErrors = new List <ErrorInfo>();

            foreach (var artifact in Artifacts)
            {
                GetErrorsForArtifact(artifact, allErrors, errorClass);
            }
            return(allErrors);
        }
Exemple #21
0
        private static string GetError(int ErrorID)
        {
            ErrorClass Error = ErrorList.ToList().Find(x => x.ErrorID == ErrorID);

            if (Error != null)
            {
                return(string.Format("{0} ({1})", Error.Message, ErrorID));
            }

            return(string.Format("Error: Unknown {0}", ErrorID));
        }
Exemple #22
0
        internal ErrorInfo(Severity severity, string message, EFObject item, int errorCode, ErrorClass errorClass)
        {
            Debug.Assert(item != null, "item != null");
            _severity = severity;

            // prefix the error code in front of the error message.  This is here to help identify runtime errors that cause safe-mode
            _message    = String.Format(CultureInfo.CurrentCulture, Resources.Error_Message_With_Error_Code_Prefix, errorCode, message);
            _item       = item;
            _errorCode  = errorCode;
            _errorClass = errorClass;
        }
Exemple #23
0
        public static ErrorBuilder CreateError(AttemptContext?ctx, ErrorClass causingErrorClass, Exception?causingException = null)
        {
            var builder = new ErrorBuilder(ctx, causingErrorClass);

            if (causingException != null)
            {
                builder.Cause(causingException);
            }

            return(builder);
        }
Exemple #24
0
        // check all conditions against these values.
        public bool?CheckAll(Variables values, out string errlist, out ErrorClass errclass, List <Condition> passed = null, Functions cf = null) // Check all conditions..
        {
            if (conditionlist.Count == 0)                                                                                                        // no filters match, null
            {
                errlist  = null;
                errclass = ErrorClass.None;
                return(null);
            }

            return(CheckConditions(conditionlist, values, out errlist, out errclass, passed, cf));
        }
Exemple #25
0
 public static string[] SplitString(this string value, int index)
 {
     if (index <0 | index> value.Length)
     {
         ErrorClass badIndex = new ErrorClass("The index is not within the string.");
         throw badIndex;
     }
     string[] retVal = { value.Substring(0, index - 1),
                         value.Substring(index) };
     return(retVal);
 }
Exemple #26
0
 internal void SetValidityDirtyForErrorClass(ErrorClass errorClass, bool isDirty)
 {
     if (isDirty)
     {
         _isValidityDirtyErrorClassMask |= errorClass;
     }
     else
     {
         _isValidityDirtyErrorClassMask &= ~errorClass;
     }
 }
        /// <summary>
        /// Get total # of bugs for given error class
        /// </summary>
        /// <param name="bugkind"></param>
        /// <returns></returns>
        public int TotalNumBugKindBugs(ErrorClass ec)
        {
            var wbs   = WorkbooksAnnotated;
            int count = 0;

            foreach (var wb in wbs)
            {
                count += NumBugKindBugsForWorkbook(wb, ec);
            }
            return(count);
        }
Exemple #28
0
 internal void RemoveErrorsForArtifact(EFArtifact artifact, ErrorClass errorClass)
 {
     if (_artifacts2Errors.ContainsKey(artifact))
     {
         var errorClass2ErrorInfo = _artifacts2Errors[artifact];
         foreach (var errorInfos in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
         {
             errorInfos.Clear();
         }
     }
 }
Exemple #29
0
        /// <summary>
        /// This method calls stored procedure getrequestbyfilters to get all service requests based on filters.
        /// </summary>
        /// <param name="caregiverId"></param>
        /// <param name="requesterId"></param>
        /// <param name="status"></param>
        /// <returns>List of Service Request</returns>
        public List <Request> getRequestsByFilters(int caregiverId, int requesterId, string status)
        {
            var requestList = new List <Request>();

            try
            {
                using (MySqlCommand cmd = new MySqlCommand("getrequestbyfilters"))
                {
                    string[] statusArr = status.Split(',');
                    for (int i = 0; i < statusArr.Length; i++)
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("_CaregiverId", caregiverId);
                        cmd.Parameters.AddWithValue("_requesterId", requesterId);
                        cmd.Parameters.AddWithValue("_status", statusArr[i]);
                        Database db = new Database();
                        using (MySqlDataReader dr = db.SelectQry(cmd))
                        {
                            while (dr.Read())
                            {
                                requestList.Add(new Request()
                                {
                                    id            = Int32.Parse(dr["id"].ToString()),
                                    RequesterId   = Int32.Parse(dr["RequesterId"].ToString()),
                                    RoleId        = Int32.Parse(dr["RoleId"].ToString()),
                                    CaregiverId   = Int32.Parse(dr["CaregiverId"].ToString()),
                                    ServiceId     = Int32.Parse(dr["ServiceId"].ToString()),
                                    Status        = dr["Status"].ToString(),
                                    ScheduleDate  = dr["ScheduleDate"].ToString(),
                                    StartTime     = dr["StartTime"].ToString(),
                                    EndTime       = dr["EndTime"].ToString(),
                                    Comments      = dr["Comments"].ToString(),
                                    ModifiedBy    = Int32.Parse(dr["ModifiedBy"].ToString()),
                                    ModifiedOn    = Convert.ToDateTime(dr["ModifiedOn"].ToString()),
                                    Address       = dr["Address"].ToString(),
                                    serviceName   = dr["serviceName"].ToString(),
                                    FirstName     = dr["FirstName"].ToString(),
                                    LastName      = dr["LastName"].ToString(),
                                    RequesterName = dr["FirstName"].ToString() + " " + dr["LastName"].ToString()
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                var objErr = new ErrorClass(ex, "");
                objErr.LogException();
            }
            return(requestList);
        }
Exemple #30
0
        private ErrorInfo(Severity severity, string message, EFObject item, string itemPath, int errorCode, ErrorClass errorClass)
        {
            Debug.Assert(item == null ^ itemPath == null, "item and itemPath are mutually exclusive");

            _severity = severity;
            _item     = item;
            _itemPath = itemPath;
            // prefix the error code in front of the error message.  This is here to help identify runtime errors that cause safe-mode
            _message    = String.Format(CultureInfo.CurrentCulture, Resources.Error_Message_With_Error_Code_Prefix, errorCode, message);
            _item       = item;
            _errorCode  = errorCode;
            _errorClass = errorClass;
        }
Exemple #31
0
        private ErrorInfo(Severity severity, string message, EFObject item, string itemPath, int errorCode, ErrorClass errorClass)
        {
            Debug.Assert(item == null ^ itemPath == null, "item and itemPath are mutually exclusive");

            _severity = severity;
            _item = item;
            _itemPath = itemPath;
            // prefix the error code in front of the error message.  This is here to help identify runtime errors that cause safe-mode
            _message = String.Format(CultureInfo.CurrentCulture, Resources.Error_Message_With_Error_Code_Prefix, errorCode, message);
            _item = item;
            _errorCode = errorCode;
            _errorClass = errorClass;
        }
Exemple #32
0
        public string GetErrorMessage(ErrorClass errorClass, long errorCode)
        {
            string errorMessage = string.Empty;

            switch (errorClass)
            {
                case ErrorClass.Win32_Process_Create:
                    errorMessage = RetreiveErrorMessage(_win32ProcessCreate, errorCode);
                    break;
                case ErrorClass.Win32_Process_Terminate:
                    errorMessage = RetreiveErrorMessage(_win32ProcessTerminate, errorCode);
                    break;
                case ErrorClass.Win32_Share:
                    errorMessage = RetreiveErrorMessage(_win32Share, errorCode);
                    break;
                case ErrorClass.Win32_Directory:
                    errorMessage = RetreiveErrorMessage(_win32Directory, errorCode);
                    break;
            }

            return errorMessage;
        }
        // internal for testing
        internal void ProcessErrors(IEnumerable<EdmSchemaError> errors, EntityDesignArtifact defaultArtifactForError, ErrorClass errorClass)
        {
            Debug.Assert(errors != null, "errors != null");
            Debug.Assert(defaultArtifactForError != null, "defaultArtifactForError != null");

            var artifactSet = defaultArtifactForError.ArtifactSet;

            foreach (var error in errors)
            {
                var efObject = EdmSchemaError2EFObject(error, defaultArtifactForError);
                if (error.ErrorCode == (int)ErrorCode.NotInNamespace)
                {
                    // we want to replace runtime error for missing complex property type with ours. This
                    // is classified as a Runtime_CSDL error even though we are using an Escher error code
                    // since we are basically re-interpreting a runtime error.
                    var property = efObject as ComplexConceptualProperty;
                    if (property != null
                        && property.ComplexType.RefName == Resources.ComplexPropertyUndefinedType)
                    {
                        artifactSet.AddError(
                            new ErrorInfo(
                                ErrorInfo.Severity.ERROR,
                                string.Format(
                                    CultureInfo.CurrentCulture, Resources.EscherValidation_UndefinedComplexPropertyType,
                                    property.LocalName.Value),
                                property,
                                ErrorCodes.ESCHER_VALIDATOR_UNDEFINED_COMPLEX_PROPERTY_TYPE,
                                ErrorClass.Runtime_CSDL));
                        continue;
                    }
                }
                else if (error.ErrorCode == (int)MappingErrorCode.InvalidAssociationSet
                         && error.Severity == EdmSchemaErrorSeverity.Warning)
                {
                    // this is a warning about AssociationSetMappings on fk associations for pk-to-pk associations being ignored.
                    var associationSetMapping = efObject as AssociationSetMapping;
                    Debug.Assert(associationSetMapping != null, "Warning 2005 reported on EFObject other than Association Set Mapping");
                    if (associationSetMapping != null)
                    {
                        artifactSet.AddError(
                            new ErrorInfo(
                                GetErrorInfoSeverity(error),
                                string.Format(
                                    CultureInfo.CurrentCulture, Resources.EscherValidation_IgnoreMappedFKAssociation,
                                    associationSetMapping.Name.RefName),
                                efObject,
                                error.ErrorCode,
                                errorClass));
                        continue;
                    }
                }

                var severity =
                    error.ErrorCode == (int)MappingErrorCode.EmptyContainerMapping
                    && ValidationHelper.IsStorageModelEmpty(defaultArtifactForError)
                        ? ErrorInfo.Severity.WARNING
                        : GetErrorInfoSeverity(error);

                artifactSet.AddError(new ErrorInfo(severity, error.Message, efObject, error.ErrorCode, errorClass));
            }

            defaultArtifactForError.SetValidityDirtyForErrorClass(errorClass, false);
        }
Exemple #34
0
 // should be used for code first errors
 public ErrorInfo(Severity severity, string message, string itemPath, int errorCode, ErrorClass errorClass)
     : this(severity, message, null, itemPath, errorCode, errorClass)
 {
     Debug.Assert(!string.IsNullOrEmpty(itemPath), "invalid item path");
 }
Exemple #35
0
 // should be used for edmx errors 
 public ErrorInfo(Severity severity, string message, EFObject item, int errorCode, ErrorClass errorClass)
     : this(severity, message, item, null, errorCode, errorClass)
 {
     Debug.Assert(item != null, "item is null");
 }
 internal void RemoveErrorsForArtifact(EFArtifact artifact, ErrorClass errorClass)
 {
     if (_artifacts2Errors.ContainsKey(artifact))
     {
         var errorClass2ErrorInfo = _artifacts2Errors[artifact];
         foreach (var errorInfos in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
         {
             errorInfos.Clear();
         }
     }
 }
 internal bool IsValidityDirtyForErrorClass(ErrorClass errorClassMask)
 {
     return Artifacts.Any(artifact => artifact.IsValidityDirtyForErrorClass(errorClassMask));
 }
        internal void RemoveErrorsForEFObject(EFObject efobject, ErrorClass errorClass, int errorCodeToRemove)
        {
            Dictionary<ErrorClass, ICollection<ErrorInfo>> errorClass2ErrorInfo = null;
            _artifacts2Errors.TryGetValue(efobject.Artifact, out errorClass2ErrorInfo);
            if (errorClass2ErrorInfo != null)
            {
                foreach (var errors in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
                {
                    var errorsToRemove = new List<ErrorInfo>();
                    foreach (var errorInfo in errors)
                    {
                        if (errorInfo.ErrorCode == errorCodeToRemove)
                        {
                            errorsToRemove.Add(errorInfo);
                        }
                    }

                    foreach (var errorInfo in errorsToRemove)
                    {
                        errors.Remove(errorInfo);
                    }
                }
            }
        }
 /// <summary>
 ///     Clear all errors of the given class for all Artifacts in this ArtifactSet.
 /// </summary>
 /// <param name="errorClass"></param>
 internal void ClearErrors(ErrorClass errorClass)
 {
     foreach (var errorClass2ErrorInfo in _artifacts2Errors.Values)
     {
         foreach (var errorList in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
         {
             errorList.Clear();
         }
     }
 }
 internal ICollection<ErrorInfo> GetErrors(ErrorClass errorClass)
 {
     var allErrors = new List<ErrorInfo>();
     foreach (var artifact in Artifacts)
     {
         GetErrorsForArtifact(artifact, allErrors, errorClass);
     }
     return allErrors;
 }
        internal void GetErrorsForArtifact(EFArtifact artifact, List<ErrorInfo> errors, ErrorClass errorClass)
        {
            Dictionary<ErrorClass, ICollection<ErrorInfo>> errorClass2ErrorInfo = null;

            _artifacts2Errors.TryGetValue(artifact, out errorClass2ErrorInfo);

            if (errorClass2ErrorInfo != null)
            {
                foreach (var e in GetErrorInfosUsingMask(errorClass2ErrorInfo, errorClass))
                {
                    errors.AddRange(e);
                }
            }
        }
        /// <summary>
        ///     This will mask the dictionary using an error class, returning back a list of error lists
        /// </summary>
        private static IEnumerable<ICollection<ErrorInfo>> GetErrorInfosUsingMask(
            Dictionary<ErrorClass, ICollection<ErrorInfo>> errorClass2ErrorInfos, ErrorClass errorClassMask)
        {
            var nonCompositeEnumValues = ErrorClassValues.Where(v => !IsCompositeErrorClass(v) && v != 0);

            foreach (var errorClass in nonCompositeEnumValues.Cast<ErrorClass>())
            {
                if ((errorClass & errorClassMask) != 0)
                {
                    if (errorClass2ErrorInfos.ContainsKey(errorClass))
                    {
                        yield return errorClass2ErrorInfos[errorClass];
                    }
                }
            }
        }
 /// <summary>
 ///     This method checks to see if *any* of the ErrorClasses in the ErrorClass
 ///     mask have a dirty validity
 /// </summary>
 internal bool IsValidityDirtyForErrorClass(ErrorClass errorClassMask)
 {
     return (_isValidityDirtyErrorClassMask & errorClassMask) != 0;
 }
 internal void SetValidityDirtyForErrorClass(ErrorClass errorClass, bool isDirty)
 {
     if (isDirty)
     {
         _isValidityDirtyErrorClassMask |= errorClass;
     }
     else
     {
         _isValidityDirtyErrorClassMask &= ~errorClass;
     }
 }