예제 #1
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
 private void DownloadTenantDocuments(List<RealpageData.Resident> tenants, string fn, ClientEntry cle)
 {
     AddMessage("Downloading tenant Documents..");
     string path = Path.GetDirectoryName(fn);
     foreach (var res in tenants)
     {
         BuildAndDownLoadDocument2(res, path, cle);
     }
     AddMessage("Download Complete..");
 }
예제 #2
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
        private void UpdateClients_RP(XElement resp, ClientEntry cle)
        {
            var respNode = resp.Descendants("Response");
            XDocument doc = ccfg.GetConfig(rpcliConfig);
            var clients = ccfg.GetElement(doc, "clients");

            foreach (var site in respNode.Descendants("Site"))
            {
                var siteId = site.Descendants("SiteID").FirstOrDefault().Value;
                bool found = false;
                foreach (var member in clients.Descendants("client"))
                {
                    var memberSite = member.Descendants("siteid").FirstOrDefault();
                    if (memberSite == null)
                    {
                        continue;
                    }
                    if (siteId == memberSite.Value)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {

                    var email = site.Descendants("Email").FirstOrDefault() == null
                        ? string.Empty
                        : site.Descendants("Email").FirstOrDefault().Value;
                    XElement newClient = new XElement("client",
                          new XAttribute("keyword", string.Empty)
                        , new XElement("name", site.Descendants("PMCName").FirstOrDefault().Value)
                        , new XElement("enabled", "false")
                        , new XElement("email", email)
                        , new XElement("siteid", site.Descendants("SiteID").FirstOrDefault().Value)
                        , new XElement("sitename", site.Descendants("SiteName").FirstOrDefault().Value)
                        , new XElement("siteaddress", GetSiteAddress(site))
                        , new XElement("firstdate", DateTime.Now.ToString("yyyy-MM-dd"))
                        , new XElement("aftermoveout", cle.AfterMoveout)
                        , new XElement("balanceowed", cle.BalanceOwed)
                        , new XElement("ekey", cle.Ekey)
                        , new XElement("pmcid", cle.PmcId)
                        , new XElement("phone1",  site.Descendants("Phone1").FirstOrDefault() != null ? site.Descendants("Phone1").FirstOrDefault().Value : string.Empty)
                        );
                    clients.Add(newClient);
                    AddMessage("New Client Entry created for Site: "
                        + site.Descendants("SiteName").FirstOrDefault().Value
                        + ", PMC : " + cle.PmcId);
                    doc.Save(rpcliConfig);
                }
            }
            LoadClients_RP(doc);
        }
예제 #3
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
        private void BuildAndDownLoadDocument2(RealpageData.Resident res, string folder, ClientEntry cle)
        {
            AuthDTO auth = GetAuth(cle);
            var client = new RPXServiceClient();
            client.InnerChannel.OperationTimeout = new TimeSpan(0, 5, 00);
            try
            {
                var req = new BuildCollectionDocumentsRequest() { reshid = res.ReshID };

                var resp = client.buildcollectiondocumentsAsync(auth, req);
                var respXml =  resp.Result.Body.buildcollectiondocumentsResult;
                txtResponse.Text = respXml.ToString();
                var fileSizeNode = respXml.Descendants("filesize").FirstOrDefault();
                int fileSizeVal = 0;
                if (fileSizeNode != null)
                {
                    fileSizeVal = Convert.ToInt32(fileSizeNode.Value);
                }
                if (fileSizeVal == 0)
                {
                    //              AddMessage("No files to download for site " + res.SiteID + " Tenant Reshid " + res.ReshID + " Name: " + res.FirstName + " " + res.LastName );
                    return;
                }

                var filename = folder
                    + @"\"
                    + cle.RrsId + "_"
                    + cle.SiteId + "_"
                    + res.ReshID + "_"
                    + StripNumber(res.LastName) + "_" + res.FirstName + "_" + DateTime.Now.ToString("MMddyyyy_HHmm") + ".pdf";

                var reqDL = new DownloadCollectionDocumentRequest() { reshid = res.ReshID };

                var returnDoc =  client.downloadcollectiondocumentAsync(auth, reqDL).Result.Body.downloadcollectiondocumentResult;
                var returnResult = returnDoc.Descendants("Result").FirstOrDefault();
                if (returnResult == null)
                {
                    AddMessage("Result is empty for file pull " + filename);
                    return;
                }
                var retData = returnDoc.Descendants("Result").FirstOrDefault().Value;

                FileStream wFile = new FileStream(filename, FileMode.Create);
                byte[] buffer;
                buffer = Convert.FromBase64String(retData);
                wFile.Write(buffer, 0, buffer.Length);
                wFile.Close();
                AddMessage("File " + filename + "  Has been created ; filesize " + fileSizeVal);
            }
            catch (Exception ex)
            {
                Log.Error("Error Creating File\n" + ex);
                MessageBox.Show("Error Creating File\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
        private void PullSitesForClient(ClientEntry cle)
        {
            AuthDTO auth = GetAuth(cle);

            var client = new RPXServiceClient();
            client.InnerChannel.OperationTimeout = new TimeSpan(0, 5, 00);
            try
            {
                var resp = client.sitelist(auth, new SiteListRequest());
                txtResponse.Text = resp.ToString();
                UpdateClients_RP(resp, cle);
                Log.Info("Sitelist Response \n" + resp);
            }
            catch (Exception ex)
            {
                Log.Info("Error on Sitelist Call \n" + ex);
                MessageBox.Show("Error on Sitelist Call \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
예제 #5
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
        private void RetrievePlacementsByDate(ClientEntry clEntry)
        {
            Cursor.Current = Cursors.WaitCursor;
               //     rpcliConfig = ConfigurationManager.AppSettings["rpclientconfiguration"];
            ccfgRP = new cNSConfig();
            rpcliFile = ccfgRP.GetConfig(rpcliConfig);

            XElement el = ccfgRP.GetElementByAttrib(rpcliFile, "client", "keyword", clEntry.RrsId);

            AuthDTO auth = GetAuth(clEntry);

            var client = new RPXServiceClient();
            client.InnerChannel.OperationTimeout = new TimeSpan(0, 5, 00);
            var request = new RetrievePlacementsByDateRequest();
            request.aftermoveout = clEntry.AfterMoveout;
            request.balanceowed = clEntry.BalanceOwed;
            request.subid = "ALL";
            request.extractfrom = string.Empty;//new DateTime(2014, 9, 1);
            request.extractto = string.Empty;//new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            request.paramstartdate = Convert.ToDateTime(clEntry.FirstDate.ToString("yyyy-MM-dd"));
            AddMessage(
                string.Format(
                    "RetrievePlacementsByDateRequest aftermoveout {0} balanceowed {1} extractfrom {2} extractto {3} paramstartdate {4}",
                    request.aftermoveout, request.balanceowed, request.extractfrom, request.extractto,
                    request.paramstartdate.ToString("yyyy-MM-dd")));
            try
            {
                var resp = client.retrieveplacementsbydate(auth, request);
                txtResponse.Text = resp.ToString();
                var respNode = resp.Descendants("Response").FirstOrDefault();
                if (RpxLeaseFileCount(respNode) == 0)
                {
                    AddMessage("No lease files found in site " + clEntry.SiteId + ", file not created");
                    return;
                }

                string dir = GetOutputFolder(txtRawXML.Text, clEntry);

                string fullfname = dir + @"\" + GetOutputSubdir(clEntry) + "_" + DateTime.Now.ToString("MMddyyyy_HHmm") + ".xml";
                string fname = GetOutputSubdir(clEntry) + "_" + DateTime.Now.ToString("MMddyyyy_HHmm") + ".xml";
                SaveRawFile(respNode, fullfname);
                AddMessage("XML File saved as " + fname);
            }
            catch (Exception ex)
            {
                Log.Error("Error on retrieveplacementsbydate Call \n" + ex);
                MessageBox.Show("Error on retrieveplacementsbydate Call \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #6
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
 private string GetOutputSubdir(ClientEntry clEntry)
 {
     string subDir = (clEntry.RrsId + "_" + clEntry.SiteName).Replace(" ", "_").Replace(",", "");
     return subDir;
 }
예제 #7
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
 private string GetOutputFolder(string folderBase , ClientEntry clEntry)
 {
     string subDir = (clEntry.RrsId + "_" + clEntry.SiteName).Replace(" ", "_").Replace(",", "");
     string dir = folderBase + @"\" + subDir;
     if (!Directory.Exists(dir))
     {
         Directory.CreateDirectory(dir);
     }
     return dir;
 }
예제 #8
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
 private ClientEntry GetClientEntry(string site)
 {
     XDocument doc = ccfg.GetConfig(rpcliConfig);
     XElement clientElement = ccfg.GetClientElementForSiteId(doc, site);
     if (clientElement == null)
     {
         return null;
     }
     var cl = new ClientEntry();
     cl.RrsId = clientElement.Attribute("keyword") != null ? clientElement.Attribute("keyword") .Value :string.Empty;
     cl.SiteId =  clientElement.Descendants("siteid").FirstOrDefault().Value;
     cl.SiteName = clientElement.Descendants("sitename").FirstOrDefault().Value;
     cl.Enabled = Convert.ToBoolean(clientElement.Descendants("enabled").FirstOrDefault().Value);
     cl.FirstDate = Convert.ToDateTime(clientElement.Descendants("firstdate").FirstOrDefault().Value);
     cl.PmcId = clientElement.Descendants("pmcid").FirstOrDefault().Value;
     cl.Ekey = clientElement.Descendants("ekey").FirstOrDefault().Value;
     cl.AfterMoveout = clientElement.Descendants("aftermoveout").FirstOrDefault().Value;
     cl.BalanceOwed = clientElement.Descendants("balanceowed").FirstOrDefault().Value;
     return cl;
 }
예제 #9
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
 private ClientEntry GetClientEntry(ListViewItem row)
 {
     var cl = new ClientEntry();
     cl.RrsId = row.SubItems[0].Text;
     cl.SiteId = row.SubItems[1].Text;
     cl.SiteName = row.SubItems[2].Text;
     cl.Enabled = Convert.ToBoolean(row.SubItems[4].Text);
     cl.FirstDate = Convert.ToDateTime(row.SubItems[7].Text);
     cl.PmcId = row.SubItems[8].Text;
     cl.Ekey = row.SubItems[9].Text;
     cl.AfterMoveout = row.SubItems[10].Text;
     cl.BalanceOwed = row.SubItems[11].Text;
     return cl;
 }
예제 #10
0
파일: frmDash.cs 프로젝트: KPratap/Yardi
        private AuthDTO GetAuth(ClientEntry clEntry)
        {
            var auth = new AuthDTO();
            auth.system = rpxsystemname;

            auth.username = rpxusername;
            auth.password = rpxpassword;
            auth.licensekey = rpxlicensekey;
            auth.pmcid = clEntry.PmcId;
            auth.siteid = clEntry.SiteId;
            return auth;
        }