public virtual void UpdatePackage(Package4AI package4AI, string tempFilePath, string saveFilePath)
        {
            package4AIDao.Update(package4AI);
            IList<App4AI> app4AIList = app4AIDao.QueryApp4AIListByPackageID(package4AI.ID.ToString());

            if (app4AIList != null && app4AIList.Count > 0)
            {
                app4AIList.ForEach(app4AI =>
                {
                    app4AI.ActionList = action4AndroidDao.QueryAction4AndroidListByApp4AIID(app4AI.ID.ToString()).ToList();
                });
            }

            package4AI.App4AIList.ForEach(app4ai =>
               {
               //插入Application
               IList<KeyValuePair<string, object>> par = new List<KeyValuePair<string, object>>();
               par.Add(new KeyValuePair<string, object>("ClientType", app4ai.ClientType));
               par.Add(new KeyValuePair<string, object>("AppID", app4ai.AppID));
               par.Add(new KeyValuePair<string, object>("Package4AIID", app4ai.Package4AIID));
               App4AI oldAPP4AI = app4AIDao.Get(par);
               if (oldAPP4AI == null)
                   app4AIDao.Insert(app4ai);
               else
               {
                   app4ai.ID = oldAPP4AI.ID;
                   app4ai.UpdateTime = oldAPP4AI.UpdateTime;
                   app4ai.UpdateUid = oldAPP4AI.UpdateUid;
                   app4ai.Version = oldAPP4AI.Version;
                   app4ai.AppCode = oldAPP4AI.AppCode;
                   app4ai.AppID = oldAPP4AI.AppID;
                   app4ai.CreateTime = oldAPP4AI.CreateTime;
                   app4AIDao.Update(app4ai);
               }
               //给Application的Action赋值
               app4ai.ActionList.ForEach(action => action.App4AIID = app4ai.ID);
               //插入Action
               action4AndroidDao.InsertList(app4ai.ActionList);
               });

            if (!System.IO.File.Exists(tempFilePath))
            {
                throw new Exception("未找到上传的安装包,请重新上传者联系管理员");
            }
            if (package4AI.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase)
                && AppConfig.PublishConfig.ContainsKey(package4AI.ClientType))
            {
                saveFilePath = AppConfig.PublishConfig.GetValue(package4AI.ClientType).Path;
            }
            if (string.IsNullOrEmpty(saveFilePath))
            {
                throw new ArgumentNullException("saveFilePath", "安装包存储位置配置有误,请联系管理员调整。");
            }
            if (saveFilePath.IndexOf("$") != -1)
            {//远程部署时所需要的地址与存储位置
                string[] savefilePaths = saveFilePath.Split("$".ToCharArray());
                var remoteServerUrl = savefilePaths[0];
                var remoteSaveFilePath = savefilePaths[1];

                //远程存储安装包文件
                Service.ApplicationCenterWS.WebService acws = new Service.ApplicationCenterWS.WebService();
                acws.Url = remoteServerUrl;
                FileStream fs = new FileStream(tempFilePath, FileMode.Open);
                byte[] content = new byte[fs.Length];
                fs.Read(content, 0, (int)fs.Length - 1);
                fs.Close();
                fs.Dispose();

                acws.RemotePublish(content, remoteSaveFilePath);
            }
            else
            {//远程地址
                try
                {
                    //本地存储安装包文件
                    string localDirPath = Path.GetDirectoryName(saveFilePath);
                    if (!System.IO.Directory.Exists(localDirPath))
                    {
                        Directory.CreateDirectory(localDirPath);
                    }
                    System.IO.File.Copy(tempFilePath, saveFilePath, true);

                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error(string.Format("tempFilePath:{0} savefilePath:{1} Method:CreateApplicationPackage", tempFilePath, saveFilePath), ex);
                }
            }
            System.IO.File.Delete(tempFilePath);
        }
 public virtual void UpdatePackage4AI(Package4AI package4AI)
 {
     package4AIDao.Update(package4AI);
     app4AIDao.UpdateList(package4AI.App4AIList);
     package4AI.App4AIList.ForEach(x => action4AndroidDao.UpdateList(x.ActionList));
 }
Esempio n. 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);
        }
        public virtual void InsertPackage4AI(Package4AI package4AI, string tempFilePath, string saveFilePath)
        {
            if (!AppConfig.DebugMode && package4AIDao.Exists(package4AI))
                throw new Exception("不能上传重复的安装包!");

            //插入安装包数据
            package4AIDao.Insert(package4AI);
            //给安装包的Application对象赋值
            package4AI.App4AIList.ForEach(x =>
            {
                x.Package4AIID = package4AI.ID;
                x.PackageName = package4AI.Name;
            });

            package4AI.App4AIList.ForEach(app4ai =>
            {
                //插入Application
                app4AIDao.Insert(app4ai);
                //给Application的Action赋值
                app4ai.ActionList.ForEach(action => action.App4AIID = app4ai.ID);

                //插入Action
                //action4AndroidDao.InsertList(app4ai.ActionList);
                if (app4ai.ActionList != null && app4ai.ActionList.Count > 0)
                    foreach (Action4Android a4a in app4ai.ActionList)
                    {
                        Action4Android _a4a = action4AndroidDao.Get(a4a.Name);
                        if (_a4a != null)
                        {
                            action4AndroidDao.Update(a4a);
                        }
                        else
                        {
                            action4AndroidDao.Insert(a4a);
                        }
                    }
            });

            if (!System.IO.File.Exists(tempFilePath))
            {
                throw new Exception("未找到上传的安装包,请重新上传者联系管理员");
            }
            //储存安装包文件
            if (saveFilePath.IndexOf("$") != -1)
            {//远程部署时所需要的地址与存储位置
                string[] savefilePaths = saveFilePath.Split("$".ToCharArray());
                var remoteServerUrl = savefilePaths[0];
                var remoteSaveFilePath = savefilePaths[1];

                //远程存储安装包文件
                Service.ApplicationCenterWS.WebService acws = new Service.ApplicationCenterWS.WebService();
                acws.Url = remoteServerUrl;
                //StreamReader sr = new StreamReader();
                FileStream fs = new FileStream(tempFilePath, FileMode.Open);
                byte[] content = new byte[fs.Length];
                fs.Read(content, 0, (int)fs.Length - 1);
                fs.Close();
                fs.Dispose();

                acws.RemotePublish(content, remoteSaveFilePath);
            }
            else
            {//远程地址
                try
                {
                    //本地存储安装包文件
                    string localDirPath = Path.GetDirectoryName(saveFilePath);
                    if (!System.IO.Directory.Exists(localDirPath))
                    {
                        Directory.CreateDirectory(localDirPath);
                    }
                    System.IO.File.Copy(tempFilePath, saveFilePath, true);

                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error(string.Format("tempFilePath:{0} savefilePath:{1} Method:CreateApplicationPackage", tempFilePath, saveFilePath), ex);
                }
            }
            System.IO.File.Delete(tempFilePath);
        }
Esempio n. 5
0
        private void _AddAction4Android(Package4AI package, SMC_PackageExt ext)
        {
            if (!String.IsNullOrEmpty(ext.pe_ApplicationCode))
            {
                string[] apps = ext.pe_ApplicationCode.Split(",".ToCharArray());
                if (apps != null && apps.Length > 0)
                {
                    ApplicationDao appDao = new ApplicationDao(AppConfig.mainDbKey);
                    App4AIDao app4AIDao = new App4AIDao(AppConfig.mainDbKey);
                    string TEMPPATH = Path.Combine(AppConfig.PackUploadFolder, "Temp");
                    int idx = 1;

                    Action4AndroidDao action4AndroidDao = new Action4AndroidDao(AppConfig.mainDbKey);
                    foreach (string appCode in apps)
                    {
                        if (String.IsNullOrEmpty(appCode))
                            continue;
                        List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                        pars.Add(new KeyValuePair<string, object>("[NAME]", appCode));
                        Application application = appDao.Get(pars);

                        //for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++)
                        //{
                        Action4Android action4Android = new Action4Android();
                        action4Android.Seq = idx;//Convert.ToInt32(form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                        action4Android.DisplayName = "";//form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        action4Android.IsLaunch = true;//Convert.ToBoolean(form["ActivityLaunch_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                        action4Android.IconUri = "";//GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), form["ActivityIco_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                        action4Android.ShortName = "";//form["ActivityShortName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        action4Android.Name = "";//form["ActivityName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        action4Android.CreateTime = DateTime.Now;
                        action4Android.UpdateTime = DateTime.Now;
                        action4Android.CreateUid = "";//CurrentUser.UserUId;
                        action4Android.UpdateUid = "";//CurrentUser.UserUId;

                        action4AndroidDao.Insert(action4Android);
                        //}

                        ++idx;
                    }
                }
            }
        }
Esempio n. 6
0
        private void _AddApp4AI(Package4AI package, SMC_PackageExt ext)
        {
            if (!String.IsNullOrEmpty(ext.pe_ApplicationCode))
            {
                string[] apps = ext.pe_ApplicationCode.Split(",".ToCharArray());
                if (apps != null && apps.Length > 0)
                {
                    ApplicationDao appDao = new ApplicationDao(AppConfig.mainDbKey);
                    App4AIDao app4AIDao = new App4AIDao(AppConfig.mainDbKey);
                    string TEMPPATH = Path.Combine(AppConfig.PackUploadFolder, "Temp");
                    int idx = 1;
                    Hashtable extendInfo = null;
                    JObject extObj = null;
                    if (!String.IsNullOrEmpty(ext.pe_ExtentInfo))
                    {
                        extendInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Hashtable>(ext.pe_ExtentInfo);
                        extObj = JObject.Parse(ext.pe_ExtentInfo);
                    }

                    Newtonsoft.Json.Linq.JArray appsHash = (Newtonsoft.Json.Linq.JArray)extendInfo["Applications"];
                    JArray appsJobj = (JArray)extObj["Applications"];
                    foreach (string appCode in apps)
                    {
                        if (String.IsNullOrEmpty(appCode))
                            continue;

                        if (extendInfo.Count > 0)
                        {
                        }

                        //appsHash.Select(e => { e.});

                        List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                        pars.Add(new KeyValuePair<string, object>("[NAME]", appCode));
                        Application application = appDao.Get(pars);

                        App4AI app4AI = new App4AI();

                        app4AI.AppID = application.ID;
                        //Newtonsoft.Json.Linq.JToken.EqualityComparer = new Newtonsoft.Json.Linq.JTokenEqualityComparer();
                        //ec.

                        string AppIconUri = "";
                        foreach (var j in appsJobj)
                        {
                            var i = (JObject)j;
                            string ApplicationID = (string)i["ApplicationID"];
                            if (ApplicationID == application.ID.ToString())
                            {
                                var oIcon = (JObject)i["ApplicationIcon"];
                                AppIconUri = (string)oIcon["AppIconUri"];
                                break;
                            }
                        }
                        //Hashtable appHash = appsHash.Find(e => e["ApplicationID"] == application.ID.ToString());
                        //Hashtable appIconHash = (Hashtable)appHash["ApplicationIcon"];
                        //string AppIconUri = (string)appIconHash["AppIconUri"];

                        app4AI.Package4AIID = package.ID;
                        //app4AI.PackageName = package.Name;
                        app4AI.AppCode = appCode;
                        app4AI.ClientType = package.ClientType;//form["AppCheckClentType_" + appIndex.ToString()];
                        //string appIco = "";//form["AppIco_" + appIndex.ToString()]
                        app4AI.IconUri = AppIconUri;// GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), appIco);
                        app4AI.Seq = idx;
                        app4AI.CreateTime = DateTime.Now;
                        app4AI.UpdateTime = DateTime.Now;
                        app4AI.CreateUid = "";
                        app4AI.UpdateUid = "";

                        IList<KeyValuePair<string, object>> _pars = new List<KeyValuePair<string, object>>();
                        _pars.Add(new KeyValuePair<string, object>("Package4AIID", app4AI.Package4AIID));
                        _pars.Add(new KeyValuePair<string, object>("AppCode", app4AI.AppCode));
                        _pars.Add(new KeyValuePair<string, object>("ClientType", app4AI.ClientType));
                        App4AI _app4ai = app4AIDao.Get(_pars);
                        if (_app4ai == null)
                        {
                            //package.App4AIList.Add(app4AI);
                            app4AIDao.Insert(app4AI);
                        }
                        else
                        {
                            app4AIDao.Update(app4AI);
                        }

                        ++idx;
                    }
                }
            }
        }
        public JsonResult CreateApplicationPackage(FormCollection form)
        {
            JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" };
            Package4AI package = new Package4AI();

            Hashtable extentInfo = new Hashtable();
            try
            {
                package.CreateUid = CurrentUser.UserUId;
                package.UpdateUid = CurrentUser.UserUId;
                package.CreateTime = DateTime.Now;
                package.UpdateTime = DateTime.Now;
                package.DownloadUri = form["packageFileName"];
                package.Name = form["packageName"];
                package.DisplayName = form["packageDisplayName"];
                package.ClientType = form["packageClientType"];
                package.Type = form["packageType"];
                package.Version = form["packageVersion"];
                package.BuildVer = Convert.ToInt32(form["packageBuildVer"]);
                package.Description = form["packageDescription"];

                List<KeyValuePair<string, object>> _pars = new List<KeyValuePair<string, object>>();

                _pars.Add(new KeyValuePair<string, object>("Name", package.Name));
                _pars.Add(new KeyValuePair<string, object>("ClientType", package.ClientType));

                Package4AI pai = BoFactory.GetPackage4AIBO.Get(_pars);
                if (pai != null)
                {
                    throw new ArgumentException("不能发布重复的包");
                }

                SMC_PackageExt packageExt = new SMC_PackageExt();

                List<Hashtable> applications = new List<Hashtable>();
                extentInfo["Applications"] = applications;
                for (int appIndex = 0; appIndex < Convert.ToInt32(form["applicationCount"]); appIndex++)
                {
                    Hashtable application = new Hashtable();
                    applications.Add(application);
                    Hashtable AppIcons = new Hashtable();
                    application["ApplicationIcon"] = AppIcons;

                    App4AI app4AI = new App4AI();
                    if (!"".Equals(form["AppCode_" + appIndex.ToString()]))
                    {
                        app4AI.AppID = Convert.ToInt32(form["AppCode_" + appIndex.ToString()]);
                    }
                    app4AI.AppCode = form["AppName_" + appIndex.ToString()];
                    packageExt.pe_ApplicationCode += app4AI.AppCode + ",";
                    List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                    KeyValuePair<string, object> par = new KeyValuePair<string, object>("Name", app4AI.AppCode);
                    pars.Add(par);
                    Application app = BoFactory.GetApplicationBO.Get(pars);
                    string applicationName = "";
                    if (app != null)
                        applicationName = app.DisplayName;
                    packageExt.pe_ApplicationName += applicationName + ",";
                    app4AI.ClientType = form["AppCheckClentType_" + appIndex.ToString()];

                    application["ApplicationID"] = form["AppCode_" + appIndex.ToString()];
                    AppIcons["AppIconName"] = form["AppIco_" + appIndex.ToString()];
                    //AppIcons.Add(new Tuple<string, string, object>("ApplicationID", form["AppCode_" + appIndex.ToString()], form["AppIco_" + appIndex.ToString()]));

                    app4AI.IconUri = GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), form["AppIco_" + appIndex.ToString()]);
                    AppIcons["AppIconUri"] = app4AI.IconUri;

                    app4AI.Seq = appIndex + 1;
                    app4AI.CreateTime = DateTime.Now;
                    app4AI.UpdateTime = DateTime.Now;
                    app4AI.CreateUid = CurrentUser.UserUId;
                    app4AI.UpdateUid = CurrentUser.UserUId;

                    List<Hashtable> activities = new List<Hashtable>();
                    application["activities"] = activities;
                    for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++)
                    {
                        Action4Android action4Android = new Action4Android();
                        action4Android.Seq = Convert.ToInt32(form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                        action4Android.DisplayName = form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        action4Android.IsLaunch = Convert.ToBoolean(form["ActivityLaunch_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                        action4Android.IconUri = GetAndroidApplicationIcoUri(Path.Combine(TEMPPATH, package.DownloadUri), form["ActivityIco_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                        action4Android.ShortName = form["ActivityShortName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        action4Android.Name = form["ActivityName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        action4Android.CreateTime = DateTime.Now;
                        action4Android.UpdateTime = DateTime.Now;
                        action4Android.CreateUid = CurrentUser.UserUId;
                        action4Android.UpdateUid = CurrentUser.UserUId;

                        Hashtable activity = new Hashtable();
                        activity["DisplayName"] = form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        activity["ActivitySeq"] = form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                        activity["IsLaunch"] = action4Android.IsLaunch;
                        activity["IconUri"] = action4Android.IconUri;
                        activity["ShortName"] = action4Android.ShortName;
                        activity["Name"] = action4Android.Name;
                        activity["CreateTime"] = action4Android.CreateTime;
                        activity["UpdateTime"] = action4Android.UpdateTime;
                        activity["CreateUid"] = action4Android.CreateUid;
                        activity["UpdateUid"] = action4Android.UpdateUid;

                        activities.Add(activity);
                        app4AI.ActionList.Add(action4Android);
                    }
                    package.App4AIList.Add(app4AI);
                }

                string saveFileName = string.Format("{0}_v{1}_{2}{3}", package.Name, package.BuildVer, DateTime.Now.ToString("yyyyMMddHHmmss"), Path.GetExtension(package.DownloadUri));
                string tempFilePath = Path.Combine(TEMPPATH, package.DownloadUri);
                string saveFilePath = Path.Combine(SAVEPATH, saveFileName);

                if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase))
                {
                    var mainConfig = AppConfig.PublishConfig.GetValue(package.ClientType);
                    if (package.ClientType.EndsWith("ios", StringComparison.CurrentCultureIgnoreCase))
                    {
                        mainConfig.Url = IOS_URL_PREFIX + mainConfig.Url;
                    }
                    package.DownloadUri = mainConfig.Url;
                    saveFilePath = mainConfig.Path;
                }
                else
                {
                    package.DownloadUri = Path.Combine(AppConfig.PackUrl, saveFileName);
                }

                GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth");
                packageExt.pe_id = BoFactory.GetVersionTrackBo.GetMaxPackageExtId() + 1;
                packageExt.pe_ExtentInfo = Newtonsoft.Json.JsonConvert.SerializeObject(extentInfo);

                if (parm.ConfigValue == "0")
                {
                    //不需要审核
                    BoFactory.GetVersionTrackBo.InsertPackage4AI(package, tempFilePath, saveFilePath);
                    packageExt.pe_UsefulStstus = "1";//上架状态
                    packageExt.pe_UsefulTime = DateTime.Now;
                    packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId;
                    packageExt.pe_UsefulOperatorName = CurrentUser.UnitName;
                    packageExt.pe_AuthStatus = 1;//审核通过
                    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_AuthSubmitTime = DateTime.Now;
                }
                else
                {
                    string serializationPath = Server.MapPath("~/PackageSerialization/") + packageExt.pe_id + "/";
                    if (!Directory.Exists(serializationPath))
                        Directory.CreateDirectory(serializationPath);
                    using (Stream fStream = new FileStream(serializationPath + "package.xml", FileMode.Create, FileAccess.ReadWrite))
                    {
                        XmlSerializer xmlFormat = new XmlSerializer(typeof(Package4AI));
                        xmlFormat.Serialize(fStream, package);
                        fStream.Close();
                        fStream.Dispose();
                    }
                    XmlDocument xmlDoc = new XmlDocument();
                    string content = String.Format("<PackagePath><TempFilePath>{0}</TempFilePath><SaveFileName>{1}</SaveFileName></PackagePath>", tempFilePath, saveFilePath);
                    xmlDoc.LoadXml(content);
                    xmlDoc.Save(serializationPath + "path.xml");

                    //审核通过后再同步到Package4AI表
                    packageExt.pe_UsefulStstus = "0";//上架状态
                    packageExt.pe_Direction = "上架";
                    packageExt.pe_AuthStatus = 0;//待审核
                    packageExt.pe_AuthSubmitTime = DateTime.Now;
                    packageExt.pe_AuthSubmitName = CurrentUser.FullName;
                    packageExt.pe_AuthSubmitUID = CurrentUser.UserUId;
                    packageExt.pe_Direction = "发布";
                    packageExt.pe_UsefulTime = DateTime.Now;
                    packageExt.pe_UsefulOperatorUID = CurrentUser.UserUId;
                    packageExt.pe_UsefulOperatorName = CurrentUser.FullName;

                    System.IO.File.Copy(tempFilePath, saveFilePath, true);
                }

                //插入扩展表
                packageExt.pe_ClientType = package.ClientType;
                var s1 = form["IsRecom"];
                var s2 = form["IsMust"];
                packageExt.pe_IsTJ = form["IsRecom"];
                packageExt.pe_IsBB = form["IsMust"];
                FileInfo fi = new FileInfo(saveFilePath);
                packageExt.pe_Size = (int)fi.Length;
                packageExt.TableName = "Package4AI";
                packageExt.TableID = package.ID;
                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_CreateUid = CurrentUser.UserUId;
                packageExt.pe_CreatedTime = DateTime.Now;
                packageExt.pe_UpdateUid = CurrentUser.UserUId;
                packageExt.pe_UpdateTime = DateTime.Now;
                packageExt.pe_Version = form["packageVersion"];
                packageExt.pe_BuildVer = form["packageBuildVer"];
                packageExt.pe_Name = form["packageDisplayName"];
                packageExt.pe_DisplayName = form["packageDisplayName"];
                packageExt.pe_Description = form["packageDescription"];
                packageExt.pe_Firmware = form["Firmware"];
                packageExt.pe_Type = package.Type;

                string conSolePath = HttpRuntime.AppDomainAppPath;//服务器路径
                string pDir = Path.Combine(SAVEOUTPATH, packageExt.pe_id.ToString());//相对路径 用安装包ID做文件夹名
                string saveDir = Path.Combine(conSolePath, pDir);

                if (!System.IO.Directory.Exists(saveDir))
                {
                    System.IO.Directory.CreateDirectory(saveDir);
                }
                //生成下载url,并生成二维码
                string url = package.DownloadUri;

                string pe_2dPictureUrl = Save2DPicture(packageExt.pe_id, url);

                //保存安装包
                string packageName = "Package4AI-" + Path.GetFileName(tempFilePath);
                string packageFilePath = System.IO.Path.Combine(saveDir, packageName);
                System.IO.File.Copy(saveFilePath, packageFilePath, true);

                packageExt.pe_FileUrl = "~/PackageExt/" + packageExt.pe_id + "/" + packageName;

                packageExt.pe_2dPictureUrl = pe_2dPictureUrl;// @"~/" + pDir + "/二维码图片.jpeg";
                //packageExt.pe_2dPictureUrl = packageExt.pe_2dPictureUrl.Replace(@"\\", "/");
                packageExt.pe_DownloadUri = url.Replace(@"\", "/");

                int i = Request.Files.Count;
                string iconSavePath = "";
                if (i > 0)
                {
                    //保存安装包图标
                    HttpPostedFileBase icon = Request.Files[0];
                    string iconFileName = "AppIcon.png";
                    iconSavePath = System.IO.Path.Combine(saveDir, iconFileName);
                    if (System.IO.File.Exists(iconSavePath))
                    {
                        System.IO.File.Delete(iconSavePath);
                    }
                    icon.SaveAs(iconSavePath);

                    packageExt.pe_PictureUrl = @"~/" + pDir + "/AppIcon.png";
                    packageExt.pe_PictureUrl = packageExt.pe_PictureUrl.Replace(@"\\", "/");
                }

                BoFactory.GetVersionTrackBo.InsertPackageExt(packageExt);

                if (parm.ConfigValue == "0")
                {
                    //不需要审核,直接同步到应用中心
                    //同步至外网数据
                    _SyncPackageExt(packageExt);
                }

                if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        //更新server缓存
                        SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient();
                        cli.ResetClientVer();
                    }
                    catch
                    {
                        data.Msg = "操作成功,更新SmartBox服务缓存失败。";
                    }
                }

                //app更新到外网
                BoFactory.GetCommonBO.CopyAppFilesToAppCenterServer(saveFilePath, packageExt.pe_id);

                #region pad布局检查
                if (package.ClientType.StartsWith("Pad", StringComparison.CurrentCultureIgnoreCase))
                {
                    PageView view = new PageView();
                    view.PageSize = 15;
                    view.PageIndex = 0;
                    int HomePlans = BoFactory.GetVersionTrackBo.QueryHomePlanList(view).rows.Count;
                    if (HomePlans < 1)
                    {
                        data.Msg += " \n没有页面布局,请在Home布局管理中增加.";
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                data.IsSuccess = false;
                data.Msg = ex.Message;
            }

            return Json(data, "text/html");
        }
Esempio n. 8
0
        protected Package4AI CopyPackageExt2Package4AI(SMC_PackageExt ext, Package4AI package4AI)
        {
            package4AI.BuildVer = int.Parse(ext.pe_BuildVer);
            package4AI.ClientType = ext.pe_ClientType;
            package4AI.CreateTime = ext.pe_CreatedTime;
            package4AI.CreateUid = ext.pe_CreateUid;
            package4AI.Description = ext.pe_Description;
            package4AI.DisplayName = ext.pe_DisplayName;
            package4AI.DownloadUri = ext.pe_DownloadUri;

            if (String.IsNullOrEmpty(package4AI.Type))
                package4AI.Type = ext.pe_Type;
            package4AI.UpdateTime = ext.pe_UpdateTime;
            package4AI.UpdateUid = ext.pe_UpdateUid;
            package4AI.Version = ext.pe_Version;
            package4AI.UpdateTime = DateTime.Now;

            if (package4AI.Type == null)
            {
                package4AI.Type = "plugin";
            }
            return package4AI;
        }
        private Package4AI ReadIOSPackage(string tempPackagePath)
        {
            XmlDocument xml = new XmlDocument();
            XmlDocument plist = new XmlDocument();

            using (ZipFile zip = new ZipFile(tempPackagePath))
            {
                const string IPHONEPLIST = "Info.plist";
                const string IPHONEXML = "package.xml";
                ZipEntry zipXML = null;
                ZipEntry zipPlist = null;
                foreach (ZipEntry item in zip)
                {
                    string[] filename = item.Name.Split('/');
                    if (filename.Length == 3 && filename[2].Equals(IPHONEPLIST, StringComparison.CurrentCultureIgnoreCase))
                    {
                        zipPlist = item;
                    }
                    else if (IPHONEXML.Equals(filename[filename.Length - 1], StringComparison.CurrentCultureIgnoreCase))
                    {
                        zipXML = item;
                    }
                    if (zipXML != null && zipPlist != null)
                    {
                        break;
                    }
                }
                if (zipXML == null)
                {
                    throw new Exception("安装包中未找到package.xml文件!,请上传正确的安装包!");
                }
                if (zipPlist == null)
                {
                    throw new Exception("安装包中未找到Info.plist文件!,请上传正确的安装包!");
                }

                Stream xmlStream = zip.GetInputStream(zipXML);
                xml.LoadXml(ConvertPlist.ConvertPlist.plist2xml(xmlStream));

                Stream plistStream = zip.GetInputStream(zipPlist);
                var plistXml = ConvertPlist.ConvertPlist.plist2xml(plistStream);
                using (var reader = new StringReader(plistXml))
                {
                    XmlReaderSettings xs = new XmlReaderSettings();
                    xs.XmlResolver = null;
                    xs.ProhibitDtd = false;
                    plist.Load(XmlReader.Create(reader, xs));
                }
            }
            XmlNode xmlPackage = xml.GetElementsByTagName("package")[0];
            XmlNode buildVer = plist.SelectSingleNode("/plist/dict/key[.='CFBundleVersion']");
            XmlNode version = plist.SelectSingleNode("/plist/dict/key[.='CFBundleShortVersionString']");
            Package4AI package = new Package4AI();
            package.CreateUid = CurrentUser.UserUId;
            package.UpdateUid = CurrentUser.UserUId;
            package.CreateTime = DateTime.Now;
            package.UpdateTime = DateTime.Now;
            package.DownloadUri = Path.GetFileName(tempPackagePath);
            package.Description = xmlPackage.Attributes["description"] != null ? xmlPackage.Attributes["description"].Value : string.Empty;
            package.DisplayName = xmlPackage.Attributes["displayName"] != null ? xmlPackage.Attributes["displayName"].Value : string.Empty;
            if (xmlPackage.Attributes["name"] == null)
            {
                throw new Exception("未找到安装包客户端名称,请上传正确的安装包!");
            }
            package.Name = xmlPackage.Attributes["name"].Value;
            if (xmlPackage.Attributes["clientType"] == null)
            {
                throw new Exception("未找到安装包客户端类型,请上传正确的安装包!");
            }
            package.ClientType = xmlPackage.Attributes["clientType"].Value;
            if (xmlPackage.Attributes["type"] == null)
            {
                throw new Exception("未找到安装包类型,请上传正确的安装包!");
            }
            package.Type = xmlPackage.Attributes["type"].Value;
            package.Version = version != null ? version.NextSibling.InnerText : string.Empty;
            if (buildVer == null)
            {
                throw new Exception("未找到内部版本号,请上传正确的安装包!");
            }
            int _buildVer = Convert.ToInt32(float.Parse(buildVer.NextSibling.InnerText));
            package.BuildVer = _buildVer;

            foreach (XmlNode application in xml.GetElementsByTagName("application"))
            {
                App4AI app4AI = new App4AI();
                app4AI.AppCode = application.Attributes["name"] != null ? application.Attributes["name"].Value : string.Empty;
                app4AI.ClientType = application.Attributes["type"] != null ? application.Attributes["type"].Value : package.ClientType;
                app4AI.IconUri = application.Attributes["ico"] != null ? application.Attributes["ico"].Value : string.Empty;
                app4AI.AppName = application.Attributes["code"] != null ? application.Attributes["code"].Value : string.Empty;
                app4AI.Seq = 1;
                app4AI.CreateTime = DateTime.Now;
                app4AI.UpdateTime = DateTime.Now;
                app4AI.CreateUid = CurrentUser.UserUId;
                app4AI.UpdateUid = CurrentUser.UserUId;

                foreach (XmlNode action in application.SelectNodes("activity/action"))
                {
                    Action4Android action4Android = new Action4Android();
                    action4Android.Seq = action.Attributes["sort"] != null ? Convert.ToInt32(action.Attributes["sort"].Value) : 1;
                    action4Android.DisplayName = action.Attributes["label"] != null ? action.Attributes["label"].Value : string.Empty;
                    action4Android.IsLaunch = action.Attributes["isLaunch"] != null ? Convert.ToBoolean(action.Attributes["isLaunch"].Value) : false;
                    action4Android.IconUri = action.Attributes["ico"] != null ? action.Attributes["ico"].Value : string.Empty;
                    action4Android.ShortName = action.Attributes["shortName"] != null ? action.Attributes["shortName"].Value : string.Empty;
                    action4Android.Name = action.Attributes["name"] != null ? action.Attributes["name"].Value : string.Empty;

                    app4AI.ActionList.Add(action4Android);
                }
                package.App4AIList.Add(app4AI);
            }
            return package;
        }
        private Package4AI ReadAndroidPackage(string tempPackagePath)
        {
            XmlDocument xmlPlugin = new XmlDocument();

            const string ANDROID = "assets/plugin.xml";
            using (ZipFile zip = new ZipFile(tempPackagePath))
            {
                ZipEntry zipPlugin = zip.GetEntry(ANDROID);
                if (zipPlugin == null)
                {
                    throw new Exception("请检查上传的包是否是内部app!");
                }
                Stream stream = zip.GetInputStream(zipPlugin);
                xmlPlugin.Load(stream);
            }
            XmlNode xmlPackage = xmlPlugin.GetElementsByTagName("package")[0];
            Package4AI package = new Package4AI();
            package.CreateUid = CurrentUser.UserUId;
            package.UpdateUid = CurrentUser.UserUId;
            package.CreateTime = DateTime.Now;
            package.UpdateTime = DateTime.Now;
            package.DownloadUri = Path.GetFileName(tempPackagePath);
            package.Description = xmlPackage.Attributes["description"] != null ? xmlPackage.Attributes["description"].Value : string.Empty;
            package.DisplayName = xmlPackage.Attributes["displayName"] != null ? xmlPackage.Attributes["displayName"].Value : string.Empty;
            if (xmlPackage.Attributes["name"] == null)
            {
                throw new Exception("未找到安装包客户端名称,请上传正确的安装包!");
            }
            package.Name = xmlPackage.Attributes["name"].Value;
            if (xmlPackage.Attributes["clientType"] == null)
            {
                throw new Exception("未找到安装包客户端类型,请上传正确的安装包!");
            }
            package.ClientType = xmlPackage.Attributes["clientType"].Value;
            if (xmlPackage.Attributes["type"] == null)
            {
                throw new Exception("未找到安装包类型,请上传正确的安装包!");
            }
            package.Type = xmlPackage.Attributes["type"].Value;
            package.Version = xmlPackage.Attributes["ver"] != null ? xmlPackage.Attributes["ver"].Value : string.Empty;
            if (xmlPackage.Attributes["buildver"] == null)
            {
                throw new Exception("未找到内部版本号,请上传正确的安装包!");
            }
            package.BuildVer = Convert.ToInt32(xmlPackage.Attributes["buildver"].Value);

            foreach (XmlNode application in xmlPlugin.GetElementsByTagName("application"))
            {
                App4AI app4AI = new App4AI();
                app4AI.AppName = application.Attributes["code"] != null ? application.Attributes["code"].Value : string.Empty;
                app4AI.AppCode = application.Attributes["name"] != null ? application.Attributes["name"].Value : string.Empty;
                app4AI.ClientType = package.ClientType;
                app4AI.IconUri = application.Attributes["ico"] != null ? BoFactory.GetCommonBO.GetAndroidApplicationIcoUri(tempPackagePath, application.Attributes["ico"].Value) : string.Empty;
                app4AI.Seq = 1;
                app4AI.CreateTime = DateTime.Now;
                app4AI.UpdateTime = DateTime.Now;
                app4AI.CreateUid = CurrentUser.UserUId;
                app4AI.UpdateUid = CurrentUser.UserUId;

                foreach (XmlNode action in application.SelectNodes("activity/action"))
                {
                    Action4Android action4Android = new Action4Android();
                    action4Android.Seq = action.Attributes["sort"] != null ? Convert.ToInt32(action.Attributes["sort"].Value) : 1;
                    action4Android.DisplayName = action.Attributes["label"] != null ? action.Attributes["label"].Value : string.Empty;
                    action4Android.IsLaunch = action.Attributes["isLaunch"] != null ? Convert.ToBoolean(action.Attributes["isLaunch"].Value) : false;
                    action4Android.IconUri = action.Attributes["ico"] != null ? BoFactory.GetCommonBO.GetAndroidApplicationIcoUri(tempPackagePath, action.Attributes["ico"].Value) : string.Empty;
                    action4Android.ShortName = action.Attributes["shortName"] != null ? action.Attributes["shortName"].Value : string.Empty;
                    action4Android.Name = action.Attributes["name"] != null ? action.Attributes["name"].Value : string.Empty;

                    app4AI.ActionList.Add(action4Android);
                }
                package.App4AIList.Add(app4AI);
            }
            return package;
        }
        public JsonResult UpdatePackage(FormCollection form)
        {
            JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" };
            Package4AI package = new Package4AI();
            SMC_PackageExtHistory history = new SMC_PackageExtHistory();

            package.CreateUid = form["packageCreateUser"];
            package.UpdateUid = CurrentUser.UserUId;
            package.CreateTime = Convert.ToDateTime(form["packageCreateDateTime"]);
            package.UpdateTime = DateTime.Now;
            package.DownloadUri = form["packageFileName"];
            package.Name = form["packageName"];
            package.DisplayName = form["packageDisplayName"];
            package.ClientType = form["packageClientType"];
            package.Type = form["packageType"];
            package.Version = form["packageVersion"];
            package.BuildVer = Convert.ToInt32(form["packageBuildVer"]);
            package.Description = form["packageDescription"];
            package.ID = Convert.ToInt32(form["packageID"]);

            SMC_PackageExt ext = BoFactory.GetAppCenterBO.GetPackageExt(package.ID);
            string tableName = ext.TableName.ToLower();
            if (tableName != "webapplication" && tableName != "smc_package4out")
            {
                package.ID = ext.TableID;
            }

            for (int appIndex = 0; appIndex < Convert.ToInt32(form["applicationCount"]); appIndex++)
            {
                App4AI app4AI = new App4AI();
                if (!"".Equals(form["AppCode_" + appIndex.ToString()]))
                {
                    app4AI.AppID = Convert.ToInt32(form["AppCode_" + appIndex.ToString()]);
                }
                app4AI.AppCode = form["AppName_" + appIndex.ToString()];
                app4AI.ClientType = form["AppCheckClentType_" + appIndex.ToString()];
                app4AI.IconUri = form["AppIco_" + appIndex.ToString()];
                app4AI.Seq = 1;
                app4AI.CreateTime = package.CreateTime;
                app4AI.UpdateTime = DateTime.Now;
                app4AI.CreateUid = package.CreateUid;
                app4AI.UpdateUid = CurrentUser.UserUId;

                for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++)
                {
                    Action4Android action4Android = new Action4Android();
                    action4Android.Seq = Convert.ToInt32(form["ActivitySeq_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                    action4Android.DisplayName = form["ActivityDisplayName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                    action4Android.IsLaunch = Convert.ToBoolean(form["ActivityLaunch_" + appIndex.ToString() + "_" + activtyIndex.ToString()]);
                    action4Android.IconUri = form["ActivityIco_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                    action4Android.ShortName = form["ActivityShortName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                    action4Android.Name = form["ActivityName_" + appIndex.ToString() + "_" + activtyIndex.ToString()];
                    action4Android.CreateTime = package.CreateTime;
                    action4Android.UpdateTime = DateTime.Now;
                    action4Android.CreateUid = package.CreateUid;
                    action4Android.UpdateUid = CurrentUser.UserUId;
                    app4AI.Package4AIID = package.ID;
                    action4Android.App4AIID = package.ID;
                    Action4Android a4a = BoFactory.GetAction4AndroidBO.Get(action4Android.Name);
                    if (a4a == null)
                        app4AI.ActionList.Add(action4Android);
                }

                IList<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                pars.Add(new KeyValuePair<string, object>("Package4AIID", app4AI.Package4AIID));
                pars.Add(new KeyValuePair<string, object>("AppCode", app4AI.AppCode));
                pars.Add(new KeyValuePair<string, object>("ClientType", app4AI.ClientType));
                App4AI _app4ai = BoFactory.GetApp4AIBO.Get(pars);
                if (_app4ai == null)
                {
                    package.App4AIList.Add(app4AI);
                }
                else
                {
                    _app4ai.AppID = app4AI.AppID;
                    BoFactory.GetApp4AIBO.Update(_app4ai);
                }
            }

            try
            {
                string saveFileName = string.Format("{0}_v{1}_{2}{3}", package.Name, package.BuildVer, DateTime.Now.ToString("yyyyMMddHHmmss"), Path.GetExtension(package.DownloadUri));
                string tempFilePath = Path.Combine(TEMPPATH, package.DownloadUri);
                string saveFilePath = Path.Combine(SAVEPATH, saveFileName);

                if (package.ClientType.EndsWith("ios", StringComparison.CurrentCultureIgnoreCase))
                {
                    string padUrl = string.Empty;
                    string phoneUrl = string.Empty;
                    Common.Configuration.IOSConfiguration iosConfig = (Common.Configuration.IOSConfiguration)System.Configuration.ConfigurationManager.GetSection("PublishConfig");
                    if (iosConfig != null && iosConfig.IOSPublishs != null)
                    {
                        foreach (Common.Configuration.IOSPublishElement item in iosConfig.IOSPublishs)
                        {
                            if (item.ClientType.StartsWith("Pad/iOS", StringComparison.CurrentCultureIgnoreCase))
                                padUrl = item.Url;
                            if (item.ClientType.StartsWith("Phone/iOS", StringComparison.CurrentCultureIgnoreCase))
                                phoneUrl = item.Url;
                        }
                    }
                    if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (package.ClientType.StartsWith("Pad", StringComparison.CurrentCultureIgnoreCase))
                        {
                            package.DownloadUri = @"itms-services://?action=download-manifest&url=" + padUrl;
                        }
                        else if (package.ClientType.StartsWith("Phone", StringComparison.CurrentCultureIgnoreCase))
                        {
                            package.DownloadUri = @"itms-services://?action=download-manifest&url=" + phoneUrl;
                        }
                    }
                }
                else
                {
                    string padUrl = string.Empty;
                    string phoneUrl = string.Empty;
                    Common.Configuration.IOSConfiguration iosConfig = (Common.Configuration.IOSConfiguration)System.Configuration.ConfigurationManager.GetSection("PublishConfig");
                    if (iosConfig != null && iosConfig.IOSPublishs != null)
                    {
                        foreach (Common.Configuration.IOSPublishElement item in iosConfig.IOSPublishs)
                        {
                            if (item.ClientType.StartsWith("Pad/Android", StringComparison.CurrentCultureIgnoreCase))
                                padUrl = item.Url;
                            if (item.ClientType.StartsWith("Phone/Android", StringComparison.CurrentCultureIgnoreCase))
                                phoneUrl = item.Url;
                        }
                    }
                    if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase))
                    {
                        package.DownloadUri = Path.Combine(AppConfig.PackUrl, saveFileName);
                    }
                }

                SMC_PackageExt _ext = BoFactory.GetAppCenterBO.GetPackage("Package4AI", package.ID.ToString());
                _ext.pe_LastVersion = _ext.pe_Version;
                _ext.pe_Version = package.Version;
                _ext.pe_FileUrl = "~/PackageExt/" + _ext.pe_id + "/" + Path.GetFileName(tempFilePath);
                GlobalParam parm = Bo.BoFactory.GetGlobalParamBO.GetGlobalParam("app_sj_need_auth");

                if (parm.ConfigValue != "0")
                {
                    string serializationPath = Server.MapPath("~/PackageSerialization/") + _ext.pe_id + "/";
                    if (!Directory.Exists(serializationPath))
                        Directory.CreateDirectory(serializationPath);
                    using (Stream fStream = new FileStream(serializationPath + "package.xml", FileMode.Create, FileAccess.ReadWrite))
                    {
                        XmlSerializer xmlFormat = new XmlSerializer(typeof(Package4AI));
                        xmlFormat.Serialize(fStream, package);
                        fStream.Close();
                        fStream.Dispose();
                    }
                    XmlDocument xmlDoc = new XmlDocument();
                    string content = String.Format("<PackagePath><TempFilePath>{0}</TempFilePath><SaveFileName>{1}</SaveFileName></PackagePath>", tempFilePath, saveFilePath);
                    xmlDoc.LoadXml(content);
                    xmlDoc.Save(serializationPath + "path.xml");

                    //审核通过后再同步到Package4AI表
                    _ext.pe_UsefulStstus = "0";//上架状态
                    _ext.pe_AuthStatus = 0;
                    _ext.pe_AuthSubmitName = CurrentUser.FullName;
                    _ext.pe_AuthSubmitTime = DateTime.Now;
                    _ext.pe_AuthSubmitUID = CurrentUser.UserUId;
                    _ext.pe_UsefulTime = DateTime.Now;
                    _ext.pe_UsefulOperatorUID = CurrentUser.UserUId;
                    _ext.pe_UsefulOperatorName = CurrentUser.FullName;
                    if (package.ClientType.ToLower().IndexOf("ios") != -1)
                        _ext.pe_DownloadUri = package.DownloadUri;
                }

                _ext.pe_Version = form["packageVersion"];
                _ext.pe_BuildVer = form["packageBuildVer"];
                Bo.BoFactory.GetSMC_PackageExtBO.Save(_ext);

                if (parm.ConfigValue == "0")
                {
                    //不需要审核,直接同步到应用中心
                    //同步至外网数据

                    BoFactory.GetVersionTrackBo.UpdatePackage(package, tempFilePath, saveFilePath);
                    _ext.pe_UsefulStstus = "1";//上架状态
                    _ext.pe_UsefulTime = DateTime.Now;
                    _ext.pe_UsefulOperatorUID = CurrentUser.UserUId;
                    _ext.pe_UsefulOperatorName = CurrentUser.FullName;
                    _ext.pe_AuthStatus = 1;//审核通过
                    _ext.pe_AuthTime = DateTime.Now;
                    _ext.pe_AuthManUID = CurrentUser.UserUId;
                    _ext.pe_AuthMan = CurrentUser.FullName;
                    _ext.pe_DownloadUri = ConfigurationManager.AppSettings["packUrl"] + saveFileName;
                    if (package.ClientType.ToLower().IndexOf("ios") != -1)
                        _ext.pe_DownloadUri = package.DownloadUri;

                    //内部发布到Package4AI
                    BoFactory.GetCommonBO.SMC_PackageExtInternalRelease(_ext);

                    //同步到应用中心
                    _SyncPackageExt(_ext);
                }

                #region 上传文件自动发布
                if (package.Type.Equals("Main", StringComparison.CurrentCultureIgnoreCase))
                {
                    //更新server缓存
                    try
                    {
                        SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient();
                        cli.ResetClientVer();
                    }
                    catch
                    {
                        data.Msg = "操作成功,更新Server缓存失败。如遇到未提示版本更新问题请联系管理员重启服务。";
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                data.IsSuccess = false;
                data.Msg = ex.Message;
            }

            return Json(data);
        }
        public JsonResult EditApplicationPackage(FormCollection form)
        {
            Package4AI package = new Package4AI();
            package.UpdateUid = CurrentUser.UserUId;
            package.UpdateTime = DateTime.Now;
            package.CreateUid = form["packageCreateUser"];
            package.CreateTime = Convert.ToDateTime(form["packageCreateDateTime"]);
            package.ID = Convert.ToInt32(form["packageID"]);
            package.DownloadUri = form["packageDownloadUrl"];
            package.Name = form["packageName"];
            package.DisplayName = form["packageDisplayName"];
            package.ClientType = form["packageClientType"];
            package.Type = form["packageType"];
            package.Version = form["packageVersion"];
            package.BuildVer = Convert.ToInt32(form["packageBuildVer"]);
            package.Description = form["packageDescription"];

            for (int appIndex = 0; appIndex < Convert.ToInt32(form["applicationCount"]); appIndex++)
            {
                string appIndexStr = appIndex.ToString();
                App4AI app4AI = new App4AI();
                app4AI.ID = Convert.ToInt32(form["AppID_" + appIndexStr]);
                if (!"".Equals(form["AppCode_" + appIndexStr]))
                {
                    app4AI.AppID = Convert.ToInt32(form["AppCode_" + appIndexStr]);
                }
                app4AI.AppCode = form["AppName_" + appIndexStr];
                app4AI.ClientType = form["AppCheckClentType_" + appIndexStr];
                app4AI.IconUri = form["AppIco_" + appIndexStr];
                app4AI.Seq = Convert.ToInt32(form["AppSeq_" + appIndexStr]);
                app4AI.Package4AIID = Convert.ToInt32(form["AppPackageID_" + appIndexStr]);
                app4AI.PackageName = form["AppPackageName_" + appIndexStr];
                app4AI.CreateTime = Convert.ToDateTime(form["AppCreateDateTime_" + appIndexStr]);
                app4AI.CreateUid = form["AppCreateUser_" + appIndexStr];
                app4AI.UpdateTime = DateTime.Now;
                app4AI.UpdateUid = CurrentUser.UserUId;

                for (int activtyIndex = 0; activtyIndex < Convert.ToInt32(form["activityCount_" + appIndex.ToString()]); activtyIndex++)
                {
                    string activtyIndexStr = activtyIndex.ToString();
                    Action4Android action4Android = new Action4Android();
                    action4Android.App4AIID = Convert.ToInt32(form["ActivityAppID_" + appIndexStr + "_" + activtyIndexStr]);
                    action4Android.Seq = Convert.ToInt32(form["ActivitySeq_" + appIndexStr + "_" + activtyIndexStr]);
                    action4Android.DisplayName = form["ActivityDisplayName_" + appIndexStr + "_" + activtyIndexStr];
                    action4Android.IsLaunch = Convert.ToBoolean(form["ActivityLaunch_" + appIndexStr + "_" + activtyIndexStr]);
                    action4Android.IconUri = form["ActivityIco_" + appIndexStr + "_" + activtyIndexStr];
                    action4Android.ShortName = form["ActivityShortName_" + appIndexStr + "_" + activtyIndexStr];
                    action4Android.Name = form["ActivityName_" + appIndexStr + "_" + activtyIndexStr];
                    action4Android.CreateTime = Convert.ToDateTime(form["ActivityCreateDateTime_" + appIndexStr + "_" + activtyIndexStr]);
                    action4Android.UpdateTime = DateTime.Now;
                    action4Android.CreateUid = form["ActivityCreateUser_" + appIndexStr + "_" + activtyIndexStr];
                    action4Android.UpdateUid = CurrentUser.UserUId;
                    app4AI.ActionList.Add(action4Android);
                }
                package.App4AIList.Add(app4AI);
            }
            JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" };

            //package数据
            string pe_id = BoFactory.GetVersionTrackBo.GetPeId(package.ID.ToString(), "Package4AI");
            SMC_PackageExt pe = BoFactory.GetVersionTrackBo.GetPackageExt(pe_id);
            pe.pe_UpdateUid = CurrentUser.UserUId;
            pe.pe_UpdateTime = DateTime.Now;
            pe.pe_IsTJ = form["pe_IsTJ"];
            pe.pe_IsBB = form["pe_IsBB"];
            pe.pe_CategoryID = form["AppID"];
            pe.pe_Category = BoFactory.GetVersionTrackBo.GetApplicationCategory(form["AppID"]).DisplayName;
            pe.pe_UnitCode = form["Unit"];
            pe.pe_Name = package.Name;
            pe.pe_DisplayName = package.DisplayName;
            SMC_Unit unit = BoFactory.GetSMC_UnitBo.Get(pe.pe_UnitCode);

            package.DownloadUri = pe.pe_DownloadUri;
            if (unit != null && !string.IsNullOrEmpty(unit.Unit_Name))
            {
                pe.pe_UnitName = unit.Unit_Name;
            }

            try
            {
                BoFactory.GetVersionTrackBo.UpdatePackage4AI(package);
                BoFactory.GetVersionTrackBo.UpdatePackageExt(pe);
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                data.IsSuccess = false;
                data.Msg = ex.Message;
            }

            return Json(data);
        }
        public ActionResult EditApplicationPackage(string id)
        {
            id = Request.QueryString["id"];
            Package4AI package = new Package4AI();
            try
            {
                package = BoFactory.GetVersionTrackBo.GetPackage4AI(id);
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                Response.Write(ex.Message);
                Response.End();
            }
            string pe_id = BoFactory.GetVersionTrackBo.GetPeId(id, "Package4AI");
            SMC_PackageExt pe = BoFactory.GetVersionTrackBo.GetPackageExt(pe_id);

            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>();
            //获取当前用户的本单位
            //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 });
            //    }
            //}

            //获取当前用户的本单位
            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 = "" });
                SelectListItem itm = new SelectListItem { Text = r.Unit_Name, Value = r.Unit_ID };

                if (pe.pe_UnitCode == r.Unit_ID)
                {
                    itm.Selected = true;
                }
                unitList.Add(itm);
            }

            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;

            ViewData["Application"] = BoFactory.GetVersionTrackBo.QueryApplicationList().ToDataTable();
            ViewData["ClientType"] = BoFactory.GetVersionTrackBo.QueryClientTypeList().ToDataTable();
            return View(package);
        }