private void GetStatus() { if (timerWork) { } else { Dictionary <string, DataBase> sendedList = new Dictionary <string, DataBase>(); timerWork = true; foreach (DataBase nodeBase in AllDataBase) { MyXmlNode node = nodeBase.node; bool started = node.started; bool finished = node.finished; bool downloaded = node.downloaded; string number = node.number; if (started && !finished && !downloaded) { sendedList.Add(ClassCalcConnect.GetChangeNumbStr(number), nodeBase); } } if (sendedList.Count > 0) { int[] status = CppClass.GetStatusFiles(sendedList.Keys.ToArray()); for (int i = 0; i < sendedList.Count; i++) { var item = sendedList.ElementAt(i); item.Value.node.curStatus = status[i]; updateRowByStatus(item.Value); } } timerWork = false; } }
internal void StartToDownload(List <int> indexes) { List <string> cadNums = new List <string>(); foreach (int i in indexes) { MyXmlNode node = AllDataBase[i].node; bool started = node.started; bool downloaded = node.downloaded; if (started && !downloaded) { node.started = true; node.finished = false; node.curStatus = -1; node.downloaded = true; cadNums.Add(ClassCalcConnect.GetChangeNumbStr(node.number)); } } if (cadNums.Count == 0) { return; } if (!downloadedStarted) { System.Threading.Thread thr = new System.Threading.Thread(() => onSendNumsDownLoad(cadNums)); thr.Start(); } else { CppClass.DownloadFilesFromServer(cadNums.ToArray()); System.Threading.Thread thr = new System.Threading.Thread(p => updateDownloadRows()); thr.Start(); } }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode, Lifestyle objParentLifestyle) { ParentLifestyle = objParentLifestyle; objNode.TryGetField("guid", Guid.TryParse, out _guiID); if (objNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } if (!objNode.TryGetField("id", Guid.TryParse, out _SourceGuid)) { MyXmlNode?.TryGetField("id", Guid.TryParse, out _SourceGuid); } objNode.TryGetStringFieldQuickly("extra", ref _strExtra); objNode.TryGetInt32FieldQuickly("lp", ref _intLP); objNode.TryGetStringFieldQuickly("cost", ref _strCost); objNode.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier); objNode.TryGetInt32FieldQuickly("basemultiplier", ref _intBaseMultiplier); objNode.TryGetBoolFieldQuickly("contributetolimit", ref _blnContributeToLimit); objNode.TryGetBoolFieldQuickly("print", ref _blnPrint); if (objNode["lifestylequalitytype"] != null) { _objLifestyleQualityType = ConvertToLifestyleQualityType(objNode["lifestylequalitytype"].InnerText); } #if DEBUG if (objNode["lifestylequalitysource"] != null) { _objLifestyleQualitySource = ConvertToLifestyleQualitySource(objNode["lifestylequalitysource"].InnerText); } #else _objLifestyleQualitySource = QualitySource.Selected; #endif objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetStringFieldQuickly("page", ref _strPage); string strAllowedFreeLifestyles = string.Empty; if (!objNode.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles)) { strAllowedFreeLifestyles = MyXmlNode?["allowed"]?.InnerText ?? string.Empty; } _lstAllowedFreeLifestyles = strAllowedFreeLifestyles.Split(',').ToList(); _nodBonus = objNode["bonus"]; objNode.TryGetStringFieldQuickly("notes", ref _strNotes); if (GlobalOptions.Language != GlobalOptions.DefaultLanguage) { XmlNode objLifestyleQualityNode = MyXmlNode; if (objLifestyleQualityNode != null) { objLifestyleQualityNode.TryGetStringFieldQuickly("translate", ref _strAltName); objLifestyleQualityNode.TryGetStringFieldQuickly("altpage", ref _strAltPage); } } LegacyShim(); }
private void updateDownloadRows() { if (timerWorkDownload) { } else { Dictionary <string, DataBase> sendedList = new Dictionary <string, DataBase>(); timerWorkDownload = true; foreach (DataBase nodeBase in AllDataBase) { MyXmlNode node = nodeBase.node; bool started = node.started; bool finished = node.finished; bool downloaded = node.downloaded; string number = node.number; if (started && !finished && downloaded) { sendedList.Add(number, nodeBase); } } if (sendedList.Count > 0) { for (int i = 0; i < sendedList.Count; i++) { var item = sendedList.ElementAt(i); point_c progress = CppClass.GetProgressFile_(item.Key); item.Value.node.curStatus = (int)progress.X_B; if (progress.Y_L == 1) { string stringForParse = CppClass.GetFile_(item.Key); updateRowByStatus(item.Value); //TODO парсим файл item.Value.node.finished = true; item.Value.node.curStatus = -1; item.Value.node.downloaded = false; } updateRowByStatus(item.Value); } } else { downloadedStarted = false; aTimerDownload.Stop(); aTimerDownload = null; } timerWorkDownload = false; } }
internal void AddByIndex(DataGridViewRow row) { DataBase baseCur = new DataBase(); int AddedIndex = row.Index; MyXmlNode node = new MyXmlNode(); node.ischecked = (bool)row.Cells[0].Value; node.number = row.Cells[1].Value.ToString(); node.started = false; node.curStatus = -1; node.finished = false; node.downloaded = false; baseCur.row = row; baseCur.node = node; AllDataBase.Add(baseCur); }
private void updateRowByStatus(DataBase nodeBase) { MyXmlNode node = nodeBase.node; bool started = node.started; bool finished = node.finished; bool downloaded = node.downloaded; // string number = node.number; int status = node.curStatus; DataGridViewCell cell = nodeBase.row.Cells[2]; DataGridViewCellStyle style = nodeBase.row.DataGridView.DefaultCellStyle; nodeBase.row.DataGridView.Invoke(new Action(() => { if (started && downloaded && !finished) { //прогресс загрузки curStatus //nodeBase.row.Cells[2].Style.BackColor = Color.White; nodeBase.row.Cells[2].Style.BackColor = Color.White; nodeBase.row.Cells[2].Value = new object[] { "downloaded", nodeBase.node.curStatus };// // updateProgressCell(cell, style, Color.Red, "downloaded", 10); } else if (started && !downloaded && finished) { //файл скачан и обработан nodeBase.row.Cells[2].Style.BackColor = Color.LawnGreen; nodeBase.row.Cells[2].Value = new object[] { "finished", -1 };// // updateProgressCell(cell, style, Color.Red, "finished", -1); } else if (started && !downloaded && !finished) { nodeBase.row.Cells[2].Style.BackColor = Color.LightGreen; nodeBase.row.Cells[2].Value = new object[] { "started", -1 };// // updateProgressCell(cell, style, Color.Red, "started", -1); //статус по curStatus } // else // nodeBase.row.Cells[2].Value = new object[] { " ", -1 };// "started"; })); }
internal void StartToSend(List <int> indexes) { List <string> cadNums = new List <string>(); foreach (int i in indexes) { MyXmlNode node = AllDataBase[i].node; bool downloaded = node.downloaded; if (!downloaded) { cadNums.Add(ClassCalcConnect.GetChangeNumbStr(node.number)); node.started = true; node.finished = false; node.downloaded = false; node.curStatus = -1; } } System.Threading.Thread thr = new System.Threading.Thread(() => onSendNums(cadNums)); thr.Start(); }
internal void Save(DataGridView grid) { XmlDocument docUserKadNums = new XmlDocument(); if (!System.IO.File.Exists(userNumsFile)) { XmlElement root = docUserKadNums.CreateElement("CadNums"); docUserKadNums.AppendChild(root); } else { docUserKadNums.Load(userNumsFile); } XmlNode rootNode = docUserKadNums.DocumentElement; rootNode.RemoveAll(); for (int i = 0; i < AllDataBase.Count; i++) { MyXmlNode mynode = AllDataBase[i].node; XmlNode node = docUserKadNums.CreateElement("userNum"); XmlAttribute selected = docUserKadNums.CreateAttribute("checked"); selected.Value = AllDataBase[i].row.Cells[0].Value.ToString(); XmlAttribute number = docUserKadNums.CreateAttribute("number"); number.Value = mynode.number.ToString(); XmlAttribute started = docUserKadNums.CreateAttribute("started"); started.Value = mynode.started.ToString(); XmlAttribute curStatus = docUserKadNums.CreateAttribute("curStatus"); curStatus.Value = mynode.curStatus.ToString(); XmlAttribute finished = docUserKadNums.CreateAttribute("finished"); finished.Value = mynode.finished.ToString(); XmlAttribute downloaded = docUserKadNums.CreateAttribute("downloaded"); downloaded.Value = mynode.downloaded.ToString(); node.Attributes.Append(selected); node.Attributes.Append(number); node.Attributes.Append(started); node.Attributes.Append(curStatus); node.Attributes.Append(finished); node.Attributes.Append(downloaded); rootNode.AppendChild(node); } XmlNode dir = rootNode.SelectSingleNode("./Directory"); if (dir == null) { dir = docUserKadNums.CreateElement("Directory"); rootNode.AppendChild(dir); } dir.InnerText = Directory; docUserKadNums.Save(userNumsFile); aTimer.Stop(); aTimer.Dispose(); }