示例#1
0
        public ActionResult OrgEdit(OrgModel model)
        {
            model.Provider = Provider;
            if (model.Command == "save")
            {
                bool adding = false;
                if (model.OrgID == 0)
                {
                    adding       = true;
                    model.Active = true; //new orgs are always active
                }

                if (model.Save())
                {
                    //when OrgID is zero (adding a new Org) the page should reload so we can add addresses and departments
                    if (adding)
                    {
                        return(RedirectToAction("OrgEdit", new { model.OrgID }));
                    }
                    else
                    {
                        return(RedirectToAction("Org"));
                    }
                }
            }
            else
            {
                model.Load();
            }

            return(View(model));
        }
示例#2
0
        public async Task <IActionResult> UpdateOrg(int id, OrgModel orgView)
        {
            var orgUpdate = await _context.organizations.FindAsync(id);

            if (orgUpdate == null)
            {
                return(NotFound());
            }
            orgUpdate.ID          = orgView.Id;
            orgUpdate.OrgName     = orgView.Org_Name;
            orgUpdate.OrgLocation = orgView.Org_Location;


            try
            {
                _context.organizations.Update(orgUpdate);
                _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw e;
            }

            return(NoContent());
        }
示例#3
0
        /// <summary>
        /// 根据用户管理的部门获取管理的部门及上级部门,并组装成树形结构
        /// </summary>
        /// <param name="orgList"></param>
        /// <param name="ownList"></param>
        /// <returns></returns>
        public string GetOwndhtmlxTree(IList <OrgModel> orgList, IList <OrgModel> ownList)
        {
            //找出上级部门
            IList <OrgModel> newList = new List <OrgModel>();
            Hashtable        ht      = new Hashtable();

            foreach (OrgModel org in ownList)
            {
                OrgModel model = new OrgModel();
                model.OrgId       = org.OrgId;
                model.OrgName     = org.OrgName;
                model.OrgCode     = org.OrgCode;
                model.ParentOrgId = org.ParentOrgId;
                ht.Add(org.OrgCode, org.OrgCode);
                newList.Add(model);
                RecursiveOwnDump(orgList, model.ParentOrgId, newList, ht);
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine);
            sb.AppendFormat("<tree id='0'>" + Environment.NewLine);
            RecursiveDump(newList, 0, 1, sb);
            sb.Append("</tree>");

            return(sb.ToString());
        }
示例#4
0
        public async Task <string> CreateOrg(OrgModel myOrg)
        {
            DocumentReference docRef = _db.Collection("organizations").Document(myOrg.UId);
            await docRef.SetAsync(myOrg);

            return(docRef.Id);
        }
示例#5
0
        public ActionResult DocumentOwnInstrumentList(int documentId)
        {
            IList <ParamModel> list           = Global.Business.ServiceProvider.ParamService.GetAll();
            ParamModel         paramModel     = null;
            string             InstrumentType = null;
            IList <OrgModel>   orgList        = Global.Business.ServiceProvider.OrgService.GetAll();
            OrgModel           org            = new OrgModel();

            string where = "InstrumentId in (Select InstrumentId From DocumentOwnInstrument Where SysDocumentId='" + documentId + "')";
            IList <Instrument.Common.Models.InstrumentModel> instrumentList = ServiceProvider.InstrumentService.GetAllInstrumentListByWhere(where);
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            foreach (var instrument in instrumentList)
            {
                paramModel     = list.SingleOrDefault(p => p.ParamCode == Constants.SysParamType.InstrumentType);
                InstrumentType = paramModel.itemsList.SingleOrDefault(p => p.ParamItemValue == instrument.InstrumentType.ToString()).ParamItemName;
                org            = orgList.SingleOrDefault(o => o.OrgCode == instrument.BelongDepart);
                sb.AppendFormat("[\"<a href='#' onclick='fnDelete({0},{1});return false;'>删 除</a>&nbsp;&nbsp;&nbsp;"
                                + "\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\""
                                + "],", documentId, instrument.InstrumentId, instrument.InstrumentName, instrument.ManageNo, instrument.Specification, InstrumentType, instrument.Manufacturer,
                                instrument.SerialNo, instrument.CreateDate, instrument.DueStartDate, instrument.DueEndDate, org == null ? null : org.OrgName);
            }
            if (instrumentList.Count > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]");
            ViewBag.instrumentData = sb.ToString();
            ViewBag.DocumentId     = documentId.ToString();
            return(View());
        }
示例#6
0
        /// <summary>
        /// 根据组织标识自动生成子组织节点的OrgCode
        /// 找出最大的子组织编号+1,若无自组织,则编号为父组织编号+01【xxxxx01】
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public string BuildSubOrgCode(int parentId)
        {
            string           subOrgCode = "";
            OrgModel         parentOrg  = ServiceProvider.OrgService.GetById(parentId);
            IList <OrgModel> subOrgs    = DBProvider.OrgDAO.GetListByParentId(parentId);

            if (subOrgs == null)
            {
                subOrgs = new List <OrgModel>();
            }
            if (subOrgs.Count == 0)
            {
                subOrgCode = parentOrg.OrgCode + "01";
            }
            else
            {
                string maxOrgCode = subOrgs.OrderByDescending(o => o.OrgId).First().OrgCode;
                int    code       = 1;
                int.TryParse(maxOrgCode.Replace(parentOrg.OrgCode, ""), out code);
                code++;
                if (code < 10)
                {
                    subOrgCode = parentOrg.OrgCode + "0" + code;
                }
                else
                {
                    subOrgCode = parentOrg.OrgCode + code;
                }
            }
            return(subOrgCode);
        }
示例#7
0
        public void CanSaveOrg()
        {
            IClient currentUser = new LNF.Data.ClientItem
            {
                ClientID = 1301,
                UserName = "******",
                LName    = "Getty",
                FName    = "James"
            };

            var model = new OrgModel()
            {
                CurrentUser = currentUser,
                OrgName     = string.Format("Test Org [{0:yyyyMMddHHmmss}]", DateTime.Now),
                OrgTypeID   = 2
            };

            var result  = model.Save();
            var message = model.GetMessage();

            Assert.IsNull(message);
            Assert.IsTrue(result);

            var alog = DataSession.Query <ActiveLog>().FirstOrDefault(x => x.TableName == "Org" && x.Record == model.OrgID);

            Assert.IsNotNull(alog);
            Assert.AreEqual(alog.EnableDate, DateTime.Now.Date);
            Assert.IsNull(alog.DisableDate);

            Console.WriteLine(model.OrgID);
        }
示例#8
0
        /// <summary>
        /// 更新组织信息
        /// </summary>
        /// <param name="orgModel"></param>
        /// <returns></returns>
        public bool update(OrgModel orgModel)
        {
            using (SqlSugarClient db = BaseDB.GetClient())
            {
                try
                {
                    //db.BeginTran();//开启事务
                    //特别说明:在事务中,默认情况下是使用锁的,也就是说在当前事务没有结束前,其他的任何查询都需要等待
                    //ReadCommitted:在正在读取数据时保持共享锁,以避免脏读,但是在事务结束之前可以更改数据,从而导致不可重复的读取或幻像数据。
                    //db.BeginTran(System.Data.IsolationLevel.ReadCommitted); //重载指定事务的级别
                    db.BeginTran();//开始事物
                    db.Updateable <Organization>(orgModel.organization);

                    //组织关系表不会发生变化 不需要处理
                    //Dictionary<string, Object> updatec = new Dictionary<string, object>();
                    // updatec.Add("",)
                    // db.Updateable<OrganizationOrg>(updatec).Where(org=>org.orgid == orgModel.parentOrgId);
                    db.CommitTran();//提交事务
                    return(true);
                }
                catch (Exception ex)
                {
                    db.RollbackTran();//回滚
                    return(false);
                }
            }
        }
示例#9
0
        private static List <OrgModel> GetOrg(int idTeacher)
        {
            string          expressSql       = "getOrganization";
            List <OrgModel> allOrganizations = new List <OrgModel>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(expressSql, connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter teacherIdParam = new SqlParameter
                {
                    ParameterName = "@idTeacher",
                    Value         = idTeacher
                };
                command.Parameters.Add(teacherIdParam);
                var organizations = command.ExecuteReader();
                if (organizations.HasRows)
                {
                    while (organizations.Read())
                    {
                        OrgModel e = new OrgModel
                        {
                            IdOrganization   = organizations.GetInt32(0),
                            NameOrganization = organizations.GetString(1),
                            IdTeacher        = idTeacher
                        };
                        allOrganizations.Add(e);
                    }
                }
                organizations.Close();
                return(allOrganizations);
            }
        }
示例#10
0
 /// <summary>
 ///  获取工种分类
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <WorkTypeCount> GetWorkType(OrgModel model)
 {
     if (null == model)
     {
         return(null);
     }
     return(DBSession.IA02DAL.GetWorkType(model));
 }
示例#11
0
        public void SetOrgState(int orgId, bool state)
        {
            string   code  = GetCodeById(orgId);
            OrgModel model = new OrgModel {
                OrgCode = code, IsEnabled = state
            };

            DBProvider.dbMapper.Update("Organization.SetOrgState", model);
        }
示例#12
0
        /// <summary>
        /// 获取一个记录对象.
        /// </summary>
        public OrgModel GetById(int OrgId)
        {
            OrgModel model = DBProvider.OrgDAO.GetById(OrgId);

            if (model == null)
            {
                model = new OrgModel();
            }
            return(model);
        }
示例#13
0
        public ActionResult Create(string parentId)
        {
            var a = new OrgModel();

            if (parentId != null)
            {
                a.Parent = _factory.CreateOrgDao().Get(parentId);
            }
            return(View(a));
        }
示例#14
0
 /// <summary>
 /// 保存实体数据.
 /// </summary>
 public void Save(OrgModel model)
 {
     if (model.OrgId == 0)
     {
         DBProvider.OrgDAO.Add(model);
     }
     else
     {
         DBProvider.OrgDAO.Update(model);
     }
 }
示例#15
0
        public static string GetOrgNameTreeByOrgId(int parentOrgId, IList <OrgModel> orgList, string strTree)
        {
            OrgModel model = orgList.SingleOrDefault(o => o.OrgId == parentOrgId);

            if (model == null)
            {
                return(strTree);
            }
            strTree = model.OrgName + "—>" + strTree;
            return(GetOrgNameTreeByOrgId(model.ParentOrgId, orgList, strTree));
        }
示例#16
0
        public ActionResult CreateOrg(OrgModel OM)
        {
            DBController db = new DBController();

            OM.OrgID = db.Count_Orgs() + 1;

            //TODO
            OM.AdminID = 2;

            db.InsertOrg(OM);
            return(View());
        }
示例#17
0
        public int InsertOrg(OrgModel OM)
        {
            string StoredProcedureName = StoredProcedures.InsertOrg;

            Dictionary <string, object> Parameters = new Dictionary <string, object>();

            Parameters.Add("@OrgID", OM.OrgID);
            Parameters.Add("@OrgName", OM.OrgName);
            Parameters.Add("@AdminID", OM.AdminID);

            return(dbMan.ExecuteNonQuery(StoredProcedureName, Parameters));
        }
        public JsonResult report(string organisation, string workitemtype = "0", string projectName = "0")
        {
            if (workitemtype != "0")
            {
                c.WIcountType = GetWorkitemCountByType(organisation, workitemtype, projectName);
                org.counts    = c;
                return(Json(org, JsonRequestBehavior.AllowGet));
            }
            req = new APIRequest(Session["PAT"].ToString());
            string url;

            url = BaseURL + "/" + organisation + "/_apis/projects?api-version=" + version;
            string response = req.ApiRequest(url);

            org = JsonConvert.DeserializeObject <OrgModel>(response);
            countGen count = new countGen();

            org.counts     = new orgCounts();
            url            = BaseURL + "/" + organisation + "/_apis/process/processes?api-version=" + version;
            response       = req.ApiRequest(url);
            count          = JsonConvert.DeserializeObject <countGen>(response);
            c.processCount = count.Count;
            foreach (var project in org.Value)
            {
                url            = BaseURL + organisation + "/" + project.Name + "/_apis/build/definitions?api-version=" + version;
                response       = req.ApiRequest(url);
                project.counts = new orgCounts();
                count          = JsonConvert.DeserializeObject <countGen>(response);
                project.counts.buildDefCount = count.Count;
                c.buildDefCount += count.Count;
                url              = BaseURLvsrm + organisation + "/" + project.Name + "/_apis/release/definitions?api-version=" + version;
                response         = req.ApiRequest(url);
                count            = JsonConvert.DeserializeObject <countGen>(response);
                project.counts.releaseDefCount = count.Count;
                c.releaseDefCount += count.Count;
                url      = BaseURL + organisation + "/" + project.Name + "/_apis/git/repositories?api-version=" + version;
                response = req.ApiRequest(url);
                count    = JsonConvert.DeserializeObject <countGen>(response);
                project.counts.repoCount = count.Count;
                //c.repoCount += count.Count;
            }

            // Calling Repos Count
            AllReposCount(organisation);
            // Calling Users Count
            AllUsersCount(organisation);
            // Calling WorkitemsCount Count
            AllWorKitemsCount(organisation);
            WITypes(organisation);
            //Calling WorkItemCountByType
            org.counts = c;
            return(Json(org, JsonRequestBehavior.AllowGet));
        }
示例#19
0
        public List <WorkTypeCount> GetWorkType(OrgModel model)
        {
            sb?.Clear();
            sb.Append(string.Format(@"SELECT ISNULL(code1.E0386,'其他') AS E0386,A.numCount FROM
                (SELECT ISNULL(E0386,'00') AS E0386,COUNT(ISNULL(E0386,'00')) AS numCount FROM dbo.A01 WHERE UnitID=@UnitID GROUP BY E0386) A LEFT JOIN
                (SELECT CodeItemID,CodeItemName AS E0386 FROM dbo.SM_CodeItems WHERE CodeID='JA') code1 
                ON A.E0386=code1.CodeItemID "));
            _param?.Clear();
            _param.Add("@UnitID", model.orgid);
            DataTable dt = SqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, SqlHelper.GetParameters(_param));

            return(HCQ2_Common.Data.DataTableHelper.DataTableToIList <WorkTypeCount>(dt));
        }
示例#20
0
        public int GetDutyCountByOrgId(int orgId)
        {
            OrgModel          orgModel = DBProvider.OrgDAO.GetById(orgId);
            IList <Hashtable> list     = DBProvider.DutyDAO.GetAllDutyByOrgCode(orgModel.OrgCode);

            if (list != null)
            {
                return(list.Count);
            }
            else
            {
                return(0);
            }
        }
示例#21
0
        public ActionResult Save(OrgModel org)
        {
            if (ModelState.IsValid)
            {
                IOrgDao orgDao = _factory.CreateOrgDao();
                org.Save(orgDao);
                if (org.Parent == null)
                {
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Index", new { id = org.Parent.Id }));
            }

            return(View(String.IsNullOrEmpty(org.Id) ? "Create" : "Edit", org));
        }
示例#22
0
        public async Task <string> UpdateOrg(OrgModel myOrg)
        {
            DocumentReference           docRef  = _db.Collection("organizations").Document(myOrg.UId);
            Dictionary <string, object> updates = new Dictionary <string, object>();

            PropertyInfo[] properties = typeof(OrgModel).GetProperties();
            foreach (PropertyInfo property in properties)
            {
                updates.Add(property.Name, property.GetValue(myOrg));
            }

            await docRef.UpdateAsync(updates);

            return(docRef.Id);
        }
示例#23
0
        public ApiResult <bool> AddOrg(OrgModel org)
        {
            ApiResult <bool> apiResult   = new ApiResult <bool>();
            OrgModel         orgnization = org;

            if (org.organization.isroot)
            {
                org.parentOrgId = "-1";
            }
            bool res = orgManager.Add(orgnization);

            apiResult.Code    = res?ApiResultStatu.OK: ApiResultStatu.Error;
            apiResult.Success = res;
            apiResult.Data    = res;
            return(apiResult);
        }
示例#24
0
        public ActionResult ViewGroupOrgs(int GroupID)
        {
            DBController    dbController = new DBController();
            DataTable       dt           = dbController.SelectMyGroups(GroupID);
            List <OrgModel> Orgs         = new List <OrgModel>();

            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                OrgModel Org = new OrgModel();
                Org.OrgName = Convert.ToString(dt.Rows[i]["OrganizationName"]);
                Org.OrgID   = int.Parse(Convert.ToString(dt.Rows[i]["OrganizationID"]));
                Org.AdminID = Convert.ToInt32(dt.Rows[i]["AdminID"]);

                Orgs.Add(Org);
            }
            return(View(Orgs));
        }
示例#25
0
 public bool delete(OrgModel orgModel)
 {
     try
     {
         using (SqlSugarClient db = BaseDB.GetClient())
         {
             db.BeginTran();//开始事物
             db.Deleteable <Organization>(orgModel.organization).ExecuteCommand();
             db.Deleteable <OrganizationOrg>().Where(orgo => orgo.orgid == orgModel.parentOrgId).ExecuteCommand();
             db.CommitTran();//提交事务
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#26
0
        public ActionResult Save(OrgModel org, FormCollection collection)
        {
            try
            {
                //org.AppendInfo.OfficeAddress = collection["OfficeAddress"];
                //org.AppendInfo.OfficeFax = collection["OfficeFax"];
                //org.AppendInfo.OfficeTel = collection["OfficeTel"];
                //org.AppendInfo.BusinessType = Convert.ToInt16(collection["BusinessType"]);
                //org.AppendInfo.OrgLeader = Convert.ToInt16(collection["OrgLeader"]);
                //org.AppendInfo.OrgType = int.Parse(collection["OrgType"]);

                ServiceProvider.OrgService.Save(org);
                return(Content("OK"));
            }
            catch (Exception e)
            {
                return(Content(e.Message));
            }
        }
示例#27
0
        public async Task getOrgData()
        {
            progress = new Android.App.ProgressDialog(this);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            //dynamic value = new ExpandoObject();
            //value.OrgId = orgid;

            //   string json = JsonConvert.SerializeObject(value);
            try
            {
                string item = await restservice.OrgnizationList(this, "", location);

                //orgmodel[0].organizationName = "Select Orgnization";
                orgmodel = JsonConvert.DeserializeObject <List <OrgModel> >(item);
                orgmodel[0].organizationName = "Select Organization";
                for (int i = 0; i < orgmodel.Count; i++)
                {
                    OrgModel org = new OrgModel();
                    //org.organizationName=orgmodel[0].
                    org.organizationName = orgmodel[i].organizationName;
                    orgname.Add(org);
                }
                //  db.InsertMarkingList(orgmodel);

                progress.Dismiss();

                spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Selectorg_ItemSelected);
                ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, orgname);
                spinner.Adapter = adapter;

                //  getorglist()
            }

            catch (Exception ex)
            {
                progress.Dismiss();
            }
        }
示例#28
0
        /// <summary>
        /// 根据用户管理的部门获取管理的部门及上级部门,并组装成树形结构
        /// </summary>
        /// <param name="ownList"></param>
        /// <returns></returns>
        public string GetParentdhtmlxTree(IList <OrgModel> ownList)
        {
            StringBuilder sb = new StringBuilder();

            if (ownList.Count == 0)
            {
                sb.Append("<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine);
                sb.AppendFormat("<tree id='0'><item text='无管理部门,请联系系统管理员' > </item>" + Environment.NewLine);
                sb.Append("</tree>");
                return(sb.ToString());
            }

            IList <OrgModel> orgList = DBProvider.OrgDAO.GetAll();

            //管理员账号设置为GRGT,则获取所有子节点
            if (ownList[0].OrgCode == "GRGT")
            {
                return(GetdhtmlxTree(orgList));
            }
            //找出上级部门
            IList <OrgModel> newList = new List <OrgModel>();
            Hashtable        ht      = new Hashtable();

            foreach (OrgModel org in ownList)
            {
                OrgModel model = new OrgModel();
                model.OrgId       = org.OrgId;
                model.OrgName     = org.OrgName;
                model.OrgCode     = org.OrgCode;
                model.ParentOrgId = org.ParentOrgId;
                ht.Add(org.OrgCode, org.OrgCode);
                newList.Add(model);
                RecursiveOwnDump(orgList, model.ParentOrgId, newList, ht);
            }
            sb.Append("<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine);
            sb.AppendFormat("<tree id='0'>" + Environment.NewLine);
            RecursiveDump(newList, 0, 1, sb);
            sb.Append("</tree>");

            return(sb.ToString());
        }
        public void AllWorKitemsCount(string organisation)
        {
            APIRequest req;
            OrgModel   org = new OrgModel();
            string     url;

            try
            {
                object       Wiql  = new { query = "Select  [Id] From WorkItems" };
                ProjectModel model = new ProjectModel();
                url = "https://dev.azure.com/" + organisation + "/_apis/wit/wiql?api-version=5.1";
                req = new APIRequest(Session["PAT"].ToString());
                string response = req.ApiRequest(url, "POST", JsonConvert.SerializeObject(Wiql));
                model        = JsonConvert.DeserializeObject <ProjectModel>(response);
                c.WIcountOrg = model.WorkItems.Count;
            }
            catch (Exception)
            {
            }

            //return org;
        }
示例#30
0
        public async Task <IActionResult> AddOrg([FromBody] OrgModel b)
        {
            try
            {
                Organization org = new Organization
                {
                    RegistedDate = DateTime.Now,
                    IsActive     = true,
                    OrgName      = b.Org_Name,
                    OrgLocation  = b.Org_Location,
                };

                _context.organizations.Add(org);
                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception e)
            {
                throw e;
            }
        }