Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve unread messages
        /// </summary>
        public void UpdateMessages()
        {
            if (SelectedUser == null)
            {
                return;
            }

            BL.DataContext msgdatacontext = new BL.DataContext();
            ////THIS IS WRONG BUT CANT GET GRID TO PULL DATA
            messageList.Clear();
            Parallel.ForEach(msgdatacontext.EntitySystemContext.SYS_MSG_Message.Where(n => (n.FromId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && n.ToId == SelectedUser.Id) || (n.ToId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && n.FromId == SelectedUser.Id)), message =>
            {
                if (message.ToId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && message.ReceivedOn == null)
                {
                    message.Received   = true;
                    message.ReceivedOn = BL.ApplicationDataContext.Instance.ServerDateTime;
                }
                messageList.Add(message);
            });

            //messageList = msgdatacontext.EntitySystemContext.SYS_MSG_Message.Where(n => (n.FromId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && n.ToId == SelectedUser.Id) || (n.ToId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && n.FromId == SelectedUser.Id)).ToList();
            //messageList.Where(n => n.ToId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && n.ReceivedOn == null).ToList().ForEach(n => n.Received = true);
            //messageList.Where(n => n.ToId == BL.ApplicationDataContext.Instance.LoggedInUser.PersonId && n.ReceivedOn == null).ToList().ForEach(n => n.ReceivedOn = BL.ApplicationDataContext.Instance.ServerDateTime);

            try
            {
                using (TransactionScope transaction = DataContext.GetTransactionScope())
                {
                    msgdatacontext.SaveChangesEntitySystemContext();
                    DataContext.CompleteTransaction(transaction);
                }
                msgdatacontext.EntitySystemContext.AcceptAllChanges();
            }
            catch (Exception ex)
            {
                msgdatacontext.EntitySystemContext.RejectChanges();
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
            this.Invoke(new Action(() => UpdateMessagesGrid()));
            //grdMessage.Invoke(new Action(() => grdMessage.DataSource = messageList));
        }
Ejemplo n.º 2
0
 public CDSService()
 {
     BL.ApplicationDataContext.Instance.SetConnections(ConfigurationManager.ConnectionStrings["BaseConnection"].ConnectionString, true);
     BL.ApplicationDataContext.Instance.SqlCommandTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"]);
     DataContext = new BL.DataContext();
 }
Ejemplo n.º 3
0
        public static void EmailtoPDF(Essential.BaseForm.ReportTemplateType reportTemplate, long id, string filename, BL.DataContext dataContext)
        {
            string reportName = null;

            //rptReport = BL.RPT.RPT_Report.LoadByName("Sales Document Template", DataContext);
            //
            //rptReport = BL.RPT.RPT_Report.LoadByName("Picking Slip Document Template", DataContext);
            //
            //rptReport = BL.RPT.RPT_Report.LoadByName("Purchase Document Template", DataContext);
            //
            //rptReport = BL.RPT.RPT_Report.LoadByName("Transfer Document Template", DataContext);
            //
            //rptReport = BL.RPT.RPT_Report.LoadByName("Stock Document Template", DataContext);
            //
            //rptReport = BL.RPT.RPT_Report.LoadByName("Work Document Template", DataContext);
            //
            //rptReport = BL.RPT.RPT_Report.LoadByName("Work Document Template", DataContext);

            switch (reportTemplate)
            {
            case Essential.BaseForm.ReportTemplateType.None:
                reportName = "";
                break;

            case Essential.BaseForm.ReportTemplateType.SalesDocument:
                reportName = "Sales Document Template";
                break;

            case Essential.BaseForm.ReportTemplateType.PurchaseDocument:
                reportName = "Purchase Document Template";
                break;

            case Essential.BaseForm.ReportTemplateType.PickerDocument:
                reportName = "Picking Slip Document Template";
                break;

            case Essential.BaseForm.ReportTemplateType.StockDocument:
                reportName = "Stock Document Template";
                break;

            case Essential.BaseForm.ReportTemplateType.WorkDocument:
                reportName = "Work Document Template";
                break;

            case Essential.BaseForm.ReportTemplateType.TransferDocument:
                reportName = "Transfer Document Template";
                break;
            }

            DB.RPT_Report rptReport = BL.RPT.RPT_Report.LoadByName(reportName, dataContext);

            if (rptReport == null)
            {
                return;
            }

            System.IO.Stream xmlstream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(rptReport.Data));

            DevExpress.XtraReports.UI.XtraReport report = new DevExpress.XtraReports.UI.XtraReport();
            report.LoadLayoutFromXml(xmlstream);

            if (report.DataSource is DevExpress.DataAccess.Sql.SqlDataSource)
            {
                ((DevExpress.DataAccess.Sql.SqlDataSource)(report.DataSource)).Connection.ConnectionString = BL.ApplicationDataContext.Instance.SqlConnectionString.ConnectionString;
            }
            else if (report.DataSource is DevExpress.DataAccess.EntityFramework.EFDataSource)
            {
                ((DevExpress.DataAccess.EntityFramework.EFDataSource)(report.DataSource)).Connection.ConnectionString = BL.ApplicationDataContext.Instance.EntityViewConnectionString.ConnectionString;
            }
            else
            {
                throw new Exception("Data Source type not implemented in reports");
            }

            //adp.SelectCommand.Connection.ConnectionString = BL.ApplicationDataContext.Instance.SqlConnectionString.ConnectionString;
            DevExpress.XtraReports.Parameters.ParameterCollection Parameters = new DevExpress.XtraReports.Parameters.ParameterCollection();
            Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter()
            {
                Name = "DocumentId", Value = id
            });
            if (Parameters.Count != 0)
            {
                foreach (var extparam in Parameters)
                {
                    foreach (var param in report.Parameters)
                    {
                        if (extparam.Name == param.Name)
                        {
                            param.Value = extparam.Value;
                            break;
                        }
                    }
                }
            }

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            report.ExportToPdf(ms);
            CDS.Client.Desktop.Essential.UTL.SendMailForm mail = new CDS.Client.Desktop.Essential.UTL.SendMailForm();
            mail.AttachFile(ms, filename);
            mail.ShowDialog();
        }
Ejemplo n.º 4
0
 public ReportExtension()
 {
     DataContext = new BL.DataContext();
 }