Esempio n. 1
0
        public static List <UserBasic> GetUsersBasic(int?iUserType)
        {
            try
            {
                DataSet ds = SqlDataAccess.ExecuteDatasetSP("TSysUserBasic_SLCT", new SqlParameter("iUserType", iUserType));

                List <UserBasic> lUsers = new List <UserBasic>();
                DataView         dv;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    UserBasic user = new UserBasic();
                    user = ObjectGenerator <UserBasic> .GeneratFromDataRow(dr);

                    dv = new DataView(ds.Tables[1],
                                      "iUserId = " + user.iUserId.ToString(),
                                      "", DataViewRowState.CurrentRows);
                    user.lOrderType = new List <int>();
                    for (int j = 0; j < dv.Count; j++)
                    {
                        user.lOrderType.Add(int.Parse(dv[j]["iTypeId"].ToString()));
                    }
                    lUsers.Add(user);
                }
                return(lUsers);
            }
            catch (Exception ex)
            {
                Log.ExceptionLog(ex.Message, "GetUsersBasic");
                return(null);
            }
        }
Esempio n. 2
0
        public static string GenerateAttendanceReport(string folderName, string url, string identityTranslator)
        {
            try
            {
                NReco.PdfGenerator.HtmlToPdfConverter pdf = new NReco.PdfGenerator.HtmlToPdfConverter();
                pdf.Margins        = new NReco.PdfGenerator.PageMargins();
                pdf.Margins.Top    = 1;
                pdf.Margins.Bottom = 5;
                pdf.Margins.Right  = 1;
                pdf.Margins.Left   = 1;
                pdf.Size           = PageSize.A4;
                pdf.Orientation    = PageOrientation.Portrait;
                //string sFileName = DateTime.Now.ToFileTime().ToString();
                string filePath = System.Configuration.ConfigurationManager.AppSettings["BaseUrlForPDF"] + url;
                //string filePath = url;
                var pdfBytes = pdf.GeneratePdfFromFile(filePath, null);
                //sFileName = "דוח" + sFileName;
                string sFileName = "pdfReport_" + DateTime.Now.ToFileTime().ToString();
                File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\pdfReports\\" + sFileName + ".pdf", pdfBytes);

                List <UserBasic> lusers   = new List <UserBasic>();
                UserBasic        provider = new UserBasic();
                UserBasic        shmaya   = new UserBasic();
                shmaya.nvEmail = "*****@*****.**";
                lusers         = UserBasic.GetUsersBasic(3);
                foreach (UserBasic user in lusers)
                {
                    if (user.nvID == identityTranslator)
                    {
                        provider = user;
                        break;
                    }
                }
                lusers = new List <UserBasic>();
                lusers.Add(provider);
                lusers.Add(shmaya);
                Messages message = new Messages();
                message.nvFrom    = "*****@*****.**";
                message.nvSubject = "מצ\"ב דו\"ח ביצוע הזמנה";
                List <Attachment> lAttach = new List <Attachment>();
                lAttach.Add(new Attachment(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\pdfReports\\" + sFileName + ".pdf"));
                Messages.SendEmailToGroup(lusers, message, 1, lAttach);

                return(filePath);
            }
            catch (Exception ex)
            {
                Log.ExceptionLog(ex.Message, "GenerateAttendanceReport");
                return(null);
            }
        }
Esempio n. 3
0
        public static string GeneratePdfFromHtml(string title, string html, string css, string sFileName, string identityTranslator)
        {
            try
            {
                NReco.PdfGenerator.HtmlToPdfConverter pdf = new NReco.PdfGenerator.HtmlToPdfConverter();
                pdf.Margins        = new NReco.PdfGenerator.PageMargins();
                pdf.Margins.Top    = 10;
                pdf.Margins.Bottom = 10;
                pdf.Margins.Right  = 10;
                pdf.Margins.Left   = 10;
                pdf.Size           = PageSize.A4;
                pdf.Orientation    = PageOrientation.Landscape;

                //pdf.CustomWkHtmlTocArgs = "--toc-disable-back-links";
                //pdf.CustomWkHtmlPageArgs = "--header-html";
                //pdf.Size = PageSize.A4;

                //string hostName = System.ServiceModel.Web.WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.Host + System.Web.Hosting.HostingEnvironment.ApplicationHost.GetVirtualPath();
                //css = css.Replace("../", hostName + "/");
                //pdf.PageFooterHtml = "<div style='text-align:center;'><span class='page' style='border-left:1px solid #ddbfd3 ;padding-left:10px'></span> / <span style='border-right:1px solid #ddbfd3 ;padding-right:10px' class='topage'></span></div>";
                //pdf.PageHeaderHtml = "<div><div style='text-align:center; font-size:20px; color: #06416D ; font-family: Arial'>" + title + "</div></div>";
                html = "<html><head><meta charset='utf-8' /><style type='text/css'>" + css + "</style></head>" +
                       "<body><div style='text-align:right;' dir='rtl'>" + html + "</div></body></html>";
                string fileName = sFileName.Replace("\\", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "") + "_" + DateTime.Now.ToFileTime();
                sFileName += "_" + DateTime.Now.ToFileTime().ToString() + ".pdf";
                byte[] Bytes = Encoding.UTF8.GetBytes(html);

                File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\pdfReports\\pdfGenerator" + fileName + ".html", Bytes);
                Log.ExceptionLog("file path: ", AppDomain.CurrentDomain.BaseDirectory + "Files\\pdfReports\\pdfGenerator" + fileName + ".html");
                var pdfBytes = pdf.GeneratePdfFromFile(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\pdfReports\\pdfGenerator" + fileName + ".html", null);

                File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\pdfReports\\pdfGenerator" + fileName + ".pdf", pdfBytes);

                //File.WriteAllBytes(dir + fileName + ".pdf", pdfBytes);
                List <UserBasic> lusers   = new List <UserBasic>();
                UserBasic        provider = new UserBasic();
                UserBasic        shmaya   = new UserBasic();
                shmaya.nvEmail = "*****@*****.**";
                lusers         = UserBasic.GetUsersBasic(3);
                foreach (UserBasic user in lusers)
                {
                    if (user.nvID == identityTranslator)
                    {
                        provider = user;
                        break;
                    }
                }
                lusers = new List <UserBasic>();
                lusers.Add(provider);
                lusers.Add(shmaya);
                Messages message = new Messages();
                message.nvFrom    = "*****@*****.**";
                message.nvSubject = "מצ\"ב דו\"ח ביצוע הזמנה";
                List <Attachment> lAttach = new List <Attachment>();
                lAttach.Add(new Attachment(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\pdfReports\\pdfGenerator" + fileName + ".pdf"));
                Messages.SendEmailToGroup(lusers, message, 1, lAttach);

                return(fileName + ".pdf");
            }
            catch (Exception ex)
            {
                Log.ExceptionLog(ex.Message, "GeneratePdfFromHtml");
                return(null);
            }
        }
Esempio n. 4
0
        public static int createDocumentToProviders(int iUserId, DateTime?dtBeginDate, DateTime?dtEndDate)
        {
            try
            {
                FileManageCtrl.DeleteAllFile(AppDomain.CurrentDomain.BaseDirectory + "Files\\reports");


                List <UserBasic> lUser = new List <UserBasic>();
                lUser = UserBasic.GetUsersBasic(3);
                foreach (var user in lUser)
                {
                    List <SqlParameter> parameters = new List <SqlParameter>();
                    parameters.Add(new SqlParameter("iUserId", user.iUserId));
                    parameters.Add(new SqlParameter("dtBeginDate", dtBeginDate));
                    parameters.Add(new SqlParameter("dtEndDate", dtEndDate));
                    //data table שולף טבלה
                    DataTable dt = SqlDataAccess.ExecuteDatasetSP("TSumMessage_SLCT", parameters).Tables[0];
                    List <MessageToProvider> lToProvider = new List <MessageToProvider>();
                    lToProvider = ObjectGenerator <MessageToProvider> .GeneratListFromDataRowCollection(dt.Rows);

                    //data table שולף טבלה
                    DataTable     dt2     = SqlDataAccess.ExecuteDatasetSP("TOrdersByStatus_SLCT", new SqlParameter("iUserId", user.iUserId)).Tables[0];
                    List <Orders> lOrders = new List <Orders>();
                    lOrders = ObjectGenerator <Orders> .GeneratListFromDataRowCollection(dt2.Rows);

                    string   sFileName  = "פירוט שעות";
                    string   sFileName2 = "רשימת הזמנות";
                    string   path       = AppDomain.CurrentDomain.BaseDirectory + "Files\\" + "reports\\" + sFileName + "_" + DateTime.Now.ToFileTime().ToString() + ".xlsx";
                    string   path2      = AppDomain.CurrentDomain.BaseDirectory + "Files\\" + "reports\\" + sFileName2 + "_" + DateTime.Now.ToFileTime().ToString() + ".xlsx";
                    string[] str        = { "זמן תרגום", "סהכ לתשלום", "תשלום שעה ראשונה", "תשלום שעה שניה" };
                    string[] str2       = { "שם לקוח", "שם מתורגמן", "סוג הזמנה", "סוג תרגום", "תאריך תרגום", "זמן תרגום" };
                    Messages message    = new Messages();
                    message.nvFrom    = System.Configuration.ConfigurationManager.AppSettings["mailFrom"];
                    message.nvTo      = user.nvEmail;
                    message.nvSubject = "דוח סיכום חודשי";

                    string dtBeginDateString = dtBeginDate != null?dtBeginDate.Value.ToString("dd-MM-yyyy") : "n/a";

                    string dtEndDateString = dtEndDate != null?dtEndDate.Value.ToString("dd-MM-yyyy") : "n/a";

                    if (lToProvider != null && lToProvider.Count != 0 && lOrders != null && lOrders.Count != 0)
                    {
                        message.nvMessage = " שלום. מצ\"ב פירוט השעות שבצעת מתאריך" + " " + dtBeginDateString + " " + "עד תאריך " + dtEndDateString + " " + "ובנוסף רשימת הזמנות שממתינות לאישור תשלום - לטיפולך";
                    }
                    else
                    if (lToProvider != null && lToProvider.Count != 0)
                    {
                        message.nvMessage = " שלום. מצ\"ב פירוט השעות שבצעת מתאריך" + " " + dtBeginDateString + " " + "עד תאריך " + dtEndDateString;
                    }
                    else
                    if (lOrders != null && lOrders.Count != 0)
                    {
                        message.nvMessage = "שלום. מצ\"ב רשימת הזמנות שממתינות לאישור תשלום - לטיפולך";
                    }



                    ExcelHendler.ExportToExcel(dt, "aaa", str, path);
                    ExcelHendler.ExportToExcel(dt2, "aaa", str2, path2);
                    List <Attachment> lAttach = new List <Attachment>();
                    if (lToProvider != null && lToProvider.Count != 0)
                    {
                        lAttach.Add(new Attachment(path));
                    }
                    if (lOrders != null && lOrders.Count != 0)
                    {
                        lAttach.Add(new Attachment(path2));
                    }
                    bool isSuccess = Messages.SendEmailToOne(message, lAttach, false);
                }
                return(1);
            }
            catch (Exception ex)
            {
                Log.ExceptionLog(ex.Message, "createDocumentToProviders");
                return(2);
            }
        }