コード例 #1
0
        public string SavePDF(string Title, byte[] fileContent, string pformatType = "pdf")
        {
            string Attachment = "";

            try
            {
                var    fileLocation = AppDomain.CurrentDomain.BaseDirectory + "ReportExportFiles";
                string dtNow        = DateTime.Now.ToString("MM-dd-yyyy_hhmmssfff_tt");
                string filename     = string.Format("{0}_{1}.{2}", Title, dtNow.ToString(), pformatType);
                Attachment = Path.Combine(fileLocation, filename);
                using (var fs = new FileStream(Attachment, FileMode.Create))
                {
                    try
                    {
                        fs.Write(fileContent, 0, fileContent.Length);
                    }
                    catch (Exception ex)
                    {
                        string sqlParam   = "Write(" + fileContent + ",0," + fileContent.Length + ")";
                        string methodName = "JCRAPI/Business/EmailServices/SavePDF";
                        exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, null, sqlParam, string.Empty);

                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Attachment);
        }
コード例 #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());
        }
コード例 #3
0
ファイル: UserServices.cs プロジェクト: SubhoM/WebApi
        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);
        }
コード例 #4
0
ファイル: PasswordServices.cs プロジェクト: SubhoM/WebApi
        public ApiSelectSecurityQuestionsByIdReturnModel GetSecurityQuestionsById(int?questionTyeId)
        {
            ApiSelectSecurityQuestionsByIdReturnModel _result;

            using (var db = new DBAMPContext())
            {
                try
                {
                    _result = db.ApiSelectSecurityQuestionsById(questionTyeId);
                }
                catch (System.Exception ex)
                {
                    string sqlParam   = "ApiSelectSecurityQuestionsById(" + questionTyeId + ")";
                    string methodName = "JCRAPI/Business/PasswordServices/GetSecurityQuestionsById";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, null, sqlParam, string.Empty);
                    return(null);
                }
            }
            return(_result);
        }
コード例 #5
0
ファイル: MenuServices.cs プロジェクト: SubhoM/WebApi
        public ApiMenuStateGetReturnModel GetMenuState(int?userId)
        {
            using (var db = new DBMEdition01Context()) {
                ApiMenuStateGetReturnModel result;

                try
                {
                    result = db.ApiMenuStateGet(userId).FirstOrDefault();
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiMenuStateGet(" + userId + ")";
                    string methodName = "JCRAPI/Business/MenuServices/GetMenuState";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userId, null, sqlParam, string.Empty);

                    return(null);
                }
                return(result);
            }
        }
コード例 #6
0
ファイル: ActionTracking.cs プロジェクト: SubhoM/WebApi
        int IActionTracking.AddAppEventLog(int?programId, int?siteId, int?actionTypeId, int?userId)
        {
            int _result;

            using (var db = new DBAMPContext())
            {
                try
                {
                    _result = db.ApiLogTracerActionSummaryByMonth(programId, siteId, actionTypeId, userId);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiLogTracerActionSummaryByMonth(" + programId + "," + siteId + "," + actionTypeId + "," + userId + ")";
                    string methodName = "JCRAPI/Business/IActionTracking/AddAppEventLog";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userId, siteId, sqlParam, string.Empty);

                    return(0);
                }
            }
            return(_result);
        }
コード例 #7
0
        public IEnumerable <UspSiteSelectReturnModel.ResultSetModel1> GetSiteById(int siteId)
        {
            UspSiteSelectReturnModel uspsiteselect_result;

            using (var db = new DBAMPContext())
            {
                try
                {
                    uspsiteselect_result = db.UspSiteSelect(siteId);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "UspSiteSelect(" + siteId + ")";
                    string methodName = "JCRAPI/Business/SiteServices/GetSiteById";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, siteId, sqlParam, string.Empty);

                    return(null);
                }
            }

            return(uspsiteselect_result.ResultSet1);
        }
コード例 #8
0
        public List <ApiGetTracerCategoryBySiteIdReturnModel> GetTracerCategoryBySite(int siteId)
        {
            try
            {
                List <ApiGetTracerCategoryBySiteIdReturnModel> _dbResult;

                using (var db = new DBMEdition01Context())
                {
                    _dbResult = db.ApiGetTracerCategoryBySiteId(siteId);
                }

                return(_dbResult);
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("EXEC dbo.ApiGetTracerCategoryBySiteId @SiteID='{0}'", siteId);
                string sqlParam   = sb.ToString();
                string methodName = "JCRAPI/Business/TracerCategoryServices/GetTracerCategoryBySite";
                exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, siteId, sqlParam, string.Empty);
                return(null);
            }
        }
コード例 #9
0
ファイル: TracerMobileServices.cs プロジェクト: SubhoM/WebApi
        //Get Tracer Observation Questions
        public List <ApiMobileGetObservationDetailsByIdReturnModel> GetObservationDetailsById(int?tracerCustomID, int?ResponseId, bool?IsGuestAccess)
        {
            List <ApiMobileGetObservationDetailsByIdReturnModel> _result;

            using (var db = new DBMEdition01Context())
            {
                try {
                    _result = db.ApiMobileGetObservationDetailsById(tracerCustomID, ResponseId, IsGuestAccess);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiMobileGetObservationDetailsById(" + tracerCustomID + "," + ResponseId + "," + IsGuestAccess + ")";
                    string methodName = "JCRAPI/Business/TracerMobileServices/GetObservationDetailsById";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, null, sqlParam, string.Empty);

                    return(null);
                }
            }
            return(_result);
        }
コード例 #10
0
ファイル: UserServices.cs プロジェクト: SubhoM/WebApi
 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);
         }
     }
 }
コード例 #11
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);
                }
            }
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
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);
        }
コード例 #15
0
ファイル: UserServices.cs プロジェクト: SubhoM/WebApi
        /// Public method to authenticate user by user name and password.

        public int Authenticate(string userLogin, string password, int?subscriptionTypeId, out string invalidMsg)
        {
            ApiValidateUserReturnModel user;
            int rtn;

            using (var db = new DBAMPContext())
            {
                try
                {
                    user = db.ApiValidateUser(userLogin, password, subscriptionTypeId, out rtn).FirstOrDefault();

                    if (rtn > 0)
                    {
                        if (rtn == 3)
                        {
                            invalidMsg = "Invalid username and/or password.";
                        }
                        else if (rtn == 4)
                        {
                            invalidMsg = "User does not have access.";
                        }
                        else
                        {
                            invalidMsg = "Other Errors";
                        }

                        return(0);
                    }
                    else
                    {
                        invalidMsg = string.Empty;

                        return(user.UserID);
                    }
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiValidateUser(" + userLogin + "," + password + "," + subscriptionTypeId + ", out rtn)";
                    string methodName = "JCRAPI/Business/UserServices/Authenticate";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, null, sqlParam, string.Empty);
                    invalidMsg = "Other Errors";
                    return(0);
                }
            }
        }
コード例 #16
0
        public List <ApiGetTracerCategoryNamesReturnModel> GetTracerCategoryNames(int?siteId, int?programId)
        {
            List <ApiGetTracerCategoryNamesReturnModel> _result;

            using (var db = new DBMEdition01Context())
            {
                try
                {
                    _result = db.ApiGetTracerCategoryNames(siteId, programId);
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiGetTracerCategoryNames(" + siteId + "," + programId + ")";
                    string methodName = "JCRAPI/Business/TracerService/GetTracerCategoryNames";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, null, siteId, sqlParam, string.Empty);

                    return(null);
                }
            }
            return(_result);
        }
コード例 #17
0
ファイル: GuestUserServices.cs プロジェクト: SubhoM/WebApi
        public List <ApiMobileGuestUserSelectSitesReturnModel> GetGuestUserSites(int userId, string email)
        {
            List <ApiMobileGuestUserSelectSitesReturnModel> rtn;

            MailAddress address = new MailAddress(email);

            string currentHost = "@" + address.Host;
            bool   isInvalidDomain;
            int    numberOfInactiveDepartments;

            using (var db = new DBMEdition01Context())
            {
                try
                {
                    rtn = db.ApiMobileGuestUserSelectSites((int)userId, (int)Enums.EProduct.Tracers);
                    if (rtn.Count > 0)
                    {
                        foreach (var item in rtn.ToList())
                        {
                            isInvalidDomain = GetGuestAccessDomains(item.SiteID, currentHost);
                            if (isInvalidDomain) //Check Domain Restriction
                            {
                                rtn.Remove(item);
                            }

                            numberOfInactiveDepartments = GetDepartmentCount(item.SiteID, item.ProgramID);

                            if (numberOfInactiveDepartments == 0) //Check  Department
                            {
                                rtn.Remove(item);
                            }

                            if (item.RoleID == null)
                            {
                                item.RoleID = 7;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string sqlParam   = "ApiMobileSaveTracerResponse(" + userId + ",2" + ")";
                    string methodName = "JCRAPI/Business/GuestUserServices/GetGuestUserSites";
                    exceptionLog.ExceptionLogInsert(ex.Message.ToString(), "", methodName, userId, null, sqlParam, string.Empty);

                    return(null);
                }
            }
            rtn = rtn.GroupBy(x => x.SiteID).Select(g => g.First()).ToList();
            return(rtn);
        }
コード例 #18
0
ファイル: UserServices.cs プロジェクト: SubhoM/WebApi
        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);
        }