Beispiel #1
0
        public void AddHistory()
        {
            //CostingHistory history = Main.main.threedview.ui.costingHistory;
            //history.Init();
            TimeSpan timeSpan = TimeSpan.FromSeconds(MainParameter.totalEstimatedTime);

            costData = new CostData()
            {
                name        = MainParameter.svgFileName,
                machinename = MainParameter.macnineName,
                profilename = MainParameter.proFileName,
                objects     = MainParameter.ModelCount.ToString(),
                //<timmy><9-16-2020><add base cover>
                weight = "0",
                //weight = totalWeigt.ToString("0"),
                //<><><>
                newPrice      = "0",
                recycledPrice = "0",
                rate          = "0",
                time          = "0",
                created       = DateTime.Now.ToString("yyyy/MM/dd"),
                cost          = "0",
                objectCount   = MainParameter.ModelCount
            };
        }
Beispiel #2
0
 public void AddHistory(CostData costData)
 {
     totalData.Insert(0, costData);
     totalPage = (int)Math.Ceiling((double)totalData.Count / pageSize);
     pageIndex = firstPage;
     //lastBtn.Content = totalPage;
     //firstBtn.Content = firstPage;
     UpdatePage();
     CostingHistoryCSV.Save(totalData);
     if (costData.objectCount > 0)
     {
         CostingHistoryCSV.SaveCostDataFor3WL(costData); // this was to create a costing history which append in 3wl File.
     }
 }
Beispiel #3
0
        static public void SaveCostDataFor3WL(CostData costData)
        {
            string        costingCSV_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XYZware_SLS_v1.0" + Path.DirectorySeparatorChar);
            StringBuilder shortPath       = new StringBuilder(255);

            MainParameter.GetShortPathName(costingCSV_path, shortPath, shortPath.Capacity);
            costingCSV_path = Path.Combine(shortPath.ToString(), "CostingHistory.csv");
            StreamWriter writer = new StreamWriter(costingCSV_path);

            writer.WriteLine(version);
            writer.WriteLine(title + ",volume");
            string data        = "";
            double totalVolume = 0.00;

            //foreach (double vol in Main.main.List_ModelsVolume)
            //    totalVolume += vol;

            totalVolume = MainParameter.gCodeVolume;/// 1000;

            foreach (string str in costData.GetDataArray())
            {
                data += str + ',';
            }
            data = data.TrimEnd(',');
            writer.WriteLine(data + "," + totalVolume);


            ////<timmy><9-21-2020><udpate - let single object detail store in costing csv of 3wl>
            ////if (costData.objectCount >= 1)
            if (costData.objectCount > 1)
            {
                int index = 0;
                foreach (CostObjectData costObjectData in costData.costObjects)
                {
                    data = "";
                    foreach (string str in costObjectData.GetDataArray())
                    {
                        data += str + ',';
                    }
                    data = data.TrimEnd(',');
                    // writer.WriteLine(data + "," + Main.main.List_ModelsVolume[index]);
                    writer.WriteLine(data + "," + "0");
                    index++;
                }
            }
            writer.WriteLine();
            writer.Close();
        }
Beispiel #4
0
        static public List <CostData> GetData(bool check)
        {
            if (check)
            {
                if (!File.Exists(path))
                {
                    CreateNew();
                }
                Upgrade();
            }
            #region remove code
            //StreamReader reader = new StreamReader(path);
            //reader.ReadLine();
            //reader.ReadLine();
            //List<CostData> costDetails = new List<CostData>();
            //string line;
            //int index = 0;

            //while (!reader.EndOfStream)
            //{
            //    line = reader.ReadLine();
            //    if (line == "") continue;
            //    //CostData costDetail = new CostData(line.Split(',')); // remove code
            //   CostData costDetail = new CostData(line.Split(','), true, index); //modified code for compatibility of files.
            //    costDetails.Add(costDetail);
            //    index++;
            //    if (costDetail.objectCount > 1)
            //    {
            //        while (!reader.EndOfStream)
            //        {
            //            line = reader.ReadLine();
            //            if (line != "")
            //            {
            //                string[] costHeader = line.Split(',');
            //                if (costHeader[0] != "")
            //                {
            //                    string[] type = costHeader[0].Split('.');
            //                    if (type.Count() == 2 && type[type.Count() - 1] != "3wl")
            //                    {
            //                     costDetail.AddObject(line.Split(','));
            //                        index++;
            //                    }
            //                    if (type[type.Count() - 1] != "3mf" && costDetail.name != costHeader[0])
            //                    {
            //                        if (Convert.ToInt32(costHeader[3]) != 1)
            //                            continue;
            //                        else
            //                        {
            //                            costDetail = new CostData(line.Split(','), true, index); //reset the costdetail item & reset to create the next costdetail.
            //                            costDetails.Add(costDetail);
            //                        }
            //                    }
            //                }
            //            }
            //            else
            //            {
            //                break;
            //            }
            //        }
            //    }

            //}

            //reader.Close();
            #endregion

            Dictionary <string, string> costitems = new Dictionary <string, string>();
            CostData        costDetail            = new CostData();
            List <CostData> costDetails           = new List <CostData>();
            List <Dictionary <string, string> > record_history = CostingHistoryCSV.BackUp_Records(CostingHistoryCSV.path);
            bool HasMultipleObject = false;
            for (int i = 0; i < record_history.Count; i++)
            {
                costitems = record_history[i];
                if (costitems["Name"].Substring(costitems["Name"].Length - 4) == ".3wl" || HasMultipleObject)
                {
                    costDetail               = new CostData();
                    costDetail.costObjects   = new List <CostObjectData>();
                    costDetail.name          = costitems["Name"] != "" || costitems["Name"] != "-" ? costitems["Name"] : "";
                    costDetail.objects       = costitems["Objects"] != "" || costitems["Objects"] != "-" ? costitems["Objects"] : "";
                    costDetail.objectCount   = Convert.ToInt32(costDetail.objects);
                    costDetail.weight        = costitems["Weight"] != "" || costitems["Weight"] != "-" ? costitems["Weight"] : "";
                    costDetail.newPrice      = costitems["New"] != "" || costitems["New"] != "-" ? costitems["New"] : "";
                    costDetail.recycledPrice = costitems["Recycled"] != "" || costitems["Recycled"] != "-" ? costitems["Recycled"] : "";
                    costDetail.rate          = costitems["Rate"] != "" || costitems["Rate"] != "-" ? costitems["Rate"] : "";
                    costDetail.time          = costitems["Time"] != "" || costitems["Time"] != "-" ? costitems["Time"] : "";
                    costDetail.created       = costitems["Created"] != "" || costitems["Created"] != "-" ? costitems["Created"] : "";
                    costDetail.cost          = costitems["Cost"] != "" || costitems["Cost"] != "-" ? costitems["Cost"] : "";
                    costDetail.profilename   = costitems.ContainsKey("Profile Settings") ? costitems["Profile Settings"] != "" || costitems["Profile Settings"] != "---" ? costitems["Profile Settings"] : "" : "---";
                    costDetail.machinename   = costitems.ContainsKey("Printer Name") ? costitems["Printer Name"] != "" || costitems["Printer Name"] != "---" ? costitems["Printer Name"] : "" :
                                               costitems.ContainsKey("Machine Name") ? costitems["Machine Name"] : "---";
                    costDetails.Add(costDetail);
                }
                else if (costitems["Name"].Substring(costitems["Name"].Length - 4) == ".3mf" || costitems["Name"].Substring(costitems["Name"].Length - 4) == ".stl")
                {
                    string name, weight, cost, volume;
                    name   = costitems["Name"] != "" || costitems["Name"] != "-" ? costitems["Name"] : "";
                    weight = costitems["Weight"] != "" || costitems["Weight"] != "-" ? costitems["Weight"] : "";
                    cost   = costitems["Cost"] != "" || costitems["Cost"] != "-" ? costitems["Cost"] : "";
                    costDetail.AddObject(name, Convert.ToDouble(weight), Convert.ToDouble(cost));
                }
            }

            return(costDetails);
        }