public virtual void UpdatePackage4Out(SMC_Package4Out package4Out)
 {
     package4OutDao.Update(package4Out);
 }
 public virtual void InsertOutPackage(SMC_Package4Out outPackage)
 {
     package4OutDao.Insert(outPackage);
 }
示例#3
0
        private void _SMC_PackageExtInternalRelease(SMC_PackageExt ext)
        {
            if (ext == null)
                return;

            string tableName = ext.TableName.ToLower();
            int tableId = ext.TableID;
            List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
            switch (tableName)
            {
                case "webapplication":
                    pars.Add(new KeyValuePair<string, object>("id", tableId));
                    WebApplication webApplication = daoWebApplication.Get(pars);
                    if (webApplication == null)
                    {
                        webApplication = new WebApplication();
                        CopyPackageExt2WebApplication(ext, webApplication);
                        daoWebApplication.Insert(webApplication);
                        ext.TableID = webApplication.ID;
                    }
                    else
                    {
                        CopyPackageExt2WebApplication(ext, webApplication);
                        daoWebApplication.Update(webApplication);
                    }
                    break;
                case "package4ai":
                    pars.Add(new KeyValuePair<string, object>("id", tableId));
                    Package4AI package4AI = daoPackage4AI.Get(pars);
                    if (package4AI == null)
                    {
                        package4AI = new Package4AI();
                        CopyPackageExt2Package4AI(ext, package4AI);
                        daoPackage4AI.Insert(package4AI);
                        ext.TableID = package4AI.ID;
                    }
                    else
                    {
                        CopyPackageExt2Package4AI(ext, package4AI);
                        daoPackage4AI.Update(package4AI);
                    }

                    try
                    {
                        _AddApp4AI(package4AI, ext);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }

                    try
                    {
                        _AddAction4Android(package4AI, ext);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }

                    break;
                case "smc_package4out":
                    pars.Add(new KeyValuePair<string, object>("po_ID", tableId));
                    SMC_Package4Out package4Out = daoSMC_Package4Out.Get(pars);
                    if (package4Out == null)
                    {
                        package4Out = new SMC_Package4Out();
                        CopyPackageExt2SMC_Package4Out(ext, package4Out);
                        daoSMC_Package4Out.Insert(package4Out);
                        ext.TableID = package4Out.po_ID;
                    }
                    else
                    {
                        CopyPackageExt2SMC_Package4Out(ext, package4Out);
                        daoSMC_Package4Out.Update(package4Out);
                    }
                    break;
            }

            daoSMC_PackageExt.Update(ext);
            _CopyExtFileToUpdateFilesFolder(ext);
        }
示例#4
0
        protected SMC_Package4Out CopyPackageExt2SMC_Package4Out(SMC_PackageExt ext, SMC_Package4Out packageOut)
        {
            packageOut.BuildVer = int.Parse(ext.pe_BuildVer);
            packageOut.ClientType = ext.pe_ClientType;
            packageOut.CreateTime = ext.pe_CreatedTime;
            packageOut.CreateUid = ext.pe_CreateUid;
            packageOut.Description = ext.pe_Description;
            packageOut.DisplayName = ext.pe_DisplayName;
            packageOut.DownloadUri = ext.pe_DownloadUri;
            packageOut.Name = ext.pe_Name;
            packageOut.Type = ext.pe_Type;
            packageOut.UpdateTime = DateTime.Now;
            packageOut.UpdateUid = ext.pe_UpdateUid;
            packageOut.Version = ext.pe_Version;

            if (packageOut.Type == null)
                packageOut.Type = "plugin";
            return packageOut;
        }
        public JsonResult UploadOutPackage(FormCollection form)
        {
            JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" };
            int i = Request.Files.Count;
            HttpPostedFileBase file = null;
            HttpPostedFileBase icon = null;
            string filePath = "";
            string packageFileName = "";

            SMC_PackageExt packageExt = new SMC_PackageExt();

            int packageId = BoFactory.GetVersionTrackBo.GetMaxPackageExtId() + 1;
            string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径
            string pDir = SAVEOUTPATH + @"\" + packageId.ToString();//相对路径 用安装包ID做文件夹名
            string saveDir = conSolePath + pDir;
            string fileUrl = "";

            try
            {
                if (i > 0)
                {
                    file = Request.Files[0];//安装包文件
                    filePath = file.FileName;
                    packageFileName = "Package4Out-" + Path.GetFileName(filePath);
                    string savePath = System.IO.Path.Combine(saveDir, packageFileName);

                    if (!System.IO.Directory.Exists(saveDir))
                    {
                        System.IO.Directory.CreateDirectory(saveDir);
                    }
                    if (System.IO.File.Exists(savePath))
                    {
                        System.IO.File.Delete(savePath);
                    }

                    file.SaveAs(savePath);
                    fileUrl = packageFileName;

                    //图标文件
                    icon = Request.Files[1];
                    string iconFileName = "AppIcon.png";
                    savePath = System.IO.Path.Combine(saveDir, iconFileName);
                    if (System.IO.File.Exists(savePath))
                    {
                        System.IO.File.Delete(savePath);
                    }
                    icon.SaveAs(savePath);

                    //插入数据
                    SMC_Package4Out package = new SMC_Package4Out();
                    package.po_ID = BoFactory.GetVersionTrackBo.GetMaxOutPackageId() + 1;
                    package.Name = packageFileName;
                    package.Type = "main";
                    package.ClientType = form["ClientType"];
                    package.DisplayName = form["DisplayName"];
                    package.Description = form["Description"];
                    package.Version = form["Version"];
                    package.BuildVer = -1;
                    package.DownloadUri = packageId.ToString() + @"\" + packageFileName;// savePath;
                    package.CreateUid = CurrentUser.UserUId;
                    package.CreateTime = DateTime.Now;
                    package.UpdateUid = CurrentUser.UserUId;
                    package.UpdateTime = DateTime.Now;

                    BoFactory.GetVersionTrackBo.InsertOutPackage(package);

                    //插入扩展表

                    packageExt.pe_id = packageId;
                    packageExt.pe_ClientType = package.ClientType;
                    packageExt.pe_IsTJ = form["IsRecom"];
                    packageExt.pe_IsBB = form["IsMust"];
                    packageExt.pe_Size = file.ContentLength;
                    packageExt.pe_Firmware = form["Firmware"];
                    packageExt.pe_UnitCode = form["Unit"];
                    packageExt.pe_CategoryID = form["AppID"];
                    packageExt.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(form["AppID"]).DisplayName;
                    packageExt.pe_UnitName = BoFactory.GetSMC_UnitBo.Get(packageExt.pe_UnitCode).Unit_Name;
                    packageExt.pe_DisplayName = form["DisplayName"];
                    packageExt.pe_Description = form["Description"];
                    packageExt.pe_Version = form["Version"];
                    packageExt.pe_BuildVer = form["Version"];
                    packageExt.pe_Name = packageExt.pe_DisplayName;

                    //packageExt.pe_PictureUrl = form["IconUri"];
                    packageExt.TableName = "SMC_Package4Out";
                    packageExt.TableID = package.po_ID;
                    packageExt.pe_CreateUid = CurrentUser.UserUId;
                    packageExt.pe_CreatedTime = DateTime.Now;
                    packageExt.pe_UpdateUid = CurrentUser.UserUId;
                    packageExt.pe_UpdateTime = DateTime.Now;
                    packageExt.pe_ApplicationCode = Request.Form["ApplicationID"];

                    if (!String.IsNullOrEmpty(packageExt.pe_ApplicationCode))
                    {
                        string[] appIds = packageExt.pe_ApplicationCode.Split(",".ToCharArray());
                        string appNames = "";
                        foreach (string appid in appIds)
                        {
                            Application application = Bo.BoFactory.GetVersionTrackBo.GetApplication(appid);
                            if (application != null)
                            {
                                appNames += application.DisplayName + ",";
                            }
                        }
                        packageExt.pe_ApplicationName = appNames;
                    }
                    GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth");
                    if (parm.ConfigValue == "1")
                    {
                        //需要审核
                        packageExt.pe_AuthStatus = 0;//待审核
                        packageExt.pe_AuthSubmitTime = DateTime.Now;
                        packageExt.pe_AuthSubmitName = CurrentUser.FullName;
                        packageExt.pe_AuthSubmitUID = CurrentUser.UserUId;
                        packageExt.pe_Direction = "发布";
                        packageExt.pe_Type = "";
                        packageExt.pe_UsefulStstus = "0";
                        packageExt.pe_UsefulTime = DateTime.Now;
                        packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId;
                        packageExt.pe_UsefulOperatorName = CurrentUser.FullName;
                    }
                    else
                    {
                        packageExt.pe_AuthStatus = 1;//审核通过
                        packageExt.pe_AuthSubmitTime = DateTime.Now;
                        packageExt.pe_AuthTime = DateTime.Now;
                        packageExt.pe_AuthSubmitName = CurrentUser.FullName;
                        packageExt.pe_AuthSubmitUID = CurrentUser.UserUId;
                        packageExt.pe_AuthManUID = CurrentUser.UserUId;
                        packageExt.pe_AuthMan = CurrentUser.FullName;
                        packageExt.pe_SyncStatus = 0;
                        packageExt.pe_Direction = "发布";
                        packageExt.pe_Type = "";
                        packageExt.pe_UsefulStstus = "1";
                        packageExt.pe_UsefulTime = DateTime.Now;
                        packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId;
                        packageExt.pe_UsefulOperatorName = CurrentUser.FullName;

                    }

                    //生成外网下载url,并生成二维码
                    string outWebHost = AppConfig.OutWebHost;
                    if (outWebHost.EndsWith("/") == false)
                        outWebHost = outWebHost + "/";
                    string url = outWebHost + AppConfig.OutPackUploadFolder + "/" + packageId.ToString() + '/' + packageFileName;
                    System.Drawing.Bitmap bmp = GetDimensionalCode(url);
                    string imgPath = System.IO.Path.Combine(saveDir, "二维码图片.jpeg");
                    bmp.Save(imgPath, System.Drawing.Imaging.ImageFormat.Jpeg);
                    packageExt.pe_2dPictureUrl = @"~/" + pDir + "/二维码图片.jpeg";
                    packageExt.pe_2dPictureUrl = packageExt.pe_2dPictureUrl.Replace(@"\\", "/");
                    packageExt.pe_DownloadUri = url.Replace(@"\", "/");
                    packageExt.pe_PictureUrl = @"~/" + pDir + "/AppIcon.png";
                    packageExt.pe_PictureUrl = packageExt.pe_PictureUrl.Replace(@"\\", "/");

                    BoFactory.GetVersionTrackBo.InsertPackageExt(packageExt);
                    packageExt.pe_FileUrl = "~/PackageExt/" + packageExt.pe_id + "/" + fileUrl;
                    BoFactory.GetSMC_PackageExtBO.Update(packageExt);
                    if (parm.ConfigValue == "0")
                    {
                        //不需要审核,直接同步到应用中心
                        //同步至外网数据
                        _SyncPackageExt(packageExt);
                    }
                }
            }
            catch (Exception e)
            {
                Log4NetHelper.Error(e);
                data.IsSuccess = false;
                data.Msg = e.Message;
            }

            return Json(data, "text/html");
        }
        public ActionResult EditOutPackage(string id)
        {
            id = Server.UrlEncode(Request.QueryString["id"]);
            SMC_Package4Out package4Out = new SMC_Package4Out();
            try
            {
                package4Out = BoFactory.GetVersionTrackBo.GetPackage4Out(id);
                string clientType = package4Out.ClientType;

                string pe_id = BoFactory.GetVersionTrackBo.GetPeId(id, "SMC_Package4Out");
                SMC_PackageExt pe = BoFactory.GetVersionTrackBo.GetPackageExt(pe_id);
                ViewData["DownUrl"] = pe != null ? pe.pe_DownloadUri : "";
                if (pe != null && !String.IsNullOrEmpty(pe.pe_PictureUrl))
                {
                    ViewData["IconUrl"] = pe.pe_PictureUrl;
                }
                else
                {
                    ViewData["IconUrl"] = "";
                }

                List<SelectListItem> clientTypes = new List<SelectListItem>();
                IList<ClientTypes> ClientTypes = BoFactory.GetVersionTrackBo.QueryClientTypeList();
                foreach (var ct in ClientTypes)
                {
                    clientTypes.Add(new SelectListItem { Text = ct.DisplayName, Value = ct.ClientType, Selected = (clientType.Contains(ct.ClientType)) });
                }

                ViewData["ClientType"] = clientTypes;

                List<SelectListItem> IsRecom = new List<SelectListItem>();
                IsRecom.Add(new SelectListItem { Text = "推荐", Value = "1" });
                IsRecom.Add(new SelectListItem { Text = "不推荐", Value = "0" });

                if (pe.pe_IsTJ == "False")
                {
                    IsRecom[1].Selected = true;
                }
                else
                {
                    IsRecom[0].Selected = true;
                }

                List<SelectListItem> IsMust = new List<SelectListItem>();
                IsMust.Add(new SelectListItem { Text = "必备", Value = "1" });
                IsMust.Add(new SelectListItem { Text = "不必备", Value = "0" });

                if (pe.pe_IsBB == "False")
                {
                    IsMust[1].Selected = true;
                }
                else
                {
                    IsMust[0].Selected = true;
                }

                List<SelectListItem> unitList = new List<SelectListItem>();

                IList<SmartBox.Console.Common.Entities.SMC_Unit> js = GetUnitData();

                foreach (SmartBox.Console.Common.Entities.SMC_Unit r in js)
                {
                    //unitList.Add(new SelectListItem { Text = "全局", Value = "" });
                    unitList.Add(new SelectListItem { Text = r.Unit_Name, Value = r.Unit_ID });
                }

                //获取当前用户的本单位
                //Dictionary<string, string> unitInfo = BoFactory.GetSMC_UserListBo.GetUnitByUL_UID(CurrentUser.UserUId);
                //if (unitInfo.Count > 0)
                //{
                //    string unitName = "本单位-" + unitInfo.ElementAt(0).Key;
                //    string unitId = unitInfo.ElementAt(0).Value;
                //    unitList.Add(new SelectListItem { Text = unitName, Value = unitId, Selected = true });
                //}
                //if (BoFactory.GetVersionTrackBo.IsSystemManager(CurrentUser.UserUId))
                //{
                //    //加入所有单位列表
                //    PageView view = new PageView();
                //    view.PageSize = 15;
                //    JsonFlexiGridData units = BoFactory.GetSMC_UnitBo.QueryUnitByUpperUnitCode(view, "");
                //    foreach (FlexiGridRow r in units.rows)
                //    {
                //        unitList.Add(new SelectListItem { Text = r.cell[1], Value = r.id });
                //    }
                //}

                var ddlApplicationSelect = BoFactory.GetVersionTrackBo.QueryApplicationCategoryList();
                List<SelectListItem> appTypes = new List<SelectListItem>();
                foreach (var ad in ddlApplicationSelect)
                {
                    appTypes.Add(new SelectListItem { Text = ad.DisplayName, Value = ad.ID.ToString(), Selected = (ad.DisplayName == pe.pe_Category) });
                }
                ViewData["AppID"] = appTypes;
                ViewData["pe_IsTJ"] = IsRecom;
                ViewData["pe_IsBB"] = IsMust;
                ViewData["Unit"] = unitList;

            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                Response.Write(ex.Message);
                Response.End();
            }

            return View(package4Out);
        }