예제 #1
0
        /// <summary>
        /// 组织架构修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonModel EditOrg(Org_Mechanism model)
        {
            JsonModel jsonModel = new UCSModel.JsonModel();
            string    result    = dal.EditOrg(model);

            if (result == "")
            {
                jsonModel = new JsonModel
                {
                    errNum  = 0,
                    errMsg  = "添加成功",
                    retData = ""
                };
            }
            else
            {
                jsonModel = new JsonModel
                {
                    errNum  = 999,
                    errMsg  = result,
                    retData = ""
                };
            }
            return(jsonModel);
        }
예제 #2
0
        /// <summary>
        /// 删除组织机构
        /// </summary>
        /// <param name="OrgID">ID</param>
        /// <returns></returns>
        public JsonModel DeleteOrg(int OrgID)
        {
            JsonModel jsonModel = new UCSModel.JsonModel();
            string    result    = dal.DeleteOrg(OrgID);

            if (result == "")
            {
                jsonModel = new JsonModel
                {
                    errNum  = 0,
                    errMsg  = "删除成功",
                    retData = ""
                };
            }
            else
            {
                jsonModel = new JsonModel
                {
                    errNum  = 999,
                    errMsg  = result,
                    retData = ""
                };
            }
            return(jsonModel);
        }
예제 #3
0
        /// <summary>
        /// 组织架构排序修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonModel EditOrgOrder(int OrgID, string OrderType)
        {
            JsonModel jsonModel = new UCSModel.JsonModel();
            string    result    = dal.EditOrgOrder(OrgID, OrderType);

            if (result == "")
            {
                jsonModel = new JsonModel
                {
                    errNum  = 0,
                    errMsg  = "操作成功",
                    retData = ""
                };
            }
            else
            {
                jsonModel = new JsonModel
                {
                    errNum  = 999,
                    errMsg  = result,
                    retData = ""
                };
            }
            return(jsonModel);
        }
예제 #4
0
        /// <summary>
        /// 统计不同类型组织机构数目
        /// </summary>
        /// <returns></returns>
        public JsonModel censusOrg(string OrganType)
        {
            JsonModel jsonModel = new UCSModel.JsonModel();
            int       result    = dal.censusOrg(OrganType);

            //if (result !=0)
            //{
            jsonModel = new JsonModel
            {
                errNum  = 0,
                errMsg  = "",
                retData = result.ToString()
            };
            //}
            //else
            //{
            //    jsonModel = new JsonModel
            //    {
            //        errNum = 999,
            //        errMsg = result.ToString(),
            //        retData = ""
            //    };
            //}
            return(jsonModel);
        }
예제 #5
0
        protected override void OnInit(EventArgs e)
        {
            string LoginPage = ConfigHelper.GetConfigString("LoginPage.ucc");

            try
            {
                //登陆页地址 从Web.config 读取
                string action = Request["action"];
                if (!string.IsNullOrEmpty(action) && action == "loginOut")   //退出登录
                {
                    Response.Cookies["LoginCookie_Author"].Expires = DateTime.Now.AddDays(-3);
                    Response.Cookies["ClassID"].Expires            = DateTime.Now.AddDays(-3);
                    Response.Cookies["TokenID"].Expires            = DateTime.Now.AddDays(-3);
                    //跳转登陆页面
                    Response.Redirect(LoginPage);
                }
                else
                {
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    if (Request.Cookies["LoginCookie_Author"] != null && !string.IsNullOrWhiteSpace(Request.Cookies["LoginCookie_Author"].Value))
                    {
                        string loginCookie         = System.Web.HttpUtility.UrlDecode(Request.Cookies["LoginCookie_Author"].Value);
                        UCSModel.Sys_UserInfo item = jss.Deserialize <UCSModel.Sys_UserInfo>(loginCookie);
                        UserInfo = item;
                        //SetPageButton();
                    }
                    else if (Request.Cookies["TokenID"] != null && !string.IsNullOrWhiteSpace(Request.Cookies["TokenID"].Value))
                    {
                        #region
                        var    postData = "&Func=GetUserInfoByToken&tokenID=" + System.Web.HttpUtility.UrlDecode(Request.Cookies["TokenID"].Value) + "&returnUrl=" + Request.Url.ToString();
                        string result   = NetHelper.RequestPostUrl(ConfigHelper.GetSettingString("TokenPath"), postData);

                        if (!string.IsNullOrWhiteSpace(result))
                        {
                            int starIndex = result.IndexOf(":") + 1;
                            int endIndex  = result.LastIndexOf("}");
                            result = result.Substring(starIndex, endIndex - starIndex);
                            UCSModel.JsonModel jsonModel = jss.Deserialize <UCSModel.JsonModel>(result);
                            if (jsonModel != null && jsonModel.retData != null && jsonModel.errNum == 0)
                            {
                                Dictionary <string, object> ht = jsonModel.retData as Dictionary <string, object>;
                                if (ht != null)
                                {
                                    Sys_User item = new Sys_User();
                                    System.Reflection.PropertyInfo[] properties = item.GetType().GetProperties();
                                    foreach (System.Reflection.PropertyInfo property in properties)
                                    {
                                        if (ht.ContainsKey(property.Name))
                                        {
                                            //object obj = property.GetValue(item, null);
                                            //object obj2 = property.GetValue(item, DBNull.Value);
                                            //property.SetValue(item, property.GetValue(item,null), null);
                                            if (property.PropertyType.Name.StartsWith("String"))
                                            {
                                                property.SetValue(item, ht[property.Name].SafeToString(), null);
                                            }
                                            if (property.PropertyType.Name.StartsWith("Int32"))
                                            {
                                                if (string.IsNullOrWhiteSpace(Convert.ToString(ht[property.Name])))
                                                {
                                                    property.SetValue(item, -999999, null);
                                                }
                                                else
                                                {
                                                    property.SetValue(item, Convert.ToInt32(ht[property.Name]), null);
                                                }
                                            }
                                            if (property.PropertyType.Name.StartsWith("DateTime"))
                                            {
                                                if (string.IsNullOrWhiteSpace(Convert.ToString(ht[property.Name])))
                                                {
                                                    property.SetValue(item, Convert.ToDateTime("1900-01-01"), null);
                                                }
                                                else
                                                {
                                                    property.SetValue(item, Convert.ToDateTime(ht[property.Name]), null);
                                                }
                                            }
                                            if (property.PropertyType.Name.StartsWith("Byte"))
                                            {
                                                if (string.IsNullOrWhiteSpace(Convert.ToString(ht[property.Name])))
                                                {
                                                    property.SetValue(item, Convert.ToByte(255), null);
                                                }
                                                else
                                                {
                                                    property.SetValue(item, Convert.ToByte(ht[property.Name]), null);
                                                }
                                            }
                                        }
                                    }

                                    List <Sys_User> list = new List <Sys_User>();
                                    list.Add(item);
                                    var items = from c in list.AsEnumerable()
                                                select new UCSModel.Sys_UserInfo()
                                    {
                                        Id          = c.Id,
                                        Address     = c.Address,
                                        Birthday    = c.Birthday,
                                        UserType    = c.UserType,
                                        AuthenType  = c.AuthenType,
                                        CheckMsg    = c.CheckMsg,
                                        CreateTime  = c.CreateTime,
                                        CreateUID   = c.CreateUID,
                                        EditTime    = c.EditTime,
                                        EditUID     = c.EditUID,
                                        HeadPic     = c.HeadPic,
                                        IDCard      = c.IDCard,
                                        IsDelete    = c.IsDelete,
                                        IsEnable    = c.IsEnable,
                                        LoginName   = c.LoginName,
                                        Name        = c.Name,
                                        Nickname    = c.Nickname,
                                        Password    = c.Password,
                                        Phone       = c.Phone,
                                        RegisterOrg = c.RegisterOrg,
                                        Remarks     = c.Remarks,
                                        Sex         = c.Sex,
                                        UniqueNo    = c.UniqueNo
                                    };
                                    UserInfo = items.ToList().Find(o => o.Id != null);
                                    if (Convert.ToDateTime(UserInfo.Birthday).ToString("yyyy-MM-dd") == "1990-01-01")
                                    {
                                        UserInfo.Birthday = null;
                                    }
                                    if (Convert.ToDateTime(UserInfo.CreateTime).ToString("yyyy-MM-dd") == "1990-01-01")
                                    {
                                        UserInfo.EditTime = null;
                                    }
                                    if (Convert.ToDateTime(UserInfo.EditTime).ToString("yyyy-MM-dd") == "1990-01-01")
                                    {
                                        UserInfo.EditTime = null;
                                    }
                                    if (UserInfo.UserType == 255)
                                    {
                                        UserInfo.UserType = null;
                                    }
                                    if (UserInfo.AuthenType == 255)
                                    {
                                        UserInfo.AuthenType = 255;
                                    }
                                    if (UserInfo.IsDelete == 255)
                                    {
                                        UserInfo.IsDelete = null;
                                    }
                                    if (UserInfo.IsEnable == 255)
                                    {
                                        UserInfo.IsEnable = null;
                                    }
                                    if (UserInfo.Sex == 255)
                                    {
                                        UserInfo.Sex = null;
                                    }
                                    Response.Cookies["LoginCookie_Author"].Value = HttpUtility.UrlEncode(JsonHelper.SerializeObject(UserInfo));
                                    Response.Cookies["username"].Expires         = DateTime.MaxValue;
                                }
                                //SetPageButton();
                                if (Request.Url.ToString().IndexOf("Login.aspx") > -1 || Request.Url.ToString().IndexOf("Resgister.aspx") > -1)
                                {
                                    Response.Write("<script language='javascript'>window.location='/Index.aspx'</script>");
                                }
                                // Response.Redirect("~/Index.aspx");
                                else
                                {
                                    Response.Write("<script language='javascript'>window.location='" + Request.Url.ToString() + "'</script>");
                                }
                                //Response.Redirect(Request.Url.ToString());
                            }
                            else
                            {
                                Response.Cookies["LoginCookie_Author"].Expires = DateTime.Now.AddDays(-3);
                                Response.Cookies["ClassID"].Expires            = DateTime.Now.AddDays(-3);
                                Response.Cookies["TokenID"].Expires            = DateTime.Now.AddDays(-3);
                                Response.Redirect(LoginPage);

                                // Response.Write("<script>window.location.href='/Login.aspx'</script>");
                                //Response.Redirect("~/Resgister.aspx");
                                //Response.Write("<script language='javascript'>window.location='/Resgister.aspx'</script>");
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        Response.Cookies["LoginCookie_Author"].Expires = DateTime.Now.AddDays(-3);
                        Response.Cookies["ClassID"].Expires            = DateTime.Now.AddDays(-3);
                        Response.Cookies["TokenID"].Expires            = DateTime.Now.AddDays(-3);

                        //Response.Redirect("~/Login.aspx");
                        Response.Redirect(LoginPage);
                    }
                    // base.OnInit(e);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                //Response.Redirect("~/Login.aspx");
                Response.Redirect(LoginPage);
            }
        }