Esempio n. 1
0
        public ActionResult Index(string CompanyCode)
        {
            ViewBag.Company = CompanyCode;

            List <SqlParameter> lstParam3 = new List <SqlParameter>();

            lstParam3.Add(new SqlParameter("Company", CompanyCode));

            DataTable dtSubDetail = GNF.ExceuteStoredProcedure("SP_Validate_Roy_FireOffStart", lstParam3);

            lstParam3 = new List <SqlParameter>();
            lstParam3.Add(new SqlParameter("Company", CompanyCode));
            DataTable dtSubDetail2 = GNF.ExceuteStoredProcedure("SP_Validate_Roy_Result_Error", lstParam3);
            DataTable dtSubDetail3 = GNF.ExceuteStoredProcedure("[SP_Validate_Roy_Data]");

            //ViewBag.subDetail = dtSubDetail;// ConvertDataTableToHTML(dtSubDetail);
            using (XLWorkbook wb = new XLWorkbook())
            {
                dtSubDetail3.TableName = "Data1";
                wb.Worksheets.Add(dtSubDetail3);
                //wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                //wb.Style.Font.Bold = true;
                //wb.find.Style.Fill.BackgroundColor=XLColor.LightGreen;
                using (MemoryStream stream = new MemoryStream())
                {
                    wb.SaveAs(stream);
                    return(File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Report.xlsx"));
                }
            }
            return(View(dtSubDetail3));
        }
Esempio n. 2
0
        public APIResponse ForgotPassword(ForgotPassword forgetPassword)
        {
            APIResponse objResponse = new APIResponse();

            if (forgetPassword != null)
            {
                var objuser = db.Users.FirstOrDefault(x => x.Email == forgetPassword.Email);
                if (objuser != null)
                {
                    objuser.Password = GNF.RandomPassword(4);
                    db.Users.Attach(objuser);
                    db.Entry(objuser).State = EntityState.Modified;
                    db.SaveChanges();

                    NotificationHelper.SendForgetPasswordEmail(objuser.Email, objuser.Password);

                    objResponse.Message = "Please check your email inbox for new login code. Thank you";
                    objResponse.Status  = "1";
                }
            }
            else
            {
                objResponse.Message = "This email is not registered with us";
                objResponse.Status  = "0";
            }
            return(objResponse);
        }
Esempio n. 3
0
 public JsonResult GetCompany()
 {
     try
     {
         DataTable dt = GNF.ExceuteStoredProcedure("SP_SelectCompany");
         return(Json(GNF.ConvertDataTabletoString(dt), JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(ex.ToString(), JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 4
0
        private void AddAsset(string path, string entryString)
        {
            if (listViewAssets.FindItemWithText(entryString) != null || !GNF.IsFileValid(path))
            {
                return;
            }

            var item = new ListViewItem
            {
                Text = entryString
            };

            item.SubItems.Add(path);
            listViewAssets.Items.Add(item);
        }
        /// <summary>
        /// Converts items from <see cref="ListView"/> to a list of <see cref="GNF"/>.
        /// </summary>
        /// <param name="listView">ListView to be converted.</param>
        /// <returns>List generated from ListView.</returns>
        public static List <GNF> ConvertItemsToGNFList(this ListView listView)
        {
            ListView.ListViewItemCollection itemCollection = listView.Items;
            var gnfList = new List <GNF>();

            foreach (ListViewItem item in itemCollection)
            {
                var gnfFile = new GNF
                {
                    EntryStr = item.Text,
                    RealPath = item.SubItems[1].Text
                };

                if (File.Exists(gnfFile.RealPath))
                {
                    gnfList.Add(gnfFile);
                }
            }

            return(gnfList);
        }
Esempio n. 6
0
        public ActionResult Export(string CompanyCode)
        {
            List <SqlParameter> lstParam3 = new List <SqlParameter>();

            lstParam3.Add(new SqlParameter("Company", CompanyCode));

            DataTable dtSubDetail = GNF.ExceuteStoredProcedure("SP_Validate_Roy_Data");

            //ViewBag.subDetail = dtSubDetail;// ConvertDataTableToHTML(dtSubDetail);
            using (XLWorkbook wb = new XLWorkbook())
            {
                dtSubDetail.TableName = "Data1";
                wb.Worksheets.Add(dtSubDetail);
                using (MemoryStream stream = new MemoryStream())
                {
                    wb.SaveAs(stream);
                    return(File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Grid.xlsx"));
                }
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            // If there are no arguments passed then it acts as if help command is ran
            if (args.Count() == 0)
            {
                Program.ShowHelpText();
                return;
            }

            switch (args[0].ToLower())
            {
            default:
            {
                if (args.Count() == 1 && Directory.Exists(args[0]))
                {
                    // If a single existing folder is inputted, the tool will autopack that
                    // The following codes sets up that process

                    string inputDir = args[0];
                    args    = new string[5];
                    args[0] = string.Empty;         // Can equal blank string value

                    args[1] = "-i";
                    args[2] = inputDir;

                    args[3] = "-o";
                    args[4] = Path.GetDirectoryName(inputDir) + "\\output.ba2";

                    goto case "-p";
                }

                Program.ShowHelpText(true);
                break;
            }

            case "-h":
            case "-help":
            {
                Program.ShowHelpText();
                break;
            }

            case "-p":
            case "-pack":
            {
                string inputDir        = string.Empty;
                string outputPath      = string.Empty;
                bool   isStrTableSaved = true;

                for (uint i = 1; i < args.Count(); i++)
                {
                    string option = args[i];

                    switch (option)
                    {
                    default:
                    {
                        Program.ShowHelpText(true);
                        return;
                    }

                    case "-nostrtbl":
                    {
                        isStrTableSaved = false;
                        break;
                    }

                    case "-i":
                    case "-indir":
                    {
                        i++;
                        inputDir = args[i];
                        break;
                    }

                    case "-o":
                    case "-out":
                    {
                        i++;
                        outputPath = args[i];
                        break;
                    }
                    }
                }

                if (string.IsNullOrEmpty(inputDir) || string.IsNullOrEmpty(outputPath))
                {
                    Program.ShowHelpText(true);
                    return;
                }

                Console.WriteLine("Reading and verifying files...");
                var gnfList = new List <GNF>();

                foreach (string file in Directory.GetFiles(inputDir, "*", SearchOption.AllDirectories))
                {
                    if (GNF.IsFileValid(file))
                    {
                        var gnfFile = new GNF
                        {
                            EntryStr = file.Substring(inputDir.Length + 1),
                            RealPath = file
                        };

                        gnfList.Add(gnfFile);
                    }
                }

                Console.WriteLine("Packing...");
                GNMF.Write(outputPath, gnfList, isStrTableSaved);

                Console.WriteLine("\nDone!\n");
                break;
            }
            }
        }
Esempio n. 8
0
        public ActionResult MailOut(string Company)
        {
            try
            {
                ViewBag.Message = "";

                string        FilePath = "E:\\IIS_Published_Websites\\RoyaltyErrorDataReports_Publish\\temp\\";
                DirectoryInfo di       = new DirectoryInfo(FilePath);
                if (!di.Exists)
                {
                    di.Create();
                }
                DataTable dtCompanies = GNF.ExceuteStoredProcedure("SP_RoyaltyErrorDataReports_Companies");
                if (dtCompanies != null && dtCompanies.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtCompanies.Rows)
                    {
                        List <SqlParameter> lstParam3 = new List <SqlParameter>();
                        lstParam3.Add(new SqlParameter("Company", dr["Company_Code"]));

                        DataTable dtSubDetail = GNF.ExceuteStoredProcedure("SP_Validate_Roy_FireOffStart", lstParam3);
                        if (dtSubDetail != null && dtSubDetail.Rows.Count > 0)
                        {
                            lstParam3 = new List <SqlParameter>();
                            lstParam3.Add(new SqlParameter("Company", dr["Company_Code"]));
                            DataTable dtSubDetail2 = GNF.ExceuteStoredProcedure("SP_Validate_Roy_Result_Error", lstParam3);

                            DataTable dtSubDetail3 = GNF.ExceuteStoredProcedure("[SP_Validate_Roy_Data]");
                            //ViewBag.subDetail = dtSubDetail;// ConvertDataTableToHTML(dtSubDetail);
                            using (XLWorkbook wb = new XLWorkbook())
                            {
                                dtSubDetail3.TableName = "Data1";
                                wb.Worksheets.Add(dtSubDetail3);
                                //wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                                //wb.Style.Font.Bold = true;
                                //wb.find.Style.Fill.BackgroundColor=XLColor.LightGreen;
                                string FileName = "File-" + DateTime.Now.ToString("MMddyyyyHHmmsstt") + ".xlsx";
                                string path     = FilePath + FileName;
                                wb.SaveAs(path);

                                lstParam3 = new List <SqlParameter>();
                                lstParam3.Add(new SqlParameter("CompanyCode", dr["Company_Code"]));

                                DataTable dtSubDetail4 = GNF.ExceuteStoredProcedure("SP_RoyaltyErrorDataReports_Email", lstParam3);
                                if (dtSubDetail4 != null && dtSubDetail4.Rows.Count > 0)
                                {
                                    foreach (DataRow dr4 in dtSubDetail4.Rows)
                                    {
                                        List <Attachment> lstAttachment = new List <Attachment>();
                                        FileInfo          fi            = new FileInfo(path);
                                        string            newFileName   = (FilePath + (fi.Name.Replace(".xlsx", Guid.NewGuid().ToString() + ".xlsx")));
                                        fi.CopyTo(newFileName);
                                        lstAttachment.Add(new Attachment(newFileName));
                                        string Subject = "Please be advised that the attached file contains errors on item setup. This is for Company '" + dr["Company_Code"].ToString() + "'";
                                        string Body    = "Please fix these errors within (3) business days upon receipt of this email. Please reach out to Eli Maiman with any questions or concerns";
                                        NotificationHelper.SendMail(dr4["Email"].ToString(), Subject, Body, true, lstAttachment);
                                    }
                                }
                            }
                        }
                        else
                        {
                            ViewBag.Message = "No data to sent in subDetail";
                        }
                    }
                    ViewBag.Message = "MailOut completed successfully";
                }
                else
                {
                    ViewBag.Message = "No data to sent";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                NotificationHelper.SendMail("*****@*****.**", "Mailout >> Exception occured", ex.Message + "<br>" + ex.StackTrace, true, null);
                NotificationHelper.SendMail("*****@*****.**", "Mailout >> Exception occured", ex.Message + "<br>" + ex.StackTrace, true, null);
            }

            return(View());
        }