protected void btnPublish_Click(object sender, EventArgs e) { try { //SessionData.Config = new AppConfiguration(); if (SessionData.PrefData.TaskTwo1.Equals(MICROSITE)) { CopyToMicrosites(SessionData.UserAction.SiteID1, txtSubDomainName.Text.Trim()); } if (SessionData.PrefData.TaskTwo1.Equals(YOUTUBE)) { //ask for uploading video and save in Userfiles if (fileYoutubeVideo.HasFile) { string filename = fileYoutubeVideo.FileName; string path = Server.MapPath("./Youtube/" + SessionData.UserAction.SiteID1); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string strFinalFileName = Path.GetFileName(fileYoutubeVideo.FileName); long FileLength = fileYoutubeVideo.PostedFile.ContentLength; fileYoutubeVideo.PostedFile.SaveAs(path + "/" + filename); if (UploadToYoutube(filename)) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Youtube video uploaded !\")", true); SessionData.UserAction.TaskComplete = YOUTUBE; } } } SessionData.Product = new AppProduct(); SessionData.Product.DID = GetNewDIDWithPrefix(); //Prepare file system directory to store Images string pathToCreate = "~/Images/" + SessionData.Product.DID; if (!Directory.Exists(Server.MapPath(pathToCreate))) { Directory.CreateDirectory(Server.MapPath(pathToCreate)); } //Fetch Template Data dsTemplateData = canv.GetTempData(Convert.ToInt32(templateID)); //REVISIT hdnTrmplateID.Value = templateID; hdnPDID.Value = SessionData.Product.DID; hdnfield.Value = CDID; if (!Directory.Exists(Server.MapPath(pathToCreate))) { Directory.CreateDirectory(Server.MapPath(pathToCreate)); } //Caption //if (!string.IsNullOrEmpty(txtHeaderText.Text)) //{ // SessionData.Product.AppCaption = txtHeaderText.Text; //} SessionData.Product.ProductCategory = WH_CREATED; //Start Date, Expiry Date FacebookBizProcess fbBiz = new FacebookBizProcess(); if (fbBiz.IsAppCreationAllowed(SessionData.Customer.CustomerID)) //check if user is allowed to create Promos etc under his current plan ***************************************************************** { SessionData.Config = new AppConfiguration(); AppConfiguration oAppAvaila = new AppConfiguration(); oAppAvaila = fbBiz.GetAvailableConfig(CDID); SessionData.Config = oAppAvaila; SessionData.Config.DID = GetNewDID("AN"); //Custom Tab Name if (!txtCustomTabNamePromoVid.Text.Trim().Equals(string.Empty)) { SessionData.Config.SCustomtTabName = txtCustomTabNamePromoVid.Text.Trim(); SessionData.UserAction.CustomTabName1 = txtCustomTabNamePromoVid.Text.Trim(); } SessionData.Config.STemplatePage = TEMPLATE_PAGE; } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"You can only create 3 Campaigns with a TRIAL account !\")", true); } FaceBook ofacebook = new FaceBook(); AppUser oAppUser = new AppUser(); SessionData.Config.SSiteID = SiteID; SessionData.Config.STemplateID = SessionData.PrefData.TemplateID1; SessionData.Product.ProductLogo = "https://www.sonetreach.com/Images/" + SessionData.Product.DID + "/Logo" + SessionData.Product.ProductLogo; SessionData.Product.SProductContentImage = "Body" + hdnContent.Value; if (!(SessionData.Config == null)) { //Now fill up the Config and get Product data. SessionData.Config.SCampaignType = Video; if (fbBiz.SetNewConfigDetails(SessionData.Config, SessionData.Config.SCustomtTabName, Video)) { //Update expiry date fbBiz.UpdateConfigExpiryForWH(SessionData.Config.DID); ////********If user comes here we know we should set up a Product Info, So, create a row in AppProduct and assign these values to SessionData******** SessionData.Product.AppConfigDID = SessionData.Config.DID; SessionData.Product.ProductName = SessionData.Config.AppName; SessionData.Product.ProductHTML = ""; fbBiz.SetNewProductDetails(SessionData.Product); SessionData.Product = fbBiz.GetAppProductDetails(); } } else { //No configs allowed Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Config Not Available. Please Contact HELPDESK.\");", true); } if (SessionData.Config.SAppPageTabSelected == null) { StringBuilder oSBPageSElector = new StringBuilder(); oSBPageSElector.Append("window.open('http://www.facebook.com/dialog/permissions.request?app_id="); oSBPageSElector.Append(SessionData.Config.AppID + "&redirect_uri=" + ActiveURL + SessionData.Config.AppID + "&response_type=code&perms=user_birthday,user_location,email,manage_pages\','name','height=140,width=790,menubar=0,toolbar=0,statusbar=0,scrollbars=0,resizable=0');"); litLogin.Text = oSBPageSElector.ToString(); } } catch (Exception ex) { //commonUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID); throw ex; } }