コード例 #1
0
        public ActionResult WorkgroupPopup()
        {
            WorkgroupParams             workgroupParams = KTUtils.GetObjectFromRequest <WorkgroupParams>(Request.QueryString);
            XmlNode                     node            = KTList.GetConfigNode("workgroupgAjax.xml", "WGSRCPEOPLE");
            string                      renderHTML      = string.Empty;
            List <KTResourceSimpleView> listNew         = new List <KTResourceSimpleView>();

            if (node != null)
            {
                IEnumerable <KTResource> list = resourceService.GetList2(workgroupParams);
                listNew    = GetNewList(list);
                renderHTML = KTList.GetDataList <KTResourceSimpleView>(node, 0, 0, listNew);
            }

            string renderHTMLSelected            = string.Empty;
            IEnumerable <KTResource>    listTar  = new AgendaService().GetResourceList(workgroupParams.WG_IDS.Split(','));
            List <KTResourceSimpleView> listNew2 = GetNewList(listTar);

            renderHTMLSelected = KTList.GetDataList <KTResourceSimpleView>(node, 0, 0, listNew2);

            //ViewBag.ListHTML = renderHTML;
            //ViewBag.ListHTMLSelected = renderHTMLSelected;
            ViewBag.resourceList = JsonConvert.SerializeObject(listNew2);
            ViewBag.selectedIds  = workgroupParams.WG_IDS;

            // 获取数据
            return(View());
        }
コード例 #2
0
        public HttpResponseMessage WGAjax()
        {
            IEnumerable <KeyValuePair <string, string> > queryString = Request.GetQueryNameValuePairs();
            WorkgroupParams  workgroupParams = KTUtils.GetObjectFromRequest <WorkgroupParams>(queryString);
            IResourceService resourceService = new ResourceService();
            string           returnstr       = "";

            switch (workgroupParams.CM.ToUpper())
            {
            case "WGSRCPEOPLE":
                IEnumerable <KTResourceSimpleView> list    = resourceService.GetList(workgroupParams);
                List <KTResourceSimpleView>        listNew = GetNewList(list);
                var obj = new { ok = true, resources = listNew };
                returnstr = JsonConvert.SerializeObject(obj);
                break;

            case "LISTWL1DAY":
                returnstr = "{\"ok\":true,\"worklogs\":[],\"workable\":28800000}";
                break;

            default:
                returnstr = "{\"ok\":true,\"loginOk\":true}";
                break;
            }

            return(new HttpResponseMessage()
            {
                Content = new StringContent(returnstr, Encoding.UTF8, "application/json"),
            });
        }
コード例 #3
0
        public HttpResponseMessage AgendaAjax()
        {
            IEnumerable <KeyValuePair <string, string> > queryString = Request.GetQueryNameValuePairs();
            AgendaParams agendaParams = KTUtils.GetObjectFromRequest <AgendaParams>(queryString);

            if (agendaParams.CM.ToUpper() == "MICSAVE")
            {
                Schedule schedule = KTUtils.GetObjectFromRequest <Schedule>(queryString);
                schedule.discriminator = "P";
                schedule.startTime     = schedule.startMillis.TimeOfDay.TotalMilliseconds.ObjToInt();
                schedule.duration      = schedule.endMillis.Subtract(schedule.startMillis).TotalMilliseconds;

                IScheduleService scheduleService = new ScheduleService();
                Schedule         resultS         = scheduleService.Insert(schedule);

                // 保存
                string id     = agendaService.Maxid().id.ToString();
                Agenda agenda = KTUtils.GetObjectFromRequest <Agenda>(queryString);
                agenda.id           = id;
                agenda.typeid       = agenda.type.ObjToInt();
                agenda.authorid     = this.UserID.ToString();
                agenda.creator      = this.UserInfo.UserName;
                agenda.lastModifier = this.UserInfo.UserName;
                agenda.creationDate = DateTime.Now;
                agenda.lastModified = DateTime.Now;
                agenda.icalId       = "TW_" + id;
                agenda.exceptions   = string.Empty;
                agenda.scheduleid   = resultS.scheduleid;
                Agenda result = agendaService.Insert(agenda);

                // 写入关联人员
                List <AgendaTarget> listTar = new List <AgendaTarget>();
                string[]            ids     = (agendaParams.WG_IDS ?? "").Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    listTar.Add(new AgendaTarget {
                        agendaid = result.id, resid = ids[i]
                    });
                }

                if (listTar.Count > 0)
                {
                    IAgendaTargetService agendaTargetService = new AgendaTargetService();
                    agendaTargetService.Insert(listTar);
                }

                // 查询
                string returnstr = GetAgendaList(agendaParams);
                return(new JsonResult(returnstr));
            }
            else if (agendaParams.CM.ToUpper() == "GETEVENTS")
            {
                // 查询
                agendaParams.userID = this.UserID.ToString();

                // 时间范围计算
                string returnstr = GetAgendaList(agendaParams);
                return(new JsonResult(returnstr));
            }
            else if (agendaParams.CM.ToUpper() == "DELEV")
            {
                // 删除
                agendaService.Delete(agendaParams);

                string returnstr = GetAgendaList(agendaParams);
                return(new JsonResult(returnstr));
            }
            else
            {
                var    obj       = new { ok = true, events = "" };
                string returnstr = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
                return(new JsonResult(returnstr));
            }
        }