예제 #1
0
 public string ImportContacts(GoogleContacts[] obj)
 {
     try
     {
         U_USR_ContactsDAL    ocontactsDAL = new U_USR_ContactsDAL();
         U_USR_Map_ContactDAL omapcntsDAL  = new U_USR_Map_ContactDAL();
         foreach (var item in obj)
         {
             if (string.IsNullOrEmpty(ocontactsDAL.CheckContact_Exist(item.EmailID)))
             {
                 U_USR_Contacts ocontacts = new U_USR_Contacts();
                 ocontacts.Contact_Id     = Guid.NewGuid().ToString();
                 ocontacts.Contact_Source = "Google";
                 ocontacts.Contact_Status = "1";
                 ocontacts.Created_by     = "";
                 ocontacts.Created_Date   = DateTime.Now;
                 ocontacts.Email_Id       = item.EmailID;
                 if (!string.IsNullOrEmpty(item.ContactNo))
                 {
                     ocontacts.Mobile_Number = item.ContactNo;
                 }
                 else
                 {
                     ocontacts.Mobile_Number = "";
                 }
                 ocontacts.Person_Name  = string.IsNullOrEmpty(item.Name) ? string.Empty : item.Name;
                 ocontacts.Updated_by   = "";
                 ocontacts.Updated_Date = DateTime.Now;
                 ocontactsDAL.InsertU_USR_Contacts(ocontacts);
             }
         }
         foreach (var item in obj)
         {
             string contactId = ocontactsDAL.CheckContact_Exist(item.EmailID);
             string mapingId  = omapcntsDAL.CheckMaping_Exist(item.UserId, contactId);
             if (!string.IsNullOrEmpty(contactId) & string.IsNullOrEmpty(mapingId))
             {
                 U_USR_Map_Contact ocontacts = new U_USR_Map_Contact();
                 ocontacts.Id           = Guid.NewGuid().ToString();
                 ocontacts.Contact_Id   = contactId;
                 ocontacts.Usr_Id       = item.UserId;
                 ocontacts.Comments     = "";
                 ocontacts.Created_by   = "";
                 ocontacts.Created_Date = DateTime.Now;
                 ocontacts.Updated_by   = "";
                 ocontacts.Updated_Date = DateTime.Now;
                 bool status = omapcntsDAL.InsertU_USR_Map_Contact(ocontacts);
             }
         }
         return("1"); // 1 successfull
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return("0"); // 0 indicates unsuccessfull
     }
 }
예제 #2
0
 private void SetParameters(SqlParameter[] U_USR_ContactsParms, U_USR_Contacts tobjU_USR_Contacts)
 {
     U_USR_ContactsParms[0].Value = tobjU_USR_Contacts.Contact_Id;
     U_USR_ContactsParms[1].Value = tobjU_USR_Contacts.Email_Id;
     U_USR_ContactsParms[2].Value = tobjU_USR_Contacts.Mobile_Number;
     U_USR_ContactsParms[3].Value = tobjU_USR_Contacts.Person_Name;
     U_USR_ContactsParms[4].Value = tobjU_USR_Contacts.Contact_Status;
     U_USR_ContactsParms[5].Value = tobjU_USR_Contacts.Contact_Source;
     U_USR_ContactsParms[6].Value = tobjU_USR_Contacts.Created_Date;
     U_USR_ContactsParms[7].Value = tobjU_USR_Contacts.Updated_Date;
     U_USR_ContactsParms[8].Value = tobjU_USR_Contacts.Created_by;
     U_USR_ContactsParms[9].Value = tobjU_USR_Contacts.Updated_by;
 }
예제 #3
0
 public bool InsertU_USR_Contacts(U_USR_Contacts tobjU_USR_Contacts)
 {
     if (tobjU_USR_Contacts != null)
     {
         //Get the parameter list needed by the given object
         SqlParameter[] lParamArray = GetParameters(tobjU_USR_Contacts);
         SetParameters(lParamArray, tobjU_USR_Contacts);
         //Get the connection
         SqlConnection con = General.GetConnection();
         if (con == null)
         {
             //Connection is not created
             return(false);
         }
         //Execute the insertion
         int i = SqlHelper.ExecuteNonQuery(
             con,
             CommandType.Text,
             SQL_INSERT_U_USR_Contacts,
             lParamArray);
         //Dispose the Sql connection
         con.Dispose();
         if (i == 1)
         {
             //Done and insert the object to the table
             return(true);
         }
         else
         {
             //Fail to execute the insertion
             return(false);
         }
     }
     else
     {
         //No object found to insert
         return(false);
     }
 }
예제 #4
0
 private SqlParameter[] GetParameters(U_USR_Contacts tobjU_USR_Contacts)
 {
     SqlParameter[] objParamArray = SqlHelperParameterCache.GetCachedParameterSet(General.SQL_CONN_STRING, SQL_INSERT_U_USR_Contacts);
     if (objParamArray == null)
     {
         //Represents a parameter to a System.Data.SqlClient.SqlCommand,
         //and optionally, its mapping to System.Data.DataSet columns.
         objParamArray = new SqlParameter[]
         {
             new SqlParameter(PARAM_Contact_Id, tobjU_USR_Contacts.Contact_Id),
             new SqlParameter(PARAM_Email_Id, tobjU_USR_Contacts.Email_Id),
             new SqlParameter(PARAM_Mobile_Number, tobjU_USR_Contacts.Mobile_Number),
             new SqlParameter(PARAM_Person_Name, tobjU_USR_Contacts.Person_Name),
             new SqlParameter(PARAM_Contact_Status, tobjU_USR_Contacts.Contact_Status),
             new SqlParameter(PARAM_Contact_Source, tobjU_USR_Contacts.Contact_Source),
             new SqlParameter(PARAM_Created_Date, tobjU_USR_Contacts.Created_Date),
             new SqlParameter(PARAM_Updated_Date, tobjU_USR_Contacts.Updated_Date),
             new SqlParameter(PARAM_Created_by, tobjU_USR_Contacts.Created_by),
             new SqlParameter(PARAM_Updated_by, tobjU_USR_Contacts.Updated_by),
         };
         SqlHelperParameterCache.CacheParameterSet(General.SQL_CONN_STRING, SQL_INSERT_U_USR_Contacts, objParamArray);
     }
     return(objParamArray);
 }