Example #1
0
        public object Insert([FromBody] CommonSetting data)
        {
            var msg = new JMessage()
            {
                Error = false
            };

            try
            {
                var checkExist = _context.CommonSettings.FirstOrDefault(x => x.CodeSet.ToLower() == data.CodeSet.ToLower());
                if (checkExist != null)
                {
                    msg.Error = true;
                    msg.Title = "Mã cài đặt đã tồn tại!";
                }
                else
                {
                    data.CreatedBy   = ESEIM.AppContext.UserName;
                    data.CreatedTime = DateTime.Now;
                    _context.CommonSettings.Add(data);
                    _context.SaveChanges();
                    msg.Title = "Thêm mới cài đặt thành công";
                }
            }
            catch (Exception ex)
            {
                msg.Error = true;
                msg.Title = "Có lỗi xảy ra khi thêm!";
            }
            return(Json(msg));
        }
Example #2
0
        public object Update([FromBody] CommonSetting data)
        {
            var msg = new JMessage()
            {
                Error = false
            };

            try
            {
                data.UpdatedBy   = ESEIM.AppContext.UserName;
                data.UpdatedTime = DateTime.Now;
                _context.CommonSettings.Update(data);
                _context.SaveChanges();

                msg.Title = "Cập nhật thành công";
                return(Json(msg));
            }
            catch (Exception ex)
            {
                msg.Error  = true;
                msg.Title  = "Có lỗi xảy ra khi cập nhật!";
                msg.Object = ex;
                return(Json(msg));
            }
        }
Example #3
0
        static public void PopulateByCommonSetting(ComboBox cbo, string groupID, bool fblank = false)
        {
            var cs = new CommonSetting();

            var dtb = cs.SelectAllByGroupID(groupID);

            cbo.DataSource    = null;
            cbo.ValueMember   = "DetailID";
            cbo.DisplayMember = "DetailDesc";

            if (fblank)
            {
                dtb.Rows.Add("", "");
            }

            dtb.DefaultView.Sort = "DetailID Asc";
            cbo.DataSource       = dtb;

            //if (fblank)
            //cbo.Items.Add(new ComboBoxItem("", ""));

            //foreach (DataRow row in dtb.Rows)
            //{
            //    cbo.Items.Add(new ComboBoxItem(row["DetailID"] + "", row["DetailDesc"] + ""));
            //}
        }
Example #4
0
        static public string SelectOneByCommonSettingByDetailID(string groupID, string DetailID)
        {
            var cs = new CommonSetting();

            cs.GroupID  = groupID.Trim();
            cs.DetailID = DetailID.Trim();
            return(Common.ProcessNull.GetString(cs.SelecOneByGroupIDByDetailID().Rows[0]["DetailDesc"]) + "");
        }
Example #5
0
        private void PopulateItemUnit()
        {
            var itemUnit = new CommonSetting();
            var dtb      = itemUnit.SelectAllByGroupID("StdItemUnit");

            cboItemUnit.DisplayMember = "DetailDesc";
            cboItemUnit.ValueMember   = "DetailID";
            cboItemUnit.DataSource    = dtb;
        }
Example #6
0
 public CommonSettingVM(ICommonSettingStore settingStore, CommonSetting commonSetting, IViewModelService viewModelService)
 {
     _storageRoot        = settingStore.StorageRoot;
     _proxyAddress       = settingStore.ProxyAddress;
     _proxyPort          = settingStore.ProxyPort;
     _dbConnectionString = settingStore.DbConnectionString;
     _commonSetting      = commonSetting;
     _viewModelService   = viewModelService;
 }
 /// <summary>
 /// 存储公共配置
 /// </summary>
 /// <param name="_settingService"></param>
 /// <param name="setting"></param>
 public static void SaveCommonSettings(this ISettingService _settingService, CommonSetting setting)
 {
     _settingService.SaveSetting(CommonSettingNames.Description, setting.Description);
     _settingService.SaveSetting(CommonSettingNames.Title, setting.Title);
     _settingService.SaveSetting(CommonSettingNames.Keywords, setting.Keywords);
     _settingService.SaveSetting(CommonSettingNames.IsClose, setting.IsClose);
     _settingService.SaveSetting(CommonSettingNames.IsOpenRegistration, setting.IsOpenRegistration);
     _settingService.SaveSetting(CommonSettingNames.RegistrationId, setting.RegistrationId);
     _settingService.SaveSetting(CommonSettingNames.Name, setting.Name);
     _settingService.SaveSetting(CommonSettingNames.Subtitle, setting.Subtitle);
 }
Example #8
0
        private void PopulateGrid()
        {
            grdChooseTransactionStatus.SuspendLayout();
            grdChooseTransactionStatus.AutoGenerateColumns = false;

            var cs = new CommonSetting();
            var dv = new DataView(cs.SelectAllByGroupID("STxnStatus"));

            dv.RowFilter = "DetailID in ('S','V')";
            grdChooseTransactionStatus.DataSource = dv;
            grdChooseTransactionStatus.ResumeLayout();
        }
Example #9
0
    /** 初始化 */
    public static void init()
    {
        ShineGlobal.init();
        CommonSetting.init();

        if (ShineSetting.isRelease)
        {
            initRelease();
        }
        else
        {
            initDebug();
        }
    }
        /// <summary>
        /// 获取公共配置
        /// </summary>
        /// <param name="_settingService"></param>
        /// <returns></returns>
        public static CommonSetting GetCommonSettings(this ISettingService _settingService)
        {
            var config = new CommonSetting
            {
                Description        = _settingService.GetSettingByKey <string>(CommonSettingNames.Description),
                Title              = _settingService.GetSettingByKey <string>(CommonSettingNames.Title),
                Keywords           = _settingService.GetSettingByKey <string>(CommonSettingNames.Keywords),
                IsClose            = _settingService.GetSettingByKey <bool>(CommonSettingNames.IsClose),
                IsOpenRegistration = _settingService.GetSettingByKey <bool>(CommonSettingNames.IsOpenRegistration),
                RegistrationId     = _settingService.GetSettingByKey <int>(CommonSettingNames.RegistrationId),
                Name     = _settingService.GetSettingByKey <string>(CommonSettingNames.Name),
                Subtitle = _settingService.GetSettingByKey <string>(CommonSettingNames.Subtitle),
            };

            return(config);
        }
Example #11
0
 private void loginHttpNext()
 {
     //分区分服的
     if (CommonSetting.isAreaSplit())
     {
         //登陆的可以停了
         _httpLoginAffair.stop();
         GameC.log.addFlowLog(FlowStepType.BeginSelectServer);
         _stepTool.completeStepAbs(LoginHttp);
     }
     else
     {
         //直接完成loginSelect
         _stepTool.completeStepAbs(LoginSelect);
     }
 }
 public void SendEmail(string email, string Cc, string subject, string message, byte[] bytes)
 {
     try
     {
         using (MailMessage mm = new MailMessage(new MailAddress(ec.UserName), new MailAddress(email)))
         {
             mm.Subject = subject;
             if (!string.IsNullOrEmpty(Cc))
             {
                 mm.CC.Add(Cc);
             }
             mm.Body       = message;
             mm.IsBodyHtml = true;
             using (System.Net.Mail.SmtpClient smtpc = new System.Net.Mail.SmtpClient())
             {
                 CommonSetting settings = SmtpServerData();
                 if (settings != null)
                 {
                     smtpc.Host      = settings.SMTPServer;
                     smtpc.EnableSsl = true;
                     NetworkCredential NetworkCred = new NetworkCredential(settings.Email, settings.Password);
                     smtpc.UseDefaultCredentials = true;
                     smtpc.Credentials           = NetworkCred;
                     smtpc.Port = settings.Port;
                 }
                 else
                 {
                     smtpc.Host      = ec.Host;
                     smtpc.EnableSsl = true;
                     NetworkCredential NetworkCred = new NetworkCredential(ec.UserName, ec.Password);
                     smtpc.UseDefaultCredentials = true;
                     smtpc.Credentials           = NetworkCred;
                     smtpc.Port = ec.Port;
                 }
                 if (bytes != null && bytes.Length > 0)
                 {
                     mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "DigitalReceipt.pdf"));
                 }
                 smtpc.Send(mm);
             }
         }
     }
     catch (Exception ex)
     {
         SendMail("*****@*****.**", "Mail Exception", ex.ToString(), "");
     }
 }
Example #13
0
    public virtual void onLoginHttpSuccess(ClientLoginResultData data)
    {
        _httpLoginSended.unlock();

        //已不在登录中
        if (!isHttpLogining())
        {
            return;
        }

        //分区分服的
        if (CommonSetting.isAreaSplit())
        {
            LocalSetting.setLoginURL(data.loginInfo.host, data.loginInfo.port);

            _loginToken = data.loginInfo.token;
            serverList  = new SList <AreaClientData>(data.areas.size());

            foreach (int k in data.areas.getSortedKeyList())
            {
                serverList.add(data.areas.get(k));
            }

            this.lastAreaID = data.lastAreaID;
        }
        else
        {
            _gameInfo = data.gameInfo;
        }

        //未等待中
        if (!_waitHotfixForHttpLogin.isLocking())
        {
            //比较更新
            if (GameC.mainLogin.clientHotfix(data.version))
            {
                loginHttpNext();
            }
            else
            {
                _waitHotfixForHttpLogin.lockOn();
            }
        }
    }
Example #14
0
        public ActionResult DiscountRuleManager()
        {
            int pageType = Context.GetRequestInt("pageType", 0);

            //根据aid,storeId读取不同模板下的开关配置
            string        errorMsg      = string.Empty;
            CommonSetting commonSetting = CommonSettingBLL.GetCommonSetting(_appId, ref _storeId, ref errorMsg);

            if (!string.IsNullOrWhiteSpace(errorMsg))
            {
                return(Redirect($"/base/PageErrorMsg?code=500&Msg={errorMsg}")); //提示报错页
            }

            ViewBag.aId           = ViewBag.appId = _appId;
            ViewBag.storeId       = _storeId;
            ViewBag.pageType      = pageType;
            ViewBag.maxRulesCount = maxRulesCount;
            return(View(commonSetting));
        }
Example #15
0
        public JsonResult UploadImage(string fileinputname, string savepath, string oldfilename)
        {
            CustomJsonResult r = new CustomJsonResult();

            r.ContentType = "text/html";
            try
            {
                HttpPostedFileBase file_upload = Request.Files[fileinputname];

                if (file_upload == null)
                {
                    return(Json("text/html", ResultType.Failure, "上传失败"));
                }

                System.IO.FileInfo file = new System.IO.FileInfo(file_upload.FileName);
                if (file.Extension != ".jpg" && file.Extension != ".png" && file.Extension != ".gif" && file.Extension != ".bmp")
                {
                    return(Json("text/html", ResultType.Failure, "上传的文件不是图片格式(jpg,png,gif,bmp)"));
                }

                ImageUpload s               = new ImageUpload();
                string      domain          = System.Configuration.ConfigurationManager.AppSettings["custom:Domain"];
                string      imagesServerUrl = CommonSetting.GetUploadPath(savepath);
                if (s.Save(file_upload, domain, imagesServerUrl, ""))
                {
                    r.Content = s;
                }

                r.Result  = ResultType.Success;
                r.Message = "上传成功";
            }
            catch (Exception ex)
            {
                r.Result  = ResultType.Exception;
                r.Message = "上传图片发生异常";
                throw (ex);
            }
            return(r);
        }
Example #16
0
        public HttpResponseMessage Post(UploadFileEntity entity)
        {
            SetTrackID();
            Log.Info("调用UploadImage");
            HttpContextBase  context = (HttpContextBase)Request.Properties["MS_HttpContext"]; //获取传统context
            HttpRequestBase  request = context.Request;                                       //定义传统request对象
            CustomJsonResult r       = new CustomJsonResult();

            try
            {
                if (entity.FileData != null && entity.FileData.Length > 0)
                {
                    ImageUpload image      = new ImageUpload();
                    int[]       bigImgSize = new int[2] {
                        500, 500
                    };
                    int[] smallImgSize = new int[2] {
                        100, 100
                    };
                    string imageSign = "";

                    string savefolder          = CommonSetting.GetUploadPath(entity.UploadFolder);
                    string extension           = Path.GetExtension(entity.FileName).ToLower();
                    string yyyyMMddhhmmssfff   = Guid.NewGuid().ToString();
                    string originalNewfilename = imageSign + yyyyMMddhhmmssfff + "_O" + extension; //原图片文件名称
                    string bigNewfilename      = imageSign + yyyyMMddhhmmssfff + "_B" + extension; //大图片文件名称
                    string smallNewfilename    = imageSign + yyyyMMddhhmmssfff + "_S" + extension; //小图片文件名称

                    string originalSavePath = string.Format("{0}/{1}", savefolder, originalNewfilename);
                    string bigSavePath      = string.Format("{0}/{1}", savefolder, bigNewfilename);
                    string smallSavePath    = string.Format("{0}/{1}", savefolder, smallNewfilename);


                    string path = System.Configuration.ConfigurationManager.AppSettings["custom:FileServerUploadPath"];

                    string serverOriginalSavePath = path + "/" + originalSavePath;
                    string serverBigSavePath      = path + "/" + bigSavePath;
                    string serverSmallSavePath    = path + "/" + smallSavePath;

                    entity.FileName = entity.FileName.ToLower().Replace("\\", "/");

                    ImageUpload s      = new ImageUpload();
                    string      domain = System.Configuration.ConfigurationManager.AppSettings["custom:FilesServerUrl"];



                    DirectoryInfo Drr = new DirectoryInfo(path + "/" + savefolder);
                    if (!Drr.Exists)
                    {
                        Drr.Create();
                    }

                    FileStream fs = new FileStream(serverOriginalSavePath, FileMode.Create, FileAccess.Write);
                    fs.Write(entity.FileData, 0, entity.FileData.Length);
                    fs.Flush();
                    fs.Close();

                    System.Drawing.Image originalImage = System.Drawing.Image.FromFile(serverOriginalSavePath);
                    image.OriginalPath   = domain + originalSavePath;
                    image.OriginalWidth  = originalImage.Width;
                    image.OriginalHeight = originalImage.Height;
                    if (entity.GenerateSize)
                    {
                        if (GreateMiniImageModel(serverOriginalSavePath, serverBigSavePath, bigImgSize[0], bigImgSize[1]))
                        {
                            image.BigPath   = domain + bigSavePath;
                            image.BigWidth  = bigImgSize[0];
                            image.BigHeight = bigImgSize[1];
                        }
                        if (GreateMiniImageModel(serverOriginalSavePath, serverSmallSavePath, smallImgSize[0], smallImgSize[1]))
                        {
                            image.SmallPath   = domain + smallSavePath;
                            image.SmallWidth  = smallImgSize[0];
                            image.SmallHeight = smallImgSize[1];
                        }
                    }

                    originalImage.Dispose();
                    r.Data    = image;
                    r.Message = "上传成功";
                    r.Result  = ResultType.Success;
                }
            }
            catch (Exception ex)
            {
                r.Result  = ResultType.Exception;
                r.Message = "上传失败";
                Log.Error("WebApi上传图片异常", ex);
            }

            string json = r.ToString();
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
Example #17
0
        /// <summary>
        /// 将 CommonSetting 逆推更入数据库
        /// </summary>
        /// <param name="commonSetting"></param>
        /// <param name="aId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static Return_Msg UpdateCommonSetting(CommonSetting commonSetting, int aId, int storeId = 0)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = false;

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(handingResult);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(handingResult);
            }

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                foodConfig.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;
                foodConfig.sortQueueSwitch = commonSetting.sortQueueSwitch;
                foodConfig.sortNo_next     = commonSetting.sortNo_next;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                handingResult.isok = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                switchModel.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                handingResult.isok            = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                handingResult.Msg             = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                store.funJoinModel.sortQueueSwitch = commonSetting.sortQueueSwitch;
                store.funJoinModel.sortNo_next     = commonSetting.sortNo_next;
                store.configJson = JsonConvert.SerializeObject(store.funJoinModel);

                store.UpdateDate   = DateTime.Now;
                handingResult.isok = StoreBLL.SingleModel.Update(store, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(handingResult);
            }
        }
Example #18
0
        /// <summary>
        /// 根据传入aId及storeId去读取店铺资料配置,自动查出默认关联的店铺的配置
        /// </summary>
        /// <param name="aId"></param>
        /// <param name="storeId">店铺ID,可传0,传0默认查出关联的店铺</param>
        /// <param name="errorMsg"></param>
        /// <param name="CommonSetting">公共配置</param>
        /// <returns></returns>
        public static CommonSetting GetCommonSetting(int aId, ref int storeId, ref string errorMsg)
        {
            CommonSetting         setting     = new CommonSetting();
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                errorMsg = "未找到小程序授权资料";
                return(setting);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                errorMsg = "未找到小程序的模板";
                return(setting);
            }
            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                storeId = store_Food.Id;

                setting.discountRuleSwitch             = store_Food.funJoinModel.discountRuleSwitch;
                setting.newUserFirstOrderDiscountMoney = store_Food.funJoinModel.newUserFirstOrderDiscountMoney;
                setting.userFirstOrderDiscountMoney    = store_Food.funJoinModel.userFirstOrderDiscountMoney;
                setting.sortQueueSwitch = store_Food.funJoinModel.sortQueueSwitch;
                setting.sortNo_next     = store_Food.funJoinModel.sortNo_next;
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                storeId = store_MultiStore.Id;

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                setting.discountRuleSwitch             = switchModel.discountRuleSwitch;
                setting.newUserFirstOrderDiscountMoney = switchModel.newUserFirstOrderDiscountMoney;
                setting.userFirstOrderDiscountMoney    = switchModel.userFirstOrderDiscountMoney;
                break;

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                setting.sortQueueSwitch = store.funJoinModel.sortQueueSwitch;
                setting.sortNo_next     = store.funJoinModel.sortNo_next;
                break;

            default:
                errorMsg = "还未开通店铺";
                return(setting);
            }
            return(setting);
        }
Example #19
0
        static public string SelectOneByCommonSetting(string groupID)
        {
            var cs = new CommonSetting();

            return(Common.ProcessNull.GetString(cs.SelectAllByGroupID(groupID).Rows[0]["DetailID"]) + "");
        }
        public HttpResponseMessage Post(UploadFileEntity entity)
        {
            SetTrackID();
            Log.Info("调用UploadFile");
            HttpContextBase  context = (HttpContextBase)Request.Properties["MS_HttpContext"]; //获取传统context
            HttpRequestBase  request = context.Request;                                       //定义传统request对象
            CustomJsonResult r       = new CustomJsonResult();

            try
            {
                if (entity.FileData == null)
                {
                    r = new CustomJsonResult(ResultType.Failure, "文件对象为空");
                }
                else if (entity.FileData.Length == 0)
                {
                    r = new CustomJsonResult(ResultType.Failure, "文件内容为空");
                }
                else if (entity.FileData.Length > (50 * 1024 * 1024))
                {
                    r = new CustomJsonResult(ResultType.Failure, "文件大小不能超过50M");
                }
                else
                {
                    string imageSign = "";

                    string savefolder          = CommonSetting.GetUploadPath(entity.UploadFolder);
                    string extension           = Path.GetExtension(entity.FileName).ToLower();
                    string yyyyMMddhhmmssfff   = Guid.NewGuid().ToString();
                    string originalNewfilename = imageSign + yyyyMMddhhmmssfff + extension;//原图片文件名称

                    string originalSavePath = string.Format("{0}/{1}", savefolder, originalNewfilename);

                    string path = System.Configuration.ConfigurationManager.AppSettings["custom:ImagesServerUploadPath"];

                    string serverOriginalSavePath = path + originalSavePath;


                    entity.FileName = entity.FileName.ToLower().Replace("\\", "/");

                    ImageUpload s      = new ImageUpload();
                    string      domain = System.Configuration.ConfigurationManager.AppSettings["custom:ImagesServerUrl"];



                    DirectoryInfo Drr = new DirectoryInfo(path + savefolder);
                    if (!Drr.Exists)
                    {
                        Drr.Create();
                    }

                    FileStream fs = new FileStream(serverOriginalSavePath, FileMode.Create, FileAccess.Write);
                    fs.Write(entity.FileData, 0, entity.FileData.Length);
                    fs.Flush();
                    fs.Close();

                    string url  = domain + originalSavePath;
                    string name = entity.FileName == null ? "" : entity.FileName;
                    r.Data    = "{\"url\":\"" + url + "\",\"name\":\"" + name + "\",\"referenceId\":\"" + entity.ReferenceId + "\"}";
                    r.Message = "上传成功";
                    r.Result  = ResultType.Success;
                }
            }
            catch (Exception ex)
            {
                r.Result  = ResultType.Exception;
                r.Message = "上传失败";
                Log.Error("WebApi上传图片异常", ex);
            }

            string json = r.ToString();
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
        public CommonSetting SmtpServerData()
        {
            CommonSetting ObjtblCommonSetting = (from mails in _context.CommonSetting select mails).FirstOrDefault();

            return(ObjtblCommonSetting);
        }