Exemplo n.º 1
0
        protected virtual void AddAuthHeaders()
        {
            if (Client.DefaultRequestHeaders.Contains("Authorization") == false)
            {
                Client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Token);
            }

            if (Client.DefaultRequestHeaders.Contains("orgId") == false)
            {
                Client.DefaultRequestHeaders.Add("orgId", OrgId.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Procedure close and sign the work order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            string      sDataGridName;
            DBFieldType FieldType;
            DateTime    daCurrentDate;

            try
            {
                daCurrentDate       = DateTime.Now;
                order               = new clsWorkOrders();
                order.iOrgId        = OrgId;
                order.iId           = OrderId;
                order.iUserId       = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                order.sInitials     = Signature.sInitials;
                order.sPIN          = Signature.sPIN;
                order.sCleanliness  = tbCleanliness.Text;
                order.daCurrentDate = _functions.CorrectDate(adtClosed.Date);
                if (order.SigningWorkOrderClose() == -1)
                {
                    Signature.sError = _functions.ErrorMessage(140);
                }
                else
                {
                    order.cAction   = "U";
                    order.iNoteId   = 0;
                    order.iItemId   = OrderId;
                    order.daCreated = daCurrentDate;

                    if (tbTechNote.Text.Length > 0)
                    {
                        order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                        order.sNote       = tbTechNote.Text;
                        order.NoteDetails();
                    }
                    if (tbCheckOutNote.Text.Length > 0)
                    {
                        order.iNoteTypeId = (int)NoteTypes.CheckOutNote;
                        order.sNote       = tbCheckOutNote.Text;
                        order.NoteDetails();
                    }

                    #region saving cutom fields
                    if (ViewState["CustomFields"] != null)
                    {
                        order.iId      = OrderId;
                        dtCustomFields = (DataTable)ViewState["CustomFields"];

                        sDataGridName = repCustomFields.ClientID;

                        // getting data from Form and changing the dtCustomFields datatable
                        for (int i = 0; i < dtCustomFields.Rows.Count; i++)
                        {
                            for (int j = 0; j < Request.Form.Count; j++)
                            {
                                if ((string)dtCustomFields.Rows[i]["TypeName"] == Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":inputTypeName"])
                                {
                                    FieldType = _functions.TypeNameParser((string)dtCustomFields.Rows[i]["TypeName"]);                                     // nvarchar1...n, ...
                                    switch (FieldType)
                                    {
                                    case DBFieldType._nvarchar:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;

                                    case DBFieldType._int:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;

                                    case DBFieldType._float:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;

                                    case DBFieldType._datetime:
                                        dtCustomFields.Rows[i]["Value_String"] = new SqlDateTime(Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_year"]),
                                                                                                 Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_month"]),
                                                                                                 Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_day"]));
                                        break;

                                    case DBFieldType._bit:
                                        if (Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":chValue"] != null)
                                        {
                                            dtCustomFields.Rows[i]["Value_String"] = "True";
                                        }
                                        else
                                        {
                                            dtCustomFields.Rows[i]["Value_String"] = "False";
                                        }
                                        break;

                                    case DBFieldType._ntext:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;

                                    case DBFieldType._sql_variant:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;

                                    case DBFieldType._lookup:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":ddlValue"];
                                        break;

                                    default:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                    }
                                }
                            }
                        }

                        // saving data to database
                        order.WorkOrderDetail_CustomFields(_functions.SetDataToParameters(dtCustomFields));
                    }
                    #endregion

                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();

                    finish.sMainText = "The Work Order closed successfully!";

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText    = "[Return to Main Menu]";
                    finish.sMainMenuURL     = "main.aspx";

                    finish.bContinueVisible = true;
                    finish.sContinueText    = "[Continue to Check-Out Equipment by Technician]";
                    finish.sContinueURL     = "wo_viewCheckOut.aspx?id=" + OrderId.ToString();

                    finish.bViewVisible = true;
                    finish.sViewText    = "[Return to Work Order Detail]";
                    finish.sViewURL     = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = true;
                    finish.sPrintText    = "[Print the Closed Work Order]";
                    finish.sPrintURL     = "ReportViewer.aspx?Report=FleetProReports%2fCompletedOrder&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "wo_closeWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }
Exemplo n.º 3
0
        private void SendNoDbEmail(Person goer, GoerSupporter gs)
        {
            var from = new MailAddress(goer.EmailAddress ?? goer.EmailAddress2, goer.Name);
            var db   = DbUtil.Db;

            try
            {
                var text = Body;

                text = text.Replace("{salutation}", gs.Salutation, true);
                text = text.Replace("{track}", "", true);
                var qs   = "OptOut/UnSubscribe/?gid=" + Util.EncryptForUrl($"{gs.Id}");
                var url  = db.ServerLink(qs);
                var link = $@"<a href=""{url}"">Unsubscribe</a>";
                text = text.Replace("{unsubscribe}", link, true);
                text = text.Replace("%7Bfromemail%7D", from.Address, true);
                var supportlink = EmailReplacements.SupportLinkAnonymousReplacement(db, OrgId.ToString(), gs.Id.ToString());
                text = text.Replace("http://supportlink", supportlink, true);
                text = text.Replace("https://supportlink", supportlink, true);
                db.SendEmail(from, Subject, text, Util.ToMailAddressList(gs.NoDbEmail), gs.Id);
            }
            catch (Exception ex)
            {
                db.SendEmail(from, "sent emails - error", ex.ToString(),
                             Util.ToMailAddressList(from), gs.Id);
                throw;
            }
        }
Exemplo n.º 4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if ((Request.QueryString["equipid"] == null) && (Request.QueryString["orderid"] == null))
                {
                    Session["lastpage"] = "ok_mainMenu.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["orderid"]);
                    EquipId = Convert.ToInt32(Request.QueryString["equipid"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "ok_mainMenu.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                NextBackControl.BackText  = "<< Back";
                NextBackControl.BackPage  = "ok_editNote.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                NextBackControl.NextText  = "  Finish  ";
                NextBackControl.sCSSClass = "ok_input_button";

                op = new OperatorInfo(Request.Cookies["bfp_operator"].Value);

                if (!IsPostBack)
                {
                    lblFirstName.Text = op.FirstName;
                    equip             = new clsEquipment();
                    equip.iOrgId      = OrgId;
                    equip.iId         = EquipId;
                    if (equip.GetEquipInfo() != -1)
                    {
                        lblEquipId.Text   = equip.sEquipId.Value;
                        lblEquipType.Text = equip.sType.Value;
                    }
                    else
                    {
                        Session["lastpage"] = "ok_editNote.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                        Session["error"]    = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    order        = new clsWorkOrders();
                    order.iOrgId = OrgId;
                    order.iId    = OrderId;
                    repInstructions.DataSource = new DataView(order.GetInstructionByCheckIn());
                    repInstructions.DataBind();

                    if (order.bPrint.Value)
                    {
                        hlPrint.Visible = true;
                        string Url = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/")).Replace("/", "%2f");
                        Url = Url.Replace(":", "%3a");
                        hlPrint.Attributes.Add("onclick", "javascript:window.open('ReportViewer.aspx?Report=" + _functions.GetValueFromConfig("SQLRS.Folder") + "%2fCheckInReceipt&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString() + "&URL=" + Url + "', 'popupcal', 'toolbars=0');");
                    }
                    else
                    {
                        hlPrint.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "ok_editNote.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (equip != null)
                {
                    equip.Dispose();
                }
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            string sDomenName, sReportPath;

            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (Session["reload"] != null)
                {
                    if ((bool)Session["reload"] == true)
                    {
                        Session["reload"] = null;
                        Response.Redirect((string)Session["RedirectPath"], false);
                        Session["RedirectPath"] = null;
                        return;
                    }
                }

                if (Request.QueryString["id"] == null || Request.QueryString["inspectid"] == null)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId   = Convert.ToInt32(Request.QueryString["id"]);
                    InspectId = Convert.ToInt32(Request.QueryString["inspectid"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                // getting the Bread Crumbs from Cookie and add last item
                if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                {
                    Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                }
                Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());

                SaveCancelControl.ParentPageURL = ParentPageURL;
                SaveCancelControl.EnableSave    = true;
                SaveCancelControl.ButtonText    = " Complete/Sign ";
                SaveCancelControl.CancelText    = " Back ";

                if (!IsPostBack)
                {
                    sReportPath = _functions.GetValueFromConfig("SQLRS.Folder");
                    hlPrintInspectRequest.NavigateUrl   = "ReportViewer.aspx?Report=" + sReportPath + "%2fInspectionRequest&OrgId=" + OrgId.ToString() + "&OrderId=" + OrderId.ToString() + "&InspectId=" + InspectId.ToString();
                    hlPrintCompletedInstect.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fCompletedInspection&OrgId=" + OrgId.ToString() + "&OrderId=" + OrderId.ToString() + "&InspectId=" + InspectId.ToString();

                    user                = new clsUsers();
                    order               = new clsWorkOrders();
                    order.iOrgId        = OrgId;
                    order.iId           = OrderId;
                    order.iInspectionId = InspectId;
                    order.iTechId       = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    switch (order.GetInfoForInspection())
                    {
                    case 1:
                        tableMain.Rows[19].Visible   = false;
                        tableMain.Rows[20].Visible   = false;
                        tableMain.Rows[21].Visible   = false;
                        tableMain.Rows[22].Visible   = true;
                        tableMain.Rows[23].Visible   = true;
                        tableMain.Rows[24].Visible   = false;
                        tableMain.Rows[25].Visible   = false;
                        SaveCancelControl.EnableSave = false;

                        order.iDocumentId     = InspectId;
                        order.iDocumentTypeId = (int)DocumentTypes.InspectionCompleted;
                        if (order.GetSignedDocument() != -1)
                        {
                            hlPrintInspectRequest.Enabled   = false;
                            hlPrintCompletedInstect.Enabled = true;
                            lblSign.Text     = order.sUserName.Value;
                            lblSignDate.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                        else
                        {
                            hlPrintInspectRequest.Enabled   = true;
                            hlPrintCompletedInstect.Enabled = false;
                            lblSign.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        }
                        break;

                    case -1:
                        Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                        Session["error"]    = _functions.ErrorMessage(124);
                        Response.Redirect("error.aspx", false);
                        return;

                    default:
                        hlPrintCompletedInstect.Enabled = false;
                        adtInspection.Date         = DateTime.Now;
                        tableMain.Rows[22].Visible = false;
                        break;
                    }
                    if (!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true)))
                    {
                        SaveCancelControl.EnableSave = false;
                    }
                    ViewState["EquipId"] = order.iEquipId.Value;
                    ViewState["InspectSchedDetailId"] = order.iInspectSchedDetailId.Value;
                    lblInspectName.Text     = order.sInspectionName.Value;
                    lblInspectSchedule.Text = order.sInspectSchedule.Value;
                    lblTargetDaysOut.Text   = order.iInspectTargetDays.Value.ToString() + " days";
                    lblEquipId.Text         = order.sEquipId.Value;
                    lblEquipMake.Text       = order.sEquipMake.Value;
                    lblEquipModel.Text      = order.sEquipModel.Value;

                    repInspectItems.DataSource = new DataView(order.GetWorkOrderInspectItems());
                    repInspectItems.DataBind();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (user != null)
                {
                    user.Dispose();
                }
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }
Exemplo n.º 6
0
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            try
            {
                order               = new clsWorkOrders();
                order.iOrgId        = OrgId;
                order.iId           = OrderId;
                order.sInitials     = Signature.sInitials;
                order.sPIN          = Signature.sPIN;
                order.daCurrentDate = DateTime.Now;
                switch (order.SigningWorkOrderOpen())
                {
                case -1:
                    Signature.sError = _functions.ErrorMessage(140);
                    break;

                case -2:
                    Session["lastpage"] = "wo_preview.aspx?id=" + OrderId.ToString();
                    Session["error"]    = _functions.ErrorMessage(120);
                    Response.Redirect("error.aspx", false);
                    return;

                case 0:
                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();

                    finish.sMainText = "The Work Order opened successfully!";

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText    = "[Return to Main Menu]";
                    finish.sMainMenuURL     = "main.aspx";

                    finish.bContinueVisible = false;

                    finish.bViewVisible = true;
                    finish.sViewText    = "[View the Opened Work Order]";
                    finish.sViewURL     = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = true;
                    finish.sPrintText    = "[Print the Opened Work Order]";
                    finish.sPrintURL     = "ReportViewer.aspx?Report=FleetProReports%2fWorkOrderRequest&rs:Command=Render&rc:Parameters=false&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                    break;
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "wo_preview.aspx?id=" + OrderId.ToString();
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }