예제 #1
0
파일: Login.xaml.cs 프로젝트: jjg0519/OA
        /// <summary>
        /// 组件下载完成事件
        /// </summary>
        /// <param name="sender">触发对象</param>
        /// <param name="e">返回结果</param>
        void webcDownloadDll_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                string msg = "服务器下载" + downloadDllName + "出错,请联系管理员" + e.Error.ToString();
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(msg);
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", msg });
            }
            try
            {
                #region 将下载的dll保存至本地
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("服务器下载" + downloadDllName + "完成");
                byte[] streambyte = new byte[e.Result.Length];
                e.Result.Read(streambyte, 0, streambyte.Length);
                e.Result.Close();
                IosManager.CreateFile(strApplicationPath, downloadDllName, streambyte);

                #endregion

                needDownDllNames.Remove(downloadDllName);
                List <string> newDlllist = needDownDllNames;
                DownLoadDll(newDlllist);
            }
            catch (Exception ex)
            {
                string msg = "下载更新出错:" + downloadDllName + ex.ToString();
                HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", ex.ToString() });
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(msg);
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                txtUserMsg.Text = "系统更新错误,请联系管理员";
            }
        }
예제 #2
0
        void webcDownloadDll_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("服务器下载" + downloadDllName + "出错,请联系管理员" + e.Error.ToString());
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
            }
            try
            {
                #region 将下载的dll保存至本地
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("服务器下载" + downloadDllName + "完成");
                byte[] streambyte = new byte[e.Result.Length];
                e.Result.Read(streambyte, 0, streambyte.Length);
                e.Result.Close();
                IosManager.CreateFile(strApplicationPath, downloadDllName, streambyte);

                #endregion

                needDownDllNames.Remove(downloadDllName);
                List <string> newDlllist = needDownDllNames;
                DownLoadDll(newDlllist);
            }
            catch (Exception ex)
            {
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("下载更新出错:" + downloadDllName + ex.ToString());
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                Loginform.NotifyUserMessage("系统更新错误,请联系管理员");
            }
        }
예제 #3
0
        /// <summary>
        /// 存储xap文件到本地
        /// </summary>
        /// <param name="xapFileStream">xap文件流</param>
        /// <param name="moduleInfo">子系统信息</param>
        private void SaveLocalXapFile(Stream xapFileStream, ModuleInfo moduleInfo)
        {
            xapFileStream.Position = 0L;
            byte[] buffer = new byte[xapFileStream.Length];
            xapFileStream.Read(buffer, 0, buffer.Length);
            IosManager.CreateFile(moduleInfo.FileName, moduleInfo.FileName, buffer);

            SetLocalVersion(moduleInfo);
        }
예제 #4
0
        /// <summary>
        /// 存储xap版本配置文件到本地
        /// </summary>
        /// <param name="appInfo">文件信息</param>
        private void SetLocalVersion(ModuleInfo moduleInfo)
        {
            XElement moduleInfoXML = new XElement("ModuleInfo",
                                                  new XElement("ModuleName", moduleInfo.ModuleName),
                                                  new XElement("Version", moduleInfo.Version),
                                                  new XElement("FileName", moduleInfo.FileName),
                                                  new XElement("EnterAssembly", moduleInfo.EnterAssembly),
                                                  new XElement("IsSave", moduleInfo.IsSave),
                                                  new XElement("HostAddress", moduleInfo.HostAddress),
                                                  new XElement("ServerID", moduleInfo.ServerID),
                                                  new XElement("ClientID", moduleInfo.ClientID),
                                                  new XElement("Description", moduleInfo.Description)
                                                  );


            IosManager.CreateFile(moduleInfo.FileName, moduleInfo.FileName + VERSION, moduleInfoXML);
        }
예제 #5
0
파일: Login.xaml.cs 프로젝트: jjg0519/OA
        /// <summary>
        /// 组件下载完成事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void webcDllVersion_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    string msg = "下载版本文件出错,请联系管理员" + e.Error.ToString();
                    SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(msg);
                    SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                    HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", msg });
                    return;
                }
                if (e.Result.Length < 1)
                {
                    SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("获取服务器更新列表为空,请联系管理员");
                    SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                    txtUserMsg.Text = "获取服务器更新列表出错,请联系管理员";
                    HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", txtUserMsg.Text });
                    return;
                }
                //txtUserMsg.Text = "获取服务器更新列表成功,正在获取更新......";
                //将读取服务器下载的Dll Version XML
                StreamResourceInfo sXapSri             = new StreamResourceInfo(e.Result, "text/xml");
                Stream             manifestStream      = sXapSri.Stream;
                string             strVersionXmlServer = new StreamReader(manifestStream).ReadToEnd();
                //Linq to xml   manifestStream
                XElement dllVersionXElementServer     = XDocument.Parse(strVersionXmlServer).Root;
                var      dllVersionXElementlistServer = (from ent in dllVersionXElementServer.Elements().Elements()
                                                         select ent).ToList();

                //本地存在dllversion.xml文件
                if (IosManager.ExistsFile(dllVersionFilePath))
                {
                    //比较版本并下载新版本的dll及zip文件
                    IsolatedStorageFileStream xmlIsoStreamLocal = IosManager.GetFileStream(dllVersionFilePath);
                    StreamResourceInfo        sXapSrilocal      = new StreamResourceInfo(xmlIsoStreamLocal, "text/xml");
                    Stream versionXmlStreamLocal = sXapSrilocal.Stream;
                    string versionXmlLocal       = new StreamReader(versionXmlStreamLocal).ReadToEnd();
                    xmlIsoStreamLocal.Close();
                    if (string.IsNullOrEmpty(versionXmlLocal))
                    {
                        needDownDllNames = (from ent in dllVersionXElementlistServer
                                            select ent.Attribute("Source").Value).ToList();

                        DownLoadDll(needDownDllNames);
                        return;
                    }
                    XElement deploymentRoot       = XDocument.Parse(versionXmlLocal).Root;
                    var      dllVersionglistlocal = (from assemblyParts in deploymentRoot.Elements().Elements()
                                                     select assemblyParts).ToList();

                    var needUpdataDlls = from a in dllVersionXElementlistServer
                                         join b in dllVersionglistlocal
                                         on a.Attribute("Source").Value equals b.Attribute("Source").Value
                                             where a.Attribute("version").Value != b.Attribute("version").Value
                                         select a;

                    if (needUpdataDlls.Count() > 0)
                    {
                        //txtUserMsg.Text = "系统检查到更新,正在更新本地程序,请稍等......";
                        needDownDllNames = (from ent in needUpdataDlls
                                            select ent.Attribute("Source").Value).ToList();

                        DownLoadDll(needDownDllNames);
                    }
                    else
                    {
                        //从本地加载系统
                        LoadData(strApplicationPath + @"/SMT.SAAS.Platform.xap");
                    }
                }
                else
                {
                    //从服务器下载所有包
                    needDownDllNames = (from ent in dllVersionXElementlistServer
                                        select ent.Attribute("Source").Value).ToList();

                    DownLoadDll(needDownDllNames);
                }
            }
            catch (Exception ex)
            {
                string msg = "更新系统出错,请联系管理员:" + ex.ToString();
                HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", msg });
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(msg);
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                txtUserMsg.Text = "系统更新错误,请联系管理员";
            }
            finally
            {
                //存储versxml到本地
                byte[] streambyte = new byte[e.Result.Length];
                e.Result.Seek(0, SeekOrigin.Begin);
                e.Result.Read(streambyte, 0, streambyte.Length);
                e.Result.Close();
                IosManager.CreateFile(strApplicationPath, "DllVersion.xml", streambyte);
            }
        }
예제 #6
0
        /// <summary>
        /// 组件下载完成事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void webcDllVersion_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("下载版本文件出错,请联系管理员" + e.Error.ToString());
                    SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                    return;
                }
                if (e.Result.Length < 1)
                {
                    SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("获取服务器更新列表为空,请联系管理员");
                    SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                    Loginform.NotifyUserMessage("获取服务器更新列表出错,请联系管理员");
                    return;
                }
                Loginform.NotifyUserMessage("获取服务器更新列表成功,正在获取更新......");
                //将读取服务器下载的Dll Version XML
                StreamResourceInfo XapSri              = new StreamResourceInfo(e.Result, "text/xml");
                Stream             manifestStream      = XapSri.Stream;
                string             strVersionXmlServer = new StreamReader(manifestStream).ReadToEnd();
                //Linq to xml   manifestStream
                XElement dllVersionXElementServer     = XDocument.Parse(strVersionXmlServer).Root;
                var      dllVersionXElementlistServer = (from ent in dllVersionXElementServer.Elements().Elements()
                                                         select ent).ToList();

                //本地存在dllversion.xml文件
                if (IosManager.ExistsFile(dllVersionFilePath))
                {
                    //比较版本并下载新版本的dll及zip文件
                    IsolatedStorageFileStream xmlIsoStreamLocal = IosManager.GetFileStream(dllVersionFilePath);
                    StreamResourceInfo        XapSrilocal       = new StreamResourceInfo(xmlIsoStreamLocal, "text/xml");
                    Stream versionXmlStreamLocal = XapSrilocal.Stream;
                    string versionXmlLocal       = new StreamReader(versionXmlStreamLocal).ReadToEnd();
                    xmlIsoStreamLocal.Close();
                    if (string.IsNullOrEmpty(versionXmlLocal))
                    {
                        needDownDllNames = (from ent in dllVersionXElementlistServer
                                            select ent.Attribute("Source").Value).ToList();

                        DownLoadDll(needDownDllNames);
                        return;
                    }
                    XElement deploymentRoot       = XDocument.Parse(versionXmlLocal).Root;
                    var      dllVersionglistlocal = (from assemblyParts in deploymentRoot.Elements().Elements()
                                                     select assemblyParts).ToList();

                    var needUpdataDlls = from a in dllVersionXElementlistServer
                                         join b in dllVersionglistlocal
                                         on a.Attribute("Source").Value equals b.Attribute("Source").Value
                                             where a.Attribute("version").Value != b.Attribute("version").Value
                                         select a;

                    if (needUpdataDlls.Count() > 0)
                    {
                        Loginform.NotifyUserMessage("系统检测到更新,正在更新本地程序,请稍等......");
                        needDownDllNames = (from ent in needUpdataDlls
                                            select ent.Attribute("Source").Value).ToList();

                        DownLoadDll(needDownDllNames);
                    }
                    else
                    {
                        //判断是否所有dll都在本地存在,处理那种下载途中断网后的问题
                        List <string> needDownload = new List <string>();
                        foreach (var q in dllVersionglistlocal)
                        {
                            string filepath = strApplicationPath + @"/" + q.Attribute("Source").Value;
                            if (!IosManager.ExistsFile(filepath))
                            {
                                Loginform.NotifyUserMessage(@"silverlight本地存储异常,请右键点击silverlight
                                ,选择应用程序存储,然后点击全部删除后刷新页面再试");
                                needDownload.Add(q.Attribute("Source").Value);
                                break;
                            }
                        }
                        if (needDownload.Count() > 0)
                        {
                            //DownLoadDll(needDownload);
                        }
                        else
                        {
                            if (UpdateDllCompleted != null)
                            {
                                UpdateDllCompleted(this, null);
                            }
                        }
                    }
                }
                else
                {
                    //从服务器下载所有包
                    needDownDllNames = (from ent in dllVersionXElementlistServer
                                        select ent.Attribute("Source").Value).ToList();

                    DownLoadDll(needDownDllNames);
                }
            }
            catch (Exception ex)
            {
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("更新系统出错,请联系管理员:" + ex.ToString());
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                Loginform.NotifyUserMessage("系统更新错误,请联系管理员");
            }
            finally
            {
                //存储versxml到本地
                byte[] streambyte = new byte[e.Result.Length];
                e.Result.Seek(0, SeekOrigin.Begin);
                e.Result.Read(streambyte, 0, streambyte.Length);
                e.Result.Close();
                IosManager.CreateFile(strApplicationPath, "DllVersion.xml", streambyte);
            }
        }