Exemplo n.º 1
0
        protected void lbtnSuspend_Click(object sender, EventArgs e)
        {
            string err = "Failed to ";

            try
            {
                ServiceManager sm = new ServiceManager();
                using (LP2ServiceClient service = sm.StartServiceClient())
                {
                    if (this.lbtnSuspend.Text.ToLower().IndexOf("suspend") >= 0)
                    {
                        err += "suspend ";
                        StopPointImportRequest req = new StopPointImportRequest();
                        req.hdr = new ReqHdr();
                        req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                        req.hdr.UserId        = 5;               //todo:check dummy data
                        StopPointImportResponse respone = null;
                        try
                        {
                            respone = service.StopPointImportService(req);
                            if (respone.hdr.Successful)
                            {
                                this.lbtnSuspend.Text = "Resume Sync";
                                PageCommon.WriteJsEnd(this, "Suspend sync successfully.", PageCommon.Js_RefreshSelf);
                            }
                            else
                            {
                                PageCommon.WriteJsEnd(this, "Suspend sync failed, reason: " + respone.hdr.StatusInfo, PageCommon.Js_RefreshSelf);
                            }
                        }
                        catch (System.ServiceModel.EndpointNotFoundException ee)
                        {
                            LPLog.LogMessage(ee.Message);
                            PageCommon.AlertMsg(this, "Failed to Suspend sync, reason: Point Manager is not running.");
                        }
                        catch (Exception exception)
                        {
                            err = "Failed to suspend sync, reason: " + exception.Message;
                            LPLog.LogMessage(err);
                            PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf);
                        }
                    }
                    else if (this.lbtnSuspend.Text.ToLower().IndexOf("resume") >= 0)
                    {
                        err += "resume ";
                        StartPointImportRequest req = new StartPointImportRequest();
                        req.hdr = new ReqHdr();
                        req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                        req.hdr.UserId        = 5;               //todo:check dummy data
                        StartPointImportResponse respone = null;

                        try
                        {
                            respone = service.StartPointImportService(req);

                            if (respone.hdr.Successful)
                            {
                                this.lbtnSuspend.Text = "Suspend Sync";
                                PageCommon.WriteJsEnd(this, "Resume sync successfully.", PageCommon.Js_RefreshSelf);
                            }
                            else
                            {
                                PageCommon.WriteJsEnd(this, "Resume sync failed.", PageCommon.Js_RefreshSelf);
                            }
                        }
                        catch (System.ServiceModel.EndpointNotFoundException ee)
                        {
                            err = "Failed to suspend sync, reason: " + ee.Message;
                            LPLog.LogMessage(err);
                            PageCommon.AlertMsg(this, "Failed to Resume sync, reason: Point Manager is not running.");
                        }
                        catch (Exception exception)
                        {
                            err = "Failed to suspend sync, reason: " + exception.Message;
                            LPLog.LogMessage(err);
                            PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                err += "sync, reason: " + ex.Message;
                LPLog.LogMessage(LogType.Logerror, err);
                PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf);
            }
        }