Ejemplo n.º 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            UpdateChecker     uc = new UpdateChecker();
            UpdateInformation ui = uc.GetNewVersion(_updateCheckUrl);

            if (ui.UpdateAvailable)
            {
                linkLabel1.Text              = String.Format(StringResources.UpdateAvailable, ui.OnlineVersion, ui.CurrentVersion);
                linkLabel1.Image             = Resources.update16;
                linkLabel1.ForeColor         = Color.DarkGreen;
                _updateDownloadUrl           = ui.DownloadUrl;
                buttonDownloadUpdate.Visible = true;
            }
            else
            {
                if (ui.OnlineVersion != null)
                {
                    linkLabel1.Text  = StringResources.ProgramVersionUptodate;
                    linkLabel1.Image = Resources.ok16;
                }
                else
                {
                    linkLabel1.Text = StringResources.ConnectionToUpdateServerFailed;
                }
                buttonDownloadUpdate.Visible = false;
            }
            timer1.Stop();
        }
        public IUser GetApplicationUser(IUserContext appUserContext, IDataContext dataContext)
        {
            UpdateInformation updateInformation = new UpdateInformation();

            updateInformation.CreatedBy    = AnalysisPortalTestSettings.Default.TestUserId + 1;
            updateInformation.CreatedDate  = DateTime.Now;
            updateInformation.ModifiedBy   = AnalysisPortalTestSettings.Default.TestUserId + 1;
            updateInformation.ModifiedDate = DateTime.Now;

            IUser appUser = new ArtDatabanken.Data.Fakes.StubIUser()
            {
                UserNameGet           = () => { return(AnalysisPortalTestSettings.Default.TestUserName + "Appuser"); },
                ApplicationIdGet      = () => { return(AnalysisPortalTestSettings.Default.TestnAnalysisPortalApplcationId); },
                IsAccountActivatedGet = () => { return(true); },
                EmailAddressGet       = () => { return(AnalysisPortalTestSettings.Default.TestUserEmail + "Appuser"); },
                DataContextGet        = () => { return(dataContext); },
                GUIDGet              = () => { return(AnalysisPortalTestSettings.Default.TestUserGuid + "Appuser"); },
                IdGet                = () => { return(AnalysisPortalTestSettings.Default.TestUserId + 1); },
                ShowEmailAddressGet  = () => { return(true); },
                TypeGet              = () => { return(UserType.Person); },
                UpdateInformationGet = () => { return(updateInformation); },
                ValidFromDateGet     = () => { return(DateTime.Now); },
                ValidToDateGet       = () => { return(new DateTime(2144, 12, 31)); }
            };



            return(appUser);
        }
Ejemplo n.º 3
0
        private void bu_go_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            List <RemoteFile> list = Local.DefaultRemoteFileList(tb_dir.Text, tb_urlbase.Text);
            UpdateInformation inf  = new UpdateInformation();

            inf.FileList       = list;
            inf.UpdateDescribe = tb_desc.Text;
            inf.Url            = tb_urlbase.Text;
            inf.Ver            = new Version(tb_ver.Text).ToString();
            string file = Path.Combine(dialog.SelectedPath, "update.pkg");

            if (File.Exists(file))
            {
                File.Delete(file);
            }
            ZipFile.CreateFromDirectory(tb_dir.Text, file);
            inf.Md5 = Md5.FileMd5(file);
            FileInfo fi = new FileInfo(file);

            inf.Size = fi.Length;
            inf.Cmds = new List <string>();
            foreach (Object o in lb_cmds.Items)
            {
                inf.Cmds.Add(o.ToString());
            }
            Serializer.SerializeJson <UpdateInformation>(inf, Path.Combine(dialog.SelectedPath, "update.desc"));
            MessageBox.Show("生成成功,哈哈哈");
        }
        private async Task CheckNewVersion()
        {
            string         scripts = Path.Combine(Environment.CurrentDirectory, "Scripts");
            InstallService service = new InstallService(scripts);

            _vm.CurrentVersion = service.GetInstalledVersion(PackageName);
            _client            = new HmacAuthWebApiClient(Url, CdmId, ApiKey);

            try
            {
                UpdateInformation apiVersion = await _client.ReadAsync <UpdateInformation>(!string.IsNullOrWhiteSpace(_vm.CurrentVersion)?ConfigurationManager.AppSettings["api:downloadUrl"] + _vm.CurrentVersion + ConfigurationManager.AppSettings["api:downloadUrlMethod"] : ConfigurationManager.AppSettings["api:downloadUrlLatestUpdate"]);

                if (apiVersion == null || (!string.IsNullOrWhiteSpace(_vm.CurrentVersion) && new Version(apiVersion.Version) < new Version(_vm.CurrentVersion))) // when current version is disabled or unknown => the provided new version is lower than current one ...
                {
                    _vm.ApiVersion = new UpdateInformation {
                        Version = _vm.CurrentVersion
                    }
                }
                ;                                                                            // ... do like there is no new version => avoid impossible downgrade
                else
                {
                    _vm.ApiVersion = apiVersion;
                }
            }
            catch (Exception ex)
            {
                _logger.Error("CheckNewVersion() failed on ", ex);
            }
        }
    public static IEnumerator Check(Text text, Button button)
    {
        button.interactable = false;
        if (updateSite.Length > 0)
        {
            if (updateSite != "no_update")
            {
                Process.Start(updateSite);
            }
            text.text  = "检查更新";
            updateSite = "";
        }
        else
        {
            UnityWebRequest webRequest = UnityWebRequest.Get("https://gitee.com/fm2333/watermelon-3-d-update-check/raw/master/json/update.json");
            text.text = "检查更新中……";
            webRequest.SendWebRequest();
            Stopwatch timer = new Stopwatch();
            timer.Restart();
            bool timeout = false;
            while (!webRequest.isDone && !timeout)
            {
                float percent = Mathf.Round(timer.ElapsedMilliseconds / 100f) / 10f;
                text.text = "检查更新中:" + percent.ToString() + "s";
                if (timer.ElapsedMilliseconds > 5000)
                {
                    timeout = true;
                }
                yield return(null);
            }
            try
            {
                if (webRequest.isHttpError || webRequest.isNetworkError)
                {
                    text.text  = "更新检测失败";
                    updateSite = "no_update";
                    yield break;
                }

                UpdateInformation inf = JsonConvert.DeserializeObject <UpdateInformation>(webRequest.downloadHandler.text);
                if (inf.version > Const.VERSION)
                {
                    text.text  = "点此下载更新";
                    updateSite = inf.download;
                }
                else
                {
                    text.text  = "没有更新";
                    updateSite = "no_update";
                }
            }
            catch (Exception err)
            {
                text.text = "错误:" + err;
            }
        }
        button.interactable = true;
        yield break;
    }
Ejemplo n.º 6
0
        public static void CheckForUpdates(Action <bool> callback)
        {
            if (!Directory.Exists("Restarter"))
            {
                Directory.CreateDirectory("Restarter");
            }
            UpdateInformation information = GetInformation();

            if (!information.needsUpdate)
            {
                Logger.LogInfo($"Oxide is up to date.\n * Found Version: {information.currentVersion}\n * Latest Version: {information.latestVersion}");
                callback.Invoke(false);
                return;
            }
            Logger.LogWarning($"Oxide is out of date.\n * Found Version: {information.currentVersion}\n * Latest Version: {information.latestVersion}");
            SlackManager.SendSlackMessage("Check", $"Oxide is out of date.\n * Found Version: {information.currentVersion}\n * Latest Version: {information.latestVersion}", "Updating");
            Thread thread = new Thread(() =>
            {
                using (WebClient wc = new WebClient())
                {
                    wc.DownloadProgressChanged += DownloadChanged;
                    wc.DownloadFileCompleted   += DownloadCompleted;
                    wc.DownloadFileAsync(new Uri("https://github.com/OxideMod/Oxide/releases/download/latest/Oxide-Rust.zip"), "Restarter/OxideRecent.zip");
                }
            });

            thread.Start();
            ProgressManager.CreateBar("Downloading Oxide", () => {
                Logger.LogInfo("\nDownload Completed");
                thread.Abort();
                thread = new Thread(() =>
                {
                    using (ZipFile zip = ZipFile.Read("Restarter/OxideRecent.zip"))
                    {
                        int run = 0;
                        foreach (ZipEntry e in zip)
                        {
                            if (e.FileName.Contains("start-example"))
                            {
                                continue;
                            }
                            run++;
                            ProgressManager.UpdateBar(zip.EntryFileNames.Count() / run * 100);
                            e.Extract(Directory.GetCurrentDirectory(), ExtractExistingFileAction.OverwriteSilently);
                        }
                        ProgressManager.StopBar();
                    }
                });
                thread.Start();
                ProgressManager.CreateBar("Extracting Files", () =>
                {
                    Logger.LogInfo("\nUpdate completed.Starting server.");
                    callback.Invoke(true);
                    thread.Abort();
                });
            });
        }
Ejemplo n.º 7
0
        public void SendCommunicationMessage(byte[] bytes, List <UpdateInformation> infoList, object lockobj)
        {
            int nFrameLen = 0;

            if ((bytes.Length) % 8 == 0)
            {
                nFrameLen = (bytes.Length) / 8;
            }
            else
            {
                nFrameLen = (bytes.Length) / 8 + 1;
            }
            m_bIsSendMultiFrame = true;
            int nSendIndex = 0;

            for (int n = nFrameLen; n > 0; n--)
            {
                byte[] byteCmdBuf = new byte[8];
                if (nSendIndex + 8 > bytes.Length)
                {
                    Buffer.BlockCopy(bytes, nSendIndex, byteCmdBuf, 0, (bytes.Length - nSendIndex));
                }
                else
                {
                    Buffer.BlockCopy(bytes, nSendIndex, byteCmdBuf, 0, 8);
                }

                uint BqProtID = (uint)(BqProtocolID | (n - 1));
                DataLinkLayer.SendCanFrame(BqProtID, byteCmdBuf);

                nSendIndex += 8;

                UpdateInformation info = new UpdateInformation();
                info.DirectionStr = "发送";
                info.Length       = byteCmdBuf.Length.ToString();
                info.TimeStr      = DateTime.Now.ToString("MM/dd HH:mm:ss") + string.Format(":{0}", DateTime.Now.Millisecond);
                info.ID           = string.Format("0x{0}", BqProtID.ToString("X"));
                info.Content      = BitConverter.ToString(byteCmdBuf);
                if (nFrameLen > 1)
                {
                    info.Comments = string.Format("多帧第{0}帧,共{1}帧", nFrameLen - n + 1, nFrameLen);
                }
                else
                {
                    info.Comments = string.Format("第{0}帧,共{1}帧", nFrameLen - n + 1, nFrameLen);
                }
                lock (lockobj)
                {
                    infoList.Add(info);
                }
            }
            m_bIsSendMultiFrame = false;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新数据至源
        /// </summary>
        /// <returns></returns>
        public override UpdateInformation UpdateToSource(UpdateMethod updateMethod)
        {
            if (updateMethod == UpdateMethod.Delete)
            {
                foreach (Container container in FetchContainers((c) => true))
                {
                    container.UpdateToSource(UpdateMethod.Delete);
                }
            }
            UpdateInformation updateInformation = base.UpdateToSource(updateMethod);

            return(updateInformation);
        }
Ejemplo n.º 9
0
 public ActionResult UpdateInformation(UpdateInformation model)
 {
     if (ModelState.IsValid)
     {
         var user = userManager.FindByName(User.Identity.Name);
         user.Name        = model.Name;
         user.Surname     = model.Surname;
         user.PhoneNumber = model.Phone;
         user.Email       = model.Email;
         userManager.Update(user);
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 10
0
Archivo: Server.cs Proyecto: yinlei/iss
    private void updateModels()
    {
        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            return;
        }  //wenn nicht verbunden

        foreach (PhysicModel model in game.PhysicModels.Values)
        {
            if (model.ShouldBeUpdated())
            {
                UpdateInformation update = model.GetUpdateInformations();
                observer.SendPhysicData(model.name, update.position, update.rotation);
            }
        }
    }
Ejemplo n.º 11
0
        public UpdateCheckDialog(UpdateInformation updateInformation)
        {
            _updateInformation = updateInformation;

            InitializeComponent();

            if (_updateInformation.UpdateAvailable)
            {
                buttonDownload.Enabled = true;

                if (!String.IsNullOrEmpty(_updateInformation.AnnouncementUrl))
                {
                    linkLabelAnnouncement.Visible = true;
                }
            }
        }
Ejemplo n.º 12
0
        public UpdateInformation BQ_RequestUpdateApp()
        {
            byte[] buf = new byte[] { m_bSourceAddress, 0x03, 0x45, 0x01, 0x00, 0x00, 0x00, 0x00 };
            SendSingleFrameData(buf);

            UpdateInformation info = new UpdateInformation();

            info.DirectionStr = "发送";
            byte[] _bytes = new byte[6];
            Buffer.BlockCopy(buf, 2, _bytes, 0, _bytes.Length);
            info.Content  = BitConverter.ToString(_bytes);
            info.Length   = _bytes.Length.ToString();
            info.Comments = "进入固件升级模式";
            info.TimeStr  = DateTime.Now.ToString("MM/dd HH:mm:ss") + string.Format(":{0}", DateTime.Now.Millisecond);
            info.ID       = string.Format("0x{0}", BqProtocolID.ToString("X"));
            return(info);
        }
Ejemplo n.º 13
0
    public async Task Get()
    {
        try
        {
            var client = new RestClient("https://raw.githubusercontent.com/Nojus0/YouTube-Livestream-Archiver/master/Lite/Latest.txt");
            client.Timeout = -1;
            var           request  = new RestRequest(Method.GET);
            IRestResponse response = await client.ExecuteAsync(request);

            UpdateInformation WebVersion = JsonConvert.DeserializeObject <UpdateInformation>(response.Content);
            if (CurrentInformation.LatestVersion < WebVersion.LatestVersion)
            { // Implement more
                switch (WebVersion.Severity)
                {
                case "Critical":
                    ConsoleColor.Red.WriteLine($"Severity: CRITICAL");
                    break;

                case "High":
                    ConsoleColor.Red.WriteLine($"Severity: HIGH");
                    break;

                case "Normal":
                    ConsoleColor.DarkGreen.WriteLine($"Severity: NORMAL");
                    break;

                case "Low":
                    ConsoleColor.Yellow.WriteLine($"Severity: LOW");
                    break;

                case "VeryLow":
                    ConsoleColor.Yellow.WriteLine($"Severity: VERYLOW");
                    break;

                case "Needed":
                    ConsoleColor.Red.WriteLine($"Severity: NEEDED FIX");
                    break;
                }
                ConsoleColor.DarkRed.WriteLine(WebVersion.Title);
                ConsoleColor.Red.WriteLine(WebVersion.Description);
                ConsoleColor.Red.WriteLine($"Version {WebVersion.LatestVersion}");
            }
        }
        catch (Exception x) { CError.ErrorCheckingUpdates(x); }
    }
Ejemplo n.º 14
0
 protected override void OnRestoreFailed(Exception ex, UpdateInformation updateInformation)
 {
     base.OnRestoreFailed(ex, updateInformation);
     Clean().Wait();
     if (LauncherRestartManager.ShowRestoreDialog(true))
     {
         var options = CreateRestoreRestartOptions();
         if (options is null)
         {
             throw ex;
         }
         ApplicationRestartManager.RestartApplication(options);
     }
     else
     {
         LauncherRegistryHelper.WriteValue(LauncherRegistryKeys.ForceRestore, true);
         Environment.Exit(-1);
     }
 }
Ejemplo n.º 15
0
        public void CheckUpdates()
        {
            updateChecked = false;
            try {
                Version           currentVersion    = Assembly.GetExecutingAssembly().GetName().Version;
                UpdateService     updateService     = new UpdateService();
                UpdateInformation updateInformation = updateService.CheckForUpdate(currentVersion.ToString());
                updateVersion = new Version(updateInformation.Version);

                Settings.Default.lastUpdateCheck = DateTime.Now;
                if (updateVersion > currentVersion)
                {
                    updateUrl = updateInformation.InfoLink;
                }
                updateChecked = true;
            }
            catch (Exception) {
                updateUrl = string.Empty;
            }
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            string exchangeName = "queueLink";

            ConnectionFactory factory = new ConnectionFactory()
            {
                HostName = "localhost",
                UserName = "******",
                Password = "******"
            };

            using var connection = factory.CreateConnection();
            using var channel    = connection.CreateModel();
            {
                MessageBusPublisherClient publisher = new MessageBusPublisherClient(channel, exchangeName);

                string exitCode = "";
                while (exitCode != "-1")
                {
                    string id = "";
                    Console.WriteLine("Enter download ID");
                    id = Console.ReadLine().ToLower();

                    var updateMessage = new UpdateInformation
                    {
                        DownloadEndPoint    = @$ "http://*****:*****@$ "http://localhost:57308/updates/{id}/information",
                        Id = id
                    };

                    Message <UpdateInformation> message = new Message <UpdateInformation>(Guid.NewGuid(), updateMessage);

                    publisher.PostAsync(message);
                    Console.WriteLine($"Message Send :: {message.Body}\n\n");
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 更新数据至源
        /// </summary>
        /// <returns></returns>
        public override UpdateInformation UpdateToSource(UpdateMethod updateMethod)
        {
            if (updateMethod == UpdateMethod.Delete)
            {
                foreach (Pair pair in FetchPairs((p) => true))
                {
                    pair.UpdateToSource(UpdateMethod.Delete);
                }
                if (File.Exists($@"{DataAvatarsFolderName}\{Avatar}"))
                {
                    File.Delete($@"{DataAvatarsFolderName}\{Avatar}");
                }
            }
            else if (updateMethod == UpdateMethod.Update)
            {
                foreach (Pair pair in _workPairs)
                {
                    pair.UpdateToSource();
                }
            }
            UpdateInformation ui = base.UpdateToSource(updateMethod);

            return(ui);
        }
        public IUser GetUser(IUserContext testUserContext, IDataContext dataContext, bool multipleUsers = false)
        {
            int id = AnalysisPortalTestSettings.Default.TestUserId;

            if (multipleUsers)
            {
                id = id + 1;
            }

            UpdateInformation updateInformation = new UpdateInformation();

            updateInformation.CreatedBy    = AnalysisPortalTestSettings.Default.TestUserId;
            updateInformation.CreatedDate  = DateTime.Now;
            updateInformation.ModifiedBy   = AnalysisPortalTestSettings.Default.TestUserId;
            updateInformation.ModifiedDate = DateTime.Now;

            IUser testUser = new ArtDatabanken.Data.Fakes.StubIUser()
            {
                UserNameGet           = () => { return(AnalysisPortalTestSettings.Default.TestUserName); },
                ApplicationIdGet      = () => { return(AnalysisPortalTestSettings.Default.TestnAnalysisPortalApplcationId); },
                IsAccountActivatedGet = () => { return(true); },
                EmailAddressGet       = () => { return(AnalysisPortalTestSettings.Default.TestUserEmail); },
                DataContextGet        = () => { return(dataContext); },
                GUIDGet              = () => { return(AnalysisPortalTestSettings.Default.TestUserGuid); },
                IdGet                = () => { return(id); },
                ShowEmailAddressGet  = () => { return(true); },
                TypeGet              = () => { return(UserType.Person); },
                UpdateInformationGet = () => { return(updateInformation); },
                ValidFromDateGet     = () => { return(DateTime.Now); },
                ValidToDateGet       = () => { return(new DateTime(2144, 12, 31)); }
            };



            return(testUser);
        }
Ejemplo n.º 19
0
        static NewVersionControl()
        {
            ProductVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            NewVersionTask = Task.Factory.StartNew(() => {

                var updateManifestUri = new Uri(Settings.Default.UpdateManifestUrl);

                var wc = new WebClient { UseDefaultCredentials = true };
                wc.Headers.Add("X-RallyTools-Version", ProductVersion);

                var manifest = wc.DownloadString(updateManifestUri);

                var xManifest = XDocument.Parse(manifest).Element("manifest");

                if (xManifest == null)
                    return null;

                var xVersion = xManifest.Element("version");

                if (xVersion == null || string.IsNullOrWhiteSpace(xVersion.Value))
                    return null;

                var currentVersion = new SoftwareVersion.SoftwareVersion(ForcedProductVersion ?? ProductVersion);
                var latestVersion = new SoftwareVersion.SoftwareVersion(xVersion.Value);

                if (currentVersion.CompareTo(latestVersion) >= 0)
                    return null;

                var ret = new UpdateInformation
                {
                    Version = xVersion.Value
                };

                var xSetupUri = xManifest.Element("setup");
                ret.SetupUri = new Uri(updateManifestUri, new Uri(xSetupUri != null ? xSetupUri.Value : "Setup.msi", UriKind.RelativeOrAbsolute));

                var xChangelogUri = xManifest.Element("changelog");
                if (xChangelogUri != null)
                {
                    ret.ChangeLogUri = new Uri(updateManifestUri, new Uri(xChangelogUri.Value, UriKind.RelativeOrAbsolute));

                    // download changelog
                    try
                    {
                        ret.ChangeLog = wc.DownloadString(ret.ChangeLogUri);
                    }
                    catch(Exception ex)
                    {
                        Logger.LogIt(ex.ToString());
                        ret.ChangeLog = "Error: " + ex;
                    }
                }

                var xDownloadUri = xManifest.Element("download");
                if (xDownloadUri != null)
                    ret.DownloadUri = new Uri(updateManifestUri, new Uri(xDownloadUri.Value, UriKind.RelativeOrAbsolute));
                else
                    ret.DownloadUri = ret.SetupUri;

                return ret;
            });
        }
Ejemplo n.º 20
0
        public void SendUpdateAppMultiFrame(byte[] dataBuf, int len, byte nCmd, List <UpdateInformation> queue, bool isAddQueue, object lockobj)
        {
            byte[] cmdBuf = new byte[len + 8];
            cmdBuf[0] = m_bSourceAddress;
            cmdBuf[1] = 0x03;
            cmdBuf[2] = 0x45;
            cmdBuf[3] = nCmd;
            byte[] lenBuf = BitConverter.GetBytes((short)len);
            cmdBuf[4] = lenBuf[1];
            cmdBuf[5] = lenBuf[0];
            Buffer.BlockCopy(dataBuf, 0, cmdBuf, 6, len);

            byte[] crc16 = CRC_Check.CRC16(cmdBuf, 0, cmdBuf.Length - 2);

            cmdBuf[cmdBuf.Length - 2] = crc16[1];
            cmdBuf[cmdBuf.Length - 1] = crc16[0];

            int nFrameLen = 0;

            if ((cmdBuf.Length - 2) % 8 == 0)
            {
                nFrameLen = (cmdBuf.Length - 2) / 8;
            }
            else
            {
                nFrameLen = (cmdBuf.Length - 2) / 8 + 1;
            }
            m_bIsSendMultiFrame = true;
            int nSendIndex = 2;

            for (int n = nFrameLen; n > 0; n--)
            {
                byte[] byteCmdBuf = new byte[8];
                if (nSendIndex + 8 > cmdBuf.Length)
                {
                    Buffer.BlockCopy(cmdBuf, nSendIndex, byteCmdBuf, 0, (cmdBuf.Length - nSendIndex));
                }
                else
                {
                    Buffer.BlockCopy(cmdBuf, nSendIndex, byteCmdBuf, 0, 8);
                }

                uint BqProtID = (uint)(BqProtocolID | (n - 1));
                DataLinkLayer.SendCanFrame(BqProtID, byteCmdBuf);

                nSendIndex += 8;
                //Thread.Sleep(5);
                if (isAddQueue)
                {
                    UpdateInformation info = new UpdateInformation();
                    info.DirectionStr = "发送";
                    info.Length       = byteCmdBuf.Length.ToString();
                    info.TimeStr      = DateTime.Now.ToString("MM/dd HH:mm:ss") + string.Format(":{0}", DateTime.Now.Millisecond);
                    info.ID           = string.Format("0x{0}", BqProtID.ToString("X"));
                    info.Content      = BitConverter.ToString(byteCmdBuf);
                    if (n == nFrameLen)
                    {
                        if (nCmd == 0x13)
                        {
                            info.Comments = string.Format("根据最新固件信息获取固件状态—多帧第{0}帧,共{1}帧", nFrameLen - n + 1, nFrameLen);
                        }
                        else if (nCmd == 0x15)
                        {
                            uint index = (uint)(dataBuf[4] << 8 | dataBuf[5]);
                            info.Comments = string.Format("第{0}块从机升级包—多帧第{1}帧,共{2}帧", index, nFrameLen - n + 1, nFrameLen);
                        }
                    }
                    else
                    {
                        info.Comments = string.Format("第{0}帧,共{1}帧", nFrameLen - n + 1, nFrameLen);
                    }
                    //queue.Enqueue(info);
                    lock (lockobj)
                    {
                        queue.Add(info);
                    }
                }
            }
            m_bIsSendMultiFrame = false;
        }
Ejemplo n.º 21
0
        private Bitmap getBitmap()
        {
            Bitmap bitmap;
            float  xScale = 1.0F * _bitmapWidth / _width;
            float  yScale = 1.0F * _bitmapHeight / _height;

            if (xScale < yScale)
            {
                _scale = xScale;
            }
            else
            {
                _scale = yScale;
            }

            //_shapeTransform = new TransformGroup();
            bitmap = new Bitmap(_bitmapWidth + _legendBoxWidth - _legendBoxOffsetX, _bitmapHeight + 2, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (Graphics canvas = Graphics.FromImage(bitmap))
            {
                using (Pen pen = new Pen(Color.Black, 1))
                {
                    using (Brush backgroundBrush = new SolidBrush(_colorBackground))
                    {
                        String countyCode         = "";
                        int    countyOccurenceKey = 0;

                        canvas.FillRectangle(backgroundBrush, 0, 0, _bitmapWidth + _legendBoxWidth - _legendBoxOffsetX, _bitmapHeight + 2);

                        for (int recordIndex = 0; recordIndex < _shapeFile.Records.Count; recordIndex++)
                        {
                            try
                            {
                                ShapeFileRecord record = _shapeFile.Records[recordIndex];

                                if (_countyInformation.IsNotEmpty())
                                {
                                    countyCode = record.Attributes[2].ToString();
                                    int countyId = getCountyId(countyCode);
                                    if (countyId > 0)
                                    {
                                        ISpeciesFact    fact  = null;
                                        SpeciesFactList facts = null;
                                        if (_counties.Exists(countyId))
                                        {
                                            try
                                            {
                                                facts = _countyInformation.GetSpeciesFacts(_counties.Get(countyId));
                                                if (facts.IsNotEmpty())
                                                {
                                                    fact = facts[0];
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                throw;
                                            }

                                            if (fact.IsNotNull())
                                            {
                                                countyOccurenceKey = fact.MainField.EnumValue.KeyInt.GetValueOrDefault(0);
                                            }
                                            else
                                            {
                                                countyOccurenceKey = 0;
                                            }
                                        }
                                        else
                                        {
                                            countyOccurenceKey = 0;
                                        }
                                    }
                                }
                                else
                                {
                                    countyOccurenceKey = -1;
                                }

                                for (int i = 0; i < record.NumberOfParts; i++)
                                {
                                    List <Point> points = new List <Point>();

                                    // Determine the starting index and the end index
                                    // into the points array that defines the figure.
                                    int start = record.Parts[i];
                                    int end;
                                    if (record.NumberOfParts > 1 && i != (record.NumberOfParts - 1))
                                    {
                                        end = record.Parts[i + 1];
                                    }
                                    else
                                    {
                                        end = record.NumberOfPoints;
                                    }


                                    for (int j = start; j < end; j++)
                                    {
                                        System.Windows.Point pt = record.Points[j];

                                        // Transform from lon/lat to canvas coordinates.
                                        //pt = this._shapeTransform.Transform(pt);

                                        Point point = new Point(_legendBoxWidth - _legendBoxOffsetX + (int)((pt.X - _xMin) * _scale), _bitmapHeight - (int)((pt.Y - _yMin) * _scale));
                                        points.Add(point);
                                    }

                                    using (Brush countyOccurrenceBrush = getBrush(countyOccurenceKey))
                                    {
                                        canvas.FillPolygon(countyOccurrenceBrush, points.ToArray());
                                    }

                                    canvas.DrawPolygon(pen, points.ToArray());
                                }
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }

                        if (_countyInformation.IsEmpty())
                        {
                            using (Font font = new Font("Arial", 24 * _bitmapHeight / 708))
                            {
                                using (Brush brush = new SolidBrush(Color.Red))
                                {
                                    canvas.DrawString("Information saknas", font, brush, _legendBoxWidth, _bitmapHeight / 2);
                                }
                            }
                        }

                        if (UpdateInformation.IsNotEmpty())
                        {
                            canvas.DrawImage(GetUpdateInformationBox(),
                                             0,
                                             0);
                            canvas.DrawImage(getLegendBox(), 0, _updateInformationBoxHeight);
                        }
                        else
                        {
                            canvas.DrawImage(getLegendBox(), 0, 0);
                        }
                    }
                }
            }

            return(bitmap);
        }
Ejemplo n.º 22
0
 protected virtual void OnUpdated(UpdateInformation updateInformation)
 {
     Updated?.Invoke(this, new RecordUpdatedEventArgs(updateInformation));
 }
Ejemplo n.º 23
0
 /**Ermoeglicht es das aktelle Model an die Position zu Transformieren, die es zu Beginn hatte.
  */
 public void reset()
 {
     this.transform.localPosition = startPosition;
     this.transform.localRotation = startRotation;
     lastInformations             = new UpdateInformation();
 }
Ejemplo n.º 24
0
 /**Ermoeglicht es das aktelle Model an die Position zu Transformieren, die es zu Beginn hatte.
  */
 public void reset()
 {
     this.transform.localPosition = startPosition;
     this.transform.localRotation = startRotation;
     lastInformations = new UpdateInformation ();
 }
Ejemplo n.º 25
0
        private static int GenerateManifest()
        {
            WriteToConsole(Resources.Output_Information_WritingManifest);
            s_Diagnostics.Log(LevelToLog.Info, Resources.Log_Information_WritingManifest);

            var hash = ComputeHash(s_FilePath);
            var info = new UpdateInformation
                {
                    ProductName = s_ProductName,
                    LatestAvailableVersion = s_Version.ToString(4),
                    Hash = hash,
                    HashType = GetHashAlgorithm().GetType().FullName,
                    DownloadLocation = s_DownloadUrl,
                };

            var s = new XmlSerializer(typeof(UpdateInformation));
            string manifest = SerializeToString(s, info, "urn:Nuclei.AutoUpdate");

            WriteToConsole(Resources.Output_Information_SigningManifest);
            s_Diagnostics.Log(LevelToLog.Info, Resources.Log_Information_SigningManifest);
            using (var rsa = CreateCryptoServiceProvider())
            {
                var signedManifestDoc = SignManifest(manifest, rsa);
                using (var stream = new FileStream(s_OutputPath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    signedManifestDoc.Save(stream);
                }
            }

            return NormalApplicationExitCode;
        }
Ejemplo n.º 26
0
    public void SetPosition( Transform trans,  Vector2 pos, Align align=Align.LeftTop )
    {
        if( cameraHud == null ) {
            Debug.LogError( "Call UKUIHelper.Instance.Init( Camera cam ); first!" );
            return;
        }
        if( trans.root.rotation != Quaternion.identity ) {
            Debug.LogError ( "UKUIHelper: Set your HUD rotation to 0!" );
            return;
        }

        UpdateInformation ui = new UpdateInformation(){
            transform = trans,
            position = pos,
            align = align
        };

        autoUpdateList.Add( ui );
        positionTransform( ui );
    }
Ejemplo n.º 27
0
    private void positionTransform( UpdateInformation ui )
    {
        Vector2 offset = GetAlignOffset( ui.align );

        if (ui.transform != null)
        {
            ui.transform.localPosition = new Vector3(ui.position.x * unitsPerPixel + offset.x,
                                                     ui.position.y * unitsPerPixel + offset.y,
                                                     ui.transform.localPosition.z );
        }
    }
Ejemplo n.º 28
0
        private static string SerializeToString(XmlSerializer serializer, UpdateInformation info, string xmlNamespace)
        {
            var n = new XmlSerializerNamespaces();
            n.Add(string.Empty, xmlNamespace);
            var builder = new StringBuilder();
            var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true };

            using (var writer = XmlWriter.Create(builder, settings))
            {
                serializer.Serialize(writer, info, n);
            }

            return builder.ToString();
        }