File1

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View File1 as PDF for free.

More details

  • Words: 18,913
  • Pages: 137
/* * file name: cgroupcomponent.cs * author: shibli mohammad arafat * date: 4th of july, 2005 * * description: * * modification history: * name date * ahmed saady yaamin 8th november,2005 * * * version: 1.0 * copyright (c) 2004: groupcare a/s. */ using system; using system.collections; using system.collections.generic; using system.text; using system.xml.serialization; using system.reflection; using using using using using using using using

groupcare.common; groupcare.common.util; groupcare.common.entity; groupcare.common.entity.group; groupcare.common.entity.component; groupcare.common.entity.permission; groupcare.services.settings; groupcare.services.notification;

using groupcare.component; using groupcare.component.util; using groupcare.components.basegroup; using groupcare.common.logcontainer; using groupcare.services.audit; using groupcare.services.language; using groupcare.services.license; using groupcare.services.permission; using groupcare.services.caching; //using groupcare.services.invitation; using groupcare.common.entity.invitation; using groupcare.services.ems; using groupcare.services.history; using groupcare.common.dalbase; using groupcare.common.dalbroker; using groupcare.common.orfilter; using groupcare.common.exceptions; using groupcare.common.exceptions.business; using groupcare.common.entity.solution; using groupcare.services.dataflexibility; namespace groupcare { namespace components {

desc refreshing the code

namespace group { /// <summary> /// this is one of the components of groupcare solution, which provides all the /// functionalities of group component mentioned in the design. the functions /// are implemented here. it inherits ccomponentbase and implements igroupcomponent /// interface. /// public class cgroupcomponent : cbasegroupcomponent, igroupcomponent { protected cgroupelement m_orootgroup;

class

#region constructors /// <summary> /// default constructor which calls the constructor of its base

/// public cgroupcomponent() : base() { m_odaobase = cdalhandler.getdaobject(); this.componentelement.componenttype = m_ocomponentutil.getcomonenttypebyname("group"); //this.loadrootgroup(); } #endregion #region methods /// <summary> /// this method is use to create group. /// /// <param name="ogroupelement">this parameter define the group that suppose to create /// <param name="ocomponentelementbase">this paramer define the parant of the creating group /// <param name="ouser">this parameter define the owner of the group /// <param name="oinfo"> public void creategroup(cgroupelement ogroupelement, ccomponentelementbase ocomponentelementbase, cuser ouser, out cinfo oinfo) { this.parent = this.loadcomponent(ocomponentelementbase.id); creategroup(ogroupelement, ouser, out oinfo); } /// <summary> /// this methode is use to create the group. /// /// <param name="ogroupelement">this parameter define the group that suppose to create /// <param name="ouser">this parameter define the owner of the group /// <param name="oinfo"> public void creategroup(cgroupelement ogroupelement, cuser ouser,

out cinfo oinfo) {

creategroup(ogroupelement, ouser, ouser, out

oinfo);

} /// <summary> /// this method will save a group information in the database /// /// <param name="ogroupelement"> /// the group element which is being saved by this method /// /// <param name="ouser"> /// the user who is creating the group /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public void creategroup(cgroupelement ogroupelement, cuser oadminuser, cuser ouser, out cinfo oinfo) { bool bisalertexception = false; oinfo = new cinfo(); try { if (ogroupelement.type.equals(((int)egrouptype.personal).tostring()) == false && getexistinggroup(ogroupelement)) { oinfo.phraseidlist.add("groupnameoremail"); oinfo.issuccess = false; } else { if (ogroupelement.parentgroup == null) { this.loadrootgroup(); ogroupelement.parentgroup = m_orootgroup; } csettingsdatamodelcollection osettingscollection = creategroupsettings(ogroupelement, ouser, out oinfo); string spermissionname = null; string salertnamecreate = null; string selseventcreate = null; string salertnamejoin = null; string selseventjoin = null; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { spermissionname = ccommonconstant.cscreategroup; selseventcreate = ccommonconstant.csactioncreatebasegroup;//"creategroup"; selseventjoin =

ccommonconstant.csactionjoinbasegroup; //"joingroup"; salertnamejoin = ccommonconstant.csemailalertscreategroupmembership; if (ogroupelement.parentgroup.id != guid.empty) { salertnamecreate = ccommonconstant.csemailalertscreategroup; } } base.createcomponent(ogroupelement, spermissionname, salertnamecreate, selseventcreate, salertnamejoin, selseventjoin, osettingscollection, oadminuser, ouser, out oinfo); if (oinfo.issuccess) { if (!ouser.id.equals(oadminuser.id)) setgroupincache(ogroupelement, oadminuser, false); else setgroupincache(ogroupelement, oadminuser, true); } } } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".creategroup()", oex); } } /// <summary> /// this method is used to detail a group /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> /// public cgroupelement getgroup(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { return this.getgroup(ogroupelement, true, ouser, out oinfo); } /// <summary> /// this method retrieves a group element from database /// /// <param name="ogroupelement"> /// the group element with some filters whith which the group element will be retrieved /// from database /// /// <param name="ouser"> /// the user who is retrieving the group element /// /// <param name="oinfo"> /// the object which will keep the information of whether the

operation is successful /// or not and will also have the language information /// /// /// it returns a group element object /// protected cgroupelement getgroup(cgroupelement ogroupelement, bool bretrivecustomfield, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelementcollection ogroupelementlist = null; cgroupelement oretgroupelement = null; ogroupelement.filterlist.clear(); try { ///commented by milton //cpermissionmanager opermissionmanager = cpermissionmanager.instance; //if (!opermissionmanager.haspermission(this, ccommonconstant.csreadgroup, ouser)) //{ // oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no_permission); // oinfo.issuccess = false; // caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); // cexceptionbase oexp = new cexceptionbase("permission denied"); // oexp.data.add("sender", this.tostring() + ".getgroup()"); // oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); // oexp.data.add("errorcode", cerrorcodes.pm_permission_denied_exception); // throw oexp; //} adaobase odao = cdalhandler.getdaobject(); ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_detail; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "id"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { ogroupelement.id }; ofilter.filteroperator = efilteroperator.equal; // adding filter to the filter list ofilterlist.addfilter(ofilter); // setting filter to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) {

if (oresult.issuccess) { // if the result is successful getting the result data

ogroupelementlist = (cgroupelementcollection)oresult.data; if (null != ogroupelementlist) { // if the data is not null if (ogroupelementlist.count > 0) { // if the collection contains any data // gets the data from the first index oinfo.issuccess = true; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); ogroupelementlist[0];

if (!bretrivecustomfield) return

cgroupelementcollection otempgroupelementlist = new cgroupelementcollection(); otempgroupelementlist.add(ogroupelementlis t[0]); object[] oparam = new object[4]; oparam[0] = "group"; oparam[1] = otempgroupelementlist; oparam[2] = ouser; oparam[3] = oinfo; type otypec = type.gettype("groupcare.services.dataflexibility.ccustomfieldmanager,gc.services.d ataflexibility"); object objc = activator.createinstance(otypec, false); try { //dictionary diccustomfldentity = (dictionary)otypec.invokemember("getcustomfield", bindingflags.invokemethod, null, objc, oparam); dictionary diccustomfldentity = (dictionary)utils.invokemember(otypec,"getcustomfield", bindingflags.invokemethod, null, objc, oparam); if (diccustomfldentity.containskey(((cgroupelement)ogroupelementlist[0]).id)) { centity oentity = (centity)diccustomfldentity[((cgroupelement)ogroupelementlist[0]).id]; if (oentity != null) { for (int j = 0; j < oentity.fieldcategories.count; j++)

{ cfieldcategory ofieldcategory = (cfieldcategory)oentity.fieldcategories[j]; if (ofieldcategory.customfields.count > 0) { for (int i = 0; i < ofieldcategory.customfields.count; i++) { ogroupelementlist[ 0].customfields.add((ccustomfield)ofieldcategory.customfields[i]); } } } } } } catch { } oretgroupelement = ogroupelementlist[0]; } else { oinfo.issuccess = false; smessage = "no data found on the request"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.information); } } else { oinfo.issuccess = false; smessage = "the data retrieved from the database is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.information); } } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } // } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgroup()",

obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgroup()", oex); } finally { ogroupelement.filterlist.clear(); } if (null == oretgroupelement) { oinfo.phraseidlist.add(cgroupcomponentconstant.csgr_delete

_group);

}

oinfo.issuccess = false;

return oretgroupelement; } /// <summary> /// this method retrieves the group element list form the database /// /// <param name="ogroupelement"> /// the goup element whith some filters with which the group list is retrieved form /// the database /// /// <param name="ouser"> /// the user who is retrieving the group element list /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// /// /// it returns a list of group element /// public cgroupelementcollection getgrouplist(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelementcollection ogroupelementlist = null; ogroupelement.filterlist.clear(); try { //// gets the instance of cpermissionmanager cpermissionmanager opermissionmanager = cpermissionmanager.instance; //// checking permission //if (!opermissionmanager.haspermission(this, ccommonconstant.csreadgroup, ouser)) //{ // oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no_permission);

// oinfo.issuccess = false; // caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); // cexceptionbase oexp = new cexceptionbase("permission denied"); // oexp.data.add("sender", this.tostring() + ".getgrouplist()"); // oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); // oexp.data.add("errorcode", cerrorcodes.pm_permission_denied_exception); // throw oexp; //} //if (opermissionmanager.haspermission(this, cgroupcomponentconstant.get_group_list, ouser)) //{ // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_basic; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "id"; ofilter.propertyname = spropertyname; string squery = " (select componentid from gc_componentuser where status= " + (int)ecomponentuserstatus.joined + " and userid='" + ouser.id + "')"; ofilter.valuelist = new object[] { squery }; ofilter.filteroperator = efilteroperator.in; ofilter.valueiscustomquery = true; // adding first filter to the filter list ofilterlist.addfilter(ofilter); // setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data; // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug);

group list is null";

} } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving

caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } //} //else //{ // oinfo.issuccess = false; // smessage = "the user " + ouser.name + " does not have permission to retrieve group."; // caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); //} } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgrouplist()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgrouplist()", oex); } }

database

/// /// /// /// /// /// /// ///

return ogroupelementlist; <summary> this method updates the group element in the database <param name="ogroupelement"> the group element with which the group element will be updated <param name="ouser"> the user who is requesting for updating group element in the

/// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public void updategroup(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); ogroupelement.filterlist.clear(); try {

if (ogroupelement.type.equals(((int)egrouptype.personal).tostring()) == false && getexistinggroup(ogroupelement)) { oinfo.phraseidlist.add("groupnameoremail"); oinfo.issuccess = false; } else { string spermissionname = ccommonconstant.csupdategroup; string salertnameupdate = ccommonconstant.csemailalertsupdategroup; string selseventupdate = null; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { selseventupdate = ccommonconstant.csactionupdatebasegroup;//"updategroup"; } //cinfo otinfo; //base.updatecomponent(getgroup(ogroupelement, false, ouser, out otinfo), spermissionname, cgroupcomponentconstant.action_update_detail, salertnameupdate, selseventupdate, ouser, out oinfo); base.updatecomponent(ogroupelement, spermissionname, cgroupcomponentconstant.action_update_detail, salertnameupdate, selseventupdate, ouser, out oinfo);

oinfo);

if (oinfo.issuccess) { updategroupcache(ogroupelement, ouser); handlecustomfield(ogroupelement, ouser, out }

} } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".updategroup()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".updategroup()", oex); } } /// <summary> /// this is used for update the root folder name. /// /// <param name="sgroupname"> protected void updaterootfoldername(string sgroupname) { if (this.childcomponentlist.count > 0)

{ foreach (ccomponentelementbase ocompelement in this.childcomponentelements) { if (ocompelement.componenttype.name.equals(cmodulenames.filearchive)) { ccomponentbase ochildcompbase = (ccomponentbase)this.childcomponentlist[ocompelement.id]; ochildcompbase.onupdate(); } } } } /// <summary> /// this method is use to update basic information of a group /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> public void updategroupbasic(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; ogroupelement.filterlist.clear(); try { //// gets the instance of cpermissionmanager cpermissionmanager opermissionmanager = cpermissionmanager.instance; //// checking permission if (!opermissionmanager.haspermission(this, ccommonconstant.csupdategroup, ouser)) { oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".updategroupbasic()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } if (ogroupelement.type.equals(((int)egrouptype.personal).tostring()) == false && getexistinggroup(ogroupelement)) { oinfo.phraseidlist.add("groupnameoremail"); oinfo.issuccess = false;

} else { //if (opermissionmanager.haspermission(this, cgroupcomponentconstant.get_group, ouser)) //{ // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_update_basic; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "id"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { ogroupelement.id }; ofilter.filteroperator = efilteroperator.equal; ofilterlist.addfilter(ofilter); ofilter = new cfilter(); ofilter.propertyname = "gc_folder.parentfolderid"; object[] o = new object[1]; o[0] = "'" + guid.empty + "' and foldertype='main' and componentid in (select componentid from gc_componentrelation where parentcomponentid ='"+ ogroupelement.id +"')"; ofilter.valuelist = o; ofilter.queryindex = 1; ofilter.filteroperator = efilteroperator.equal; ofilter.iscustomproperty = true; ofilter.isfiltergivenasquery = true; ofilterlist.add(ofilter); ofilter = new cfilter(); ofilter.propertyname = "id"; o = new object[1]; o[0] = "'" + ogroupelement.id.tostring() + "'"; ofilter.valuelist = o; ofilter.queryindex = 2; ofilter.filteroperator = efilteroperator.equal; ofilter.iscustomproperty = true; ofilter.isfiltergivenasquery = true; ofilterlist.add(ofilter);

private

// setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.update(odao); if (null != oresult) { if (oresult.issuccess) { //sd: delete the group catalogue if it is

if (ogroupelement.type.equals(((int)egrouptype.private).tostring())) {

cgroupcatalogue ogroupcatalogue = new cgroupcatalogue();

{ ogroupcatalogue.group.id }; efilteroperator.equal;

ogroupcatalogue.group = ogroupelement; ogroupcatalogue.filterlist.clear(); ofilter = new cfilter(); ofilter.propertyname = "group"; ofilter.valuelist = new object[] ofilter.filteroperator = ogroupcatalogue.filterlist.add(ofilter); ogroupcatalogue.delete(odao);

} //changed by milton on 21012006 cgroupelement otempgroup = (cgroupelement)this.componentelement; otempgroup.name = ogroupelement.name; otempgroup.description = ogroupelement.description; otempgroup.email = ogroupelement.email; otempgroup.type = ogroupelement.type; otempgroup.photo = ogroupelement.photo; this.componentelement = otempgroup;

+ "_usergrouplist";

//testing cache by zayed string scachekeyprefix = typeof(cgroupelement)

cgroupelementcollection otempgroupcollection = (cgroupelementcollection)ccachemanager.getcacheinstance().getdatafromcache(scachek eyprefix + ouser.id); if (otempgroupcollection != null && otempgroupcollection.count > 0) { int iposition = -1; for (int i=0;i= 0) { otempgroupcollection.removeat(ipos ition); otempgroupcollection.add(ogroupele ment); } } //testing end

//sm: added by milton on 12022007 updaterootfoldername(ogroupelement.name); //zr: handle custom field of group. handlecustomfield(ogroupelement, ouser, out oinfo); oinfo.issuccess = true; smessage = oresult.message; caudithandler.writelog(smessage, ouser.id, ecruds.u, ogroupelement.id, ogroupelement.id, cgroupcomponentconstant.audit_module_name, eloglevel.information); pdategroup, ogroupelement, ouser);

raisealertevent(ccommonconstant.csemailalertsu

if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { raiseevent("updatebasegroup", ogroupelement, ouser); //by zilani to update the email in the listserver raiseevent("updatebasegroupemail", ogroupelement, ouser); } } else { oinfo.issuccess = false; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "the result retrieved while updating group is null."; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } //} //else //{ // oinfo.issuccess = false; // smessage = "the user " + ouser.name + " does not have permission to update group."; // caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); //} } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".updategroupbasic()", obaseex);

} catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".updategroupbasic()", oex); } } /// <summary> /// this mehtod is use to handle custom field of a group /// /// <param name="ogroupelement"> protected void handlecustomfield(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); if (ogroupelement.customfields != null && ogroupelement.customfields.count > 0) { arraylist alcustomcreatelist = new arraylist(); foreach (ccustomfield ocfld in ogroupelement.customfields) alcustomcreatelist.add(ocfld); type otypec = type.gettype("groupcare.services.dataflexibility.ccustomfieldmanager,gc.services.d ataflexibility"); object objc = activator.createinstance(otypec, false); object[] oparamup = new object[5]; oparamup[0] = "group"; oparamup[1] = ogroupelement; oparamup[2] = alcustomcreatelist; oparamup[3] = ouser; oparamup[4] = oinfo; if (alcustomcreatelist.count > 0) { //otypec.invokemember("updatecustomfield", bindingflags.invokemethod, null, objc, oparamup); utils.invokemember(otypec,"updatecustomfield", bindingflags.invokemethod, null, objc, oparamup); }

oinfo = (cinfo)oparamup[4];

} else {

oinfo.issuccess = true;

}

}

/// <summary> /// this method is to update the group address. in the groupcare solution, there is a ///provision of updating a part of an object. so, if we just update the group then it /// will update the entire data of group element. in order to

avoid this type of update /// this method is introduced which will update only the address part of group element /// /// <param name="ogroup"> /// the group element which will contain the address of group. /// /// <param name="ouser"> /// the user who is is creating the component role permission /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public void updategroupaddress(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; ogroupelement.filterlist.clear(); try { string spermissionname = ccommonconstant.csupdategroup; string salertnameupdate = ccommonconstant.csemailalertsupdategroup; string selseventupdate = null; //cinfo otinfo; // base.updatecomponent(getgroup(ogroupelement, false, ouser, out otinfo), spermissionname, cgroupcomponentconstant.action_update_address, salertnameupdate, selseventupdate, ouser, out oinfo); base.updatecomponent(ogroupelement, spermissionname, cgroupcomponentconstant.action_update_address, salertnameupdate, selseventupdate, ouser, out oinfo); if (oinfo.issuccess) { updategroupcache(ogroupelement, ouser); handlecustomfield(ogroupelement, ouser, out oinfo); } else { caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".updategroupaddress()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() +

".updategroupaddress()", oex); } } /// <summary> /// this method is to update the group address. in the groupcare solution, there is a /// provision of updating a part of an object. so, if we just update the group then it /// will update the entire data of group element. in order to avoid this type of update /// this method is introduced which will update only the email part of group element /// /// <param name="ogroup"> /// the group element which will contain the email data of group. /// /// <param name="ouser"> /// the user who is is creating the component role permission /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public void updategroupemail(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); try { string spermissionname = ccommonconstant.csupdategroup; string salertnameupdate = ccommonconstant.csemailalertsupdategroup; string selseventupdate = null; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { selseventupdate = ccommonconstant.csactionupdatebasegroupemail;// "updategroupemail"; } //cinfo otinfo; //base.updatecomponent(getgroup(ogroupelement, false, ouser, out otinfo), spermissionname, cgroupcomponentconstant.action_update_email, salertnameupdate, selseventupdate, ouser, out oinfo); base.updatecomponent(ogroupelement, spermissionname, cgroupcomponentconstant.action_update_email, salertnameupdate, selseventupdate, ouser, out oinfo); if (oinfo.issuccess) updategroupcache(ogroupelement, ouser); } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".updategroupemail()", obaseex); } catch (exception oex)

{ oinfo.issuccess = false; throw new exception(this.tostring() + ".updategroupemail()", oex); } } /// <summary> /// this method is use to delete a group /// /// <param name="ogroupelement">this parameter define the group that suppose to delete /// <param name="ocomponentelementbase">this parameter define the parant of the group /// <param name="ouser"> /// <param name="oinfo"> public void deletegroup(cgroupelement ogroupelement, ccomponentelementbase ocomponentelementbase, cuser ouser, out cinfo oinfo) { this.parent = this.loadcomponent(ocomponentelementbase.id); this.componentelement = ogroupelement; deletegroup(ogroupelement, ouser, out oinfo); }

be deleted

/// /// /// /// ///

<summary> theis mtthod deletes a group element from the database <param name="ogroupelement"> the group element which contains the information which data to

/// /// <param name="ouser"> /// the user requesting to delete a group /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public void deletegroup(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { ccomponentutil ocomponentutil = new ccomponentutil(); oinfo = new cinfo(); ogroupelement.filterlist.clear(); adaobase odao = cdalhandler.getdaobject(); try { otinfo);

cinfo otinfo = new cinfo(); ogroupelement = getgroup(ogroupelement, false, ouser, out

cgroupelementcollection ogroupelementlist = getgroupthread(ogroupelement, true, ouser, out oinfo); if (ogroupelementlist.count > 1) { oinfo.phraseidlist.add("gr_delete_permission"); oinfo.issuccess = false;

caudithandler.writelog(ouser.name + " the group has sub groups. so you can't delete this group. " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("having subgroup"); oexp.data.add("sender", this.tostring() + ".deletegroup()"); oexp.data.add("phraseid", "gr_delete_permission"); oexp.data.add("errorcode", cerrorcodes.grp_having_subgroup_exception); throw oexp; } string spermissionname = ccommonconstant.csdeletegroup; string salertnamedelete = null; string selseventdelete = null; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { selseventdelete = ccommonconstant.csactiondeletebasegroup;// "deletegroup"; salertnamedelete = ccommonconstant.csemailalertsdeletegroup; } base.deletecomponent(ogroupelement, spermissionname, salertnamedelete, selseventdelete, ouser, out oinfo); if (oinfo.issuccess) { removegroupfromcache(ogroupelement, ouser); cinfo oinfo1; ccomponentuserlist ouserlist = getuserlist(ogroupelement, (int)ecomponentuserstatus.left,ouser, out oinfo1); if(ouserlist!=null && ouserlist.count>0) { foreach(ccomponentuser otempcompuser in ouserlist) { removegroupfromcache(ogroupelement, otempcompuser.user); } } } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".deletegroup()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".deletegroup()", oex); } } /// <summary>

/// this mehtod is use to make member to a group. /// /// <param name="ogroupelement">this parameter define the group where member will create /// <param name="ojoineduser">the user who will be the membere of the group /// <param name="gmembershipid"> /// <param name="ouser"> /// <param name="oinfo"> public void joingroup(cgroupelement ogroupelement, cuser ojoineduser, guid gmembershipid, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); adaobase odao = cdalhandler.getdaobject(); try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; if (!opermissionmanager.haspermission(this, ccommonconstant.cscreategroupmembership, ouser)) { oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".joingroup()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } jointogroup(ogroupelement, null, gmembershipid, ojoineduser, out oinfo); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".joingroup()", oex); } } /// <summary> /// this is a overrloading mentod call previous method /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> public void joingroup(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { jointogroup(ogroupelement, null, guid.newguid(), ouser, out

oinfo); } /// <summary> /// this is a overrloading mentod call previous method /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> public void joingroup(cgroupelement ogroupelement, crole orole, cuser ouser, out cinfo oinfo) { jointogroup(ogroupelement, orole, guid.newguid(), ouser, out oinfo); } /// <summary> /// this is a overrloading mentod call previous method /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> public void joingroup(cgroupelement ogroupelement, crole orole, guid gmembershipid, cuser ouser, out cinfo oinfo) { jointogroup(ogroupelement, orole, gmembershipid, ouser, out oinfo); } /// <summary> /// this method assigns a user in a group element.when a user join to a group some

/// role are assigned to the user and also add the user to memberlist of this component /// /// <param name="ogroupelement"> /// the gorup element whith which a user is assigned /// /// <param name="ouser"> /// the user who is joining the gorup /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// protected void jointogroup(cgroupelement ogroupelement, crole orole, guid gmembershipid, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string salertnamejoin = null; string selseventjoin = null; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { selseventjoin = ccommonconstant.csactionjoinbasegroup;// "joingroup"; salertnamejoin =

ccommonconstant.csemailalertscreategroupmembership; } try { base.joincomponent(ogroupelement, orole, gmembershipid, salertnamejoin, selseventjoin, ouser, out oinfo); if (oinfo.issuccess) setgroupincache(ogroupelement, ouser, false); } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".joingroup()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".joingroup()", oex); } } /// <summary> /// this is a overrloading mentod call previous method /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> public void joingroup(cpersoncollection opersoncollection, cuser ouser, out cinfo oinfo) { joingroup(opersoncollection, "", ouser, out oinfo); } /// /// /// /// group

<summary> this method is use to add a collection of user to a group <param name="opersoncollection">users whose have to add to

/// <param name="ouser">user who wish to perform the operation /// <param name="oinfo"> public void joingroup(cpersoncollection opersoncollection, string smailbody, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); ccomponentuserlist ocomoponentuserlist = new ccomponentuserlist(); adaobase odao = cdalhandler.getdaobject(); cusercollection ouserlist = new cusercollection(); try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; if (!opermissionmanager.haspermission(this, ccommonconstant.cscreategroupmembership, ouser)) {

oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission);

oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".joingroup()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } foreach (cperson operson in opersoncollection) { ccomponentuser ocomponentuser = new ccomponentuser(); ccomponentuser ocomuser = new ccomponentuser(); ocomponentuser.filterlist.clear(); ocomponentuser.user = operson.user; ocomponentuser.component.id = this.componentelement.id; ocomuser = getcomponentuser(ocomponentuser, out oinfo); if (null == ocomuser) { ocomponentuser.status = (int)ecomponentuserstatus.joined; ocomoponentuserlist.add(ocomponentuser); cuserdigesttimestamp odigesttime = new cuserdigesttimestamp(); odigesttime.userid = ouser.id; odigesttime.groupid = ocomponentuser.component.id; odigesttime.create(odao); //join to the group caudithandler.writelog("message", ouser.id, ecruds.joined, operson.user.id, ocomponentuser.component.id, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else if (ocomuser.status != (int)ecomponentuserstatus.joined) { ccomponentutil ocomponentutil = new ccomponentutil(); ocomponentutil.assigndefaultroletouser(ocomponentu ser, ouser, out oinfo); operson.user.roles = ocomponentuser.user.roles; //check if email notification needs to be sent bool bsendnotification = false; foreach (cpersoninfo opersoninfo in operson.informationlist)

{ if (opersoninfo.isallowtoemail)

{ bsendnotification = true; break; }

}

//rejoin to the group rejointogroup(ocomponentuser, smailbody, bsendnotification, ouser);

ouserlist.add(operson.user); }

} if (ouserlist.count > 0) { addusers(ouserlist, ouser, out oinfo); } cresult oresult = ocomoponentuserlist.create(odao); if (oresult.issuccess) { ccomponentutil ocomponentutil = new ccomponentutil(); ocomponentutil.assigndefaultroletouser(ocomoponentuser list, ouser, out oinfo);

//raise event to ems added by nitol to send data in

list server //raiseevent("joinmemberstogroup", ocomoponentuserlist, ouser); ccomponentuser ocomuser = new ccomponentuser(); time continue

//when try to read the group to send mail in the mean //it may deleted from other end but task must be //for this reason catch exception but do nothing try { cinfo otinfo = new cinfo(); cgroupelement ogroup = new cgroupelement();

ocomoponentuserlist)

ogroup.id = this.componentelement.id; ogroup = getgroup(ogroup, ouser, out otinfo); foreach (ccomponentuser ocomuser1 in {

setgroupincache(ogroup, ocomuser1.user,

false);

(long)eroleflags.default;

//raiseevent("joingroup", ocomuser1, ouser); ocomuser1.component = ogroup; raiseevent("joinbasegroup", ocomuser1, ouser); if (this.componentrolepermission.count > 0) { long lflagvalue; lflagvalue = (long)eroleflags.builtin + foreach (ccomponentrolepermission

ocomprolepermission in this.componentrolepermission) { if (ocomprolepermission.role.flagvalue == lflagvalue) { raiseevent("createpermission", ocomprolepermission, ocomuser1.user); } } } if (ouser.id != ocomuser1.user.id) { ocomuser = new ccomponentuser(); ocomuser = getcomponentuser(ocomuser1, out otinfo); foreach (cperson mailperson in opersoncollection) { if (ocomuser1.user.id == mailperson.user.id) { foreach (cpersoninfo mailpersoninfo in mailperson.informationlist) { if (mailpersoninfo.category.equals(ecategory.basicinfo.tostring())) { if (mailpersoninfo.isallowtoemail) { arraylist olist = new arraylist(); olist.add(ouser); olist.add(ogroup); icomponentbase oparentcomp = this.parent; while (oparentcomp.parent != null) { oparentcomp = oparentcomp.parent; } csolutionelement osolelement = new csolutionelement(); osolelement = (csolutionelement)oparentcomp.componentelement; olist.add(osolelement) ; sendmail(ccommonconsta nt.csactioninformationaddmember, olist, smailbody, ouser, mailperson.user); } } } }

}

}

} } catch { } icollection ocol = this.childcomponentlist.keys; ienumerator oenum = ocol.getenumerator(); while (oenum.movenext()) { guid gkey = new guid(oenum.current.tostring()); ccomponentbase ocompbase = new ccomponentbase(); ocompbase = (ccomponentbase)this.childcomponentlist[gkey]; if (ocompbase.componentelement.componenttype.name.equals("memberlist")) { object obnewobject = this.loadcomponent(ocompbase.componentelement.id); //object obnewobject = this.loadcomponent(new guid("b98f659c-40f2-4d88-9f09-328c23131e26")); type otype = obnewobject.gettype(); object[] oparamlist = new object[3]; oparamlist[0] = opersoncollection; oparamlist[1] = ouser; oparamlist[2] = oinfo; //otype.invokemember("adduser", bindingflags.invokemethod, null, obnewobject, oparamlist); utils.invokemember(otype,"adduser", bindingflags.invokemethod, null, obnewobject, oparamlist); oinfo.issuccess = true; break; }

obaseex);

}

} } catch (cexceptionbase obaseex) { throw new cexceptionbase(this.tostring() + ".joingroup()", } catch (exception oex) { throw new exception(this.tostring() + ".joingroup()",

oex);

} } /// <summary> /// this method is use to leave a user from list of group /// /// <param name="ogroupelementcollection"> /// <param name="oleaveduser"> /// <param name="ouser"> /// <param name="oinfo"> public void leavegrouprecursive(cgroupelementcollection ogroupelementcollection, cuser oleaveduser, cuser ouser, out cinfo oinfo) {

cgroupelementcollection ogroupcollection; oinfo = new cinfo(); foreach (cgroupelement oparentgroup in ogroupelementcollection) { ogroupcollection = getgroupthread(oparentgroup, false, oleaveduser, out oinfo); foreach (cgroupelement ogroup in ogroupcollection) { leavegroup(ogroup, oleaveduser, out oinfo); } } } /// <summary> /// this method is use to leave from one group. if this group have /// sub group user will be leave also from subgroup /// /// <param name="ogroupelement"> /// <param name="oleaveduser"> /// <param name="ouser"> /// <param name="oinfo"> public void leavegrouprecursive(cgroupelement ogroupelement, cuser oleaveduser, cuser ouser, out cinfo oinfo) { cgroupelementcollection ogroupcollection = getgroupthread(ogroupelement, false, oleaveduser, out oinfo); foreach (cgroupelement ogroup in ogroupcollection) { leavegroup(ogroup, oleaveduser, out oinfo); } } /// <summary> /// this method removes an user from a group element /// /// <param name="ogroupelement"> /// the group element from which a user is being removed /// /// <param name="ouser"> /// the user who is being removed from the group /// /// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public void leavegroup(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); ogroupelement.deletetime = datetime.now; string spermissionname = null; string salertnameleave = ccommonconstant.csemailalertsdeletegroupmembership;

string selseventleave = null; string snotificationnameleave = ccommonconstant.csactioninformationremovemember; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { selseventleave = ccommonconstant.csactionleavebasegroup;// "leavegroup"; } try { ogroupelement = getgroup(ogroupelement, ouser, out oinfo); cgroupelementcollection ogrouplist = getgroupthread(ogroupelement, false, ouser, out oinfo); if (ogrouplist.count > 1) { oinfo.phraseidlist.add(cgroupcomponentconstant.csgr_le ave_permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got leave permission denied exception while trying to leave from group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".leavegroup()"); oexp.data.add("phraseid", cgroupcomponentconstant.csgr_leave_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } if (isadmin(ouser.roles,ogroupelement.id) && getcomponentadminusercount(out oinfo) == 1 ) { oinfo.issuccess = false; oinfo.phraseidlist.add("gr_leave_group_admin"); return; } base.leavecomponent(ogroupelement, spermissionname, salertnameleave, selseventleave, snotificationnameleave, ouser, out oinfo); if (oinfo.issuccess) removegroupfromcache(ogroupelement, ouser); } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".leavegroup()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".leavegroup()",

oex); } } /// <summary> /// this mehtod return member lsit of a gorup /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> /// public cusercollection getuserlist(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); cusercollection ouserlist = null; string smessage = null; try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; if (!opermissionmanager.haspermission(this, ccommonconstant.csreadgroupmembership, ouser)) { oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".getuserlist()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } // gets dao instance adaobase odao = cdalhandler.getdaobject(); cuser onewuser = new cuser(); onewuser.filterlist.clear(); // sets chaing action filter name onewuser.chainactionfiltername = cgroupcomponentconstant.action_user_read; // setting filter list cfilterlist ofilterlist = new cfilterlist(); // setting first filter cfilter ofilter = new cfilter(); // creating property name string spropertyname = "id"; ofilter.propertyname = spropertyname;

gc_componentuser"

// creating custom query string scustomquery = "(select userid from

+ " where componentid = '" + ogroupelement.id + "'" + " and status = '" + (int)ecomponentuserstatus.joined + "')"; ofilter.valuelist = new object[] { scustomquery }; ofilter.filteroperator = efilteroperator.in; // mentioning whether the value is a custom query ofilter.valueiscustomquery = true; // adding first filter to the filter list ofilterlist.addfilter(ofilter); // setting the filter list to the group element onewuser.filterlist = ofilterlist; // invokes read method cresult oresult = onewuser.read(odao); if (null != oresult) { oinfo.issuccess = oresult.issuccess; smessage = oresult.message; if (oresult.issuccess) { ouserlist = (cusercollection)oresult.data; } caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } else { oinfo.issuccess = false; smessage = "result obtained by get user list request is null";

caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getuserlist()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getuserlist()", oex); } return ouserlist; } /// <summary> /// this mehtod is use to accept group inviation /// public void acceptinvitation(cinvitee oinvitee, cgroupelement

ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); ogroupelement = getgroup(ogroupelement, ouser, out oinfo);

r_join_permission);

oinfo.issuccess = true; try { //cheek whatever user is a member of the parent group if (ogroupelement.parentgroup.id != guid.empty) { ccomponentuser ocomuser = new ccomponentuser(); ocomuser.user = ouser; ocomuser.component = ogroupelement.parentgroup; ocomuser = getcomponentuser(ocomuser, out oinfo); if (null == ocomuser) { oinfo.phraseidlist.add(cgroupcomponentconstant.csg

oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to join group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); exception oexp = new exception("permission denied"); oexp.data.add("sender", this.tostring() + ".acceptinvitation()"); oexp.data.add("phraseid", cgroupcomponentconstant.csgr_join_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } else if (ocomuser.status != (int)ecomponentuserstatus.joined) { oinfo.phraseidlist.add(cgroupcomponentconstant.csg r_join_permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to join group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); exception oexp = new exception("permission denied"); oexp.data.add("sender", this.tostring() + ".acceptinvitation()"); oexp.data.add("phraseid", cgroupcomponentconstant.csgr_join_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } } string spermissionname = ccommonconstant.cscreategroupmembership; string salertnamejoin = ccommonconstant.csemailalertscreategroupmembership;

string selseventjoin = ccommonconstant.csactionjoinbasegroup;// "joingroup"; string snotificationnamejoin = ccommonconstant.csactioninformationaddmember; base.acceptinvitation(oinvitee, ogroupelement, spermissionname, salertnamejoin, selseventjoin, snotificationnamejoin, ouser, out oinfo); if (oinfo.issuccess) setgroupincache(ogroupelement, ouser, true); } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".acceptinvitation()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".acceptinvitation()", oex); } } /// <summary> /// assign a user to a group /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="ologgedinuser"> /// <param name="oinfo"> public void joingroup(cgroupelement ogroupelement, cuser ouser, cuser ologgedinuser, out cinfo oinfo) { oinfo = new cinfo(); oinfo.issuccess = true; string spermissionname = ccommonconstant.cscreategroupmembership; string salertnamejoin = ccommonconstant.csemailalertscreategroupmembership; string selseventjoin = ccommonconstant.csactionjoinbasegroup; string snotificationnamejoin = ccommonconstant.csactioninformationaddmember; base.joingroupfromsolutionadmin(ogroupelement, spermissionname, salertnamejoin, selseventjoin, snotificationnamejoin, ouser, ologgedinuser, out oinfo); if (oinfo.issuccess) setgroupincache(ogroupelement, ouser, false); } /// <summary> /// decline the group inviation /// public void declineinvitation(cinvitee oinvitee, cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) {

base.declineinvitation(oinvitee, ogroupelement, ouser, out oinfo);

}

/// <summary> /// this method is use to retrieve all group setting from database /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> /// public csettingsdatamodelcollection getgroupsettings(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); csettingsdatamodelcollection osettingdatamodelcoll = new csettingsdatamodelcollection(); csettingsdatamodel osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.maximum_size; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty;// ouser.id; osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.archive_message; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty;// ouser.id; osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.archive_attachment; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty;// ouser.id; osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.replie_to; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty;// ouser.id; osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.allow_attatchment;

osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty;//ouser.id; osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.subject_prefix; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty;// ouser.id; osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.attachment_type; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty; osettingdatamodelcoll.add(osettingdatamodel); //osettingdatamodel = new csettingsdatamodel(); //osettingdatamodel.settingsname = cgroupcomponentconstant.check_virus; //osettingdatamodel.componentid = ogroupelement.id; //osettingdatamodel.componenttype = "group"; //osettingdatamodel.settingsuserid = guid.empty; //osettingdatamodelcoll.add(osettingdatamodel); //osettingdatamodel = new csettingsdatamodel(); //osettingdatamodel.settingsname = cgroupcomponentconstant.check_spam; //osettingdatamodel.componentid = ogroupelement.id; //osettingdatamodel.componenttype = "group"; //osettingdatamodel.settingsuserid = guid.empty; //osettingdatamodelcoll.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = cgroupcomponentconstant.email_sender; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = guid.empty; osettingdatamodelcoll.add(osettingdatamodel); ccomponentloadutil ocomploadutil =new ccomponentloadutil();

try {

ccomponentcontext ocompcontext = ocomploadutil.preparecontext(ogroupelement.id, ouser); csettingsmanager osettingmanager = csettingsmanager.getinstance(); osettingdatamodelcoll = osettingmanager.getsettingslist(osettingdatamodelcoll, ocompcontext, ouser, out

oinfo); oinfo.issuccess = true; } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgroupsettings()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgroupsettings()", oex); } return osettingdatamodelcoll; } /// <summary> /// this mehtod is use to save group setting. group setting creating inside the mehod /// /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> /// public csettingsdatamodelcollection creategroupsettings(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { cperson operson = new cperson(); csettingsdatamodel osettingdatamodel = new csettingsdatamodel(); csettingsdatamodelcollection osettinglist = new csettingsdatamodelcollection(); oinfo = new cinfo(); type otypec = type.gettype("groupcare.services.dataflexibility.ccustomfieldmanager,gc.services.d ataflexibility"); object objc = activator.createinstance(otypec, false); object[] oparamup = new object[3]; oparamup[0] = ccommonconstant.cscustomentityperson; oparamup[1] = ouser; oparamup[2] = oinfo; //centity oentity = (centity)otypec.invokemember("getcustomfieldattributelist", bindingflags.invokemethod, null, objc, oparamup); centity oentity = (centity)utils.invokemember(otypec,"getcustomfieldattributelist", bindingflags.invokemethod, null, objc, oparamup); string scustomcatname = ""; foreach (cfieldcategory ofieldcategory in oentity.fieldcategories) { scustomcatname += "," + ofieldcategory.fieldcategoryid;

} osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = "groupmain"; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = ouser.id; osettingdatamodel.settingsvalue = "photo,birthdate,homeinfo,businessinfo,comments" + scustomcatname; osettinglist.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = "groupemail.receivable"; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = ouser.id; osettingdatamodel.settingsvalue = "y"; osettinglist.add(osettingdatamodel); osettingdatamodel = new csettingsdatamodel(); osettingdatamodel.settingsname = "groupemail.addresses"; osettingdatamodel.componentid = ogroupelement.id; osettingdatamodel.componenttype = "group"; osettingdatamodel.settingsuserid = ouser.id; osettingdatamodel.settingsvalue = "basicinfo";// semaillist; osettinglist.add(osettingdatamodel); //osettingdatamodel = new csettingsdatamodel(); //osettingdatamodel.settingsname = "showgroup"; //osettingdatamodel.componentid = ogroupelement.id; //osettingdatamodel.componenttype = "group"; //osettingdatamodel.settingsuserid = ouser.id; //osettingdatamodel.settingsvalue = "y"; //osettinglist.add(osettingdatamodel);

}

//creategroupsettings(osettinglist, ouser, out oinfo); oinfo.issuccess = true; return osettinglist;

/// <summary> /// this method is use to create settings in database. the settings will get as parameter /// /// <param name="osettinglist"> /// <param name="ouser"> /// <param name="oinfo"> public void creategroupsettings(csettingsdatamodelcollection osettinglist, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; //if (!opermissionmanager.haspermission(this, ccommonconstant.csupdategroup, ouser)) //{

// oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no_permission); // oinfo.issuccess = false; // caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); // cexceptionbase oexp = new cexceptionbase("permission denied"); // oexp.data.add("sender", this.tostring() + ".creategroupsettings()"); // oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); // oexp.data.add("errorcode", cerrorcodes.pm_permission_denied_exception); // throw oexp; //} csettingsmanager osettingmanager = csettingsmanager.getinstance(); osettingmanager.createsettingslist(osettinglist, false, ouser, out oinfo); oinfo.issuccess = true; //send data to list server raiseevent(ccommonconstant.csactioncreatebasegroupsetting, osettinglist, ouser); } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".creategroupsettings()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".creategroupsettings()", oex); } } /// <summary> /// this method returns the composite object, which means it will return the object /// along with its parent /// /// /// it will return and object of type icomponentbase /// public override icomponentbase getcomposit() { cgroupcomponent ogroupcomponent = new cgroupcomponent(); ogroupcomponent.parent = base.parent; return ogroupcomponent; } /// <summary>

/// to load the root group. this is needed to set the left, right id of any group. /// protected void loadrootgroup() { ccachemanager ocachemanager = ccachemanager.getcacheinstance(); string scachekey = typeof(cgroupelement).fullname + cgroupcomponentconstant.cache_key_sep + guid.empty.tostring(); m_orootgroup = (cgroupelement)ocachemanager.getdatafromcache(scachekey); if (m_orootgroup == null) { string smessage = null; cgroupelementcollection ogroupelementlist = null; cgroupelement ogroupelement = new cgroupelement(); ogroupelement.id = guid.empty; ogroupelement.filterlist.clear(); try { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_root; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "id"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { ogroupelement.id }; ofilter.filteroperator = efilteroperator.equal; // adding filter to the filter list ofilterlist.addfilter(ofilter); // setting filter to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { // if the result is successful getting the result data ogroupelementlist = (cgroupelementcollection)oresult.data; if (null != ogroupelementlist) { // if the data is not null if (ogroupelementlist.count > 0) { m_orootgroup = ogroupelementlist[0]; ocachemanager.setdataincache(scachekey , m_orootgroup, 0); caudithandler.writelog(oresult.message , cgroupcomponentconstant.audit_module_name, eloglevel.information); }

else { smessage = "no data found on the request";

caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.information); } } else { smessage = "the data retrieved from the database is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.information); } } else { smessage = oresult.message; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { smessage = "returned result from dal is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { throw new cexceptionbase(this.tostring() + ".loadrootgroup()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".loadrootgroup()", oex); } finally { ogroupelement.filterlist.clear(); } } } /// <summary> /// this method returns the list of activities in the goup performed by other users /// since the user has last visited the group /// /// <param name="ogroupelement"> /// the group element which was visited by the user last time /// /// <param name="ouser"> /// the user who has visited the group element last time ///

/// <param name="oinfo"> /// the object which will keep the information of whether the operation is successful /// or not and will also have the language information /// public chistoryelementcontainercollection getsincelastvisithistorylist(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); chistorymanager ohistorymanager = chistorymanager.getinstance(); chistoryelementcontainercollection ohistoryelementcontainercoll = ohistorymanager.readgrouplastaccesselementhistorylist(ouser, ogroupelement, out oinfo); return ohistoryelementcontainercoll; } /// <summary> /// this method will be used for getting the no. of current users of

/// /// /// /// /// /// ///

a group element <param name="ogroupelement"> the group element whose user count is retrieved <param name="oinfo"> is an out parameter which determines whether the operation is

successful

/// /// /// it returns an integer value /// public int getnoofusers(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { return base.getnoofusers(ogroupelement, ouser, out oinfo); } public ccomponentuserlist getjoineduserlist(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { return getuserlist(ogroupelement, (int)ecomponentuserstatus.joined, ouser, out oinfo); ; } public ccomponentuserlist getleftuserlist(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { return getuserlist(ogroupelement, (int)ecomponentuserstatus.left, ouser, out oinfo); ; } /// <summary> /// this method return a list of user from a group depending on requested status of /// user. status value can found in ecomponentuserstatus

retriev

/// /// <param name="ogroupelement">the group whose user list want to

/// <param name="status">status of user. /// none = 0,invited = 1,joined = 2,left = 3,declined = 4,applied = 5 /// the return value is user collection public ccomponentuserlist getuserlist(cgroupelement ogroupelement, int istatus, cuser ouser, out cinfo oinfo) { return base.getuserlist(ogroupelement, istatus, ccommonconstant.csreadgroupmembership, ouser, out oinfo); } /// <summary> /// this is used for updating status of the members who applied for joining to the group /// /// <param name="ouserlist">cusercollection, the list of user whose status will be updated /// <param name="ouser">cuser, the user who accept the joining of the applied user /// <param name="oinfo">cinfo public void acceptapplication(cusercollection ouserlist, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; if (!opermissionmanager.haspermission(this, ccommonconstant.csupdategroupmembership, ouser)) { oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".acceptapplication()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } cresult oresult = applicationstatusupdate(ouserlist, (int)ecomponentuserstatus.joined, ouser); if (oresult.issuccess) { oinfo.issuccess = true; addusers(ouserlist, ouser, out oinfo); }

} catch (cexceptionbase obaseex) { throw new cexceptionbase(this.tostring() + ".acceptapplication()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".acceptapplication()", oex); } } /// <summary> /// this is used for updating status of the members who applied for joining to the group. all the application are rejected. /// /// <param name="ouserlist">cusercollection, the list of user whose status will be updated as rejected application /// <param name="ouser">cuser, the user who reject the joining of the applied user /// <param name="oinfo">cinfo public void rejectapplication(cusercollection ouserlist, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; if (!opermissionmanager.haspermission(this, ccommonconstant.csupdategroupmembership, ouser)) { oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission); oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".acceptapplication()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } cresult oresult = applicationstatusupdate(ouserlist, (int)ecomponentuserstatus.declined, ouser); if (oresult.issuccess) { oinfo.issuccess = true; } } catch (cexceptionbase obaseex)

{ throw new cexceptionbase(this.tostring() + ".rejectapplication()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".rejectapplication()", oex); } } /// <summary> /// this is used for updating the status of component user /// /// <param name="ouserlist">cusercollection, the list of users whose status will be updated /// <param name="istatus">int, the status of the users /// <param name="ouser">cuser, the user who is updating the status /// cresult protected cresult applicationstatusupdate(cusercollection ouserlist, int istatus, cuser ousr) { cinfo oinfo = new cinfo(); cresult oresult = new cresult(); ccomponentuserlist ocomponentuserlist = new ccomponentuserlist(); try { ccomponentuser ocomponentuser; foreach (cuser ouser in ouserlist) { ocomponentuser = new ccomponentuser(); ocomponentuser.component = this.componentelement; ocomponentuser.status = istatus; ocomponentuser.joinleavetime = datetime.now; ocomponentuser.user = ouser;

ousr, out oinfo);

//createrole(ocomponentuser, ousr, out oinfo); ccomponentutil ocomponentutil = new ccomponentutil(); ocomponentutil.assigndefaultroletouser(ocomponentuser, cfilter ofilter = new cfilter(); ofilter.propertyname = "user"; ofilter.valuelist = new object[] { ouser.id }; ocomponentuser.filterlist.addfilter(ofilter);

ofilter = new cfilter(); ofilter.propertyname = "component"; ofilter.valuelist = new object[] { ocomponentuser.component.id }; ocomponentuser.filterlist.addfilter(ofilter); ocomponentuserlist.add(ocomponentuser);

} adaobase odao = cdalhandler.getdaobject(); ocomponentuserlist.chainactionfiltername = cgroupcomponentconstant.action_comp_user_rejoin; oresult = (cresult)ocomponentuserlist.update(odao); } catch (cexceptionbase obaseex) { throw new cexceptionbase(this.tostring() + ".applicationstatusupdate()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".applicationstatusupdate()", oex); } return oresult; } /// <summary> /// this method is written to test wheather the getting group is exit

/// or not.it checks to avoid duplicate group name or duplicate

group

/// mail address. /// /// <param name="ogroupelement"> /// the function's return value is bool public bool getexistinggroup(cgroupelement ogroupelement) { //readroot bool bissuccess = false; cgroupelementcollection ogroupelementlist = null; try { adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_detail; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); //string spropertyname = "(gc_group.name"; //ofilter.propertyname = spropertyname; //ofilter.valueiscustomquery = true; //ofilter.iscustomproperty = true; //ofilter.valuelist = new object[] { "'" + ogroupelement.name.replace("'", "''") + "'" }; //ofilter.filteroperator = efilteroperator.equal; //// adding first filter to the filter list //ofilterlist.addfilter(ofilter); // creating second filter ofilter = new cfilter(); string spropertyname = "(gc_group.email"; ofilter.propertyname = spropertyname; ofilter.iscustomproperty = true;

ofilter.valueiscustomquery = true; ofilter.valuelist = new object[] { "'" + ogroupelement.email + "')" }; ofilter.filteroperator = efilteroperator.equal; //ofilter.logicaloperator = elogicaloperator.or; // adding second filter to the filter list ofilterlist.addfilter(ofilter); // setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method ogroupelementlist = (cgroupelementcollection)ogroupelement.read(odao).data; if (ogroupelementlist.count > 1) { bissuccess = true; } else if (ogroupelementlist.count == 1) { bissuccess = true; foreach (cgroupelement otempgroup in ogroupelementlist) { if (otempgroup.id == ogroupelement.id) { bissuccess = false; break; } } } } catch (cexceptionbase obaseex) { throw new cexceptionbase(this.tostring() + ".getexistinggroup()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".getexistinggroup()", oex); } return bissuccess; }

group.

/// /// /// /// ///

<summary> this method is written to retrieve all child group of the given group. it done by filtering left and right id of the group. the groups whose left & right id between left & right id of the given group are child of the current

/// /// <param name="ogroupelement">group whose child have to retrieve

/// <param name="ouser">user who whish to retrieve /// <param name="oinfo"> /// the return vlaue is group collection public cgroupelementcollection getgroupthread(cgroupelement

ogroupelement, bool bisall, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelementcollection ogroupelementlist = null; try { //// gets the instance of cpermissionmanager cpermissionmanager opermissionmanager = cpermissionmanager.instance; //if (!opermissionmanager.haspermission(this, ccommonconstant.csreadgroup, ouser)) //{ // oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no_permission); // oinfo.issuccess = false; // caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); // cexceptionbase oexp = new cexceptionbase("permission denied"); // oexp.data.add("sender", this.tostring() + ".getgroupthread()"); // oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); // oexp.data.add("errorcode", cerrorcodes.pm_permission_denied_exception); // throw oexp; //} //// checking permission //if (opermissionmanager.haspermission(this, cgroupcomponentconstant.get_group_list, ouser)) //{ // gets the dao object instance ogroupelement = getgroup(ogroupelement, ouser, out oinfo); adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_comp_user_read; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "leftid"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { ogroupelement.leftid }; ofilter.filteroperator = efilteroperator.greaterthanequal; // adding first filter to the filter list ofilterlist.addfilter(ofilter); // creating second filter ofilter = new cfilter(); spropertyname = "rightid"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { ogroupelement.rightid }; ofilter.filteroperator = efilteroperator.lessthanequal; ofilter.logicaloperator = elogicaloperator.and;

// adding second filter to the filter list ofilterlist.addfilter(ofilter); if (!bisall) { ofilter = new cfilter(); ofilter.logicaloperator = elogicaloperator.and; spropertyname = "id"; ofilter.propertyname = spropertyname; string squery = " (select componentid from gc_componentuser where status= " + (int)ecomponentuserstatus.joined + " and userid='" + ouser.id + "')"; ofilter.valuelist = new object[] { squery }; ofilter.filteroperator = efilteroperator.in; ofilter.valueiscustomquery = true; // adding first filter to the filter list ofilterlist.addfilter(ofilter); } // setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data; // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving group list is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgroupthread()", obaseex); } catch (exception oex)

{ oinfo.issuccess = false; throw new exception(this.tostring() + ".getgroupthread()", oex); }

persons

} return ogroupelementlist;

/// <summary> /// this method is use to filter the group memberes from a list of

/// /// <param name="ogroupid"> /// <param name="opersoncollection"> /// <param name="ouser"> /// <param name="oinfo"> /// public arraylist getsubgroupusers(guid ogroupid, cpersoncollection opersoncollection, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; ccomponentuser ocomponentuser = new ccomponentuser(); arraylist alsubgroupuserid = new arraylist(); try { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ocomponentuser.chainactionfiltername = cgroupcomponentconstant.action_subgroup_user_read; // creating filter list cfilterlist ofilterlist = new cfilterlist(); cfilter ofilter = new cfilter(); string spropertyname = "component"; ofilter.propertyname = spropertyname; string sval = "(select componentid from gc_componentrelation where parentcomponentid='" + ogroupid + "'" + "and componentid in (select id from gc_component where componenttypeid=(select id from gc_componenttype where name='group')))"; ofilter.valuelist = new object[] { sval }; ofilter.filteroperator = efilteroperator.in; ofilter.valueiscustomquery = true; ofilterlist.addfilter(ofilter); // creating second filter ofilter = new cfilter(); spropertyname = "status"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { (int)ecomponentuserstatus.joined }; // adding second filter to the filter list ofilterlist.addfilter(ofilter); ofilter = new cfilter();

spropertyname = "user"; ofilter.propertyname = spropertyname; string squery = "("; foreach (cperson operson in opersoncollection) { if (operson.user != null) { squery = squery + "'" + operson.user.id + "',"; } } if (squery.indexof(',') > 0) { squery = squery.substring(0, squery.lastindexof(",")) + ")";

squery += " group by gc_componentuser.[membershipid],gc_componentuser.[userid],gc_user.firstname, gc_user.lastname,gc_user.email"; ofilter.valuelist = new object[] { squery }; ofilter.filteroperator = efilteroperator.in; ofilter.valueiscustomquery = true; ofilterlist.addfilter(ofilter); // setting filter list to the group element ocomponentuser.filterlist = ofilterlist; // invokes the dao method cresult oresult = ocomponentuser.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ccomponentuserlist ocomponentuserlist = (ccomponentuserlist)oresult.data; foreach (ccomponentuser ocompuser in ocomponentuserlist) { if (ocompuser.status > 0) { alsubgroupuserid.add(ocompuser.user); } } } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving group list is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug);

} }

} catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgroupthread()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgroupthread()", oex); } return alsubgroupuserid; } /// <summary> /// this is use to leave one or more user from a group. /// to leave from group here update delete time of role /// permission of this user to the group and update status /// in component user. /// /// <param name="ouserlist"> /// <param name="ogroupelement"> /// <param name="ouser"> /// <param name="oinfo"> /// public cresult leavegroup(cusercollection ouserlist, cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { cresult oresult = new cresult(); string spermissionname = null; string salertnameleave = ccommonconstant.csemailalertsdeletegroupmembership; string selseventleave = null; string snotificationnameleave = ccommonconstant.csactioninformationremovemember; if (!ogroupelement.type.equals(((int)egrouptype.personal).tostring())) { selseventleave = ccommonconstant.csactionleavebasegroup;// "leavegroup"; } try {

base.leavecomponent(ouserlist, getgroup(ogroupelement, false, ouser, out oinfo), spermissionname, salertnameleave, selseventleave, snotificationnameleave, ouser, out oinfo); if (oinfo.issuccess) { foreach (cuser otempuser in ouserlist) { removegroupfromcache(ogroupelement, otempuser); } }

} catch (cexceptionbase obaseex) { throw new cexceptionbase(this.tostring() + ".leavegroup()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".leavegroup()", oex); } oresult.issuccess = oinfo.issuccess; return oresult; }

ouser)

/// <summary> /// this mehtod is use to join a user to a group /// /// <param name="ocomponentuser"> /// <param name="ouser"> public void rejointogroup(ccomponentuser ocomponentuser, cuser {

rejointogroup(ocomponentuser, "", true, ouser);

} /// <summary> /// this mehtod is use to join a user to a group /// /// <param name="ocomponentuser"> /// <param name="smailbody"> /// <param name="ouser"> public void rejointogroup(ccomponentuser ocomponentuser, string smailbody,bool bsendnotification, cuser ouser) { cgroupelement ogroup = new cgroupelement(); cinfo oinfo = new cinfo(); try { ogroup.id = ocomponentuser.component.id; ogroup = getgroup(ogroup, false, ocomponentuser.user, out oinfo); string salertnamejoin = null; string selseventjoin = ccommonconstant.csactionjoinbasegroup;//"joingroup"; string snotificationnamejoin = ccommonconstant.csactioninformationaddmember; base.rejointocomponent(ocomponentuser, ogroup, salertnamejoin, selseventjoin, snotificationnamejoin, bsendnotification, smailbody, ouser); if (oinfo.issuccess) setgroupincache(ogroup, ocomponentuser.user, true); } catch (cexceptionbase obaseex)

{ throw new cexceptionbase(this.tostring() + ".rejointogroup()", obaseex); } catch (exception oex) { throw new exception(this.tostring() + ".rejointogroup()", oex); } } /// <summary> /// this function returns the admin user count for the current component.

/// /// <param name="ouser"> /// <param name="oinfo"> /// public int getgroupadminusercount(cuser ouser, out cinfo oinfo) { return getcomponentadminusercount(out oinfo); }

/// <summary> /// this method is use to get admin list of a group. /// /// <param name="gcomponentid"> /// <param name="ouser"> /// <param name="oinfo"> /// public cusercollection getgroupadminusercollection(guid gcomponentid, cuser ouser, out cinfo oinfo) { return getcomponentadminusercollection(gcomponentid, ouser, out oinfo); } /// <summary> /// this is use to apply to restricted group to become a member /// /// <param name="ogroupelement">the group to which apply /// <param name="ouser">the user who apply /// <param name="oinfo"> /// the return value is result of the operation public cresult applytogroup(cgroupelement ogroupelement, cuser ouser, out cinfo oinfo) { oinfo = new cinfo(); cresult oresult = new cresult(); adaobase odao = cdalhandler.getdaobject(); cfilter ofilter = new cfilter(); try { cpermissionmanager opermissionmanager = cpermissionmanager.instance; if (!opermissionmanager.haspermission(this, ccommonconstant.cscreategroupmembership, ouser)) {

oinfo.phraseidlist.add(cgroupcomponentconstant.cspm_no _permission);

oinfo.issuccess = false; caudithandler.writelog(ouser.name + " got permission denied exception while trying to read group at " + datetime.now, ouser.id, cgroupcomponentconstant.audit_module_name, eloglevel.debug); cexceptionbase oexp = new cexceptionbase("permission denied"); oexp.data.add("sender", this.tostring() + ".applytogroup()"); oexp.data.add("phraseid", cgroupcomponentconstant.cspm_no_permission); oexp.data.add("errorcode", cerrorcodes.grp_permission_denied_exception); throw oexp; } ccomponentuser ocomponentuser = new ccomponentuser(); ocomponentuser.component.id = ogroupelement.id; ocomponentuser.user = ouser; ocomponentuser = getcomponentuser(ocomponentuser, out oinfo);

if (null == ocomponentuser) { ocomponentuser = new ccomponentuser(); ocomponentuser.component.id = ogroupelement.id; ocomponentuser.user = ouser; ocomponentuser.status = (int)ecomponentuserstatus.applied; oresult = (cresult)ocomponentuser.create(odao); } else if (ocomponentuser.status != (int)ecomponentuserstatus.joined) { ocomponentuser.status = (int)ecomponentuserstatus.applied; ofilter.propertyname = "user"; ofilter.valuelist = new object[] { ocomponentuser.user.id }; ocomponentuser.filterlist.addfilter(ofilter); ofilter = new cfilter(); ofilter.propertyname = "component"; ofilter.valuelist = new object[] { ocomponentuser.component.id }; ocomponentuser.filterlist.addfilter(ofilter); oresult = (cresult)ocomponentuser.update(odao); } oinfo.issuccess = true; } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".applytogroup()", obaseex); } catch (exception oex) { oinfo.issuccess = false;

throw new exception(this.tostring() + ".applytogroup()", oex); }

} return oresult;

/// <summary> /// this function returns all parnt groups /// /// <param name="ouser"> /// <param name="oinfo"> /// public cgroupelementcollection getallparentgroups(cuser ouser, out cinfo oinfo)

{

oinfo = new cinfo(); cgroupelementcollection oparentgrouplist = new cgroupelementcollection(); try { icomponentbase ocompbase = this.parent; while (ocompbase != null) { if (ocompbase.componentelement.componenttype.name.toupper().equals("group")) { cgroupelement ogroupelement = (cgroupelement)ocompbase.componentelement; oparentgrouplist.add(ogroupelement); } ocompbase = ocompbase.parent;

} } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getallparentgroups", oex); } oinfo.issuccess = true; return oparentgrouplist; }

bool bflag)

/// <summary> /// this method is use to save a group to cache /// /// <param name="ogroup"> /// <param name="ouser"> /// <param name="bflag"> protected void setgroupincache(cgroupelement ogroup, cuser ouser, {

"_usergrouplist";

string scachekeyprefix = typeof(cgroupelement) +

cgroupelementcollection otempgroupcollection = (cgroupelementcollection)ccachemanager.getcacheinstance().getdatafromcache(scachek eyprefix + ouser.id); if (otempgroupcollection != null && otempgroupcollection.count > 0) { foreach (cgroupelement otempgroup in otempgroupcollection) { if (otempgroup.id.equals(ogroup.id)) { otempgroupcollection.removebyid(ogroup.id); break; } } otempgroupcollection.add(ogroup); } else { if (bflag) { otempgroupcollection = new cgroupelementcollection(); otempgroupcollection.add(ogroup); ccachemanager.getcacheinstance().setdataincache(scache keyprefix + ouser.id, otempgroupcollection, 20); } } } protected void updategroupcache(cgroupelement ogroup, cuser ouser) { string scachekeyprefix = typeof(cgroupelement) + "_usergrouplist"; cgroupelementcollection otempgroupcollection = (cgroupelementcollection)ccachemanager.getcacheinstance().getdatafromcache(scachek eyprefix + ouser.id); if (otempgroupcollection != null && otempgroupcollection.count > 0) { otempgroupcollection.removebyid(ogroup.id); otempgroupcollection.add(ogroup); } } ouser)

protected void removegroupfromcache(cgroupelement ogroup, cuser {

"_usergrouplist";

string scachekeyprefix = typeof(cgroupelement) +

cgroupelementcollection otempgroupcollection = (cgroupelementcollection)ccachemanager.getcacheinstance().getdatafromcache(scachek eyprefix + ouser.id); if (otempgroupcollection != null && otempgroupcollection.count > 0) { otempgroupcollection.removebyid(ogroup.id); } }

/// <summary> /// this method is use to get child list of a group /// /// <param name="ogroup"> /// <param name="ouser"> /// <param name="oinfo"> /// public cgroupelementcollection getsubgrouplist(cgroupelement ogroup, cuser ouser,out cinfo oinfo) { oinfo = new cinfo(); cgroupelementcollection osubgrouplist = null; cgroupelement ogroupelement = new cgroupelement(); adaobase odao = cdalhandler.getdaobject(); ogroupelement.filterlist.clear(); try { ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_basic; cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); ofilter.propertyname = "parentgroup"; ofilter.valuelist = new object[] { ogroup.id.tostring() }; ofilter.filteroperator = efilteroperator.equal; ofilterlist.addfilter(ofilter); // setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; osubgrouplist = (cgroupelementcollection)oresult.data; // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; string smessage = "returned result from dal while retrieving group list is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug);

} } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgrouplist()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgrouplist()", oex); } }

return osubgrouplist;

/// <summary> /// this method checks the current user's role mode in a group. /// /// <param name="orolls"> /// <param name="ogroupid"> /// private bool isadmin(crolecollection orolls, guid ogroupid) { crole orole = new crole(); if (orolls != null && ogroupid != null) { for (int i = 0; i < orolls.count; i++) { orole = (crole)orolls[i]; if (orole.componentid.equals(ogroupid)) { if (orole.flagvalue == (int)eroleflags.creator + (int)eroleflags.builtin) { return true; } } }

}

} return false;

#region get group list for catalogue /// <summary> /// this method return a list of most popular groups. popular groups maximum member, according to

/// can be ranked by the members of group. the group that has /// is the most popular group. first load all group groups

/// /// /// maximum no of group

group member than create a new collection for return <param name="igroupcount">this parameter value defien the should return

/// <param name="oinfo"> /// the return value is group list public cgroupelementcollection getmostpopulargrouplist(int igroupcount, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelement ogroupelement = new cgroupelement(); cgroupelementcollection ogroupelementlist = null; cgroupelementcollection onewgroupelementlist = new cgroupelementcollection(); ogroupelement.filterlist.clear(); try { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_most_popular_group; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data;

[i]);

if (ogroupelementlist.count > igroupcount) { onewgroupelementlist.clear(); for (int i = 0; i < igroupcount; i++) { onewgroupelementlist.add(ogroupelementlist }

} else {

onewgroupelementlist = ogroupelementlist; } // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving

most popular group list is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getmostpopulargrouplist()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getmostpopulargrouplist()", oex); } return onewgroupelementlist; } /// <summary> /// this method load all group(s) associated to a category. /// /// <param name="ocatalogue">this parameter value define the catagory for which groups should load /// <param name="oinfo"> /// the return value is group list public cgroupelementcollection getgrouplistbycatalogue(ccatalogue ocatalogue, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelement ogroupelement = new cgroupelement(); cgroupelementcollection ogroupelementlist = null; ogroupelement.filterlist.clear(); try { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_group_by_catagory; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "parentgroup"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { guid.empty }; ofilter.filteroperator = efilteroperator.equal; ofilter.logicaloperator = elogicaloperator.and; // adding first filter to the filter list ofilterlist.addfilter(ofilter); ofilter = new cfilter(); spropertyname = "gc_groupcatalogue.catalogueid";

"'" };

ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { "'" + ocatalogue.id + ofilter.iscustomproperty = true; ofilter.filteroperator = efilteroperator.equal; ofilter.logicaloperator = elogicaloperator.and; // adding first filter to the filter list ofilterlist.addfilter(ofilter);

// setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data; // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving group list by catalogue is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgrouplistbycatalogue()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgrouplistbycatalogue()", oex); } return ogroupelementlist; } /// <summary> /// this method is return the associated groups from a catalogue

that are exist in /// the provied group list. /// /// <param name="ocatalogue">this parameter value define the catalogue where need to search /// <param name="ogrouplist">this parameter value define the group list that need to check /// <param name="oinfo"> /// the return group list is intersection of provied group list and the groups of the catagory. public cgroupelementcollection getgrouplistbycatalogue(ccatalogue ocatalogue, cgroupelementcollection ogrouplist, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelement ogroupelement = new cgroupelement(); cgroupelementcollection ogroupelementlist = null; ogroupelement.filterlist.clear(); try { if (ogrouplist.count > 0) { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_group_by_catagory; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "parentgroup"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { guid.empty }; ofilter.filteroperator = efilteroperator.equal; ofilter.logicaloperator = elogicaloperator.and; // adding first filter to the filter list ofilterlist.addfilter(ofilter); ofilter = new cfilter(); spropertyname = "gc_groupcatalogue.groupid"; ofilter.propertyname = spropertyname; string sidlist = ""; foreach (cgroupelement otempgroup in ogrouplist) { sidlist += sidlist.equals("") ? "'" + otempgroup.id.tostring() + "'" : ",'" + otempgroup.id.tostring() + "'"; } ofilter.valuelist = new object[] { "(" + sidlist + ")" }; ofilter.iscustomproperty = true; ofilter.filteroperator = efilteroperator.in; ofilter.logicaloperator = elogicaloperator.and; // adding first filter to the filter list ofilterlist.addfilter(ofilter);

+ "'" };

ofilter = new cfilter(); spropertyname = "gc_groupcatalogue.catalogueid"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { "'" + ocatalogue.id ofilter.iscustomproperty = true; ofilter.filteroperator = efilteroperator.equal; ofilter.logicaloperator = elogicaloperator.and; // adding first filter to the filter list ofilterlist.addfilter(ofilter);

// setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data; // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving group list by catalogue is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = true; } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgrouplistbycatalogue()", obaseex); } catch (exception oex) { oinfo.issuccess = false;

throw new exception(this.tostring() + ".getgrouplistbycatalogue()", oex); } return ogroupelementlist; } /// <summary> /// <summary> /// this method return a list of most popular groups. recent groups

/// can be ranked by the create time of group. /// first load all group groups according to /// group create time than create a new collection for return /// /// <param name="igroupcount">his parameter value defien the maximum no of group should return /// <param name="oinfo"> /// the return value is group list public cgroupelementcollection getmostrecentgrouplist(int igroupcount, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelement ogroupelement = new cgroupelement(); cgroupelementcollection ogroupelementlist = null; cgroupelementcollection onewgroupelementlist = new cgroupelementcollection(); ogroupelement.filterlist.clear(); try { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_most_recent_group; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data;

[i]);

if (ogroupelementlist.count > igroupcount) { onewgroupelementlist.clear(); for (int i = 0; i < igroupcount; i++) { onewgroupelementlist.add(ogroupelementlist }

} else {

onewgroupelementlist = ogroupelementlist;

} // saving audit log to database (action log) caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else { oinfo.issuccess = false; smessage = "returned result from dal while retrieving most recent group list is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getmostrecentgrouplist()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getmostrecentgrouplist()", oex); }

catagory. associated to

return onewgroupelementlist; } /// <summary> /// this method is use to load group list for adding to a /// this method should return those group(s) that are not

/// the catalogue and did not cross the association limite. /// /// <param name="ocatalogue">this parameter define the cataloge where wish to add groups /// <param name="imaxcatalogueforonegroup">this parameter define the association limite /// <param name="oinfo"> /// the return value is grouplist add can be added to the catagory public cgroupelementcollection getgrouplisttoaddincatalogue(ccatalogue ocatalogue, int imaxcatalogueforonegroup, out cinfo oinfo) { oinfo = new cinfo(); string smessage = null; cgroupelement ogroupelement = new cgroupelement(); cgroupelementcollection ogroupelementlist = null;

ogroupelement.filterlist.clear(); try { // gets the dao object instance adaobase odao = cdalhandler.getdaobject(); // setting the chain action name ogroupelement.chainactionfiltername = cgroupcomponentconstant.action_read_most_recent_group; // creating filter list cfilterlist ofilterlist = new cfilterlist(); // creating first filter cfilter ofilter = new cfilter(); string spropertyname = "parentgroup"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { guid.empty }; ofilter.filteroperator = efilteroperator.equal; // adding first filter to the filter list ofilterlist.addfilter(ofilter); ofilter = new cfilter(); spropertyname = "id"; ofilter.propertyname = spropertyname; ofilter.valuelist = new object[] { "(select groupid from gc_groupcatalogue where groupid not in (select groupid from gc_groupcatalogue where catalogueid='"+ ocatalogue.id.tostring()+"') group by groupid having count(cast(catalogueid as varchar(50)))<" + imaxcatalogueforonegroup.tostring() + ")" }; ofilter.filteroperator = efilteroperator.in; ofilter.logicaloperator = elogicaloperator.and; ofilter.valueiscustomquery = true; // adding first filter to the filter list ofilterlist.addfilter(ofilter); // setting filter list to the group element ogroupelement.filterlist = ofilterlist; // invokes the dao method cresult oresult = ogroupelement.read(odao); if (null != oresult) { if (oresult.issuccess) { oinfo.issuccess = true; ogroupelementlist = (cgroupelementcollection)oresult.data; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.information); } else { oinfo.issuccess = false; caudithandler.writelog(oresult.message, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } else {

oinfo.issuccess = false; smessage = "returned result from dal while retrieving most recent group list is null"; caudithandler.writelog(smessage, cgroupcomponentconstant.audit_module_name, eloglevel.debug); } } catch (cexceptionbase obaseex) { oinfo.issuccess = false; throw new cexceptionbase(this.tostring() + ".getgrouplisttoaddincatalogue()", obaseex); } catch (exception oex) { oinfo.issuccess = false; throw new exception(this.tostring() + ".getgrouplisttoaddincatalogue()", oex); }

}

return ogroupelementlist; } #endregion #endregion

}

} }/* * file name: mailfilelist.cs * author: fakhrul hossain * date: 20 feb 2007 * * description: * * modification history: * name: nazmul date: 29-05-2007 * name: nazmul date: 31-05-2007 * * version: 1.0 * copyright (c) 2007: groupcare a/s * */ using using using using using using using using using using

system; system.data; system.configuration; system.collections; system.web; system.web.security; system.web.ui; system.web.ui.webcontrols; system.web.ui.webcontrols.webparts; system.web.ui.htmlcontrols;

using groupcare.web.ui.base; using groupcare.common; using system.collections.generic; using groupcare.common.entity;

desc: desc:

using groupcare.common.util; using using using using using using using using

groupcare.web.ui.basecontrols; groupcare.web.ui.util; groupcare.common.entity.filearchive; groupcare.component; groupcare.common.entity.permission; groupcare.web.ui.uiengine; groupcare.web.ui.compositecontrols; system.io;

public partial class maillist : cmymailcontrol { #region member variables protected protected protected protected protected protected protected protected protected protected protected protected

cuser m_ouser; string m_apppath = string.empty; hashtable m_htphraseid; string m_sfilelistactionfilters; hashtable m_htaction; cfolder m_ofolder; cfoldercollection m_ofoldercol; arraylist m_alcheckeditemlist; bool m_bsuccess = true; string m_stotalfiles = "-1"; cfilearchivemanager m_ofamanager = new cfilearchivemanager(); ccomponentcontext m_ocomponentcontext = new ccomponentcontext();

#endregion member variables #region properties public string folderid { get { return (viewstate["folderid"] == null) ? "" : (string)viewstate["folderid"]; } set { viewstate["folderid"] = value; } } public string groupcomponentid { get { return (viewstate["groupcomponentid"] == null) ? "" : (string)viewstate["groupcomponentid"]; } set { viewstate["groupcomponentid"] = value; } }

public string foldercomponentid { get { return (viewstate["foldercomponentid"] == null) ? "" : (string)viewstate["foldercomponentid"]; } set { viewstate["foldercomponentid"] = value; } } public string filenoproperty { get { return (viewstate["fileno"] == null) ? "0" : (string)viewstate["fileno"]; } set { viewstate["fileno"] = value; } } public string foldersizeproperty { get { return (viewstate["foldsize"] == null) ? "0" : (string)viewstate["foldsize"]; } set { viewstate["foldsize"] = value; } } public enum eactiontype { default = 0, copypastefile = 1, cutpastefile = 2, deletefile = 3 } public eactiontype actiontype { get { return (viewstate["actiontype"] == null) ? eactiontype.default : (eactiontype)viewstate["actiontype"]; } set { viewstate["actiontype"] = value;

} } #endregion #region commom functions protected override void oninit(eventargs e) { base.oninit(e); } protected override void onload(eventargs e) { base.onload(e); this.componentcontext = utils.currentcomponentcontext; if (utils.getsession(csessionvarnames.csmymail_action) != null) { eactiontype ecurrentactiontype = (eactiontype)utils.getsession(csessionvarnames.csmymail_action); if (ecurrentactiontype == eactiontype.copypastefile || ecurrentactiontype == eactiontype.cutpastefile) { btnpastefile.display = true; } else { btnpastefile.display = false; } } else btnpastefile.display = false; if (ispostback) { cresult oresult = getfolderlist(); if (oresult.issuccess) { m_ofoldercol = (cfoldercollection)oresult.data; if (issolutioncontext) { m_ofoldercol = checkfolderpermission(m_ofoldercol); } } }

createtree(m_ofoldercol);

}

public override void initcontrol() { base.initcontrol(); bxfolder.title = utils.getphrasevalue("mm_folder_header").trim();

bxfilelist.title = utils.getphrasevalue("mm_filesandmail_header").trim(); gcutilitybuttonset1.printtooltip = utils.getphrasevalue("fa_tip_utility_btn_print").trim(); gcutilitybuttonset1.settingtooltip = utils.getphrasevalue("fa_tip_utility_btn_settings").trim(); gcutilitybuttonset1.filtertooltip = utils.getphrasevalue("fa_tip_utility_btn_filter").trim(); gcutilitybuttonset1.exporttooltip = utils.getphrasevalue("fa_tip_utility_btn_export").trim(); m_apppath = utils.apppath + "/"; m_ofoldercol = new cfoldercollection(); m_ofolder = new cfolder(); m_ouser = utils.currentuser; btnpastefile.display = false; createcontextmenues(); cresult oresult = new cresult(); if (!issolutioncontext) { utils.setsession(csessionvarnames.csmymail_componentcontextid, this.componentcontext.component.id); } if (ispostback && utils.getsession(csessionvarnames.csmymail_getfolderlist) != null) { m_ofoldercol = (cfoldercollection)utils.getsession(csessionvarnames.csmymail_getfolderlist); } else { oresult = getfolderlist(); if (oresult.issuccess == true) { m_ofoldercol = (cfoldercollection)oresult.data; if (issolutioncontext) { m_ofoldercol = checkfolderpermission(m_ofoldercol); } else { if (!(bool)this.permissions[ccommonconstant.csreadfolder] || ! (bool)this.permissions[ccommonconstant.csreadfile]) { showerror(utils.getphrasevalue("fa_no_permission")); } } utils.setsession(csessionvarnames.csmymail_getfolderlist,

m_ofoldercol); } } if (utils.getsession(csessionvarnames.csmymail_view) == null) { utils.setsession(csessionvarnames.csmymail_view, "list"); } if (!ispostback) { if (httpcontext.current.request.querystring.get("module") != null) { if (utils.getsession(csessionvarnames.csmymail_folderid) != null && utils.getsession(csessionvarnames.csmymail_foldercomponentid) != null) { this.folderid = utils.getsession(csessionvarnames.csmymail_folderid).tostring(); this.foldercomponentid = utils.getsession(csessionvarnames.csmymail_foldercomponentid).tostring(); } else { this.folderid = ((cfolder)m_ofoldercol[0]).id.tostring(); this.foldercomponentid = ((cfolder)m_ofoldercol[0]).componentid.tostring(); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid);

utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_componentid, this.componentcontext.component.id.tostring()); } } else if (m_ofoldercol.count > 0) { if (httpcontext.current.request.querystring.get("foldid") != null) this.folderid = httpcontext.current.request.querystring.get("foldid").tostring(); else this.folderid = ((cfolder)m_ofoldercol[0]).id.tostring(); this.foldercomponentid = ((cfolder)m_ofoldercol[0]).componentid.tostring(); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid);

utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_view, "list"); } } else {

if (utils.getsession(csessionvarnames.csmymail_folderid) != null && utils.getsession(csessionvarnames.csmymail_foldercomponentid) != null)

{ this.folderid = utils.getsession(csessionvarnames.csmymail_folderid).tostring(); this.foldercomponentid = utils.getsession(csessionvarnames.csmymail_foldercomponentid).tostring(); } } if (utils.getsession(csessionvarnames.csmymail_getfolderdetail) == null || !ispostback) { cfolder ofolder = new cfolder(); ccomponentcontext ogroupcontext = new ccomponentcontext(); if (this.folderid != null && !this.folderid.equals("")) { ofolder.id = new guid(this.folderid.tostring()); ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); oresult = getfolderdetail(ofolder, ogroupcontext, false); if (oresult.issuccess == true) { m_ofolder = (cfolder)oresult.data; if (m_ofolder != null) { m_ofolder.files = getlatestversioncollection(m_ofolder.files); utils.setsession(csessionvarnames.csmymail_getfolderdetail

, m_ofolder); } else {

this.folderid = ((cfolder)m_ofoldercol[0]).id.tostring(); this.foldercomponentid = ((cfolder)m_ofoldercol[0]).componentid.tostring(); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid);

utils.setsession(csessionvarnames.csmymail_foldercomponent id, this.foldercomponentid.tostring()); ofolder.id = new guid(this.folderid.tostring()); ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); oresult = getfolderdetail(ofolder, ogroupcontext, false); m_ofolder = (cfolder)oresult.data; m_ofolder.files = getlatestversioncollection(m_ofolder.files); utils.setsession(csessionvarnames.csmymail_getfolderdetail

, m_ofolder); } }

}

} else { m_ofolder = (cfolder)utils.getsession(csessionvarnames.csmymail_getfolderdetail); } if (m_ofoldercol.count > 0) { createtree(m_ofoldercol); applypermissiontofilelist(m_ofolder.files); populatefilelist(m_ofolder); setfolderinformation(); ibtnnewfolder.display = ((cpermission)m_ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefolder; })).isset; btnfileupload.display = ((cpermission)m_ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefile; })).isset; } else { cconfirmwindow oconfirmwindow = new cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = null; oconfirmwindow.componentcontext = m_ocomponentcontext; oconfirmwindow.commandname = string.empty; oconfirmwindow.successurl = urlmappings.geturl(urls.sys_home); oconfirmwindow.cancelurl = ""; oconfirmwindow.title = utils.getphrasevalue("mm_msg_header_error").trim(); oconfirmwindow.displaymessage = utils.getphrasevalue("fa_msg_no_folder_available"); oconfirmwindow.okphrasekey = "mm_btn_lbl_ok"; oconfirmwindow.cancelphrasekey = "mm_btn_lbl_cancel"; oconfirmwindow.cancelvisible = false; oconfirmwindow.okvisible = true; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } } protected override void onprerender(eventargs e) { string sversionpermission = "0"; string sjscheckbox = string.format(@" function enabledisableactiondropdown(event) {{ var form = document.forms[0]; var elemdropdown = document.getelementbyid('{0}'); var bchecked = false;

if(elemdropdown) {{ for(var i = 0;i < form.length; i++) {{ var element = form[i]; if(element.id.indexof('checkbox1')!=-1) {{ if(element.checked) {{ bchecked = true; break; }} }} }}

}}

if(!bchecked) {{ ddcbevent('{0}',0); //elemdropdown.shoemenu = false; }} else {{ ddcbevent('{0}',1); //elemdropdown.showmenu = true; elemdropdown.focus(); }}

}}

", ogcfunctiondropdown.clientid); if (!page.clientscript.isstartupscriptregistered("imagethumbnailcheckbox")) { page.clientscript.registerstartupscript(this.gettype(), "imagethumbnailcheckbox", sjscheckbox, true); } if (this.folderid != "" && tvfolderlist.getnode(this.folderid) != null) tvfolderlist.getnode(this.folderid).imageurl = utils.imagepath + "list/treelist_folder_open.gif"; if (utils.getsession(csessionvarnames.csmymail_view) != null) { if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("thumbnails")) { gcutilitybuttonset1.displayexportimage = false; gcutilitybuttonset1.displayfilterimage = false; } } else { gcutilitybuttonset1.displayexportimage = true; gcutilitybuttonset1.displayfilterimage = true;

} sversionpermission = getfileversionsetting(); bool bflag = ((cpermission)m_ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag) { if (m_ofolder.files.count == 0) { ofagridviewex.visible = false; ogcfunctiondropdown.visible = false; gcutilitybuttonset1.displayexportimage = false; gcutilitybuttonset1.displayfilterimage = false; gcutilitybuttonset1.displayprintimage = false; gcphraselabel2.text = utils.getphrasevalue("fa_mess_no_permission_file_read"); gcphraselabel2.visible = true; } else { m_ofoldercol = (cfoldercollection)((cresult)getfolderlist()).data; gcutilitybuttonset1.displayprintimage = true; if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { ofagridviewex.visible = true; ogcfunctiondropdown.visible = true; gcutilitybuttonset1.displayexportimage = true; gcutilitybuttonset1.displayfilterimage = true; gcphraselabel2.visible = false; } if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("thumbnails")) { ofagridviewex.visible = false; ogcfunctiondropdown.visible = true; gcutilitybuttonset1.displayexportimage = false; gcutilitybuttonset1.displayfilterimage = false; gcphraselabel2.visible = false; } } } else { ofagridviewex.visible = false; ogcfunctiondropdown.visible = false; gcutilitybuttonset1.displayexportimage = false; gcutilitybuttonset1.displayfilterimage = false; gcphraselabel2.text = utils.getphrasevalue("fa_msg_nofile_available"); gcphraselabel2.visible = true; } utils.state.clearstate(); }

public override void populatecontrol() { base.populatecontrol(); } protected void page_load(object sender, eventargs e) { } #endregion #region functions protected cfoldercollection checkfolderpermission(cfoldercollection ofoldercol) { cfoldercollection ofoldercollection = new cfoldercollection(); foreach (cfolder ofold in ofoldercol) { if (((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfolder; })).isset) { if (ofold.parent.id.equals(guid.empty)) { ofoldercollection.add(ofold); } else { foreach (cfolder ofolder in ofoldercollection) { if (ofold.parent.id.equals(ofolder.id)) { ofoldercollection.add(ofold); break; } } } } } return ofoldercollection; } protected void setfolderinformation() { if (this.foldercomponentid == null || this.foldercomponentid.equals("")) return; m_ocomponentcontext.component.id = new guid(this.foldercomponentid); if (utils.getsession(csessionvarnames.csmymail_diskspacesetted) == null) { string str = m_ofamanager.getdiskspacesetted(this.foldercomponentid.tostring(), utils.currentcomponentcontext);//m_ocomponentcontext utils.setsession(csessionvarnames.csmymail_diskspacesetted, str); } arraylist alelems = new arraylist();

cdynamicvariable odynavar = new cdynamicvariable(); odynavar.filecountinfolder = int.parse(this.filenoproperty); odynavar.filespaceinfolder = this.foldersizeproperty; alelems.add(odynavar); lblfolderdetails.text = getdynamictext(alelems, "fa_lbl_fileinfolder"); lbltotalfileofselectedarchive.text = gettotalfileofselectedarchive(new guid(this.foldercomponentid.tostring())); m_stotalfiles = "-1"; decimal m_stotalspaceused = m_ofamanager.getdiskspaceused(this.foldercomponentid.tostring(), m_ocomponentcontext); lblfilesize.text = getconvertedfilesize(m_stotalspaceused * 1024 * 1024); alelems = new arraylist(); odynavar = new cdynamicvariable(); odynavar.filecountingroup = int.parse(lbltotalfileofselectedarchive.text); odynavar.usedfilespaceingroup = lblfilesize.text; alelems.add(odynavar); lblgroupdetails.text = getdynamictext(alelems, "fa_lbl_file_in_allfolder"); // space left decimal ispaceleft = (decimal.parse(utils.getsession(csessionvarnames.csmymail_diskspacesetted).tostrin g()) - m_stotalspaceused); lblspaceleft.text = math.round(ispaceleft, 2) + "" + " mb"; alelems = new arraylist(); odynavar = new cdynamicvariable(); odynavar.filespacefreeingroup = math.round(ispaceleft, 2) + "" + " mb"; alelems.add(odynavar); lblfreespace.text = getdynamictext(alelems, "fa_lbl_diskspace_free_in_group"); } protected void showerror(string message) { string surl = string.empty; if (httpcontext.current.request.querystring.get("module") == null) surl = utils.state.getreturnurl(); else surl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); utils.setsession(csessionvarnames.csmymail_actiondata, null); utils.setsession(csessionvarnames.csmymail_action, null); cconfirmwindow oconfirmwindow = new cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = null; oconfirmwindow.componentcontext = m_ocomponentcontext; oconfirmwindow.commandname = string.empty; oconfirmwindow.successurl = surl; oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = utils.getphrasevalue("fa_lbl_header_error").trim(); oconfirmwindow.displaymessage = message; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.cancelvisible = false;

oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } protected string getfilenamelengthexceed(cfilecollection ofilecol) { string smlfilename = string.empty; string smlfilenamelist = string.empty; arraylist almlfilename = new arraylist(); foreach (cfile ofile in ofilecol) { smlfilename = ofile.name; smlfilename = "copy of " + smlfilename; if (smlfilename.length > 255) smlfilenamelist = smlfilenamelist + "
" + smlfilename; } return smlfilenamelist; } protected decimal getsizeofcopiedfile(cfilecollection ofilecolpast) { decimal dsize = 0; foreach (cfile ofile in ofilecolpast) { dsize = dsize + ofile.size; } return dsize; } /// <summary> /// get the personal folder to the top /// /// <param name="ofoldcollection"> /// protected cfoldercollection arrangepersonalfolder(cfoldercollection ofoldcollection) { guid gpersonalfaid = guid.empty; for (int i = 0; i < ofoldcollection.count; i++) { cfolder oflper = (cfolder)ofoldcollection[i]; if (oflper.type.equals("personal")) { gpersonalfaid = oflper.componentid; if (i != 0) { ofoldcollection.removeat(i); ofoldcollection.insert(0, oflper); } break; }

} // apply setting for personal group

if (utils.getsession(csessionvarnames.csmymail_pesonalgrpsetting) == null) { string str = m_ofamanager.getpersonalgroupsetting(gpersonalfaid.tostring(), this.componentcontext);//m_ocomponentcontext utils.setsession(csessionvarnames.csmymail_pesonalgrpsetting, str); } if (utils.getsession(csessionvarnames.csmymail_pesonalgrpsetting) != null && utils.getsession(csessionvarnames.csmymail_pesonalgrpsetting).tostring().equals("n ")) { ienumerator oenum = ofoldcollection.getenumerator(); while (oenum.movenext()) { if (((cfolder)oenum.current).componentid.equals(gpersonalfaid)) { ofoldcollection.remove(oenum.current); oenum = ofoldcollection.getenumerator(); } } } return ofoldcollection; } public void createtree(cfoldercollection ofoldcollection) { try { bool bflag1; bool bflag2; tvfolderlist.clearnodes(); tvfolderlist.showlines = true; tvfolderlist.selectednodestyle.font.bold = true; tvfolderlist.contextmenucontrol = cmfolders; string sfilter = string.empty; foreach (cfolder ofold in ofoldcollection) { gctreenode otreenode = new gctreenode(); otreenode.nodedata = ofold.name; otreenode.text = " " + ofold.name; otreenode.imageurl = utils.imagepath + "list/treelist_folder_closed.gif"; // -- \\ otreenode.value = ofold.id.tostring() + "|" + ofold.componentid.tostring(); if (this.folderid.equals(ofold.id.tostring())) { otreenode.selected = true; utils.setsession(csessionvarnames.csmymail_selectednode, tvfolderlist.getnode(this.folderid.tostring())); } if (ofold.parent.id.equals(guid.empty)) { if (this.permissions != null)

{ sfilter = string.empty; bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag1) { sfilter = sfilter + "0"; } bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefolder; })).isset; if (bflag1) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ","; sfilter = sfilter + "1"; } }

otreenode.filterids = sfilter;

otreenode.filterids = sfilter; tvfolderlist.addnode("", ofold.id.tostring(), otreenode);

} else { if (haschildren(ofold.id, ofoldcollection)) { sfilter = string.empty;

bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag1) { sfilter = sfilter + "0"; } bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefolder; })).isset;

",";

if (bflag1) { if (!sfilter.equals(string.empty)) sfilter = sfilter + }

sfilter = sfilter + "1";

bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csupdatefolder; })).isset; if (bflag1) { if (!sfilter.equals(string.empty)) sfilter = sfilter +

","; }

sfilter = sfilter + "2";

otreenode.filterids = sfilter; } else {

sfilter = string.empty;

bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag1) { sfilter = sfilter + "0"; } bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefolder; })).isset; if (bflag1) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ",";

sfilter = sfilter + "1"; }

bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csupdatefolder; })).isset; if (bflag1) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ","; sfilter = sfilter + "2"; } bflag1 = ((cpermission)ofold.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefolder; })).isset; if (bflag1) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ","; sfilter = sfilter + "3"; } else { if (ofold.creator.id.equals(utils.currentuser.id.tostring())) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ","; sfilter = sfilter + "3"; } }

otreenode.filterids = sfilter; } tvfolderlist.addnode(ofold.parent.id.tostring(), ofold.id.tostring(), otreenode); } } utils.setsession(csessionvarnames.csmymail_selectednode, tvfolderlist.getnode(this.folderid.tostring())); tvfolderlist.visible = true; tvfolderlist.expandall(); tvfolderlist.expanddepth = 2; } catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error); } } protected bool haschildren(guid gfoldid, cfoldercollection ofoldercol) { bool bhaschild = false; foreach (cfolder ofold in ofoldercol) { if (ofold.parent.id.equals(gfoldid)) { bhaschild = true; break; } } return bhaschild; } protected cresult getfolderlist() { cresult oresult = new cresult(); list<string> alpermnamelist = new list<string>(); alpermnamelist.add(ccommonconstant.cscreatefile); alpermnamelist.add(ccommonconstant.csreadfile); alpermnamelist.add(ccommonconstant.csupdatefile); alpermnamelist.add(ccommonconstant.csdeletefile); alpermnamelist.add(ccommonconstant.cscreatefolder); alpermnamelist.add(ccommonconstant.csreadfolder); alpermnamelist.add(ccommonconstant.csupdatefolder); alpermnamelist.add(ccommonconstant.csdeletefolder);

if (issolutioncontext) { if (path.getfilenamewithoutextension(request.url.tostring()).equals("mymail"))

{ object[] obj = new object[4]; obj[0] obj[1] obj[2] obj[3]

= = = =

new cfolder(); alpermnamelist; true; utils.currentuser;

oresult = m_ocontrolmanager.performaction("getaggregatefolders", obj, this.componentcontext, utils.currentuser); } else { object[] obj = new object[3]; obj[1] = alpermnamelist; obj[2] = utils.currentuser; obj[0] = new cfolder(); oresult = m_ocontrolmanager.performaction("getaggregatefolders", obj, this.componentcontext, utils.currentuser); if (oresult.issuccess && oresult.data != null) { cfoldercollection ofolders = arrangepersonalfolder((cfoldercollection)oresult.data); oresult.data = ofolders; } } } else { object[] obj = new object[4]; obj[1] = alpermnamelist; obj[2] = utils.currentuser; obj[3] = false; if (utils.getsession(csessionvarnames.csmymail_foldercomponentid) != null && utils.getsession(csessionvarnames.csmymail_componentcontextid).tostring().equals(u tils.getsession(csessionvarnames.csmymail_foldercomponentid).tostring())) { obj[0] = new guid(utils.getsession(csessionvarnames.csmymail_foldercomponentid).tostring()); } else { obj[0] = this.componentcontext.component.id; utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.componentcontext.component.id.tostring()); } oresult = m_ocontrolmanager.performaction("getallfolders", obj, this.componentcontext, utils.currentuser); } }

return oresult;

protected cresult deletefolder(cfolder ofolder) { cresult oresult = new cresult(); return oresult; } protected cresult pastcopyfile(object odata) { cresult oresult = new cresult(); ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid.tostring()); oresult = m_ocontrolmanager.performaction("pastecopyfiles", odata, ocontext, utils.currentuser); return oresult; } protected cresult pastecutfile(object odata) { cresult oresult = new cresult(); ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid.tostring()); oresult = m_ocontrolmanager.performaction("pastecutfiles", odata, ocontext, utils.currentuser); }

return oresult;

protected cresult uploadfiletofolder(cfolder ofolder, cfilecollection filelist) { cresult oresult = new cresult(); return oresult; } protected cresult savetoclipboard(object file) { cresult oresult = new cresult(); return oresult; } public void applypermissiontofilelist(cfilecollection ofilecollection) { cfile oparentfile = new cfile(); cfilecollection filecollection = new cfilecollection(); bool bflag; int iindex = 9; foreach (cfile ofile in ofilecollection) { if (!ofile.versionno.equals("")) { oparentfile.id = ofile.parentfile; oparentfile.componentid = ofile.componentid;

oparentfile = getfile(oparentfile); } string sfilterstr = ""; if (ofile.versionno.equals("")) { sfilterstr = "0"; } else { sfilterstr = "1"; } if (!ofile.versionno.equals("")) { bflag = ((cpermission)oparentfile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; } else { bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; } if (bflag || ofile.creator.id == utils.currentuser.id) { if (sfilterstr == "") { if (ofile.versionno.equals("")) { sfilterstr = "2"; } else { sfilterstr = "3"; } } else { if (ofile.versionno.equals("")) { sfilterstr += ",2"; } else { sfilterstr += ",3"; } } } if (!ofile.versionno.equals("")) { bflag = ((cpermission)oparentfile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; }

else { bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; } if (bflag) { if (sfilterstr == "") { sfilterstr = "4"; } else { sfilterstr += ",4"; } } if (!ofile.versionno.equals("")) { bflag = ((cpermission)oparentfile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; } else { bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; } if (bflag) { if (!ofile.versionno.equals("")) { bflag = ((cpermission)oparentfile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; } else { bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; } if (bflag) { if (sfilterstr == "") { sfilterstr = "5"; } else { sfilterstr += ",5"; } } } if (!ofile.versionno.equals(""))

{ bflag = ((cpermission)oparentfile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; } else { bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; } if (bflag) { if (sfilterstr == "") { sfilterstr = "6"; } else { sfilterstr += ",6"; } } //set "new" or "downloaded" context menu item if (ofile.creator.id != utils.currentuser.id) { if (ofile.isread) { sfilterstr += ",7"; } else { sfilterstr += ",8"; } } //ofile.menuitems = sfilterstr; foreach (cfile otempfile in (cfilecollection)ofile.mylist) { if (sfilterstr == "") { sfilterstr = "" + iindex; } else { sfilterstr += "," + iindex; } iindex++; } ofile.menuitems = sfilterstr; }

filecollection.add(ofile);

m_ofolder.files = filecollection; } protected void populatefilelist(cfolder ofolder)

{ utils.state.setstate(null, null, request.url.tostring()); gcactiondropdown.visible = false; gcimgselecdropdownlist.visible = false;

if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { componentutils ocomputil = new componentutils(); guid gcomponentid; if (utils.currentcomponentcontext.component.componenttype.name.equals(cmodulenames.so lution)) { gcomponentid = ocomputil.preparememberlistcomponentid(ofolder.componentid); } else { gcomponentid = ocomputil.getmemberlistcomponentid(); } ccomponentelementbase otempparentcomponent = new ccomponentelementbase(); otempparentcomponent.id = gcomponentid; foreach (cfile ofile in ofolder.files) { ofile.parentcomponent.parentcomponent = otempparentcomponent; } gccontextmenuitemcollection ocolitem = new gccontextmenuitemcollection(); gccontextmenuitem odropdownmenuitem; odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "copyfiles"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_copy_func"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_copy_func"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_copy.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "cutfiles"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_cut_func"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_cut_func"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_cut.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem();

odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "deletefiles"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_delete_func"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_delete_func"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_delete.gif"; ocolitem.add(odropdownmenuitem); ogcfunctiondropdown.displaytext = utils.getphrasevalue("fa_lbl_choose_func"); ogcfunctiondropdown.dropdownmenuitems = ocolitem; ocolitem = new gccontextmenuitemcollection(); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "list"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_views_list"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_views_list"); odropdownmenuitem.imageurl = "images/icons/action/icon_folder_view_normal.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "thumbnails"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_views_thumbnail"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_views_thumbnail"); odropdownmenuitem.imageurl = "images/icons/action/icon_folder_view_thumbnail.gif"; ocolitem.add(odropdownmenuitem); gccontextmenuitemcollection ocontextmenuitems = new gccontextmenuitemcollection(); gccontextmenuitem ocontextmenuitem; ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = true; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "download"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_menu_download"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_download"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_download.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = true;

ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "download"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_menu_latestversion_download"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_download"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_download.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "details"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_menu_file_details"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_file_details"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_details.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "details"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_menu_file_details_edit_series"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_file_details"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_details.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "copyfiles"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_menu_file_copy"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_file_copy"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_copy.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "cutfiles"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_menu_file_cut"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_file_cut"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_cut.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false;

ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "deletefiles"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_btn_file_delete"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_file_delete"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_delete.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "setflagnew"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_set_new"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_set_new"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_set_new.gif"; ocontextmenuitems.add(ocontextmenuitem); ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "setflagdownloaded"; ocontextmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_set_downloaded"); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_set_downloaded"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_set_downloaded.gif"; ocontextmenuitems.add(ocontextmenuitem); foreach (cfile ofile in ofolder.files) { cfilecollection ofilecollection = new cfilecollection(); ofilecollection = (cfilecollection)ofile.mylist; foreach (cfile otempfile in ofilecollection) { ocontextmenuitem = new gccontextmenuitem(); ocontextmenuitem.default = false; ocontextmenuitem.enabled = true; ocontextmenuitem.commandname = "downloadversion_" + otempfile.id.tostring(); ocontextmenuitem.displaytext = otempfile.versionno.tostring() + " " + otempfile.name.tostring(); ocontextmenuitem.tooltip = utils.getphrasevalue("fa_lbl_menu_tooltip_download"); ocontextmenuitem.imageurl = "images/icons/action/icon_file_download.gif"; ocontextmenuitems.add(ocontextmenuitem); } } ofagridviewex.gridcolumns.clear();

gridviewcolumn ogvcolumn; ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = true; ogvcolumn.isfilter = false; ogvcolumn.showheader = true; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.none; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = "check box"; ogvcolumn.datatextfields = "id"; ogvcolumn.datatextformatstring = string.empty; ogvcolumn.datanavigateurlfields = string.empty; ogvcolumn.datanavigateurlformatstring = string.empty; ogvcolumn.columntype = ecolumntype.checkbox; ogvcolumn.chooseactioncontrol = ogcfunctiondropdown; ofagridviewex.gridcolumns.add(ogvcolumn); ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = true; ogvcolumn.isfilter = true; ogvcolumn.showheader = true; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.none; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = utils.getphrasevalue("fa_lbl_file_type"); ogvcolumn.datatextfields = "fileicon"; ogvcolumn.datatextformatstring = string.empty; ogvcolumn.datanavigateurlfields = string.empty; ogvcolumn.contextmenufilterfield = "menuitems"; ogvcolumn.iscontextmenufilter = true; ogvcolumn.columntype = ecolumntype.image; ofagridviewex.gridcolumns.add(ogvcolumn); ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = true; ogvcolumn.isfilter = true; ogvcolumn.showheader = true; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.textbox; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = utils.getphrasevalue("fa_lbl_file_name"); ogvcolumn.datatextfields = "filetitle";//"name"; ogvcolumn.commandname = "download"; ogvcolumn.commandargument = "id"; ogvcolumn.datatextformatstring = string.empty; ogvcolumn.datanavigateurlfields = string.empty; ogvcolumn.contextmenufilterfield = "menuitems"; ogvcolumn.iscontextmenufilter = true; foreach (gccontextmenuitem omenuitem in ocontextmenuitems) {

ogvcolumn.contextmenuitems.add(omenuitem); } ogvcolumn.applyreadunreadflag = true; ogvcolumn.readflagfield = "isread"; ogvcolumn.readunreadiconurl = utils.imagepath + "misc/newflag" + utils.currentuser.currentlanguage.tolower() + ".gif"; ogvcolumn.columntype = ecolumntype.linkbutton; ofagridviewex.gridcolumns.add(ogvcolumn); ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = true; ogvcolumn.isfilter = true; ogvcolumn.showheader = true; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.textbox; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = utils.getphrasevalue("fa_lbl_file_uploadedby"); ogvcolumn.datatextfields = "creator.name"; ogvcolumn.datatextformatstring = ""; ogvcolumn.datanavigateurlfields = "creator.id,parentcomponent.parentcomponent.id"; ogvcolumn.datanavigateurlformatstring = urlmappings.geturl(urls.ml_memberdetails) + "?uid={0}&id={1}"; ogvcolumn.columntype = ecolumntype.hyperlink; ofagridviewex.gridcolumns.add(ogvcolumn); ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = true; ogvcolumn.isfilter = true; ogvcolumn.showheader = true; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.dateinterval; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = utils.getphrasevalue("fa_lbl_file_uploaded_date");// +"(" + utils.getdateformatforuser() + ")"; ogvcolumn.datatextfields = "createtime"; ogvcolumn.datatextformatstring = utils.getdateformatforuser() + " " + utils.gettimeformatforuser(); ogvcolumn.columntype = ecolumntype.date; ofagridviewex.gridcolumns.add(ogvcolumn); ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = false; ogvcolumn.isfilter = false; ogvcolumn.showheader = false; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.textbox; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = utils.getphrasevalue("fa_lbl_file_size"); ogvcolumn.datatextfields = "size";

ogvcolumn.datatextformatstring = ""; ogvcolumn.columntype = ecolumntype.numeric; ofagridviewex.gridcolumns.add(ogvcolumn); ogvcolumn = new gridviewcolumn(); ogvcolumn.id = guid.newguid(); ogvcolumn.visible = true; ogvcolumn.isfilter = true; ogvcolumn.showheader = true; ogvcolumn.nulldisplaytext = string.empty; ogvcolumn.imagealternatetext = string.empty; ogvcolumn.filtertype = efiltertype.textbox; ogvcolumn.filterdropdownlistitems = null; ogvcolumn.headertext = utils.getphrasevalue("fa_lbl_file_size"); ogvcolumn.datatextfields = "formattedsize"; ogvcolumn.datatextformatstring = ""; ogvcolumn.columntype = ecolumntype.label; ogvcolumn.sortcolumnno = 5; ofagridviewex.gridcolumns.add(ogvcolumn); ofagridviewex.pagesize = 10; ofagridviewex.width = unit.percentage(0); ofagridviewex.filterapplyphrasekey = "fa_btn_list_filter_button"; ofagridviewex.filterfromtext = utils.getphrasevalue("mb_from"); ofagridviewex.filtertotext = utils.getphrasevalue("fa_lbl_to"); ofagridviewex.previouspagetext = "<<previous"; ofagridviewex.nextpagetext = "next>>"; ofagridviewex.filtercaption = utils.getphrasevalue("fa_msg_list_filter_header"); ofagridviewex.emptydatatext = utils.getphrasevalue("fa_msg_avgrid_no_data_available"); ofagridviewex.gridviewcaption = utils.getphrasevalue("fa_msg_avgrid_files"); ofagridviewex.datasource = includefileiconandsize(ofolder.files); ofagridviewex.databind();

} else if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("thumbnails")) { gccontextmenuitemcollection ocolitem = new gccontextmenuitemcollection(); gccontextmenuitem odropdownmenuitem; odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "copyfiles"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_copy_func"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_copy_func"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_copy.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true;

odropdownmenuitem.commandname = "cutfiles"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_cut_func"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_cut_func"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_cut.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "deletefiles"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_delete_func"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_delete_func"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_delete.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "setflagnewlist"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_set_new"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_set_new"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_view_thumbnail.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "setflagdownloadedlist"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_choose_set_downloaded"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_choose_set_downloaded"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_view_thumbnail.gif"; ocolitem.add(odropdownmenuitem); ogcfunctiondropdown.displaytext = utils.getphrasevalue("fa_lbl_choose_func"); ogcfunctiondropdown.dropdownmenuitems = ocolitem; ocolitem = new gccontextmenuitemcollection(); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "list"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_views_list"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_views_list"); odropdownmenuitem.imageurl =

"images/icons/action/icon_file_view_list.gif"; ocolitem.add(odropdownmenuitem); odropdownmenuitem = new gccontextmenuitem(); odropdownmenuitem.default = false; odropdownmenuitem.enabled = true; odropdownmenuitem.commandname = "thumbnails"; odropdownmenuitem.displaytext = utils.getphrasevalue("fa_lbl_views_thumbnail"); odropdownmenuitem.tooltip = utils.getphrasevalue("fa_lbl_views_thumbnail"); odropdownmenuitem.imageurl = "images/icons/action/icon_file_view_thumbnail.gif"; ocolitem.add(odropdownmenuitem); gcdatalist1.datasource = includefileiconandsize(getasthumbnail(ofolder.files)); gcdatalist1.databind(); gcdatalist1.visible = true; ofagridviewex.visible = false; utils.setsession(csessionvarnames.csmymail_view, "thumbnails"); } } protected string getdynamictext(arraylist alelements, string sphraseid) { cresult oresult = new cresult(); string strdnmictext = string.empty; object[] data = new object[] { sphraseid, utils.currentuser.currentlanguage, alelements, null }; oresult = m_ocontrolmanager.performaction("gettext", data, null, null); if (oresult.issuccess) { if (oresult.data != null) strdnmictext = oresult.data.tostring(); } else { strdnmictext = oresult.message; } return strdnmictext; } protected cfilecollection includefileiconandsize(cfilecollection ofilecol) { decimal dfsize = 0; string sdeletefilter = "4"; int ifilecountinfolder = 0; try { foreach (cfile ofile in ofilecol) { if (!ofile.versionno.equals("")) ifilecountinfolder += ofile.mylist.count; else

ifilecountinfolder += 1; if (file.exists(ccommonutil.getapppath() + "images\\icons\\filetype\\" + ofile.extension.substring(1) + ".gif")) { ofile.fileicon = m_apppath + "images/icons/filetype/" + ofile.extension.substring(1) + ".gif"; } else { ofile.fileicon = m_apppath + "images/icons/filetype/x.gif"; } if (ofile.creator.id.equals(m_ouser.id) && ! (bool)this.permissions[ccommonconstant.csdeletefile]) { if (!m_sfilelistactionfilters.equals(string.empty)) sdeletefilter = ",4"; } else { } ofile.formattedsize = getconvertedfilesize(ofile.size); dfsize = dfsize + ofile.size; } dfsize = math.round(dfsize, 3); this.foldersizeproperty = getconvertedfilesize(dfsize); this.filenoproperty = ifilecountinfolder.tostring();

} catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error); } return ofilecol; } protected string getconvertedfilesize(decimal dfilesize) { string str = string.empty; try { str = math.round(dfilesize, 0) + " bytes"; if (dfilesize >= 1024 && dfilesize < (1024 * 1024)) { str = math.round((dfilesize / 1024), 2) + " kb"; } else if (dfilesize >= (1024 * 1024) && dfilesize < (1024 * 1024 * 1024)) { str = math.round((dfilesize / (1024 * 1024)), 2) + " mb"; } else if (dfilesize >= (1024 * 1024 * 1024))

{ }

str = math.round((dfilesize / (1024 * 1024 * 1024)), 2) + " gb";

} catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error); } return str; } protected void populatedropdownstatic(gcdropdownlist ogcddlist, arraylist alphrase, arraylist alvaluelist) { listitem oitem; ogcddlist.items.clear(); for (int i = 0; i < alphrase.count; i++) { oitem = new listitem(); oitem.text = utils.getphrasevalue(alphrase[i].tostring()).trim(); oitem.value = alvaluelist[i].tostring().trim(); ogcddlist.items.add(oitem); }

}

protected void createcontextmenues() { m_sfilelistactionfilters = ctreateactionfilterid(); cmfolders.contextmenuitems.add(new gccontextmenuitem(utils.getphrasevalue("fa_lbl_menu_open_folder").trim(), "details", "", utils.getphrasevalue("fa_lbl_menu_tooltip_folder_details").trim(), "icons/action/icon_folder_open.gif", true)); cmfolders.contextmenuitems.add(new gccontextmenuitem(utils.getphrasevalue("fa_lbl_btn_newfolder").trim(), "new", "", utils.getphrasevalue("fa_lbl_menu_tooltip_folder_new").trim(), "icons/action/icon_folder_new.gif", false)); cmfolders.contextmenuitems.add(new gccontextmenuitem(utils.getphrasevalue("fa_lbl_btn_renamefolder").trim(), "rename", "", utils.getphrasevalue("fa_lbl_menu_tooltip_folder_rename").trim(), "icons/action/icon_folder_rename.gif", false)); cmfolders.contextmenuitems.add(new gccontextmenuitem(utils.getphrasevalue("fa_lbl_folder_delete").trim(), "delete", "", utils.getphrasevalue("fa_lbl_menu_tooltip_folder_delete").trim(), "icons/action/icon_folder_delete.gif", false)); } protected string ctreateactionfilterid() { string sfilter = string.empty; if ((bool)this.permissions[ccommonconstant.csreadfile]) sfilter = sfilter + "0,1"; if ((bool)this.permissions[ccommonconstant.csreadfile]) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ",";

sfilter = sfilter + "2"; } if ((bool)this.permissions[ccommonconstant.csreadfile] && (bool)this.permissions[ccommonconstant.csdeletefile]) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ","; sfilter = sfilter + "3"; } if ((bool)this.permissions[ccommonconstant.csdeletefile]) { if (!sfilter.equals(string.empty)) sfilter = sfilter + ","; sfilter = sfilter + "4"; } return sfilter; } protected string gettotalfileofselectedarchive(guid gcompid) { int ifcount = 0; if (int.parse(m_stotalfiles) >= 0 && m_stotalfiles != "-1") { ifcount = int.parse(m_stotalfiles); } else { if (m_ofoldercol != null) { foreach (cfolder ofold in m_ofoldercol) { if (ofold.componentid.equals(gcompid)) { ifcount = ifcount + (int)ofold.filecount; } }

}

} } return ifcount.tostring();

protected guid getfilecreatorid(guid gfileid) { guid gcreatorid = guid.empty; foreach (cfile ofl in ((cfilecollection)m_ofolder.files)) { if (ofl.id.equals(gfileid)) { gcreatorid = ofl.creator.id; break; } } return gcreatorid; } protected cfile getfile(cfile otempfile) { cfile file = new cfile();

cfolder ofolder = new cfolder(); cresult oresult = new cresult(); ofolder.id = m_ofolder.id; ofolder.componentid = m_ofolder.componentid; ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = m_ofolder.componentid; oresult = getfolderdetail(ofolder, ocontext, false); ofolder = (cfolder)oresult.data; foreach (cfile ofile in (cfilecollection)ofolder.files) { if (ofile.id.equals(otempfile.id)) { file = ofile; break; } } return file; } protected cfilecollection getasthumbnail(cfilecollection ofilecollection) { try { foreach (cfile ofile in ofilecollection) { if (ofile.contenttype.split('/')[0] == "image") { string surlstr = urlmappings.geturl(urls.fa_download) + "?file=" + ofile.physicalfilename.tostring() + "&action=0&fileloc=" + ofile.physicalfoldername.tostring() + "&cid=" + ofile.componentid.tostring(); ofile.physicalthumbname = surlstr; } else { if (file.exists(ccommonutil.getapppath() + "images\\icons\\filetype\\" + ofile.extension.substring(1) + ".gif")) { ofile.physicalthumbname = m_apppath + "images\\icons\\filetype\\" + ofile.extension.substring(1) + ".gif"; } else { ofile.physicalthumbname = m_apppath + "images\\icons\\filetype\\x.gif"; } } ofile.formattedsize = getconvertedfilesize(ofile.size); } } catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); httpcontext.current.response.redirect(urlmappings.geturl(urls.sys_erro r), true); }

return ofilecollection; } protected cfile getallversion(cfile ofile) { cfile file = new cfile(); cfolder ofolder = new cfolder(); cresult oresult = new cresult(); ofolder.id = m_ofolder.id; ofolder.componentid = m_ofolder.componentid; ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = m_ofolder.componentid; oresult = getfolderdetail(ofolder, ocontext, false); ofolder = (cfolder)oresult.data; cfilecollection ocollection = getlatestversioncollection(ofolder.files); foreach (cfile otempfile in ocollection) { if (otempfile.parentfile.equals(ofile.parentfile)) { file = otempfile; } } return file; } #endregion functions #region events protected void ibtnnewfolder_click(object sender, eventargs e) { utils.state.setstate(null, null, request.url.tostring()); utils.setsession(csessionvarnames.csmymail_folderaction, "newfolder"); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); cfolder ofolder = new cfolder(); ofolder.id = new guid(this.folderid.tostring()); ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid.tostring()); cresult oresult = new cresult(); oresult = (cresult)getfolderdetail(ofolder, ocontext, false); if (oresult.issuccess) { ofolder = (cfolder)oresult.data; if (ofolder != null) { string sredirecturl = httpcontext.current.request.path + "?" + mm_create_folder + "&id=" + request.querystring["id"].tostring(); response.redirect(geturlwithtabno(sredirecturl), true); }

else { utils.setsession(csessionvarnames.csmymail_folderid, null); showerror(utils.getphrasevalue("fa_msg_folder_not_availabel_to_pro

cess")); }

}

} protected void btnfileupload_click(object sender, eventargs e) { utils.setsession(csessionvarnames.csmymail_currentfolder, this.folderid); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); string surlstr = httpcontext.current.request.path + "?" + mm_upload_file + "&mode=0&cid=" + this.foldercomponentid; utils.state.setstate(null, "", request.url.tostring() + "&module=mymail"); /**/ if (issolutioncontext) { string sadditionalqs = httpcontext.current.request.querystring.get("tab");

}

if (sadditionalqs != null) surlstr = surlstr + "&tab=" + sadditionalqs;

response.redirect(surlstr); } protected void btnpastefile_click(object sender, eventargs e) { string surl = string.empty; try { if (utils.getsession(csessionvarnames.csmymail_actiondata) != null && utils.getsession(csessionvarnames.csmymail_action) != null) { decimal dspaceleft = (decimal.parse(utils.getsession(csessionvarnames.csmymail_diskspacesetted).tostrin g()) - m_ofamanager.getdiskspaceused(this.foldercomponentid, m_ocomponentcontext)); dspaceleft = dspaceleft * 1024 * 1024; int ifilecountcopied = 0; cresult oresult = null; cfilecollection ofilecolpast = null; cfolder ofoldercopyto = new cfolder(); ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid);

ofilecolpast = (cfilecollection)utils.getsession(csessionvarnames.csmymail_actiondata); this.actiontype = (eactiontype)utils.getsession(csessionvarnames.csmymail_action); ofoldercopyto.id = new guid(this.folderid); ofoldercopyto.componentid = new guid(this.foldercomponentid); if (ofilecolpast != null && ofilecolpast.count > 0) { if (ofoldercopyto.id.equals(((cfile)ofilecolpast[0]).folder.id) && ! getfilenamelengthexceed(ofilecolpast).equals(string.empty) && this.actiontype == eactiontype.copypastefile) { utils.setsession(csessionvarnames.csmymail_actiondata, null); utils.setsession(csessionvarnames.csmymail_action, null); cconfirmwindow oconfirmwindow = new cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = null; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = string.empty; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = utils.getphrasevalue("fa_lbl_header_error").trim(); oconfirmwindow.displaymessage = utils.getphrasevalue("fa_lbl_max_filename_size_exceed_paste") + "" + getfilenamelengthexceed(ofilecolpast) + ""; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.cancelvisible = false; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } else if ((getsizeofcopiedfile(ofilecolpast) < dspaceleft) || ((ofoldercopyto.componentid.equals(((cfile)ofilecolpast[0]).componentid) && this.actiontype == eactiontype.cutpastefile))) { object odata = new object[] { ofilecolpast, ofoldercopyto, utils.currentuser }; if (this.actiontype == eactiontype.copypastefile) { oresult = pastcopyfile(odata); } else if (this.actiontype == eactiontype.cutpastefile) { oresult = pastecutfile(odata); } if (oresult.issuccess)

{ btnpastefile.display = false; utils.setsession(csessionvarnames.csmymail_actiondata, null);

utils.setsession(csessionvarnames.csmymail_action,

null); cfolder ofolder = new cfolder(); ccomponentcontext ogroupcontext = new ccomponentcontext(); ofolder.id = new guid(this.folderid.tostring()); ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); m_stotalfiles = gettotalfileofselectedarchive(new guid(this.foldercomponentid.tostring())); m_stotalfiles = (int.parse(m_stotalfiles) + ofilecolpast.count) + ""; if (oresult.data != null) { string sdisplaymessage = ""; string scommandname = ""; ofilecolpast = (cfilecollection)oresult.data; sdisplaymessage = utils.getphrasevalue("fa_lbl_file_replace_message1") + "

"; foreach (cfile ofl in ofilecolpast) { sdisplaymessage = sdisplaymessage + "" + ofl.name + "" + "
";

}

sdisplaymessage = sdisplaymessage + "

" + utils.getphrasevalue("fa_lbl_file_replace_message2"); if (this.actiontype == eactiontype.copypastefile) { scommandname = "replacecopyfiles"; object ardata = new object[] { ofilecolpast, utils.currentuser }; cconfirmwindow();

cconfirmwindow oconfirmwindow = new

oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = ardata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = scommandname; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl =

request.url.tostring(); oconfirmwindow.title = utils.getphrasevalue("fa_lbl_file_replace_header"); oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif";

eactiontype.cutpastefile)

oconfirmwindow.show(); } else if (this.actiontype == {

ofoldercopyto, utils.currentuser };

scommandname = "replacecutfiles"; object ardata = new object[] { ofilecolpast, cconfirmwindow oconfirmwindow = new

cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = ardata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = scommandname; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = utils.getphrasevalue("fa_lbl_file_replace_header"); oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } oresult = getfolderdetail(ofolder, ogroupcontext, false);

folderdetail, m_ofolder);

if (oresult.issuccess == true) { ofolder = (cfolder)oresult.data; m_ofolder = (cfolder)oresult.data; utils.setsession(csessionvarnames.csmymail_get

ofolder.files = getlatestversioncollection(ofolder.files); applypermissiontofilelist(ofolder.files);

populatefilelist(ofolder); setfolderinformation();

} } else { oresult = getfolderdetail(ofolder, ogroupcontext, false); if (oresult.issuccess == true) { ofolder = (cfolder)oresult.data; m_ofolder = (cfolder)oresult.data; utils.setsession(csessionvarnames.csmymail_get

folderdetail, m_ofolder);

m_ofolder.files = getlatestversioncollection(m_ofolder.files);

}

applypermissiontofilelist(m_ofolder.files); populatefilelist(m_ofolder); setfolderinformation();

}

} else { btnpastefile.display = false; if (!oresult.isexception) { showerror(oresult.message); } else { surl = urlmappings.geturl(urls.sys_error); } }

} else {

showerror(utils.getphrasevalue("fa_lbl_file_copy_disk_spac

e_exceed"));

} } else { showerror(utils.getphrasevalue("fa_msg_file_not_availabel_to_p

rocess")); }

}

} catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error);

} if (!surl.equals(string.empty)) { httpcontext.current.response.redirect(surl, true); } } protected void tvfolderlist_selectednodechanged(object sender, eventargs e) { string surl = string.empty; try { gctreeview otreeview = new gctreeview(); otreeview = (gctreeview)sender; if (otreeview != null) { cfolder ofolder = new cfolder(); string sdata = otreeview.selectednode.value.tostring(); string[] data = sdata.split('|'); this.folderid = data[0]; this.foldercomponentid = data[1]; utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); ofolder.id = new guid(this.folderid.tostring()); ccomponentcontext ogroupcontext = new ccomponentcontext(); ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); cresult oresult = getfolderdetail(ofolder, ogroupcontext, true); if (oresult.issuccess == true) { ofolder = (cfolder)oresult.data; m_ofolder = (cfolder)oresult.data;

, ofolder); ofolder.parent);

if (m_ofolder != null) { utils.setsession(csessionvarnames.csmymail_getfolderdetail utils.setsession(csessionvarnames.csmymail_parentfolder,

bool bflag = ((cpermission)ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefolder; })).isset; if (bflag) { ibtnnewfolder.display = true; }

else { ibtnnewfolder.display = false; } bflag = ((cpermission)ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefile; })).isset; if (bflag) { btnfileupload.display = true; } else { btnfileupload.display = false; } m_ofolder.files = getlatestversioncollection(m_ofolder.files); applypermissiontofilelist(m_ofolder.files); populatefilelist(m_ofolder); setfolderinformation();

} else {

utils.setsession(csessionvarnames.csmymail_folderid,

null);

showerror(utils.getphrasevalue("fa_msg_folder_not_availabe

l_to_process"));

} } else { if (!oresult.isexception) { showerror(oresult.message); } else { surl = urlmappings.geturl(urls.sys_error); }

}

} utils.setsession(csessionvarnames.csmymail_selectednode, tvfolderlist.getnode(this.folderid.tostring())); tvfolderlist.selectednodestyle.font.bold = true; } catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error);

}

}

if (!surl.equals(string.empty)) { httpcontext.current.response.redirect(surl, true); }

protected void gcactiondropdown_selectedindexchanged(object sender, eventargs e)

{ try { string scommandname = string.empty; string stitle = string.empty; string sdisplaymessage = string.empty; int action = gcactiondropdown.selectedindex; ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid); arraylist alfileidlist = new arraylist(); cfilecollection ofilecol = new cfilecollection(); cfile ofile;

if (gcactiondropdown != null) { if (action == 1) { this.actiontype = eactiontype.copypastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.copypastefile); scommandname = "copyfiles"; stitle = "copy files"; sdisplaymessage = "are you sure you want to copy this record?";

}

else if (action == 2) { this.actiontype = eactiontype.cutpastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.cutpastefile); scommandname = "cutfiles"; stitle = "cut files"; sdisplaymessage = "are you sure you want to cut this record?"; } else if (action == 3) { this.actiontype = eactiontype.deletefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.deletefile);

scommandname = "deletefiles"; stitle = "delete files"; sdisplaymessage = "are you sure you want to delete these

records?"; }

cconfirmwindow oconfirmwindow = new cconfirmwindow(); for (int i = 0; i < agvfilelist.gridview.rows.count; i++) { if (agvfilelist.gridview.rows[i].cells[0].controls[0].gettype().equals(typeof(gchtmlc heckbox))) { gchtmlcheckbox ocheckbox = (gchtmlcheckbox)agvfilelist.gridview.rows[i].cells[0].controls[0]; if (ocheckbox.checked) { ofile = new cfile(); ofile.id = new guid(ocheckbox.value.tostring()); ofile.creator.id = getfilecreatorid(ofile.id); if (ofile.creator.id == guid.empty) { oconfirmwindow = new cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = null; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = string.empty; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = utils.getphrasevalue("fa_lbl_header_error").trim(); oconfirmwindow.displaymessage = utils.getphrasevalue("fa_lbl_max_filename_size_exceed_paste"); oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.cancelvisible = false; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } else ofilecol.add(ofile); } } } utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_actiondata, ofilecol);

object[] odata = new object[] { ofilecol, utils.currentuser }; oconfirmwindow = new cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = odata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = scommandname; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = stitle; oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } gcactiondropdown.selectedindex = 0; } catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessage, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error); }

}

protected void gcimgselecdropdownlist_selectedindexchanged(object sender, eventargs e) { cfolder ofolder = new cfolder(); ccomponentcontext ogroupcontext = new ccomponentcontext(); ofolder.id = new guid(this.folderid.tostring()); ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); cresult oresult = getfolderdetail(ofolder, ogroupcontext, false); ofolder = (cfolder)oresult.data; if (gcimgselecdropdownlist.selecteditem.value == "1") { populatefilelist(ofolder); gcdatalist1.visible = false; agvfilelist.visible = true; } else if (gcimgselecdropdownlist.selecteditem.value == "2") { gcdatalist1.datasource = includefileiconandsize(getasthumbnail(ofolder.files));

gcdatalist1.databind(); gcdatalist1.visible = true; agvfilelist.visible = false; }

}

protected void gcutilitybuttonset1_command(object sender, commandeventargs e) { if (e.commandname.tostring() == gcutilitybuttoncommandname.filter.tostring()) { ofagridviewex.displayfilter = true; } else if (e.commandname.tostring() == gcutilitybuttoncommandname.export.tostring()) { ofagridviewex.exportgrid(utils.getexportseparator()); } } protected void agvfilelist_itemcommand(object sender, eventargs e) { } protected void imbinformation_click(object sender, imageclickeventargs e) { utils.state.setstate(null, "", request.url.tostring() + "&module=mymail"); utils.setsession(csessionvarnames.csmymail_fileid, ((imagebutton)sender).commandargument.tostring()); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); this.redirecturl = httpcontext.current.request.path + "?" + fa_filedetailsview + "&fid=" + ((imagebutton)sender).commandargument.tostring() + "&cid=" + this.foldercomponentid.tostring(); } protected void imbdelete_click(object sender, imageclickeventargs e) { string scommandname = string.empty; string stitle = utils.getphrasevalue("fa_lbl_delete_header"); string sdisplaymessage = string.empty; string snodeletepermission = string.empty; bxfolder.visible = false; bxfilelist.visible = false; ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid); cfilecollection ofilecol = new cfilecollection(); cfilecollection oversioncollection = new cfilecollection(); cfile ofile;

ofile = new cfile(); ofile.id = new guid(((imagebutton)sender).commandargument.tostring()); ofile.creator.id = getfilecreatorid(ofile.id); ofile = getfile(ofile); ofilecol.add(ofile); if (!ofile.versionno.equals("")) { ofile = getallversion(ofile);

}

foreach (cfile otempfile in (cfilecollection)ofile.mylist) { oversioncollection.add(otempfile); }

this.actiontype = eactiontype.deletefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.deletefile); sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_message") + "
"; if (oversioncollection.count > 0) { sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_version_message") + "
"; } else { sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_message") + "
"; } foreach (cfile ofl in ofilecol) { bool bflag = ((cpermission)ofl.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; if (bflag) { } else { if (snodeletepermission.equals("")) snodeletepermission = snodeletepermission + ofl.name.tostring(); else snodeletepermission = snodeletepermission + "," + ofl.name.tostring(); } "
";

sdisplaymessage = sdisplaymessage + "" + ofl.name + "" +

} sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_delete_message2"); utils.setsession(csessionvarnames.csmymail_folderid,

this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_actiondata, ofilecol); cconfirmwindow oconfirmwindow = new cconfirmwindow(); object[] odata = null; if (oversioncollection.count > 0) { odata = new object[] { oversioncollection, utils.currentuser }; } else { odata = new object[] { ofilecol, utils.currentuser }; } if (!(snodeletepermission.equals(""))) { sdisplaymessage = utils.getphrasevalue("fa_mess_no_permission_delete_file"); oconfirmwindow.cancelvisible = false; } oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = odata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = "deletefiles"; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = stitle; oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } protected void gcdatalist1_selectedindexchanged(object sender, eventargs e) { } protected void cmfilelist_itemcommand(object sender, commandeventargs e) { string scopy = "copy"; string sdelete = "delete"; string scut = "cut"; string sdownload = "download"; string sdetails = "details"; string scommandname = string.empty; string stitle = string.empty;

string sdisplaymessage = string.empty; string sdata = cmfilelist.commandargument.tostring(); string[] data = sdata.split('|'); bxfolder.visible = false; bxfilelist.visible = false; ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid); cfilecollection ofilecol = new cfilecollection(); cfile ofile; ofile = new cfile(); ofile.id = new guid(data[0]); ofile.creator.id = getfilecreatorid(ofile.id); ofilecol.add(ofile); if (e.commandname.equals(scopy)) { this.actiontype = eactiontype.copypastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.copypastefile);

}

scommandname = "copyfiles"; stitle = "copy files"; sdisplaymessage = "are you sure you want to copy this record?";

if (e.commandname.equals(scut)) { this.actiontype = eactiontype.cutpastefile; utils.setsession(csessionvarnames.csmymail_action, (eactiontype.cutpastefile)); scommandname = "cutfiles"; stitle = "cut files"; sdisplaymessage = "are you sure you want to cut this record?"; } if (e.commandname.equals(sdelete)) { this.actiontype = eactiontype.deletefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.deletefile);

}

scommandname = "deletefiles"; stitle = "delete files"; sdisplaymessage = "are you sure you want to delete these records?";

if (e.commandname.equals(sdetails)) { utils.setsession(csessionvarnames.csmymail_fileid, cmfilelist.commandargument.tostring());

utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); string sredirecturl = httpcontext.current.request.path + "?" + mm_view_attachmentdetails + "&id=" + request.querystring["id"].tostring(); }

httpcontext.current.response.redirect(geturlwithtabno(sredirecturl));

if (e.commandname.equals(sdownload)) { string surlstr = ""; surlstr = urlmappings.geturl(urls.fa_download) + "?fid=" + ofile.id.tostring() + "&action=1&cid=" + this.foldercomponentid.tostring(); httpcontext.current.response.redirect(surlstr, false); } utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_actiondata, ofilecol); object[] odata = new object[] { ofilecol, utils.currentuser }; cconfirmwindow oconfirmwindow = new cconfirmwindow(); oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = odata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = scommandname; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = stitle; oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); } protected void cmfolders_itemcommand(object sender, commandeventargs e) { utils.state.setstate(null, null, request.url.tostring()); string sdata = cmfolders.commandargument.tostring();

string[] data = sdata.split('|'); cfolder ofolder = new cfolder(); ofolder.id = new guid(data[0]); ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(data[1]); cresult oresult = new cresult(); oresult = (cresult)getfolderdetail(ofolder, ocontext, false); if (oresult.issuccess) { string sredirecturl = string.empty; string scommandname = string.empty; string stitle = string.empty; string sdisplaymessage = string.empty; ofolder = (cfolder)oresult.data; if (ofolder != null) { switch (e.commandname.tostring()) { case "new": sdata = cmfolders.commandargument.tostring(); data = sdata.split('|'); this.folderid = data[0]; this.foldercomponentid = data[1]; this.folderid);

utils.setsession(csessionvarnames.csmymail_folderid,

utils.setsession(csessionvarnames.csmymail_foldercomponent id, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_folderaction, "newfolder"); utils.setsession(csessionvarnames.csmymail_selectednode, tvfolderlist.getnode(this.folderid.tostring())); sredirecturl = httpcontext.current.request.path + "?" + mm_create_folder + "&id=" + request.querystring["id"].tostring(); response.redirect(geturlwithtabno(sredirecturl), true); break; case "rename": sdata = cmfolders.commandargument.tostring(); data = sdata.split('|'); this.folderid = data[0]; this.foldercomponentid = data[1]; utils.setsession(csessionvarnames.csmymail_folderid, this.folderid);

utils.setsession(csessionvarnames.csmymail_foldercomponent id, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_folderaction, "renamefolder"); utils.setsession(csessionvarnames.csmymail_selectednode, tvfolderlist.getnode(this.folderid.tostring())); sredirecturl = httpcontext.current.request.path + "?" + mm_create_folder + "&id=" + request.querystring["id"].tostring(); response.redirect(geturlwithtabno(sredirecturl), true); break;

"deletefolder");

case "delete": utils.setsession(csessionvarnames.csmymail_folderaction,

utils.setsession(csessionvarnames.csmymail_selectednode, tvfolderlist.getnode(this.folderid.tostring())); if (oresult.issuccess == true) { ofolder = (cfolder)oresult.data; utils.setsession(csessionvarnames.csmymail_currfolderi d, ofolder.id.tostring()); utils.setsession(csessionvarnames.csmymail_folderid, ofolder.parent.id.tostring()); utils.setsession(csessionvarnames.csmymail_foldercompo nentid, ofolder.componentid.tostring()); } else { if (!oresult.isexception) { showerror(oresult.message); } else { httpcontext.current.response.redirect(urlmappings. geturl(urls.sys_error), true); } } if (ofolder.files.count > 0) { scommandname = string.empty; stitle = utils.getphrasevalue("fa_lbl_header_error").trim(); sdisplaymessage = utils.getphrasevalue("fa_mess_no_delete_folder_contain_file"); utils.setsession(csessionvarnames.csmymail_folderid, data[0]);//this.folderid.tostring(); utils.setsession(csessionvarnames.csmymail_foldercompo nentid, data[1]);//this.foldercomponentid.tostring(); } else { scommandname = "deletefolder"; stitle = utils.getphrasevalue("fa_lbl_folder_delete").trim();

arraylist alelem = new arraylist(); ofolder.name = utils.getmultilinetext(ofolder.name, 40).trim().replace("<pre>", "").replace("", ""); alelem.add(ofolder); sdisplaymessage = getdynamictext(alelem, "fa_lbl_fold_del_mess"); } object[] odata = new object[] { ofolder, utils.currentuser };

cconfirmwindow oconfirmwindow = new cconfirmwindow();

oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = odata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = scommandname; oconfirmwindow.successurl = geturlwithtabno(httpcontext.current.request.path + "?" + cmymailcontrol.mm_view_maillist + "&id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = request.url.tostring(); oconfirmwindow.title = stitle; oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; if (ofolder.files.count > 0) oconfirmwindow.cancelvisible = false; oconfirmwindow.headerimageurl = "images/frame/header/header_image_message_delete.gif"; oconfirmwindow.show(); break; case "details": string surl = string.empty; try { ofolder = new cfolder(); sdata = cmfolders.commandargument.tostring(); data = sdata.split('|'); this.folderid = data[0]; this.foldercomponentid = data[1]; utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring());

utils.setsession(csessionvarnames.csmymail_foldercompo nentid, this.foldercomponentid.tostring()); ofolder.id = new guid(this.folderid.tostring());

ccomponentcontext();

ccomponentcontext ogroupcontext = new

ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); oresult = getfolderdetail(ofolder, ogroupcontext, false); if (oresult.issuccess == true) { ofolder = (cfolder)oresult.data; m_ofolder = (cfolder)oresult.data; utils.setsession(csessionvarnames.csmymail_getfold erdetail, ofolder); bool bflag = ((cpermission)ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefolder; })).isset; if (bflag) { ibtnnewfolder.display = true; } else { ibtnnewfolder.display = false; } bflag = ((cpermission)ofolder.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.cscreatefile; })).isset; if (bflag) { btnfileupload.display = true; } else { btnfileupload.display = false; } m_ofolder.files = getlatestversioncollection(m_ofolder.files); applypermissiontofilelist(m_ofolder.files); populatefilelist(m_ofolder); setfolderinformation(); } else { if (!oresult.isexception) { showerror(oresult.message); } else {

surl = urlmappings.geturl(urls.sys_error); } } utils.setsession(csessionvarnames.csmymail_selectednod e, tvfolderlist.getnode(this.folderid.tostring())); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid); utils.setsession(csessionvarnames.csmymail_foldercompo nentid, this.foldercomponentid.tostring()); createtree(m_ofoldercol); } catch (exception oexp) { utils.setsession(csessionvarnames.csmymail_errormessag e, oexp.message); this.redirecturl = urlmappings.geturl(urls.sys_error); } if (!surl.equals(string.empty)) { httpcontext.current.response.redirect(surl, true); } break; default: break; } } else { showerror(utils.getphrasevalue("fa_msg_folder_not_availabel_to_pro

cess"));

}

} else {

if (!oresult.isexception) { showerror(oresult.message); } else { httpcontext.current.response.redirect(urlmappings.geturl(urls.sys_ error), true); } } } public override cresult performconfirmationokevent(object odata, string scommandname, ccomponentcontext ocomponentcontext) { cresult oresult = new cresult(); m_ocontrolmanager = new ccontrolmanager(); if (scommandname.equals("deletefolder")) {

oresult = m_ocontrolmanager.performaction("deletefolder", odata, ocomponentcontext, utils.currentuser); } if (scommandname.equals("copyfiles")) { oresult = m_ocontrolmanager.performaction("copyfiles", odata, ocomponentcontext, utils.currentuser); utils.setsession(csessionvarnames.csmymail_actiondata, (cfilecollection)oresult.data); } if (scommandname.equals("cutfiles")) { oresult = m_ocontrolmanager.performaction("cutfiles", odata, ocomponentcontext, utils.currentuser); utils.setsession(csessionvarnames.csmymail_actiondata, (cfilecollection)oresult.data); } if (scommandname.equals("deletefiles")) { oresult = m_ocontrolmanager.performaction("deletefiles", odata, ocomponentcontext, utils.currentuser); } if (scommandname.equals("replacecutfiles")) { oresult = m_ocontrolmanager.performaction("replacecutfiles", odata, ocomponentcontext, utils.currentuser); } if (scommandname.equals("replacecopyfiles")) { oresult = m_ocontrolmanager.performaction("replacecopyfiles", odata, ocomponentcontext, utils.currentuser); } if (scommandname == string.empty) { oresult.issuccess = true; } return oresult; } protected void performaction_linkbuttoncommand_gridviewex(object sender, commandeventargs e) { utils.state.setstate(null, "", request.url.tostring() + "&module=mymail"); string string string string

scommandname = string.empty; stitle = string.empty; sdisplaymessage = string.empty; sheaderimage = string.empty;

string sdata = e.commandargument.tostring(); string[] data = sdata.split('|'); bxfolder.visible = false; bxfilelist.visible = false;

ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid); cfilecollection ofilecol = new cfilecollection(); cfilecollection oversioncollection = new cfilecollection(); cfile ofile; ofile = new cfile(); ofile.id = new guid(data[0]); ofile.creator.id = getfilecreatorid(ofile.id); ofile = getfile(ofile); ofilecol.add(ofile); if (!ofile.versionno.equals("")) { ofile = getallversion(ofile); foreach (cfile otempfile in (cfilecollection)ofile.mylist) { oversioncollection.add(otempfile); } } cconfirmwindow oconfirmwindow = new cconfirmwindow(); if (ofile.id.equals(new guid(data[0]))) { if ("copyfiles".equals(e.commandname)) { this.actiontype = eactiontype.copypastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.copypastefile);

if (oversioncollection.count > 0) { sdisplaymessage = utils.getphrasevalue("fa_lbl_copy_version_message") + "
";

+ "
";

} else { sdisplaymessage = utils.getphrasevalue("fa_lbl_copy_message")

} foreach (cfile ofl in ofilecol) { sdisplaymessage = sdisplaymessage + "" + ofl.name + "" + "
";

} sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_copy_paste_message"); sheaderimage = "images/frame/header/header_image_file_copy.gif"; stitle = utils.getphrasevalue("fa_lbl_copy_header").trim(); }

else if ("cutfiles".equals(e.commandname)) { this.actiontype = eactiontype.cutpastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.cutpastefile);

if (oversioncollection.count > 0) { sdisplaymessage = utils.getphrasevalue("fa_lbl_cut_version_message") + "
";

"
";

+ "
";

} else { sdisplaymessage = utils.getphrasevalue("fa_lbl_cut_message") + } foreach (cfile ofl in ofilecol) { sdisplaymessage = sdisplaymessage + "" + ofl.name + ""

} sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_copy_paste_message"); sheaderimage = "images/frame/header/header_image_file_cut.gif"; stitle = utils.getphrasevalue("fa_lbl_cut_header").trim(); } else if ("deletefiles".equals(e.commandname)) { this.actiontype = eactiontype.deletefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.deletefile);

if (oversioncollection.count > 0) { sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_version_message") + "
"; foreach (cfile ofl in ofilecol) { sdisplaymessage = sdisplaymessage + "" + ofl.name + "" + "
";

} } else { sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_message") + "
"; foreach (cfile ofl in ofilecol)

{ "" + "
";

sdisplaymessage = sdisplaymessage + "" + ofl.name +

} } sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_delete_message2"); sheaderimage = "images/frame/header/header_image_message_delete.gif"; stitle = utils.getphrasevalue("fa_lbl_delete_header").trim(); } else if ("details".equals(e.commandname)) { utils.setsession(csessionvarnames.csmymail_fileid, e.commandargument.tostring()); utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); string sredirecturl = httpcontext.current.request.path + "?" + mm_view_attachmentdetails + "&fid=" + e.commandargument.tostring() + "&cid=" + this.foldercomponentid.tostring() + "&folderid=" + this.folderid.tostring(); httpcontext.current.response.redirect(geturlwithtabno(sredirecturl )); } else if ("download".equals(e.commandname)) { string surlstr = ""; surlstr = urlmappings.geturl(urls.fa_download) + "?fid=" + ofile.id.tostring() + "&action=1&cid=" + this.foldercomponentid.tostring(); httpcontext.current.response.redirect(surlstr, false); } utils.setsession(csessionvarnames.csmymail_actiondata, ofilecol); object[] odata = null; if (oversioncollection.count > 0) { odata = new object[] { oversioncollection, utils.currentuser }; } else { odata = new object[] { ofilecol, utils.currentuser }; } oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = odata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = e.commandname; ; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring() + "&module=mymail"); oconfirmwindow.cancelurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" +

request.querystring["id"].tostring()); oconfirmwindow.title = stitle; oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = sheaderimage; oconfirmwindow.show(); } else { showerror(utils.getphrasevalue("fa_msg_file_not_availabel_to_process") ); } } protected void performaction_linkbuttoncommand_functiondropdown(object sender, commandeventargs e) { utils.state.setstate(null, null, request.url.tostring()); string scommandname = string.empty; string stitle = string.empty; string sdisplaymessage = string.empty; string sheaderimage = string.empty; string snodeletepermission = ""; bool bfilenotavailable = false; bool bcontainsversionedfile = false; cfilecollection oversioncollection = new cfilecollection(); bxfolder.visible = false; bxfilelist.visible = false; ccomponentcontext ocontext = new ccomponentcontext(); ocontext.component.id = new guid(this.foldercomponentid); arraylist alfileidlist = new arraylist(); cfilecollection ofilecol = new cfilecollection(); list ochecklist = new list(); cfile ofile; if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { ochecklist = ofagridviewex.getselectedcheckboxlist(0); } else { foreach (datalistitem odataitem in gcdatalist1.items) { htmlinputcheckbox ockhbox = (htmlinputcheckbox)odataitem.findcontrol("checkbox1");//checkbox if (ockhbox.checked) { hiddenfield obutton = (hiddenfield)odataitem.findcontrol("hiddenfield1"); alfileidlist.add(obutton.value.tostring()); }

} } if ("copyfiles".equals(e.commandname)) { this.actiontype = eactiontype.copypastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.copypastefile); if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { foreach (htmlinputcheckbox ohtmlinputcheckbox in ochecklist) { ofile = new cfile(); ofile.id = new guid(ohtmlinputcheckbox.value.tostring()); ofile = getfile(ofile); if (ofile.id.equals(new guid(ohtmlinputcheckbox.value.tostring()))) { bool bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag) { ofilecol.add(ofile); oversioncollection.add(ofile); if (!ofile.versionno.equals("")) { bcontainsversionedfile = true; ofile = getallversion(ofile); (cfilecollection)ofile.mylist)

foreach (cfile otempfile in {

oversioncollection.add(otempfile);

}

ofile.name.tostring();

} } else { if (snodeletepermission.equals("")) snodeletepermission = snodeletepermission + else snodeletepermission = snodeletepermission + "," +

ofile.name.tostring();

}

} else {

bfilenotavailable = true;

}

} } else { for (int i = 0; i < alfileidlist.count; i++) { ofile = new cfile(); ofile.id = new guid(alfileidlist[i].tostring()); ofile = getfile(ofile); if (ofile.id.equals(new guid(alfileidlist[i].tostring()))) { bool bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag) { ofilecol.add(ofile); oversioncollection.add(ofile); if (!ofile.versionno.equals("")) { bcontainsversionedfile = true; ofile = getallversion(ofile); foreach (cfile otempfile in (cfilecollection)ofile.mylist)

{ }

oversioncollection.add(otempfile);

} } else { if (snodeletepermission.equals("")) snodeletepermission = snodeletepermission + ofile.name.tostring();

else snodeletepermission = snodeletepermission + "," +

ofile.name.tostring(); }

} else { } }

bfilenotavailable = true;

}

if (bcontainsversionedfile) { sdisplaymessage = utils.getphrasevalue("fa_lbl_copy_version_message") + "
"; } else { sdisplaymessage = utils.getphrasevalue("fa_lbl_copy_message") +

"
"; }

"
";

foreach (cfile ofl in ofilecol) { sdisplaymessage = sdisplaymessage + "" + ofl.name + "" + }

if (!(snodeletepermission.equals(""))) { snodeletepermission = utils.getphrasevalue("fa_mess_no_permission_file_copy") + "
" + snodeletepermission + "
"; } sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_copy_paste_message"); sheaderimage = "images/frame/header/header_image_file_copy.gif"; stitle = utils.getphrasevalue("fa_lbl_copy_header").trim(); } else if ("cutfiles".equals(e.commandname)) { this.actiontype = eactiontype.cutpastefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.cutpastefile); if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { foreach (htmlinputcheckbox ohtmlinputcheckbox in ochecklist) { ofile = new cfile(); ofile.id = new guid(ohtmlinputcheckbox.value.tostring()); ofile = getfile(ofile); if (ofile.id.equals(new guid(ohtmlinputcheckbox.value.tostring()))) { if (!ofile.versionno.equals("")) { ofile.id = ofile.parentfile; ofile = getfile(ofile); } bool bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; bool bflag1 = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag && bflag1) { ofilecol.add(ofile); oversioncollection.add(ofile); if (!ofile.versionno.equals("")) {

bcontainsversionedfile = true; ofile = getallversion(ofile); (cfilecollection)ofile.mylist)

foreach (cfile otempfile in {

oversioncollection.add(otempfile);

}

ofile.name.tostring();

} } else { if (snodeletepermission.equals("")) snodeletepermission = snodeletepermission + else snodeletepermission = snodeletepermission + "," +

ofile.name.tostring();

}

} else {

bfilenotavailable = true;

}

} } else { for (int i = 0; i < alfileidlist.count; i++) { ofile = new cfile(); ofile.id = new guid(alfileidlist[i].tostring()); ofile = getfile(ofile); if (ofile.id.equals(new guid(alfileidlist[i].tostring()))) { bool bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; bool bflag1 = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csreadfile; })).isset; if (bflag && bflag1) { ofilecol.add(ofile); oversioncollection.add(ofile); if (!ofile.versionno.equals("")) { bcontainsversionedfile = true; ofile = getallversion(ofile); foreach (cfile otempfile in

(cfilecollection)ofile.mylist) {

oversioncollection.add(otempfile);

}

ofile.name.tostring();

} } else { if (snodeletepermission.equals("")) snodeletepermission = snodeletepermission + else snodeletepermission = snodeletepermission + "," +

ofile.name.tostring();

}

} else {

bfilenotavailable = true;

}

}

} if (bcontainsversionedfile) { sdisplaymessage = utils.getphrasevalue("fa_lbl_cut_version_message") + "
"; } else { sdisplaymessage = utils.getphrasevalue("fa_lbl_cut_message") + "
"; } foreach (cfile ofl in ofilecol) { sdisplaymessage = sdisplaymessage + "" + ofl.name + "" + "
";

}

if (!(snodeletepermission.equals(""))) { snodeletepermission = utils.getphrasevalue("fa_mess_no_permission_file_cut") + "
" + snodeletepermission + "
"; } sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_copy_paste_message"); sheaderimage = "images/frame/header/header_image_file_cut.gif"; stitle = utils.getphrasevalue("fa_lbl_cut_header").trim(); } else if ("deletefiles".equals(e.commandname)) { this.actiontype = eactiontype.deletefile; utils.setsession(csessionvarnames.csmymail_action, eactiontype.deletefile);

if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { foreach (htmlinputcheckbox ohtmlinputcheckbox in ochecklist) { ofile = new cfile(); ofile.id = new guid(ohtmlinputcheckbox.value.tostring()); ofile = getfile(ofile); if (ofile.id.equals(new guid(ohtmlinputcheckbox.value.tostring()))) { if (!ofile.versionno.equals("")) { ofile.id = ofile.parentfile; ofile = getfile(ofile); } bool bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; if (bflag) { ofilecol.add(ofile); oversioncollection.add(ofile); if (!ofile.versionno.equals("")) { bcontainsversionedfile = true; ofile = getallversion(ofile); foreach (cfile otempfile in (cfilecollection)ofile.mylist)

{ }

oversioncollection.add(otempfile);

} } else { if (snodeletepermission.equals("")) snodeletepermission = "
" + snodeletepermission + ofile.name.tostring() + "
"; else snodeletepermission = snodeletepermission + ofile.name.tostring() + "
"; } } else { bfilenotavailable = true; } } } else

{ for (int i = 0; i < alfileidlist.count; i++) { ofile = new cfile(); ofile.id = new guid(alfileidlist[i].tostring()); ofile = getfile(ofile); if (ofile.id.equals(new guid(alfileidlist[i].tostring()))) { bool bflag = ((cpermission)ofile.permissionlist.find(delegate(cpermission operm) { return operm.permissionname == ccommonconstant.csdeletefile; })).isset; if (bflag) { ofilecol.add(ofile); oversioncollection.add(ofile); if (!ofile.versionno.equals("")) { bcontainsversionedfile = true; ofile = getallversion(ofile); (cfilecollection)ofile.mylist)

foreach (cfile otempfile in {

oversioncollection.add(otempfile);

}

} } else { if (snodeletepermission.equals("")) snodeletepermission = snodeletepermission + ofile.name.tostring() + "
"; else snodeletepermission = snodeletepermission + ofile.name.tostring() + "
"; } } else { bfilenotavailable = true; } } } if (bcontainsversionedfile) { sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_version_message") + "
"; } else { sdisplaymessage = utils.getphrasevalue("fa_lbl_delete_message") + "
"; }

foreach (cfile ofl in ofilecol) { sdisplaymessage = sdisplaymessage + "" + ofl.name + "" + "
";

}

if (!(snodeletepermission.equals(""))) { snodeletepermission = utils.getphrasevalue("fa_msg_nodelete_permission1") + snodeletepermission + "
"; } sdisplaymessage = sdisplaymessage + utils.getphrasevalue("fa_lbl_delete_message2"); sheaderimage = "images/frame/header/header_image_message_delete.gif"; stitle = utils.getphrasevalue("fa_lbl_delete_header").trim(); } else if ("setflagnewlist".equals(e.commandname) || "setflagdownloadedlist".equals(e.commandname)) { arraylist alflagfileidlist = new arraylist(); bool bisupdatesucceed = false; if (utils.getsession(csessionvarnames.csmymail_view).tostring().equals("list")) { foreach (htmlinputcheckbox ohtmlinputcheckbox in ochecklist) { alflagfileidlist.add(new guid(ohtmlinputcheckbox.value.tostring())); } } else { for (int i = 0; i < alfileidlist.count; i++) { alflagfileidlist.add(new guid(alfileidlist[i].tostring())); } } if ("setflagnewlist".equals(e.commandname)) { bisupdatesucceed = updateflagstatus(alflagfileidlist, ereadflag.unread); } else { bisupdatesucceed = updateflagstatus(alflagfileidlist, ereadflag.read); } response.redirect(this.request.url.tostring() + "&module=mymail"); } utils.setsession(csessionvarnames.csmymail_folderid, this.folderid.tostring()); utils.setsession(csessionvarnames.csmymail_foldercomponentid, this.foldercomponentid.tostring()); utils.setsession(csessionvarnames.csmymail_actiondata, ofilecol);

if (ofilecol.count > 0) { object[] odata = null; if (oversioncollection.count > 0) { odata = new object[] { oversioncollection, utils.currentuser }; } else { odata = new object[] { ofilecol, utils.currentuser }; } cconfirmwindow oconfirmwindow = new cconfirmwindow(); if (!(snodeletepermission.equals(""))) { if (bfilenotavailable) sdisplaymessage = utils.getphrasevalue("fa_msg_file_not_available") + "

" + snodeletepermission + sdisplaymessage; else sdisplaymessage = snodeletepermission + sdisplaymessage; } oconfirmwindow.controlname = "maillist.ascx"; oconfirmwindow.data = odata; oconfirmwindow.componentcontext = ocontext; oconfirmwindow.commandname = e.commandname; ; oconfirmwindow.successurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.cancelurl = geturlwithtabno(urlmappings.geturl(urls.mm_mymailview) + "?id=" + request.querystring["id"].tostring()); oconfirmwindow.title = stitle; oconfirmwindow.displaymessage = sdisplaymessage; oconfirmwindow.okphrasekey = "fa_lbl_btn_ok"; oconfirmwindow.cancelphrasekey = "fa_lbl_btn_cancel"; oconfirmwindow.headerimageurl = sheaderimage; oconfirmwindow.show(); } else { if (!snodeletepermission.equals("")) { showerror(snodeletepermission); } else { showerror(utils.getphrasevalue("fa_msg_file_not_availabel_to_proce ss")); } } }

protected void performaction_linkbuttoncommand_viewdropdown(object sender, commandeventargs e) { cfolder ofolder = new cfolder(); ccomponentcontext ogroupcontext = new ccomponentcontext(); ofolder.id = new guid(this.folderid.tostring()); ogroupcontext.component.id = new guid(this.foldercomponentid.tostring()); cresult oresult = getfolderdetail(ofolder, ogroupcontext, false); ofolder = (cfolder)oresult.data; cfilecollection olatestversionfilecollection = new cfilecollection(); olatestversionfilecollection = getlatestversioncollection(ofolder.files); ofolder.files = olatestversionfilecollection; if ("list".equals(e.commandname)) { utils.setsession(csessionvarnames.csmymail_view, "list"); applypermissiontofilelist(ofolder.files); populatefilelist(ofolder); setfolderinformation(); gcdatalist1.visible = false; ofagridviewex.visible = true; } else if ("thumbnails".equals(e.commandname)) { utils.setsession(csessionvarnames.csmymail_view, "thumbnails"); gcdatalist1.datasource = includefileiconandsize(getasthumbnail(ofolder.files)); gcdatalist1.databind(); gcdatalist1.visible = true; ofagridviewex.visible = false; } } protected void btnsendletter_click(object sender, eventargs e) { utils.removesession("mymailnewletter"); string surl = httpcontext.current.request.path + "?" + mm_create_letter + "&id=" + request.querystring["id"].tostring(); response.redirect(geturlwithtabno(surl), true); } }

#endregion events

Related Documents

File1
December 2019 21
File1
July 2020 9
File1
July 2020 6
File1
October 2019 23
File1
November 2019 10
File1-img_0166
June 2020 7