示例#1
0
        // 摘要:
        //     由自定义 HTTP Web 请求的允许处理 HttpHandler 实现 System.Web.IHttpHandler 接口。
        //
        // 参数:
        //   context:
        //     System.Web.HttpContext 提供对内部服务器对象的引用的对象 (例如, Request, ,Response, ,Session,
        //     ,和 Server) 用于处理 HTTP 请求。
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest Request        = context.Request;
            string      questionId     = Request.QueryString["questionId"];
            string      userquestionId = Request.QueryString["userquestionId"];
            string      companyId      = Request.QueryString["companyId"];
            string      classId        = Request.QueryString["classid"];
            string      courseId       = Request.QueryString["courseid"];
            string      userId         = Request.QueryString["userid"];
            string      Name           = Request.QueryString["Name"];

            if (!string.IsNullOrEmpty(questionId))
            {
                JObject jo = new JObject();
                jo["questionId"]     = questionId;
                jo["userquestionId"] = userquestionId;
                jo["companyId"]      = companyId;
                jo["classId"]        = classId;
                jo["courseId"]       = courseId;
                jo["userId"]         = userId;
                jo["Name"]           = Name;

                YsbqcSetting.insertSession(jo);

                string split = "/";
                string path  = AppDomain.CurrentDomain.BaseDirectory + split + "Log" + split + YsbqcSetting.getSession().userId;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string        fileFullPath = path + split + "Session.json";
                StringBuilder str          = new StringBuilder();
                str.Append(JsonConvert.SerializeObject(jo));
                StreamWriter sw = System.IO.File.CreateText(fileFullPath);
                sw.WriteLine(str.ToString());
                sw.Close();

                string          logPath = AppDomain.CurrentDomain.BaseDirectory + split + "Log";
                DirectoryInfo[] DIs     = Directory.CreateDirectory(logPath).GetDirectories();
                foreach (DirectoryInfo DI in DIs)
                {
                    if (DI.LastAccessTime.Date != DateTime.Now.Date)
                    {
                        DI.Delete(true);
                    }
                }
            }

            string JsonStr = System.IO.File.ReadAllText(context.Server.MapPath("index_login.html"));

            context.Response.ContentType = "text/html;charset=utf-8";
            context.Response.Write(JsonStr);
        }
示例#2
0
        protected void create(HttpRequest Request)
        {
            string questionId     = Request.Query["questionId"];
            string userquestionId = Request.Query["userquestionId"];
            string companyId      = Request.Query["companyId"];
            string classId        = Request.Query["classid"];
            string courseId       = Request.Query["courseid"];
            string userId         = Request.Query["userid"];
            string Name           = Request.Query["Name"];

            if (!string.IsNullOrEmpty(questionId))
            {
                JObject jo = new JObject();
                jo["questionId"]     = questionId;
                jo["userquestionId"] = userquestionId;
                jo["companyId"]      = companyId;
                jo["classId"]        = classId;
                jo["courseId"]       = courseId;
                jo["userId"]         = userId;
                jo["Name"]           = Name;

                set.insertSession(jo);

                string          split   = "/";
                string          logPath = he.ContentRootPath + split + "Log";
                DirectoryInfo[] DIs     = Directory.CreateDirectory(logPath).GetDirectories();
                foreach (DirectoryInfo DI in DIs)
                {
                    if (DI.LastWriteTime.Date != DateTime.Now.Date)
                    {
                        DI.Delete(true);
                    }
                }

                string path = he.ContentRootPath + split + "Log" + split + set.getSession().userId;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string        fileFullPath = path + split + "Session.json";
                StringBuilder str          = new StringBuilder();
                str.Append(JsonConvert.SerializeObject(jo));
                StreamWriter sw = System.IO.File.CreateText(fileFullPath);
                sw.WriteLine(str.ToString());
                sw.Close();
            }
        }
示例#3
0
        void HandleDelete()
        {
            log.Write("Удаление: ");
            FileInfo      FI   = null;
            DirectoryInfo DI   = null;
            String        path = CNB.Br.ReadString();

            path = "ServerData/" + path;
            log.Write(path);
            string answer = "@@@";

            if (path.Contains('.'))
            {
                FI = new FileInfo(path);
            }
            else
            {
                DI = new DirectoryInfo(path);
            }
            if (FI != null)
            {
                try
                {
                    FI.Delete();
                    answer = "Файл успешно удалён";
                }
                catch (Exception E) { answer = $"Не удалось переместить файл - {E.Message}"; }
            }
            else
            {
                try
                {
                    DI.Delete();
                    answer = "Директория успешно удалена";
                }
                catch (Exception E) { answer = $"Не удалось переместить директорию - {E.Message}"; }
            }
            log.Write(answer);
            CNB.Bw.Write(answer);
            cs.Send(CNB.Ms_Buf);
            log.WriteLine("!");
        }