Esempio n. 1
0
        public static String GetUserPreference(int userID, int siteID, int programID, string preferenceType)
        {
            String _result = string.Empty;

            using (var db = new Data.DBMEdition01Context())
            {
                ExceptionLogServices exceptionLog = new ExceptionLogServices();
                try
                {
                    var _ret = db.ApiGetUserPreference(userID, siteID, programID, preferenceType);

                    if (_ret.Count > 0)
                    {
                        _result = _ret.FirstOrDefault().PreferenceValue;
                    }
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiMobileSaveTracerResponse(" + userID + "," + siteID + "," + programID + "," + preferenceType + ")";
                    string methodName = "JCRAPI/Business/UserServices/MenuStateInit";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userID, siteID, sqlParam, string.Empty);

                    return(null);
                }
            }

            return(_result);
        }
Esempio n. 2
0
        public static string SaveAttachmentFile(string fileName, byte[] p2, string appCode)
        {
            UsmCcmInsertFileReturnModel rtn;
            ExceptionLogServices        exceptionLog = new ExceptionLogServices();

            using (var db = new DBFileTableContext())
            {
                //rtn = db.usmc(fileName, p2,).FirstOrDefault().stream_id.ToString();
                //   rtn = _result.ToString();

                try
                {
                    rtn = db.UsmCcmInsertFile(fileName, p2, appCode).FirstOrDefault();
                }
                catch (Exception ex)
                {
                    string sqlParam   = "UsmCcmInsertFile(" + fileName + "," + p2 + "," + appCode + ")";
                    string methodName = "JCRAPI/Business/FilesServices/SaveAttachmentFile";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, null, sqlParam, string.Empty);

                    return(null);
                }
            }

            return(rtn.stream_ID.ToString());
        }
Esempio n. 3
0
 public static void UpdateUserPreference(UserPreference userPref)
 {
     using (var db = new Data.DBMEdition01Context())
     {
         ExceptionLogServices exceptionLog = new ExceptionLogServices();
         try
         {
             db.ApiUpdateUserPreference(userPref.UserID, userPref.SiteID, userPref.ProgramID, userPref.preferenceType, userPref.PreferenceValue);
         }
         catch (Exception ex)
         {
             string sqlParam   = "ApiUpdateUserPreference(" + userPref.UserID + "," + userPref.SiteID + "," + userPref.ProgramID + "," + userPref.preferenceType + "," + userPref.PreferenceValue + ")";
             string methodName = "JCRAPI/Business/UserServices/UpdateUserPreference";
             exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userPref.UserID, userPref.SiteID, sqlParam, string.Empty);
         }
     }
 }
Esempio n. 4
0
        public void KillToken(Token token)
        {
            ExceptionLogServices exceptionLog = new ExceptionLogServices();

            using (var db = new DBAMPContext())
            {
                try
                {
                    int rtn = db.ApiTokenDelete(token.UserId, token.AuthToken);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiTokenDelete(" + token.UserId + "," + token.AuthToken + ")";
                    string methodName = "JCRAPI/Business/TokenService/KillToken";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, token.UserId, null, sqlParam, string.Empty);
                }
            }
        }
Esempio n. 5
0
        public int InsertCustomerSupport(CustomerSupport customerSupport)
        {
            ExceptionLogServices exceptionLog = new ExceptionLogServices();
            int      _result;
            DateTime submitTime = DateTime.Now;
            //=============User for Expection Log=======
            string userId    = customerSupport.UserID;
            string siteId    = customerSupport.SiteID;
            string HCOID     = (customerSupport.HCOID == 0) ? "null" : customerSupport.HCOID.ToString();
            string subject   = customerSupport.Subject;
            string body      = customerSupport.Body;
            string productId = customerSupport.EProductID.ToString();
            string programId = customerSupport.ProgramID.ToString();

            //==========================================
            using (var db = new DBAMPContext())
            {
                try
                {
                    _result = db.ApiInsertCustomerSupport(Convert.ToInt32(customerSupport.UserID),
                                                          Convert.ToInt32(customerSupport.SiteID),
                                                          (customerSupport.HCOID == 0) ? null : customerSupport.HCOID,
                                                          submitTime,
                                                          customerSupport.Subject,
                                                          customerSupport.Body,
                                                          customerSupport.EProductID,
                                                          customerSupport.ProgramID);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiInsertCustomerSupport(" + userId + "," + siteId + "," + HCOID + "," + submitTime.ToString() + "," + subject + "," + body + "," + productId + "," + programId + ")";
                    string methodName = "JCRAPI/Business/CustomerSupportEmailServices/InsertCustomerSupport";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, Convert.ToInt32(userId), Convert.ToInt32(siteId), sqlParam, string.Empty);

                    return(0);
                }
            }

            return(_result);
        }
Esempio n. 6
0
        public static List <ApiGetProgramsBySiteReturnModel> GetProgramsBySite(int siteID)
        {
            List <ApiGetProgramsBySiteReturnModel> _result;

            using (var db = new Data.DBMEdition01Context())
            {
                ExceptionLogServices exceptionLog = new ExceptionLogServices();
                try
                {
                    _result = db.ApiGetProgramsBySite(siteID);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiGetUserSites(" + siteID + ")";
                    string methodName = "JCRAPI/Business/SiteServices/GetProgramsBySite";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, siteID, 0, sqlParam, string.Empty);

                    return(null);
                }
            }

            return(_result);
        }
Esempio n. 7
0
        public static List <ApiGetAllUserSitesReturnModel> GetUserSites(int userID)
        {
            List <ApiGetAllUserSitesReturnModel> _result;

            using (var db = new Data.DBAMPContext())
            {
                ExceptionLogServices exceptionLog = new ExceptionLogServices();
                try
                {
                    _result = db.ApiGetAllUserSites(userID);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiGetUserSites(" + userID + ")";
                    string methodName = "JCRAPI/Business/SiteServices/ApiGetUserSites";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userID, 0, sqlParam, string.Empty);

                    return(null);
                }
            }

            return(_result);
        }
Esempio n. 8
0
 public TracerCategoryServices()
 {
     exceptionLog = new ExceptionLogServices();
 }
Esempio n. 9
0
        public static string ValidatePasswordRules(int userId, string newPassword)
        {
            //get existing site settings
            string attributeList = "";
            int    siteId;
            string existingPassword;

            List <ApiSelectSiteAttributeMapReturnModel> passwordRestrictions = new List <ApiSelectSiteAttributeMapReturnModel>();

            attributeList = ((int)Enums.CodeCategoryEnum.SitePasswordResetInterval).ToString() + "," +
                            ((int)Enums.CodeCategoryEnum.SitePasswordSpecialRequirements).ToString() + "," +
                            ((int)Enums.CodeCategoryEnum.SitePasswordLength).ToString() + "," +
                            ((int)Enums.CodeCategoryEnum.SitePasswordUpperCaseRequirements).ToString() + "," +
                            ((int)Enums.CodeCategoryEnum.SitePasswordNumericRequirements).ToString();
            ExceptionLogServices exceptionLog = new ExceptionLogServices();

            using (var db = new DBAMPContext())
            {
                try
                {
                    siteId = db.ApiGetUserDefaultSiteId(userId).FirstOrDefault().DefaultSelectedSiteId;
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiGetUserDefaultSiteId(" + userId + ")";
                    string methodName = "JCRAPI/Business/UserServices/ValidatePasswordRules";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userId, null, sqlParam, string.Empty);

                    siteId = 0;
                }
                try
                {
                    existingPassword = db.ApiGetUserPassword(userId).FirstOrDefault().AttributeValue;
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiGetUserPassword(" + userId + ")";
                    string methodName = "JCRAPI/Business/UserServices/ValidatePasswordRules";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userId, siteId, sqlParam, string.Empty);

                    existingPassword = string.Empty;
                }
            }

            using (var db = new DBMEdition01Context())
            {
                try
                {
                    passwordRestrictions = db.ApiSelectSiteAttributeMap(siteId, attributeList);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiSelectSiteAttributeMap(" + siteId + "," + attributeList + ")";
                    string methodName = "JCRAPI/Business/UserServices/ValidatePasswordRules";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userId, siteId, sqlParam, string.Empty);

                    existingPassword = string.Empty;
                }
            }


            bool   textRestrictions = false;
            string retValue         = "";
            bool   passwordGood     = true;


            foreach (var restriction in passwordRestrictions)

            {
                int rowCode  = Convert.ToInt32(restriction.AttributeTypeID.ToString());
                int rowValue = Convert.ToInt32(restriction.AttributeValueID.ToString());
                switch (rowCode)
                {
                case (int)Enums.CodeCategoryEnum.SitePasswordLength:
                    if (newPassword.Trim().Length < rowValue)
                    {
                        retValue    += "###Minimum Password Length is " + rowValue.ToString() + " Characters";
                        passwordGood = false;
                    }
                    break;

                case (int)Enums.CodeCategoryEnum.SitePasswordResetInterval:

                    string encyptEnteredPwd = "";
                    if (newPassword.Trim().Length > 0)
                    {
                        encyptEnteredPwd = CryptHelpers.Encrypt(newPassword.Trim(), WebConstants.EncryptionKey);
                    }

                    if (encyptEnteredPwd == existingPassword)
                    {
                        retValue    += "###Existing password cannot be used";
                        passwordGood = false;
                    }
                    break;

                case (int)Enums.CodeCategoryEnum.SitePasswordSpecialRequirements:
                    if (rowValue == 1)
                    {
                        char[] anyChars =
                        {
                            '!', '#', '$', '%', '&', '(',  ')', '*', '+', ',', '.', '/', ':', '<',
                            '='
                            ,    '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~',
                            '"'
                        };
                        // special chars
                        int index = newPassword.IndexOfAny(anyChars);
                        if (index < 0)
                        {
                            passwordGood = false;
                            retValue    +=
                                "###At least one Special Character is required: ! # $ % & ( ) * + , . / : < = > ? @ [ \\ ] ^ _ ` { | } ~ \"  Characters below cannot be used  ' - ; ";
                        }
                        textRestrictions = true;
                    }
                    break;

                case (int)Enums.CodeCategoryEnum.SitePasswordUpperCaseRequirements:
                    if (rowValue == 1)
                    {
                        char[] anyChars =
                        {
                            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
                            'O'
                            ,    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
                        };
                        // special chars
                        int index = newPassword.IndexOfAny(anyChars);
                        if (index < 0)
                        {
                            passwordGood = false;
                            retValue    += "###At least one Upper Case Character is required ";
                        }
                        textRestrictions = true;
                    }
                    break;

                case (int)Enums.CodeCategoryEnum.SitePasswordNumericRequirements:
                    if (rowValue == 1)
                    {
                        char[] anyChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };     // special chars
                        int    index    = newPassword.IndexOfAny(anyChars);
                        if (index < 0)
                        {
                            passwordGood = false;
                            retValue    += "###At least one Numeric Character is required ";
                        }
                        textRestrictions = true;
                    }
                    break;
                }
            }
            if (textRestrictions)
            {
                char[] anyChars =
                {
                    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
                    'q',
                    'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
                };                   // special chars
                int index = newPassword.IndexOfAny(anyChars);
                if (index < 0)
                {
                    passwordGood = false;
                    retValue    += "###At least one Lower Case Character is required";
                }
            }
            if (passwordGood)
            {
                retValue = "";
            }
            return(retValue);
        }