Example #1
0
        /// <summary>
        /// 同步单位至应用中心
        /// </summary>
        /// <returns></returns>
        public ActionResult SyncUnitToAppCenter()
        {
            JsonReturnMessages data = new JsonReturnMessages()
            {
                IsSuccess = true, Msg = "操作成功"
            };

            Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();
            IList <SMC_Unit> units = BoFactory.GetSMC_UnitBo.GetAllUnits();

            if (units != null && units.Count > 0)
            {
                Service.ApplicationCenterWS.SMC_Unit[] _units = new Service.ApplicationCenterWS.SMC_Unit[units.Count];
                for (int i = 0; i < units.Count; ++i)
                {
                    SMC_Unit unit = units[i];
                    Service.ApplicationCenterWS.SMC_Unit _unit = new Service.ApplicationCenterWS.SMC_Unit();
                    _unit.Unit_CreatedTime = unit.Unit_CreatedTime;
                    _unit.Unit_CreatedUser = unit.Unit_CreatedUser;
                    _unit.Unit_Demo        = unit.Unit_Demo;
                    _unit.Unit_ID          = unit.Unit_ID;
                    _unit.Unit_Name        = unit.Unit_Name;
                    _unit.Unit_Path        = unit.Unit_Path;
                    _unit.Unit_Sequence    = unit.Unit_Sequence;
                    _unit.Unit_UpdateTime  = unit.Unit_UpdateTime;
                    _unit.Unit_UpdateUser  = unit.Unit_UpdateUser;
                    _unit.Upper_Unit_ID    = unit.Upper_Unit_ID;

                    _units[i] = _unit;
                }
                ws.SMC_UnitSync(_units);
            }
            return(Json(data));
        }
Example #2
0
        public virtual void CopyAppFilesToAppCenterServer(string filePath, int pe_id)
        {
            string packUploadFolder = ConfigurationManager.AppSettings["packUploadFolder"];


            if (Directory.Exists(packUploadFolder))
            {
                string[] sourceFiles = null;
                if (pe_id <= 0)
                {
                    sourceFiles = Directory.GetFiles(packUploadFolder);
                }
                else
                {
                    sourceFiles = new string[] { filePath };
                }

                foreach (string file in sourceFiles)
                {
                    string fileName = Path.GetFileName(file);

                    Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

                    FileStream fs      = null;
                    byte[]     content = null;
                    try
                    {
                        fs      = new FileStream(file, FileMode.Open, FileAccess.Read);
                        content = new byte[fs.Length];
                        fs.Read(content, 0, (int)fs.Length - 1);
                        ws.AppFileSync(content, fileName);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                        continue;
                    }
                    finally
                    {
                        fs.Close();
                        fs.Dispose();
                    }
                }

                //更新server缓存
                try
                {
                    SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient();
                    cli.ResetClientVer();
                }
                catch (Exception ex)
                {
                    throw new Exception("文件同步成功,Server缓存数据清除失败。如遇到未提示版本更新问题请联系管理员重启服务", ex);
                }
            }
            else
            {
                Log4NetHelper.Info("packUploadFolder不存在:" + packUploadFolder);
            }
        }
        public virtual void BUAUserSyncToOutside(string ids)
        {
            SMC_UserDao userDao = new SMC_UserDao(AppConfig.statisticDBKey);
            string[] idlist = ids.Split(",".ToCharArray());
            List<SMC_User> usersToBeSynced = new List<SMC_User>();

            foreach (string uid in idlist)
            {
                if (String.IsNullOrEmpty(uid))
                {
                    continue;
                }
                SMC_User u = userDao.GetUser(uid);
                if (u != null)
                {
                    usersToBeSynced.Add(u);
                }
            }

            if (usersToBeSynced == null || usersToBeSynced.Count == 0)
                return;

            SmartBox.Console.Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

            Service.ApplicationCenterWS.SMC_User[] users = new Service.ApplicationCenterWS.SMC_User[usersToBeSynced.Count];
            int i = 0;
            foreach (SMC_User user in usersToBeSynced)
            {
                users[i] = new Service.ApplicationCenterWS.SMC_User();
                users[i].U_CREATEDDATE = user.U_CREATEDDATE;
                users[i].U_ID = user.U_ID;
                users[i].U_NAME = user.U_NAME;
                users[i].U_PASSWORD = user.U_PASSWORD;
                users[i].U_UID = user.U_UID;
                users[i].U_UNITCODE = user.U_UNITCODE;

                ++i;
            }
            bool result = ws.SMC_UserSync(users);

            SMC_BUAUserSyncToOutsideDao buaUserSyncOutDao = new SMC_BUAUserSyncToOutsideDao(AppConfig.statisticDBKey);
            int batNo = buaUserSyncOutDao.GetMaxBatNo() + 1;
            foreach (SMC_User user in usersToBeSynced)
            {
                SMC_BUAUserSyncToOutside log = new SMC_BUAUserSyncToOutside();
                log.description = "同步" + (result ? "成功" : "失败");
                log.sync_bat_no = batNo;
                log.sync_status = result;
                log.sync_time = DateTime.Now;
                log.sync_user_name = "";
                log.sync_user_uid = "";
                log.user_name = user.U_NAME;
                log.user_uid = user.U_UID;

                try
                {
                    int maxId = buaUserSyncOutDao.GetMaxId() + 1;
                    log.buso_id = maxId;
                    buaUserSyncOutDao.Insert(log);
                    buaUserSyncOutDao.UpdateMaxId();
                }
                catch
                {
                }
            }
        }
Example #4
0
        public virtual void BUAUserSyncToOutside(string ids)
        {
            SMC_UserDao userDao = new SMC_UserDao(AppConfig.statisticDBKey);

            string[]        idlist          = ids.Split(",".ToCharArray());
            List <SMC_User> usersToBeSynced = new List <SMC_User>();

            foreach (string uid in idlist)
            {
                if (String.IsNullOrEmpty(uid))
                {
                    continue;
                }
                SMC_User u = userDao.GetUser(uid);
                if (u != null)
                {
                    usersToBeSynced.Add(u);
                }
            }

            if (usersToBeSynced == null || usersToBeSynced.Count == 0)
            {
                return;
            }

            SmartBox.Console.Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

            Service.ApplicationCenterWS.SMC_User[] users = new Service.ApplicationCenterWS.SMC_User[usersToBeSynced.Count];
            int i = 0;

            foreach (SMC_User user in usersToBeSynced)
            {
                users[i] = new Service.ApplicationCenterWS.SMC_User();
                users[i].U_CREATEDDATE = user.U_CREATEDDATE;
                users[i].U_ID          = user.U_ID;
                users[i].U_NAME        = user.U_NAME;
                users[i].U_PASSWORD    = user.U_PASSWORD;
                users[i].U_UID         = user.U_UID;
                users[i].U_UNITCODE    = user.U_UNITCODE;

                ++i;
            }
            bool result = ws.SMC_UserSync(users);

            SMC_BUAUserSyncToOutsideDao buaUserSyncOutDao = new SMC_BUAUserSyncToOutsideDao(AppConfig.statisticDBKey);
            int batNo = buaUserSyncOutDao.GetMaxBatNo() + 1;

            foreach (SMC_User user in usersToBeSynced)
            {
                SMC_BUAUserSyncToOutside log = new SMC_BUAUserSyncToOutside();
                log.description    = "同步" + (result ? "成功" : "失败");
                log.sync_bat_no    = batNo;
                log.sync_status    = result;
                log.sync_time      = DateTime.Now;
                log.sync_user_name = "";
                log.sync_user_uid  = "";
                log.user_name      = user.U_NAME;
                log.user_uid       = user.U_UID;

                try
                {
                    int maxId = buaUserSyncOutDao.GetMaxId() + 1;
                    log.buso_id = maxId;
                    buaUserSyncOutDao.Insert(log);
                    buaUserSyncOutDao.UpdateMaxId();
                }
                catch
                {
                }
            }
        }
        /// <summary>
        /// 同步单位至应用中心
        /// </summary>
        /// <returns></returns>
        public ActionResult SyncUnitToAppCenter()
        {
            JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "操作成功" };

            Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();
            IList<SMC_Unit> units = BoFactory.GetSMC_UnitBo.GetAllUnits();
            if (units != null && units.Count > 0) {
                Service.ApplicationCenterWS.SMC_Unit[] _units = new Service.ApplicationCenterWS.SMC_Unit[units.Count];
                for (int i = 0; i < units.Count; ++ i)
                {
                    SMC_Unit unit = units[i];
                    Service.ApplicationCenterWS.SMC_Unit _unit = new Service.ApplicationCenterWS.SMC_Unit();
                    _unit.Unit_CreatedTime = unit.Unit_CreatedTime;
                    _unit.Unit_CreatedUser = unit.Unit_CreatedUser;
                    _unit.Unit_Demo = unit.Unit_Demo;
                    _unit.Unit_ID = unit.Unit_ID;
                    _unit.Unit_Name = unit.Unit_Name;
                    _unit.Unit_Path = unit.Unit_Path;
                    _unit.Unit_Sequence = unit.Unit_Sequence;
                    _unit.Unit_UpdateTime = unit.Unit_UpdateTime;
                    _unit.Unit_UpdateUser = unit.Unit_UpdateUser;
                    _unit.Upper_Unit_ID = unit.Upper_Unit_ID;

                    _units[i] = _unit;
                }
                ws.SMC_UnitSync(_units);
            }
            return Json(data);
        }
        protected void SyncPackageExtToAppCenter(SMC_PackageExt ext, Hashtable r, int batch_no)
        {
            SmartBox.Console.Bo.AppCenter.AppCenterBO bo = Bo.BoFactory.GetAppCenterBO;
            Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

            string smartbox_console_path = HttpRuntime.AppDomainAppPath;
            Service.ApplicationCenterWS.SMC_PackageExt entity = CopyPackageExt(ext);
            bool flag = true;
            //Log4NetHelper.Info("wsurl:" + ws.Url);

            try
            {
                //同步安装包到外网应用中心
                ws.PackageExtSync(entity);

                Service.ApplicationCenterWS.SMC_PackageFAQ faqEntity = new Service.ApplicationCenterWS.SMC_PackageFAQ();

                //同步应用手册到外网应用中心
                IList<SMC_PackageManual> manuals = bo.GetPackageManuals(entity.pe_id);
                foreach (SMC_PackageManual _manual in manuals)
                {
                    Service.ApplicationCenterWS.SMC_PackageManual manual = CopyPackageManual(_manual);
                    bool f = ws.PackageManualSync(manual);
                    flag = flag && f;
                }

                //同步截图表到外网应用中心
                IList<SMC_PackagePicture> pics = bo.GetPackagePictures(entity.pe_id);

                if (pics.Count > 0)
                {
                    foreach (SMC_PackagePicture _pic in pics)
                    {
                        Service.ApplicationCenterWS.SMC_PackagePicture pic = CopyPackagePicture(_pic);
                        bool f = ws.PackagePictuerSync(pic);
                        flag = flag && f;
                    }
                }

                //同步附件到外网应用中心
                string entityFolder = smartbox_console_path + "\\PackageExt\\" + ext.pe_id;
                if (Directory.Exists(entityFolder))
                {
                    string[] files = System.IO.Directory.GetFiles(entityFolder);

                    List<Service.ApplicationCenterWS.FileEntity> fs = new List<Service.ApplicationCenterWS.FileEntity>();
                    foreach (string filePath in files)
                    {
                        if (System.IO.File.Exists(filePath))
                        {
                            FileStream s = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                            Service.ApplicationCenterWS.FileEntity fEntity = new Service.ApplicationCenterWS.FileEntity();
                            fEntity.Content = new byte[s.Length];
                            s.Read(fEntity.Content, 0, (int)s.Length);
                            s.Close();
                            s.Dispose();
                            fEntity.FileName = Path.GetFileName(filePath);
                            fs.Add(fEntity);
                        }
                    }
                    bool f = true;
                    if (fs.Count > 0)
                    {
                        f = ws.PackageFilesSync(fs.ToArray(), ext.pe_id);
                    }
                    flag = flag && f;
                }
                r["r"] = flag;
                r["d"] = "同步" + (flag ? "成功!" : "失败!");
                //同步成功
                ext.pe_SyncStatus = flag ? 1 : 2;
                BoFactory.GetVersionTrackBo.UpdatePackageExt(ext);

                SMC_PackageExtSyncToOutside sync = new SMC_PackageExtSyncToOutside();
                sync.sync_bat_no = batch_no;
                sync.pe_id = ext.pe_id;
                sync.pe_name = ext.pe_Name;
                sync.sync_status = true;
                sync.sync_time = DateTime.Now;
                sync.description = "同步成功";
                BoFactory.GetSMC_PackageExtSyncToOutsideBO.Insert(sync);

            }
            catch (Exception xe)
            {
                Log4NetHelper.Error(xe);
                //同步失败
                BoFactory.GetVersionTrackBo.UpdatePackageExt(ext);

                SMC_PackageExtSyncToOutside sync = new SMC_PackageExtSyncToOutside();
                sync.sync_bat_no = batch_no;
                sync.pe_id = ext.pe_id;
                sync.pe_name = ext.pe_Name;
                sync.sync_status = false;
                sync.sync_time = DateTime.Now;
                sync.description = xe.Message;
                BoFactory.GetSMC_PackageExtSyncToOutsideBO.Insert(sync);
                r["r"] = false;
                r["d"] = "同步失败!";
            }
        }
 protected bool DeleteAppCenterPackageExt(int pe_id)
 {
     Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();
     return ws.DeletePackageExt(pe_id);
 }
        public virtual void UpdatePackageFAQ(SMC_PackageFAQ packageFAQ)
        {
            packageFAQDao.Update(packageFAQ);
            Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();
            Service.ApplicationCenterWS.SMC_PackageFAQ faq = new Service.ApplicationCenterWS.SMC_PackageFAQ();
            faq.pe_id = packageFAQ.pe_id;
            faq.pf_answer = packageFAQ.pf_answer;
            faq.pf_askdate = packageFAQ.pf_askdate;
            faq.pf_askemail = packageFAQ.pf_askemail;
            faq.pf_askmobile = packageFAQ.pf_askmobile;
            faq.pf_id = packageFAQ.pf_id;
            faq.pf_need_syncto_inside = packageFAQ.pf_need_syncto_inside;
            faq.pf_need_syncto_outside = packageFAQ.pf_need_syncto_outside;
            faq.pf_peplyman = packageFAQ.pf_peplyman;
            faq.pf_question = packageFAQ.pf_question;
            faq.pf_uid = packageFAQ.pf_uid;
            faq.pf_uname = packageFAQ.pf_uname;
            //同步问题反馈回复至外网

            ws.PackageFAQSync(faq);
        }
        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 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);
        }
Example #11
0
        /// <summary>
        /// 复制安装包到更新文件目录
        /// </summary>
        /// <param name="ext"></param>
        private void _CopyExtFileToUpdateFilesFolder(SMC_PackageExt ext)
        {
            string pathSource = HttpContext.Current.Server.MapPath(ext.pe_FileUrl);

            //string[] files = Directory.GetFiles(pathSource);

            Dao.Package4AIDao daoPackage4AI             = new Package4AIDao(AppConfig.mainDbKey);
            IList <KeyValuePair <string, object> > pars = new List <KeyValuePair <string, object> >();

            pars.Add(new KeyValuePair <string, object>("id", ext.TableID));
            Package4AI package4AI = daoPackage4AI.Get(pars);

            //string sourceFileName = Path.GetFileName(ext.pe_FileUrl);
            //foreach (string file in files)
            {
                string sFileName = Path.GetFileName(pathSource);

                if (sFileName.EndsWith(".ipa") || sFileName.EndsWith(".apk"))
                {
                    string destFileName = Path.GetFileName(ext.pe_DownloadUri);
                    string destFolder   = AppConfig.PackUploadFolder;
                    if (destFolder.EndsWith(@"\") == false)
                    {
                        destFolder += @"\";
                    }
                    destFolder += destFileName;
                    try
                    {
                        File.Copy(pathSource, destFolder, true);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                }

                string savefilePath = AppConfig.PublishConfig.GetValue(ext.pe_ClientType).Path;
                //saveFileName = savefilePath;
                string saveFilePathOut = "";
                if (savefilePath.IndexOf("$") != -1)
                {
                    string[] savefilePaths = savefilePath.Split("$".ToCharArray());
                    savefilePath    = savefilePaths[0];
                    saveFilePathOut = savefilePaths[1];
                }
                //内网本地存储固定名称的主程序

                try
                {
                    System.IO.File.Copy(pathSource, savefilePath, true);
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error(ex);
                }

                Service.ApplicationCenterWS.WebService acws = new Service.ApplicationCenterWS.WebService();
                //StreamReader sr = new StreamReader();
                FileStream fs      = new FileStream(pathSource, FileMode.Open);
                byte[]     content = new byte[fs.Length];
                fs.Read(content, 0, (int)fs.Length - 1);
                fs.Close();
                fs.Dispose();

                //发布到外网存储固定名称的主程序
                if (package4AI != null && package4AI.Type.ToLower() == "main")
                {
                    acws.RemotePublish(content, saveFilePathOut);
                }
            }
        }
Example #12
0
        /// <summary>
        /// 复制安装包到更新文件目录
        /// </summary>
        /// <param name="ext"></param>
        private void _CopyExtFileToUpdateFilesFolder(SMC_PackageExt ext)
        {
            string pathSource = HttpContext.Current.Server.MapPath(ext.pe_FileUrl);
            //string[] files = Directory.GetFiles(pathSource);

            Dao.Package4AIDao daoPackage4AI = new Package4AIDao(AppConfig.mainDbKey);
            IList<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
            pars.Add(new KeyValuePair<string, object>("id", ext.TableID));
            Package4AI package4AI = daoPackage4AI.Get(pars);

            //string sourceFileName = Path.GetFileName(ext.pe_FileUrl);
            //foreach (string file in files)
            {
                string sFileName = Path.GetFileName(pathSource);

                if (sFileName.EndsWith(".ipa") || sFileName.EndsWith(".apk"))
                {
                    string destFileName = Path.GetFileName(ext.pe_DownloadUri);
                    string destFolder = AppConfig.PackUploadFolder;
                    if (destFolder.EndsWith(@"\") == false)
                    {
                        destFolder += @"\";
                    }
                    destFolder += destFileName;
                    try
                    {
                        File.Copy(pathSource, destFolder, true);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                }

                string savefilePath = AppConfig.PublishConfig.GetValue(ext.pe_ClientType).Path;
                //saveFileName = savefilePath;
                string saveFilePathOut = "";
                if (savefilePath.IndexOf("$") != -1)
                {
                    string[] savefilePaths = savefilePath.Split("$".ToCharArray());
                    savefilePath = savefilePaths[0];
                    saveFilePathOut = savefilePaths[1];
                }
                //内网本地存储固定名称的主程序

                try
                {
                    System.IO.File.Copy(pathSource, savefilePath, true);
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error(ex);
                }

                Service.ApplicationCenterWS.WebService acws = new Service.ApplicationCenterWS.WebService();
                //StreamReader sr = new StreamReader();
                FileStream fs = new FileStream(pathSource, FileMode.Open);
                byte[] content = new byte[fs.Length];
                fs.Read(content, 0, (int)fs.Length - 1);
                fs.Close();
                fs.Dispose();

                //发布到外网存储固定名称的主程序
                if (package4AI != null && package4AI.Type.ToLower() == "main")
                    acws.RemotePublish(content, saveFilePathOut);
            }
        }
Example #13
0
        public virtual void CopyAppFilesToAppCenterServer(string filePath, int pe_id)
        {
            string packUploadFolder = ConfigurationManager.AppSettings["packUploadFolder"];

            if (Directory.Exists(packUploadFolder))
            {
                string[] sourceFiles = null;
                if (pe_id <= 0)
                {
                    sourceFiles = Directory.GetFiles(packUploadFolder);
                }
                else
                {
                    sourceFiles = new string[] { filePath };
                }

                foreach (string file in sourceFiles)
                {
                    string fileName = Path.GetFileName(file);

                    Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

                    FileStream fs = null;
                    byte[] content = null;
                    try
                    {
                        fs = new FileStream(file, FileMode.Open, FileAccess.Read);
                        content = new byte[fs.Length];
                        fs.Read(content, 0, (int)fs.Length - 1);
                        ws.AppFileSync(content, fileName);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                        continue;
                    }
                    finally
                    {
                        fs.Close();
                        fs.Dispose();
                    }
                }

                //更新server缓存
                try
                {
                    SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient();
                    cli.ResetClientVer();
                }
                catch (Exception ex)
                {
                    throw new Exception("文件同步成功,Server缓存数据清除失败。如遇到未提示版本更新问题请联系管理员重启服务", ex);
                }
            }
            else
            {
                Log4NetHelper.Info("packUploadFolder不存在:" + packUploadFolder);
            }
        }
        /// <summary>
        /// 上架
        /// </summary>
        /// <param name="id"></param>
        /// <param name="Operation"></param>
        /// <param name="data"></param>
        public void _SetUserfulStatus(string id, string Operation, JsonReturnMessages data)
        {
            try
            {
                GlobalParam parm = BoFactory.GetGlobalParamBO.Get("app_sj_need_auth");
                bool app_sj_need_auth = parm.ConfigValue == "1";
                SMC_PackageExt ext = BoFactory.GetSMC_PackageExtBO.Get(id);
                //SMC_PackageExt ext = BoFactory.GetVersionTrackBo.GetPackageExt(id);

                switch (Operation)
                {
                    case "ENABLE":
                        ext.pe_Direction = "上架";
                        if (app_sj_need_auth)
                        {
                            //app上架需要审核
                            ext.pe_AuthStatus = 0;
                            ext.pe_AuthSubmitTime = DateTime.Now;
                            ext.pe_AuthSubmitUID = this.CurrentUser.UserUId;
                            ext.pe_AuthSubmitName = this.CurrentUser.FullName;
                            BoFactory.GetSMC_PackageExtBO.Update(ext);
                        }
                        else
                        {
                            ext.pe_UsefulStstus = "1";//上架
                            ext.pe_UsefulOperatorUID = this.CurrentUser.UserUId;
                            ext.pe_UsefulOperatorName = this.CurrentUser.FullName;
                            ext.pe_UsefulTime = DateTime.Now;
                            //app上架不需要审核
                            ext.pe_AuthStatus = 1;
                            BoFactory.GetSMC_PackageExtBO.Update(ext);

                            //内网数据更新
                            BoFactory.GetVersionTrackBo.SetUserfulStatus(id, Operation);

                            //同步至外网数据
                            IProxy proxy = ProxyFactory.CreateProxy();
                            SmartBox.Console.Bo.AppCenter.AppCenterBO bo = proxy.CreateObject<SmartBox.Console.Bo.AppCenter.AppCenterBO>();
                            Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

                            Service.ApplicationCenterWS.SMC_PackageExt entity = CopyPackageExt(ext);

                            //同步安装包到外网应用中心
                            List<int> ids = new List<int>();
                            ids.Add(entity.pe_id);
                            //ws.PackageExtSync(entity);
                            SyncPackages(bo, ws, ids);
                        }
                        break;
                    case "DISABLE":
                        ext.pe_UsefulStstus = "0";//下架
                        ext.pe_UsefulOperatorUID = this.CurrentUser.UserUId;
                        ext.pe_UsefulOperatorName = this.CurrentUser.FullName;
                        ext.pe_UsefulTime = DateTime.Now;
                        ext.pe_Direction = "下架";
                        BoFactory.GetSMC_PackageExtBO.Update(ext);
                        break;
                }

            }
            catch (Exception ex)
            {
                data.IsSuccess = false;
                data.Msg = ex.Message;
                Log4NetHelper.Error(ex);
            }
        }
        public ActionResult PackageFAQList(string id)
        {
            //string TableName = Request.QueryString["TableName"];
            //ViewData["TableName"] = TableName;
            //ViewData["id"] = BoFactory.GetVersionTrackBo.GetPeId(id, TableName);
            Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();
            Service.ApplicationCenterWS.SMC_PackageFAQ[] faqs = ws.GetNeedSyncToInsideFAQ();
            if (faqs != null && faqs.Length > 0)
            {
                for (int i = 0; i < faqs.Length; ++i)
                {
                    SMC_PackageFAQ faq = new SMC_PackageFAQ();
                    faq.pe_id = faqs[i].pe_id;
                    faq.pf_answer = faqs[i].pf_answer;
                    faq.pf_askdate = faqs[i].pf_askdate;
                    faq.pf_askemail = faqs[i].pf_askemail;
                    faq.pf_askmobile = faqs[i].pf_askmobile;
                    faq.pf_id = faqs[i].pf_id;
                    faq.pf_need_syncto_inside = false;
                    faq.pf_need_syncto_outside = false;
                    faq.pf_peplyman = faqs[i].pf_peplyman;
                    faq.pf_question = faqs[i].pf_question;
                    faq.pf_uid = faqs[i].pf_uid;
                    faq.pf_uname = faqs[i].pf_uname;

                    List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                    pars.Add(new KeyValuePair<string, object>("pf_id", faq.pf_id));
                    SMC_PackageFAQ _faq = BoFactory.GetSMC_PackageFAQBO.Get(pars);
                    if (_faq == null)
                    {
                        BoFactory.GetSMC_PackageFAQBO.Insert(faq);
                    }
                    if (faqs[i].pf_need_syncto_inside)
                    {
                        faqs[i].pf_need_syncto_inside = false;
                        ws.PackageFAQSync(faqs[i]);
                    }
                }
            }
            ViewData["id"] = id;
            return View();
        }
        public JsonResult AsyncManage(string pe_ids)
        {
            JsonReturnMessages data = new JsonReturnMessages() { IsSuccess = true, Msg = "" };
            string[] ids = pe_ids.Split(',');
            List<int> ayncpe_ids = new List<int>();
            int id = -1;
            foreach (string s in ids)
            {
                if (int.TryParse(s, out id) == true)
                {
                    ayncpe_ids.Add(id);
                }
            }

            try
            {
                IProxy proxy = ProxyFactory.CreateProxy();
                SmartBox.Console.Bo.AppCenter.AppCenterBO bo = proxy.CreateObject<SmartBox.Console.Bo.AppCenter.AppCenterBO>();

                Service.ApplicationCenterWS.WebService ws = new Service.ApplicationCenterWS.WebService();

                SyncPackages(bo, ws, ayncpe_ids);
                SyncUnits(bo, ws);
                SyncUsers(bo, ws);
            }
            catch (Exception e)
            {
                Log4NetHelper.Error(e);
                data.IsSuccess = false;
                data.Msg = e.Message;
            }
            //获取同步成功的ext列表
            string succMsg = "";
            int batch_no = BoFactory.GetSMC_AutoTableIDBo.GetMaxId("SMC_PackageExtSyncToOutside", "sync_bat_no");
            var syncPs = BoFactory.GetSMC_PackageExtSyncToOutsideBO.GetByBatNo(batch_no);
            foreach (var psync in syncPs)
            {
                if (psync == null || psync.sync_status == false)
                {
                    data.Msg += psync.pe_name + "同步失败,原因是" + psync.description + "\n";
                }
                else if (psync.sync_status == true)
                {
                    succMsg += psync.pe_name + "同步成功\n";
                }
            }
            data.Msg = succMsg + data.Msg;
            return Json(data);
        }