Пример #1
0
        public bool CancelUpload(
            Guid transactionid,
            Guid userid,
            BigFileItemInfo info,
            out string strJsonResult)
        {
            bool result = true;

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

            paramstr += $"userid:{userid}";
            paramstr += $"||TempID:{info.TempID}";
            string funname = "CancelUpload";

            try
            {
                do
                {
                    AttachResultInfo    resultinfo = new AttachResultInfo();
                    BigAttachDBProvider Provider   = new BigAttachDBProvider();
                    result = Provider.CancelUpload(transactionid, userid, ref info, out error);
                    if (result == true)
                    {
                        //delete temp file
                        if (info.FilePath != string.Empty)
                        {
                            FileInfo fi = new FileInfo(info.FilePath);
                            if (fi.Exists)
                            {
                                fi.Delete();
                            }
                        }
                        // to do
                        resultinfo.data = true;
                        strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                        LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid);
                        result = true;
                        break;
                    }
                    else
                    {
                        resultinfo.data = false;
                        strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                        LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid);
                        result = false;
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid);
                LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Пример #2
0
        public bool CheckManagerOuRole(Guid transactionid, string oudistinguishedName, List <SameLevelOuInfo> sameLevelOus, out ErrorCodeInfo error)
        {
            bool bResult = false;

            error = new ErrorCodeInfo();

            try
            {
                foreach (SameLevelOuInfo SameLevelOu in sameLevelOus)
                {
                    if (oudistinguishedName.Contains(SameLevelOu.SamelevelOuPath))
                    {
                        bResult = true;
                        break;
                    }
                }
                if (!bResult)
                {
                    error.Code = ErrorCode.UserNotEnoughRole;
                    bResult    = false;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error("CheckManagerOuRole", string.Empty, ex.ToString(), transactionid);
                error.Code = ErrorCode.Exception;
                bResult    = false;
            }

            return(bResult);
        }
Пример #3
0
        private string Operate(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();

            do
            {
                string strOp = context.Request["op"];
                //判断json参数是否为空
                if (string.IsNullOrEmpty(strOp))
                {
                    error.Code    = ErrorCode.JsonRequestEmpty;
                    strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                    break;
                }
                switch (strOp)
                {
                case "GetLogList":
                    context.Response.ContentType = "text/plain";
                    strJsonResult = GetLogList(context);
                    context.Response.Write(strJsonResult);
                    break;

                case "ExportLogListToExcel":
                    strJsonResult = ExportLogListToExcel(context);
                    break;

                default:
                    context.Response.Write(strJsonResult);
                    break;
                }
            }while (false);
            return(strJsonResult);
        }
        /// <summary>
        /// Creates failed CreationResult using error code and custom error message.
        /// </summary>
        /// <param name="errorCodeInfo">Error code info.</param>
        /// <param name="message">Custom Error message.</param>
        /// <typeparam name="TResult">Type of the entry.</typeparam>
        /// <returns>Failed result.</returns>
        public static CreationResult <TResult> Failed <TResult>(ErrorCodeInfo errorCodeInfo, string message)
            where TResult : class
        {
            var executionError = new ExecutionError(errorCodeInfo, null, message);

            return(new CreationResult <TResult>(executionError));
        }
Пример #5
0
        private string getGroupsByParentDn(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "getGroupsByParentDn";

            try
            {
                do
                {
                    string DistinguishedName = context.Request["DistinguishedName"];
                    string IsOrganizational  = context.Request["IsOrganizational"];

                    GroupManager manager = new GroupManager(ClientIP);
                    manager.getGroupsByParentDn(transactionid, DistinguishedName, IsOrganizational, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("HabBook.ashx调用接口getGroupsByParentDn异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #6
0
        private string GetShareFiles(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "GetShareFiles";

            try
            {
                do
                {
                    string           urlcode = context.Request["code"];
                    string           valcode = context.Request["valcode"];
                    DownResult       arinfo  = new DownResult();
                    BigAttachManager dll     = new BigAttachManager(ClientIP);
                    dll.GetShareFiles(transactionid, urlcode, valcode, ref arinfo, out strJsonResult);
                    if (arinfo.error == "Unauthorized")
                    {
                        context.Response.StatusCode = 401;
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #7
0
        public bool GetAppAccessToken(Guid transactionid, string appid, string secret, out string strJsonResult)
        {
            bool result = true;

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

            paramstr += "appid:" + appid;
            paramstr += "||secret:" + secret;
            string funname = "GetAppAccessToken";

            try
            {
                do
                {
                    AdminInfo      info     = new AdminInfo();
                    RoleDBProvider Provider = new RoleDBProvider();
                    if (!Provider.GetAppInfo(transactionid, appid, secret, ref info, out error))
                    {
                        strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                        LoggerHelper.Info(appid, funname, paramstr, Convert.ToString(error.Code), false, transactionid);
                        result = false;
                        break;
                    }

                    info.Token = TokenManager.GenToken(appid, secret);
                    Dictionary <string, object> dictionary = new Dictionary <string, object>();
                    dictionary.Add("accesstoken", info.Token);
                    dictionary.Add("expiresin", 7200);
                    string json = JsonConvert.SerializeObject(dictionary);
                    LoggerHelper.Info(appid, funname, paramstr, Convert.ToString(error.Code), true, transactionid);
                    strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info, json);

                    #region 操作日志
                    LogInfo operateLog = new LogInfo();
                    operateLog.AdminID       = info.UserID;
                    operateLog.AdminAccount  = "Interface";
                    operateLog.RoleID        = info.RoleID;
                    operateLog.ClientIP      = _clientip;
                    operateLog.OperateResult = true;
                    operateLog.OperateType   = "Inertface 获取 AccessToken";
                    operateLog.OperateLog    = "Inertface于" + DateTime.Now + "获取 AccessToken";

                    LogManager.AddOperateLog(transactionid, operateLog);
                    #endregion

                    result = true;
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Info(appid, funname, paramstr, Convert.ToString(error.Code), false, transactionid);
                LoggerHelper.Error("RoleManager调用GetAppAccessToken异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Пример #8
0
        private string validateToken(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "validateToken";

            try
            {
                do
                {
                    userAccount = context.Request["emailAddress"];

                    UserManager manager = new UserManager(ClientIP);
                    manager.validateToken(transactionid, userAccount, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("HabBook.ashx调用接口validateToken异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExecutionError"/> class.
 /// </summary>
 /// <param name="errorCodeInfo">Error Code Info.</param>
 /// <param name="source">Source.</param>
 /// <param name="customMessage">Custom message.</param>
 public ExecutionError(ErrorCodeInfo errorCodeInfo, string source, string customMessage)
 {
     CodeInfo = errorCodeInfo;
     Source   = source;
     Code     = errorCodeInfo.Code;
     Message  = customMessage;
 }
Пример #10
0
        private string searchADObject(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "searchADObject";

            try
            {
                do
                {
                    string searchkey = context.Request["key"];
                    string dn        = context.Request["dn"];
                    int    pagesize  = Convert.ToInt32(context.Request["pagesize"]);
                    int    pageindex = Convert.ToInt32(context.Request["pageindex"]);

                    UserManager manager = new UserManager(ClientIP);
                    manager.searchADObject(transactionid, searchkey, dn, pagesize, pageindex, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("HabBook.ashx调用接口searchADObject异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #11
0
        public bool test(Guid transactionid, string cmd, out string strJsonResult)
        {
            bool result = true;

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

            try
            {
                do
                {
                    //if (!ExchangeProvider.TestCommand(cmd, out message))
                    //{
                    //    strJsonResult = JsonHelper.ReturnJson(false, -9999, message);
                    //    result = false;
                    //    break;
                    //}

                    strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info);
                    result        = true;
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code    = ErrorCode.Exception;
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Пример #12
0
        private string GetShareSettings(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "GetShareSettings";

            try
            {
                do
                {
                    Guid userid = this.CheckCookie(context);
                    if (userid == Guid.Empty)
                    {
                        //error?
                        break;
                    }
                    BigAttachManager dll = new BigAttachManager(ClientIP);
                    dll.GetShareSettings(transactionid, userid, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("Setting.ashx调用接口GetShareSettings异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #13
0
        private string DownloadFileById(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "DownloadFileById";

            try
            {
                do
                {
                    string           urlcode = context.Request["code"];
                    string           fileid  = context.Request["fileid"];
                    Guid             id      = Guid.Parse(fileid);
                    BigFileItemInfo  info    = new BigFileItemInfo();
                    BigAttachManager dll     = new BigAttachManager(ClientIP);
                    bool             result  = dll.DownloadFileById(transactionid, urlcode, id, ref info, out strJsonResult);
                    if (result && info.FilePath != string.Empty)
                    {
                        downfile2(context, info.FilePath, info.FileName);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #14
0
        private string Search(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "Search";

            try
            {
                do
                {
                    int    top     = Convert.ToInt32(context.Request["Top"]);
                    string keyword = context.Request["keyword"];

                    Guid userid = this.CheckCookie(context);
                    if (userid == Guid.Empty)
                    {
                        //error?
                        break;
                    }
                    BigAttachManager dll = new BigAttachManager(ClientIP);
                    dll.Search(transactionid, userid, keyword, top, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #15
0
        private string Test(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "Test";

            try
            {
                do
                {
                    //string strCommand = "set-Mailbox -Identity \"CN=cs6121,OU=B集团控股,OU=佳兆业集团,DC=bnc2,DC=cn\" -ExtensionCustomAttribute3 \"11111\"";
                    string strCommand = $"Search-Mailbox -Identity \"CN=cs6121,OU=B集团控股,OU=佳兆业集团,DC=bnc2,DC=cn\" " +
                                        $"-SearchQuery 'subject:\"test111\"  AND sent>=\"2019-07-04 00:00:01\" AND sent<=\"2019-07-06 00:00:01\"'  -DeleteContent -Force";
                    Log4netHelper.Info(strCommand);
                    SensitiveMailManager manager = new SensitiveMailManager(ClientIP);
                    manager.test(transactionid, strCommand, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("SensitiveMail.ashx调用接口test异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #16
0
        private string Operate(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();

            do
            {
                string strOp = context.Request["op"];
                //判断json参数是否为空
                if (string.IsNullOrEmpty(strOp))
                {
                    error.Code    = ErrorCode.JsonRequestEmpty;
                    strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                    break;
                }
                switch (strOp)
                {
                case "GetStaticGroupList":
                    strJsonResult = GetStaticGroupList(context);
                    break;

                case "GetStaticGroupInfo":
                    strJsonResult = GetStaticGroupInfo(context);
                    break;

                case "ChangeStaticGroupInfo":
                    strJsonResult = ChangeStaticGroupInfo(context);
                    break;

                default:
                    break;
                }
            }while (false);
            return(strJsonResult);
        }
Пример #17
0
        private string GetServerTime(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "GetServerTime";

            try
            {
                do
                {
                    AttachResultInfo ar = new AttachResultInfo();
                    ar.data       = DateTime.Now.ToString("yyyy-MM-dd");
                    strJsonResult = JsonHelper.Obj2Json <AttachResultInfo>(ar);// JsonConvert.SerializeObject(ar);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("Setting.ashx调用接口AutoLogin异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #18
0
        /// <summary>
        /// Creates failed CreationResult using default error code.
        /// </summary>
        /// <param name="errorCodeInfo">Error code info.</param>
        /// <typeparam name="TResult">Type of the entry.</typeparam>
        /// <returns>Failed result.</returns>
        public static CreationResult <TResult> Failed <TResult>(ErrorCodeInfo errorCodeInfo)
            where TResult : class
        {
            var executionError = new ExecutionError(errorCodeInfo);

            return(new CreationResult <TResult>(executionError));
        }
Пример #19
0
        private string CheckVerificationCode(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "CheckVerificationCode";

            try
            {
                do
                {
                    string urlcode = context.Request["code"];
                    string valcode = context.Request["VerificationCode"];

                    BigAttachManager dll = new BigAttachManager(ClientIP);
                    dll.CheckVerificationCode(transactionid, urlcode, valcode, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #20
0
        private string Operate(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();

            do
            {
                string strOp = context.Request["op"];
                //判断json参数是否为空
                if (string.IsNullOrEmpty(strOp))
                {
                    error.Code    = ErrorCode.JsonRequestEmpty;
                    strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                    break;
                }
                switch (strOp)
                {
                case "validateToken":
                    strJsonResult = validateToken(context);
                    break;

                case "getGroupsByParentDn":
                    strJsonResult = getGroupsByParentDn(context);
                    break;

                case "searchADObject":
                    strJsonResult = searchADObject(context);
                    break;

                default:
                    break;
                }
            }while (false);
            return(strJsonResult);
        }
Пример #21
0
        private static ExecutionError CreateExecutionError(ValidationAttribute attribute, ValidationResult validationResult)
        {
            var errorCode     = AnnotationErrorCodes.GetErrorCodeFromAttribute(attribute.GetType());
            var errorCodeInfo = new ErrorCodeInfo(errorCode, validationResult.ErrorMessage);
            var source        = validationResult.MemberNames.FirstOrDefault();

            return(new ExecutionError(errorCodeInfo, source, validationResult.ErrorMessage));
        }
        public void Failed_WithErrorCode_ReturnsResultWithSameErrorCode()
        {
            var errorCode     = new ErrorCodeInfo(nameof(Core), FixtureUtils.String(), FixtureUtils.String());
            var expectedError = new ExecutionError(errorCode);

            CreationResult.Failed <DummyEntry>(errorCode)
            .Should().BeEquivalentTo(new CreationResult <DummyEntry>(expectedError));
        }
Пример #23
0
        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);
        }
Пример #24
0
        public bool GetFileList(
            Guid transactionid,
            Guid userid,
            int curpage,
            int pagesize,
            //string orderbyField,
            //string orderbyType,
            out string strJsonResult)
        {
            bool result = true;

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

            paramstr += $"userid:{userid}";
            paramstr += $"||curpage:{curpage}";
            paramstr += $"||pagesize:{pagesize}";
            //paramstr += $"||orderbyField:{orderbyField}";
            //paramstr += $"||orderbyType:{orderbyType}";
            string funname = "GetFileList";

            try
            {
                do
                {
                    AttachResultInfo resultinfo = new AttachResultInfo();
                    BigFileListInfo  bfli       = new BigFileListInfo();


                    BigAttachDBProvider Provider = new BigAttachDBProvider();
                    result = Provider.GetFileList(transactionid, userid, curpage, pagesize, out bfli, out error);
                    if (result == true)
                    {
                        resultinfo.data = bfli;
                        strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                        LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid);
                        result = true;
                        break;
                    }
                    else
                    {
                        LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid);
                        result = false;
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid);
                LoggerHelper.Error("BigAttachManager调用GetFileList异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Пример #25
0
        public bool WorkerOperation(UserSensitiveMailQueueInfo info)
        {
            ErrorCodeInfo error         = new ErrorCodeInfo();
            string        message       = string.Empty;
            string        resultmessage = string.Empty;
            Guid          transactionid = Guid.NewGuid();
            string        paramstr      = string.Empty;

            paramstr += $"SensitiveID:{info.ID}";
            paramstr += $"||Keywords:{info.Keywords}";
            paramstr += $"||StartTime:{info.StartTime}";
            paramstr += $"||EndTime:{info.EndTime}";
            paramstr += $"||UserID:{info.UserID}";
            bool bResult = true;

            try
            {
                do
                {
                    Log4netHelper.Info($"RemoveSensitiveMail Begin: {paramstr}");
                    CommonProvider          commonProvider = new CommonProvider();
                    DirectoryEntry          userEntry      = new DirectoryEntry();
                    SensitiveMailDBProvider provider       = new SensitiveMailDBProvider();
                    if (!commonProvider.GetADEntryByGuid(info.UserID, out userEntry, out message))
                    {
                        Log4netHelper.Error($"RemoveSensitiveMail GetADEntryByGuid ID:{info.UserID}, Error:{message}");
                        info.Status   = SensitiveMailStatus.Failed;
                        resultmessage = "用户不存在。";
                        provider.UpdateUserSensitiveMailQueue(transactionid, info, resultmessage, out error);
                        bResult = false;
                        break;
                    }
                    string userMail = userEntry.Properties["mail"].Value == null ? "" : Convert.ToString(userEntry.Properties["mail"].Value);
                    ADManagerWebService.ManagerWebService webService = new ADManagerWebService.ManagerWebService();
                    webService.Timeout = -1;
                    if (!webService.RemoveSensitiveMail(transactionid, userMail, info.Keywords, info.StartTime, info.EndTime, out resultmessage, out message))
                    {
                        info.Status = SensitiveMailStatus.Failed;
                        provider.UpdateUserSensitiveMailQueue(transactionid, info, resultmessage, out error);
                        Log4netHelper.Error($"RemoveSensitiveMail ID:{info.ID}, Error:{message}");
                        bResult = false;
                        break;
                    }
                    //记录执行日志
                    info.Status = SensitiveMailStatus.Success;
                    provider.UpdateUserSensitiveMailQueue(transactionid, info, resultmessage, out error);
                    Log4netHelper.Info($"RemoveSensitiveMail End: {paramstr}");
                } while (false);
            }
            catch (Exception ex)
            {
                Log4netHelper.Error("RemoveSensitiveMail异常", paramstr, ex.ToString(), transactionid);
                bResult = false;
            }
            return(bResult);
        }
        internal override IFFFile Get()
        {
            var item = new ErrorCodeInfo();

            item.Header.Active        = Reader().ReadUInt32();
            item.Header.ID            = Reader().ReadUInt32();
            item.Un1                  = Reader().ReadUInt32();
            item.ErrorTextDescription = GetString(260);
            return(item);
        }
Пример #27
0
        private string Operate(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();

            do
            {
                string strOp = context.Request["op"];
                //判断json参数是否为空
                if (string.IsNullOrEmpty(strOp))
                {
                    error.Code    = ErrorCode.JsonRequestEmpty;
                    strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                    break;
                }
                switch (strOp)
                {
                case "GetUserRole":
                    //strJsonResult = GetUserRole(context);
                    break;

                case "AddRole":
                    strJsonResult = AddRole(context);
                    break;

                case "DeleteRole":
                    strJsonResult = DeleteRole(context);
                    break;

                case "ChangeRole":
                    strJsonResult = ChangeRole(context);
                    break;

                case "GetRoleList":
                    strJsonResult = GetRoleList(context);
                    break;

                case "GetRoleInfo":
                    strJsonResult = GetRoleInfo(context);
                    break;

                case "GetRoleModuleList":
                    strJsonResult = GetRoleModuleList(context);
                    break;

                case "GetSameLevelOuList":
                    strJsonResult = GetSameLevelOuList(context);
                    break;

                default:
                    break;
                }
            }while (false);
            return(strJsonResult);
        }
Пример #28
0
        private string ChangeStaticGroupInfo(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "ChangeStaticGroupInfo";

            try
            {
                do
                {
                    string strAccesstoken = context.Request["accessToken"];
                    //判断AccessToken
                    if (string.IsNullOrEmpty(strAccesstoken))
                    {
                        error.Code    = ErrorCode.TokenEmpty;
                        strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                        LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                        break;
                    }

                    AdminInfo admin = new AdminInfo();
                    if (!TokenManager.ValidateUserToken(transactionid, strAccesstoken, out admin, out error))
                    {
                        strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                        LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                        break;
                    }

                    Stream str = context.Request.InputStream;
                    // Find number of bytes in stream.
                    Int32 strLen = Convert.ToInt32(str.Length);
                    // Create a byte array.
                    byte[] strArr = new byte[strLen];
                    // Read stream into byte array.
                    str.Read(strArr, 0, strLen);
                    string body = System.Text.Encoding.UTF8.GetString(strArr);

                    GroupInfo info = JsonConvert.DeserializeObject <GroupInfo>(body);

                    StaticGroupManager manager = new StaticGroupManager(ClientIP);
                    manager.ChangeStaticGroupInfo(transactionid, admin, info, out strJsonResult);
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("StaticGroup.ashx调用接口ChangeStaticGroupInfo异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }
Пример #29
0
        public void ErrorCodeInfoObjectTest()
        {
            ErrorCodeInfo sample = new ErrorCodeInfo();

            sample.errorCode = 1;
            sample.timestamp = "time";


            Assert.AreEqual("time", sample.timestamp);
            Assert.AreEqual(1, sample.errorCode);
        }
Пример #30
0
        public bool SendMeeting(Guid transactionid, MeetingInfo meeting, out ErrorCodeInfo error)
        {
            bool result = true;

            error = new ErrorCodeInfo();

            string paramstr = string.Empty;

            paramstr  = $"Sender:{meeting.Sender}";
            paramstr += $"||Subject:{meeting.Subject}";
            paramstr += $"||Body:{meeting.Body}";
            paramstr += $"||Start:{meeting.Start}";
            paramstr += $"||End:{meeting.End}";
            paramstr += $"||Attendees:";
            foreach (string Attendee in meeting.Attendees)
            {
                paramstr += Attendee + ",";
            }
            string funname = "SendMeeting";

            try
            {
                do
                {
                    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
                    service.Credentials        = new WebCredentials(ConfigHelper.ConfigInstance["AD_Admin"], ConfigHelper.ConfigInstance["AD_Password"]);
                    service.Url                = new Uri(ConfigHelper.ConfigInstance["EWS_Uri"]);
                    service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, meeting.Sender);

                    Appointment appointment = new Appointment(service);
                    // Set the properties on the meeting object to create the meeting.
                    appointment.Subject  = meeting.Subject;
                    appointment.Body     = meeting.Body;
                    appointment.Start    = meeting.Start;
                    appointment.End      = meeting.End;
                    appointment.Location = meeting.Location;
                    foreach (string Attendee in meeting.Attendees)
                    {
                        appointment.RequiredAttendees.Add(Attendee);
                    }
                    appointment.ReminderMinutesBeforeStart = 15;
                    appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
                    // Verify that the meeting was created.
                    Item item = Item.Bind(service, appointment.Id, new PropertySet(ItemSchema.Subject));
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("SendMeeting异常", paramstr, ex.ToString(), transactionid);
                result = false;
            }
            return(result);
        }