Exemplo n.º 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());
        }
Exemplo n.º 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"),
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据模板组装返回数据List的HTML内容
        /// </summary>
        /// <typeparam name="T">行数据类型</typeparam>
        /// <param name="list">数据列表</param>
        /// <param name="rowTemplate">行模板</param>
        /// <param name="listExpress"></param>
        /// <returns></returns>
        public static string GetListFromTemplate <T>(IEnumerable <T> list, string rowTemplate, List <MyExpress> listExpress)
        {
            string htmlTotal = null;

            PropertyInfo[] arrs = KTUtils.GetPropertyArray <T>();
            for (int i = 0; i < list.Count(); i++)
            {
                T      item    = list.ElementAt(i);
                string rowhtml = rowTemplate;
                // {字段}替换为值
                for (int j = 0; j < arrs.Length; j++)
                {
                    string pro = arrs[j].Name;

                    string value = KTUtils.GetObjectPropertyValue <T>(item, pro);
                    rowhtml = rowhtml.Replace("{" + pro.ToLower() + "}", value);

                    // 处理expressfield配置
                    if (listExpress != null && listExpress.Count > 0)
                    {
                        for (int m = 0; m < listExpress.Count; m++)
                        {
                            MyExpress obj = listExpress[m];
                            if (obj.sign == "equal")
                            {
                                // 目前只处理 等于情况 TODO:更多情况,如大小比较类
                                if (obj.field == pro)
                                {
                                    // 获取值对应的html
                                    if (obj.dicConditions.ContainsKey(value))
                                    {
                                        string v = obj.dicConditions[value];
                                        rowhtml = rowhtml.Replace("#" + pro.ToLower() + "#", v);
                                    }
                                }
                            }

                            if (j == arrs.Length - 1 && m == listExpress.Count - 1)
                            {
                                // 最后一个,替换掉默认的
                                rowhtml = rowhtml.Replace("#" + pro.ToLower() + "#", obj.dicConditions["else"]);
                            }
                        }
                    }
                }


                // 更新行号
                rowhtml    = rowhtml.Replace("#rowid#", i.ToString());
                htmlTotal += rowhtml;
            }


            return(htmlTotal);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 头像字段处理
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private List <KTResourceSimpleView> GetNewList(IEnumerable <KTResourceSimpleView> list)
        {
            List <KTResourceSimpleView> listNew = new List <KTResourceSimpleView>();

            for (int i = 0; i < list.Count(); i++)
            {
                KTResourceSimpleView resource = list.ElementAt(i);
                resource.avatarUrl = KTUtils.GetAvatar2(resource);
                listNew.Add(resource);
            }
            return(listNew);
        }
Exemplo n.º 5
0
        private List <KTResourceExt> GetNewList(IEnumerable <KTResource> list)
        {
            List <KTResourceExt> list2 = new List <KTResourceExt>();

            for (int i = 0; i < list.Count(); i++)
            {
                KTResource    issueStatus = list.ElementAt(i);
                KTResourceExt obj         = KTUtils.AutoCopy <KTResource, KTResourceExt>(issueStatus);
                obj.myAvatar = KTUtils.GetAvatar(issueStatus);
                list2.Add(obj);
            }

            return(list2);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 根据模板组装返回数据List的HTML内容
        /// </summary>
        /// <typeparam name="T">行数据类型</typeparam>
        /// <param name="list">数据列表</param>
        /// <param name="rowTemplate">行模板</param>
        /// <returns></returns>
        public static string GetListFromTemplate <T>(IEnumerable <T> list, string rowTemplate)
        {
            string htmlTotal = null;

            PropertyInfo[] arrs = KTUtils.GetPropertyArray <T>();
            for (int i = 0; i < list.Count(); i++)
            {
                T      item    = list.ElementAt(i);
                string rowhtml = rowTemplate;
                for (int j = 0; j < arrs.Length; j++)
                {
                    string pro = arrs[j].Name;

                    string value = KTUtils.GetObjectPropertyValue <T>(item, pro);
                    rowhtml = rowhtml.Replace("{" + pro.ToLower() + "}", value);
                }
                // 更新行号
                rowhtml    = rowhtml.Replace("#rowid#", i.ToString());
                htmlTotal += rowhtml;
            }

            return(htmlTotal);
        }
Exemplo n.º 7
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));
            }
        }