Example #1
0
        private bool UpdateConfigValueByName(string name, string value)
        {
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras    = new CParameters();
                SqlParameter paraName = new SqlParameter("@Name", name);
                paras.Add(paraName);
                SqlParameter paraValue = new SqlParameter("@Value", value);
                paras.Add(paraValue);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.prc_ModifyCommon", out ds, out strError))
                    {
                        Log4netHelper.Error("prc_ModifyCommon 执行错误,Error:" + strError);
                        bResult = false;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                break;

                            default:
                                bResult = false;
                                break;
                            }
                        }
                        else
                        {
                            bResult = false;
                            break;
                        }
                    }
                    else
                    {
                        bResult = false;
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                Log4netHelper.Error(string.Format("UpdateConfigValueByName 异常:{0}", ex.ToString()));
                bResult = false;
            }
            return(bResult);
        }
Example #2
0
        private void SyncSystemMailCount(DateTime startTime, DateTime endTime)
        {
            ExchangeWebservice.ManagerWebService service = new ExchangeWebservice.ManagerWebService();
            service.Timeout = -1;
            //DateTime startTime = new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, 0, 0, 1);
            //DateTime endTime = new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, 23, 23, 59);
            int    iSendMailCount    = 0;
            int    iReceiveMailCount = 0;
            string strError          = string.Empty;

            try
            {
                if (!service.GetServerMailCount(startTime, endTime, out iSendMailCount, out iReceiveMailCount, out strError))
                {
                    Log4netHelper.Error("获取系统邮件个数, error:" + strError);
                }
            }
            catch (Exception ex)
            {
                Log4netHelper.Error("获取系统邮件个数, Exception:" + ex.ToString());
            }


            try
            {
                CParameters  parameters   = new CParameters();
                SqlParameter paraDateTime = new SqlParameter("@TotalDate", startTime);
                parameters.Add(paraDateTime);
                SqlParameter paraSendCount = new SqlParameter("@SendMailCount", iSendMailCount);
                parameters.Add(paraSendCount);
                SqlParameter paraReceiveCount = new SqlParameter("@ReceiveMailCount", iReceiveMailCount);
                parameters.Add(paraReceiveCount);

                int iResult = 1;

                if (!m_db.ExcuteByTransaction(parameters, "dbo.prc_InsertADSystemMailCount", out iResult, out strError))
                {
                    Log4netHelper.Error("系统邮件个数存入数据库, error:" + strError);
                }

                if (iResult == -1)
                {
                    Log4netHelper.Error("系统邮件个数存入数据库, error: 调用存储过程 spInsertADSystemMailCount 返回值-1");
                }
            }
            catch (Exception ex)
            {
                Log4netHelper.Error("系统邮件个数存入数据库, Exception:" + ex.ToString());
            }
        }
        public bool GetMailDataBaseBydistinguishedName(Guid transactionid, string distinguishedName, out List <MailDataBaseInfo> list, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            list  = new List <MailDataBaseInfo>();
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras = new CParameters();
                SqlParameter paraDistinguishedName = new SqlParameter("@distinguishedName", distinguishedName);
                paras.Add(paraDistinguishedName);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_GetMailboxDBBydistinguishedName]", out ds, out strError))
                    {
                        strError   = "prc_GetMailboxDBBydistinguishedName数据库执行失败,Error:" + strError;
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }

                    if (ds != null && ds.Tables.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            DataRow          sdr  = ds.Tables[0].Rows[i];
                            MailDataBaseInfo info = new MailDataBaseInfo();
                            info.ID     = Guid.Parse(Convert.ToString(sdr["ID"]));
                            info.OuID   = Guid.Parse(Convert.ToString(sdr["OuID"]));
                            info.OuName = Convert.ToString(sdr["OuName"]);
                            info.OUdistinguishedName = Convert.ToString(sdr["OUdistinguishedName"]);
                            info.MailboxDBID         = Guid.Parse(Convert.ToString(sdr["MailboxDBID"]));
                            info.MailboxDB           = Convert.ToString(sdr["MailboxDB"]);
                            info.MailboxServer       = Convert.ToString(sdr["MailboxServer"]);
                            info.CreateTime          = Convert.ToDateTime(sdr["CreateTime"]);
                            list.Add(info);
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("数据库执行prc_GetMailboxDBBydistinguishedName失败", string.Empty, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("MailDataBaseDBProvider调用prc_GetMailboxDBBydistinguishedName异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #4
0
        private bool GetDC(ref string dcName)
        {
            string strError = string.Empty;
            bool   bResult  = true;

            if (!GetAvailabilityDC(dcName))
            {
                #region 参数变量
                CParameters  paras       = new CParameters();
                SqlParameter paraSpareDC = new SqlParameter("@Name", "SpareDC");
                paras.Add(paraSpareDC);
                #endregion

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                DataSet ds  = null;
                if (!_db.ExcuteByTransaction(paras, "[prc_GetCommonDataByName]", out ds, out strError))
                {
                    strError = "执行存储过程GetConfigValueByNameByProc异常";
                    bResult  = false;
                }
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string dc = Convert.ToString(ds.Tables[0].Rows[0]["Comm_Value"]);
                        if (GetAvailabilityDC(dc))
                        {
                            UpdateConfigValueByName("AD_DC", dc);
                            dcName = dc;
                            break;
                        }
                    }

                    bResult = true;
                }
                else
                {
                    strError = "执行存储过程GetConfigValueByNameByProc,输出的DataSet为空或无效";
                    bResult  = false;
                }

                return(bResult);
            }
            else
            {
                return(true);
            }
        }
Example #5
0
        private bool GetConfigValueByNameByProc(string name, out string value, out string strError)
        {
            bool bResult = true;

            strError = string.Empty;
            value    = string.Empty;
            try
            {
                #region 参数变量
                CParameters  paras       = new CParameters();
                SqlParameter paraAccount = new SqlParameter("@Name", name);
                paras.Add(paraAccount);
                #endregion

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                DataSet ds  = null;
                if (!_db.ExcuteByTransaction(paras, "[prc_GetCommonDataByName]", out ds, out strError))
                {
                    strError = "执行存储过程GetConfigValueByNameByProc异常";
                    bResult  = false;
                }
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    value = Convert.ToString(ds.Tables[0].Rows[0]["Comm_Value"]);
                    if (name == "AD_DC")
                    {
                        lock (o)
                        {
                            //判断DC有效性
                            GetDC(ref value);
                        }
                    }
                    bResult = true;
                }
                else
                {
                    strError = "执行存储过程GetConfigValueByNameByProc,输出的DataSet为空或无效";
                    bResult  = false;
                }
            }
            catch (Exception ex)
            {
                strError = "接口方法GetConfigValueByNameByProc异常,error:" + ex.ToString();
                bResult  = false;
            }
            return(bResult);
        }
Example #6
0
        private static bool GetConfigValueByNameByProc(string name, out List <string> list, out string strError)
        {
            bool bResult = true;

            strError = string.Empty;
            list     = new List <string>();
            try
            {
                #region 参数变量
                CParameters  paras       = new CParameters();
                SqlParameter paraAccount = new SqlParameter("@Name", name);
                paras.Add(paraAccount);
                #endregion

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                DataSet ds  = null;
                if (!_db.ExcuteByTransaction(paras, "[prc_GetCommonDataByName]", out ds, out strError))
                {
                    strError = "执行存储过程GetConfigValueByNameByProc异常";
                    bResult  = false;
                }
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string value = Convert.ToString(dr["Comm_Value"]);
                        list.Add(value);
                    }
                    bResult = true;
                }
                else
                {
                    strError = "执行存储过程GetConfigValueByNameByProc,输出的DataSet为空或无效";
                    bResult  = false;
                }
            }
            catch (Exception ex)
            {
                strError = "接口方法GetConfigValueByNameByProc异常,error:" + ex.ToString();
                bResult  = false;
            }
            return(bResult);
        }
Example #7
0
        private void SyncUserMailCount(DateTime startTime, DateTime endTime)
        {
            ExchangeWebservice.ManagerWebService service = new ExchangeWebservice.ManagerWebService();
            service.Timeout = -1;
            //DateTime startTime = new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, 0, 0, 1);
            //DateTime endTime = new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, 23, 23, 59);
            string  strError = string.Empty;
            DataSet ds       = new DataSet();

            try
            {
                //读取ad user
                string strsql = "select sAMAccountName,UserPrincipalName from dbo.T_Base_ADUser";

                if (!m_db.ExcuteByDataAdapter(strsql, out ds, out strError))
                {
                    Log4netHelper.Error("获取User信息失败, Error:" + strError);
                }
            }
            catch (Exception ex)
            {
                Log4netHelper.Error("获取User信息失败, Exception:" + ex.ToString());
            }


            //循环调用接口同步用户邮件个数
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int iSendMailCount    = 0;
                    int iReceiveMailCount = 0;
                    try
                    {
                        if (!service.GetUserMailCount(startTime, endTime, Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), out iSendMailCount, out iReceiveMailCount, out strError))
                        {
                            Log4netHelper.Error(string.Format("获取用户邮件个数, sAMAccountName:{0} UserPrincipalName:{1} error:{2}", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), strError));
                        }
                    }
                    catch (Exception ex)
                    {
                        Log4netHelper.Error(string.Format("获取用户邮件个数, sAMAccountName:{0} UserPrincipalName:{1} Exception:{2}", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), ex.ToString()));
                    }

                    try
                    {
                        //添加到数据库
                        CParameters  parameters         = new CParameters();
                        SqlParameter parasAMAccountName = new SqlParameter("@sAMAccountName", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]));
                        parameters.Add(parasAMAccountName);
                        //SqlParameter paraUserPrincipalName = new SqlParameter("@UserPrincipalName", Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]));
                        //parameters.Add(paraUserPrincipalName);
                        SqlParameter paraStartTime = new SqlParameter("@TotalDate", startTime);
                        parameters.Add(paraStartTime);
                        SqlParameter paraSendCount = new SqlParameter("@SendMailCount", iSendMailCount);
                        parameters.Add(paraSendCount);
                        SqlParameter paraReceiveCount = new SqlParameter("@ReceiveMailCount", iReceiveMailCount);
                        parameters.Add(paraReceiveCount);

                        int iResult = 1;
                        if (!m_db.ExcuteByTransaction(parameters, "dbo.prc_InsertADUserMailCount", out iResult, out strError))
                        {
                            Log4netHelper.Error(string.Format("用户邮件个数存入数据库, sAMAccountName:{0} UserPrincipalName:{1} error:{2}", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), strError));
                        }

                        if (iResult == -1)
                        {
                            Log4netHelper.Error(string.Format("用户邮件个数存入数据库, sAMAccountName:{0} UserPrincipalName:{1} 调用存储过程spInsertADUserMailCount返回值-1", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"])));
                        }
                    }
                    catch (Exception ex)
                    {
                        Log4netHelper.Error(string.Format("用户邮件个数存入数据库, sAMAccountName:{0} UserPrincipalName:{1} Exception:{2}", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), ex.ToString()));
                    }
                }
            }
        }
Example #8
0
        private void SyncUserMailSize()
        {
            ExchangeWebservice.ManagerWebService service = new ExchangeWebservice.ManagerWebService();
            service.Timeout = -1;
            string  strError = string.Empty;
            DataSet ds       = new DataSet();

            try
            {
                do
                {
                    //读取ad user
                    string strsql = "select sAMAccountName,UserPrincipalName from dbo.T_Base_ADUser";

                    if (!m_db.ExcuteByDataAdapter(strsql, out ds, out strError))
                    {
                        Log4netHelper.Error("获取User信息失败, Error:" + strError);
                        break;
                    }

                    //循环调用接口同步用户邮件个数
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            //GB
                            long   mailSize     = 0;
                            long   usedMailSize = 0;
                            string databaseName = string.Empty;
                            string sizename     = string.Empty;
                            string usedsizename = string.Empty;

                            if (!service.GetUserMailSize(Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), out sizename, out mailSize, out usedsizename, out usedMailSize, out databaseName, out strError))
                            {
                                Log4netHelper.Error(string.Format("获取用户邮箱空间, sAMAccountName:{0} UserPrincipalName:{1} error:{2}", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), strError));
                                continue;
                            }
                            //添加到数据库
                            CParameters  parameters         = new CParameters();
                            SqlParameter parasAMAccountName = new SqlParameter("@sAMAccountName", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]));
                            parameters.Add(parasAMAccountName);
                            SqlParameter paraSizeName = new SqlParameter("@sizename", sizename);
                            parameters.Add(paraSizeName);
                            SqlParameter paraMailSize = new SqlParameter("@mailSize", mailSize);
                            parameters.Add(paraMailSize);
                            SqlParameter paraUsedSizeName = new SqlParameter("@usedsizename", usedsizename);
                            parameters.Add(paraUsedSizeName);
                            SqlParameter paraUsedMailSize = new SqlParameter("@usedMailSize", usedMailSize);
                            parameters.Add(paraUsedMailSize);
                            SqlParameter paraDatabaseName = new SqlParameter("@databaseName", databaseName);
                            parameters.Add(paraDatabaseName);

                            int iResult = 1;
                            if (!m_db.ExcuteByTransaction(parameters, "dbo.prc_UpdateADUserMailSize", out iResult, out strError))
                            {
                                Log4netHelper.Error(string.Format("用户已用空间存入数据库, sAMAccountName:{0} UserPrincipalName:{1} error:{2}", Convert.ToString(ds.Tables[0].Rows[i]["sAMAccountName"]), Convert.ToString(ds.Tables[0].Rows[i]["UserPrincipalName"]), strError));
                                continue;
                            }
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                Log4netHelper.Error($"同步用户已用空间异常, Exception:{ex.ToString()}");
            }
        }
Example #9
0
        public static bool AddSysLog(
            string UserAccount,
            String OperationName,
            String ParamInfo,
            String DetailInfo,
            String Result,
            Guid TransactionID
            )
        {
            bool   bResult  = true;
            string strError = string.Empty;

            try
            {
                CParameters  paras             = new CParameters();
                SqlParameter paraUserAccount   = new SqlParameter("@UserAccount", UserAccount);
                SqlParameter paraOperationName = new SqlParameter("@OperationName", OperationName);
                SqlParameter paraParamInfo     = new SqlParameter("@ParamInfo", ParamInfo);
                SqlParameter paraDetailInfo    = new SqlParameter("@DetailInfo", DetailInfo);
                SqlParameter paraResult        = new SqlParameter("@Result", Result);
                SqlParameter paraTransactionID = new SqlParameter("@TransactionID", TransactionID);

                paras.Add(paraUserAccount);
                paras.Add(paraOperationName);
                paras.Add(paraParamInfo);
                paras.Add(paraDetailInfo);
                paras.Add(paraResult);
                paras.Add(paraTransactionID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    int     iResult = 0;
                    DataSet ds      = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_AddSysLog]", out iResult, out strError))
                    {
                        strError = "prc_AddSysLog数据库执行失败,Error:" + strError;
                        Log4netHelper.Error(strError);
                        bResult = false;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            switch (iResult)
                            {
                            case 0:
                                bResult = true;
                                break;

                            case -9999:
                                bResult = false;
                                break;

                            default:
                                bResult = false;
                                break;
                            }
                        }
                        else
                        {
                            bResult = false;
                            break;
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                Log4netHelper.Error(ex.ToString());
                bResult = false;
            }
            return(bResult);
        }
Example #10
0
        public bool GetLogList(Guid transactionid, AdminInfo admin, int curpage, int pagesize, string account, DateTime startTime, DateTime endTime, string searchstr, out BaseListInfo lists, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            lists = new BaseListInfo();
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras       = new CParameters();
                SqlParameter paraAdminID = new SqlParameter("@AdminID", admin.UserID);
                paras.Add(paraAdminID);
                SqlParameter paraPageIndex = new SqlParameter("@PageIndex", curpage);
                paras.Add(paraPageIndex);
                SqlParameter paraPageSize = new SqlParameter("@PageSize", pagesize);
                paras.Add(paraPageSize);
                SqlParameter paraAccount = new SqlParameter("@account", $"%{account}%");
                paras.Add(paraAccount);
                SqlParameter paraStartTime = new SqlParameter("@StartTime", startTime);
                paras.Add(paraStartTime);
                SqlParameter paraEndTime = new SqlParameter("@EndTime", endTime);
                paras.Add(paraEndTime);
                SqlParameter paraSearchstr = new SqlParameter("@Searchstr", $"%{searchstr}%");
                paras.Add(paraSearchstr);
                SqlParameter paraRecordCount = new SqlParameter("@RecordCount", SqlDbType.Int);
                paraRecordCount.Direction = ParameterDirection.Output;
                paras.Add(paraRecordCount);
                SqlParameter paraPageCount = new SqlParameter("@PageCount", SqlDbType.Int);
                paraPageCount.Direction = ParameterDirection.Output;
                paras.Add(paraPageCount);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_GetLogList]", out ds, out strError))
                    {
                        strError   = "prc_GetLogList数据库执行失败,Error:" + strError;
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }

                    lists.RecordCount = (int)paraRecordCount.Value;
                    lists.PageCount   = (int)paraPageCount.Value;

                    if (ds != null && ds.Tables.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            DataRow sdr  = ds.Tables[0].Rows[i];
                            LogInfo info = new LogInfo();
                            info.ID            = Guid.Parse(Convert.ToString(sdr["ID"]));
                            info.LogNum        = Convert.ToString(sdr["LogNum"]);
                            info.AdminID       = Guid.Parse(Convert.ToString(sdr["AdminID"]));
                            info.AdminAccount  = Convert.ToString(sdr["AdminAccount"]);
                            info.ClientIP      = Convert.ToString(sdr["ClientIP"]);
                            info.OperateLog    = Convert.ToString(sdr["OperateLog"]);
                            info.OperateResult = Convert.ToBoolean(sdr["OperateResult"]);
                            info.OperateTime   = Convert.ToDateTime(sdr["OperateTime"]);
                            info.OperateType   = Convert.ToString(sdr["OperateType"]);
                            info.RoleID        = Guid.Parse(Convert.ToString(sdr["RoleID"]));
                            lists.Lists.Add(info);
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("数据库执行prc_GetLogList失败", string.Empty, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("LogDBProvider调用prc_GetLogList异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #11
0
        public bool GetMailAuditInfo(Guid transactionid, AdminInfo admin, ref MailAuditInfo mailAuditInfo, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"AdminID:{admin.UserID}";
            paramstr += $"||ID:{mailAuditInfo.ID}";
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras       = new CParameters();
                SqlParameter paraAdminID = new SqlParameter("@AdminID", admin.UserID);
                paras.Add(paraAdminID);
                SqlParameter paraID = new SqlParameter("@ID", mailAuditInfo.ID);
                paras.Add(paraID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_GetMailAuditInfo]", out ds, out strError))
                    {
                        strError = "GetMailAuditInfo异常,Error:" + strError;
                        LoggerHelper.Error("MailAuditDBProvider调用GetMailAuditInfo异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                if (ds.Tables.Count > 1)
                                {
                                    DataRow sdr = ds.Tables[1].Rows[0];
                                    mailAuditInfo.ID                = Guid.Parse(Convert.ToString(sdr["ID"]));
                                    mailAuditInfo.Group.GroupID     = Guid.Parse(Convert.ToString(sdr["GroupID"]));
                                    mailAuditInfo.Group.DisplayName = Convert.ToString(sdr["GroupName"]);
                                    mailAuditInfo.Group.Account     = Convert.ToString(sdr["GroupAccount"]);
                                    mailAuditInfo.CreateTime        = Convert.ToDateTime(sdr["CreateTime"]);
                                    mailAuditInfo.UpdateTime        = Convert.ToDateTime(sdr["UpdateTime"]);
                                    mailAuditInfo.CreateUserID      = Guid.Parse(Convert.ToString(sdr["CreateUserID"]));
                                    mailAuditInfo.RoleID            = Guid.Parse(Convert.ToString(sdr["RoleID"]));

                                    foreach (DataRow dr in ds.Tables[2].Rows)
                                    {
                                        UserInfo user = new UserInfo();
                                        user.UserID      = Guid.Parse(Convert.ToString(dr["UserID"]));
                                        user.DisplayName = Convert.ToString(dr["DisplayName"]);
                                        user.UserAccount = Convert.ToString(dr["Account"]);
                                        mailAuditInfo.Audits.Add(user);
                                        mailAuditInfo.AuditUsers += user.DisplayName + "(" + user.UserAccount + "),";
                                    }

                                    mailAuditInfo.AuditUsers = mailAuditInfo.AuditUsers.Remove(mailAuditInfo.AuditUsers.LastIndexOf(','), 1);
                                }
                                break;

                            case -1:
                                bResult    = false;
                                error.Code = ErrorCode.HaveSameOu;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("MailAuditDBProvider调用GetMailAuditInfo异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("SensitiveMailDBProvider调用GetSensitiveMailInfo异常", paramstr, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("SensitiveMailDBProvider调用GetSensitiveMailInfo异常", paramstr, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #12
0
        public bool ModifyUser(Guid transactionid, AdminInfo admin, UserInfo user, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"AdminID:{admin.UserID}";
            paramstr += $"||AdminAccount:{admin.UserAccount}";
            paramstr += $"||UserID:{user.UserID}";
            paramstr += $"||UserAccount:{user.UserAccount}";
            paramstr += $"||UserDisplayName:{user.DisplayName}";
            paramstr += $"||UserFirstName:{user.FirstName}";
            paramstr += $"||UserLastName:{user.LastName}";
            paramstr += $"||DistinguishedName:{user.DistinguishedName}";

            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras      = new CParameters();
                SqlParameter paraUserID = new SqlParameter("@UserID", user.UserID);
                paras.Add(paraUserID);
                SqlParameter paraUserAccount = new SqlParameter("@UserAccount", user.UserAccount);
                paras.Add(paraUserAccount);
                SqlParameter paraDisplayName = new SqlParameter("@DisplayName", user.DisplayName);
                paras.Add(paraDisplayName);
                SqlParameter paraFirstName = new SqlParameter("@FirstName", user.FirstName);
                paras.Add(paraFirstName);
                SqlParameter paraLastName = new SqlParameter("@LastName", user.LastName);
                paras.Add(paraLastName);
                SqlParameter paraDistinguishedName = new SqlParameter("@DistinguishedName", user.DistinguishedName);
                paras.Add(paraDistinguishedName);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_ModifyUser]", out ds, out strError))
                    {
                        strError = "ModifyUser异常,Error:" + strError;
                        LoggerHelper.Error("UserDBProvider调用ModifyUser异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("UserDBProvider调用ModifyUser异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("UserDBProvider调用ModifyUser异常", paramstr, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("UserDBProvider调用ModifyUser异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #13
0
        public bool GetMailDataBaseInfo(Guid transactionid, AdminInfo admin, ref MailDataBaseInfo maildb, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"ID:{maildb.ID}";
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras      = new CParameters();
                SqlParameter paraUserID = new SqlParameter("@UserID", admin.UserID);
                paras.Add(paraUserID);
                SqlParameter paraID = new SqlParameter("@ID", maildb.ID);
                paras.Add(paraID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_GetMailDataBaseInfo]", out ds, out strError))
                    {
                        strError = "GetMailDataBaseInfo异常,Error:" + strError;
                        LoggerHelper.Error("MailDataBaseDBProvider调用GetMailDataBaseInfo异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                if (ds.Tables.Count > 1)
                                {
                                    DataRow sdr = ds.Tables[1].Rows[0];
                                    maildb.MailboxDBID         = Guid.Parse(Convert.ToString(sdr["MailboxDBID"]));
                                    maildb.MailboxDB           = Convert.ToString(sdr["MailboxDB"]);
                                    maildb.MailboxServer       = Convert.ToString(sdr["MailboxServer"]);
                                    maildb.OuID                = Guid.Parse(Convert.ToString(sdr["OuID"]));
                                    maildb.OuName              = Convert.ToString(sdr["OuName"]);
                                    maildb.OUdistinguishedName = Convert.ToString(sdr["OUdistinguishedName"]);
                                    maildb.Status              = (State)Convert.ToInt32(sdr["Status"]);
                                    maildb.CreateTime          = Convert.ToDateTime(sdr["CreateTime"]);
                                    maildb.ID = Guid.Parse(Convert.ToString(sdr["ID"]));
                                }
                                break;

                            case -1:
                                bResult    = false;
                                error.Code = ErrorCode.IdEmpty;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("MailDataBaseDBProvider调用GetMailDataBaseInfo异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("MailDataBaseDBProvider调用GetMailDataBaseInfo异常", paramstr, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("MailDataBaseDBProvider调用GetMailDataBaseInfo异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #14
0
        public bool GetMailDataBaseList(Guid transactionid, AdminInfo admin, int curpage, int pagesize, string searchstr, out BaseListInfo lists, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            lists = new BaseListInfo();
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras      = new CParameters();
                SqlParameter paraUserID = new SqlParameter("@UserID", admin.UserID);
                paras.Add(paraUserID);
                SqlParameter paraPageIndex = new SqlParameter("@PageIndex", curpage);
                paras.Add(paraPageIndex);
                SqlParameter paraPageSize = new SqlParameter("@PageSize", pagesize);
                paras.Add(paraPageSize);
                SqlParameter paraSearchstr = new SqlParameter("@Searchstr", $"%{searchstr}%");
                paras.Add(paraSearchstr);
                SqlParameter paraRecordCount = new SqlParameter("@RecordCount", SqlDbType.Int);
                paraRecordCount.Direction = ParameterDirection.Output;
                paras.Add(paraRecordCount);
                SqlParameter paraPageCount = new SqlParameter("@PageCount", SqlDbType.Int);
                paraPageCount.Direction = ParameterDirection.Output;
                paras.Add(paraPageCount);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_GetMailDataBaseList]", out ds, out strError))
                    {
                        strError   = "prc_GetMailDataBaseList数据库执行失败,Error:" + strError;
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }

                    lists.RecordCount = (int)paraRecordCount.Value;
                    lists.PageCount   = (int)paraPageCount.Value;

                    if (ds != null && ds.Tables.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            DataRow          sdr  = ds.Tables[0].Rows[i];
                            MailDataBaseInfo info = new MailDataBaseInfo();
                            info.ID     = Guid.Parse(Convert.ToString(sdr["ID"]));
                            info.OuID   = Guid.Parse(Convert.ToString(sdr["OuID"]));
                            info.OuName = Convert.ToString(sdr["OuName"]);
                            info.OUdistinguishedName = Convert.ToString(sdr["OUdistinguishedName"]);
                            info.MailboxDBID         = Guid.Parse(Convert.ToString(sdr["MailboxDBID"]));
                            info.MailboxDB           = Convert.ToString(sdr["MailboxDB"]);
                            info.MailboxServer       = Convert.ToString(sdr["MailboxServer"]);
                            info.CreateTime          = Convert.ToDateTime(sdr["CreateTime"]);
                            lists.Lists.Add(info);
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("数据库执行prc_GetMailDataBaseList失败", string.Empty, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("MailDataBaseDBProvider调用prc_GetMailDataBaseList异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #15
0
        public bool AddMailAudit(Guid transactionid, AdminInfo admin, ref MailAuditInfo mailAuditInfo, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"AdminID:{admin.UserID}";
            paramstr += $"||AdminAccount:{admin.UserAccount}";
            paramstr += $"||GroupID:{mailAuditInfo.Group.GroupID}";

            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras       = new CParameters();
                SqlParameter paraGroupID = new SqlParameter("@GroupID", mailAuditInfo.Group.GroupID);
                paras.Add(paraGroupID);
                SqlParameter paraGroupName = new SqlParameter("@GroupName", mailAuditInfo.Group.DisplayName);
                paras.Add(paraGroupName);
                SqlParameter paraGroupAccount = new SqlParameter("@GroupAccount", mailAuditInfo.Group.Account);
                paras.Add(paraGroupAccount);
                SqlParameter paraRoleID = new SqlParameter("@RoleID", admin.RoleID);
                paras.Add(paraRoleID);
                SqlParameter paraUserID = new SqlParameter("@CreateUserID", admin.UserID);
                paras.Add(paraUserID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_AddMailAudit]", out ds, out strError))
                    {
                        strError = "AddMailAudit异常,Error:" + strError;
                        LoggerHelper.Error("MailAuditDBProvider调用AddMailAudit异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                if (ds.Tables.Count > 1)
                                {
                                    DataRow sdr = ds.Tables[1].Rows[0];
                                    mailAuditInfo.ID = Guid.Parse(Convert.ToString(sdr["ID"]));
                                }
                                break;

                            case -1:
                                bResult    = false;
                                error.Code = ErrorCode.HaveSameGroup;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("MailAuditDBProvider调用AddMailAudit异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("MailAuditDBProvider调用AddMailAudit异常", paramstr, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("MailAuditDBProvider调用AddMailAudit异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #16
0
        public bool GetMailAuditList(Guid transactionid, AdminInfo admin, int curpage, int pagesize, string searchstr, out BaseListInfo lists, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            lists = new BaseListInfo();
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras       = new CParameters();
                SqlParameter paraAdminID = new SqlParameter("@AdminID", admin.UserID);
                paras.Add(paraAdminID);
                SqlParameter paraPageIndex = new SqlParameter("@PageIndex", curpage);
                paras.Add(paraPageIndex);
                SqlParameter paraPageSize = new SqlParameter("@PageSize", pagesize);
                paras.Add(paraPageSize);
                SqlParameter paraSearchstr = new SqlParameter("@Searchstr", $"%{searchstr}%");
                paras.Add(paraSearchstr);
                SqlParameter paraRecordCount = new SqlParameter("@RecordCount", SqlDbType.Int);
                paraRecordCount.Direction = ParameterDirection.Output;
                paras.Add(paraRecordCount);
                SqlParameter paraPageCount = new SqlParameter("@PageCount", SqlDbType.Int);
                paraPageCount.Direction = ParameterDirection.Output;
                paras.Add(paraPageCount);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_GetMailAuditList]", out ds, out strError))
                    {
                        strError   = "prc_GetMailAuditList数据库执行失败,Error:" + strError;
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }

                    lists.RecordCount = (int)paraRecordCount.Value;
                    lists.PageCount   = (int)paraPageCount.Value;

                    if (ds != null && ds.Tables.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            DataRow       sdr  = ds.Tables[0].Rows[i];
                            MailAuditInfo info = new MailAuditInfo();
                            info.ID                = Guid.Parse(Convert.ToString(sdr["ID"]));
                            info.Group.GroupID     = Guid.Parse(Convert.ToString(sdr["GroupID"]));
                            info.Group.DisplayName = Convert.ToString(sdr["GroupName"]);
                            info.Group.Account     = Convert.ToString(sdr["GroupAccount"]);
                            info.CreateTime        = Convert.ToDateTime(sdr["CreateTime"]);
                            info.UpdateTime        = Convert.ToDateTime(sdr["UpdateTime"]);
                            info.CreateUserID      = Guid.Parse(Convert.ToString(sdr["CreateUserID"]));
                            info.RoleID            = Guid.Parse(Convert.ToString(sdr["RoleID"]));

                            DataRow[] drArr = ds.Tables[1].Select("MailAuditID='" + info.ID + "'");

                            foreach (DataRow dr in drArr)
                            {
                                UserInfo user = new UserInfo();
                                user.UserID      = Guid.Parse(Convert.ToString(dr["UserID"]));
                                user.DisplayName = Convert.ToString(dr["DisplayName"]);
                                user.UserAccount = Convert.ToString(dr["Account"]);
                                info.Audits.Add(user);
                                info.AuditUsers += user.DisplayName + "(" + user.UserAccount + "),";
                            }

                            info.AuditUsers = string.IsNullOrEmpty(info.AuditUsers) ? string.Empty : info.AuditUsers.Remove(info.AuditUsers.LastIndexOf(','), 1);
                            lists.Lists.Add(info);
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("数据库执行prc_GetMailAuditList失败", string.Empty, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("MailAuditDBProvider调用prc_GetMailAuditList异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #17
0
        public bool SendFUserMobileCode(Guid transactionid, Guid userid, string mobile, string code, out ErrorCodeInfo error)
        {
            bool bResult = true;

            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"userid:{userid}";
            paramstr += $"||mobile:{mobile}";
            paramstr += $"||code:{code}";
            string strError = string.Empty;

            try
            {
                CParameters  paras      = new CParameters();
                SqlParameter paraUserID = new SqlParameter("@UserID", userid);
                SqlParameter paraMobile = new SqlParameter("@Mobile", mobile);
                SqlParameter paraCode   = new SqlParameter("@Code", code);
                paras.Add(paraUserID);
                paras.Add(paraMobile);
                paras.Add(paraCode);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_SendFUserMobileCode]", out ds, out strError))
                    {
                        strError = "prc_SendFUserMobileCode数据库执行失败,Error:" + strError;
                        LoggerHelper.Error("UserDBProvider调用SendFUserMobileCode异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 0:
                                bResult = true;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("UserDBProvider调用SendFUserMobileCode异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult = false;
                LoggerHelper.Error("UserDBProvider调用SendFUserMobileCode异常", paramstr, ex.ToString(), transactionid);
                error.Code = ErrorCode.Exception;
            }
            return(bResult);
        }
Example #18
0
        public bool DeleteMailAudit(Guid transactionid, AdminInfo admin, MailAuditInfo mailAuditInfo, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"AdminID:{admin.UserID}";
            paramstr += $"||ID:{mailAuditInfo.ID}";
            string strError = string.Empty;
            bool   bResult  = true;

            try
            {
                CParameters  paras       = new CParameters();
                SqlParameter paraAdminID = new SqlParameter("@AdminID", admin.UserID);
                paras.Add(paraAdminID);
                SqlParameter paraID = new SqlParameter("@ID", mailAuditInfo.ID);
                paras.Add(paraID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_DeleteMailAudit]", out ds, out strError))
                    {
                        strError = "DeleteMailAudit异常,Error:" + strError;
                        LoggerHelper.Error("MailAuditDBProvider调用DeleteMailAudit异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                break;

                            case -1:
                                bResult    = false;
                                error.Code = ErrorCode.HaveSameGroup;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("MailAuditDBProvider调用DeleteMailAudit异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("MailAuditDBProvider调用DeleteMailAudit异常", paramstr, "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("MailAuditDBProvider调用DeleteMailAudit异常", string.Empty, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #19
0
        public bool CheckFUserSmsByCodeID(Guid transactionid, Guid codeid, out Guid userid, out ErrorCodeInfo error)
        {
            bool bResult = true;

            error = new ErrorCodeInfo();
            string paramstr = string.Empty;

            paramstr += $"codeid:{codeid}";
            string strError = string.Empty;

            userid = Guid.Empty;
            try
            {
                CParameters  paras      = new CParameters();
                SqlParameter paraCodeID = new SqlParameter("@CodeID", codeid);
                paras.Add(paraCodeID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_CheckFUserSmsByCodeID]", out ds, out strError))
                    {
                        strError = "prc_CheckFUserSmsByCodeID数据库执行失败,Error:" + strError;
                        LoggerHelper.Error("UserDBProvider调用CheckFUserSmsByCodeID异常", paramstr, strError, transactionid);
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 0:
                                bResult = true;
                                break;

                            case -3:
                                bResult    = false;
                                error.Code = ErrorCode.SmsCodeWrong;
                                break;

                            case -4:
                                bResult    = false;
                                error.Code = ErrorCode.SmsCodeExpired;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("UserDBProvider调用CheckFUserSmsByCodeID异常", paramstr, "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                        if (ds.Tables.Count > 1)
                        {
                            for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                            {
                                DataRow sdr = ds.Tables[1].Rows[i];
                                userid = Guid.Parse(Convert.ToString(sdr["UserID"]));
                            }
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult = false;
                LoggerHelper.Error("UserDBProvider调用CheckFUserSmsByCodeID异常", paramstr, ex.ToString(), transactionid);
                error.Code = ErrorCode.Exception;
            }
            return(bResult);
        }
Example #20
0
        public bool AddOperateLog(Guid transactionid, LogInfo log, out ErrorCodeInfo error)
        {
            error = new ErrorCodeInfo();
            string strError = string.Empty;
            bool   bResult  = true;
            string paramstr = string.Empty;

            paramstr += $"AdminID:{log.AdminID}";
            paramstr += $"||AdminAccount:{log.AdminAccount}";
            paramstr += $"||RoleID:{log.RoleID}";
            paramstr += $"||OperateType:{log.OperateType}";
            paramstr += $"||OperateTimeName:{log.OperateTimeName}";
            paramstr += $"||OperateTime:{log.OperateTime}";
            paramstr += $"||OperateResult:{log.OperateResult}";
            paramstr += $"||OperateLog:{log.OperateLog}";

            try
            {
                CParameters  paras       = new CParameters();
                SqlParameter paraAdminID = new SqlParameter("@AdminID", log.AdminID);
                paras.Add(paraAdminID);
                SqlParameter paraAdminAccount = new SqlParameter("@AdminAccount", log.AdminAccount);
                paras.Add(paraAdminAccount);
                SqlParameter paraRoleID = new SqlParameter("@RoleID", log.RoleID);
                paras.Add(paraRoleID);
                SqlParameter paraOperateType = new SqlParameter("@OperateType", log.OperateType);
                paras.Add(paraOperateType);
                SqlParameter paraOperateLog = new SqlParameter("@OperateLog", log.OperateLog);
                paras.Add(paraOperateLog);
                SqlParameter paraOperateResult = new SqlParameter("@OperateResult", log.OperateResult);
                paras.Add(paraOperateResult);
                SqlParameter paraClientIP = new SqlParameter("@ClientIP", log.ClientIP);
                paras.Add(paraClientIP);


                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    DataSet ds = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_AddOperateLog]", out ds, out strError))
                    {
                        strError   = "prc_AddOperateLog数据库执行失败,Error:" + strError;
                        bResult    = false;
                        error.Code = ErrorCode.SQLException;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int iResult = 0;
                            iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 1:
                                bResult = true;
                                break;

                            case -1:
                                bResult    = false;
                                error.Code = ErrorCode.HaveSameOu;
                                break;

                            case -9999:
                                bResult    = false;
                                error.Code = ErrorCode.SQLException;
                                LoggerHelper.Error("LogDBProvider调用AddOperateLog异常", "", "-9999", transactionid);
                                break;

                            default:
                                bResult    = false;
                                error.Code = ErrorCode.Exception;
                                break;
                            }
                        }
                        else
                        {
                            bResult    = false;
                            error.Code = ErrorCode.Exception;
                            break;
                        }
                    }
                    else
                    {
                        bResult    = false;
                        error.Code = ErrorCode.Exception;
                        LoggerHelper.Error("LogDBProvider调用AddOperateLog异常", "", "ds = null 或者 ds.Tables.Count <= 0", transactionid);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult    = false;
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("LogDBProvider调用AddOperateLog异常", paramstr, ex.ToString(), transactionid);
            }
            return(bResult);
        }
Example #21
0
        public static bool AddErrorLog(
            String OperationType,
            String ParamInfo,
            String ErrorInfo,
            Guid TransactionID
            )
        {
            bool   bResult  = true;
            string strError = string.Empty;

            try
            {
                CParameters  paras             = new CParameters();
                SqlParameter paraOperationType = new SqlParameter("@OperationType", OperationType);
                SqlParameter paraParamInfo     = new SqlParameter("@ParamInfo", ParamInfo);
                SqlParameter paraErrorInfo     = new SqlParameter("@ErrorInfo", ErrorInfo);
                SqlParameter paraTransactionID = new SqlParameter("@TransactionID", TransactionID);


                paras.Add(paraOperationType);
                paras.Add(paraParamInfo);
                paras.Add(paraErrorInfo);
                paras.Add(paraTransactionID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    int     iResult = 0;
                    DataSet ds      = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_AddErrorLog]", out iResult, out strError))
                    {
                        strError = "prc_AddErrorLog数据库执行失败,Error:" + strError;
                        bResult  = false;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            //iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                            switch (iResult)
                            {
                            case 0:
                                bResult = true;
                                break;

                            case -9999:
                                bResult = false;
                                break;

                            default:
                                bResult = false;
                                break;
                            }
                        }
                        else
                        {
                            bResult = false;
                            break;
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                bResult = false;
            }
            return(bResult);
        }