Esempio n. 1
0
 public Main(CustomSession _session = null)
 {
     InitializeComponent();
     this._repo     = new CommonRepository(epiSession);
     this._repoSess = new Erp.Custom.Core.Session.Repositories.Session();
     this.session   = new CustomSession();
 }
Esempio n. 2
0
        private void butOK_Click(object sender, EventArgs e)
        {
            string msgErr = string.Empty;

            //TODO switching offline/online
            _session = _repo.IdentifySession(txtUserName.Text, txtPassword.Text, out msgErr);
            //_session = _repo.IdentifySession();
            eSession = _repo.GetSession();

            if (chkRemember.Checked)
            {
                Properties.Settings.Default.username = txtUserName.Text;
                Properties.Settings.Default.password = txtPassword.Text;
            }
            else
            {
                Properties.Settings.Default.username = "";
                Properties.Settings.Default.password = "";
            }

            Properties.Settings.Default.remember = chkRemember.Checked;
            Properties.Settings.Default.Save();

            if (_session.SessionId != null)
            {
                epiSession = _session;
                this.Close();
            }
            else
            {
                MessageBox.Show(msgErr, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
 public AddTree(CustomSession _session = null, string param = null)
 {
     InitializeComponent();
     this._repo = new AuthRepo();
     epiSession = _session;
     addedModel = new TreeViewModel();
     DefaultSession();
 }
Esempio n. 4
0
        public Repositories()
        {
            CustomSession ses = new CustomSession();

            this._s    = new Session();
            this._repo = new AuthRepo();
            this._inst = new EndpointBindingSvc(ses);
        }
Esempio n. 5
0
 public TeamManagement(CustomSession _session = null, string param = null)
 {
     InitializeComponent();
     this._repo = new AuthRepo();
     this.trans = new TransModel();
     epiSession = _session;
     DefaultSession();
 }
Esempio n. 6
0
 public TreeList(CustomSession _session = null, TransModel param = null)
 {
     InitializeComponent();
     this._repo    = new AuthRepo();
     this.trees    = new List <TreeViewModel>();
     this.selected = new TreeViewModel();
     epiSession    = _session;
     DefaultSession();
 }
Esempio n. 7
0
        public SessionModSvcContractClient IdentifiesSession(CustomSession session)
        {
            UriBuilder builder = EndpointBinding(out bindingType);

            builder.Path = epiSite + "/Ice/Lib/SessionMod.svc";
            SessionModSvcContractClient sessionModClient = GetClient <SessionModSvcContractClient, SessionModSvcContract>(builder.Uri.ToString(), session.UserId, session.Password, bindingType);

            return(sessionModClient);
        }
Esempio n. 8
0
        /// <summary>
        /// 向指定会话对象推送消息
        /// </summary>
        /// <param name="session">当前会话</param>
        /// <param name="command">命令</param>
        /// <param name="msg">数据包</param>
        public static void Send(this CustomSession session, SocketCommand command, string msg)
        {
            if (session != null && session.Connected)
            {
                byte[] data = GetMsgBytes(msg, command);

                session.Send(data, 0, data.Length);
            }
        }
Esempio n. 9
0
        public bool NewRunningRow(CustomSession session, EstimateRunningModel model, out string resultMessage)
        {
            Erp.Custom.Core.Session.EndpointBindingSvc.EndpointBindingType bindingType;
            resultMessage = string.Empty;
            bool       result  = false;
            UriBuilder builder = _inst.EndpointBinding(out bindingType);
            SessionModSvcContractClient sessionModClient = _inst.IdentifiesSession(session);

            builder.Path = _inst.epiSite + "/Ice/BO/UD07.svc";
            UD07SvcContractClient ud07Client = _inst.GetClient <UD07SvcContractClient, UD07SvcContract>(builder.Uri.ToString(), session.UserId, session.Password, bindingType);

            Guid sessionId = Guid.Empty;

            try
            {
                sessionId = sessionModClient.Login();
                sessionModClient.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, session.UserId));
                ud07Client.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, session.UserId));
                var ts = new UD07Tableset();

                ud07Client.GetaNewUD07(ref ts);

                ts.UD07[0].Key1   = model.EstimateNo;
                ts.UD07[0].Key2   = model.RunningNo.ToString();
                ts.UD07[0].Key3   = model.QuoteNumber.ToString();
                ts.UD07[0].Key4   = model.TeamId;
                ts.UD07[0].Key5   = model.GeneratedPerson;
                ts.UD07[0].Date01 = DateTime.Now;
                ts.UD07[0].RowMod = "A";

                try
                {
                    ud07Client.Update(ref ts);
                    result = true;
                }
                catch (FaultException <Erp.Custom.Core.Session.Epicor.ReqSvc.EpicorFaultDetail> ex)
                {
                    if (ex.Detail.ExceptionKindValue.Equals("RecordNotFound", StringComparison.InvariantCultureIgnoreCase))
                    {
                        resultMessage = "Record deleted.";
                    }
                    else
                    {
                        resultMessage = ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                resultMessage = "ex" + ex.Message;
                sessionModClient.Logout();
                return(result);
            }

            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// 推送消息
        /// </summary>
        /// <param name="session"></param>
        /// <param name="action"></param>
        /// <param name="text"></param>
        public static void Push(this CustomSession session, ushort action, string text)
        {
            var response = BitConverter.GetBytes(action).Reverse().ToList();
            var arr      = System.Text.Encoding.UTF8.GetBytes(text);

            response.AddRange(BitConverter.GetBytes((ushort)arr.Length).Reverse().ToArray());
            response.AddRange(arr);

            session.Send(response.ToArray(), 0, response.Count);
        }
Esempio n. 11
0
 public TestMethods(CustomSession _session)
 {
     InitializeComponent();
     this._sess    = new Session();
     this._pr      = new Ice.CustomUI.PRList.RequisitionRepo();
     this._repoAth = new AuthRepo();
     this._repoReq = new RequisitionRepo();
     this._repoEst = new Erp.Custom.CostManagement.Repositories();
     epiSession    = _session;
     content       = new ApprovalModel();
 }
Esempio n. 12
0
        public EndpointBindingSvc(CustomSession session)
        {
            this.epiSession = session;
            this._repo      = new Erp.Custom.Core.Session.Repositories.Session();
            String[] arguments = Environment.GetCommandLineArgs();
            var      result    = _repo.ProcessCommandLineArguments(arguments);

            epiServer  = result.FirstOrDefault(x => x.Key.Equals("epiServer")).Value;
            epiSite    = result.FirstOrDefault(x => x.Key.Equals("epiSite")).Value;
            epiUserWCF = result.FirstOrDefault(x => x.Key.Equals("ActiveServcieWCFUser")).Value;
            epiPassWCF = result.FirstOrDefault(x => x.Key.Equals("ActiveServcieWCFPassword")).Value;
        }
Esempio n. 13
0
        public CustomSession GetSessionForWCFAccount()
        {
            CustomSession sessionResult = new CustomSession();

            String[] arguments = Environment.GetCommandLineArgs();

            var result = ProcessCommandLineArguments(arguments);

            sessionResult.UserId   = result.FirstOrDefault(x => x.Key.Equals("ActiveServcieWCFUser")).Value;
            sessionResult.Password = result.FirstOrDefault(x => x.Key.Equals("ActiveServcieWCFPassword")).Value;

            return(sessionResult);
        }
        /// <summary>
        /// 命令结束后调用
        /// </summary>
        /// <param name="commandContext"></param>
        public override void OnCommandExecuted(CommandExecutingContext commandContext)
        {
            CustomSession session = (CustomSession)commandContext.Session;

            if (session != null)
            {
                var startTime = session.Items.GetValue <DateTime>("StartTime");
                var ts        = DateTime.Now.Subtract(startTime);
                if (ts.TotalSeconds > 5 && session.Logger.IsInfoEnabled)
                {
                    session.Logger.InfoFormat("命令'{0}' 执行时间: {1} 秒!", commandContext.CurrentCommand.Name, ts.ToString());
                }
            }
        }
        /// <summary>
        /// 执行命令前调用
        /// </summary>
        /// <param name="commandContext"></param>
        public override void OnCommandExecuting(CommandExecutingContext commandContext)
        {
            CustomSession session = (CustomSession)commandContext.Session;

            if (session != null)
            {
                session.Items["StartTime"] = DateTime.Now;

                if (commandContext.RequestInfo.Key.Equals("-1"))
                {
                    session.Push(Convert.ToUInt16(commandContext.RequestInfo.Key), "未知命令!");
                    //取消执行当前命令
                    commandContext.Cancel = true;
                }
            }
        }
Esempio n. 16
0
        public CustomSession IdentifySession(string userName, string userPassword, out string errmsg)
        {
            errmsg = "";
            CustomSession sessionResult = new CustomSession();

            String[] arguments = Environment.GetCommandLineArgs();

            var result = ProcessCommandLineArguments(arguments);

            sessionResult.AppServerURL     = result.FirstOrDefault(x => x.Key.Equals("AppServerURL")).Value;
            sessionResult.ConnectionString = result.FirstOrDefault(x => x.Key.Equals("connectionString")).Value;
            sessionResult.UserId           = result.FirstOrDefault(x => x.Key.Equals("UserID")).Value;
            sessionResult.Password         = result.FirstOrDefault(x => x.Key.Equals("Password")).Value;

            if (!string.IsNullOrEmpty(sessionResult.UserId) && !string.IsNullOrEmpty(sessionResult.Password))
            {
                userName     = sessionResult.UserId;
                userPassword = sessionResult.Password;
            }

            try
            {
                Ice.Core.Session curr = new Ice.Core.Session(userName, userPassword
                                                             , sessionResult.AppServerURL
                                                             , Ice.Core.Session.LicenseType.Default);

                if (!string.IsNullOrEmpty(curr.SessionID))
                {
                    sessionResult.Company     = curr.CompanyID;
                    sessionResult.CompanyName = curr.CompanyName;
                    sessionResult.PlantId     = curr.PlantID.GetString();
                    sessionResult.PlantName   = curr.PlantName.GetString();
                    sessionResult.UserId      = curr.UserID;
                    sessionResult.Username    = curr.UserName;
                    sessionResult.SessionId   = curr.SessionID;
                    sessionResult.Client      = curr.Client.ToString();
                    sessionResult.Password    = userPassword;
                }

                return(sessionResult);
            }
            catch (Exception ex)
            {
                errmsg = ex.Message;
                return(sessionResult);
            }
        }
Esempio n. 17
0
        public bool SaveApprove(CustomSession _session, ApprovalModel model, ReqHeadModel reqHead)
        {
            var result = GetByID(Convert.ToInt32(model.OrderNum));

            string sql = string.Format(@"UPDATE ReqHead
                                           SET  Status_c = '{1}'
                                              , TreeViewID_c = N'{2}'
                                              , WaitingTeamID_c = N'{3}'
	                                          , ReqActionDesc_c = N'{4}'
                                              , SentByTeam_c = N'{5}'
                                         WHERE ReqNum = {0}" + Environment.NewLine
                                       , model.OrderNum
                                       , model.ApproveFlag == true ? "2" : "3"
                                       , model.ActionTreeId
                                       , model.ApproveFlag == true ? model.DepatcherTeam : result.SentByTeam
                                       , model.ReplyRemark
                                       , model.ApproveFlag == true ? model.WaitForApproveTeamId : "");

            try
            {
                Repository.Instance.ExecuteWithTransaction(sql, "Approve");

                var lv = _repoAth.GetAllTeamsLevel().Where(x => x.TreeViewId.Equals(model.ActionTreeId) && x.TeamId.Equals(model.WaitForApproveTeamId)).OrderByDescending(i => i.Level).FirstOrDefault();
                if (lv.Level == 0)
                {
                    string resultMessage;
                    reqHead.ReqNum         = Convert.ToInt32(model.OrderNum);
                    reqHead.NextActionID   = "03";
                    reqHead.NextActionDesc = "Purchasing Department";
                    reqHead.ReplyOption    = "A";
                    reqHead.ReqUserId      = reqHead.RequestorID;

                    SendToPOSuggestions(_session, reqHead, out resultMessage);
                    UpdateBuyer(reqHead.ReqNum, model.DepatcherTeam);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 18
0
        private void Save(bool insertFlag)
        {
            string resultMsg = string.Empty;

            model.EstimateByCostFlag = (rdoEstimateByCost.Checked) ? true : false;
            model.RevisionStr        = txtReviseNo.Text.Trim();
            model.GKCStadardFlag     = chkGKCStadardFlag.Checked;
            model.JisFlag            = chkJisFlag.Checked;
            model.ANSFlag            = chkANSFlag.Checked;
            model.CustomerSpecFlag   = chkCustomerSpecFlag.Checked;
            model.DinFlag            = chkDinFlag.Checked;
            model.OtherFlag          = chkOtherFlag.Checked;

            model.RequestDate  = dtpRequestDate.Value;
            model.OtherRemark  = txtOtherRemark.Text;
            model.ProjectName  = txtProjectName.Text;
            model.Budget       = Convert.ToDecimal(txtBudget.Text);
            model.Location     = txtLocation.Text;
            model.Remarks      = txtRemarks.Text;
            model.CustomerName = txtCustomer.Text;

            ValidationContext        context = new ValidationContext(this.model, null, null);
            IList <ValidationResult> errors  = new List <ValidationResult>();

            if (!Validator.TryValidateObject(this.model, context, errors, true))
            {
                foreach (ValidationResult result in errors)
                {
                    MessageBox.Show(result.ErrorMessage, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                CustomSession sess = new CustomSession();
                sess.UserId  = epiSession.UserID;
                model.TeamId = _repoAth.GetTeamByUserID(epiSession.UserID);
                var result = _repo.Save(sess, model, insertFlag, out resultMsg);

                BindData(result);
                MessageBox.Show(resultMsg);
            }
        }
Esempio n. 19
0
        public string GetLastRunning(Ice.Core.Session _session, string teamid, int quoteNo)
        {
            var team = _repo.GetTeamByUserID(_session.UserID);
            EstimateRunningModel model = new EstimateRunningModel();
            int    iRn = 1;
            string no  = "";

            if (quoteNo == 0)
            {
                return(no);
            }

            model = GetExistingRow(quoteNo);

            if (model == null)
            {
                model = GetLastRow(team);
                if (model != null)
                {
                    iRn = model.RunningNo + 1;
                }
                no = string.Format(@"{0}E{1:00}{2:00}{3:000}", team, DateTime.Now.ToString("yy"), DateTime.Now.ToString("MM"), iRn);
            }
            else
            {
                iRn = model.RunningNo;
                no  = model.EstimateNo;
            }

            string outResult         = string.Empty;
            EstimateRunningModel est = new EstimateRunningModel();

            est.TeamId          = team;
            est.RunningNo       = iRn;
            est.EstimateNo      = no;
            est.QuoteNumber     = quoteNo;
            est.GeneratedPerson = _session.UserID;
            CustomSession custSession = _s.GetSessionForWCFAccount();

            NewRunningRow(custSession, est, out outResult);
            return(no);
        }
Esempio n. 20
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (rdoApprove.Checked)
            {
                content.ApproveFlag = true;
            }
            else
            {
                content.ApproveFlag = false;
            }
            content.ReplyRemark = txtReplyRemark.Text;
            CustomSession sess = new CustomSession();

            sess.UserId   = "manager";
            sess.Password = "******";
            if (_repoReq.SaveApprove(sess, content, reqHeadModel))
            {
                this.Close();
            }
        }
        /// <summary>
        /// 执行命令前调用
        /// </summary>
        /// <param name="commandContext"></param>
        public override void OnCommandExecuting(CommandExecutingContext commandContext)
        {
            CustomSession session = (CustomSession)commandContext.Session;

            if (session != null)
            {
                session.Items["StartTime"] = DateTime.Now;

                if (commandContext.RequestInfo.Key.Equals("-1"))
                {
                    CustomCommand comm = (CustomCommand)Enum.Parse(typeof(CustomCommand), commandContext.RequestInfo.Key);

                    string json = "未知命令!".GetTransmitPackets(comm);
                    session.Send(comm, json);

                    //取消执行当前命令
                    commandContext.Cancel = true;
                }
            }
        }
Esempio n. 22
0
        public Ice.Core.Session GetSession()
        {
            CustomSession sessionResult = new CustomSession();

            sessionResult.AppServerURL     = "net.tcp://GOLLUM/E10Pilot";
            sessionResult.ConnectionString = "Data Source=gollum;Initial Catalog=E10Pilot;Persist Security Info=True;User ID=sa;Password=sp3@rm1nt";
            sessionResult.UserId           = "manager";
            sessionResult.Password         = "******";

            try
            {
                Ice.Core.Session curr = new Ice.Core.Session("manager", "manager"
                                                             , "net.tcp://GOLLUM/E10Pilot"
                                                             , Ice.Core.Session.LicenseType.Default);
                return(curr);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 23
0
        public IEnumerable <TeamMemberModel> AddAllMember(CustomSession session, List <TeamMemberModel> list, out bool IsSucces, out string msgError)
        {
            try
            {
                Ice.Core.Session curr = new Ice.Core.Session(session.UserId, session.Password
                                                             , session.AppServerURL
                                                             , Ice.Core.Session.LicenseType.Default);

                //UD07Tableset myUD = new UD07Tableset();

                //UD07DataSet
                IsSucces = true;
                msgError = "";
            }
            catch (Exception ex)
            {
                IsSucces = false;
                msgError = ex.Message;
            }

            return(null);
        }
Esempio n. 24
0
 public ApproveReq(CustomSession _session = null, string param = null)
 {
     InitializeComponent();
 }
Esempio n. 25
0
 public RequisitionRepo(CustomSession _session = null)
 {
     this.epiSession = _session;
     this._inst      = new EndpointBindingSvc(epiSession);
     this._repoAth   = new AuthRepo();
 }
Esempio n. 26
0
        //public Ice.Core.Session _session;

        public Login(CustomSession session = null)
        {
            InitializeComponent();
            this._session = session;
            this._repo    = new Erp.Custom.Core.Session.Repositories.Session();
        }
Esempio n. 27
0
        public CostRequestModel Save(CustomSession session, CostRequestModel model, bool insertFlag, out string resultMessage)
        {
            CostRequestModel result      = new CostRequestModel();
            CustomSession    custSession = _s.GetSessionForWCFAccount();

            Erp.Custom.Core.Session.EndpointBindingSvc.EndpointBindingType bindingType;
            resultMessage = "Save Completed.";// +Environment.NewLine +
            //"EstimateNo = " + model.GKCStadardFlag + Environment.NewLine +
            //"ReviseNo = " + model.ReviseNo + Environment.NewLine +
            //"RevisionStr = " + model.RevisionStr;


            string sRowMod = string.Empty;

            UriBuilder builder = _inst.EndpointBinding(out bindingType);
            SessionModSvcContractClient sessionModClient = _inst.IdentifiesSession(custSession);

            builder.Path = _inst.epiSite + "/Ice/BO/UD07.svc";
            UD07SvcContractClient ud07Client = _inst.GetClient <UD07SvcContractClient, UD07SvcContract>(builder.Uri.ToString(), custSession.UserId, custSession.Password, bindingType);

            //resultMessage = resultMessage + Environment.NewLine + "Binded.";
            Guid sessionId = Guid.Empty;

            try
            {
                sessionId = sessionModClient.Login();
                sessionModClient.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, custSession.UserId));
                ud07Client.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, custSession.UserId));

                //resultMessage = resultMessage + Environment.NewLine + "GUID : " + sessionId;
                var ts = new UD07Tableset();

                if (!insertFlag)
                {
                    var row = GetRowByID(model.EstimateNo, model.ReviseNo);
                    ts      = ud07Client.GetByID(row.EstimateNo, row.RevisionStr.Trim(), row.RunningNo.ToString(), row.TeamId, row.GeneratedPerson);
                    sRowMod = "U";
                }
                else
                {
                    int iRn = 1;
                    ud07Client.GetaNewUD07(ref ts);
                    sRowMod = "A";
                    if (string.IsNullOrEmpty(model.EstimateNo))
                    {
                        var res = GetLastRow(model.TeamId);
                        if (model != null)
                        {
                            iRn = ((res == null) ? 0 : res.RunningNo) + 1;
                        }
                        model.EstimateNo = string.Format(@"{0}E{1:00}{2:00}{3:000}", model.TeamId, DateTime.Now.ToString("yy"), DateTime.Now.ToString("MM"), iRn);
                        model.ReviseNo   = 0;
                        model.RunningNo  = iRn;
                        model.RequestBy  = session.UserId;
                    }
                    else
                    {
                        model.ReviseNo = GetLastRow(model.TeamId).ReviseNo + 1;
                    }

                    ts.UD07[0].Key1     = model.EstimateNo;
                    ts.UD07[0].Key2     = string.IsNullOrEmpty(Enum.GetName(typeof(RevisionEnum), Convert.ToInt32(Convert.ToInt32((model.ReviseNo.GetInt() == 0) ? 0 : model.ReviseNo)))) ? string.Empty : Enum.GetName(typeof(RevisionEnum), Convert.ToInt32(Convert.ToInt32((model.ReviseNo.GetInt() == 0) ? 0 : model.ReviseNo)));
                    ts.UD07[0].Key3     = model.RunningNo.GetString();
                    ts.UD07[0].Number02 = model.ReviseNo.GetInt();
                    ts.UD07[0].Key4     = model.TeamId;
                    ts.UD07[0].Key5     = model.RequestBy;
                }

                ts.UD07[0].Character01 = string.IsNullOrEmpty(model.ProjectName) ? "" : model.ProjectName;
                ts.UD07[0].Character03 = string.IsNullOrEmpty(model.OtherRemark) ? "" : model.OtherRemark;
                ts.UD07[0].Character04 = string.IsNullOrEmpty(model.Remarks) ? "" : model.Remarks;
                ts.UD07[0].Character05 = string.IsNullOrEmpty(model.Location) ? "" : model.Location;
                ts.UD07[0].Number01    = model.Budget;
                ts.UD07[0].CheckBox01  = model.GKCStadardFlag;
                ts.UD07[0].CheckBox02  = model.JisFlag;
                ts.UD07[0].CheckBox03  = model.ANSFlag;
                ts.UD07[0].CheckBox04  = model.CustomerSpecFlag;
                ts.UD07[0].CheckBox05  = model.DinFlag;
                ts.UD07[0].CheckBox06  = model.OtherFlag;
                ts.UD07[0].CheckBox07  = model.EstimateByCostFlag;
                //ts.UD07[0].CheckBox08 = model.EstimateByOwner;
                ts.UD07[0].ShortChar01 = string.IsNullOrEmpty(model.CustomerName) ? "" : model.CustomerName;
                ts.UD07[0].ShortChar02 = string.IsNullOrEmpty(model.Ref_ProjectID) ? "" : model.Ref_ProjectID;

                ts.UD07[0].Date01 = model.RequestDate;
                ts.UD07[0].RowMod = sRowMod;
                //resultMessage = resultMessage + Environment.NewLine + "RowMod : " + sRowMod + model.ToString();

                try
                {
                    ud07Client.Update(ref ts);
                }
                catch (FaultException <Erp.Custom.Core.Session.Epicor.ReqSvc.EpicorFaultDetail> ex)
                {
                    if (ex.Detail.ExceptionKindValue.Equals("RecordNotFound", StringComparison.InvariantCultureIgnoreCase))
                    {
                        resultMessage = "Record deleted.";
                    }
                    else
                    {
                        resultMessage = ex.Message;
                    }
                }
                catch (Exception x)
                {
                    resultMessage = x.Message;
                }
                result = GetEstimateByID(model.EstimateNo, model.ReviseNo.GetString());
            }
            catch (Exception ex)
            {
                resultMessage = "Error Code : 20055 " + ex.Message + Environment.NewLine + "Source : " + ex.Source + Environment.NewLine + "StackTrace : " + ex.StackTrace;
                sessionModClient.Logout();
            }

            //sessionModClient.Logout();
            return(result);
        }
Esempio n. 28
0
        public bool ReqToPOSug(CustomSession _session, out string resultMessage)
        {
            Erp.Custom.Core.Session.EndpointBindingSvc.EndpointBindingType bindingType;
            resultMessage = string.Empty;
            bool       result  = false;
            UriBuilder builder = _inst.EndpointBinding(out bindingType);
            SessionModSvcContractClient sessionModClient = _inst.IdentifiesSession(_session);

            builder.Path = _inst.epiSite + "/Erp/BO/Req.svc";
            ReqSvcContractClient reqClient = _inst.GetClient <ReqSvcContractClient, ReqSvcContract>(builder.Uri.ToString(), _session.UserId, _session.Password, bindingType);

            Guid sessionId = Guid.Empty;

            try
            {
                sessionId = sessionModClient.Login();
                sessionModClient.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, epiSession.UserId));
                reqClient.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, epiSession.UserId));
                var ts = new ReqTableset();
                ts = reqClient.GetByID(108);

                if (ts != null && ts.ReqHead.Any())
                {
                    ReqHeadRow backupRow = new ReqHeadRow();
                    var        fields    = backupRow.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                    foreach (var field in fields)
                    {
                        if (field.PropertyType == typeof(System.Runtime.Serialization.ExtensionDataObject))
                        {
                            continue;
                        }

                        var fieldValue = field.GetValue(ts.ReqHead[0]);
                        field.SetValue(backupRow, fieldValue);
                    }
                    ts.ReqHead.Add(backupRow);
                }

                ts.ReqHead[0].NextActionID   = "03";
                ts.ReqHead[0].NextActionDesc = "Send to Procurement Dept";
                ts.ReqHead[0].ReplyOption    = "A";
                ts.ReqHead[0].ReqUserId      = "Manager";
                ts.ReqHead[0].RowMod         = "U";

                try
                {
                    reqClient.Update(ref ts);
                    result = true;
                }
                catch (FaultException <Epicor.ReqSvc.EpicorFaultDetail> ex)
                {
                    if (ex.Detail.ExceptionKindValue.Equals("RecordNotFound", StringComparison.InvariantCultureIgnoreCase))
                    {
                        resultMessage = "Record deleted.";
                    }
                    else
                    {
                        resultMessage = ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                resultMessage = "ex" + ex.Message;
                sessionModClient.Logout();
                return(result);
            }

            return(result);
        }
Esempio n. 29
0
 public RequisitionSvc(CustomSession _session)
 {
     this.epiSession = _session;
     this._inst      = new EndpointBindingSvc(epiSession);
     this._s         = new Session();
 }
Esempio n. 30
0
 public CommonRepository(CustomSession _session)
 {
     this.session = _session;
 }