protected void Page_Load(object sender, EventArgs e)
    {
        //Some variables for use on this page
        int id;
        string fname;
        string lname;
        string perm;
        string woID;

        //Check permission level and redirect if needed
        if (Session["Perm"] == null)
        {
            Response.Redirect("login.aspx");
        }

        if (!Session["Perm"].Equals("C"))
        {
            Response.Redirect("login.aspx");

        }

        //assign the variables from the session created from the login page
        id = Convert.ToInt32(Session["CustID"]);
        perm = Session["Perm"].ToString();
        fname = Session["CFname"].ToString();
        lname = Session["CLname"].ToString();
        woID = Session["WorkOrderID"].ToString();

        //Custom welcome message on the screen
        lblWelcome.Text = "Welcome " + fname + " " + lname + ". Customer ID: " + id;
        string select = "SELECT Doc from Docs WHERE EmpID IS NOT NULL AND WorkOrderID = " + woID + ";";
        FileWork fw = new FileWork();
        fw.DownloadFile(select);
    }
Пример #2
0
 protected void btnDownloadDocs_Click(object sender, EventArgs e)
 {
     woID = Convert.ToInt16(ddlWOList.SelectedValue);
     Session["WorkOrderID"] = woID;
     FileWork fw = new FileWork();
     string select = "Select Doc FROM Docs WHERE WorkOrderID = " + woID + ";";
     fw.DownloadFile(select);
 }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Ваш словарь: ");
            foreach (var keyValue in FileWork.ParseFile())
            {
                Console.WriteLine(keyValue.Key + " : " + keyValue.Value);
            }

            CounterOp.Counter.DictCounter();
            Console.Write("Введите слово, информацию о котором хотите узнать: ");
            var yourWord = Console.ReadLine();

            CounterOp.Counter.DictSearch(yourWord, FileWork.ParseFile());
        }
Пример #4
0
        private void ApplyAllSuggestions(object sender, RoutedEventArgs e)
        {
            this.TierListFacade.ApplyAllSuggestions();

            this.TierListFacade.TierListData.Values.ToList().ForEach(x => x.ReEvaluate());

            LoggingFacade.LogInfo($"Writing Changelog! Tiers Logged: {this.TierListFacade.Changelog.Select(x => x.Value.Count).Sum()}");

            var json          = JsonConvert.SerializeObject(this.TierListFacade.Changelog).Replace("->", "_");
            var changeLogPath = LocalConfiguration.GetInstance().AppSettings["Output Folder"] + "/Changelog/changelog.json";

            FileWork.WriteTextAsync(changeLogPath, json);

            this.EventGrid.Publish();
        }
Пример #5
0
 private void OpenBtn_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             FileWork file = new FileWork(openFileDialog.FileName);
             input.Text = file.ReadText();
         }
         catch (Exception)
         {
             MessageBox.Show("error");
         }
     }
 }
Пример #6
0
 private void saveBtn_Click(object sender, EventArgs e)
 {
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             FileWork file = new FileWork(saveFileDialog.FileName);
             file.Write(graph);
         }
         catch (Exception)
         {
             MessageBox.Show("Error");
         }
     }
 }
Пример #7
0
        /// <summary>
        /// Переделать для автоматизации
        /// </summary>
        private void CheckNextMonthFileWorkPlan()
        {
            IsWorkSync = true;
            if (DateTime.Now.Day >= 25)
            {
                var NextMonth = DateTime.Now.AddMonths(1);
                // Проверка на следующий год
                if (NextMonth.Month == 1)
                {
                    if (setContext.Settings.YearAddedInCalendar < NextMonth.Year)
                    {
                        if (FileWork.GetFileName(NextMonth.Month, NextMonth.Year) != null)
                        {
                            var itemCalendars = GetListItemCalendarsOfEmploy(NextMonth);
                            if (itemCalendars != null)
                            {
                                setContext.Settings.YearAddedInCalendar  = NextMonth.Year;
                                setContext.Settings.MonthAddedInCalendar = NextMonth.Month;
                                setContext.SaveSettings();
                            }
                        }

                        //Other.AddItemCalendar(itemCalendars);
                    }
                }//Конец проверки на следующий год
                else
                {
                    if (setContext.Settings.MonthAddedInCalendar < NextMonth.Month)
                    {
                        if (FileWork.GetFileName(NextMonth.Month, NextMonth.Year) != null)
                        {
                            var itemCalendars = GetListItemCalendarsOfEmploy(NextMonth);
                            if (itemCalendars != null)
                            {
                                setContext.Settings.MonthAddedInCalendar = NextMonth.Month;
                                setContext.SaveSettings();
                            }

                            //Other.AddItemCalendar(itemCalendars);
                        }
                    }
                }
            }

            setContext.Settings.LastSync = Converter.ConvertToDateSync(DateTime.Now);
            setContext.SaveSettings();
            IsWorkSync = false;
        }
Пример #8
0
 private void OpenBtn_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             FileWork file = new FileWork(openFileDialog.FileName);
             queue = file.ReadIntQueue();
             Upd();
         }
         catch (Exception)
         {
             MessageBox.Show("Error");
         }
     }
 }
Пример #9
0
        private void LoadFromFile(object sender, RoutedEventArgs e)
        {
            var fd = new OpenFileDialog();

            if (fd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var filePath       = fd.FileName;
            var responseString = FileWork.ReadFromFile(filePath);

            var branchKey = this.GetBranchKey();

            this.ItemInfoData.Deserialize(branchKey, responseString);
            this.ItemInfoData.MigrateAspectDataToEcoData(this.EconomyData, branchKey);
        }
Пример #10
0
        public void Input()
        {
            FileWork     fileWork     = new FileWork();
            String       fileName     = fileWork.ReadFromFile();
            StreamReader streamReader = new StreamReader(fileName);
            bool         fileIsSaved  = false;

            int[] array = new int[1];
            while (!fileIsSaved)
            {
                fileIsSaved = true;
                InputValidation inputValidation = new InputValidation();
                string[]        tmpArray        = streamReader.ReadLine().Split(' ', '\n');
                array = new int[tmpArray.Length];
                for (int i = 0; i < tmpArray.Length; i++)
                {
                    if (!int.TryParse(tmpArray[i], out array[i]))
                    {
                        Console.WriteLine("Error on symbol number" + (i + 1));
                        Console.WriteLine("Fix this file and then try again");
                        fileName     = fileWork.ReadFromFile();
                        streamReader = new StreamReader(fileName);
                        fileIsSaved  = false;
                        break;
                    }
                }
            }

            Algorithms algo = new Algorithms(array);

            algo.Algorithm();

            algo.printArr();

            Console.Write(
                "Sum of odd numbers - {0}\nSum of even numbers - {1}\n", algo.getOddSum(), algo.getEvenSum());


            streamReader.Close();
            Confirmation confirmation = new Confirmation();

            if (confirmation.Confirm("Do you want to save the results? Y/N"))
            {
                fileWork.WriteIntoTheFile(algo);
            }
        }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        int fileLength;
        bool success;
        string connectionString = "INSERT INTO Docs (WorkOrderID, CustomerID, Doc) VALUES (@WorkOrderID, @CustomerID, @Doc)";
        //first check to see if there is actually a file selected, then do work
        if (cstFileUp.HasFile)
        {
            string fileExt = System.IO.Path.GetExtension(cstFileUp.FileName);
            if (fileExt == ".pdf")
            {
                //get the file length to initialize the array to
                fileLength = cstFileUp.PostedFile.ContentLength;
                byte[] fileBytes = new byte[fileLength - 1];
                //read the bytes of the file
                fileBytes = cstFileUp.FileBytes;
                //create a new instance to use its methods
                FileWork fw = new FileWork();
                //method returns a boolean to check for successfull addition of the file to the db
                success = fw.UploadFile(connectionString, ddlWOList.SelectedValue, fileBytes);
                if (success)
                {
                    lblUploadStatus.Text = "Your file has been uploaded and the staff at WeServeU notified.";
                    lblUploadStatus.ForeColor = System.Drawing.Color.Green;
                    lblUploadStatus.Visible = true;
                }
                else
                {
                    lblUploadStatus.Text = "There was an error uploading your file. Please try again later";
                    lblUploadStatus.ForeColor = System.Drawing.Color.Red;
                    lblUploadStatus.Visible = true;
                }
            }
            else
            {
                lblUploadStatus.Text = "File is not a PDF. Please only upload PDF documents";
                lblUploadStatus.ForeColor = System.Drawing.Color.Red;
                lblUploadStatus.Visible = true;
            }

        }
        else
        {
            lblUploadStatus.Text = "There was no file specified to upload";
        }
    }
Пример #12
0
        static void Main(string[] args)
        {
            // Console.Write("Enter the name of the dictionary you need: ");
            //  var fileName = Console.ReadLine();
            //  Console.WriteLine("Dictionary is " + fileName);
            Console.WriteLine("Dictionary: ");
            foreach (var keyValue in FileWork.ParseFile())
            {
                Console.WriteLine(keyValue.Key + " : " + keyValue.Value);
            }

            CounterOp.Counter.DictCounter();
            Console.Write("Enter the word for information about it's repeats: ");
            var yourWord = Console.ReadLine();

            CounterOp.Counter.DictSearch(yourWord, FileWork.ParseFile());
        }
Пример #13
0
 private void OpenBtn_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             FileWork file = new FileWork(openFileDialog.FileName);
             graph           = file.Read();
             GraphDraw.graph = graph;
             UpdateImage();
         }
         catch (Exception)
         {
             MessageBox.Show("Error");
         }
     }
 }
        private void LoadMetaFilter(object sender, RoutedEventArgs e)
        {
            var outputFolder = Configuration.AppSettings["Meta Filter Path"];

            LoggingFacade.LogInfo($"Loading Meta Filter: {outputFolder}");

            this.FilterExoFacade.RawMetaFilterText = FileWork.ReadLinesFromFile(outputFolder);
            var output = this.FilterExoFacade.Execute();

            GenerationOptions.TextSources = output;
            EventGrid.Publish();

            if (this.FilterRawString == null || this.FilterRawString.Count < 4500)
            {
                LoggingFacade.LogWarning($"Loading Filter: Meta-Filter Content Suspiciously Short");
            }
        }
Пример #15
0
        private void Initialization(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                IsNameButtonAfterRun = false;
                file                 = new FileWork();
                basicCalculate       = new BasicCalculations(this);
                IsEnabledBtnOpenFile = true;
            }
            catch (Exception ex)
            {
                IsEnabledBtnOpenFile = false;
                IsEnabledBtnRun      = false;
                MessageBox.Show("Инициализация прервана" + ex.Message);
            }
        }
        public void ApplyAllSuggestions()
        {
            LoggingFacade.LogInfo("Applying All Suggestions!");
            this.Changelog.Clear();

            foreach (var section in this.Suggestions)
            {
                if (!this.TierListData.ContainsKey(section.Key) || (this.TierListData[section.Key].FilterEntries?.Count == 0))
                {
                    if (FilterPolishConfig.MatrixTiersStrategies.Keys.Contains(section.Key))
                    {
                        continue;
                    }

                    LoggingFacade.LogWarning($"Skipping section {section.Key} . No data found for section!");
                    continue;
                }

                if (this.EnabledSuggestions.ContainsKey(section.Key) && !this.EnabledSuggestions[section.Key])
                {
                    LoggingFacade.LogInfo($"SKIP Suggestions generation for: {section.Key}");
                    continue;
                }

                this.Changelog.Add(section.Key, new List <TieringChange>());
                this.ApplyAllSuggestionsInSection(section.Key);
            }

            var keys = this.Changelog.Keys.ToList();

            foreach (var section in keys)
            {
                this.Changelog[section] = this.Changelog[section].OrderBy(x => x.BaseType).ToList();
            }

            if (this.generatePrimitiveReport)
            {
                var report   = this.GeneratePrimitiveReport();
                var seedPath = this.WriteFolder + "tierlistchanges\\" + DateTime.Today.ToString().Replace("/", "-").Replace(":", "") + ".txt";
                FileWork.WriteTextAsync(seedPath, report);
            }
        }
Пример #17
0
 public bool Exec(string Query)
 {
     try
     {
         this.ExError = new Exception();
         if (!(this.OleDbCon.State == ConnectionState.Open))
         {
             this.OleDbCon.Open();
         }
         new OleDbCommand(Query, this.OleDbCon).ExecuteNonQuery();
         FileWork.WriteSqlLog(Query + Environment.NewLine + "\tRESULT: " + "true");
         return(true);
     }
     catch (Exception ex)
     {
         this.ExError = ex;
         FileWork.WriteSqlLog(Query + Environment.NewLine + "\tRESULT: " + "Exception " + ex.Message);
         return(false);
     }
 }
Пример #18
0
        public FormAdd(FileWork fileWork, IFile file, int indexElement = -1)
        {
            this.file = file;
            InitializeComponent();
            this.indexElement = indexElement;

            this.fileWork = fileWork;
            if (fileWork == FileWork.EditNotes)
            {
                LinkedListNode <INote> node = note.First;
                int i = 0;
                while (i++ != indexElement)
                {
                    node = node.Next;
                }
                addressTextBox.Text     = view.Address;
                portTextBox.Text        = view.Port.ToString();
                serverTypeComboBox.Text = view.ServerType;
            }
        }
Пример #19
0
        private void SelectSeedFilterFile(object sender, RoutedEventArgs e)
        {
            var fd = new OpenFileDialog();

            if (fd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            var filePath = fd.FileName;
            var lineList = FileWork.ReadLinesFromFile(filePath);

            if (lineList == null || lineList.Count < 4500)
            {
                LoggingFacade.LogError("Warning: (seed) filter result line count: " + lineList?.Count);
            }
            this.FilterAccessFacade.PrimaryFilter = new Filter(lineList);

            this.ResetAllComponents();
            this.LoadAllComponents();
            this.EventGrid.Publish();
        }
Пример #20
0
        /// <summary>
        /// 开始执行升级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_update_Click(object sender, EventArgs e)
        {
            Btn_update.Enabled       = false;
            Btn_close.Enabled        = false;
            this.notifyIcon1.Visible = true;
            this.notifyIcon1.ShowBalloonTip(5000);

            #region  载远程更新说明xml
            if (DownXml())
            {
                //下载完成后检查是否需要下载更新包
                if (FileWork.IsUpdate())
                {
                    if (Util.GetProcessName())
                    {
                        if (MessageBox.Show(this, "为了更新的顺利完成,请退出应用程序!", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            Util.KillProcess();
                        }
                        else
                        {
                            File.Delete(Util.GetDictiory() + "\\ServerUpdateFiles.xml");
                            this.Close();
                            Back_thread.CancelAsync();//取消线程
                        }
                    }
                    //创建事件日志文件
                    LookEventLog();
                    Back_thread.RunWorkerAsync();//开始辅助线程
                }
                else
                {
                    //无需更新
                    MessageBox.Show(this, "您当前是最新版本无需更新!", "信息提示");
                    File.Delete(Util.GetDictiory() + "\\ServerUpdateFiles.xml");
                    this.Close();
                }
            }
            #endregion
        }
Пример #21
0
        private List <ItemCalendar> GetListItemCalendarsOfEmploy(DateTime month)
        {
            if (FileWork.GetFileName(month.Month,
                                     month.Year) == null)
            {
                return(null);
            }

            var workPlans = WorkPlanList.GetPlan(month.Month,
                                                 month.Year);

            //var itemCalendars = Converter.Convert(
            //    workPlans.Where(t => t.NameEmploy.Contains(setContext.Settings.NameEmploy))
            //        .Where(t => t.EndTO >= DateTime.Now).ToList()
            var itemCalendars = Converter.Convert(
                workPlans.Where(t => t.NameEmploy
                                .Contains(setContext.Settings.NameEmploy))
                .ToList());

            lAddedItem.Text = "Добавлено " + itemCalendars.Count.ToString();
            return(itemCalendars);
        }
Пример #22
0
        public int ExecWithResult(string Query)
        {
            int value = 0;

            try
            {
                this.ExError = new Exception();
                this.OleDbCon.Open();
                value = (int)new OleDbCommand(Query, this.OleDbCon).ExecuteScalar();
                FileWork.WriteSqlLog(Query + Environment.NewLine + "\tRESULT: " + value);
                this.OleDbCon.Close();
                FileWork.WriteSqlLog(Query + Environment.NewLine + "\tRESULT: " + value);
                return(value);
            }
            catch (Exception ex)
            {
                this.ExError = ex;
                value        = int.MaxValue;
                OleDbCon.Close();
                FileWork.WriteSqlLog(Query + Environment.NewLine + "\tRESULT: " + "Exception");
                return(value);
            }
        }
Пример #23
0
        static void Main(string[] args)
        {
            Transport car = new Car();
            //  Console.WriteLine(car.getInformation());

            Transport plane = new AirPlane();
            //  Console.WriteLine(plane.getInformation());
            Transport ship  = new Ship();
            Transport train = new Train();
            Transport bike  = new Bike();

            List <Transport> list = new List <Transport>();

            list.Add(car);
            list.Add(plane);
            list.Add(ship);
            list.Add(train);
            list.Add(bike);

            foreach (Transport t in list)
            {
                //     Console.WriteLine(t.infoToWrite());
            }

            /* foreach (Transport t in list)
             * {
             *   Console.WriteLine(t.getInformation());
             * }*/

            FileWork fw = new FileWork();

            //fw.WriteAllToFile(list);
            fw.readAllFromFile();

            Console.ReadLine();
        }
Пример #24
0
 public int GetAsInteger(string Row)
 {
     try
     {
         this.ExError = new Exception();
         if (!this.OleDbdr.IsClosed)
         {
             for (int ordinal = 0; ordinal < this.OleDbdr.FieldCount; ++ordinal)
             {
                 if (this.OleDbdr.GetName(ordinal).ToUpper() == Row.ToUpper())
                 {
                     FileWork.WriteSqlLog("SQL Get as Integer from " + Row + Environment.NewLine + "\tRESULT: " + Convert.ToInt32(this.OleDbdr[ordinal]).ToString());
                     return(Convert.ToInt32(this.OleDbdr[ordinal]));
                 }
             }
         }
         return(0);
     }
     catch (Exception ex)
     {
         this.ExError = ex;
         return(0);
     }
 }
Пример #25
0
        private Filter PerformFilterWork()
        {
            var    outputFolder = Configuration.AppSettings["Output Folder"];
            var    defaultPath  = outputFolder + "\\Unnamed filter - SEED (SeedFilter) .filter";
            string filePath;

            if (System.IO.File.Exists(defaultPath))
            {
//                InfoPopUpMessageDisplay.ShowInfoMessageBox("unnamed seed used");
                filePath = defaultPath;
            }
            else
            {
                this.SelectSeedFilterFile(null, null);
                return(this.FilterAccessFacade.PrimaryFilter);
            }

            this.FilterRawString = FileWork.ReadLinesFromFile(filePath);
            if (this.FilterRawString == null || this.FilterRawString.Count < 4500)
            {
                InfoPopUpMessageDisplay.ShowError("Warning: (seed) filter result line count: " + this.FilterRawString?.Count);
            }
            return(new Filter(this.FilterRawString));
        }
Пример #26
0
        private void button_ADD(object sender, RoutedEventArgs e)
        {
            if (Wait.IsOpen)
            {
                return;
            }
            if (LongtaskPingCANCELING.isENABLE())
            {
                return;
            }
            if (IPTVman.Model.loc.openfile)
            {
                return;
            }
            loc.openfile = true;
            if (ViewModelMain.myLISTselect == null)
            {
                ViewModelMain.myLISTselect = new List <ParamCanal>();
            }

            _file = new FileWork();
            _file.Task_Completed += _file_Task_Completed;
            _file.LOAD("", ViewModelMain.myLISTselect, title, false, false);
        }
Пример #27
0
        public void ApplyAllSuggestions()
        {
            this.Changelog.Clear();

            foreach (var section in this.Suggestions)
            {
                this.Changelog.Add(section.Key, new List <TieringChange>());
                this.ApplyAllSuggestionsInSection(section.Key);
            }

            var keys = this.Changelog.Keys.ToList();

            foreach (var section in keys)
            {
                this.Changelog[section] = this.Changelog[section].OrderBy(x => x.BaseType).ToList();
            }

            if (this.generatePrimitiveReport)
            {
                var report   = this.GeneratePrimitiveReport();
                var seedPath = this.WriteFolder + "tierlistchanges\\" + DateTime.Today.ToString().Replace("/", "-").Replace(":", "") + ".txt";
                FileWork.WriteTextAsync(seedPath, report);
            }
        }
Пример #28
0
        static void Main(string[] args)
        {
            FileStream   fout = new FileStream("test.txt", FileMode.OpenOrCreate);
            StreamReader file_out;
            int          Count_in_file;

            Console.WriteLine("Самое большое слово в файле: {0}\n Оно встреччайлось в файле {1} раз(а)", FileWork.FindBiggestWordAndItCount(fout, out Count_in_file), Count_in_file);
        }
Пример #29
0
 private async Task WriteSeedFilter(Filter baseFilter, string filePath)
 {
     var seedFilterString = baseFilter.Serialize();
     await FileWork.WriteTextAsync(filePath, seedFilterString);
 }
Пример #30
0
        public static async Task WriteFilter(Filter baseFilter, bool isGeneratingStylesAndSeed, string outputFolder, string styleSheetFolderPath)
        {
            var isStopping = VerifyFilter(baseFilter);

            if (isStopping)
            {
                return;
            }

            new FilterTableOfContentsCreator(baseFilter).Run();

            const string filterName       = "NeverSink's";
            var          generationTasks  = new List <Task>();
            var          seedFilterString = baseFilter.Serialize();

            if (isGeneratingStylesAndSeed)
            {
                var seedPath = outputFolder + "ADDITIONAL-FILES\\SeedFilter\\";
                if (!Directory.Exists(seedPath))
                {
                    Directory.CreateDirectory(seedPath);
                }
                seedPath += filterName + " filter - SEED (SeedFilter) .filter";
                generationTasks.Add(FileWork.WriteTextAsync(seedPath, seedFilterString));
            }

            baseFilter = new Filter(seedFilterString); // we do not want to edit the seedFilter directly and execute its tag commands
            baseFilter.ExecuteCommandTags();
            var baseFilterString = baseFilter.Serialize();

            if (baseFilterString == null || baseFilterString.Count < 4500)
            {
                LoggingFacade.LogError("Warning: (seed) filter result line count: " + baseFilterString?.Count);
            }

            for (var strictnessIndex = 0; strictnessIndex < FilterGenerationConfig.FilterStrictnessLevels.Count; strictnessIndex++)
            {
                if (isGeneratingStylesAndSeed)
                {
                    foreach (var style in FilterGenerationConfig.FilterStyles)
                    {
                        if (style.ToLower() == "default" || style.ToLower() == "backup" || style.ToLower() == "streamsound")
                        {
                            continue;
                        }
                        generationTasks.Add(GenerateFilter_Inner(style, strictnessIndex));
                    }
                }

                // default style
                generationTasks.Add(GenerateFilter_Inner("", strictnessIndex));
            }

            if (isGeneratingStylesAndSeed)
            {
                generationTasks.Add(GenerateFilter_Inner("", 3, 2, explicitName: "NeverSink's filter - 1X-ConStrict"));
                generationTasks.Add(GenerateFilter_Inner("", 4, 2, explicitName: "NeverSink's filter - 2X-ConStrict"));
                generationTasks.Add(GenerateFilter_Inner("", 4, 3, explicitName: "NeverSink's filter - 3X-ConStrict"));
                generationTasks.Add(GenerateFilter_Inner("", 5, 3, explicitName: "NeverSink's filter - 4X-ConStrict"));
                generationTasks.Add(GenerateFilter_Inner("", 6, 3, explicitName: "NeverSink's filter - 5X-ConStrict"));
            }

            await Task.WhenAll(generationTasks);

            LoggingFacade.LogInfo("Filter generation successfully done!", true);

            // local func
            async Task GenerateFilter_Inner(string style, int strictnessIndex, int?consoleStrictness = null, string explicitName = null)
            {
                var filePath = outputFolder;
                var fileName = filterName + " filter - " + strictnessIndex + "-" + FilterGenerationConfig.FilterStrictnessLevels[strictnessIndex].ToUpper();
                var filter   = new Filter(baseFilterString);

                LoggingFacade.LogDebug($"GENERATING: {fileName}");

                new FilterTableOfContentsCreator(filter).Run();
                filter.ExecuteStrictnessCommands(strictnessIndex, consoleStrictness);

                if (style != "")
                {
                    new StyleGenerator(filter, styleSheetFolderPath + style + ".fsty", style).Apply();
                    filePath += "(STYLE) " + style.ToUpper() + "\\";
                    fileName += " (" + style + ") ";
                }

                if (consoleStrictness.HasValue)
                {
                    // little dirty fix
                    filePath += "(Console-Strictness)\\";
                    fileName += " Console-Strictness ";
                }

                if (explicitName != null)
                {
                    fileName = explicitName;
                }

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                var result = filter.Serialize();

                if (result.Count <= seedFilterString?.Count)
                {
                    LoggingFacade.LogError("Error: style/strictness variant is smaller size than seed");
                }

                await FileWork.WriteTextAsync(filePath + "\\" + fileName + ".filter", result);

                LoggingFacade.LogInfo($"DONE GENERATING: {fileName}");
            }
        }
Пример #31
0
        public Dictionary <string, ItemList <FilterEconomy.Model.NinjaItem> > PerformRequest(string league, string variation, string branchKey, string url, string prefix, RequestType requestType, string baseStoragePath, string ninjaUrl)
        {
            var economySegmentBranch = url;
            var directoryPath        = $"{baseStoragePath}/{variation}/{league}/{StringWork.GetDateString()}";
            var fileName             = $"{branchKey}.txt";
            var fileFullPath         = $"{directoryPath}/{fileName}";

            string responseString;

            try
            {
                if (File.Exists(fileFullPath) && requestType != RequestType.ForceOnline)
                {   // Load existing file
                    responseString = FileWork.ReadFromFile(fileFullPath);
                }
                else
                {   // Request online file
                    var urlRequest = $"{ninjaUrl}{economySegmentBranch}{prefix}league={variation}";

                    try
                    {
                        responseString = new RestRequest(urlRequest).Execute();
                    }
                    catch (Exception e)
                    {
                        InfoPopUpMessageDisplay.ShowInfoMessageBox("Error while connecting to poeNinja: " + e);
                        responseString = null;
                    }

                    // poeNinja down -> use most recent local file
                    if (responseString == null || responseString.Length < 400)
                    {
                        var recentFile = Directory.EnumerateDirectories(directoryPath.Replace(StringWork.GetDateString(), "")).OrderByDescending(Directory.GetCreationTime).FirstOrDefault();

                        if (recentFile != null)
                        {
                            responseString = FileWork.ReadFromFile(recentFile + "/" + fileName);

                            if (responseString != null && responseString.Length >= 400)
                            {
                                if (!didShowNinjaOfflineMessage)
                                {
                                    InfoPopUpMessageDisplay.ShowInfoMessageBox("Could not connect to poeNinja. used recent local file instead: " + recentFile + "/" + fileName);
                                    this.didShowNinjaOfflineMessage = true;
                                }
                            }
                        }
                    }

                    // Store locally
                    FileWork.WriteTextAsync(fileFullPath, responseString).Wait(1000);
                }

                if (responseString == null || responseString.Length < 400)
                {
                    InfoPopUpMessageDisplay.ShowError("poeNinja web request or file content is null/short:\n\n\n" + responseString);
                    responseString = "";
                }
            }
            catch (Exception e)
            {
                throw new Exception("Failed to load economy file: " + branchKey + ": " + e);
            }

            var result = NinjaParser.CreateOverviewDictionary(NinjaParser.ParseNinjaString(responseString).ToList());

            return(result);
        }
Пример #32
0
 public void SaveItemInformation(string filePath, string branchKey)
 {
     FileWork.WriteTextAsync(filePath, this.Serialize(branchKey));
 }
Пример #33
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        int fileLength;
        bool success;
        bool emailSuccess;
        //two different connection strings to use to overwrite the doc if there is one in there already
        string connectionString = "INSERT INTO Docs (WorkOrderID, EmpID, Doc) VALUES (@WorkOrderID, @EmpID, @Doc)";
        string altConnString = "UPDATE Docs SET Doc = @Doc, EmpID = @EmpID WHERE WorkOrderID = @WorkOrderID";

        //test the docs table and see if there is a doc in there and then switch the connection string
        string connection = ConfigurationManager.ConnectionStrings["testDB"].ConnectionString;
        SqlConnection conn = new SqlConnection(connection);
        SqlCommand cmd = new SqlCommand("SELECT DocID from Docs WHERE WorkOrderID = @WorkOrderID;", conn);
        cmd.Parameters.AddWithValue("@WorkOrderID", woID);

        conn.Open();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);

        if (dt.Rows.Count > 0)
        {
            connectionString = altConnString;
        }
        conn.Close();
        dt.Clear();

        //first check to see if there is actually a file selected, then do work
        if (cstFileUp.HasFile)
        {
            string fileExt = System.IO.Path.GetExtension(cstFileUp.FileName);
            if (fileExt == ".pdf")
            {

                //get the file length to initialize the array to
                fileLength = cstFileUp.PostedFile.ContentLength;
                byte[] fileBytes = new byte[fileLength - 1];
                //read the bytes of the file
                fileBytes = cstFileUp.FileBytes;
                //create a new instance to use its methods
                FileWork fw = new FileWork();
                //method returns a boolean to check for successfull addition of the file to the db
                success = fw.UploadFile(connectionString, woID.ToString(), fileBytes);
                if (success)
                {
                    SendMail sm = new SendMail();
                    emailSuccess = sm.Send_CustMail(woID.ToString());
                    if (emailSuccess)
                    {
                        lblUploadStatus.Text = "Your file has been uploaded and the Customer has been notified.";
                        lblUploadStatus.ForeColor = System.Drawing.Color.Green;
                        lblUploadStatus.Visible = true;
                    }
                    else
                    {
                        lblUploadStatus.Text = "The file was uploaded but the system failed to notify the customer. Please notify the customer manually.";
                        lblUploadStatus.ForeColor = System.Drawing.Color.Red;
                        lblUploadStatus.Visible = true;
                    }

                }
                else
                {
                    lblUploadStatus.Text = "There was an error uploading your file. Please try again later";
                    lblUploadStatus.ForeColor = System.Drawing.Color.Red;
                    lblUploadStatus.Visible = true;
                }
            }
            else
            {
                lblUploadStatus.Text = "File is not a PDF. Please only upload PDF documents";
                lblUploadStatus.ForeColor = System.Drawing.Color.Red;
                lblUploadStatus.Visible = true;
            }

        }
        else
        {
            lblUploadStatus.Text = "There was no file specified to upload";
        }
    }
        public Dictionary <string, ItemList <FilterEconomy.Model.NinjaItem> > PerformRequest(string league, string leagueType, string branchKey, string url, string baseStoragePath)
        {
            var economySegmentBranch = url;
            var directoryPath        = $"{baseStoragePath}/{leagueType}/{league}/{StringWork.GetDateString()}";
            var fileName             = $"{branchKey}.txt";
            var fileFullPath         = $"{directoryPath}/{fileName}";

            string responseString;

            try
            {
                if (FilterPolishConfig.ActiveRequestMode != RequestType.ForceOnline && File.Exists(fileFullPath))
                {   // Load existing file
                    LoggingFacade.LogInfo($"Loading Economy: Loading Cached File {fileFullPath}");
                    responseString = FileWork.ReadFromFile(fileFullPath);
                }
                else
                {   // Request online file
                    string variation = this.CreateNinjaLeagueParameter(league, leagueType);

                    var urlRequest = $"{economySegmentBranch}&league={variation}";

                    try
                    {
                        responseString = new RestRequest(urlRequest).Execute();
                    }
                    catch (Exception)
                    {
                        LoggingFacade.LogError($"Loading Economy: Requesting From Ninja {urlRequest}");
                        responseString = null;
                    }

                    // poeNinja down -> use most recent local file
                    if ((responseString == null || responseString.Length < 400) && FilterPolishConfig.ActiveRequestMode == RequestType.Dynamic)
                    {
                        var recentFile = Directory
                                         .EnumerateDirectories(directoryPath.Replace(StringWork.GetDateString(), ""))
                                         .Where(x => File.Exists(x + "/" + fileName))
                                         .OrderByDescending(Directory.GetCreationTime)
                                         .FirstOrDefault();

                        if (recentFile != null && File.Exists(recentFile + "/" + fileName))
                        {
                            responseString = FileWork.ReadFromFile(recentFile + "/" + fileName);

                            if (responseString != null && responseString.Length >= 400)
                            {
                                if (!didShowNinjaOfflineMessage)
                                {
                                    LoggingFacade.LogWarning("Could not connect to poeNinja. used recent local file instead: " + recentFile + "/" + fileName);
                                    this.didShowNinjaOfflineMessage = true;
                                }
                            }
                        }
                        else
                        {
                            throw new Exception("did not find any old ninja files");
                        }
                    }

                    if (!string.IsNullOrEmpty(responseString) && FilterPolishConfig.ActiveRequestMode == RequestType.Dynamic)
                    {
                        // Store locally
                        FileWork.WriteText(fileFullPath, responseString);
                    }
                }

                if (responseString == null || responseString.Length < 400)
                {
                    LoggingFacade.LogError("poeNinja web request or file content is null/short:\n\n\n" + responseString);
                    throw new Exception("poeNinja web request or file content is null/short:\n\n\n" + responseString);
                }
            }
            catch (Exception e)
            {
                LoggingFacade.LogError("Failed to load economy file: " + branchKey + ": " + e);
                return(null);
            }

            var result = NinjaParser.CreateOverviewDictionary(NinjaParser.ParseNinjaString(responseString, branchKey).ToList());

            return(result);
        }