예제 #1
0
        public ActionResult PushDllAdd(string pd_id)
        {
            if (String.IsNullOrEmpty(pd_id))
            {
                SMC_PushDll dll = new SMC_PushDll();
                dll.pd_createdtime = DateTime.Now;
                dll.pd_status      = false;
                BoFactory.GetSMC_PushDllBO.Insert(dll);
                ViewData["pd_id"] = dll.pd_id;
                Hashtable initialFiles = new Hashtable();
                initialFiles["files"] = new ArrayList();
                string fstr = Newtonsoft.Json.JsonConvert.SerializeObject(new ArrayList(), Newtonsoft.Json.Formatting.Indented);
                ViewData["f"] = fstr;
                string entity_fstr = Newtonsoft.Json.JsonConvert.SerializeObject(dll, Newtonsoft.Json.Formatting.Indented);
                ViewData["entity"] = entity_fstr;
            }
            else
            {
                ViewData["pd_id"] = pd_id;
                SMC_PushDll _dll         = BoFactory.GetSMC_PushDllBO.Get(int.Parse(pd_id));
                Hashtable   initialFiles = new Hashtable();
                initialFiles["name"]      = _dll.pd_zip_filename;
                initialFiles["extension"] = _dll.pd_zip_extension;
                initialFiles["size"]      = _dll.pd_zip_size;
                string fstr = Newtonsoft.Json.JsonConvert.SerializeObject(initialFiles, Newtonsoft.Json.Formatting.Indented);
                ViewData["f"] = "[" + fstr + "]";

                string entity_fstr = Newtonsoft.Json.JsonConvert.SerializeObject(_dll, Newtonsoft.Json.Formatting.Indented);
                ViewData["entity"] = entity_fstr;
            }
            return(View());
        }
예제 #2
0
        public ActionResult PushDllAddPost(string pd_id, string pd_name, string pd_dll_filename, string pd_xml_filename)
        {
            Hashtable p = new Hashtable();

            if (!String.IsNullOrEmpty(pd_id))
            {
                int         _pd_id = int.Parse(pd_id);
                SMC_PushDll dll    = BoFactory.GetSMC_PushDllBO.Get(int.Parse(pd_id));
                dll.pd_name         = pd_name;
                dll.pd_dll_filename = pd_dll_filename;
                dll.pd_xml_filename = pd_xml_filename;
                dll.pd_updatetime   = DateTime.Now;

                bool existsXml = BoFactory.GetSMC_PushDllBO.ExistsXml(dll);
                if (existsXml)
                {
                    p["r"] = false;
                    p["d"] = "插件Job配置文件已存在,请检查是否重复!";
                    return(Json(p));
                }

                dll.pd_status = true;
                BoFactory.GetSMC_PushDllBO.Update(dll);
                p["r"] = true;
                p["d"] = "保存插件成功!";
            }
            else
            {
                p["r"] = false;
                p["d"] = "保存插件成功!";
            }
            return(Json(p));
        }
예제 #3
0
        public ActionResult PushDllDeleteFile(string pd_id)
        {
            Hashtable r = new Hashtable();

            SMC_PushDll dll = BoFactory.GetSMC_PushDllBO.Get(int.Parse(pd_id));

            if (dll != null)
            {
                string path = Server.MapPath("~/PushZipPacks/") + dll.pd_id + "\\";
                try
                {
                    System.IO.Directory.Delete(path, true);
                    r["result"] = true;
                }
                catch (Exception ex)
                {
                    r["result"] = false;
                }
            }
            else
            {
                r["result"] = false;
            }

            return(Json(r));
        }
예제 #4
0
        public ActionResult JobCommandCtrl(FormCollection form)
        {
            JsonReturnMessages data = new JsonReturnMessages()
            {
                IsSuccess = true, Msg = ""
            };
            string s1     = form["JosType"];
            string s2     = form["ComdArgs"];
            string spd_id = form["pd_id"];
            int    pd_id  = 0;

            if (!String.IsNullOrEmpty(spd_id))
            {
                pd_id = int.Parse(spd_id);
            }
            SMC_PushDll dll = BoFactory.GetSMC_PushDllBO.Get(pd_id);

            s2 = dll.pd_xml_filename + ".xml" + s2;
            string rtv = "";

            if (s1 == "AddJobPluginGroup")
            {
                TransferFile(dll);
            }
            if (s1 != "" && s2 != "")
            {
                try
                {
                    CommandSvcClient cmdClient = new CommandSvcClient();

                    rtv = cmdClient.ExecCommand(s1, s2);

                    if (rtv == "文件名参数不正确,请重试!")
                    {
                        data.IsSuccess = false;
                        data.Msg       = rtv;
                    }
                    cmdClient.Close();
                }
                catch (Exception e)
                {
                    data.IsSuccess = false;
                    data.Msg       = e.Message;
                }
                if (data.IsSuccess)
                {
                    data.Msg = rtv;
                }

                changeDllStatus(dll, s1, data.IsSuccess);
            }
            else
            {
                data.Msg = "请选择任务类型和输入参数文件名!";
            }


            return(Json(data));
        }
예제 #5
0
 public virtual void Save(SMC_PushDll entity)
 {
     if (SMC_PushDllDAO.Get(entity.pd_id) == null)
     {
         SMC_PushDllDAO.Insert(entity);
     }
     else
     {
         SMC_PushDllDAO.Update(entity);
     }
 }
예제 #6
0
        //[Frame(false, false)]
        //public virtual void InsertBatch(IList<SMC_Role> roles, int batchSize)
        //{
        //    try
        //    {
        //        SMC_RoleDao.InsertBatch(roles, batchSize);
        //    }
        //    catch (DalException ex)
        //    {
        //        throw new BOException("调用方法InsertBatch失败", ex);
        //    }
        //}

        public virtual bool ExistsXml(SMC_PushDll entity)
        {
            try
            {
                return(SMC_PushDllDAO.ExistsXml(entity));
            }
            catch (DalException ex)
            {
                throw new BOException("调用方法ExistsXml失败", ex);
            }
        }
예제 #7
0
 public virtual void Update(SMC_PushDll role)
 {
     try
     {
         SMC_PushDllDAO.Update(role);
     }
     catch (DalException ex)
     {
         throw new BOException("调用方法Update失败", ex);
     }
 }
예제 #8
0
 public virtual void Insert(SMC_PushDll role)
 {
     try
     {
         int maxid = SMC_PushDllDAO.GetMaxID();
         role.pd_id = maxid + 1;
         SMC_PushDllDAO.Insert(role);
     }
     catch (DalException ex)
     {
         throw new BOException("调用方法Insert失败", ex);
     }
 }
예제 #9
0
 public virtual void Delete(SMC_PushDll entity)
 {
     try
     {
         SMC_PushDllDAO.Delete(entity);
         string path = HttpContext.Current.Server.MapPath("~/PushZipPacks/") + entity.pd_id + "\\";
         if (System.IO.Directory.Exists(path))
         {
             System.IO.Directory.Delete(path, true);
         }
     }
     catch (DalException ex)
     {
         throw new BOException("????????????", ex);
     }
 }
예제 #10
0
        private void TransferFile(SMC_PushDll dll)
        {
            if (dll == null)
            {
                return;
            }

            string path = dll.pd_path + dll.pd_zip_filename;

            if (!System.IO.File.Exists(path))
            {
                return;
            }
            FileStream         fs   = new FileStream(path, FileMode.Open);
            FileTransSvcClient ftsc = new FileTransSvcClient();

            ftsc.Open();

            #region   文件

            FileUploadMessage myFileMessage = new FileUploadMessage();

            myFileMessage.FileName = dll.pd_zip_filename;//"PushSharp-master.zip"; //文件名
            {
                myFileMessage.FileData = fs;
                IFileTransSvc intfFileTrans = ftsc.ChannelFactory.CreateChannel();
                try
                {
                    intfFileTrans.UploadFileMethod(myFileMessage);
                }
                catch { }
                finally
                {
                    fs.Close();
                    fs.Dispose();
                }
            }

            #endregion



            ftsc.Close();
        }
예제 #11
0
        private void changeDllStatus(SMC_PushDll dll, string jostype, bool executeSucced)
        {
            switch (jostype)
            {
            case "AddJobPluginGroup":
                if (executeSucced)
                {
                    dll.pd_dll_status = "已载入";
                }
                break;

            case "RemoveJobPluginGroup":
                if (executeSucced)
                {
                    dll.pd_dll_status = "已载出";
                }
                break;

            case "RestartJobPluginGroup":
                if (executeSucced)
                {
                    dll.pd_dll_status = "已重载";
                }
                break;

            case "SetTargetJobTime":
                break;

            case "PauseTargetJob":
                if (executeSucced)
                {
                    dll.pd_dll_status = "已暂停";
                }
                break;

            case "ContinueTargetJob":
                if (executeSucced)
                {
                    dll.pd_dll_status = "已继续";
                }
                break;
            }
            BoFactory.GetSMC_PushDllBO.Update(dll);
        }
예제 #12
0
        public virtual bool InsertOrUpdate(SMC_PushDll role)
        {
            try
            {
                int i = 0;
                if (SMC_PushDllDAO.Get(role.pd_id) == null)
                {
                    SMC_PushDllDAO.Insert(role);
                }
                else
                {
                    SMC_PushDllDAO.Update(role);
                }

                return(true);
            }
            catch (DalException ex)
            {
                throw new BOException("调用方法InsertOrUpdate失败", ex);
            }
        }
예제 #13
0
        public ActionResult UploadFile(FormCollection form)
        {
            //return View(true);
            if (HttpContext.Request != null && HttpContext.Request.Files.Count > 0)
            {
                HttpPostedFileBase file     = HttpContext.Request.Files[0];
                string             fileName = System.IO.Path.GetFileNameWithoutExtension(file.FileName);
                SMC_PushDll        dll      = new SMC_PushDll();
                dll.pd_name = fileName;
                //bool exists = BoFactory.GetSMC_PushDllBO.Exists(dll);

                string path = Server.MapPath("~/PushZipPacks/") + fileName + "/";
                SmartBox.Console.Common.ZipHelper.UnpackFiles(file.InputStream, path);
                //TransferFile(file.InputStream);
            }

            Hashtable r = new Hashtable();

            r["result"] = true;
            return(Json(r));
        }
예제 #14
0
        public JsonResult PushDLLDelete(string ids)
        {
            string[] idlist = ids.Split(",".ToCharArray());
            if (idlist != null && idlist.Length > 0)
            {
                foreach (string id in idlist)
                {
                    if (String.IsNullOrEmpty(id))
                    {
                        continue;
                    }
                    SMC_PushDll dll = BoFactory.GetSMC_PushDllBO.Get(int.Parse(id));
                    if (dll != null)
                    {
                        BoFactory.GetSMC_PushDllBO.Delete(dll);
                    }
                }
            }
            Hashtable result = new Hashtable();

            result["IsSuccess"] = true;
            result["Msg"]       = "删除插件成功!";
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
        public JsonResult GetPushDLLEntity(string pd_id)
        {
            SMC_PushDll _dll = BoFactory.GetSMC_PushDllBO.Get(int.Parse(pd_id));

            return(Json(_dll));
        }
예제 #16
0
        public ActionResult PushDllUploadFile(string pd_id)
        {
            //return View(true);
            //string pd_id = form["pd_id"];
            Hashtable r = null;

            if (String.IsNullOrEmpty(pd_id))
            {
                r           = new Hashtable();
                r["result"] = false;

                return(View(r));
            }

            if (HttpContext.Request != null && HttpContext.Request.Files.Count > 0)
            {
                HttpPostedFileBase file     = HttpContext.Request.Files[0];
                string             fileName = System.IO.Path.GetFileNameWithoutExtension(file.FileName);


                SMC_PushDll dll = BoFactory.GetSMC_PushDllBO.Get(int.Parse(pd_id));
                if (dll != null)
                {
                    dll.pd_zip_filename    = System.IO.Path.GetFileName(file.FileName);
                    dll.pd_zip_extension   = System.IO.Path.GetExtension(file.FileName);
                    dll.pd_zip_size        = file.ContentLength;
                    dll.pd_zip_contenttype = file.ContentType;
                }

                string path = Server.MapPath("~/PushZipPacks/") + pd_id + "\\";
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                try
                {
                    file.SaveAs(path + System.IO.Path.GetFileName(file.FileName));
                }
                catch
                {
                }
                //if (System.IO.Directory.Exists(path))
                //{
                //    throw new DirectoryNotFoundException("目录已经存在!");
                //    r = new Hashtable();
                //    r["result"] = false;
                //    return Json(r);
                //}
                dll.pd_path = path;
                SmartBox.Console.Common.ZipHelper.UnpackFiles(file.InputStream, path);
                string[] files = System.IO.Directory.GetFiles(path);
                if (files != null && files.Length > 0)
                {
                    foreach (string _file in files)
                    {
                        if (_file.EndsWith(".xml"))
                        {
                            dll.pd_xml_filename = System.IO.Path.GetFileName(_file);
                        }
                        else
                        {
                            dll.pd_dll_filename = System.IO.Path.GetFileName(_file);
                        }
                    }
                }
                BoFactory.GetSMC_PushDllBO.Update(dll);
                //TransferFile(file.InputStream);
            }

            r           = new Hashtable();
            r["result"] = true;
            return(View(r));
        }