Exemplo n.º 1
0
        protected void lbtnSync_Click(object sender, EventArgs e)
        {
            string FolderPaths = hdnFolderPaths.Value;

            string[] paths = FolderPaths.Split(",".ToArray());
            string   err   = "";

            if (paths.Length < 1)
            {
                return;
            }
            try
            {
                ServiceManager sm = new ServiceManager();
                using (LP2ServiceClient service = sm.StartServiceClient())
                {
                    ImportAllLoansRequest req = new ImportAllLoansRequest();
                    req.hdr = new ReqHdr();
                    req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                    req.hdr.UserId        = 5;               //todo:check dummy data
                    req.PointFolders      = paths;
                    ImportAllLoansResponse respone = null;

                    try
                    {
                        respone = service.ImportAllLoans(req);

                        if (respone.hdr.Successful)
                        {
                            PageCommon.WriteJsEnd(this, "Sync Point Folder(s) successfully.", PageCommon.Js_RefreshSelf);
                        }
                        else
                        {
                            PageCommon.WriteJsEnd(this, "Failed to sync Point Folder(s), reason: " + respone.hdr.StatusInfo, PageCommon.Js_RefreshSelf);
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException ee)
                    {
                        LPLog.LogMessage(ee.Message);
                        PageCommon.AlertMsg(this, "Failed to Import Point Folders, reason: Point Manager is not running.");
                    }
                    catch (Exception exception)
                    {
                        err = "Failed to sync Point folder(s), reason: " + exception.Message;
                        LPLog.LogMessage(err);
                        PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf);
                    }
                }
            }
            catch (Exception ex)
            {
                err = "Failed to sync Point Folder(s), reason: " + ex.Message;
                LPLog.LogMessage(ex.Message);
                PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf);
            }
        }