Esempio n. 1
0
        public static void printBankAll(uint _code)
        {
            try {
                List <BankSheetOneEntry> tempCol = ExcelFileHandler.BankSheet_getDetail(_code, "", false);
                SerialP.sendDirect(1, "Payment Report All");
                SerialP.sendDirect(1, "CODE : " + _code.ToString() + " | " + ProcessData.GetName(_code));
                SerialP.sendDirect(1, "Date  Time  Bal.  Credit  Ded.");
                SerialP.sendDirect(1, "------------------------------");
                if (tempCol.Count > 0)
                {
                    foreach (BankSheetOneEntry b in tempCol)
                    {
                        SerialP.sendDirect(1, b.date + " " + b.time + " " + b.balance + " " + b.credit + " " + b.deduct);
                    }
                }
                else
                {
                    SerialP.sendDirect(1, "No Entry Found");
                }

                SerialP.sendDirect(1, "------------------------------");
                SerialP.sendDirect(1, "Your Company");
                SerialP.sendDirect(1, "");
                SerialP.sendDirect(1, "");
            }
            catch (Exception ex) { }
        }
        /// <summary>
        ///     Creates the instance of the ExcelFileProvider, which reads and persists all translations as Excel-files.
        ///     A backup Excel-file will be created for all edits.
        /// </summary>
        /// <param name="translationFilePath">Path to the file containing the translations.</param>
        /// <param name="glossaryTag">
        ///     (Optional) Entries in the Excel table that start with this tag will be interpreted as part of the glossary.
        /// </param>
        /// <param name="oldTranslationFilePath">
        ///     (Optional) The path to where the original translation file will be copied as a backup.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown, if <paramref name="translationFilePath" /> is null.
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     Thrown, if the permissions are missing that are needed to create the directory for
        ///     <paramref name="translationFilePath" /> / <paramref name="oldTranslationFilePath" /> or one of them
        ///     is write-only, read-only, a directory, hidden, the needed permissions for opening or writing are
        ///     missing or the operation is not supported on the current platform.
        /// </exception>
        /// <exception cref="System.Security.SecurityException">
        ///     Thrown, if certain permissions are missing. (CLR level)
        /// </exception>
        /// <exception cref="FileNotFoundException">
        ///     Thrown, if <paramref name="translationFilePath" /> / <paramref name="oldTranslationFilePath" />
        ///     does not exist or cannot be found.
        /// </exception>
        /// <exception cref="IOException">
        ///     Thrown, if an unknown I/O-Error occurs.
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///     Thrown, if <paramref name="translationFilePath" /> / <paramref name="oldTranslationFilePath" />
        ///     contains a colon anywhere other than as part of a volume identifier ("C:\").
        /// </exception>
        /// <exception cref="PathTooLongException">
        ///     Thrown, if <paramref name="translationFilePath" /> / <paramref name="oldTranslationFilePath" />
        ///     is too long.
        /// </exception>
        /// <exception cref="DirectoryNotFoundException">
        ///     Thrown, if the directory was not found.
        ///     For example because it is on an unmapped device.
        /// </exception>
        public ExcelFileProvider(string translationFilePath, string glossaryTag = null,
                                 string oldTranslationFilePath = null)
        {
            //set Status.
            Status = ProviderStatus.InitializationInProgress;

            //easy initializations.
            _logger = GlobalSettings.LibraryLoggerFactory.CreateLogger <ExcelFileProvider>();
            _logger.Log(LogLevel.Trace, "Initializing ExcelFileProvider.");
            _fileHandler = new ExcelFileHandler(typeof(ExcelFileProvider),
                                                //make sure all possible not-null values for glossaryTag can be recognized in sheet.
                                                glossaryTag == string.Empty ? null : glossaryTag);

            //null check.
            ExceptionLoggingUtils.ThrowIfNull(_logger, (object)translationFilePath, nameof(translationFilePath),
                                              "Unable to open null path.", "ExcelFileProvider received null parameter in constructor.");

            //start difficult initializations.
            if (oldTranslationFilePath != null)
            {
                _fileHandler.VerifyPath(oldTranslationFilePath);
                _backupPath = oldTranslationFilePath;
            }

            _fileHandler.VerifyPath(translationFilePath);
            _path             = translationFilePath;
            _fileHandler.Path = _path;

            Initialize();
        }
Esempio n. 3
0
        public static void Main()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            PokedexDataContract pokedex = DataContractGenerator <PokedexDataContract> .getInstance(1);

            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}:{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

            Debug.WriteLine("RunTime: " + elapsedTime);

            int dateCompare = DateTime.Compare((DateTime)pokedex.Modified, new DateTime(2013, 11, 10, 0, 0, 0, 0));

            Assert.IsTrue(dateCompare < 0);
            dateCompare = DateTime.Compare((DateTime)pokedex.Created, new DateTime(2013, 11, 10, 0, 0, 0, 0));
            Assert.IsTrue(dateCompare < 0);
            Assert.IsTrue(pokedex.Name == "national");
            Assert.IsTrue(pokedex.PokedexResourceUri == "/api/v1/pokedex/1/");
            Assert.IsTrue(pokedex.PokemonResourceUriList.Count == 778);

            ExcelFileHandler excelFileHandler = new ExcelFileHandler("PokedexUnitTest.xlsx");

            try {
                excelFileHandler.SetCellValue(1, 1, "Created");
                excelFileHandler.SetCellValue(1, 2, "Modified");
                excelFileHandler.SetCellValue(1, 3, "Name");
                excelFileHandler.SetCellValue(1, 4, "Pokedex Resource Uri");
                excelFileHandler.SetCellValue(1, 5, "Pokemon Count");
                excelFileHandler.SetCellValue(1, 6, "Test Results");
                excelFileHandler.SetCellValue(1, 7, "Time Elapsed");

                excelFileHandler.SetCellValue(2, 1, ((DateTime)pokedex.Created).ToString("yyyy-MM-dd"));
                excelFileHandler.SetCellValue(2, 2, ((DateTime)pokedex.Modified).ToString("yyyy-MM-dd"));
                excelFileHandler.SetCellValue(2, 3, pokedex.Name);
                excelFileHandler.SetCellValue(2, 4, pokedex.PokedexResourceUri);
                excelFileHandler.SetCellValue(2, 5, pokedex.PokemonResourceUriList.Count.ToString());
                excelFileHandler.SetCellValue(2, 6, "OK");
                excelFileHandler.SetCellValue(2, 7, elapsedTime);

                excelFileHandler.SaveAs();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Unable to create Excel Application for the following reason: " + e.StackTrace);
            }
            finally
            {
                excelFileHandler.Close();
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> UploadForm()
        {
            String folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                            + "\\websync";
            String fileName = "Excel_" + DateTime.Now.ToLongDateString() + ".xlsx";


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


            String fullPath = folder + "\\" + fileName;

            FormValueProvider formModel;

            using (var stream = System.IO.File.Create(fullPath))
            {
                formModel = await Request.StreamFile(stream);
            }

            var viewModel = new MyViewModel();

            var bindingSuccessful = await TryUpdateModelAsync(viewModel, prefix : "",
                                                              valueProvider : formModel);

            if (!bindingSuccessful)
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
            }
            IList <Lead> leads = ExcelFileHandler.LoadExcelData(fullPath, _context.LeadSources.ToList());

            if (leads == null)
            {
                return(BadRequest("Marked with * are must, " +
                                  "please update the missed fields and upload again"));
            }
            else
            {
                _context.Leads.AddRange(leads.ToArray());
                await _context.SaveChangesAsync();

                return(View(nameof(Index), leads));
            }
        }
Esempio n. 5
0
        public void generateReport(List <PokemonDataContract> pokemonList, string elapsedTime)
        {
            ExcelFileHandler excelFileHandler = null;

            try
            {
                excelFileHandler = new ExcelFileHandler("PokemonUnitTestResults.xlsx");

                excelFileHandler.SetCellValue(1, 1, "PokedexId");
                excelFileHandler.SetCellValue(1, 2, "Name");
                excelFileHandler.SetCellValue(1, 3, "Hp");
                excelFileHandler.SetCellValue(1, 4, "Attack");
                excelFileHandler.SetCellValue(1, 5, "SpAtk");
                excelFileHandler.SetCellValue(1, 6, "Defense");
                excelFileHandler.SetCellValue(1, 7, "SpDef");
                excelFileHandler.SetCellValue(1, 8, "Speed");
                excelFileHandler.SetCellValue(1, 9, "EvYield");
                excelFileHandler.SetCellValue(1, 6, "Test Results");
                excelFileHandler.SetCellValue(1, 7, "Time Elapsed");

                int baseRowCount = 2;
                foreach (PokemonDataContract pokemon in pokemonList)
                {
                    excelFileHandler.SetCellValue(baseRowCount, 1, pokemon.PkdxId.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 2, pokemon.Name.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 3, pokemon.Hp.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 4, pokemon.Attack.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 5, pokemon.SpAtk.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 6, pokemon.Defense.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 7, pokemon.SpDef.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 8, pokemon.Speed.ToString());
                    excelFileHandler.SetCellValue(baseRowCount, 9, pokemon.EvYield);
                    baseRowCount++;
                }

                excelFileHandler.SaveAs();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Unable to create the Excel File for the following reason: " + e.StackTrace);
            }
            finally
            {
                if (excelFileHandler != null)
                {
                    excelFileHandler.Close();
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var excelFileHandler = new ExcelFileHandler();

            excelFileHandler.createExcelPackage();
            excelFileHandler.SaveFile();

            foreach (AccountDataRow adr in excelFileHandler.ReadExcel())
            {
                Console.WriteLine(adr.ID);
                Console.WriteLine(adr.accountName);
            }
        }
Esempio n. 7
0
        public static void printCollection_ID(string _id, string _date, string _month, string _year, string _shift, bool isDuplicate)
        {
            List <ExcelDetailOneMember> printOneMember = new List <ExcelDetailOneMember>();


            try
            {
                printOneMember = ExcelFileHandler.GetDetail_ID(_id, _date, _month, _year, _shift);

                if (printOneMember != null && printOneMember.Count >= 1)
                {
                    //Print
                }
                if (isDuplicate)
                {
                    SerialP.sendDirect(1, "Duplicate Slip");
                }
                else
                {
                    SerialP.sendDirect(1, "Collection Detail");
                }
                SerialP.sendDirect(1, ("CODE: " + _id.ToString() + "   DT:" + _date + "/" + _month + "/" + _year + "(" + _shift + ")"));
                SerialP.sendDirect(1, "-----------------------------");
                foreach (ExcelDetailOneMember rc in printOneMember)
                {
                    SerialP.sendDirect(1, "Name: " + rc.Name);
                    SerialP.sendDirect(1, "Milk Weight: " + rc.MilkWeight);
                    SerialP.sendDirect(1, "Amount: " + rc.Rate);
                    SerialP.sendDirect(1, "FAT: " + rc.Fat);
                    SerialP.sendDirect(1, "SNF: " + rc.Snf);
                    SerialP.sendDirect(1, "Entry: " + rc.AutoMan);
                }
                SerialP.sendData(1, "");


                SerialP.sendDirect(1, "-----------------------------");
                SerialP.sendDirect(1, "**Your Company**");
                SerialP.sendDirect(1, "  ");
                SerialP.sendDirect(1, "  ");
                SerialP.sendDirect(1, "  ");
            }
            catch (Exception ex) { }
        }
        public void generateReport(List <TypeDataContract> typeList, string elapsedTime)
        {
            ExcelFileHandler excelFileHandler = null;

            try
            {
                excelFileHandler = new ExcelFileHandler("TypeUnitTestResults.xlsx");

                excelFileHandler.SetCellValue(1, 1, "Id");
                excelFileHandler.SetCellValue(1, 2, "Name");
                excelFileHandler.SetCellValue(1, 3, "Created");
                excelFileHandler.SetCellValue(1, 4, "Modified");
                excelFileHandler.SetCellValue(1, 5, "Time Elapsed");

                int row = 2;
                foreach (TypeDataContract type in typeList)
                {
                    excelFileHandler.SetCellValue(row, 1, type.Id.ToString());
                    excelFileHandler.SetCellValue(row, 2, type.Name);
                    excelFileHandler.SetCellValue(row, 3, ((DateTime)type.Created).ToString("yyyy-MM-dd"));
                    excelFileHandler.SetCellValue(row, 4, ((DateTime)type.Modified).ToString("yyyy-MM-dd"));
                    excelFileHandler.SetCellValue(row, 5, elapsedTime);
                    row++;
                }

                excelFileHandler.SaveAs();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Unable to create the Excel File for the following reason: " + e.StackTrace);
            }
            finally
            {
                if (excelFileHandler != null)
                {
                    excelFileHandler.Close();
                }
            }
        }
Esempio n. 9
0
        public void generateReport(PokedexDataContract pokedex, string elapsedTime)
        {
            ExcelFileHandler excelFileHandler = null;

            try
            {
                excelFileHandler = new ExcelFileHandler("PokedexUnitTestResults.xlsx");

                excelFileHandler.SetCellValue(1, 1, "Created");
                excelFileHandler.SetCellValue(1, 2, "Modified");
                excelFileHandler.SetCellValue(1, 3, "Name");
                excelFileHandler.SetCellValue(1, 4, "Pokedex Resource Uri");
                excelFileHandler.SetCellValue(1, 5, "Pokemon Count");
                excelFileHandler.SetCellValue(1, 6, "Test Results");
                excelFileHandler.SetCellValue(1, 7, "Time Elapsed");

                excelFileHandler.SetCellValue(2, 1, ((DateTime)pokedex.Created).ToString("yyyy-MM-dd"));
                excelFileHandler.SetCellValue(2, 2, ((DateTime)pokedex.Modified).ToString("yyyy-MM-dd"));
                excelFileHandler.SetCellValue(2, 3, pokedex.Name);
                excelFileHandler.SetCellValue(2, 4, pokedex.PokedexResourceUri);
                excelFileHandler.SetCellValue(2, 5, pokedex.PokemonResourceUriList.Count.ToString());
                excelFileHandler.SetCellValue(2, 6, "OK");
                excelFileHandler.SetCellValue(2, 7, elapsedTime);

                excelFileHandler.SaveAs();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Unable to create the Excel File for the following reason: " + e.StackTrace);
            }
            finally
            {
                if (excelFileHandler != null)
                {
                    excelFileHandler.Close();
                }
            }
        }
Esempio n. 10
0
        public static void printSaleSheet(uint _Date, uint _Month, uint _Year, bool _isLocal)
        {
            try
            {
                List <SaleSheetOneEntry> AllEntry = ExcelFileHandler.Sale_SearchAll(int.Parse(_Date.ToString()), int.Parse(_Month.ToString()), int.Parse(_Year.ToString()), _isLocal);

                string local = "";

                if (_isLocal)
                {
                    local = "Local";
                }
                else
                {
                    local = "TRUCK";
                }

                SerialP.sendDirect(1, local + " SALE REPORT");
                SerialP.sendDirect(1, ("DT:" + _Date.ToString() + "/" + _Month.ToString() + "/" + _Year.ToString()));
                if (!_isLocal)
                {
                    SerialP.sendDirect(1, "Sr. Time  Ltr  Amount CAT  Tr.");
                }
                else
                {
                    SerialP.sendDirect(1, "Sr. Time  Ltr     Amount   CAT  ");
                }
                SerialP.sendDirect(1, "------------------------------");

                if (AllEntry.Count > 0)
                {
                    if (!_isLocal)
                    {
                        foreach (SaleSheetOneEntry SH in AllEntry)
                        {
                            SerialP.sendDirect(1, (SH.Serial + " " + SH.time + "  " + SH.quantity + "  " + SH.amount + " " + SH.cat + " " + SH.truckNo));
                        }
                    }
                    else
                    {
                        foreach (SaleSheetOneEntry SH in AllEntry)
                        {
                            SerialP.sendDirect(1, (SH.Serial + "  " + SH.time + "  " + SH.quantity + "  " + SH.amount + "  " + SH.cat));
                        }
                    }
                }
                else
                {
                    SerialP.sendDirect(1, "Empty List");
                }
                SerialP.sendDirect(1, "------------------------------");
                SerialP.sendDirect(1, "**Your Company**");
                SerialP.sendDirect(1, "  ");
                SerialP.sendDirect(1, "  ");
                SerialP.sendDirect(1, "  ");
            }
            catch (Exception ex) {
                SerialP.sendDirect(1, "Try Again : Error Occured");
                SerialP.sendDirect(1, "");
                SerialP.sendDirect(1, "");
            }
        }
        public Boolean Can_EnterInspectionRequestInput()
        {
            Browser.Instance.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(90);
            //Thread.Sleep(5000);
            //WebDriverWait waitForElement = new WebDriverWait(Browser.Instance, TimeSpan.FromMinutes(5));
            //waitForElement.Until(ExpectedConditions.ElementToBeSelected(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div.ui.fluid.selection.dropdown")));
            //Thread.Sleep(1000);
            //SelectElement selElement = new SelectElement(Browser.Instance.FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div.ui.fluid.selection.dropdown")).FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div.ui.fluid.selection.dropdown > select")));
            //selElement.SelectByValue("5915");
            IWebElement propertyDropDown = Browser.Instance.FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div.ui.fluid.selection.dropdown"));

            Thread.Sleep(1000);
            propertyDropDown.Click();
            //Actions actions = new Actions(Browser.Instance);
            //actions.MoveToElement(propertyDropDown);
            //actions.Click();
            //actions.Build().Perform();
            IWebElement propertySelectItem = Browser.Instance.FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div.ui.fluid.selection.dropdown.active.visible > div.menu.transition.visible > div:nth-child(3)"));

            Thread.Sleep(1000);
            propertySelectItem.Click();
            //IWebElement selProperty= Browser.Instance.FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div.ui.fluid.selection.dropdown"));
            SelectElement selectTenant = new SelectElement(Browser.Instance.FindElement(By.Id("tenant-select")));

            //IWebElement selectTenant = Browser.Instance.FindElement(By.Id("tenant-select"));
            // IWebElement selectTenant = Browser.Instance.FindElement(By.Id("tenant-select"));
            //("//*[@id='main - content']/div/form/fieldset/div[1]/div[2]/div[1]/div[2]/div"));
            //  #main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div:nth-child(5) > input[type="text"]
            IWebElement dueDateInput     = Browser.Instance.FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(1) > div:nth-child(5) > input[type='text']"));
            IWebElement descriptionInput = Browser.Instance.FindElement(By.CssSelector("#main-content > div > form > fieldset > div:nth-child(1) > div.two.fields > div:nth-child(2) > div > textarea"));


            ExcelFileHandler excelData = new ExcelFileHandler();

            excelData.GetInspectionRequestInput();
            String   selectProperty = excelData.selectProperty;
            String   selTenant      = excelData.selectTenant;
            DateTime dueDate        = excelData.dueDate;
            String   description    = excelData.description;

            excelData.closeAllObject();

            bool propertyFound = false;
            //foreach (IWebElement propertyElement in selElement.Options)
            {
                //if (propertyElement.Text.Contains(selectProperty))
                {
                    //selElement.SelectByIndex(4);
                    propertyFound = true;
                    //propertyElement.Click();
                    //break;
                }
            }

            //selProperty.SendKeys(selectProperty);
            //selectTenant.SendKeys(selTenant);
            bool tenantFound = true;

            if (propertyFound == true)
            {
                foreach (IWebElement tenantElement in selectTenant.Options)
                {
                    if (tenantElement.Text.Contains(selTenant))
                    {
                        tenantFound = true;
                        tenantElement.Click();
                        break;
                    }
                }
            }

            if (tenantFound == true)
            {
                dueDateInput.SendKeys(dueDate.ToString());
                descriptionInput.SendKeys(description);
                return(true);
            }
            else
            {
                return(false);
            }
        }