Пример #1
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("系统更新错误,请联系管理员");
            }
        }
Пример #2
0
        /// <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 = "系统更新错误,请联系管理员";
            }
        }
Пример #3
0
        /// <summary>
        /// 获取本地配置文件
        /// </summary>
        /// <returns></returns>
        private ModuleInfo GetLocalVersion(string filePath)
        {
            //获取本地的升级文件
            //  string filePath = string.Format("{0}/{1}", xapInfo.FileName, VersionFileName);
            if (IosManager.ExistsFile(filePath))
            {
                using (Stream localfilesm = new MemoryStream(IosManager.GetFileBytes(filePath)))
                {
                    XElement xmlClient = XElement.Load(System.Xml.XmlReader.Create(localfilesm));

                    ModuleInfo modeuleInfo = (from c in xmlClient.DescendantsAndSelf("ModuleInfo")
                                              select new ModuleInfo
                    {
                        ModuleName = c.Elements("ModuleName").SingleOrDefault().Value,
                        Version = c.Elements("Version").SingleOrDefault().Value,
                        FileName = c.Elements("FileName").SingleOrDefault().Value,
                        EnterAssembly = c.Elements("EnterAssembly").SingleOrDefault().Value,
                        IsSave = c.Elements("IsSave").SingleOrDefault().Value,
                        HostAddress = c.Elements("HostAddress").SingleOrDefault().Value,
                        ServerID = c.Elements("ServerID").SingleOrDefault().Value,
                        ClientID = c.Elements("ClientID").SingleOrDefault().Value,
                        Description = c.Elements("Description").SingleOrDefault().Value,
                    }).FirstOrDefault();
                    return(modeuleInfo);
                }
            }
            else
            {
                return(new ModuleInfo()
                {
                    Version = "1.0.0.0000"
                });
            }
        }
Пример #4
0
 public void OnExit(RoleInfo roleInfo)
 {
     if (roleInfo.roleID != 0)
     {
         SubmitRoleInfo(roleInfo);
     }
     //SendToSDK("Exit");
     IosManager.Exit();
 }
Пример #5
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);
        }
Пример #6
0
    public string GetPhoneModel()
    {
        //string model = sdkUtil.CallAPI<string>("GetPhoneModel");
        string model = IosManager.GetPhoneModel();

        if (model == null)
        {
            model = "";
        }
        return(model);
    }
Пример #7
0
        ///<summary>
        /// 获取本地的xap文件包
        /// </summary>
        /// <returns>xap文件流</returns>
        private Stream GetLocalXapFile(string fileName)
        {
            string filePath = string.Format("{0}/{1}", fileName, fileName);

            byte[] fileBytes = IosManager.GetFileBytes(filePath);
            if ((fileBytes != null) && (fileBytes.Length > 0))
            {
                return(new MemoryStream(fileBytes, 0, fileBytes.Length));
            }
            return(Stream.Null);
        }
Пример #8
0
    public string GetPhoneBrand()
    {
        //string brand = sdkUtil.CallAPI<string>("GetPhoneBrand");
        string brand = IosManager.GetPhoneBrand();

        if (brand == null)
        {
            brand = "";
        }
        return(brand);
    }
Пример #9
0
    public string GetMacAddress()
    {
        //string mac = sdkUtil.CallAPI<string>("GetMacAddress");
        string mac = IosManager.GetMacAdress();

        if (mac == null)
        {
            mac = "";
        }
        return(mac);
    }
Пример #10
0
    public string GetDeviceId()
    {
        //string device = sdkUtil.CallAPI<string>("GetDeviceId");
        string device = IosManager.GetDeviceId();

        if (device == null)
        {
            device = "";
        }
        return(device);
    }
Пример #11
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);
        }
Пример #12
0
        /// <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);
            }
        }
Пример #13
0
        /// <summary>
        ///  检查登录
        /// </summary>
        private void CheckLoginUser()
        {
            try
            {
                if (!IosManager.CheckeSpace())
                {
                    try
                    {
                        if (!IosManager.AddSpace())
                        {
                            MessageBox.Show("请增加独立存储空间,否则系统无法运行");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("增加独立存储空间出错,原因如下:" + ex.ToString());
                    }
                }

                if (!IosManager.ExistsFile(strApplicationPath))
                {
                    IosManager.CreatePath(strApplicationPath);
                    isFirstUser     = true;
                    txtUserMsg.Text = "初次访问协同办公系统,请点击上方按钮--增加系统存储空间,以确保系统能正常运行";
                }

                btnAddSpace.Visibility = System.Windows.Visibility.Collapsed;

                string strUid = string.Empty, strUserName = string.Empty;

                if (Application.Current.Resources["CurrentSysUserID"] != null)
                {
                    strUid = Application.Current.Resources["CurrentSysUserID"].ToString();
                }

                if (Application.Current.Resources["username"] != null)
                {
                    strUserName = Application.Current.Resources["username"].ToString();
                }

                if (string.IsNullOrWhiteSpace(strUid) || string.IsNullOrWhiteSpace(strUserName))
                {
                    txtUserMsg.Text = "警告!用户信息异常,不能执行当前的操作请求。";
                    if (string.IsNullOrWhiteSpace(strUid))
                    {
                        AppContext.SystemMessage("传入的用户CurrentSysUserID为空");
                        AppContext.ShowSystemMessageText();
                    }
                    if (string.IsNullOrWhiteSpace(strUserName))
                    {
                        AppContext.SystemMessage("传入的用户username为空");
                        AppContext.ShowSystemMessageText();
                    }
                    return;
                }

                if (!App.AppSettings.Contains(USERKEY))
                {
                    App.AppSettings.Add(USERKEY, strUserName);
                    isFirstUser = true;
                }
                else
                {
                    App.AppSettings[USERKEY] = strUserName;
                }

                sysloginClinet.GetUserInfobyIDAsync(strUid);
                //txtUserMsg.Text = "系统正在加载,请稍等......";
            }
            catch (Exception ex)
            {
                btnAddSpace.Visibility = System.Windows.Visibility.Visible;
                string msg = "系统错误,请联系管理员:" + ex.ToString();
                txtUserMsg.Text = msg;
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(msg);
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", msg });
            }
        }
Пример #14
0
        public void StartSilverlight(string strmoduleid, string stropttype, string strmessageid, string strconfig, string strUid, string strUserName)
        {
            try
            {
                ibLogin.Visibility    = System.Windows.Visibility.Collapsed;
                spAddSpace.Visibility = System.Windows.Visibility.Visible;
                btnAddSpace.IsEnabled = true;
                if (string.IsNullOrWhiteSpace(strUid) || string.IsNullOrWhiteSpace(stropttype) || string.IsNullOrWhiteSpace(strUserName))
                {
                    txtUserMsg.Text = "关键信息未获取到,操作被阻止!";
                    return;
                }


                //txtUserMsg.Text += "[" + strUid + ";" + stropttype + ";" + strUserName + "]";

                if (Application.Current.Resources["CurrentSysUserID"] != null)
                {
                    Application.Current.Resources.Remove("CurrentSysUserID");
                }

                Application.Current.Resources.Add("CurrentSysUserID", strUid);

                if (Application.Current.Resources["username"] != null)
                {
                    Application.Current.Resources.Remove("username");
                }
                Application.Current.Resources.Add("username", strUserName);

                //标明第一次打开
                if (Application.Current.Resources["isFirstOpen"] != null)
                {
                    Application.Current.Resources.Remove("isFirstOpen");
                }
                Application.Current.Resources.Add("isFirstOpen", true);

                List <string> MvcSourcelist = new List <string>();
                MvcSourcelist.Add(strmoduleid);
                MvcSourcelist.Add(stropttype);
                MvcSourcelist.Add(strmessageid);
                MvcSourcelist.Add(strconfig);
                AppContext.SystemMessage("StartSilverlight-------------"
                                         + "strModuleid:" + strmoduleid + System.Environment.NewLine
                                         + "strOptType:" + stropttype + System.Environment.NewLine
                                         + "strMessageid:" + strmessageid + System.Environment.NewLine
                                         + "strConfig:" + strconfig + System.Environment.NewLine
                                         + "strUid:" + strUid + System.Environment.NewLine
                                         + "strUserName:"******"MvcOpenRecordSource"] != null)
                {
                    Application.Current.Resources.Remove("MvcOpenRecordSource");
                }

                Application.Current.Resources.Add("MvcOpenRecordSource", MvcSourcelist);

                //SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                if (IosManager.CheckeSpace())
                {
                    CheckLoginUser();
                }
            }
            catch (Exception ex)
            {
                AppContext.logAndShow("StartSilverlight 异常:" + ex.ToString());
            }
        }
Пример #15
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);
            }
        }
Пример #16
0
        private void LoadAssemblyPart(Object state)
        {
            string          XapName         = strApplicationPath + @"/SMT.SAAS.Platform.xap";
            string          DllSourceName   = string.Empty;
            AssemblyPart    asmPart         = null;
            List <XElement> deploymentParts = new List <XElement>();

            try
            {
                #region "直接加载xap包中的dll"
                dtstart = DateTime.Now;
                using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
                {
                    //打开本地xap包流

                    IsolatedStorageFileStream XapfileStream = store.OpenFile(XapName, FileMode.Open, FileAccess.Read);
                    if (XapfileStream.Length == 0)
                    {
                        //IosManager.DeletFile(ApplicationPath, "SMT.SAAS.Platform.Main.xap");
                        List <string> dllNames = new List <string>();
                        dllNames.Add("SMT.SAAS.Platform.xap");
                        DownLoadDll(dllNames);
                    }

                    #region Original Code
                    StreamResourceInfo XapSri         = new StreamResourceInfo(XapfileStream, "application/binary");
                    Stream             manifestStream = Application.GetResourceStream(XapSri, new Uri("AppManifest.xaml", UriKind.Relative)).Stream;

                    string appManifest = new StreamReader(manifestStream).ReadToEnd();
                    manifestStream.Close();
                    //Linq to xml
                    XElement deploymentRoot = XDocument.Parse(appManifest).Root;
                    deploymentParts = (from assemblyParts in deploymentRoot.Elements().Elements()
                                       select assemblyParts).ToList();
                    //检测所有包是否在本地,不在,就从服务器上下载
                    bool          canStart  = true;
                    List <string> dllDelete = new List <string>();
                    foreach (XElement xElement in deploymentParts)
                    {
                        if (xElement.Attribute("Source").Value.Contains("zip") &&
                            !IosManager.ExistsFile(strApplicationPath + @"/" + xElement.Attribute("Source").Value))
                        {
                            dllDelete.Add(xElement.Attribute("Source").Value);
                            canStart = false;
                        }
                    }
                    if (!canStart)
                    {
                        DownLoadDll(dllDelete);
                        return;
                    }

                    StreamResourceInfo streamInfo;
                    //Assembly assemblyViewModel = null;
                    foreach (XElement xElement in deploymentParts)
                    {
                        try
                        {
                            DllSourceName = xElement.Attribute("Source").Value;
                            dtstart       = DateTime.Now;
                            //form.setLoadmingMessage( "正在加载:" + DllSourceName);
                            if (!DllSourceName.Contains("zip"))
                            {
                                //直接加载dll
                                asmPart        = new AssemblyPart();
                                asmPart.Source = DllSourceName;
                                streamInfo     = Application.GetResourceStream(new StreamResourceInfo(XapfileStream, "application/binary"), new Uri(DllSourceName, UriKind.Relative));

                                if (DllSourceName == "SMT.SAAS.Platform.dll")
                                {
                                    asmMain = asmPart.Load(streamInfo.Stream);
                                }
                                else
                                {
                                    var a = asmPart.Load(streamInfo.Stream);
                                }
                                streamInfo.Stream.Close();
                            }
                            else
                            {
                                //加载zip包
                                //form.setLoadmingMessage("正在加载:" + DllSourceName);
                                if (DllSourceName.Contains("zip"))
                                {
                                    //打开本地zip包流
                                    IsolatedStorageFileStream zipfileStream = IosManager.GetFileStream(strApplicationPath + @"/" + DllSourceName);
                                    streamInfo     = Application.GetResourceStream(new StreamResourceInfo(zipfileStream, "application/binary"), new Uri(DllSourceName.Replace("zip", "dll"), UriKind.Relative));
                                    asmPart        = new AssemblyPart();
                                    asmPart.Source = DllSourceName.Replace("zip", "dll");
                                    var a = asmPart.Load(streamInfo.Stream);
                                    streamInfo.Stream.Close();
                                    SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("从Zip文件中加载程序集: " + a.FullName);
                                }
                            }
                            dtend = DateTime.Now;
                            string strmsg = "加载成功:" + DllSourceName + " 加载耗时: " + (dtend - dtstart).Milliseconds.ToString() + " 毫秒";
                            SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(strmsg);
                        }
                        catch (Exception ex)
                        {
                            string strmsg = "加载失败:" + DllSourceName + " 错误信息: " + ex.ToString();
                            SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(strmsg);
                            SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                            Loginform.NotifyUserMessage("系统加载出错,请联系管理员");
                            return;
                        }
                    }

                    #endregion
                }
                #endregion

                Loginform.NotifyUserMessage("系统检测更新完毕,请您登录系统");
                Loginform.setbtnLoginEnable(true);
            }
            catch (Exception ex)
            {
                Loginform.NotifyUserMessage(@"silverlight本地存储异常,请右键点击silverlight
                                ,选择应用程序存储,然后点击全部删除后刷新页面再试");
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(DllSourceName + " 加载系统出错:" + ex.ToString());
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
            }
        }
Пример #17
0
 public void PlayVoice(string filePath, float soundValue)
 {
     //SendToSDK("PlayVoice", filePath, soundValue.ToString());
     IosManager.PlayVoice(filePath, soundValue.ToString());
 }
Пример #18
0
 public void OpenLoginView()
 {
     IosManager.OpenLoginWindow();
 }
Пример #19
0
        /// <summary>
        /// 系统登录
        /// </summary>
        public void userloading()
        {
            btnLogin.IsEnabled = false;
            try
            {
                if (!IosManager.CheckeSpace())
                {
                    try
                    {
                        if (!IosManager.AddSpace())
                        {
                            MessageBox.Show("请增加独立存储空间,否则系统无法运行");
                            btnLogin.IsEnabled = true;
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("增加独立存储空间出错,请联系管理员" + ex.ToString());
                    }
                }

                if (!IosManager.ExistsFile(ApplicationPath))
                {
                    IosManager.CreatePath(ApplicationPath);
                }
                if (!IsAllFilled())
                {
                    btnLogin.IsEnabled = true;
                    return;
                }
                if (!App.AppSettings.Contains(USERKEY))
                {
                    App.AppSettings.Add(USERKEY, txbUserName.Text);
                }
                else
                {
                    App.AppSettings[USERKEY] = txbUserName.Text;
                }

                string UserPwdMD5 = string.Empty;
                if (Application.Current.Resources["userpwd"] != null)
                {
                    UserPwdMD5 = Application.Current.Resources["userpwd"].ToString();
                }
                else
                {
                    UserPwdMD5 = MD5.GetMd5String(this.txbUserPassword.Password);
                }
                sysloginClinet.SystemLoginAsync(this.txbUserName.Text, UserPwdMD5);

                txtLoadingMessage.Text = "开始登录系统,请稍等......";
                DateTime dtstart = DateTime.Now;
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("开始登录系统,请稍等......");

                //sysloginClinet.SystemLoginAsync(this.txbUserName.Text, Utility.Encrypt(this.txbUserPassword.Password));
            }
            catch (Exception ex)
            {
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("系统错误,请联系管理员:" + ex.ToString());
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                btnLogin.IsEnabled = true;
            }
        }
Пример #20
0
 public void SetCallBack()
 {
     IosManager.SetCallback("GameWorld");
 }
Пример #21
0
 public void StartVoice()
 {
     //("StartVoice");
     IosManager.StartVoice();
 }
Пример #22
0
 public void StopPlayVoice()
 {
     //SendToSDK("StopPlayVoice");
     IosManager.StopPlayVoice();
 }
Пример #23
0
 public void OpenPay(PayParam param)
 {
     IosManager.OpenPay(JsonFx.Json.JsonWriter.Serialize(param));
 }
Пример #24
0
        /// <summary>
        /// 加载数据包
        /// </summary>
        /// <param name="strXapName">xap包名称</param>
        private void LoadData(string strXapName)
        {
            string          sDllSourceName  = string.Empty;
            AssemblyPart    asmPart         = null;
            List <XElement> deploymentParts = new List <XElement>();

            try
            {
                #region "直接加载xap包中的dll"
                dtstart = DateTime.Now;
                using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
                {
                    //打开本地xap包流
                    IsolatedStorageFileStream sXapfileStream = store.OpenFile(strXapName, FileMode.Open, FileAccess.Read);
                    if (sXapfileStream.Length == 0)
                    {
                        //IosManager.DeletFile(ApplicationPath, "SMT.SAAS.Platform.Main.xap");
                        List <string> dllNames = new List <string>();
                        dllNames.Add("SMT.SAAS.Platform.xap");
                        DownLoadDll(dllNames);
                    }

                    #region Original Code
                    StreamResourceInfo srXapSri       = new StreamResourceInfo(sXapfileStream, "application/binary");
                    Stream             manifestStream = Application.GetResourceStream(srXapSri, new Uri("AppManifest.xaml", UriKind.Relative)).Stream;

                    string appManifest = new StreamReader(manifestStream).ReadToEnd();
                    manifestStream.Close();
                    //Linq to xml
                    XElement deploymentRoot = XDocument.Parse(appManifest).Root;
                    deploymentParts = (from assemblyParts in deploymentRoot.Elements().Elements()
                                       select assemblyParts).ToList();
                    //检测所有包是否在本地,不在,就从服务器上下载
                    bool          canStart  = true;
                    List <string> dllDelete = new List <string>();
                    foreach (XElement xElement in deploymentParts)
                    {
                        if (xElement.Attribute("Source").Value.Contains("zip") &&
                            !IosManager.ExistsFile(strApplicationPath + @"/" + xElement.Attribute("Source").Value))
                        {
                            dllDelete.Add(xElement.Attribute("Source").Value);
                            canStart = false;
                        }
                    }
                    if (!canStart)
                    {
                        DownLoadDll(dllDelete);
                        return;
                    }

                    StreamResourceInfo streamInfo;
                    //Assembly assemblyViewModel = null;
                    string message = string.Empty;
                    foreach (XElement xElement in deploymentParts)
                    {
                        try
                        {
                            sDllSourceName = xElement.Attribute("Source").Value;
                            dtstart        = DateTime.Now;
                            //setLoadmingMessage( "正在加载:" + DllSourceName);
                            if (!sDllSourceName.Contains("zip"))
                            {
                                //直接加载dll
                                asmPart        = new AssemblyPart();
                                asmPart.Source = sDllSourceName;
                                streamInfo     = Application.GetResourceStream(new StreamResourceInfo(sXapfileStream, "application/binary"), new Uri(sDllSourceName, UriKind.Relative));

                                if (sDllSourceName == "SMT.SAAS.Platform.dll")
                                {
                                    asmMain = asmPart.Load(streamInfo.Stream);
                                }
                                else
                                {
                                    var a = asmPart.Load(streamInfo.Stream);
                                    message = message + a.FullName + System.Environment.NewLine + "从DLL文件中直接加载程序集: " + a.FullName;
                                }
                                streamInfo.Stream.Close();
                            }
                            else
                            {
                                //加载zip包
                                //setLoadmingMessage("正在加载:" + DllSourceName);
                                if (sDllSourceName.Contains("zip"))
                                {
                                    //打开本地zip包流
                                    IsolatedStorageFileStream zipfileStream = IosManager.GetFileStream(strApplicationPath + @"/" + sDllSourceName);
                                    streamInfo     = Application.GetResourceStream(new StreamResourceInfo(zipfileStream, "application/binary"), new Uri(sDllSourceName.Replace("zip", "dll"), UriKind.Relative));
                                    asmPart        = new AssemblyPart();
                                    asmPart.Source = sDllSourceName.Replace("zip", "dll");
                                    var a = asmPart.Load(streamInfo.Stream);
                                    streamInfo.Stream.Close();
                                    message = message + a.FullName + System.Environment.NewLine + "从Zip文件中加载程序集: " + a.FullName;
                                    SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("从Zip文件中加载程序集: " + a.FullName);
                                }
                            }
                            dtend = DateTime.Now;
                            string strmsg = "加载成功:" + sDllSourceName + " 加载耗时: " + (dtend - dtstart).Milliseconds.ToString() + " 毫秒";
                            SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(strmsg);
                        }
                        catch (Exception ex)
                        {
                            string strmsg = "加载失败:" + sDllSourceName + " 错误信息: " + ex.ToString();
                            SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(strmsg);
                            SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
                            setLoadmingMessage("系统加载出错,请联系管理员");
                            HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", strmsg });
                            return;
                        }
                    }
                    message = string.Empty;;
                    #endregion
                }
                #endregion

                setLoadmingMessage("系统检测更新完毕,正在打开单据,请稍后...");

                //return;
                if (isFirstUser == true)
                {
                    //MainPage = asmMain.CreateInstance("SMT.SAAS.Platform.Xamls.MainPage") as UIElement;
                    uMainPage = asmMain.CreateInstance("SMT.SAAS.Platform.Xamls.MVCMainPage") as UIElement;
                    if (uMainPage == null)
                    {
                        MessageBox.Show("系统加载错误,请清空silverlight缓存后再试,或联系管理员");
                        setLoadmingMessage("系统加载错误,请清空silverlight缓存后再试,或联系管理员");
                        return;
                    }
                    AppContext.AppHost.SetRootVisual(uMainPage);
                }
            }
            catch (Exception ex)
            {
                HtmlPage.Window.Invoke("loadCompletedSL", new string[] { "false", ex.ToString() });
                this.txtUserMsg.Text = @"silverlight本地存储异常,请右键点击silverlight"
                                       + System.Environment.NewLine + "选择应用程序存储,然后点击全部删除后刷新页面再试";
                SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage(sDllSourceName + " 加载系统出错:" + ex.ToString());
                SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText();
            }
        }
Пример #25
0
        void LoginForm_Loaded(object sender, RoutedEventArgs e)
        {
            btnLogin.IsEnabled = false;

            if (App.AppSettings.Contains(USERKEY))
            {
                txbUserName.Text = App.AppSettings[USERKEY].ToString();
            }

            if (Application.Current.Resources["username"] != null &&
                Application.Current.Resources["userpwd"] != null)
            {
                this.txbUserName.Text         = Application.Current.Resources["username"].ToString();
                this.txbUserPassword.Password = Application.Current.Resources["userpwd"].ToString();
                isAutoloaded = true;
                MainPageManeger.isAutoloaded = this.isAutoloaded;
            }

            if (string.IsNullOrEmpty(txbUserName.Text))
            {
                txbUserName.Focus();
                //txbUserName.Text = "smtwangl";
                //txbUserPassword.Password = "******";
            }
            else
            {
                txbUserPassword.Focus();
            }
            if (IosManager.ExistsFile(dllVersionFilePath))
            {
                //判断所有文件是否在本地存在
                SMT.SaaS.LocalData.Tables.V_UserLogin us = new SaaS.LocalData.Tables.V_UserLogin();
                //us = SMT.SaaS.LocalData.ViewModel.V_UserLoginVM.Get_V_UserLogin(txbUserName.Text);
                if (IsolatedStorageSettings.ApplicationSettings.Contains("user"))
                {
                    us = IsolatedStorageSettings.ApplicationSettings["user"] as SMT.SaaS.LocalData.Tables.V_UserLogin;
                }
                if (!string.IsNullOrEmpty(us.EMPLOYEEID))
                {
                    isFirstUser = false;
                    MainPageManeger.isFirstUser = false;
                    NotifyUserMessage("系统正在检测更新,请您稍等......");
                    MainPageManeger.dllVersionUpdataCheck();
                }
                else
                {
                    isFirstUser        = true;
                    btnLogin.IsEnabled = true;
                    NotifyUserMessage("您第一次使用系统,需要下载较多内容,登录后请您耐心等候");
                }
            }
            else
            {
                isFirstUser = true;
            }

            if (isFirstUser)
            {
                btnLogin.IsEnabled     = true;
                txtLoadingMessage.Text = "您第一次使用系统,需要下载较多内容,登录后请您耐心等候";
            }
        }
Пример #26
0
 public void SubmitRoleInfo(RoleInfo roleInfo)
 {
     //SendToSDK("SubmitRoleInfo", JsonFx.Json.JsonWriter.Serialize(roleInfo));
     IosManager.SumbitRoleInfo(JsonFx.Json.JsonWriter.Serialize(roleInfo));
 }
Пример #27
0
 public void StopVoice(long playerId)
 {
     //SendToSDK("StopVoice", playerId.ToString());
     IosManager.StopVoice(playerId);
 }
Пример #28
0
 protected string GetSdkConfig()
 {
     sdkUtil.ClassName = GetSdkConfigClass();
     //return sdkUtil.CallAPI<string>("GetConfig");
     return(IosManager.GetConfig());
 }
Пример #29
0
 public void Init()
 {
     this.LoadSdkConifg();
     IosManager.SDKInit();
     this.SetCallBack();
 }