Anda di halaman 1dari 12

using System;

using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using rcw.PMIContactObjects;
using rcw.pmiFormat;
using rcw.pmiMessageWrapper;
using System.Reflection;

public partial class BillingUsage : System.Web.UI.Page


{
public string strBrandPath = "";
public string strUserKey, strStorageBar, strCompanyUsageData, strCompanyKey;
public string strUsageDetails, strCompanyName;
public string strBillStartDate, strBillEndDate;
public pmiUser objUser;
public string sDiskUsage;
public string strLvRecNotIncludePkg=string.Empty;
public string strLvRecIncludePkg = string.Empty;
public int intCompanycount, SPNum;
public string strSpStartDt, strSpEndDt, strSpFreeMinPkg, strSpFrdOutCall,
strSpCallMeNotifiCall, strSpinternationalFax, intSPInternationalC2C;
public int intFreeMinutes, intInternationalCallMinutes,
intInternationalCallMeCallMinutes, intInternationalFaxPages, intInternationalC2C;
public rcw.PMIContactObjects.pmiCollection objLiveReceptionCollection = new
rcw.PMIContactObjects.pmiCollection();
public rcw.PMIContactObjects.pmiCollection objSPCollection = new
rcw.PMIContactObjects.pmiCollection();
public rcw.PMIContactObjects.pmiUsagefunctions objBillingUsage = new
pmiUsagefunctions();
Type objTypeBillingUsage = typeof(rcw.PMIContactObjects.pmiUsagefunctions);
public rcw.PMIContactObjects.pmiCollection objCompColl;
public Type ObjTypeUser=typeof(pmiUser);
public clsCommon objCommon = new clsCommon();
public bool blnIsBillingOrUsageLnkEnbl=false;
private int intIndexOfRndExt = 0;
private int intUserRatePlanID;
public string strHTTPS="";
public string strIsSecureSite="";
public string strCurrentHashKey=String.Empty;
public String strActionServerName=String.Empty;
protected void Page_Load(object sender, EventArgs e)
{
bool blnCompanyBilling = false;
string strActionFilePath;
string strPrevHashKey;
int intTemp;
int intRandom;
Random random = new Random();
UCMSession objUCMSession = new UCMSession();
strBrandPath = Convert.ToString(Session["ASPX_UserBrandPath"]); //Get
The Brand Path from Session
csslink.Href = strBrandPath + Convert.ToString(Session["ASPX_CSSName"]);
objUser = new pmiUser();
strUserKey = Convert.ToString(Session["Userkey"]);

checkIfBillingOrUsageLnkEnbl();
if(Convert.ToString(Request.ServerVariables["HTTPS"])=="off")
strIsSecureSite = "0";
else
strIsSecureSite = "1";

try
{
// Initialize Hash key so it has a value. This is important so
single users being billed get a hash key.
UCMHashKeyValidation csHashKeyValidation = new
UCMHashKeyValidation();
csHashKeyValidation.CreateHashKey(csHashKeyValidation.GENERICHash,
Convert.ToString(Session["userkey"]));
strCurrentHashKey = csHashKeyValidation.hash;
strPrevHashKey = csHashKeyValidation.hashprev;

//----------------------------Individuals Usages
Summary-------------------------------------
DisplaySubscriberUsage(strUserKey, "");
fnCalculateLiveReceptionMinutes(strUserKey, "12/31/1959 00:00:00");
//---------------------------Company Usage
--------------------------------------------------
objCompColl =
(rcw.PMIContactObjects.pmiCollection)ObjTypeUser.InvokeMember("GetAdministeredCompa
nies", BindingFlags.InvokeMethod, null, objUser, new object[] { strUserKey });
//---------------------------SP Usage
-------------------------------------------------------
objSPCollection =
(rcw.PMIContactObjects.pmiCollection)ObjTypeUser.InvokeMember("GetAdministeredSPs",
BindingFlags.InvokeMethod, null, objUser, new object[] { strUserKey });
//-------------------------------------------------------------------
-------------------------
if ((blnIsBillingOrUsageLnkEnbl) ||
((Convert.ToBoolean(Session["CoBrandFeaturesFindMeFollowMe"]) &&
Convert.ToBoolean(Session["CoBrandFeatureTUI_CallerAccess"])) ||

(Convert.ToBoolean(Session["CoBrandFeatureVoiceMessageAccess"]) &&
Convert.ToBoolean(Session["CoBrandFeatureTUI_CallerAccess"])) ||
(Convert.ToBoolean(Session["CoBrandFeatureInboundFax"]))) )
{
LoadRndExtender("divRoundedIndividual");
}
if (blnIsBillingOrUsageLnkEnbl)
{
//LoadRndExtender("divRoundedIndUsageSummary");
}
//-----------------------------------------------All COMPANY
----------------------------------------------------
int intIndexOfCompSP = 0;
strActionServerName=Request.ServerVariables["SERVER_NAME"];
foreach (string objCompany in objCompColl)
{
intIndexOfCompSP++;
strCompanyKey = objCompany.Split('~')[0];
DisplayCompanyUsage(strCompanyKey);
HtmlTableRow objTabCompHeaderRow = new HtmlTableRow();
HtmlTableCell objTabCompHeaderCell = new HtmlTableCell();
objTabCompHeaderCell.Attributes["class"] = "header_text1";
objTabCompHeaderCell.Align = "left";
objTabCompHeaderCell.InnerHtml =
"<br>&nbsp;&nbsp;&nbsp;&nbsp;Company: " + strCompanyName;
objTabCompHeaderRow.Cells.Add(objTabCompHeaderCell);
TBL_BillingUsage.Rows.Add(objTabCompHeaderRow);
HtmlTableRow objTabCompUsageRow = new HtmlTableRow();
HtmlTableCell objTabCompUsageCell = new HtmlTableCell();
Panel objPanelCompanyUsage = new Panel();
objPanelCompanyUsage.ID = "divRoundCompanyUsage" +
intIndexOfCompSP;
objPanelCompanyUsage.Style["width"] = "99%";
objPanelCompanyUsage.CssClass = "roundedPanel";
Label objlabelCompanyUsage = new Label();
objlabelCompanyUsage.Text = "<table width='100%' border='0'
cellspacing='0' cellpadding='0'>" +
"<tr>" +
"<td height='20' align='left'>&nbsp;&nbsp;&nbsp;&nbsp;<img
src='" + strBrandPath + "images/icon1.gif' width='6' alt='' height='8'/><a
href='./ASPXTOASP.ASPX?destpage=/content/CompanyLedger.asp?lstCompany=" +
strCompanyKey + "ASPX_ANDhdnAction=ChangeCompany'
onclick=\"javascript:LoadBillingUpdatePage('CompanyLedger.asp');\" target='_self'
class='link3'>View Billing History</a></td>" +
"</tr>" +
"<tr>" +
"<td height='20' align='left'>&nbsp;&nbsp;&nbsp;&nbsp;<img
src='" + strBrandPath + "images/icon1.gif' width='6' alt='' height='8'/><a
href='./ASPXTOASP.ASPX?destpage=/content/CompanyUsageSummary.asp?lstCompany=" +
strCompanyKey + "'
onclick=\"javascript:LoadBillingUpdatePage('CompanyUsageSummary.asp');\"
target='_self' class='link3'>View Current Usage </a></td>" +
"</tr>";
// ------------------------ Show link for Company Credit Card
Entry Screen-----------------------------
blnCompanyBilling=IsCompanyBillingInfoUpdatable(strCompanyKey);
csHashKeyValidation = new UCMHashKeyValidation();

csHashKeyValidation.CreateHashKey(csHashKeyValidation.GENERICHash,
Convert.ToString(Session["userkey"]));
strCurrentHashKey = csHashKeyValidation.hash;
strPrevHashKey = csHashKeyValidation.hashprev;

if (blnCompanyBilling)
{

strActionFilePath=Request.ServerVariables["PATH_INFO"];
intTemp = strActionFilePath.LastIndexOf("/");
if (intTemp < 2)
{
//No path in the URL.
strActionFilePath = "";
}
else
{
//Strip file name from URL path.
strActionFilePath = strActionFilePath.Substring(0,
intTemp);// left(strActionFilePath, intTemp);
}

strHTTPS = "https://" + strActionServerName +


"/net_olm/CompanyBillingInfo.aspx";
intRandom = random.Next(1000);
strHTTPS = strHTTPS + "?u=" + Session["userkey"] + "&h=" +
strCurrentHashKey + "&lstCompany=" + strCompanyKey + "&IsSecureSite=" +
strIsSecureSite + "&ShowBackToASPX=1&rnd=" + intRandom;
objlabelCompanyUsage.Text=objlabelCompanyUsage.Text+ "<tr>" +
"<td height='20' align='left'>&nbsp;&nbsp;&nbsp;&nbsp;<img
src='" + strBrandPath + "images/icon1.gif' width='6' alt='' height='8'/><a href='"
+ strHTTPS + "'
onclick=\"javascript:LoadBillingUpdatePage('CompanyBillingInfo.aspx');\"
target='_self' class='link3'>View Company Credit Card Entry Screen </a></td>" +
"</tr>" +
"</table>";
}
else
{
objlabelCompanyUsage.Text=objlabelCompanyUsage.Text+
"</table>";
}
objPanelCompanyUsage.Controls.Add(objlabelCompanyUsage);
objTabCompUsageCell.Controls.Add(objPanelCompanyUsage);
objTabCompUsageRow.Controls.Add(objTabCompUsageCell);
TBL_BillingUsage.Rows.Add(objTabCompUsageRow);
LoadRndExtender("divRoundCompanyUsage" + intIndexOfCompSP);
}

//-----------------------------------------------All
SP----------------------------------------------------
intIndexOfCompSP = 0;
foreach (string strSPItem in objSPCollection)
{
intIndexOfCompSP++;
SPNum = Convert.ToInt32(strSPItem.Split('~')[0]);
DisplaySPUsage(SPNum);
HtmlTableRow objTabSPHeaderRow = new HtmlTableRow();
HtmlTableCell objTabSPHeaderCell = new HtmlTableCell();
objTabSPHeaderCell.Attributes["class"] = "header_text1";
objTabSPHeaderCell.Align = "left";
objTabSPHeaderCell.InnerHtml = "<br>&nbsp;&nbsp;&nbsp;&nbsp;SP: "
+ strSPItem.Substring((strSPItem.IndexOf("~") + 1));
objTabSPHeaderRow.Cells.Add(objTabSPHeaderCell);
TBL_BillingUsage.Rows.Add(objTabSPHeaderRow);
HtmlTableRow objTabSPUsageRow = new HtmlTableRow();
HtmlTableCell objTabSPUsageCell = new HtmlTableCell();
Panel objPanelSPUsage = new Panel();
objPanelSPUsage.ID = "divRoundSPUsage" + intIndexOfCompSP;
objPanelSPUsage.Style["width"] = "99%";
objPanelSPUsage.CssClass = "roundedPanel";
Label objlabelSPUsage = new Label();
objlabelSPUsage.Text = "<table width='100%' cellspacing='0'
cellpadding='0'>" +
"<tr>" +
"<td height='20' align='left'>&nbsp;&nbsp;&nbsp;&nbsp;<img
src='" + strBrandPath + "images/icon1.gif' width='6' alt='' height='8'/><a
href='./ASPXTOASP.ASPX?destpage=/content/SPLedger.asp?lstSP=" + SPNum +
"ASPX_ANDhdnAction=ChangeSP'
onclick=\"javascript:LoadBillingUpdatePage('SPLedger.asp');\" target='_self'
class='link3'>View Billing History</a></td>" +
"</tr>" +
"<tr>" +
"<td height='20' align='left'>&nbsp;&nbsp;&nbsp;&nbsp;<img
src='" + strBrandPath + "images/icon1.gif' width='6' alt='' height='8'/><a
href='./ASPXTOASP.ASPX?destpage=/content/SPUsageSummary.asp?lstSP=" + SPNum + "'
onclick=\"javascript:LoadBillingUpdatePage('SPUsageSummary.asp');\"
class='link3'>View Current Usage</a></td>" +
"</tr>" +
"</table>";
objPanelSPUsage.Controls.Add(objlabelSPUsage);
objTabSPUsageCell.Controls.Add(objPanelSPUsage);
objTabSPUsageRow.Controls.Add(objTabSPUsageCell);
TBL_BillingUsage.Rows.Add(objTabSPUsageRow);
LoadRndExtender("divRoundSPUsage" + intIndexOfCompSP);
//=============================================================
}
MakeDivRounded();
}
catch(Exception ex)
{
Response.Write("Unexpected error...");
Response.End();
}
}

public void LoadRndExtender(string getThisDiv)


{
AjaxControlToolkit.RoundedCornersExtender objRndCornerExt = new
AjaxControlToolkit.RoundedCornersExtender();
objRndCornerExt.TargetControlID = getThisDiv;
intIndexOfRndExt++;
objRndCornerExt.BehaviorID = "ExtBhvId" + intIndexOfRndExt;
objRndCornerExt.Corners = AjaxControlToolkit.BoxCorners.All;
RoundedCornerPanel.Controls.Add(objRndCornerExt);
}

private void MakeDivRounded()


{
string strJsScript = string.Empty;
strJsScript = "function pageLoad(sender, args){" +
"var counter; var controlBehaver;" +
"for(counter=1;counter<=" + intIndexOfRndExt + ";counter++){" +
"controlBehaver='ExtBhvId'+counter;"+

"setAjaxRoundedCornerBorderColorForDiv(controlBehaver,'.roundedPanel')}}";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "RefreshMap",
strJsScript, true);
}

private void checkIfBillingOrUsageLnkEnbl()


{
// ----------------------- Check if "Billing History and Current Usage
--------------------
if (Convert.ToBoolean(Session["CoBrandFeatureViewBillingHistory"]))
{
if (!(Convert.ToBoolean(Session["BillingDisabled"])))
{
pmiCompany objCompanyInfo = new pmiCompany();
Type ObjTypeCompany = typeof(pmiCompany);
ObjTypeCompany.InvokeMember("GetCompany",
BindingFlags.InvokeMethod, null, objCompanyInfo, new object[]
{ Session["Companykey"], "", false, "" });
if (!(objCompanyInfo.SummaryBilling))
{
pmiServiceProvider objSPInfo = new pmiServiceProvider();
Type objTypeServiceProvider =
typeof(rcw.PMIContactObjects.pmiServiceProvider);
objTypeServiceProvider.InvokeMember("GetSP",
BindingFlags.InvokeMethod, null, objSPInfo, new object[]
{ objCompanyInfo.get_SPNum() });

if (!(objSPInfo.SummaryBilling))
{
blnIsBillingOrUsageLnkEnbl = true;
}
}
}
}
//-------------------------------------------------------------------------
----------------
}

public void DisplayCompanyUsage(string CompanyKey)


{
string sBillingDate = "12/31/1959 00:00:00";
rcw.PMIContactObjects.pmiRatePlan objRatePlan = new pmiRatePlan();
rcw.PMIContactObjects.pmiCompany objCompany = new pmiCompany();
Type ObjTypeCompany = typeof(pmiCompany);
rcw.pmiFormat.pmiFormatter FormatObj = new pmiFormatter();
Type objTypeFormat = typeof(pmiFormatter);
rcw.PMIContactObjects.pmiCompanyOverage objOverageSummary = new
pmiCompanyOverage();
Type objTypeCompanyOverage = typeof(pmiCompanyOverage);
ObjTypeCompany.InvokeMember("GetCompanyBasicsOnly",
BindingFlags.InvokeMethod, null, objCompany, new object[] { CompanyKey });
ObjTypeCompany.InvokeMember("GetCompanyBillingInfo",
BindingFlags.InvokeMethod, null, objCompany, new object[] { CompanyKey });
objTypeCompanyOverage.InvokeMember("GetCompanyUsageSummary",
BindingFlags.InvokeMethod, null, objOverageSummary, new object[] { CompanyKey,
sBillingDate });
Session["BillStartDate"] = objOverageSummary.BillStartDate;
Session["BillEndDate"] = objOverageSummary.BillEndDate;
strCompanyName = objCompany.CompanyName;
strBillStartDate = (string)objTypeFormat.InvokeMember("pmiFormat",
BindingFlags.InvokeMethod, null, FormatObj, new object[]
{objOverageSummary.BillStartDate, "MMM DD YYYY"});
strBillEndDate = (string)objTypeFormat.InvokeMember("pmiFormat",
BindingFlags.InvokeMethod, null, FormatObj, new object[]
{ objOverageSummary.BillEndDate.AddDays(-1), "MMM DD YYYY" });
intFreeMinutes = objOverageSummary.FreeMinutes;
intInternationalCallMinutes = objOverageSummary.InternationalCallMinutes;
intInternationalCallMeCallMinutes =
objOverageSummary.InternationalCallMeCallMinutes;
intInternationalFaxPages = objOverageSummary.InternationalFaxPages;
intInternationalC2C = objOverageSummary.InternationalC2CMinutes;
System.Runtime.InteropServices.Marshal.ReleaseComObject(objRatePlan);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objCompany);
System.Runtime.InteropServices.Marshal.ReleaseComObject(FormatObj);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objOverageSummary);
}

public void DisplaySPUsage(int SPNum)


{
string strBillingDate = "12/31/1959 00:00:00";
rcw.PMIContactObjects.pmiCollection objPmiCollection;
rcw.PMIContactObjects.pmiRatePlan objRatePlan = new pmiRatePlan();
Type objTypeRatePlan = typeof(rcw.PMIContactObjects.pmiRatePlan);
rcw.PMIContactObjects.pmiServiceProvider objServiceProvider = new
pmiServiceProvider();
Type objTypeServiceProvider =
typeof(rcw.PMIContactObjects.pmiServiceProvider);
rcw.pmiFormat.pmiFormatter ObjFormat = new pmiFormatter();
Type objTypeFormat = typeof(pmiFormatter);
rcw.PMIContactObjects.pmiSPOverage objSPOverage = new pmiSPOverage();
Type objTypeSPOverage = typeof(rcw.PMIContactObjects.pmiSPOverage);
rcw.PMIContactObjects.pmiUsagefunctions objUsagefunctions = new
pmiUsagefunctions();
Type objTypeUsagefunctions =
typeof(rcw.PMIContactObjects.pmiUsagefunctions);
objTypeServiceProvider.InvokeMember("GetSP", BindingFlags.InvokeMethod,
null, objServiceProvider, new object[] { SPNum });
objTypeServiceProvider.InvokeMember("GetSPBillingInfo",
BindingFlags.InvokeMethod, null, objServiceProvider, new object[] { SPNum });
objTypeSPOverage.InvokeMember("GetSPUsageSummary",
BindingFlags.InvokeMethod, null, objSPOverage, new object[] { SPNum, strBillingDate
});
objPmiCollection =
(rcw.PMIContactObjects.pmiCollection)objTypeUsagefunctions.InvokeMember("GetSPUsage
BreakupByCompanies", BindingFlags.InvokeMethod, null, objUsagefunctions, new
object[] { SPNum, strBillingDate, 9 });
objTypeRatePlan.InvokeMember("GetRatePlan", BindingFlags.InvokeMethod,
null, objRatePlan, new object[] { objServiceProvider.RatePlanID });
Session["BillStartDate"] = objSPOverage.BillStartDate;
Session["BillEndDate"] = objSPOverage.BillEndDate;
strSpStartDt = Convert.ToString(objTypeFormat.InvokeMember("pmiFormat",
BindingFlags.InvokeMethod, null, ObjFormat, new object[]
{ objSPOverage.BillStartDate, "MMM DD YYYY" }));
strSpEndDt = Convert.ToString(objTypeFormat.InvokeMember("pmiFormat",
BindingFlags.InvokeMethod, null, ObjFormat, new object[]
{ objSPOverage.BillEndDate.AddDays(-1), "MMM DD YYYY" }));
strSpFreeMinPkg = Convert.ToString(objSPOverage.FreeCallAmount);
strSpFrdOutCall = Convert.ToString(objSPOverage.InboundCallMinutes);
strSpCallMeNotifiCall =
Convert.ToString(objSPOverage.InternationalCallMeCallMinutes);
strSpinternationalFax = Convert.ToString(objSPOverage.InboundFaxPages);
intSPInternationalC2C =
Convert.ToString(objSPOverage.InternationalC2CMinutes);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objPmiCollection);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objRatePlan);

System.Runtime.InteropServices.Marshal.ReleaseComObject(objServiceProvider);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ObjFormat);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objSPOverage);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objUsagefunctions);
}

private void DisplaySubscriberUsage(string UserKey, string CompanyKey)


{
long lngUsageMinutes = 0;
pmiOutboundCallColl objpmiOutboundCallColl = new pmiOutboundCallColl();
rcw.PMIContactObjects.pmiCollection objpmiCollection = new
rcw.PMIContactObjects.pmiCollection();
string sBillingDate = "12/31/1959 00:00:00";
DateTime sStartDate, sEndDate;
pmiUser objUser = new rcw.PMIContactObjects.pmiUser();
Type ObjTypeUser = typeof(rcw.PMIContactObjects.pmiUser);
rcw.pmiFormat.pmiFormatter ObjFormat = new pmiFormatter();
Type objTypeFormat = typeof(pmiFormatter);
rcw.PMIContactObjects.pmiRatePlan objRatePlan = new pmiRatePlan();
Type objTypeRatePlan = typeof(rcw.PMIContactObjects.pmiRatePlan);
ObjTypeUser.InvokeMember("GetUser", BindingFlags.InvokeMethod, null,
objUser, new object[] { UserKey });

//====================FreeMinutes==================================================
=====================
intUserRatePlanID = objUser.RatePlanID;
if (intUserRatePlanID > 0)
{
objTypeRatePlan.InvokeMember("GetRatePlan", BindingFlags.InvokeMethod,
null, objRatePlan, new object[] { intUserRatePlanID });
lblFreeMinPkg.Text = Convert.ToString(objRatePlan.FreeCallminutes);
}
//====================Forward & Outgoing Calls -
International===================================================
lblFrdOutCall.Text =
fnCalculateBillingMinutes("GetInternationalCallDetails", UserKey, sBillingDate);
//====================CallMe Notification Calls -
International==================================================
lblCallMeNotifiCall.Text =
fnCalculateBillingMinutes("GetInternationalCallMeCallDetails", UserKey,
sBillingDate);
//==================== Click to call International Minute
=======================================================
double dblC2CInternMin=0;
objpmiCollection =
(rcw.PMIContactObjects.pmiCollection)objTypeBillingUsage.InvokeMember("GetInternati
onalC2CDetails", BindingFlags.InvokeMethod, null, objBillingUsage, new object[]
{UserKey, sBillingDate});
foreach (pmiCallDetails objC2CDetails in objpmiCollection)
{
if (objCommon.fnIsDate(Convert.ToString(objC2CDetails.StartTime)) &&
objCommon.fnIsDate(Convert.ToString(objC2CDetails.EndTime)))
{
dblC2CInternMin = dblC2CInternMin +
(double)Math.Ceiling(DateTimeUtil.DateDiff("s",
Convert.ToDateTime(objC2CDetails.StartTime),
Convert.ToDateTime(objC2CDetails.EndTime))/60.0);
}
}
lblC2CIntCallMin.Text = Convert.ToString(dblC2CInternMin);
//====================Outgoing International Faxes(pages)============
lngUsageMinutes = 0;
objpmiCollection =
(rcw.PMIContactObjects.pmiCollection)objTypeBillingUsage.InvokeMember("GetInternati
onalFaxDetails", BindingFlags.InvokeMethod, null, objBillingUsage, new object[]
{ UserKey, sBillingDate });
foreach (pmiFaxDetails objpmiFaxDetails in objpmiCollection)
{
if (objpmiFaxDetails.FaxStatusCode == 6)
{
lngUsageMinutes = lngUsageMinutes +
Convert.ToInt64(objpmiFaxDetails.FaxPages);
}
}
lblinternationalFax.Text = Convert.ToString(lngUsageMinutes);
//=======================================================
if (CompanyKey != "")
{
Response.Write("<br />No Company Usage...<br />");
rcw.PMIContactObjects.pmiCompanyOverage objOverageSummary = new
pmiCompanyOverage();
Type objTypeCompanyOverage =
typeof(rcw.PMIContactObjects.pmiCompanyOverage);
objTypeCompanyOverage.InvokeMember("GetCompanyUsageSummary",
BindingFlags.InvokeMethod, null, objOverageSummary, new object[] { CompanyKey,
sBillingDate });

sStartDate = objOverageSummary.BillStartDate;
sEndDate = objOverageSummary.BillEndDate.AddDays(-1);

System.Runtime.InteropServices.Marshal.ReleaseComObject(objOverageSummary);
}
else
{ //if end date ends up prior to now then we need to add a month to
EndDate and StartDate
sEndDate =
Convert.ToDateTime(objUser.DateAdded).AddMonths(Convert.ToInt32(DateTimeUtil.DateDi
ff("m", Convert.ToDateTime(objUser.DateAdded), DateTime.Now)));
sEndDate = sEndDate.AddDays(-1);
sEndDate = Convert.ToDateTime(objTypeFormat.InvokeMember("pmiFormat",
BindingFlags.InvokeMethod, null, ObjFormat, new object[] { sEndDate,
"mm/dd/yyyy" }));
sEndDate = sEndDate.AddHours(23).AddMinutes(59).AddSeconds(59);
if (DateTimeUtil.DateDiff("d", DateTime.Now, sEndDate) >= 0)
{
sStartDate =
Convert.ToDateTime(objUser.DateAdded).AddMonths(Convert.ToInt32(DateTimeUtil.DateDi
ff("m", Convert.ToDateTime(objUser.DateAdded), DateTime.Now)) - 1);
sEndDate =
Convert.ToDateTime(objUser.DateAdded).AddMonths(Convert.ToInt32(DateTimeUtil.DateDi
ff("m", Convert.ToDateTime(objUser.DateAdded), DateTime.Now)));
}
else
{
sEndDate =
Convert.ToDateTime(objUser.DateAdded).AddMonths(Convert.ToInt32(DateTimeUtil.DateDi
ff("m", Convert.ToDateTime(objUser.DateAdded), DateTime.Now)) + 1);
sStartDate =
Convert.ToDateTime(objUser.DateAdded).AddMonths(Convert.ToInt32(DateTimeUtil.DateDi
ff("m", Convert.ToDateTime(objUser.DateAdded), DateTime.Now)));
}
}
lblStartDt.Text = Convert.ToString(objTypeFormat.InvokeMember("pmiFormat",
BindingFlags.InvokeMethod, null, ObjFormat, new object[] { sStartDate, "MMMM DD
YYYY" }));
if (CompanyKey == "")
{
lblEndDt.Text =
Convert.ToString(objTypeFormat.InvokeMember("pmiFormat", BindingFlags.InvokeMethod,
null, ObjFormat, new object[] { sEndDate.AddDays(-1), "MMMM DD YYYY" }));
}
else
{
lblEndDt.Text =
Convert.ToString(objTypeFormat.InvokeMember("pmiFormat", BindingFlags.InvokeMethod,
null, ObjFormat, new object[] {sEndDate, "MMMM DD YYYY" }));
}

System.Runtime.InteropServices.Marshal.ReleaseComObject(objpmiOutboundCallColl);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objpmiCollection);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objUser);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ObjFormat);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objRatePlan);
}

public string fnCalculateBillingMinutes(string pMethodName, string pUserKey, string


pBillingDate)
{
long lngMinutes=0;
pmiOutboundCallColl objpmiOutboundCallColl = new pmiOutboundCallColl();

objpmiOutboundCallColl =
(pmiOutboundCallColl)objTypeBillingUsage.InvokeMember(pMethodName,
BindingFlags.InvokeMethod, null, objBillingUsage, new object[] { pUserKey,
pBillingDate });
foreach (pmiOutboundCall objpmiOutboundCall in objpmiOutboundCallColl)
{
if
(objCommon.fnIsDate(Convert.ToString(objpmiOutboundCall.OutboundCallStart)) &&
objCommon.fnIsDate(Convert.ToString(objpmiOutboundCall.OutboundCallEnd)))
{
lngMinutes = lngMinutes +
Convert.ToInt64(Math.Ceiling(DateTimeUtil.DateDiff("s",
objpmiOutboundCall.OutboundCallStart, objpmiOutboundCall.OutboundCallEnd) / 60.0));
}
}

System.Runtime.InteropServices.Marshal.ReleaseComObject(objpmiOutboundCallColl);
return Convert.ToString(lngMinutes);
}

public void fnCalculateLiveReceptionMinutes(string pUserKey, string


pBillingDate)
{
rcw.PMIContactObjects.pmiRatePlan objRatePlan = new pmiRatePlan();
Type objTypeRatePlan = typeof(rcw.PMIContactObjects.pmiRatePlan);
double dblLiveRec = 0;
objTypeRatePlan.InvokeMember("GetRatePlan", BindingFlags.InvokeMethod,
null, objRatePlan, new object[] { intUserRatePlanID });
objLiveReceptionCollection =
(rcw.PMIContactObjects.pmiCollection)objTypeBillingUsage.InvokeMember("GetLiveRecep
tionistCallDetails", BindingFlags.InvokeMethod, null, objBillingUsage, new object[]
{ pUserKey, pBillingDate});

if (objRatePlan.LiveReceptionistFreeMinutes > 0)
{
strLvRecIncludePkg = "<tr><td class='bodytext_5' align='left'><table
border='0' width='100%'><tr><td style='width:60%;'>Live Receptionist Minutes
included in Package:&nbsp;&nbsp;</td><td><label ID='lblLiveReception'>" +
objRatePlan.LiveReceptionistFreeMinutes + "</Label></td></tr></table>" +
"</td></tr>";
if (objRatePlan.LiveReceptionistRate>0)
{
if (objLiveReceptionCollection.Count==0)
{
strLvRecNotIncludePkg = "<tr><td class='bodytext_5'
align='left'><table border='0' width='100%'><tr><td style='width:60%;'>Live
Receptionist Calls (minutes):</td><td><label
ID='lblLiveReception'>0</Label></td></tr></table></td></tr>";
}
else if(objLiveReceptionCollection.Count>0)
{
foreach(pmiLiveReceptCall objLvRecCall in
objLiveReceptionCollection)
{
if
(objCommon.fnIsDate(Convert.ToString(objLvRecCall.Time_Presented)) &&
objCommon.fnIsDate(Convert.ToString(objLvRecCall.Time_Completed)))
{
dblLiveRec = dblLiveRec +
(double)Math.Ceiling(DateTimeUtil.DateDiff("s",
Convert.ToDateTime(objLvRecCall.Time_Presented),
Convert.ToDateTime(objLvRecCall.Time_Completed)) / 60.0);
}
}
strLvRecNotIncludePkg = "<tr><td class='bodytext_5'
align='left'><table border='0' width='100%'><tr><td style='width:60%;'>Live
Receptionist Calls (minutes):</td><td><label ID='lblLiveReception'>" + dblLiveRec +
"</Label></td></tr></table></td></tr>";
}
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(objRatePlan);
}

private bool IsCompanyBillingInfoUpdatable(string CompanyKey)


{
bool blnReturn=false;
bool blnChkSummaryBilling=false;
string strPaymentMethod, strErrMsg="";
rcw.PMIContactObjects.pmiCompany objCompany = new pmiCompany();
Type ObjTypeCompany = typeof(pmiCompany);
ObjTypeCompany.InvokeMember("GetCompany", BindingFlags.InvokeMethod, null,
objCompany, new object[] { CompanyKey, strErrMsg, true, "" });
blnChkSummaryBilling=objCompany.SummaryBilling;
strPaymentMethod = objCompany.get_PaymentMethod();
ObjTypeCompany.InvokeMember("GetCompanyBillingInfo",
BindingFlags.InvokeMethod, null, objCompany, new object[] {CompanyKey});
if (blnChkSummaryBilling && (strPaymentMethod.ToLower().Trim()=="cc"))
{
blnReturn=true;
}
return blnReturn;
}

//GLOBAL

public bool IsNumber(string input)


{
foreach (char c in input)
{
if (!char.IsNumber(c)) return false;
}
return true;
}
}

Anda mungkin juga menyukai