Exemplo n.º 1
0
        public ActionResult Create()
        {
            try
            {
                sc.CheckSecurity(AppRoles.All, Session[SessionName.UserName.ToString()].ToString());
            }
            catch
            {
                return(RedirectToAction("Login", "Home"));
            }

            ViewBag.ShowPrice         = "none";
            ViewBag.ShowLineItemPrice = "none";

            MasterRequisition mr = new MasterRequisition();

            mr.MasterReqID           = 0;
            mr.MasterReqNbrSpecified = true;
            mr.RequestID             = "MReq".ToUniqueID();
            mr.RequestMode           = "MReqMode".ToUniqueID();
            mr.Description3          = "Status, Inwork";
            mr.CMSDatabase           = Properties.Settings.Default.DB2Database;
            //mr.Requisitioner = "1295";
            mr.Buyer = "SYS";


            mr.VendorList.Clear();
            mr.VendorList = vnRepository.GetVendorList(string.Empty);


            Requisitioner rq = new Requisitioner();
            string        u  = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString().ToUserIDWithoutDomain().ToUpper(); //In case we ever want to use Windows Login ID

            u  = Session[SessionName.UserName.ToString()].ToString().ToUpper();                                                          //Use the CMS User name
            rq = repository.GetRequisitionerByID(u);

            mr.Requisitioner = rq.ID;

            try
            {
                Session[SessionName.ProjectCode.ToString()] = mr.ProjectCodeSummary;
            }
            catch
            {
                Session[SessionName.ProjectCode.ToString()] = "";
            }
            return(View(mr));
        }
Exemplo n.º 2
0
        public ActionResult Create(MasterRequisition mr)
        {
            Int32  MReqID = 0;
            string Result = string.Empty;
            string u      = Session[SessionName.UserName.ToString()].ToString();
            string p      = Session[SessionName.Password.ToString()].ToString();

            Session[SessionName.MReqID.ToString()]    = "";
            Session[SessionName.MReqError.ToString()] = "";
            ViewBag.ShowPrice         = "none";
            ViewBag.ShowLineItemPrice = "none";


            if (ModelState.IsValid)
            {
                CMSAPI api = new CMSAPI();

                Result = api.AddMasterRequisition(mr, u, p);

                if (Result.IsNumeric())
                {
                    MReqID = Convert.ToInt32(Result);
                    Session[SessionName.MReqID.ToString()] = MReqID.ToString();
                }
                else
                {
                    Session[SessionName.MReqError.ToString()] = Result;
                }
                try
                {
                    Session[SessionName.ProjectCode.ToString()] = mr.ProjectCodeSummary;
                    Session[SessionName.VendorCode.ToString()]  = mr.VendorCode;
                }
                catch
                {
                    Session[SessionName.ProjectCode.ToString()] = "";
                }
                return(RedirectToAction("Create", "ReqDetail"));
            }
            else
            {
                mr.VendorList.Clear();
                mr.VendorList = vnRepository.GetVendorList(string.Empty);
                return(View(mr));
            }
        }
Exemplo n.º 3
0
        public ActionResult SubmitReqSupervisor()
        {
            try
            {
                sc.CheckSecurity(AppRoles.All, Session[SessionName.UserName.ToString()].ToString());
            }
            catch
            {
                return(RedirectToAction("Login", "Home"));
            }

            string MasterReqID = Session[SessionName.MReqID.ToString()].ToString();
            string SupID       = string.Empty;

            MasterRequisition mReq   = masterRepository.GetMasterRequisitionByID(MasterReqID);
            List <ReqDetail>  reqDet = reqDetRepository.GetRequisitionsByMasterReqID(MasterReqID);
            Requisitioner     reqr   = reqRepository.GetRequisitionerByUserName(Session[SessionName.UserName.ToString()].ToString());

            foreach (ReqDetail req in reqDet)
            {
                Approval routeApproval = new Approval();

                routeApproval.RequisitionNumber = Convert.ToInt32(req.RequestID.ToString());
                routeApproval.SupervisorID      = GetRequisitionerManager(reqr.ID);
                routeApproval.Level             = 1;
                routeApproval.Pass              = 1;
                routeApproval.Status            = "P";
                routeApproval.SubmittedUserName = reqr.UserName;

                Int32 returnValue = approvalRepository.InsertApprovalRoute(routeApproval);
                SupID = routeApproval.SupervisorID;
            }
            SendEmailNotice(SupID, reqDet, MasterReqID, mReq.Description1);

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public string AddMasterRequisition(MasterRequisition mReq, string UserName, string Password)
        {
            string returnValue = string.Empty;

            ERMA.IVRequisition.ivpwsNPO001PortTypeClient client = new ivpwsNPO001PortTypeClient("ivpwsNPO001HttpSoap12Endpoint");
            client.ChannelFactory.Endpoint.Behaviors.Remove <System.ServiceModel.Description.ClientCredentials>();
            client.ChannelFactory.Endpoint.Behaviors.Add(new CustomCredentials());

            // set the credentials and path to the certificate.
            client.ClientCredentials.UserName.UserName = UserName;
            client.ClientCredentials.UserName.Password = Password;
            client.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindBySerialNumber, "4d 00 eb c7");

            AddPORequsitionMasterRequest      request = new AddPORequsitionMasterRequest();
            Service_AddPORequsitionMasterType addMReq = new Service_AddPORequsitionMasterType();

            addMReq.CMSDataBase   = mReq.CMSDatabase;
            addMReq.ServPlntCod   = mReq.ServPlntCode;
            addMReq.ServLang      = mReq.ServLang;
            addMReq.RequestID     = mReq.RequestID;
            addMReq.RequestMode   = mReq.RequestMode;
            addMReq.Requisitioner = mReq.Requisitioner;
            addMReq.Buyer         = mReq.Buyer;
            addMReq.Description1  = mReq.Description1;
            addMReq.Description2  = mReq.Description2;
            addMReq.Description3  = mReq.Description3;
            addMReq.MasterRequisitionNbrSpecified = mReq.MasterReqNbrSpecified;
            addMReq.MasterRequisitionNbr          = mReq.MasterReqID;
            addMReq.CommodityCategoryCode         = mReq.CommodityCode;
            addMReq.ProjectNumber = mReq.ProjectCodeSummary;

            ERMA.IVRequisition.NotepadTextType[] nts = new ERMA.IVRequisition.NotepadTextType[25];
            Int32  linePerPage = 0;
            Int32  page        = 1;
            Int32  index       = 0;
            string newline     = string.Empty;

            Parsing ps = new Parsing();

            if (!(mReq.Notes is null))
            {
                if (mReq.Notes.Length > 0)
                {
                    ps.Parse(mReq.Notes, 70);

                    foreach (string ln in ps.Notes)
                    {
                        linePerPage++;
                        if (linePerPage <= 10)
                        {
                            ERMA.IVRequisition.NotepadTextType nt = new IVRequisition.NotepadTextType();
                            nt.PageNumber = page;
                            nt.LineNumber = linePerPage;
                            if (ln == Environment.NewLine)
                            {
                                newline = " ";
                            }
                            else
                            {
                                newline = ln;
                            }
                            nt.LineText = newline;
                            if (index < 10)
                            {
                                nts.SetValue(nt, index);
                            }
                            index++;
                        }
                        else
                        {
                            page++;
                            linePerPage = 0;
                        }
                    }
                }
            }
            if (!(mReq.Purpose is null))
            {
                if (mReq.Purpose.Length > 0)
                {
                    Parsing ps2 = new Parsing();
                    ps2.Parse(mReq.Purpose, 70);
                    linePerPage = 0;
                    page        = 11;
                    index       = 10;

                    foreach (string ln in ps2.Notes)
                    {
                        linePerPage++;
                        if (linePerPage <= 10)
                        {
                            ERMA.IVRequisition.NotepadTextType nt = new IVRequisition.NotepadTextType();
                            nt.PageNumber = page;
                            nt.LineNumber = linePerPage;
                            if (ln == Environment.NewLine)
                            {
                                newline = " ";
                            }
                            else
                            {
                                newline = ln;
                            }
                            nt.LineText = newline;
                            if (index < 20)
                            {
                                nts.SetValue(nt, index);
                            }
                            index++;
                        }
                        else
                        {
                            page++;
                            linePerPage = 0;
                        }
                    }
                }
            }
            page        = 20;
            linePerPage = 1;
            index       = 20;

            if (!(mReq.HowShipped is null))
            {
                if (mReq.HowShipped.Length > 0)
                {
                    ERMA.IVRequisition.NotepadTextType nt20 = new IVRequisition.NotepadTextType();
                    nt20.PageNumber = page;
                    nt20.LineNumber = linePerPage;
                    nt20.LineText   = mReq.HowShipped;
                    nts.SetValue(nt20, index);
                }
            }
            linePerPage++;
            index++;

            if (!(mReq.Reason is null))
            {
                if (mReq.Reason.Length > 0)
                {
                    ERMA.IVRequisition.NotepadTextType nt21 = new IVRequisition.NotepadTextType();
                    nt21.PageNumber = page;
                    nt21.LineNumber = linePerPage;
                    nt21.LineText   = mReq.Reason;
                    nts.SetValue(nt21, index);
                }
            }
            linePerPage++;
            index++;

            if (!(mReq.QuoteNumber is null))
            {
                if (mReq.QuoteNumber.Length > 0)
                {
                    ERMA.IVRequisition.NotepadTextType nt22 = new IVRequisition.NotepadTextType();
                    nt22.PageNumber = page;
                    nt22.LineNumber = linePerPage;
                    nt22.LineText   = mReq.QuoteNumber;
                    nts.SetValue(nt22, index);
                }
            }

            linePerPage++;
            index++;

            ERMA.IVRequisition.NotepadTextType nt23 = new IVRequisition.NotepadTextType();
            nt23.PageNumber = page;
            nt23.LineNumber = linePerPage;
            nt23.LineText   = mReq.IsReimbursable.ToString();
            nts.SetValue(nt23, index);

            addMReq.NotepadTexts = nts;


            request.Service_AddPORequsitionMaster = addMReq;

            try
            {
                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;

                AddPORequsitionMasterResponse response = ((ivpwsNPO001PortType)client).AddPORequsitionMaster(request);
                CMS_ServiceResponse_AddPORequsitionMasterType addGlobalPOMasterReqResponse = response.CMS_ServiceResponse_AddPORequsitionMaster;
                //Console.WriteLine(addGlobalPOMasterReqResponse.MasterRequisitionNbr);
                returnValue = addGlobalPOMasterReqResponse.MasterRequisitionNbr.ToString();
            }
            catch (FaultException <IVRequisition.ServerFaultResponse> ex)
            {
                StringWriter  sw  = new StringWriter();
                XmlTextWriter xtw = new XmlTextWriter(sw);
                //ex.Detail.WriteXml(xtw);
                xtw.Close();
                //Console.WriteLine(sw);
                returnValue = ex.Message;
            }
            catch (ProtocolException pe)
            {
                WebException we = pe.InnerException as WebException;
                //Console.WriteLine(getFaultAsString(we));
                returnValue = we.Message;
            }
            return(returnValue);
        }