Example #1
0
        /// <summary>
        /// 报价 图片上传
        /// </summary>
        /// <returns></returns>
        public Task <ApiReturnModel> QuotationProductImgUpload()
        {
            // 检查是否是 multipart/form-data
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }
            //文件保存目录路径
            string SaveTempPath = ConfigHelp.GetValueByNameInAppSettings("QuotationProductImg");

            SaveTempPath += DateTime.Now.ToString("yyyy") + '/';
            SaveTempPath += DateTime.Now.ToString("MM") + '/';
            String dirTempPath = HttpContext.Current.Server.MapPath(SaveTempPath);

            if (!System.IO.Directory.Exists(dirTempPath))
            {
                System.IO.Directory.CreateDirectory(dirTempPath);
            }

            // 设置上传目录
            var provider = new MultipartFormDataStreamProvider(dirTempPath);
            //var queryp = Request.GetQueryNameValuePairs();//获得查询字符串的键值集合
            var task = Request.Content.ReadAsMultipartAsync(provider).
                       ContinueWith <ApiReturnModel>(o =>
            {
                var file          = provider.FileData[0];//provider.FormData
                string orfilename = file.Headers.ContentDisposition.FileName.TrimStart('"').TrimEnd('"');
                FileInfo fileinfo = new FileInfo(file.LocalFileName);
                //最大文件大小
                int maxSize = 10000000;
                if (fileinfo.Length <= 0)
                {
                    return(ApiReturnModel.ReturnError("请上传文件"));
                }
                else if (fileinfo.Length > maxSize)
                {
                    return(ApiReturnModel.ReturnError("文件大小超过限制"));
                }
                else
                {
                    string fileExt = orfilename.Substring(orfilename.LastIndexOf('.'));
                    //定义允许上传的文件扩展名
                    String fileTypes = "gif,jpg,jpeg,png,bmp";
                    if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1)
                    {
                        return(ApiReturnModel.ReturnError("只能上传 图片"));
                    }
                    else
                    {
                        String ymd         = DateTime.Now.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                        String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                        fileinfo.CopyTo(Path.Combine(dirTempPath, newFileName + fileExt), true);
                        fileinfo.Delete();
                        return(ApiReturnModel.ReturnOk("上传 成功", SaveTempPath + newFileName + fileExt));
                    }
                }
            });

            return(task);
        }
        public void TestConfigRead()
        {
            var helper = new ConfigHelp <EncryptionConfigEntity>(new SectionConfig("EncryptionService", "Entities"));

            Assert.AreEqual("TripleDES", helper.DefaultConfig.Name);
            Assert.AreEqual(5, helper.Count);
        }
        public ActionResult Register(RegisterDto UserInfo)
        {
            //int pageSize = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            try
            {
                if (ModelState.IsValid == false)
                {
                    ModelState.AddModelError("", "实体验证不合法");

                    List <RoomDto> list = new List <RoomDto>();
                    list = roomService.GetAll();
                    SelectList selList = new SelectList(list, "ID", "Name");
                    ViewData["Position"] = selList;

                    return(View(UserInfo)); //数据验证不通过后,重新跳到新增页面。
                }

                bool InsertCount = registerService.InsertInfo(UserInfo);
                /// <summary>
                /// 发送邮件
                /// </summary>
                /// <param name="title">邮件主题</param>
                /// <param name="email">要发送对象的邮箱</param>
                /// <param name="content">邮件内容</param>
                /// <returns></returns>
                if (InsertCount)
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");                                             //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = ConfigHelp.GetConfigValue("admin");                                                //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress");                                          //你的邮箱
                    string subjectInfo     = "学生注册审核通知";                                                                        //主题
                    string bodyInfo        = "<html>" + "名为 " + UserInfo.Real_Name + " 的学生提交了注册申请,请前往“用户管理”界面进行审核" + "</html>"; //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");                                                 //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");                                                 //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                                                              //发送邮箱的端口号
                    //string attachPath = "E:\\123123.txt; E:\\haha.pdf";

                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    //添加附件
                    //email.AddAttachments(attachPath);
                    //string message;
                    if (myEmail.Send())
                    {
                        return(Content("<script>alert('已将审核邮件发送给管理员,请耐心等待');window.location.href='Register';</script>"));
                    }
                    else
                    {
                        return(Content("<script>alert('邮件发送失败')window.location.href='Register';</script>"));
                    }
                }
            }
            catch
            {
            }
            return(View());
        }
Example #4
0
        public JsonResult GetSumPer(string nickTime, int curPage, int id)
        {
            long recordCount          = 0;
            int  pageSize             = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            List <SumBaseDto> sumList = SumService.GetSumPer(nickTime, curPage, pageSize, id, out recordCount);
            string            jsonStr = JsonConvert.SerializeObject(new { recordCount = recordCount, pageSize = pageSize, lists = sumList });

            return(Json(jsonStr));
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbConfigName">database config name</param>
        public BaseRepostitory(string dbConfigName)
        {
            var setting = ConfigHelp.GetConnectionSetting();

            if (setting == null)
            {
                throw new ArgumentException("dbConfigName");
            }

            _factory          = GetFactory(setting.ProviderName);
            _connectionString = setting.ConnectionString;
        }
Example #6
0
        //Generate report based on config data from app.config file
        private void GenerateReport()
        {
            var reporter = new clsReporter();

            reporter.AllServers    = ConfigHelp.getAllConnections();
            reporter.StartDate     = ConfigHelp.getStartDate();
            reporter.StopDate      = ConfigHelp.getStopDate();
            reporter.ExcludedGroup = ConfigHelp.getExcludedGroup();
            reporter.ExcludedUser  = ConfigHelp.getExcludedUser();

            reporter.CreateReport();
            MessageBox.Show("Done");
        }
Example #7
0
        //start main process for Watchdog
        public void Start()
        {
            common.StartLogging();
            common.DisplayAndLog("Start Main Program");


            var mainT    = new clsMainServerThread();
            var AllConns = ConfigHelp.getAllConnections();

            foreach (var actCon in AllConns)
            {
                var SrvMainThread = new clsMainServerThread();
                SrvMainThread.Connection = actCon;

                StopFunction StopThisWatcher;
                StopThisWatcher = new StopFunction(SrvMainThread.Stop);
                this.AllStopFunction.Add(StopThisWatcher);

                SrvMainThread.set_fullDealcallback_function(NewFullDealReceive);

                var bwthread = new Thread(SrvMainThread.StartWatch);
                bwthread.Start();
            }

            string KeybordCode = "";

            while (KeybordCode == "")
            {
                Thread.Sleep(10000);
                Console.WriteLine("Press andy key to quit");
                KeybordCode = Console.ReadKey().ToString();
            }

            // stop all threads
            foreach (var stopFunction in this.AllStopFunction)
            {
                stopFunction();
            }
            Thread.Sleep(2000);


            common.DisplayAndLog("Program end");
        }
Example #8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            ConfigHelp.SetAppSetting(Configuration.GetSection("XmlConfig"));
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc();
        }
        public JsonResult GetLeaveList(string nickName, string nickTime, int curPage, string RoomID)  //获取分页列表
        {
            List <UserBaseDto> UserList = userService.GetAll();
            long recordCount            = 0;

            int pageSize = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            List <LeaveBaseDto> LeaveList = leaveService.GetLeaveList(nickName.Trim(), nickTime, curPage, pageSize, RoomID, out recordCount);

            foreach (var item in LeaveList)
            {
                foreach (var item1 in UserList)
                {
                    if (item1.ID == item.User_ID)
                    {
                        item.Real_Name = item1.Real_Name;
                    }
                }
            }
            string jsonStr = JsonConvert.SerializeObject(new { recordCount = recordCount, pageSize = pageSize, lists = LeaveList });

            return(Json(jsonStr));
        }
        public JsonResult GetEquipList(string nickName, int curPage)  //获取分页列表
        {
            List <LABMANAGE.Service.Equip.Dto.EUserBaseDto> UserList = userService.GetAll();
            int  pageSize    = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            long recordCount = 0;
            List <EquipBaseDto> EquipList = null;

            EquipList = equipService.GetEquipList(nickName.Trim(), curPage, pageSize, out recordCount);

            foreach (var item in EquipList)
            {
                foreach (var item1 in UserList)
                {
                    if (item1.ID == item.User_ID)
                    {
                        item.Real_Name = item1.Real_Name;
                    }
                }
            }
            string jsonStr = JsonConvert.SerializeObject(new { recordCount = recordCount, pageSize = pageSize, lists = EquipList });

            return(Json(jsonStr));
        }
        public ContentResult UserCheck(int userId, string email) //用户审核,用于审核刚注册的用户
        {
            try
            {
                bool success = UserManService.UserCheck(userId);
                if (success)
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");    //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = email;                                    //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress"); //你的邮箱
                    string subjectInfo     = "审核通过消息";                                 //主题
                    string bodyInfo        = "<p>" + "注册已通过审核,请前往“登陆”页面进行登陆" + "</p>"; //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");        //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");        //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                     //发送邮箱的端口号
                    //string attachPath = "E:\\123123.txt; E:\\haha.pdf";

                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    if (myEmail.Send())
                    {
                        return(Content("true"));
                    }
                    else
                    {
                        return(Content("false"));
                    }
                }
                else
                {
                    return(Content("false"));
                }
            }
            catch { return(Content("false")); }
        }
        public ActionResult Index(EquipBaseDto equipBaseDto)
        {
            string VerfiyEmail            = null;
            List <EUserBaseDto> UserModel = userService.GetAll();

            TempData["peoplelist"] = UserModel;
            int id = 0;

            try
            {
                id = Convert.ToInt32(@LoginBase.ID);
            }
            catch { return(Content("<script>alert('尚未登录');window.location.href='../Login';</script>")); }
            equipBaseDto.User_ID = id;
            try
            {
                int Valid = Convert.ToInt32(Request.Form["valid"]);
                foreach (var item in UserModel)
                {
                    if (item.ID == Valid)
                    {
                        equipBaseDto.Verify_ID = item.ID;
                        VerfiyEmail            = item.Email;
                    }
                }
            }
            catch { return(Content("<script>alert('该审核用户不存在');window.location.href='Index';</script>")); }
            if (VerfiyEmail == null)
            {
                return(Content("<script>alert('审核用户不存在!');window.location.href='AskEquip?id=" + id + "&flag=false';</script>"));
            }
            System.DateTime NowTime = System.DateTime.Now;
            equipBaseDto.Time      = NowTime;
            equipBaseDto.Pass      = 0;
            equipBaseDto.IsExamine = 0;
            try
            {
                if (equipService.InsertInfo(equipBaseDto))
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");    //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = VerfiyEmail;                              //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress"); //你的邮箱
                    string subjectInfo     = "设备申请";                                   //主题
                    string bodyInfo        = "<p>" + "有新的设备申请,请前往“设备管理”进行审核" + "</p>"; //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");        //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");        //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                     //发送邮箱的端口号
                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    //添加附件
                    //email.AddAttachments(attachPath);
                    //string message;
                    if (myEmail.Send())
                    {
                        return(RedirectPermanent("/Equip/AskEquip?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
                    }
                    else
                    {
                        return(Content("<script>alert('邮件发送失败');</script>"));
                    }
                }
            }
            catch { }


            return(RedirectPermanent("/Equip/AskEquip?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
        }
Example #13
0
 private void Initialize()
 {
     // 设置webbrower 页面数据
     this.webBrowser_vteshow.Url = new Uri(ConfigHelp.GetPathBaseRootPath("Main"));
 }
Example #14
0
 private void VteDetailsLoad(object sender, EventArgs e)
 {
     this.webBrowser_detials.Url = new Uri(ConfigHelp.GetPathBaseRootPath("Detail"));
 }
        public ActionResult Index(LeaveBaseDto leaveBaseDto)
        {
            string             VerfiyEmail = null;
            List <UserBaseDto> UserModel   = userService.GetAll();

            TempData["peoplelist"] = UserModel;
            int id = 0;

            try
            {
                id = Convert.ToInt32(@LoginBase.ID);
            }
            catch { return(Content("<script>alert('尚未登录');window.location.href='../Login';</script>")); }
            leaveBaseDto.User_ID = id;

            try
            {
                int Valid = Convert.ToInt32(Request.Form["valid"]);

                foreach (var item in UserModel)
                {
                    if (item.ID == Valid)
                    {
                        leaveBaseDto.Verify_ID = item.ID;
                        VerfiyEmail            = item.Email;
                    }
                }
            }
            catch { return(Content("<script>alert('请选择正确的审核用户!');window.location.href='Index';</script>")); }
            if (VerfiyEmail == null)
            {
                return(Content("<script>alert('审核用户不存在!');window.location.href='AskLeave?id=" + id + "&flag=false';</script>"));
            }


            string Time = Request.Form["time"];
            string StartTime, EndTime;

            StartTime = EndTime = null;
            if (Time != null)
            {
                StartTime = Time.Split('-')[0].Trim().ToString();
                EndTime   = Time.Split('-')[1].Trim().ToString();
                leaveBaseDto.Start_Time = Convert.ToDateTime(StartTime);
                leaveBaseDto.End_Time   = Convert.ToDateTime(EndTime);
            }
            System.DateTime NowTime = System.DateTime.Now;
            leaveBaseDto.Time      = NowTime;
            leaveBaseDto.Pass      = 0;
            leaveBaseDto.IsExamine = 0;

            try
            {
                if (leaveService.InsertInfo(leaveBaseDto))
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");    //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = VerfiyEmail;                              //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress"); //你的邮箱
                    string subjectInfo     = "请假申请";                                   //主题
                    string bodyInfo        = "<p>" + "有学生请假,请前往“请假管理”进行审核" + "</p>";   //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");        //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");        //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                     //发送邮箱的端口号
                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    //添加附件
                    //email.AddAttachments(attachPath);
                    //string message;
                    if (myEmail.Send())
                    {
                        return(RedirectPermanent("/Leave/AskLeave?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
                    }
                    else
                    {
                        //return Content("<script>alert('邮件发送失败')window.location.href='Index';</script>");
                    }
                }
            }
            catch { }
            return(RedirectPermanent("/Leave/AskLeave?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
        }
Example #16
0
 public DemoRepository() :
     base(ConfigHelp.GetSqlConnection())
 {
 }
 /// <summary>
 /// 初始化
 /// </summary>
 private void InitializeStaticResource()
 {
     ViewBag.RootNode     = ConfigHelp.GetConfigValueForNull("ReferenceKey.RootNode") ?? string.Empty;
     ViewBag.CurrentModel = CurrentModel;
 }