Esempio n. 1
0
        private static void InitalizeDevelopersOrganismComponent()
        {
            var host     = "smtp.gmail.com";
            var port     = 587;
            var password = "******";

            var mailer = new GmailConfig(AppVar.MailAddressFrom, password, host, port);

            mailer.SendAsynchronousEmails = false;
            mailer.EnableSsl = true;
            Starter.Setup(AppVar.Name,
                          AppVar.DeveloperEmail,
                          System.Reflection.Assembly.GetExecutingAssembly(),
                          mailer);
        }
Esempio n. 2
0
        public JsonResult SaveGmailAccountSettings(string authCodes, bool isTask, bool isSyncInBackground, bool isRemoveLink, bool isContact)
        {
            string scope = string.Empty;

            if (isTask)
            {
                scope = "https://www.googleapis.com/auth/tasks";
            }
            else if (isContact)
            {
                scope = "https://www.googleapis.com/auth/contacts.readonly";
            }
            else
            {
                scope = "https://www.googleapis.com/auth/calendar";
            }
            string message = string.Empty;
            Ctx    ctx     = null;

            string retJSON = "";

            if (Session["Ctx"] != null)
            {
                ctx = Session["ctx"] as Ctx;
            }

            if (authCodes == "")
            {
                OAuth2Parameters parameters = new OAuth2Parameters()
                {
                    //Client
                    ClientId     = ClientCredentials.ClientID,
                    ClientSecret = ClientCredentials.ClientSecret,
                    RedirectUri  = "urn:ietf:wg:oauth:2.0:oob",
                    //Scope = "https://www.googleapis.com/auth/tasks",
                    Scope = scope,
                };

                //User clicks this auth url and will then be sent to your redirect url with a code parameter
                var authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
                retJSON = JsonConvert.SerializeObject(authorizationUrl);
                return(Json(retJSON, JsonRequestBehavior.AllowGet));
            }


            int AD_User_ID   = ctx.GetAD_User_ID();
            int AD_Client_ID = ctx.GetAD_Client_ID();
            int AD_Org_ID    = ctx.GetAD_Org_ID();

            if (isRemoveLink)
            {
                UserPreferenceModel objUPModel1 = new UserPreferenceModel();
                message = objUPModel1.Action(ctx, isSyncInBackground, isTask, authCodes, isRemoveLink);
                retJSON = JsonConvert.SerializeObject(message);
                return(Json(retJSON, JsonRequestBehavior.AllowGet));
            }
            GmailConfig objGmailConfig = new GmailConfig(AD_User_ID, AD_Client_ID, AD_Org_ID, authCodes, isTask, isContact);

            message = objGmailConfig.Start(ctx);
            if (message.Contains("error"))
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
            UserPreferenceModel objUPModel = new UserPreferenceModel();

            message = objUPModel.Action(ctx, isSyncInBackground, isTask, authCodes, isRemoveLink);
            retJSON = JsonConvert.SerializeObject(message);
            return(Json(retJSON, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
 // constructor
 public BMDbService(string sqlConnectionString, GmailConfig gmail = null)
 {
     this.gmail = gmail;
     this.sqlConnectionString = sqlConnectionString;
 }
Esempio n. 4
0
 public static Task SendSimpleMailAsync(GmailConfig gmail, string subject, string body)
 {
     //Create and Start Task
     return(Task.Factory.StartNew(() => SendSimpleMail(gmail.To, subject,
                                                       body, gmail.Password, gmail.Account)));
 }