Ejemplo n.º 1
0
        private List <KTResourceSimpleView> GetNewList(IEnumerable <KTResource> list)
        {
            List <KTResourceSimpleView> listNew = new List <KTResourceSimpleView>();

            for (int i = 0; i < list.Count(); i++)
            {
                KTResource resource = list.ElementAt(i);
                resource.avatarUrl = KTUtils.GetAvatar(resource);
                KTResourceSimpleView newobj = KTUtils.AutoCopy2 <KTResource, KTResourceSimpleView>(resource);
                listNew.Add(newobj);
            }
            return(listNew);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public PartialViewResult EditorTabsPartial(string cm, string resource_type, int objid = 0)
 {
     if (cm.ToLower() == "ad")
     {
         // 添加
         if (!string.IsNullOrEmpty(resource_type) && resource_type.ToLower() == "com.twproject.resource.person")
         {
             return(PartialView("_AddPersonPartial"));
         }
         else if (!string.IsNullOrEmpty(resource_type) && resource_type.ToLower() == "com.twproject.resource.company")
         {
             return(PartialView("_AddDepartmentPartial"));
         }
         else
         {
             return(PartialView());
         }
     }
     else if (cm.ToLower() == "sv")
     {
         if (resource_type.ToLower() == "com.twproject.resource.person")
         {
             return(PartialView("_EditPersonPartial"));
         }
         else
         {
             return(PartialView("_EditDepartmentPartial"));
         }
     }
     else
     {
         // 编辑
         KTResource resource = service.GetDetail(objid);
         ViewBag.Info = resource;
         if (resource.discriminator.ToLower() == "person")
         {
             return(PartialView("_EditPersonPartial"));
         }
         else if (resource.discriminator.ToLower() == "company")
         {
             return(PartialView("_EditDepartmentPartial"));
         }
         else
         {
             return(PartialView());
         }
     }
 }
Ejemplo n.º 4
0
        public static string GetAvatar(KTResource obj)
        {
            string txt = string.Empty;

            if (!string.IsNullOrEmpty(obj.myPhoto))
            {
                string[] arr = obj.myPhoto.Split(new string[] { "+++" }, StringSplitOptions.RemoveEmptyEntries);
                if (arr.Length == 2)
                {
                    return("/" + arr[1]);
                }
            }

            // 李 小利 返回:小利
            if (!string.IsNullOrEmpty(obj.name))
            {
                string _s = obj.name.Replace(" ", "");
                txt = _s.Length <= 2 ? _s : _s.Substring(0, 2);
            }

            return("/img/svgAvatar?code=" + System.Web.HttpUtility.UrlEncode(txt) + "&fill=hsl%28180%2C70%25%2C80%25%29&stroke=hsl%28180%2C90%25%2C20%25%29");
        }
Ejemplo n.º 5
0
        public ActionResult ResourceEditor(string cm, string resource_type, int objid = 0)
        {
            this.cm            = cm;
            this.resource_type = resource_type;

            // 添加的情况
            if (cm.ToLower() == "ad" && objid == 0)
            {
                if (resource_type.ToLower() == "com.twproject.resource.person")
                {
                    ViewBag.Type = "person";
                }
                else if (resource_type.ToLower() == "com.twproject.resource.company")
                {
                    ViewBag.Type = "company";
                }
                else
                {
                }
            }

            // 编辑的情况
            if (objid > 0)
            {
                KTResource resource = service.GetDetail(objid);
                if (resource.discriminator.ToLower() == "person")
                {
                    ViewBag.Type = "person";
                }
                else if (resource.discriminator.ToLower() == "company")
                {
                    ViewBag.Type = "company";
                }
            }
            return(View());
        }
Ejemplo n.º 6
0
 public int Delete(KTResource obj)
 {
     return(repository.Delete(obj));
 }
Ejemplo n.º 7
0
 public int Update(KTResource metadata)
 {
     return(repository.Update(metadata));
 }
Ejemplo n.º 8
0
 public KTResource Insert(KTResource metadata)
 {
     return(repository.Insert(metadata));
 }
Ejemplo n.º 9
0
 public int Delete(KTResource obj)
 {
     return(db.Deleteable <KTResource>(m => m.id == obj.id).ExecuteCommand());
 }
Ejemplo n.º 10
0
 public int Update(KTResource obj)
 {
     return(db.Updateable <KTResource>(obj)
            .Where(m => m.id == obj.id)
            .ExecuteCommand());
 }
Ejemplo n.º 11
0
 public KTResource Insert(KTResource obj)
 {
     return(db.Insertable <KTResource>(obj).ExecuteReturnEntity());
 }
Ejemplo n.º 12
0
        public PartialViewResult GeneralDataPartial(string cm, string resource_type, int objid = 0)
        {
            // 编辑的情况
            if (cm.ToLower() == "ed" && objid != 0)
            {
                KTResource resource = TempData["resource"] as KTResource;
                //KTResource resource = service.GetDetail(objid);
                ViewBag.Info = resource;
                if (resource.discriminator.ToLower() == "person")
                {
                    return(PartialView("_PersonGeneralDataPartial"));
                }
                else if (resource.discriminator.ToLower() == "company")
                {
                    return(PartialView("_DepartmentGeneralDataPartial"));
                }
                else
                {
                    return(PartialView("_GeneralDataPartial"));
                }
            }

            if (cm.ToLower() == "sv")
            {
                KTResource resource = TempData["resource"] as KTResource;
                //KTResource resource = service.GetDetail(objid);
                ViewBag.Info = resource;
                if (resource.discriminator.ToLower() == "person")
                {
                    return(PartialView("_PersonGeneralDataPartial"));
                }
                else if (resource.discriminator.ToLower() == "company")
                {
                    return(PartialView("_DepartmentGeneralDataPartial"));
                }
                else
                {
                    return(PartialView("_GeneralDataPartial"));
                }
            }


            // 添加的情况
            if (cm.ToLower() == "ad" && objid == 0)
            {
                if (resource_type.ToLower() == "com.twproject.resource.person")
                {
                    return(PartialView("_PersonGeneralDataPartial"));
                }
                else if (resource_type.ToLower() == "com.twproject.resource.company")
                {
                    return(PartialView("_DepartmentGeneralDataPartial"));
                }
                else
                {
                    return(PartialView("_GeneralDataPartial"));
                }
            }
            else
            {
                return(PartialView("_GeneralDataPartial"));
            }
        }
Ejemplo n.º 13
0
        public ActionResult ResourceEditor(FormCollection form)
        {
            string _cm = form["cm"];

            this.cm            = _cm;
            this.resource_type = form["resource_type"];

            KTResource resource = null;
            string     id       = form["objid"];

            resource = new KTResource {
                code         = form["code"],
                parent       = form["parent_id"],
                ancestorids  = form["parent_id"],      //TODO 到根的层级
                myManager    = form["manager"],
                myManagerIds = form["courtesy_title"], //TODO 到根的层级
                area         = Convert.ToInt32(form["area"]),
                tags         = form["resource_tags"],
                notes        = form["note"],
                ownerx       = this.UserID,
                name         = form["fld_surname"] + " " + form["fld_name"],
                inherit      = false,
                propagate    = true,
                hidden       = false,
            };

            // 设置manager myManagerIds字段,就是上级主管人
            string _managerid = form["manager"];

            if (!string.IsNullOrEmpty(_managerid))
            {
                KTResource _managerResourceInfo = service.GetDetail(Convert.ToInt32(_managerid));
                string     _mids = _managerResourceInfo.myManagerIds ?? "";
                resource.myManager    = _managerid;
                resource.myManagerIds = _mids + _managerid + "^";
            }

            // 设置manager myManagerIds字段,就是上级主管人
            string _parentid = form["parent_id"];

            if (!string.IsNullOrEmpty(_parentid))
            {
                KTResource _parentResourceInfo = service.GetDetail(Convert.ToInt32(_parentid));
                string     _pids = _parentResourceInfo.ancestorids ?? "";
                resource.parent      = _parentid;
                resource.ancestorids = _pids + _parentid + "^";
            }


            if (this.resource_type.ToLower() == "com.twproject.resource.person")
            {
                // 人
                ViewBag.Type           = "person";
                resource.discriminator = "PERSON";
                resource.personName    = form["fld_name"];
                resource.personSurname = form["fld_surname"];
                resource.courtesyTitle = form["courtesy_title"];

                if (this.cm.ToLower() == "sv" && id.ToLower() == "newemptyid")
                {
                    resource.creationDate = DateTime.Now;
                    resource.creator      = this.User.Identity.Name;
                    resource.lastModified = DateTime.Now;
                    resource.lastModifier = this.User.Identity.Name;
                    resource.id           = service.Maxid().id.ToString();
                    KTResource result = service.Insert(resource);
                }
                else
                {
                    resource.id           = id;
                    resource.lastModified = DateTime.Now;
                    resource.lastModifier = this.User.Identity.Name;
                    int count = service.Update(resource);
                }
            }
            else
            {
                // 加部门
                resource.discriminator = "COMPANY";
                resource.typex         = Convert.ToInt32(form["type"]);
                if (this.cm.ToLower() == "sv" && id.ToLower() == "newemptyid")
                {
                    resource.creationDate = DateTime.Now;
                    resource.creator      = this.User.Identity.Name;
                    resource.lastModified = DateTime.Now;
                    resource.lastModifier = this.User.Identity.Name;
                    IntID _id = service.Maxid();
                    resource.id = _id.id.ToString();
                    KTResource result = service.Insert(resource);
                }
                else
                {
                    resource.id           = id;
                    resource.lastModified = DateTime.Now;
                    resource.lastModifier = this.User.Identity.Name;
                    int count = service.Update(resource);
                }
                ViewBag.Type = "company";
            }

            ViewBag.ResourceInfo = resource;
            TempData["resource"] = resource;

            return(View());
        }