예제 #1
0
파일: TBase.cs 프로젝트: labvit/AI-XO3
        public void Run(TPole Pole)
        {
            TAnalysis Analysis = new TAnalysis();

            TAnalysisRes Res = Analysis.What(Pole.Pos);

            if (Res.Act != ActionType.Nil)
            {
                if (Pole.Move(Res.Coord.i, Res.Coord.j) != Result.Error)
                {
                    return;
                }
            }

            // for (int i = 0; i < 3; i++)
            // {
            //     for (int j = 0; j < 3; j++)
            //     {
            for (int i = 0; i < cell_count; i++)     // labvit
            {
                for (int j = 0; j < cell_count; j++) // labvit
                {
                    if (Pole.Move(i, j) != Result.Error)
                    {
                        return;
                    }
                }
            }
        }
예제 #2
0
        public ActionResult PostTAnalsTs()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();
            OLog.BeforeValue = "";

            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'非法请求!'}");
            int Id = Converter.ToInt(Request.Form["Id"], 0);
            string title = Converter.ToString(Request.Form["Title"]).Trim();
            string body = Converter.ToString(Request.Form["MsgBody"]).Trim();
            string timer = Converter.ToString(Request.Form["timer"]).Trim();
            string date = Converter.ToString(Request.Form["sendtime"]).Trim();
            string errMsg = "";
            DateTime dt = DateTime.Now;
            if (title == "")
                errMsg += "标题不能为空;";
            if (body == "")
                errMsg += "正文不能为空;";
            if (timer == "1")
            {
                if (!DateTime.TryParse(date, out dt))
                    errMsg += "定时分析必须设置时间;";
                else if (DateTime.Now > dt)
                    errMsg += "您设置的时间已过期;";
            }
            if (errMsg != "")
            {
                return Content("{result:'fail',msg:'" + errMsg + "'}");
            }
            if (Id > 0)
            {
                try
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        var arr = (from b in db.TAnalysis where b.ID == Id select b).FirstOrDefault();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(arr);
                        arr.Title = title;
                        arr.MsgBody = body;
                        arr.SendTime = DateTime.Now;
                        if (timer=="1")
                        {
                            arr.SendTime = dt;
                        }

                        db.SubmitChanges();

                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "修改分析成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        OLog.UpdateValue = ObjectToJson.ModelToJson(arr);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "修改分析";
                        Converter.InsertOperationLog(OLog);
                        return Content("{result:'success',msg:'分析修改成功!'}");
                    }
                }
                catch (Exception ex)
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "修改分析失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);
                    return Content("{result:'fail',msg:'未知错误,分析修改失败!'}");
                }

            }
            else
            {
                try
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        TAnalysis entity = new TAnalysis();
                        entity.Title = title;
                        entity.MsgBody = body;
                        entity.SendTime = DateTime.Now;
                        if (timer == "1")
                        {
                            entity.SendTime = dt;
                        }
                        entity.SenderID = Convert.ToInt32(Session["ID"]);
                        db.TAnalysis.InsertOnSubmit(entity);
                        db.SubmitChanges();

                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "发布分析成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        OLog.UpdateValue = ObjectToJson.ModelToJson(entity);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "发布分析";
                        Converter.InsertOperationLog(OLog);

                        return Content("{result:'success',msg:'分析发布成功!'}");
                    }
                }
                catch (Exception ex)
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "发布分析失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);
                    return Content("{result:'fail',msg:'未知错误,分析发送失败!'}");
                }

            }
        }