示例#1
0
    private void ImportNodeExcel()
    {
        DataTable dataTable = ExcelHelper.ReadFromExcelFile(_fileName, ConfigHandler.ExcelSheetName);

        ProgressObject progressObject = new ProgressObject();

        progressObject.ProgressBarMaximum = dataTable.Rows.Count;
        progressObject.OperationLabelText = "Importing...";

        for (int i = 1; i < dataTable.Rows.Count; i++)
        {
            progressObject.ProgressBarValue = i;
            _worker.ReportProgress(-1, progressObject);

            string level1Type        = dataTable.Rows[i][0].ToString();
            string level1Name        = dataTable.Rows[i][1].ToString();
            string level2Type        = dataTable.Rows[i][2].ToString();
            string level2Name        = dataTable.Rows[i][3].ToString();
            string databaseFieldName = dataTable.Rows[i][4].ToString();
            string description       = dataTable.Rows[i][5].ToString();

            if (_objectsSelectorForm.allCheckBox.Checked || (!_objectsSelectorForm.allCheckBox.Checked && _selectedDatabaseFieldNames.Contains(databaseFieldName)))
            {
                if (_objectsSelectorForm.IncludeObjectType(level1Type, level2Type))
                {
                    if (_objectsSelectorForm.IncludeIndividualObject(level1Type, level1Name))
                    {
                        _databaseOperation.SaveDescription(level1Type, level1Name, level2Type, level2Name, description, databaseFieldName);
                    }
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        this.ProgressManager = GameObject.Find("Progress");

        ProgressObject progress = ProgressManager.GetComponent <ProgressObject>();

        EntryTextDisplay.text = String.Empty;

        foreach (EncyclopediaEntry entry in EncyclopediaEntries)
        {
            if (entry.UnlockPath.ChapterNum == 0 || progress.ProgressPaths.progressPaths.Any(i => i.ChapterNum == entry.UnlockPath.ChapterNum && i.SectionNum == entry.UnlockPath.SectionNum))
            {
                GameObject           newEntry   = Instantiate(EncyclopediaItemPrefab) as GameObject;
                TopicPanelProperties properties = newEntry.GetComponent <TopicPanelProperties>();
                properties.Name.text        = entry.Title;
                properties.TopicTag         = entry.TopicTag;
                properties.TopicText        = entry.EntryText;
                properties.BackgroundImage  = entry.BackgroundImage;
                properties.EntryTextDisplay = this.EntryTextDisplay;

                FillTopicList fillTopic = newEntry.GetComponent <FillTopicList>();
                fillTopic.ImagePanel      = this.ImagePanel;
                fillTopic.ProgressManager = this.ProgressManager;
                fillTopic.SubTopicPanel   = this.SubTopicPanel;

                newEntry.transform.SetParent(ContentPanel.transform, false);
            }
        }
    }
        private ProgressObject GenerateBar(RectTransform rectTransform)
        {
            var bgGmo   = new GameObject("progress", typeof(RectTransform), typeof(Image));
            var barGmo  = new GameObject("val", typeof(RectTransform), typeof(Image));
            var bgRect  = bgGmo.GetComponent <RectTransform>();
            var barRect = barGmo.GetComponent <RectTransform>();
            var bgImg   = bgGmo.GetComponent <Image>();
            var barImg  = barGmo.GetComponent <Image>();

            bgRect.parent  = rectTransform;
            barRect.parent = bgRect;

            bgRect.anchorMin = new Vector2(1, 0);
            bgRect.anchorMax = new Vector2(1, 0);
            bgRect.pivot     = new Vector2(1, 0);

            barRect.anchoredPosition = new Vector2(BarBorderWidth * 0.5f, 0.0f);
            barRect.anchorMin        = new Vector2(0, 0.5f);
            barRect.anchorMax        = new Vector2(0, 0.5f);
            barRect.pivot            = new Vector2(0.0f, 0.5f);

            bgRect.sizeDelta  = new Vector2(BarWidth + BarBorderWidth, BarHeight + BarBorderHeight);
            barRect.sizeDelta = new Vector2(BarWidth, BarHeight);
            bgImg.color       = Color.black;
            barImg.color      = new Color(0.3f, 0.9f, 0.4f);

            var progressObject = new ProgressObject(bgRect, barRect, barImg);

            return(progressObject);
        }
        private Control BuildProgressBar(ProgressObject progressObject)
        {
            Label topLabel = this.CreateTopLabel(progressObject);

            Label bottomLabel = this.CreateBottomLabel(progressObject);

            ProgressBar progressBar = this.CreateProgressBar();

            FlowLayoutPanel flowLayoutPanel = this.CreateFlowLayoutPanel();

            progressObject.TaskTitle.Binding = GuiBindings.Bind(topLabel, x => x.Text).ToBinding(BindingMode.FromTarget);
            progressObject.TaskText.Binding  = GuiBindings.Bind(bottomLabel, x => x.Text).ToBinding(BindingMode.FromTarget);
            progressObject.Total.Binding     = GuiBindings.Bind(progressBar, x => x.Maximum).ToBinding(BindingMode.FromTarget);
            progressObject.Current.Binding   = GuiBindings.Bind(progressBar, x => x.Value).ToBinding(BindingMode.FromTarget);

            progressBar.Maximum = progressObject.Total.Value;
            progressBar.Value   = progressObject.Current.Value;

            flowLayoutPanel.Controls.AddRange(new[]
            {
                (Control)topLabel,
                bottomLabel,
                progressBar
            });

            return(flowLayoutPanel);
        }
    void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }
        DontDestroyOnLoad(this.gameObject);

        BinaryFormatter bf = new BinaryFormatter();

        if (!File.Exists(Application.persistentDataPath + "/progress.dat"))
        {
            FileStream file = File.Create(Application.persistentDataPath + "/progress.dat");

            ProgressPaths newPaths = new ProgressPaths();
            newPaths.progressPaths = new List <ProgressPath>();
            newPaths.progressPaths.Add(new ProgressPath(1, 1));
            newPaths.progressPaths.Add(new ProgressPath(1, 2));
            bf.Serialize(file, newPaths);
            file.Close();
        }

        FileStream openFile = File.Open(Application.persistentDataPath + "/progress.dat", FileMode.Open);

        this.ProgressPaths = (ProgressPaths)bf.Deserialize(openFile);
        openFile.Close();
    }
        public async Task <XmlHistory> PatchAsync(LaunchType launchType)
        {
            var history = new XmlHistory();

            history.Success = false;

            var totalProgress = new ProgressObject();

            var logForm = new LogForm(totalProgress);

            logForm.InvokeIfRequired(() => logForm.Show());

            try
            {
                List <PatchGroup> patches = PatchManager.SaveInstructions(ref history);

                await Task.Run(() => PatchManager.ApplyInstructions(launchType, patches, totalProgress)).ConfigureAwait(false);

                history.Success = true;
            }
            catch (Exception exception)
            {
                Logger.Error(exception, "Patching failed because instructions cannot be applied.");
            }

            if (!history.Success)
            {
                PatchingHelper.RestorePatchedFiles(AppContextManager.Context.Value, history.Files);
            }

            logForm.InvokeIfRequired(() => CloseForm(logForm));

            return(history);
        }
示例#7
0
    private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        if (e.ProgressPercentage == -1)
        {
            ProgressObject progressObject = (ProgressObject)e.UserState;

            progressBar1.Maximum = progressObject.Total;
            progressBar1.Value   = progressObject.Step;

            if (ConfigHandler.UseTranslation)
            {
                infoLabel1.Text = string.Format("{2} ({0}/{1}): {3}", progressObject.Step, progressObject.Total, Translator.GetText("preparingCustomColumns"), progressObject.Message);
            }
            else
            {
                infoLabel1.Text = string.Format("Preparing Custom Column ({0}/{1}): {2}", progressObject.Step, progressObject.Total, progressObject.Message);
            }
        }
        else if (e.ProgressPercentage == -2)
        {
            ProgressObject progressObject = (ProgressObject)e.UserState;

            progressBar2.Maximum = progressObject.Total;
            progressBar2.Value   = progressObject.Step;

            infoLabel2.Text = string.Format("{2} ({0}/{1})", progressObject.Step, progressObject.Total, progressObject.Message);
        }
    }
    private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        ProgressObject progressObject = (ProgressObject)e.UserState;

        progressBar1.Maximum = progressObject.ProgressBarMaximum;
        progressBar1.Value   = progressObject.ProgressBarValue;
        statusLabel.Text     = "Status: Deleting...";
    }
示例#9
0
        public static Task <List <string> > ExtractFile(string fileName, ProgressObject progressObject)
        {
            if (progressObject == null)
            {
                throw new ArgumentNullException(nameof(progressObject));
            }
            return(Task.Factory.StartNew(() =>
            {
                var result = new List <string>();
                var reader = new PdfReader(fileName);
                progressObject.Total = reader.NumberOfPages;
                try
                {
                    for (var i = 1; i <= reader.NumberOfPages; i++)
                    {
                        var pg = reader.GetPageN(i);
                        var res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));
                        var xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));

                        foreach (PdfName name in xobj.Keys)
                        {
                            var obj = xobj.Get(name);
                            if (obj.IsIndirect())
                            {
                                var tg = (PdfDictionary)PdfReader.GetPdfObject(obj);

                                var type = (PdfName)PdfReader.GetPdfObject(tg.Get(PdfName.SUBTYPE));

                                if (type.Equals(PdfName.IMAGE))
                                {
                                    float width = float.Parse(tg.Get(PdfName.WIDTH).ToString());
                                    float height = float.Parse(tg.Get(PdfName.HEIGHT).ToString());
                                    var matrix = new Matrix(width, height);

                                    var render = ImageRenderInfo.CreateForXObject(matrix, (PRIndirectReference)obj, tg);
                                    var image = render.GetImage();

                                    using (Bitmap dotnetImg = (Bitmap)image.GetDrawingImage())
                                    {
                                        dotnetImg.SetResolution(300f, 300f);

                                        var tempPath = System.IO.Path.GetTempFileName();
                                        dotnetImg.Save(tempPath);
                                        result.Add(tempPath);
                                    }
                                }
                            }
                        }
                        progressObject.Progress = i;
                    }
                    return result;
                }
                finally
                {
                    reader.Close();
                }
            }));
        }
        private Label CreateBottomLabel(ProgressObject progressObject)
        {
            var bottomLabel = new Label();

            bottomLabel.Width        = this.guiPanel.Width - 30;
            bottomLabel.AutoSize     = true;
            bottomLabel.TextChanged += (sender, args) => progressObject.TaskText.Value = bottomLabel.Text;
            return(bottomLabel);
        }
示例#11
0
        private void AddProgress()
        {
            if (ProgressObject != null)
            {
                var progressObjectType = ProgressObject.GetType().GenericTypeArguments.First().UnderlyingSystemType;

                StandardProgressImpl(progressObjectType);
                OutputProgressImpl(progressObjectType);
            }
        }
        private Label CreateTopLabel(ProgressObject progressObject)
        {
            var topLabel = new Label();

            topLabel.Margin       = new Padding(0, 5, 0, 5);
            topLabel.Font         = new Font(this.Font.FontFamily, 12f, FontStyle.Bold);
            topLabel.Width        = this.guiPanel.Width - 30;
            topLabel.AutoSize     = true;
            topLabel.TextChanged += (sender, args) => progressObject.TaskTitle.Value = topLabel.Text;
            return(topLabel);
        }
示例#13
0
        public async Task <XmlHistory> Command_Patch()
        {
            State.Value = LaunchManagerState.IsPatching;
            var history = new XmlHistory
            {
                Success = false
            };

            try
            {
                var progObj = new ProgressObject();
                using (var logForm = new LogForm(progObj)
                {
                    Icon = _home.Icon
                })
                {
                    logForm.Show();
                    try
                    {
                        var patches = GroupPatches(Instructions).ToList();
                        history.Files = patches.Select(XmlFileHistory.FromInstrGroup).ToList();
                        _historySerializer.Serialize(history, _pathHistoryXml);
                        await Task.Run(() => ApplyInstructions(patches, progObj));

                        history.Success = true;
                    }
                    catch (PatchingProcessException ex)
                    {
                        Command_Display_Patching_Error(ex);
                    }
                    if (!history.Success)
                    {
                        PatchingHelper.RestorePatchedFiles(AppInfo, history.Files);
                    }
                    logForm.Close();
                }
            }
            catch (Exception ex)
            {
                Command_Display_Error("Patch the game", ex: ex);
            }
            finally
            {
                State.Value = LaunchManagerState.Idle;
                if (Preferences.OpenLogAfterPatch)
                {
                    Process.Start(_pathLogFile);
                }
            }
            return(history);
        }
示例#14
0
 private void ReportProgress(ProgressObject progress)
 {
     ScanProgress.Text =
         (progress.CurrentScan + 1).ToString() + "/" + NScans.Value.ToString();
     if (progress.Data != null)
     {
         int start = LastAcqWidth * SelectedRow;
         int count = LastAcqWidth;
         Light = progress.Data.Select((x) => (double)x).ToArray();
         Graph.DrawPoints(Camera.Calibration, new ArraySegment <double>(Light, start, count));
         Graph.MarkerColor = Graph.NextColor;
         Graph.Invalidate();
     }
 }
        public void ReleaseProgressObject(ProgressObject obj)
        {
            obj.Disable();
            this.activeProgress.Remove(obj);
            this.poolProgress.Enqueue(obj);

            int idx = 0;

            foreach (var progress in activeProgress)
            {
                progress.SetPosition(GetPosition(idx));
                ++idx;
            }
            this.ExpandBgObject(activeProgress.Count);
        }
    public void OnPointerClick(PointerEventData pointerEventData)
    {
        properties = GetComponent <TopicPanelProperties>();

        #region SetSubTopics

        if (this.SubTopicPanel != null)
        {
            SubListController subList = SubTopicPanel.GetComponent <SubListController>();

            subList.DestroyPanels();
            subList.UpdateContents(properties.TopicTag);
        }

        #endregion

        #region SetImageandText
        Image entryImage = ImagePanel.GetComponent <Image>();
        entryImage.sprite = properties.BackgroundImage;

        ProgressObject progress = ProgressManager.GetComponent <ProgressObject>();
        properties.EntryTextDisplay.text = String.Empty;

        foreach (EncyclopediaEntryText entry in properties.TopicText)
        {
            if (entry.UnlockPath.ChapterNum == 0 || progress.ProgressPaths.progressPaths.Any(i => i.ChapterNum == entry.UnlockPath.ChapterNum && i.SectionNum == entry.UnlockPath.SectionNum))
            {
                try
                {
                    if (String.IsNullOrEmpty(properties.EntryTextDisplay.text))
                    {
                        properties.EntryTextDisplay.text = entry.EntryText.text;
                    }
                    else
                    {
                        properties.EntryTextDisplay.text += "\n\n" + entry.EntryText.text;
                    }
                }

                catch (NullReferenceException)
                {
                    properties.EntryTextDisplay.text = "Entry text is not set. Cannot be displayed.";
                }
            }
        }

        #endregion
    }
示例#17
0
    private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        ProgressObject progressObject = (ProgressObject)e.UserState;

        operationLabel.Text = progressObject.OperationLabelText;

        if (progressObject.ProgressBarValue == -1)
        {
            statusLabel.Text = "Status: Saving...";
        }
        else
        {
            progressBar1.Maximum = progressObject.ProgressBarMaximum;
            progressBar1.Value   = progressObject.ProgressBarValue;
            statusLabel.Text     = string.Format("Status: Exporting ({0}/{1})", progressObject.ProgressBarValue, progressObject.ProgressBarMaximum);
        }
    }
示例#18
0
    private void Worker_DoWork(object sender, DoWorkEventArgs e)
    {
        string extension = openFileDialog1.DefaultExt;

        if (extension != null)
        {
            extension = extension.ToLower();
        }

        ProgressObject progressObject = new ProgressObject();

        progressObject.OperationLabelText = "";
        progressObject.ProgressBarValue   = -1;
        _worker.ReportProgress(-1, progressObject);

        ImportNode(extension);
    }
    private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        if (e.ProgressPercentage == -1)
        {
            ProgressObject progressObject = (ProgressObject)e.UserState;
            SetFileLabel(progressObject.Step, progressObject.Total, progressObject.ImportTraceFileInfo);
        }
        else if (e.ProgressPercentage == -2)
        {
            string statusMessage = e.UserState.ToString();

            fileValueLabel.Text = "";
            nameValueLabel.Text = "";
            sizeValueLabel.Text = "";

            statusValueLabel.Text = statusMessage;
        }
    }
示例#20
0
    private void ExportScalarValuedFunctionParameters(CustomNode functionsNode, int count, int totalCount)
    {
        ProgressObject progressObject = new ProgressObject();

        progressObject.ProgressBarMaximum = functionsNode.Nodes.Count;
        progressObject.OperationLabelText = string.Format("Exporting Scalar-valued Functions Parameters ({0}/{1})", count, totalCount);

        for (int i = 0; i < functionsNode.Nodes.Count; i++)
        {
            progressObject.ProgressBarValue = i + 1;
            _worker.ReportProgress(-1, progressObject);
            CustomNode node = (CustomNode)functionsNode.Nodes[i];

            if (_objectsSelectorForm.IncludeIndividualObject(node))
            {
                NodeDataGenerator.GenerateScalarValuedFunctionParametersNode((CustomNode)node.Nodes["Parameters"], node.Text, _databaseOperation);
            }
        }
    }
示例#21
0
    private void ExportViewIndexes(CustomNode viewsNode, int count, int totalCount)
    {
        ProgressObject progressObject = new ProgressObject();

        progressObject.ProgressBarMaximum = viewsNode.Nodes.Count;
        progressObject.OperationLabelText = string.Format("Exporting View Indexes ({0}/{1})", count, totalCount);

        for (int i = 0; i < viewsNode.Nodes.Count; i++)
        {
            progressObject.ProgressBarValue = i + 1;
            _worker.ReportProgress(-1, progressObject);
            CustomNode node = (CustomNode)viewsNode.Nodes[i];

            if (_objectsSelectorForm.IncludeIndividualObject(node))
            {
                NodeDataGenerator.GenerateViewIndexesNode((CustomNode)node.Nodes["Indexes"], node.Text, _databaseOperation);
            }
        }
    }
        public ProgressObject GetProgressObject()
        {
            ProgressObject obj = null;

            if (this.poolProgress.Count > 0)
            {
                obj = poolProgress.Dequeue();
            }
            else
            {
                obj = GenerateBar(this.bgObject);
            }
            this.activeProgress.Add(obj);
            int count = activeProgress.Count;

            obj.Enable();
            obj.SetPosition(GetPosition(count - 1));

            this.ExpandBgObject(count);
            return(obj);
        }
示例#23
0
        private static void SetTaskData(this ProgressObject progress, string taskTitle = "", string taskText = "", int total = -1, bool increment = false)
        {
            if (!string.IsNullOrEmpty(taskTitle))
            {
                progress.TaskTitle.Value = taskTitle;
            }

            if (!string.IsNullOrEmpty(taskText))
            {
                progress.TaskText.Value = taskText;
            }

            if (total > -1)
            {
                progress.Total.Value = total;
            }

            if (increment)
            {
                progress.Current.Value++;
            }
        }
示例#24
0
    private void Worker_DoWork(object sender, DoWorkEventArgs e)
    {
        if (File.Exists(_fileName))
        {
            File.Delete(_fileName);
        }

        string extension = saveFileDialog1.DefaultExt;

        if (extension != null)
        {
            extension = extension.ToLower();
        }

        CustomNode serverNode = GenerateServerNode();

        ProgressObject progressObject = new ProgressObject();

        progressObject.OperationLabelText = "";
        progressObject.ProgressBarValue   = -1;
        _worker.ReportProgress(-1, progressObject);

        if (extension == "xml" || extension == "sql")
        {
            StringBuilder stringBuilder = new StringBuilder();
            WriteHeader(stringBuilder, extension);
            ExportNode(serverNode, stringBuilder, extension);
            WriteFile(stringBuilder, extension);
        }
        else if (extension == "xls")
        {
            List <string> dataRows = new List <string>();
            ExcelHelper.CreateExcelFile(_fileName, ConfigHandler.ExcelSheetName, GetExcelHeaderRow());
            ExportNode(serverNode, dataRows, extension);
            WriteFile(dataRows, extension);
        }
    }
示例#25
0
        public Game1()
        {
            progressObject = ExtraFunctions.loadProgress();


            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            TargetElapsedTime = TimeSpan.FromTicks(333333);

            graphics.IsFullScreen = true;
            //graphics.PreferredBackBufferWidth = sSCREEN_RESOLUTION_WIDTH;
            //graphics.PreferredBackBufferHeight = sSCREEN_RESOLUTION_HEIGHT;
            //graphics.ApplyChanges();
            //graphics.GraphicsDevice.Clear(Color.Black);

            mScreenManager = new ScreenManager(this);

            Components.Add(mScreenManager);

            instance = this;
            SoundManager.Initialize(this);
        }
示例#26
0
 public Wrapper(ProgressObject inner)
 {
     _inner = inner;
 }
        public LogForm(ProgressObject list)
        {
            this.InitializeComponent();

            this.List = Bindable.List(new ProgressList(list));
        }
示例#28
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundParameter bObj = e.Argument as BackgroundParameter;
                string url = bObj.url;
                string querySuffix = bObj.querySuffix;
                Uri uriFujiRDS = new Uri(url);

                ProgressObject pObj = new ProgressObject();
                backgroundWorker.ReportProgress(0, pObj);

                DateTime dtime = dateTimePickerStart.Value;
                string dateStart = dtime.ToString("yyyy-MM-dd HH:mm:ss");

                string dateEnd = dtime.AddHours(double.Parse(bObj.duration)).ToString("yyyy-MM-dd HH:mm:ss");
                //dateTimePickerEnd.Value.ToString("yyyy-MM-dd HH:mm:ss");
                string query = String.Format(@"select * from storage s,document d,study_document sd,study st,patient p,procedure_info pi
              where d.id = sd.document_uid
                and s.id=d.storage_uid
                and st.id=sd.study_uid
                and p.id=st.patient_uid
                and pi.id=st.procedure_info_uid
                and d.name='Notes'
                and d.creation_timedate between to_date('{0}','YYYY-MM-DD HH24:MI:SS') and to_date('{1}','YYYY-MM-DD HH24:MI:SS')", dateStart, dateEnd);

                query += querySuffix;

                ADODB.Recordset rs = new ADODB.Recordset();
                byte[] result = retrieveRDS(uriFujiRDS, query);

                if (result == null) return;
                string tempfile = Path.GetTempFileName();
                ByteArrayToFile(tempfile, result);
                rs.Open(tempfile, "Provider=MSPersist", ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0);

                string notefile = Path.GetTempFileName();

                //** Eliminating this code due to apparent unreliability of WebClient with redirects
                //WebClient client = new WebClient();
                //client.Credentials = myCredentialCache;
                //client.UseDefaultCredentials = true;

                dt = new DataTable();

                dt.Columns.Add("Name", typeof(string));
                dt.Columns.Add("MRN", typeof(string));
                dt.Columns.Add("Accession", typeof(string));
                dt.Columns.Add("Procedure", typeof(string));
                dt.Columns.Add("Study Time", typeof(string));
                dt.Columns.Add("Note Time", typeof(string));
                dt.Columns.Add("Note", typeof(string));
                dt.Columns.Add("Reports", typeof(string));

                DateTime lastprogress = DateTime.Now;

                while (!rs.EOF)
                {
                    string http_url = rs.Fields["http_url"].Value.ToString();
                    string https_url = rs.Fields["https_url"].Value.ToString();
                    string accnum = rs.Fields["ris_study_euid"].Value.ToString();
                    string proc = rs.Fields["description"].Value.ToString();
                    string proc_code = rs.Fields["code"].Value.ToString();
                    string filename = rs.Fields["filename"].Value.ToString();
                    string mrn = rs.Fields["internal_euid"].Value.ToString();
                    string lastname = rs.Fields["last_name"].Value.ToString();
                    string firstname = rs.Fields["first_name"].Value.ToString();
                    string middlename = rs.Fields["middle_name"].Value.ToString();
                    string study_time = ((DateTime)rs.Fields["study_timedate"].Value).ToString("s").Replace('T', ' ');
                    string creation_time = ((DateTime)rs.Fields["creation_timedate"].Value).ToString("s").Replace('T', ' ');

                    if (url.StartsWith("https"))
                    {
                        filename = https_url + filename;
                    }
                    else
                    {
                        filename = http_url + filename;
                    }

                    string note = "";
                    try
                    {
                        downloadFile(filename, notefile);
                        //client.DownloadFile(filename, notefile);
                        note = parseNote(notefile);
                    }
                    catch (Exception ex)
                    {
                        note = String.Format("Error downloading note at {0}: {1}", filename, ex.Message);
                    }

                    string name = (lastname + ", " + firstname + " " + middlename).Trim();

                    dt.Rows.Add(name, mrn, accnum, proc, study_time, creation_time, note, "");

                    rs.MoveNext();
                    pObj.dt = dt;
                    backgroundWorker.ReportProgress(0, pObj);
                }

                rs.Close();
                File.Delete(tempfile);

                int totalNotes = dt.Rows.Count;
                int current = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    // Retrieve reports here

                    query = String.Format(@"select * from storage s,document d,study_document sd,study st
                  where d.id = sd.document_uid
                    and s.id=d.storage_uid
                    and st.id=sd.study_uid
                    and d.name='Report'
                    and st.ris_study_euid='{0}'
                    order by d.creation_timedate", dr["Accession"]);
                    //dr["Reports"] = query;

                    result = retrieveRDS(uriFujiRDS, query);

                    if (result == null) return;
                    tempfile = Path.GetTempFileName();
                    ByteArrayToFile(tempfile, result);
                    rs.Open(tempfile, "Provider=MSPersist", ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0);
                    string report = "";

                    while (!rs.EOF)
                    {
                        string http_url = rs.Fields["http_url"].Value.ToString();
                        string https_url = rs.Fields["https_url"].Value.ToString();
                        string doctype = rs.Fields["name"].Value.ToString();
                        string filename = rs.Fields["filename"].Value.ToString();

                        if (url.StartsWith("https"))
                        {
                            filename = https_url + filename;
                        }
                        else
                        {
                            filename = http_url + filename;
                        }

                        try
                        {
                            downloadFile(filename, notefile);
                            //client.DownloadFile(filename, notefile);
                            report += parseReport(notefile, url);
                        }
                        catch (Exception ex)
                        {
                            report += String.Format("Error downloading report at {0}: {1}", filename, ex.Message);
                        }

                        rs.MoveNext();

                        if (!rs.EOF) report += "\r\n\r\n======\r\n\r\n";
                    }
                    rs.Close();
                    File.Delete(tempfile);
                    dr["Reports"] = report;

                    current += 1;
                    if ((DateTime.Now - lastprogress).Milliseconds > 50)
                    {
                        backgroundWorker.ReportProgress(current * 100 / totalNotes, pObj);
                        lastprogress = DateTime.Now;
                    }
                }
                File.Delete(notefile);

                pObj.updateDT = true;

                backgroundWorker.ReportProgress(100, pObj);
            }
            catch (Exception ex)
            {
                labelStatus.Text = ex.Message;
            }
        }
示例#29
0
        private void ApplyInstructions(IEnumerable <PatchGroup> patchGroups, ProgressObject po)
        {
            //TODO: Use a different progress tracking system and make the entire patching operation more recoverable and fault-tolerant.
            //TODO: Refactor this method.
            patchGroups = patchGroups.ToList();
            var appInfo      = AppInfo;
            var logger       = Logger;
            var fileProgress = new ProgressObject();

            po.Child.Value = fileProgress;
            var patchProgress = new ProgressObject();

            fileProgress.Child.Value = patchProgress;
            var myAttributesAssembly   = typeof(AppInfo).Assembly;
            var attributesAssemblyName = Path.GetFileName(myAttributesAssembly.Location);
            var history = new List <XmlFileHistory>();

            po.TaskTitle.Value = "Patching Game";
            po.TaskText.Value  = appInfo.AppName;
            po.Total.Value     = patchGroups.Count();

            foreach (var patchGroup in patchGroups)
            {
                var patchCount = patchGroup.Instructions.Count;
                po.TaskTitle.Value = $"Patching {appInfo.AppName}";
                var targetFile = patchGroup.TargetPath;
                po.TaskText.Value = Path.GetFileName(targetFile);
                //Note that Path.Combine(FILENAME, "..", OTHER_FILENAME) doesn't work on Mono but does work on .NET.
                var dir = Path.GetDirectoryName(targetFile);

                var localAssemblyName = Path.Combine(dir, attributesAssemblyName);
                var copy = true;
                fileProgress.TaskTitle.Value = "Patching File";
                fileProgress.Total.Value     = 2 + patchCount;
                fileProgress.Current.Value++;

                var backupModified = PatchingHelper.GetBackupForModified(targetFile);
                var backupOrig     = PatchingHelper.GetBackupForOriginal(targetFile);
                fileProgress.TaskText.Value = "Applying Patch";

                if (!PatchingHelper.DoesFileMatchPatchList(backupModified, targetFile, patchGroup.Instructions) ||
                    Preferences.AlwaysPatch)
                {
                    if (File.Exists(localAssemblyName))
                    {
                        try {
                            var localAssembly = AssemblyCache.Default.ReadAssembly(localAssemblyName);
                            if (localAssembly.GetAssemblyMetadataString() == myAttributesAssembly.GetAssemblyMetadataString())
                            {
                                copy = false;
                            }
                        }
                        catch (Exception ex) {
                            Logger.Warning(ex, $"Failed to read local attributes assembly so it will be overwritten.");
                            //if reading the assembly failed for any reason, just ignore...
                        }
                    }
                    if (copy)
                    {
                        File.Copy(myAttributesAssembly.Location, localAssemblyName, true);
                    }

                    var patcher = new AssemblyPatcher(targetFile, logger)
                    {
                        EmbedHistory = true
                    };

                    foreach (var patch in patchGroup.Instructions)
                    {
                        try {
                            patcher.PatchManifest(patch.Patch, patchProgress.ToMonitor());
                        }
                        catch (PatchException ex) {
                            throw new PatchingProcessException(ex)
                                  {
                                      AssociatedInstruction = patch,
                                      AssociatedPatchGroup  = patchGroup,
                                      Step = PatchProcessingStep.ApplyingSpecificPatch
                                  };
                        }
                        fileProgress.Current.Value++;
                    }
                    patchProgress.TaskText.Value  = "";
                    patchProgress.TaskTitle.Value = "";


                    fileProgress.Current.Value++;
                    fileProgress.TaskText.Value = "Writing Assembly";
                    if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                    {
                        fileProgress.TaskText.Value = "Running PEVerify...";
                        var targetFolder = Path.GetDirectoryName(targetFile);
                        try {
                            var peOutput = patcher.RunPeVerify(new PEVerifyInput {
                                AssemblyResolutionFolder = targetFolder,
                                IgnoreErrors             = AppInfo.IgnorePEVerifyErrors.ToList()
                            });
                            logger.Information(peOutput.Output);
                        }
                        catch (Exception ex) {
                            logger.Error(ex, "Failed to run PEVerify on the assembly.");
                        }
                    }

                    try {
                        patcher.WriteTo(backupModified);
                    }
                    catch (Exception ex) {
                        throw new PatchingProcessException(ex)
                              {
                                  AssociatedInstruction = null,
                                  AssociatedPatchGroup  = patchGroup,
                                  Step = PatchProcessingStep.WritingToFile
                              };
                    }
                }
                else
                {
                    fileProgress.Current.Value += patchCount;
                }
                try {
                    PatchingHelper.SwitchFilesSafely(backupModified, targetFile, backupOrig);
                }
                catch (Exception ex) {
                    throw new PatchingProcessException(ex)
                          {
                              AssociatedInstruction = null,
                              AssociatedPatchGroup  = patchGroup,
                              Step = PatchProcessingStep.PerformingSwitch
                          };
                }
                AssemblyCache.Default.ClearCache();
                po.Current.Value++;
            }
        }
示例#30
0
 private void UpdateProgress(ProgressObject progress)
 {
     ProgressPercentage = progress.Percentage;
     Output             = progress.Message;
 }
        private void InitializeNetworkWindow()
        {
            /*Нахожу поднятые интерфейсы*/
            networkInterfaces = new List <NetworkInterface>();
            NetworkInterface[] allInterfaces = NetworkInterface.GetAllNetworkInterfaces();
            for (int i = 0; i < allInterfaces.Length; ++i)
            {
                if (allInterfaces[i].OperationalStatus == OperationalStatus.Up)
                {
                    networkInterfaces.Add(allInterfaces[i]);
                }
            }
            currentInterface = 0;

            networkWindow                 = new Window(2, 14, 70, 24, "Сетевая статистика", false, 3, ref app);
            networkWindow.TimerTick      += NetworkWindow_TimerTick;
            networkWindow.BackgroundColor = ConsoleColor.Blue;
            ButtonObject btnExitNetwork = new ButtonObject(networkWindow.Left + networkWindow.Width - 12
                                                           , networkWindow.Top + networkWindow.Height - 2, 9, 1, true, false, "Закрыть");

            btnExitNetwork.BackgroundColor = ConsoleColor.DarkGray;
            btnExitNetwork.ButtonClicked  += BtnExit_ButtonClicked1;


            LabelObject labelName = new LabelObject(networkWindow.Left + 2, networkWindow.Top + 2, 40, 1, false, false, "Интерфейсы");

            labelName.BackgroundColor = ConsoleColor.Gray;
            labelName.TextColor       = ConsoleColor.Black;

            ListObject listInterfaces = new ListObject(networkWindow.Left + 2, networkWindow.Top + 3, 66, 2, false, false);

            listInterfaces.ButtonClicked        += ListInterfaces_ButtonClicked;
            listInterfaces.BackgroundColor       = ConsoleColor.Blue;
            listInterfaces.BackgroundActiveColor = ConsoleColor.White;
            listInterfaces.TextColor             = ConsoleColor.White;

            listInterfaces.List = new List <string>();
            for (int i = 0; i < networkInterfaces.Count; ++i)
            {
                listInterfaces.List.Add(networkInterfaces[i].Name);
            }

            /////////////////////////////////////////Заголовки подписей/////////////////
            LabelObject labelTitle = new LabelObject(listInterfaces.Left, listInterfaces.Top + 3, 9, 1, false, false, "Название: ");

            labelTitle.BackgroundColor = ConsoleColor.Blue;
            labelTitle.TextColor       = ConsoleColor.White;


            LabelObject labelDescription = new LabelObject(listInterfaces.Left, labelTitle.Top + 1, 9, 1, false, false, "Описание: ");

            labelDescription.BackgroundColor = ConsoleColor.Blue;
            labelDescription.TextColor       = ConsoleColor.White;

            LabelObject labelMAC = new LabelObject(listInterfaces.Left, labelTitle.Top + 2, 10, 1, false, false, "MAC-адрес: ");

            labelMAC.BackgroundColor = ConsoleColor.Blue;
            labelMAC.TextColor       = ConsoleColor.White;

            LabelObject labelStatistics = new LabelObject(labelMAC.Left, labelMAC.Top + 2, 40, 1, false, false, "Статистика");

            labelStatistics.BackgroundColor = ConsoleColor.Gray;
            labelStatistics.TextColor       = ConsoleColor.Black;

            LabelObject labelDownload = new LabelObject(listInterfaces.Left, labelStatistics.Top + 1, 34, 1, false, false, "Пакетов принято(входящий трафик): ");

            labelDownload.BackgroundColor = ConsoleColor.Blue;
            labelDownload.TextColor       = ConsoleColor.White;

            LabelObject labelUpload = new LabelObject(listInterfaces.Left, labelDownload.Top + 1, 39, 1, false, false, "Пакетов отправлено(исходящий трафик): ");

            labelUpload.BackgroundColor = ConsoleColor.Blue;
            labelUpload.TextColor       = ConsoleColor.White;

            LabelObject labelDownloadSpeed = new LabelObject(listInterfaces.Left, labelUpload.Top + 2, 40, 1, false, false, "Скорость получения:");

            labelDownloadSpeed.BackgroundColor = ConsoleColor.Blue;
            labelDownloadSpeed.TextColor       = ConsoleColor.White;

            LabelObject labelUploadSpeed = new LabelObject(listInterfaces.Left, labelDownloadSpeed.Top + 4, 40, 1, false, false, "Скорость отдачи:");

            labelUploadSpeed.BackgroundColor = ConsoleColor.Blue;
            labelUploadSpeed.TextColor       = ConsoleColor.White;
            ///////////////////////////////////////////Вставляемая информация/////////////////
            LabelObject labelTitleinfo = new LabelObject(labelTitle.Left + labelTitle.Width + 1, labelTitle.Top, 40, 1, false, false,
                                                         networkInterfaces[listInterfaces.ActiveLine].Name);

            labelTitleinfo.BackgroundColor = ConsoleColor.Blue;
            labelTitleinfo.TextColor       = ConsoleColor.White;

            LabelObject labelDescriptioninfo = new LabelObject(labelDescription.Left + labelTitle.Width + 1, labelTitle.Top + 1, 55, 1, false, false,
                                                               networkInterfaces[listInterfaces.ActiveLine].Description);

            labelDescriptioninfo.BackgroundColor = ConsoleColor.Blue;
            labelDescriptioninfo.TextColor       = ConsoleColor.White;

            LabelObject labelMACinfo = new LabelObject(labelMAC.Left + labelTitle.Width + 2, labelMAC.Top, 55, 1, false, false,
                                                       networkInterfaces[listInterfaces.ActiveLine].GetPhysicalAddress().ToString());

            labelMACinfo.BackgroundColor = ConsoleColor.Blue;
            labelMACinfo.TextColor       = ConsoleColor.White;

            var ipstat = networkInterfaces[currentInterface].GetIPv4Statistics();

            oldBytesRecived = ipstat.BytesReceived;

            oldBytesSent = ipstat.BytesSent;

            LabelObject labelDownloadinfo = new LabelObject(labelDownload.Left + labelDownload.Width, labelDownload.Top, 20, 1, false, false,
                                                            ipstat.UnicastPacketsReceived.ToString() + "/" + (ipstat.BytesReceived / 1024 / 1024).ToString() +
                                                            " Мбайт");

            labelDownloadinfo.BackgroundColor = ConsoleColor.Blue;
            labelDownloadinfo.TextColor       = ConsoleColor.White;

            LabelObject labelUploadinfo = new LabelObject(labelUpload.Left + labelUpload.Width, labelUpload.Top, 20, 1, false, false,
                                                          ipstat.UnicastPacketsSent.ToString() + "/" + (ipstat.BytesSent / 1024 / 1024).ToString() +
                                                          " Мбайт");

            labelUploadinfo.BackgroundColor = ConsoleColor.Blue;
            labelUploadinfo.TextColor       = ConsoleColor.White;


            MaxSpeed = 100;

            ProgressObject progressInput = new ProgressObject(labelStatistics.Left, labelDownloadSpeed.Top + 1, 50, 2, false, false);

            progressInput.TextColor           = ConsoleColor.White;
            progressInput.BackgroundTextColor = ConsoleColor.Blue;
            progressInput.BackgroundColor     = ConsoleColor.DarkCyan;
            progressInput.PercentColor        = ConsoleColor.Yellow;
            progressInput.Min = "0";
            progressInput.Max = MaxSpeed.ToString() + " Мбит/c";

            ProgressObject progressOutput = new ProgressObject(labelStatistics.Left, labelUploadSpeed.Top + 1, 50, 2, false, false);

            progressOutput.TextColor           = ConsoleColor.White;
            progressOutput.BackgroundTextColor = ConsoleColor.Blue;
            progressOutput.BackgroundColor     = ConsoleColor.DarkCyan;
            progressOutput.PercentColor        = ConsoleColor.Yellow;
            progressOutput.Min = "0";
            progressOutput.Max = MaxSpeed.ToString() + " Мбит/c";


            networkWindow.AddChildren(btnExitNetwork);
            networkWindow.AddChildren(labelName);
            networkWindow.AddChildren(listInterfaces);
            networkWindow.AddChildren(labelTitle);
            networkWindow.AddChildren(labelDescription);
            networkWindow.AddChildren(labelMAC);
            networkWindow.AddChildren(labelStatistics);
            networkWindow.AddChildren(labelDownload);
            networkWindow.AddChildren(labelUpload);
            networkWindow.AddChildren(labelDownloadSpeed);
            networkWindow.AddChildren(labelUploadSpeed);
            networkWindow.AddChildren(labelTitleinfo);
            networkWindow.AddChildren(labelDescriptioninfo);
            networkWindow.AddChildren(labelMACinfo);
            networkWindow.AddChildren(labelDownloadinfo);
            networkWindow.AddChildren(labelUploadinfo);
            networkWindow.AddChildren(progressOutput);
            networkWindow.AddChildren(progressInput);
        }
示例#32
0
 /// <exception cref="T:PatchworkLauncher.PatchingProcessException">Cannot patch manifest during the patching process</exception>
 public static void TryPatchManifest(this AssemblyPatcher patcher, PatchInstruction patch, PatchGroup patchGroup, ProgressObject patchProgress)
 {
     try
     {
         patcher.PatchManifest(patch.Patch, patchProgress.ToMonitor());
     }
     catch (PatchException patchException)
     {
         throw new PatchingProcessException(patchException)
               {
                   AssociatedInstruction = patch,
                   AssociatedPatchGroup  = patchGroup,
                   Step = PatchProcessingStep.ApplyingSpecificPatch
               };
     }
 }