public MaintenanceProcessor(DataContext context, int buildingId)
 {
     _context        = context;
     _buildingId     = buildingId;
     _building       = context.tblBuildings.Where(a => a.id == buildingId).Single();
     _buildingConfig = context.BuildingMaintenanceConfigurationSet.Where(a => a.BuildingId == _buildingId).ToList();
 }
        private bool UploadFileToBuilding(tblBuilding building, Data.ManagementPackData.ManagementPack dataItem, out string url)
        {
            string fileName    = "ManagementPack_" + dataItem.Period.ToString("yyyy_MMM") + ".pdf";
            string description = "Management Pack " + dataItem.Period;

            url = _ClientPortal.UploadBuildingDocument(DocumentCategoryType.MonthlyFinancial,
                                                       dataItem.Period,
                                                       building.id, description, fileName, dataItem.ReportData, string.Empty);
            return(true);
        }
        private byte[] CreateCSVForBuildingBatch(tblBuilding building, RequisitionBatch batch, out string fileName)
        {
            fileName = string.Empty;
            if (!building.IsUsingNedbank)
            {
                return(null);
            }

            return(CreateNedbankCSV(building, batch, out fileName));
        }
        public ProjectScreenBeforeViewModal(int ID, bool isback = false)
        {
            _isback = isback;
            tblSystemElement _tblSystemElement = new tblSystemElement();

            SystemElementList = _tblSystemElement.GetAll();
            SESelectedValue   = 1;
            tblMaterial _tblMaterial = new tblMaterial();

            MaterialList = _tblMaterial.GetAll();

            if (isback == false)
            {
                _LocationID = ID;
            }
            else
            {
                Building    build   = new Building();
                tblBuilding dbbuild = new tblBuilding();
                build       = dbbuild.Get(ID);
                _LocationID = build.LocationID;

                //build.BuildingSystemID = BSSelectedValue;
                SESelectedValue = 1;
                //build.SystemTypeID = STSelectedValue;
                //build.Rating = RTSelectedValue;
                _detail = build.Details;
                //build.IsDeficiencyRepair = true;
                //build.ProjectID = 0;
                //build.ServiceContractID = 0;
                //build.WorkOrder = "";
                //build.Compliance = "";
                _height          = build.Height;
                _width           = build.Width;
                MATSelectedValue = build.MaterialID;
                //build.UserID = Constant.UserID;
                //build.createon = DateTime.Now;
                //build.AddressLine1 = "";
                //build.AddressLine2 = "";
                //build.LocationCity = "";
                //build.StateID = 0;
                //build.LocationZip = "";
                //build.createon = DateTime.Now;
                //build.isedit = false;
                //build.issupload = false;
            }
        }
Beispiel #5
0
        private void SendNotification(tblBuilding building, IEnumerable <ExpiryItem> items)
        {
            string status;
            var    pm = building.pm;

            if (String.IsNullOrWhiteSpace(pm))
            {
                pm = "*****@*****.**";
            }

            string bodyContent = "Good day" + Environment.NewLine +
                                 "Please note that building " + building.Building + " has the following document(s) set to expire:" + Environment.NewLine;

            foreach (var d in items.OrderBy(a => a.AccountNumber).ThenBy(a => a.Expires))
            {
                bodyContent = bodyContent + "Account: " + d.AccountNumber + " " + d.DocumentType + " expires on " + d.Expires.Value.ToString("yyyy/MM/dd", CultureInfo.InstalledUICulture) + Environment.NewLine;
            }

            if (String.IsNullOrWhiteSpace(bodyContent))
            {
                bodyContent = "";
            }

            bodyContent = bodyContent + Environment.NewLine + Environment.NewLine;

            bodyContent += "Kind Regards" + Environment.NewLine;
            bodyContent += "Tel: 011 867 3183" + Environment.NewLine;
            bodyContent += "Fax: 011 867 3163" + Environment.NewLine;
            bodyContent += "Direct Fax: 086 657 6199" + Environment.NewLine;
            bodyContent += "BEE Level 4 Contributor" + Environment.NewLine;

            bodyContent += "FOR AND ON BEHALF OF ASTRODON(PTY) LTD" + Environment.NewLine;
            bodyContent += "The information contained in this communication is confidential and may be legally privileged.It is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it.If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking action in reliance of the contents of this information is strictly prohibited and may be unlawful.The company is neither liable for proper, complete transmission of the information contained in this communication nor any delay in its receipt." + Environment.NewLine;


            List <string> toAddress = new List <string>();

            toAddress.Add(pm);


            if (!Mailer.SendMailWithAttachments("*****@*****.**", toAddress.Distinct().ToArray(),
                                                "Customer document expiry notification " + building.Building, bodyContent,
                                                false, false, false, out status, new Dictionary <string, byte[]>(), "*****@*****.**"))
            {
                Console.WriteLine("Error seding email " + status, "Email error");
            }
        }
        public async Task SaveDetail()
        {
            Building      build   = new Building();
            tblBuilding   dbbuild = new tblBuilding();
            tblCompliance com     = new tblCompliance();

            build.LocationID       = _locid;
            build.BuildingCode     = "";
            build.BuildingSystemID = BSSelectedValue;
            build.SystemElementID  = 0;
            build.SystemTypeID     = 0;
            build.Rating           = 0;
            build.Details          = _detail;
            //build.IsDeficiencyRepair = true;
            build.ProjectID          = PLSelectedValue;
            build.ServiceContractID  = SCSelectedValue;
            build.WorkOrder          = "";
            build.Compliance         = com.Get(CMSelectedValue);
            build.Height             = 0;
            build.Width              = 0;
            build.MaterialID         = 0;
            build.UserID             = Constant.UserID;
            build.createon           = DateTime.Now;
            build.AddressLine1       = "";
            build.AddressLine2       = "";
            build.LocationCity       = "";
            build.StateID            = 0;
            build.LocationZip        = "";
            build.createon           = DateTime.Now;
            build.isedit             = false;
            build.issupload          = false;
            build.IsDeficiencyRepair = false;
            bool ans = await App.Current.MainPage.DisplayAlert("Work Order", "Request for Work Order", "Yes", "No");

            if (ans == true)
            {
                build.WorkOrder = "1";
            }
            else
            {
                build.WorkOrder = "";
            }

            int bid = dbbuild.Add(build);

            App.Current.MainPage = new MainPageCS(new CameraPage(bid, "Facility"));
        }
        private static byte[] CreateNedbankCSV(tblBuilding building, RequisitionBatch batch, out string fileName)
        {
            fileName = null;


            string fromAccountNumber           = building.bankAccNumber;
            string fromAccountDescription      = building.accName;
            string fromAccountSubAccountNumber = string.Empty;

            using (var context = SqlDataHandler.GetDataContext())
            {
                var q = from r in context.tblRequisitions
                        where r.RequisitionBatchId == batch.id &&
                        r.UseNedbankCSV == true
                        select new NedbankCSVRecord
                {
                    FromAccountNumber               = fromAccountNumber,
                    FromAccountDescription          = fromAccountDescription,
                    MyStatementDescription          = r.payreference,
                    BeneficiaryReferenceNumber      = r.NedbankCSVBenificiaryReferenceNumber,
                    BeneficiaryStatementDescription = r.payreference,
                    Amount = r.amount
                };
                var transactions = q.ToList();

                //var csvFile = new NedbankCSVFile(transactions);

                using (MemoryStream fs = new MemoryStream())
                {
                    using (StreamWriter tw = new StreamWriter(fs))
                    {
                        foreach (var t in transactions)
                        {
                            tw.WriteLine(t.ToString());
                        }
                    }

                    byte[] result = new byte[fs.Length];
                    fs.Flush();
                    fs.Read(result, 0, result.Length);
                    fileName = "Nedbank - " + building.Code + "-" + batch.BatchNumber.ToString().PadLeft(6, '0') + ".csv";
                    return(result);
                }
            }
        }
Beispiel #8
0
        private void SendNotification(tblBuilding building)
        {
            string status;
            var    pm = building.pm;

            if (String.IsNullOrWhiteSpace(pm))
            {
                pm = "*****@*****.**";
            }

            string bodyContent = "Good day" + Environment.NewLine +
                                 "Please note that the Insurance Policy for " + building.Building + " is set to expire on " + building.InsurancePolicyExpiryDate.Value.ToString("yyyy-MM-dd") + Environment.NewLine +
                                 "Please remember to update the insurance policy on the building." + Environment.NewLine;


            if (String.IsNullOrWhiteSpace(bodyContent))
            {
                bodyContent = "";
            }

            bodyContent = bodyContent + Environment.NewLine + Environment.NewLine;

            bodyContent += "Kind Regards" + Environment.NewLine;
            bodyContent += "Tel: 011 867 3183" + Environment.NewLine;
            bodyContent += "Fax: 011 867 3163" + Environment.NewLine;
            bodyContent += "Direct Fax: 086 657 6199" + Environment.NewLine;
            bodyContent += "BEE Level 4 Contributor" + Environment.NewLine;

            bodyContent += "FOR AND ON BEHALF OF ASTRODON(PTY) LTD" + Environment.NewLine;
            bodyContent += "The information contained in this communication is confidential and may be legally privileged.It is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it.If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking action in reliance of the contents of this information is strictly prohibited and may be unlawful.The company is neither liable for proper, complete transmission of the information contained in this communication nor any delay in its receipt." + Environment.NewLine;


            List <string> toAddress = new List <string>();

            toAddress.Add(pm);


            if (!Mailer.SendMailWithAttachments("*****@*****.**", toAddress.Distinct().ToArray(),
                                                "Insurnace Policy Expiry " + building.Building, bodyContent,
                                                false, false, false, out status, new Dictionary <string, byte[]>(), "*****@*****.**"))
            {
                Console.WriteLine("Error seding email " + status, "Email error");
            }
        }
        public async Task SaveDetail()
        {
            tblLocation dbloc = new tblLocation();
            Location    loc   = new Location();

            loc = dbloc.Get(_locid);
            Building    build   = new Building();
            tblBuilding dbbuild = new tblBuilding();

            build.LocationID       = _locid;
            build.BuildingCode     = "";
            build.BuildingSystemID = BSSelectedValue;
            build.SystemElementID  = SESelectedValue;
            build.SystemTypeID     = STSelectedValue;
            build.Rating           = RTSelectedValue;
            build.Details          = _detail;
            //build.IsDeficiencyRepair = true;
            build.ProjectID          = 0;
            build.ServiceContractID  = 0;
            build.WorkOrder          = "";
            build.Compliance         = "";
            build.Height             = 0;
            build.Width              = 0;
            build.MaterialID         = 0;
            build.UserID             = Constant.UserID;
            build.createon           = DateTime.Now;
            build.AddressLine1       = "";
            build.AddressLine2       = "";
            build.LocationCity       = "";
            build.StateID            = 0;
            build.LocationZip        = "";
            build.createon           = DateTime.Now;
            build.isedit             = false;
            build.issupload          = false;
            build.IsDeficiencyRepair = await App.Current.MainPage.DisplayAlert("FCA Deficiency Screen", "is this Deficiency/Repair ?", "Yes", "No");

            int bid = dbbuild.Add(build);

            App.Current.MainPage = new MainPageCS(new CameraPage(bid, "FCA"));
        }
Beispiel #10
0
        private void ScheduleBuildingMeeting(tblBuilding building)
        {
            //find a calendare entry for next month.

            DateTime dt      = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            var      dtStart = dt.AddMonths(1); // next month
            var      dtEnd   = dt.AddMonths(2).AddDays(-1);

            var entryCount = _Context.BuildingCalendarEntrySet.Where(a => a.BuildingId == building.id &&
                                                                     a.EventToDate >= dtStart &&
                                                                     a.EventToDate <= dtEnd &&
                                                                     a.Event == building.FinancialMeetingEvent).Count();

            if (entryCount > 0)
            {
                return; //already scheduled
            }
            //find the day to use

            var day = building.FinancialMeetingDayOfMonth;

            if (day == null)
            {
                return;
            }

            DateTime meetingDate = dtStart;

            try
            {
                meetingDate = new DateTime(dtStart.Year, dtStart.Month, day.Value);
            }
            catch
            {
                meetingDate = dtEnd; //must be end of month gone past the end of the month
            }

            //now find closest work day.
            var workDay = ClosestWorkDay(meetingDate);

            //find allocated PM
            var monthFin = _Context.tblMonthFins.Where(a => a.buildingID == building.Code && a.findate == dtStart).FirstOrDefault();

            if (monthFin == null)
            {
                DoRandomAllocations(dtStart);
            }


            monthFin = _Context.tblMonthFins.Where(a => a.buildingID == building.Code && a.findate == dtStart).FirstOrDefault();
            if (monthFin != null)
            {
                var meetingStart = new DateTime(workDay.Year, workDay.Month, workDay.Day, building.FinancialMeetingStartTime.Value.Hour, building.FinancialMeetingStartTime.Value.Minute, 1);
                var meetingEnd   = new DateTime(workDay.Year, workDay.Month, workDay.Day, building.FinancialMeetingEndTime.Value.Hour, building.FinancialMeetingEndTime.Value.Minute, 1);
                //Schedule the meeting
                var calEntry = new BuildingCalendarEntry()
                {
                    CalendarEntryType = CalendarEntryType.Financial,
                    BuildingId        = building.id,
                    UserId            = monthFin.userID,
                    EntryDate         = meetingStart,
                    EventToDate       = meetingEnd,
                    Event             = building.FinancialMeetingEvent,
                    Venue             = building.FinancialMeetingVenue,
                    NotifyTrustees    = building.FinancialMeetingSendInviteToAllTrustees,
                    BCCEmailAddress   = building.FinancialMeetingBCC,
                    InviteSubject     = building.FinancialMeetingSubject,
                    InviteBody        = building.FinancialMeetingBodyText
                };
                _Context.BuildingCalendarEntrySet.Add(calEntry);
                _Context.SaveChanges();
                SendInviteOut(calEntry);
            }
        }
        private async Task SaveDetail()
        {
            //data save
            LocationPhoto lp = new LocationPhoto();

            lp.createon  = DateTime.Now;
            lp.issupload = false;
            lp.isedit    = false;

            //byte[] imageBytes = streamToByteArray(_imgstream);
            //StreamReader sr = new StreamReader(_imgstream);


            string str = "";

            str = Convert.ToBase64String(_imgstream);

            lp.Photo = str;
            //await App.Current.MainPage.DisplayAlert("Upload Image", str, "Yes", "No");
            //lp.Photo = System.Convert.FromBase64String(_imageSource);
            lp.PhotoDescription           = _pagename;
            lp.PhotoUploadedDate          = DateTime.Now;
            lp.LocationID                 = 0;
            lp.BuildingID                 = 0;
            lp.BuildingDeficiencyRepairID = 0;
            lp.buildingWorkOrderID        = 0;
            lp.WorkOrderFollowUpID        = 0;
            if (_pagename == "Location")
            {
                lp.LocationID = _id;
            }
            else if (_pagename == "FCA")
            {
                lp.BuildingID = _id;
            }
            else if (_pagename == "BuildingDeficiencyRepair")
            {
                lp.BuildingDeficiencyRepairID = _id;
            }
            else if (_pagename == "Facility")
            {
                lp.FacilityID = _id;
            }
            else if (_pagename == "WorkOrder")
            {
                lp.WorkOrderRequestID = _id;
            }
            else if (_pagename == "WorkOrderFollowUp")
            {
                lp.WorkOrderFollowUpID = _id;
            }
            else if (_pagename == "ProjectScreenBefore")
            {
                lp.ProjectBeforeID = _id;
            }
            else if (_pagename == "BuildingDeficiencyRepairScreen")
            {
                lp.DeficiencyRepairID = _id;
            }
            //else if (_pagename == "WorkOrderFollowUp")
            //{
            //    lp.WorkOrderFollowUpID = _id;
            //}
            //else if (_pagename == "WorkOrderFollowUp")
            //{
            //    lp.WorkOrderFollowUpID = _id;
            //}

            tblLocationPhoto dblp = new tblLocationPhoto();

            dblp.Add(lp);
            bool ans = await App.Current.MainPage.DisplayAlert("Upload Image", "Would you like to Upload another Image?", "Yes", "No");

            if (ans == true)
            {
                App.Current.MainPage = new MainPageCS(new CameraPage(_id, _pagename));
            }
            else if (ans == false)
            {
                //App.Current.MainPage = new MainPageCS(new LocationView());
                //redirection
                if (_pagename == "Location")
                {
                    Location    loc   = new Location();
                    tblLocation dbloc = new tblLocation();
                    loc = dbloc.Get(_id);
                    //await App.Current.MainPage.DisplayAlert("Selected Location", _id.ToString(), "Submit");
                    //tblJobType dbjobtype = new tblJobType();
                    //JobType jt = new JobType();
                    //jt = dbjobtype.Get(loc.JobTypeID);
                    if (loc.JobTypeID == 1)
                    {
                        if (loc.JobStatusID == 1)
                        {
                            App.Current.MainPage = new MainPageCS(new ProjectScreenBefore(_id, false));
                        }
                        else if (loc.JobStatusID == 2)
                        {
                            //App.Current.MainPage = new MainPageCS(new ProjectScreenActive(_id));
                        }
                        else if (loc.JobStatusID == 3)
                        {
                            //App.Current.MainPage = new MainPageCS(new ProjectScreenAfter(_id));
                        }
                    }
                    else if (loc.JobTypeID == 3)
                    {
                        App.Current.MainPage = new MainPageCS(new FCASystem(_id));
                    }
                    else if (loc.JobTypeID == 4)
                    {
                        App.Current.MainPage = new MainPageCS(new FacilityScreen(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new LocationView());
                    }
                }
                else if (_pagename == "FCA")
                {
                    Building    build   = new Building();
                    tblBuilding DBbuild = new tblBuilding();
                    build = DBbuild.Get(_id);
                    if (build.IsDeficiencyRepair == true)
                    {
                        App.Current.MainPage = new MainPageCS(new FCADeficiencyScreen(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new LocationView());
                    }
                }
                else if (_pagename == "BuildingDeficiencyRepair")
                {
                    App.Current.MainPage = new MainPageCS(new LocationView());
                }
                else if (_pagename == "Facility")
                {
                    tblBuilding DBBuild = new tblBuilding();
                    Building    build   = new Building();
                    build = DBBuild.Get(_id);
                    if (build.WorkOrder != "")
                    {
                        App.Current.MainPage = new MainPageCS(new WorkOrderRequest(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new LocationView());
                    }
                }
                else if (_pagename == "WorkOrder")
                {
                    App.Current.MainPage = new MainPageCS(new WorkOrderFollowUpScreen(_id));
                }
                else if (_pagename == "ProjectScreenBefore")
                {
                    Building    build   = new Building();
                    tblBuilding DBbuild = new tblBuilding();
                    build = DBbuild.Get(_id);
                    bool isDetail = await App.Current.MainPage.DisplayAlert("Detail's", "Do you want add more detail ?", "Yes", "No");

                    if (build.IsDeficiencyRepair == true)
                    {
                        App.Current.MainPage = new MainPageCS(new ProposalChecklistFlatRoof(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new DeficiencyRepairScreen(_id));
                    }
                }
                else if (_pagename == "ProjectScreenBefore")
                {
                }
                else
                {
                    App.Current.MainPage = new MainPageCS(new LocationView());
                }
            }
        }
Beispiel #12
0
 public RequisitionProcessor(DataContext context, int buildingId)
 {
     _context    = context;
     _buildingId = buildingId;
     _building   = context.tblBuildings.Where(a => a.id == buildingId).Single();
 }