Esempio n. 1
0
        public JsonResult GetTree()
        {
            DataTable dt = proxy.GetLoginPictureTree();

            string strPath = Request.PhysicalApplicationPath;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["type"].ToString() == "1")
                {
                    if (!System.IO.File.Exists(strPath + dt.Rows[i]["src"].ToString()) && dt.Rows[i]["attachid"] != DBNull.Value)
                    {
                        try
                        {
                            byte[] buffer = NG3UploadFileService.NG3GetEx("", (long)dt.Rows[i]["attachid"]);
                            System.IO.File.WriteAllBytes(strPath + dt.Rows[i]["src"].ToString(), buffer);
                        }
                        catch { }
                    }
                }
            }

            string filter             = "(pid is null or pid='')";
            IList <TreeJSONBase> list = new LoginPicManagerSelectedTreeBuilder().GetExtTreeList(dt, "pid", "id", filter, TreeDataLevelType.TopLevel);

            return(this.Json(list, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public string ReplaceIconUpload(string id, string name, string tag, string attachid)
        {
            try
            {
                name = Guid.NewGuid().ToString() + name.Substring(name.LastIndexOf("."));

                string             strPath  = "NG3Resource\\CustomIcons\\";
                string             dirPath  = Request.PhysicalApplicationPath + strPath;
                HttpPostedFileBase imgFile  = Request.Files["replaceCustomIcon"];
                string             filePath = dirPath + name;
                imgFile.SaveAs(filePath);

                if (!string.IsNullOrEmpty(attachid))
                {
                    byte[] buffer = GetFileData(filePath);
                    NG3UploadFileService.NG3ModifyEx("", long.Parse(attachid), buffer);
                }

                return(JsonConvert.SerializeObject(proxy.ReplaceFuncIcon(id, name, tag)));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 3
0
        public string AttachUpload(string src)
        {
            string     path = Request.PhysicalApplicationPath + src;
            FileStream fs   = new FileStream(path, FileMode.Open, FileAccess.Read);

            byte[] buffer;
            try
            {
                buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
            }
            catch
            {
                return("");
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            string  result = NG3UploadFileService.NG3UploadEx("", buffer);
            JObject jo     = (JObject)JsonConvert.DeserializeObject(result);

            if (jo["success"] != null && jo["success"].ToString() == "true")
            {
                return(jo["phid"].ToString());
            }
            else
            {
                return("");
            }
        }
Esempio n. 4
0
        public string SaveOneAttach()
        {
            string tablename = System.Web.HttpContext.Current.Request.Params["tablename"];
            string busguid   = System.Web.HttpContext.Current.Request.Params["busguid"];
            string phid      = System.Web.HttpContext.Current.Request.Params["phid"];
            string asrflg    = System.Web.HttpContext.Current.Request.Params["asrflg"]; //1有附件;0无附件;3附件标志无变化

            //附件保存
            string saveparms = string.Empty;

            if (!string.IsNullOrEmpty(busguid) && busguid.Length > 30)  //guid长度为36
            {
                saveparms += busguid + "||" + phid + "@@##";
            }

            if (!string.IsNullOrEmpty(saveparms))
            {
                saveparms = saveparms.TrimEnd('#', '@');
                NG3UploadFileService.BatchSave(saveparms, NG3.AppInfoBase.UserConnectString);
            }

            //更新表上的附件标志asr_flg
            int iret = 0;

            if (asrflg != "3")
            {
                DataTable dt = DbHelper.GetDataTable(string.Format("select * from {0} where 1=2", tablename));

                if (dt.Columns.Contains("asr_flg"))
                {
                    iret = DbHelper.ExecuteNonQuery(string.Format("update {0} set asr_flg = {1} where phid = {2}", tablename, asrflg, phid));
                }
            }

            JObject jResult = new JObject();

            if (iret != -1)
            {
                jResult.Add("status", "OK");
                return(JsonConvert.SerializeObject(jResult));
            }
            else
            {
                jResult.Add("status", "Fail");
                return(JsonConvert.SerializeObject(jResult));
            }
        }
Esempio n. 5
0
        string AttachUpload(byte[] buffer)
        {
            if (buffer == null)
            {
                return("");
            }

            string  result = NG3UploadFileService.NG3UploadEx("", buffer);
            JObject jo     = (JObject)JsonConvert.DeserializeObject(result);

            if (jo["success"] != null && jo["success"].ToString() == "true")
            {
                return(jo["phid"].ToString());
            }
            else
            {
                return("");
            }
        }
Esempio n. 6
0
        public bool DelFuncIcon(string id)
        {
            try
            {
                bool deletable = dac.CheckDelFuncIcon(id);
                if (deletable)
                {
                    DataTable dt   = dac.GetFuncIconDtByPhid(id);
                    string    tag  = dt.Rows[0]["tag"].ToString();
                    string    name = dt.Rows[0]["name"].ToString();

                    //删除图标文件
                    string path = AppDomain.CurrentDomain.BaseDirectory + @"NG3Resource\CustomIcons";
                    if (File.Exists(path + "\\" + name))
                    {
                        File.Delete(path + "\\" + name);
                    }

                    //删除附件表存储数据
                    if (dt.Rows[0]["attachid"] != DBNull.Value)
                    {
                        try
                        {
                            NG3UploadFileService.NG3Del("", (long)dt.Rows[0]["attachid"]);
                        }
                        catch { }
                    }

                    return(dac.DelFuncIcon(id, tag));
                }
                else
                {
                    return(deletable);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 7
0
        public void DelNode(string phid)
        {
            try
            {
                string    rootpath = AppDomain.CurrentDomain.BaseDirectory;
                DataTable dt       = dac.GetLoginPicture(phid);

                //图片节点需要删除图片文件以及附件表存储数据
                if (dt.Rows[0]["type"].ToString() == "1")
                {
                    if (!string.IsNullOrEmpty(dt.Rows[0]["src"].ToString()))
                    {
                        string src  = dt.Rows[0]["src"].ToString();
                        string path = Path.Combine(rootpath, src);
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                    }

                    if (dt.Rows[0]["attachid"] != DBNull.Value)
                    {
                        try
                        {
                            NG3UploadFileService.NG3Del("", (long)dt.Rows[0]["attachid"]);
                        }
                        catch { }
                    }
                }

                dac.DelNode(phid);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 注意,默认tab和设置是分别加载,一起保存
        /// </summary>
        /// <returns></returns>
        public string SaveDefaultOpenTab()
        {
            string defaultOpenTab = System.Web.HttpContext.Current.Request.Form["defaultOpenTab"];
            //string userid = System.Web.HttpContext.Current.Request.Form["userid"];
            long userid = AppInfoBase.UserID;
            //保存默认tab页设置
            DataTable defaultOpenTabTable = DataConverterHelper.ToDataTable(defaultOpenTab, "select * from fg3_defaultopen_tab");
            int       iret1 = proxy.SaveDefaultOpenTab(userid, defaultOpenTabTable);
            //保存系统设置
            string individualSetting = System.Web.HttpContext.Current.Request.Form["individualSetting"];
            bool   iret2             = proxy.SaveSysSetting(userid, individualSetting);

            if (String.Compare(AppInfoBase.UserType, UserType.System, true) == 0)
            {
                //保存管理员权限下的路由设置和显示设置,注意这两个会改了数据库连接串,不再连0002
                string ServerIpAndNetWorkIpConfig = System.Web.HttpContext.Current.Request.Form["ServerIpAndNetWorkIpConfig"];
                string DisplaySetting             = System.Web.HttpContext.Current.Request.Form["DisplaySetting"];
                this.SaveServerIpAndNetWorkIpConfig(ServerIpAndNetWorkIpConfig);
                this.SaveDisplaySetting(DisplaySetting);
            }

            //保存小铃铛设置
            string alertconfig = System.Web.HttpContext.Current.Request.Form["alertconfig"];
            bool   iret3       = proxy.SaveAlertItem(alertconfig);
            //bool iret3 = this.SaveAlertItem(alertconfig);

            //保存换肤设置
            string uitheme     = System.Web.HttpContext.Current.Request.Form["uitheme"];
            int    tempuitheme = 0;

            Int32.TryParse(uitheme.ToString(), out tempuitheme);
            bool iret4 = MenuConfigProxy.SaveUITheme(tempuitheme, userid);

            ////保存登陆单位信息
            //string SSOOrgValue = System.Web.HttpContext.Current.Request.Form["SSOOrgValue"];
            //proxy.SetSSOOrg(SSOOrgValue);

            //保存APP启动页Logo
            string APPlogo  = System.Web.HttpContext.Current.Request.Form["APPlogo"];
            string filePath = Request.PhysicalApplicationPath + "NG3Resource\\APPLogo\\" + APPlogo;
            bool   iret5    = true;

            if (!string.IsNullOrEmpty(APPlogo) && System.IO.File.Exists(filePath))
            {
                byte[] buffer;
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    buffer = new byte[fs.Length];
                    fs.Read(buffer, 0, (int)fs.Length);
                }

                string attachid = proxy.GetAPPLogoAttachId();
                try
                {
                    if (string.IsNullOrEmpty(attachid))
                    {
                        string  result = NG3UploadFileService.NG3UploadEx("", buffer);
                        JObject jo     = (JObject)JsonConvert.DeserializeObject(result);

                        if (jo["success"] != null && jo["success"].ToString() == "true")
                        {
                            attachid = jo["phid"].ToString();
                        }
                        else
                        {
                            return("{status : \"error\", msg: \"APPLogo上传到附件出错\"}");
                        }
                    }
                    else
                    {
                        NG3UploadFileService.NG3ModifyEx("", long.Parse(attachid), buffer);
                    }
                }
                catch
                {
                    return("{status : \"error\", msg: \"APPLogo上传到附件出错\"}");
                }

                iret5 = proxy.SaveAPPLogo(APPlogo, attachid);
                if (iret5)
                {
                    string dirPath = Request.PhysicalApplicationPath + "NG3Resource\\APPLogo";
                    if (Directory.Exists(dirPath))
                    {
                        Directory.Delete(dirPath, true);
                    }
                }
            }

            if (iret1 >= 0 && iret2 && iret3 && iret4 && iret5)
            {
                return("{status : \"ok\"}");
            }
            else
            {
                return("{status : \"error\"}");
            }
        }
Esempio n. 9
0
        public DataTable GetFuncIcons(bool buildinIconShow, bool customIconShow, string tag, ref int totalRecord)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.TableName = "FuncIcons";

                dt.Columns.Add(new DataColumn("id", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("name", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("src", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("tag", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("icontype", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("attachid", Type.GetType("System.String")));

                DataRow row;
                string  path;
                string  srcPre = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host
                                 + ":" + HttpContext.Current.Request.Url.Port + "/" + HttpContext.Current.Request.Url.Segments[1];
                DataTable iconDt;

                if (buildinIconShow)
                {
                    path = AppDomain.CurrentDomain.BaseDirectory + @"NG3Resource\FuncIcons";
                    if (Directory.Exists(path))
                    {
                        iconDt       = dac.GetIconDt("0");
                        totalRecord += iconDt.Rows.Count;
                        for (int i = 0; i < iconDt.Rows.Count; i++)
                        {
                            row             = dt.NewRow();
                            row["id"]       = iconDt.Rows[i]["phid"];;
                            row["name"]     = iconDt.Rows[i]["name"];
                            row["src"]      = srcPre + "/NG3Resource/FuncIcons/" + row["name"];
                            row["tag"]      = iconDt.Rows[i]["tag"];
                            row["icontype"] = "0";
                            dt.Rows.Add(row);
                        }
                    }
                }

                if (customIconShow)
                {
                    path = AppDomain.CurrentDomain.BaseDirectory + @"NG3Resource\CustomIcons";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    if (Directory.Exists(path))
                    {
                        iconDt       = dac.GetIconDt("1");
                        totalRecord += iconDt.Rows.Count;
                        for (int i = 0; i < iconDt.Rows.Count; i++)
                        {
                            row         = dt.NewRow();
                            row["id"]   = iconDt.Rows[i]["phid"];
                            row["name"] = iconDt.Rows[i]["name"];
                            row["src"]  = srcPre + "/NG3Resource/CustomIcons/" + row["name"];
                            if (File.Exists(path + "\\" + row["name"]))
                            {
                                row["tag"]      = iconDt.Rows[i]["tag"];
                                row["icontype"] = "1";
                                row["attachid"] = iconDt.Rows[i]["attachid"];
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                if (iconDt.Rows[i]["attachid"] != DBNull.Value)
                                {
                                    try
                                    {
                                        byte[] buffer = NG3UploadFileService.NG3GetEx("", (long)iconDt.Rows[i]["attachid"]);
                                        File.WriteAllBytes(path + "\\" + row["name"], buffer);

                                        row["tag"]      = iconDt.Rows[i]["tag"];
                                        row["icontype"] = "1";
                                        row["attachid"] = iconDt.Rows[i]["attachid"];
                                        dt.Rows.Add(row);
                                    }
                                    catch
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }

                if (tag != "")
                {
                    DataView dv = dt.DefaultView;
                    dv.RowFilter = "tag like '%" + tag + ";%'";
                    dt           = dv.ToTable();
                    totalRecord  = dt.Rows.Count;
                }

                return(dt);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }