public string GetJobs() { string resultCount = string.Empty; oJob = new RecuritingAPI(sEndpoint, sUser, sPass); Get_Job_Postings_RequestType oRequest = new Get_Job_Postings_RequestType(); WorkdayAPI.RecuritingService1.Response_FilterType oRespFilter = new WorkdayAPI.RecuritingService1.Response_FilterType(); Job_Posting_Response_GroupType oRespGroup = new Job_Posting_Response_GroupType(); Job_Posting_Site_Request_ReferencesType siteref = new Job_Posting_Site_Request_ReferencesType(); Job_Posting_SiteObjectType jobsiteObj = new Job_Posting_SiteObjectType(); Job_Posting_SiteObjectIDType ID = new Job_Posting_SiteObjectIDType(); // TODO: need to investigate the purpose of those values below and if we can move them into the appSettings ID.type = "WID"; ID.Value = "03ca6cbf24cc10fabe92ff4b5f82a0ac"; jobsiteObj.ID = new Job_Posting_SiteObjectIDType[1]; jobsiteObj.ID[0] = ID; siteref.Job_Posting_Site_Reference = new Job_Posting_SiteObjectType[1]; siteref.Job_Posting_Site_Reference[0] = jobsiteObj; Job_Posting_Request_CriteriaType criteria = new Job_Posting_Request_CriteriaType(); criteria.Job_Posting_Site_Reference = siteref.Job_Posting_Site_Reference; criteria.Show_Only_Active_Job_PostingsSpecified = true; criteria.Show_Only_Active_Job_Postings = true; oRequest.Request_Criteria = criteria; oRespFilter.Count = 999; oRespFilter.CountSpecified = true; oRequest.Response_Filter = oRespFilter; oRespGroup.Include_Reference = true; oRespGroup.Include_Job_Requisition_Restrictions_Data = true; oRespGroup.Include_Job_Requisition_Definition_Data = true; oRespGroup.Include_Qualifications = true; oRespGroup.Include_Job_Requisition_Attachments = false; oRequest.Response_Group = oRespGroup; Get_Job_Postings_ResponseType oResponse = oJob.GetJobPosting(oRequest, oRespFilter, oRespGroup); string jobsxml = XmlTools.ToXmlString(oResponse); jobsxml = jobsxml.Replace("utf-16", "utf-8"); xmlDocument = xmlDocument + DateTime.Now.Ticks + ".xml"; using (System.IO.StreamWriter file = new System.IO.StreamWriter(xmlDocument)) { file.Write(jobsxml); } XmlDocument doc = new XmlDocument(); doc.Load(xmlDocument); var nodes = doc.GetElementsByTagName("d1p1:Job_Posting_Data"); int jobsCreatedCount = 0; int jobsUpdatedCount = 0; int jobsErrorCount = 0; int jobsDeletedCount = 0; string jobsDeletedID = "", jobsUpdatedID = "", jobsErrorID = "", jobsCreatedID = ""; TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode parentNode = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/Company/Jobs", "en-us"); DocumentQuery cmsjobs = DocumentHelper.GetDocuments("AT.Jobs") .Path("/Company/Jobs", PathTypeEnum.Children) .OnSite(SiteContext.CurrentSiteName); foreach (XmlNode xn in nodes) { var jobPostingID = xn.ChildNodes.Item(0).InnerText.ToString(); try { bool isJobInCMS = false; foreach (var jobs in cmsjobs) { string jobsID = jobs.GetValue("Job_Posting_ID").ToString(); if (jobsID.ToString().ToLower() == xn.ChildNodes.Item(0).InnerText.ToString().ToLower()) { if (parentNode != null) { var documents = DocumentHelper.GetDocuments() .Types("AT.Jobs") .Path("/Company/Jobs", PathTypeEnum.Children) .WhereLike("Job_Posting_ID", jobPostingID) .OnSite(SiteContext.CurrentSiteName) .Culture("en-us") .WithCoupledColumns(); if (!DataHelper.DataSourceIsEmpty(documents) && documents.Tables[0].Rows.Count == 1) { // Loop through all documents foreach (DataRow documentRow in documents.Tables[0].Rows) { // Create a new Tree node from the data row CMS.DocumentEngine.TreeNode editDocument = CMS.DocumentEngine.TreeNode.New("AT.Jobs", documentRow, tree); // Change coupled data SetNodeValue(xn, editDocument); editDocument.Update(); } } jobsUpdatedCount++; jobsUpdatedID += jobPostingID + "\r\n"; } isJobInCMS = true; break; } } if (!isJobInCMS) { if (parentNode != null) { // Create a new instance of the Tree node CMS.DocumentEngine.TreeNode newNode = CMS.DocumentEngine.TreeNode.New("AT.Jobs", tree); // Set the document's properties newNode.DocumentName = xn.ChildNodes.Item(1).InnerText; newNode.DocumentCulture = "en-us"; SetNodeValue(xn, newNode); newNode.Insert(parentNode); jobsCreatedCount++; jobsCreatedID += jobPostingID + "\r\n"; } else { EventLogProvider.LogInformation("No parent", "No parent", "Page can't be created as there is no parent page."); } } } catch (Exception ex) { jobsErrorCount++; jobsErrorID += jobPostingID + "\r\n"; } finally { CleanupXMLFIles(); } } string result = jobsCreatedCount + " Jobs were created and " + jobsUpdatedCount + " Jobs were updated and " + jobsDeletedCount + " Jobs were deleted and " + jobsErrorCount + " Jobs have errors."; string reportResults = String.Format("{0} \r\n\r\n========List of jobs created IDs========\r\n\r\n {1}\r\n========List of jobs updated IDs========\r\n\r\n {2}\r\n========List of jobs deleted IDs========\r\n\r\n {3}\r\n========List of jobs with error IDs========\r\n\r\n {4}", result, jobsCreatedID, jobsUpdatedID, jobsDeletedID, jobsErrorID); EventLogProvider.LogEvent(EventType.INFORMATION, "Workday", "Workday Import Report", reportResults); return(result); }
private void CheckSsoToken() { bool loggedin = objKenticoService.CheckLoginUser(""); if (!loggedin) { if (!string.IsNullOrEmpty(Request.QueryString["ct"])) { var customerToken = Request.QueryString["ct"]; Session["cuctomerReturnToken"] = customerToken; var decryptedToken = DecryptCustomerToken(customerToken); Session["OpenLoginBox"] = true; var finalToken = ""; if (decryptedToken != "") { finalToken = ValidateCustomerToken(decryptedToken); } // in case of corrupted decrypted token, until success, retry authentication x times as specified in web config to get new customer token if (finalToken == null && Convert.ToInt32(Session["retryAuth"]) < Convert.ToInt32(ConfigurationManager.AppSettings["PersonifyRetryCount"])) { EventLogProvider.LogInformation("Personify corrupt decryption string", "Personify", "customer token: " + customerToken + "decrypted token: " + decryptedToken); RetryAuth(); } Session.Remove("uname"); Session.Remove("pwd"); var customerIdentifier = ""; string emailaddress = null; string userName = null; if (finalToken != "") { customerIdentifier = ValidateUser(finalToken, ref emailaddress, ref userName); Session["PersonifyToken"] = finalToken; Session["redirecttomember"] = true; Session["retryAuth"] = Convert.ToInt32(ConfigurationManager.AppSettings["PersonifyRetryCount"]); LoginUsertokentico.WriteError("token for " + userName, finalToken); } var eUserData = AuthenticateCustomer(customerIdentifier, emailaddress, userName); if (eUserData == null) { return; } //use master customer id as the default password if (customerIdentifier != null) { var defaultPassword = customerIdentifier.Split('|')[0]; if (Session["PersonifyToken"] == null && !string.IsNullOrEmpty(finalToken)) { Session["PersonifyToken"] = finalToken; } } if (_wsSso != null) { _wsSso.Dispose(); } var hasToken = Request.Url.AbsoluteUri.IndexOf("ct=", StringComparison.Ordinal) > 0; Session["redirecttomember"] = true; Response.Redirect( hasToken ? Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf("ct=", StringComparison.Ordinal) - 1) : Request.Url.AbsoluteUri, true); } else { if (Session["LoginAttempted"] != null) { bool loginAttempted; bool.TryParse(Session["LoginAttempted"].ToString(), out loginAttempted); if (loginAttempted) { Session["OpenLoginBox"] = true; Session.Remove("LoginAttempted"); } } } } else { bool flagpersonifyMember = false; //if logged in as admin user keep the userlogged in /// If personify token is expired logout user /// if (CMS.Membership.AuthenticationHelper.IsAuthenticated()) { UserInfo userdata = CMS.Membership.UserInfoProvider.GetUserInfo(MembershipContext.AuthenticatedUser.UserName); DataTable dt = UserInfoProvider.GetUserRoles(userdata); if (dt.Rows.Count > 0 && dt != null) { foreach (DataRow dr in dt.Rows) { if (dr["RoleName"].ToString().ToLower().Contains("peronifyuser")) { flagpersonifyMember = true; } } } ///if personify key is null or empty /// if (flagpersonifyMember) { string tokenReturn = null; if (Session[PersonifySessionKey] != null) { tokenReturn = this.ValidateCustomerToken(Session[PersonifySessionKey].ToString()); } if ((Session[PersonifySessionKey] == null) || tokenReturn == null) { /* Response.Redirect( * Request.ServerVariables["PATH_INFO"] + "?action=logout&returnurl=" + * Server.UrlEncode(Request.Url.AbsoluteUri), true);*/ //logout user if (Session["userClass"] != null && Session["userClass"] != "") { userinfo ui = (userinfo)Session["userClass"]; objKenticoService.Logout(ui.username); System.Web.Security.FormsAuthentication.SignOut(); HttpContext.Current.Response.Cookies["ASPXFORMSAUTH"].Expires = DateTime.Now.AddYears(-1); Response.Redirect("/logout.aspx"); } } } } } }
/// <summary> /// Refreshes the security parameters in macros for all the objects of the specified object types. /// Signs all the macros with the current user if the old salt is not specified. /// </summary> /// <param name="objectTypes">Object types</param> /// <param name="oldSalt">Old salt </param> /// <param name="newSalt">New salt</param> private void RefreshSecurityParams(IEnumerable <string> objectTypes, string oldSalt, string newSalt) { var oldSaltSpecified = !string.IsNullOrEmpty(oldSalt) && !chkRefreshAll.Checked; var newSaltSpecified = !string.IsNullOrEmpty(newSalt) && !chkUseCurrentSalt.Checked; processedObjects.Clear(); using (CMSActionContext context = new CMSActionContext()) { context.LogEvents = false; context.LogSynchronization = false; foreach (var objectType in objectTypes) { var objectTypeResourceKey = TypeHelper.GetObjectTypeResourceKey(objectType); var niceObjectType = GetString(objectTypeResourceKey); if (niceObjectType == objectTypeResourceKey) { if (objectType.StartsWithCSafe("bizformitem.bizform.", true)) { DataClassInfo dci = DataClassInfoProvider.GetDataClass(objectType.Substring("bizformitem.".Length)); if (dci != null) { niceObjectType = "on-line form " + dci.ClassDisplayName; } } else { niceObjectType = objectType; } } LogContext.AppendLine(string.Format(GetString("macros.refreshsecurityparams.processing"), niceObjectType)); try { var infos = InfoObjectCollection.New(objectType); foreach (var info in infos) { bool refreshed = false; if (oldSaltSpecified) { refreshed = MacroResolver.RefreshSecurityParameters(info, oldSalt, newSaltSpecified ? newSalt : ValidationHelper.HashStringSalt, true); } else { if (chkRefreshAll.Checked && newSaltSpecified) { // Do not check integrity, but use new salt refreshed = MacroResolver.RefreshSecurityParameters(info, CMSContext.CurrentUser.UserName, true, newSalt); } else { // Do not check integrity, sign everything with current user, current salt refreshed = MacroResolver.RefreshSecurityParameters(info, CMSContext.CurrentUser.UserName, true); } } if (refreshed) { var objectName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.Generalized.ObjectDisplayName)); processedObjects.Add(niceObjectType, objectName); } } } catch (Exception e) { LogContext.AppendLine(e.Message); EventLogProvider.LogException(EVENTLOG_SOURCE_REFRESHSECURITYPARAMS, "ERROR", e); } } } EventLogProvider.LogInformation(EVENTLOG_SOURCE_REFRESHSECURITYPARAMS, "PROCESSEDOBJECTS", GetProcessedObjectsForEventLog()); }
public string Execute(TaskInfo ti) { string result = ""; try { // Load path from TaskData property string filePath = FileHelper.GetFullFilePhysicalPath(ti.TaskData.Trim()); if (File.Exists(filePath)) { using (var context = new CMSActionContext()) { // Disable logging of all system operations like event log, web farm task etc. to improve performance. context.DisableAll(); // Disable logging of staging tasks // context.LogSynchronization = false; // Read all lines var lines = File.ReadAllLines(filePath); var doctors = new List <DoctorInfo>(); // Loop through each line and get individual fields: column0 = FisrtName, column1 = LastName, column2 = Email, column3 = Number, column4 = Speciality foreach (var line in lines) { var fields = line.Split(','); // Create new doctor var doctor = new DoctorInfo() { DoctorFirstName = fields[0], DoctorLastName = fields[1], DoctorEmail = fields[2], DoctorCodeName = fields[3], DoctorSpecialty = fields[4] }; // Add doctor to a list doctors.Add(doctor); } // Set all doctors int inserted = DoctorInfoProvider.SetDoctors(doctors); // Doctors were successfully imported result = string.Format("{0} new doctor(s) was/were imported.", inserted); } } else { // Prepare error message. result = string.Format("File '{0}' does not exist.", filePath); } } catch (Exception e) { result = e.Message; } // Logs the execution of the task in the event log. EventLogProvider.LogInformation("DoctorsAppointment", "IMPORT", result); // Return result of scheduled task execution. return(result); }
private static void UpgradeApplication(Func <bool> versionSpecificMethod, string newVersion, string packageName) { // Increase the timeout for upgrade request due to expensive operations like macro signing and conversion (needed for large DBs) HttpContext.Current.Server.ScriptTimeout = 14400; // CI can't be enabled during (and after) upgrade because repository won't be consistent with actual data on the database SettingsKeyInfoProvider.SetGlobalValue("CMSEnableCI", false); EventLogProvider.LogInformation(EventLogSource, "START"); // Set the path to the upgrade package (this has to be done here, not in the Import method, because it's an async procedure without HttpContext) mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/" + packageName); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); var dtm = new TableManager(null); using (var context = new CMSActionContext()) { context.DisableLogging(); context.CreateVersion = false; context.LogIntegration = false; if (dtm.TableExists(FORM_DEFINITION_TABLE)) { UpdateClasses(); UpdateAlternativeForms(); DropTempDefinitionTable(dtm); } } // Update all views dtm.RefreshDocumentViews(); RefreshCustomViews(dtm); // Set data version SettingsKeyInfoProvider.SetGlobalValue("CMSDataVersion", newVersion); SettingsKeyInfoProvider.SetGlobalValue("CMSDBVersion", newVersion); // Clear hashtables ModuleManager.ClearHashtables(); // Clear the cache CacheHelper.ClearCache(null, true); // Drop the routes CMSDocumentRouteHelper.DropAllRoutes(); // Call version specific operations if (versionSpecificMethod != null) { using (var context = new CMSActionContext()) { context.DisableLogging(); context.CreateVersion = false; context.LogIntegration = false; versionSpecificMethod.Invoke(); } } // Import upgrade package with webparts, widgets... UpgradeImportPackage(); RefreshMacroSignatures(); EventLogProvider.LogInformation(EventLogSource, "FINISH"); }
protected void ButtonGetColumn_Click(object sender, EventArgs e) { LiteralWaitting.Text = " Loading ... "; get_column_table(); if (bl) { ButtonExport.Visible = true; RadioButtonKeep.Visible = true; RadioButtonAll.Visible = true; } DataClassInfo clsi = null; clsi = (Session["DataClassInfo"] != null ? (DataClassInfo)Session["DataClassInfo"] : null); DeleteCustomTableItem(clsi); int i = 1; if (ds_excel == null) { ds_excel = (Session["ds_excel"] != null ? (DataSet)Session["ds_excel"] : null); } if (!DataHelper.DataSourceIsEmpty(ds_excel)) { Literal1.Text = ""; foreach (DataRow row in ds_excel.Tables[0].Rows) { if (i != 1) { if (CreateCustomTableItem(clsi, row)) { Literal1.Text += "<br> insert row " + i.ToString() + " sucess"; } else { Literal1.Text += "<br> <span style='color:red;'>insert row " + i.ToString() + " error</span>"; } } i++; } Literal1.Text += "<br> Import sucess"; EventLogProvider.LogInformation("CustomTable", "Import sucess", ""); string taskName = "SportingCarzTask"; string siteName = CMSContext.CurrentSiteName; // Get task object TaskInfo ti = TaskInfoProvider.GetTaskInfo(taskName, siteName); // If task exists if (ti != null) { // Run task SchedulingExecutor.ExecuteTask(ti); Literal1.Text += "<br> Run task sucess"; } } }
public void get_query_task(TaskInfo ti) { //--------*** this populates the calculated fields -------- //--------*** this calculates the Average 0-60 time, for all 5 source fields combined -------- string avg = "Declare @TempTableVariable5 TABLE( \n" + " ItemID int, \n" + " Average060Time float); \n" + " INSERT INTO @TempTableVariable5 (ItemID,Average060Time) \n" + " SELECT ItemID, \n" + " (iif(RT060Time is null,0,RT060Time) + iif(MT060Time is null,0,MT060Time) + iif(CD060Time is null,0,CD060Time) + iif(ED060Time is null,0,ED060Time) + iif(Other060Time is null,0,Other060Time))/(iif(RT060Time is null,0,1) + iif(MT060Time is null,0,1) + iif(CD060Time is null,0,1) + iif(ED060Time is null,0,1) + iif(Other060Time is null,0,1)) as Average060Time \n" + " FROM [dbo].[customtable_carz] \n" + " Update [dbo].[customtable_carz] SET \n" + " Average060Time=[@TempTableVariable5].Average060Time \n" + " FROM [dbo].[customtable_carz] \n" + " RIGHT OUTER JOIN @TempTableVariable5 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable5].[ItemID];"; //--------*** this calculates the Best 0-60, 1/4 time, 1/4 speed, top speed and skid pad, for all 5 source fields combined -------- //--------*** this is the Road & Track (RT) section -------- string speed = "Declare @TempTableVariable TABLE( \n" + "ItemID int, \n" + " Best060Time float, \n" + "Best1of4MileTime float, \n" + "Best1of4MileSpeed float, \n" + "BestTopSpeed float, \n" + "BestSkidPad float); \n" + " INSERT INTO @TempTableVariable (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" + " SELECT ItemID, \n" + " iif(RT060Time is null,1000,RT060Time) as Best060Time, \n" + " iif(RT1of4MileTime is null,1000,RT1of4MileTime) as Best1of4MileTime, \n" + " iif(RT1of4MileSpeed is null,1000,RT1of4MileSpeed) as Best1of4MileSpeed, \n" + " iif(RTTopSpeed is null,1000,RTTopSpeed) as BestTopSpeed, \n" + " iif(RTSkidPad is null,1000,RTSkidPad) as BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " Update [dbo].[customtable_carz] SET \n" + " Best060Time=[@TempTableVariable].Best060Time, \n" + " Best1of4MileTime=[@TempTableVariable].Best1of4MileTime, \n" + " Best1of4MileSpeed=[@TempTableVariable].Best1of4MileSpeed, \n" + " BestTopSpeed=[@TempTableVariable].BestTopSpeed, \n" + " BestSkidPad=[@TempTableVariable].BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " RIGHT OUTER JOIN @TempTableVariable ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable].[ItemID]; \n" + //--------*** this is the MotorTrend (MT) section -------- "Declare @TempTableVariable1 TABLE( \n" + " ItemID int, \n" + " Best060Time float, \n" + " Best1of4MileTime float, \n"+ " Best1of4MileSpeed float, \n"+ " BestTopSpeed float, \n"+ " BestSkidPad float); \n"+ " INSERT INTO @TempTableVariable1 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" + " SELECT ItemID, \n" + " iif(MT060Time is null,Best060Time,iif(MT060Time<Best060Time,MT060Time,Best060Time)) as Best060Time, \n"+ " iif(MT1of4MileTime is null,Best1of4MileTime,iif(MT1of4MileTime<Best1of4MileTime,MT1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n"+ //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time -------- " iif(MT1of4MileSpeed is null,Best1of4MileSpeed,iif(MT1of4MileTime<Best1of4MileTime,MT1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ " iif(MTTopSpeed is null,BestTopSpeed,iif(MTTopSpeed<BestTopSpeed,MTTopSpeed,BestTopSpeed)) as BestTopSpeed, \n"+ " iif(MTSkidPad is null,BestSkidPad,iif(MTSkidPad>BestSkidPad,MTSkidPad,BestSkidPad)) as BestSkidPad \n"+ " FROM [dbo].[customtable_carz] \n" + " Update [dbo].[customtable_carz] SET \n" + " Best060Time=[@TempTableVariable1].Best060Time, \n" + " Best1of4MileTime=[@TempTableVariable1].Best1of4MileTime, \n" + " Best1of4MileSpeed=[@TempTableVariable1].Best1of4MileSpeed, \n" + " BestTopSpeed=[@TempTableVariable1].BestTopSpeed, \n" + " BestSkidPad=[@TempTableVariable1].BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " RIGHT OUTER JOIN @TempTableVariable1 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable1].[ItemID]; \n" + //--------*** this is the Car & Driver (CD) section -------- " Declare @TempTableVariable2 TABLE( \n" + " ItemID int, \n" + " Best060Time float, \n" + " Best1of4MileTime float, \n"+ " Best1of4MileSpeed float, \n"+ " BestTopSpeed float, \n"+ " BestSkidPad float); \n"+ " INSERT INTO @TempTableVariable2 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" + " SELECT ItemID, \n" + " iif(CD060Time is null,Best060Time,iif(CD060Time<Best060Time,CD060Time,Best060Time)) as Best060Time, \n" + " iif(CD1of4MileTime is null,Best1of4MileTime,iif(CD1of4MileTime<Best1of4MileTime,CD1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n" + //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time -------- " iif(CD1of4MileSpeed is null,Best1of4MileSpeed,iif(CD1of4MileTime<Best1of4MileTime,CD1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ " iif(CDTopSpeed is null,BestTopSpeed,iif(CDTopSpeed<BestTopSpeed,CDTopSpeed,BestTopSpeed)) as BestTopSpeed, \n" + " iif(CDSkidPad is null,BestSkidPad,iif(CDSkidPad>BestSkidPad,CDSkidPad,BestSkidPad)) as BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " Update [dbo].[customtable_carz] SET \n" + " Best060Time=[@TempTableVariable2].Best060Time, \n" + " Best1of4MileTime=[@TempTableVariable2].Best1of4MileTime, \n" + " Best1of4MileSpeed=[@TempTableVariable2].Best1of4MileSpeed, \n" + " BestTopSpeed=[@TempTableVariable2].BestTopSpeed, \n" + " BestSkidPad=[@TempTableVariable2].BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " RIGHT OUTER JOIN @TempTableVariable2 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable2].[ItemID]; \n" + //--------*** this is the Edmunds (ED) source section -------- " Declare @TempTableVariable3 TABLE( \n" + " ItemID int, \n" + " Best060Time float, \n" + " Best1of4MileTime float, \n"+ " Best1of4MileSpeed float, \n"+ " BestTopSpeed float, \n"+ " BestSkidPad float); \n"+ " INSERT INTO @TempTableVariable3 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" + " SELECT ItemID, \n" + " iif(ED060Time is null,Best060Time,iif(ED060Time<Best060Time,ED060Time,Best060Time)) as Best060Time, \n" + " iif(ED1of4MileTime is null,Best1of4MileTime,iif(ED1of4MileTime<Best1of4MileTime,ED1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n" + //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time -------- " iif(ED1of4MileSpeed is null,Best1of4MileSpeed,iif(ED1of4MileTime<Best1of4MileTime,ED1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ " iif(EDTopSpeed is null,BestTopSpeed,iif(EDTopSpeed<BestTopSpeed,EDTopSpeed,BestTopSpeed)) as BestTopSpeed, \n" + " iif(EDSkidPad is null,BestSkidPad,iif(EDSkidPad>BestSkidPad,EDSkidPad,BestSkidPad)) as BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " Update [dbo].[customtable_carz] SET \n" + " Best060Time=[@TempTableVariable3].Best060Time, \n" + " Best1of4MileTime=[@TempTableVariable3].Best1of4MileTime, \n" + " Best1of4MileSpeed=[@TempTableVariable3].Best1of4MileSpeed, \n" + " BestTopSpeed=[@TempTableVariable3].BestTopSpeed, \n" + " BestSkidPad=[@TempTableVariable3].BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " RIGHT OUTER JOIN @TempTableVariable3 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable3].[ItemID]; \n" + //--------*** this is the Other source section -------- " Declare @TempTableVariable4 TABLE( \n" + " ItemID int, \n" + " Best060Time float, \n" + " Best1of4MileTime float, \n"+ " Best1of4MileSpeed float, \n"+ " BestTopSpeed float, \n"+ " BestSkidPad float); \n"+ " INSERT INTO @TempTableVariable4 (ItemID,Best060Time,Best1of4MileTime,Best1of4MileSpeed,BestTopSpeed,BestSkidPad) \n" + " SELECT ItemID, \n" + " iif(Other060Time is null,iif(Best060Time = 1000,0,Best060Time),iif(Other060Time<Best060Time,Other060Time,Best060Time)) as Best060Time, \n"+ " iif(Other1of4MileTime is null,iif(Best1of4MileTime = 1000,0,Best1of4MileTime),iif(Other1of4MileTime<Best1of4MileTime,Other1of4MileTime,Best1of4MileTime)) as Best1of4MileTime, \n"+ //--------*** edit by holly 7-6-13 use best 1/4 mi speed from the source with best 1/4 time -------- " iif(Other1of4MileSpeed is null,Best1of4MileSpeed,iif(Other1of4MileTime<Best1of4MileTime,Other1of4MileSpeed,Best1of4MileSpeed)) as Best1of4MileSpeed, \n"+ " iif(OtherTopSpeed is null,iif(BestTopSpeed = 1000,0,BestTopSpeed),iif(OtherTopSpeed<BestTopSpeed,OtherTopSpeed,BestTopSpeed)) as BestTopSpeed, \n"+ " iif(OtherSkidPad is null,iif(BestSkidPad = 1000,0,BestSkidPad),iif(OtherSkidPad>BestSkidPad,OtherSkidPad,BestSkidPad)) as BestSkidPad \n"+ " FROM [dbo].[customtable_carz] \n" + " Update [dbo].[customtable_carz] SET \n" + " Best060Time=[@TempTableVariable4].Best060Time, \n" + " Best1of4MileTime=[@TempTableVariable4].Best1of4MileTime, \n" + " Best1of4MileSpeed=[@TempTableVariable4].Best1of4MileSpeed, \n" + " BestTopSpeed=[@TempTableVariable4].BestTopSpeed, \n" + " BestSkidPad=[@TempTableVariable4].BestSkidPad \n" + " FROM [dbo].[customtable_carz] \n" + " RIGHT OUTER JOIN @TempTableVariable4 ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable4].[ItemID];"; //--------*** this calculates the final Rankings for each car within its default time class (super fast, fast, spirited, mellow, tame) -------- GeneralConnection cn = ConnectionHelper.GetConnection(); string qryname = ""; string clsname = ""; string qryRank = "Declare @TempTableVariable TABLE( \n" + "ItemID int, \n" + "STT int);\n" + "INSERT INTO @TempTableVariable (ItemID, STT)\n" + //--------*** edit by holly 7-6-13 also use best 1/4 mi time and top speed as tie-breakers for rankings -------- "SELECT ItemID, ROW_NUMBER() OVER (Order by Average060Time asc,Best1of4MileTime asc,Best1of4MileSpeed desc) as STT \n" + "FROM [dbo].[customtable_carz] \n" + "Where ({0}); \n"+ "Update [dbo].[customtable_carz] SET TimeClassRank=[@TempTableVariable].STT \n" + "FROM [dbo].[customtable_carz] \n" + "RIGHT OUTER JOIN @TempTableVariable ON [dbo].[customtable_carz].[ItemID] = [@TempTableVariable].[ItemID];"; string qrytimeclass = "Update customtable_carz SET TimeClass='{0}' Where {1} "; //TreeProvider tree = new TreeProvider(); //DataSet ds = tree.SelectNodes(CMSContext.CurrentSiteName, "/Classes/%", CMSContext.CurrentDocumentCulture.CultureCode, true, "CMS.MenuItem", "DocumentMenuItemHideInNavigation='False' and ExpressClasses='False' ", "NodeOrder ASC", -1, true); DataSet ds = cn.ExecuteQuery("select QueryName,NodeAlias FROM [dbo].[View_CONTENT_MenuItem_Joined] where NodeAliasPath like '/Classes/%' and DocumentMenuItemHideInNavigation='False' and ExpressClasses='False'", null, QueryTypeEnum.SQLQuery, false); DataSet ds_ = null; try { int k = cn.ExecuteNonQuery(speed, null, QueryTypeEnum.SQLQuery, false); EventLogProvider.LogInformation("CustomTask", "Execute Sucess Speed", ti.TaskData); } catch (Exception ex3) { // Logs the execution of the task in the event log. EventLogProvider.LogInformation("CustomTask", "Execute Rank Speed Error", ex3.ToString()); } try { int k = cn.ExecuteNonQuery(avg, null, QueryTypeEnum.SQLQuery, false); EventLogProvider.LogInformation("CustomTask", "Execute Average 0-60 Speed", ti.TaskData); } catch (Exception ex4) { // Logs the execution of the task in the event log. EventLogProvider.LogInformation("CustomTask", "Execute Rank Average 0-60 Error", ex4.ToString()); } if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow ItemRow in ds.Tables[0].Rows) { if (ItemRow["QueryName"].ToString() != "") { qryname = ItemRow["QueryName"].ToString(); clsname = ItemRow["NodeAlias"].ToString(); string[] aqn = qryname.Split('.'); string sql2 = "select QueryName,QueryText from dbo.CMS_Query where QueryName='{0}'"; ds_ = cn.ExecuteQuery(string.Format(sql2, aqn[2]), null, QueryTypeEnum.SQLQuery, false); if (ds_ != null) { foreach (DataRow ItemD in ds_.Tables[0].Rows) { string[] stringSeparators = new string[] { "where" }; string[] QueryText = ItemD["QueryText"].ToString().ToLower().Replace("and ##", "").Split(stringSeparators, StringSplitOptions.None); //LiteralTitle.Text += "<br>" + string.Format(qrytimeclass, clsname, QueryText[1]);// "<br>" + QueryText[1] + " " + clsname; // LiteralTitle.Text += "<br>" + string.Format(qryRank, QueryText[1]);// "<br>" + QueryText[1] + " " + clsname; QueryDataParameters parameters = new QueryDataParameters(); try { int k = cn.ExecuteNonQuery(string.Format(qrytimeclass, clsname, QueryText[1]), null, QueryTypeEnum.SQLQuery, false); EventLogProvider.LogInformation("CustomTask", "Execute Sucess classtime:" + clsname, ti.TaskData); //LiteralTitle.Text += "<br> class:" + clsname + " ok" ; } catch (Exception ex1) { // Logs the execution of the task in the event log. EventLogProvider.LogInformation("CustomTask", "Execute " + clsname + " Error", ex1.ToString()); //LiteralTitle.Text += "<br>" + ex1.ToString(); } try { int k = cn.ExecuteNonQuery(string.Format(string.Format(qryRank, QueryText[1]), clsname, QueryText[1]), null, QueryTypeEnum.SQLQuery, false); EventLogProvider.LogInformation("CustomTask", "Execute Sucess Rank class:" + clsname, ti.TaskData); } catch (Exception ex2) { // Logs the execution of the task in the event log. EventLogProvider.LogInformation("CustomTask", "Execute Rank class:" + clsname + " Error", ex2.ToString()); } } } } } } }
/// <summary> /// Chekcou click event for order processing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkCheckout_Click(object sender, EventArgs e) { try { if (!DIContainer.Resolve <IShoppingCartProvider>().ValidateAllCarts(userID: CurrentUser.UserID)) { Response.Cookies["status"].Value = QueryStringStatus.InvalidCartItems; Response.Cookies["status"].HttpOnly = false; return; } var loggedInUserCartIDs = GetCartsByUserID(CurrentUser.UserID, ProductType.GeneralInventory, OpenCampaign?.CampaignID); settingKeys = DIContainer.Resolve <IKenticoResourceService>(); var orderTemplateSettingKey = settingKeys.GetSettingsKey("KDA_OrderReservationEmailTemplateGI"); var unprocessedDistributorIDs = new List <Tuple <int, string> >(); var userInfo = DIContainer.Resolve <IKenticoUserProvider>(); var salesPerson = userInfo.GetUserByUserId(CurrentUser.UserID); loggedInUserCartIDs.ForEach(distributorCart => { Cart = ShoppingCartInfoProvider.GetShoppingCartInfo(distributorCart); decimal shippingCost = default(decimal); if (Cart.ShippingOption != null && Cart.ShippingOption.ShippingOptionName.ToLower() != ShippingOption.Ground) { var shippingResponse = GetOrderShippingTotal(Cart); if (shippingResponse != null && shippingResponse.Success) { shippingCost = ValidationHelper.GetDecimal(shippingResponse?.Payload?.Cost, default(decimal)); } else { unprocessedDistributorIDs.Add(new Tuple <int, string>(Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)), shippingResponse.ErrorMessages)); return; } } OrderDTO ordersDTO = CreateOrdersDTO(Cart, Cart.ShoppingCartUserID, OrderType.generalInventory, shippingCost); var response = ProcessOrder(Cart, CurrentUser.UserID, OrderType.generalInventory, ordersDTO, shippingCost); if (response != null && response.Success) { UpdateAvailableSKUQuantity(Cart); UpdateAllocatedProductQuantity(Cart, salesPerson.UserId); ProductEmailNotifications.SendMail(salesPerson, ordersDTO, orderTemplateSettingKey); ShoppingCartInfoProvider.DeleteShoppingCartInfo(Cart); ShoppingCartHelper.UpdateRemainingBudget(ordersDTO, CurrentUser.UserID); } else { unprocessedDistributorIDs.Add(new Tuple <int, string>(Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)), response.ErrorMessages)); } }); if (unprocessedDistributorIDs.Count == 0) { Response.Cookies["status"].Value = QueryStringStatus.OrderSuccess; Response.Cookies["status"].HttpOnly = false; URLHelper.Redirect(Request.RawUrl); } else { if (loggedInUserCartIDs.Count > unprocessedDistributorIDs.Count) { Response.Cookies["status"].Value = QueryStringStatus.OrderSuccess; Response.Cookies["status"].HttpOnly = false; } Response.Cookies["error"].Value = QueryStringStatus.OrderFail; Response.Cookies["error"].HttpOnly = false; ShowOrderErrorList(unprocessedDistributorIDs); divErrorDailogue.Attributes.Add("class", "dialog active"); } } catch (Exception ex) { EventLogProvider.LogInformation("Kadena_CMSWebParts_Kadena_Cart_CartCheckout", "lnkCheckout_Click", ex.Message); } }
public string Execute(TaskInfo ti) { try { string eventName = string.Empty; string eventStartdate = string.Empty; string eventEnddate = string.Empty; string eventDescription = string.Empty; string eventCategory = string.Empty; long eventProductId; StringBuilder documentsAddedStatus = new StringBuilder();//string eventLocation = string.Empty; string eventWebsite = string.Empty; string eventContact = string.Empty; string eventFax = string.Empty; string eventFacilityID = string.Empty; //Communicates with personify web service and gets the list of meetings string dataServiceUri = ConfigurationManager.AppSettings["svcUri_Base"]; string dataServiceUserName = ConfigurationManager.AppSettings["svcLogin"]; string dataServicePassword = ConfigurationManager.AppSettings["svcPassword"]; Uri ServiceUri = new Uri(dataServiceUri); PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri); DataAccessLayer.Credentials = new NetworkCredential(dataServiceUserName, dataServicePassword); var eventsListPersonify = DataAccessLayer.WebProductViews.Where(p => p.Subsystem == "MTG" && p.MeetingEndDate >= DateTime.Now.AddDays(-2)).ToList(); DataSet eventsList = DocumentHelper.GetDocuments("SME.EVENT") .OnSite(SiteContext.CurrentSiteName) .Culture("en-us") .CombineWithDefaultCulture(false) .All(); string un = "smeadmin"; string pwd = "533@dm1n"; //authenticates user for publishing documents/pages/events AuthenticateUser(un, pwd); UserInfo ui = UserInfoProvider.GetUserInfo(un); // Create new instance of the Tree provider TreeProvider tree = new TreeProvider(ui); // Get parent node TreeNode parentNode = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/events-professional-development/events", "en-us"); foreach (var events in eventsListPersonify) { eventName = events.ShortName; eventProductId = events.ProductId; eventStartdate = events.MeetingStartDate.ToString(); eventEnddate = events.MeetingEndDate.ToString(); eventDescription = events.WebShortDescription; eventCategory = events.ProductClassCodeString; eventFacilityID = events.FacilityMasterCustomerId; string[] addressDelimiter = new string[] { "\r\n" }; string[] address; string eventAddress = string.Empty; string eventCity = string.Empty; string eventCountry = string.Empty; string eventStateProvince = string.Empty; string eventZipPostalCode = string.Empty; string eventLocation = string.Empty; string eventEmail = string.Empty; string eventPhone = string.Empty; bool isAllowSocialEvents = events.ProductClassCodeString.ToLower() != "social_event"; if (eventFacilityID != "" && eventFacilityID != null) { var CommuniteeList = DataAccessLayer.AddressInfos.Where(p => p.MasterCustomerId == eventFacilityID).ToList(); foreach (var item in CommuniteeList) { address = item.AddressLabel.Split(addressDelimiter, StringSplitOptions.None); eventAddress = address[0] + " " + address[1]; eventCity = item.City; eventCountry = item.CountryCode; eventStateProvince = item.State; eventZipPostalCode = item.PostalCode; eventLocation = item.City + ", " + item.CountryCode; eventEmail = item.MailStop; eventPhone = item.PersonalLine; } } if (parentNode != null) { if (!DocumentExists(events.ProductId, eventsList) && isAllowSocialEvents) { // Create documents var newNode = CMS.DocumentEngine.TreeNode.New("SME.EVENT", tree); newNode.DocumentName = events.LongName; newNode.NodeAlias = eventName; newNode.DocumentCulture = "en-us"; newNode.SetValue("EventName", eventName); newNode.SetValue("ProductId", eventProductId); newNode.SetValue("StartDate", eventStartdate); newNode.SetValue("EndDate", eventEnddate); newNode.SetValue("EventDetails", eventDescription); newNode.SetValue("EventCategory", eventCategory); newNode.SetValue("Location", eventLocation); //newNode.SetValue("TargetUrl", eventWebsite); //newNode.SetValue("Contact", eventContact); newNode.SetValue("email", eventEmail); newNode.SetValue("Address", eventAddress); newNode.SetValue("City", eventCity); newNode.SetValue("State_Province", eventStateProvince); newNode.SetValue("Zip_PostalCode", eventZipPostalCode); newNode.SetValue("Country", eventCountry); newNode.SetValue("Phone", eventPhone); newNode.SetValue("AllowPersonifyUpdate", true); //newNode.SetValue("Fax", eventFax); newNode.DocumentPageTemplateID = 24357; newNode.Insert(parentNode); //newNode.Publish(); documentsAddedStatus.Append("Meeting " + eventName + " added into kentico at " + DateTime.Now + Environment.NewLine); } else { // Update the Document var updateNode = eventsList.Tables[0].AsEnumerable().Where(row => events.ProductId == row.Field <long?>("ProductId")).Select(row => new { ID = row.Field <int>("NodeId"), }).ToList(); if (updateNode.Count == 1 && isAllowSocialEvents) { TreeNode node = tree.SelectSingleNode(updateNode[0].ID, "en-us", "SME.Event"); if (node.GetBooleanValue("AllowPersonifyUpdate", false)) { //node.DocumentName = events.LongName; //node.NodeAlias = eventName; node.DocumentCulture = "en-us"; //node.SetValue("EventName", eventName); node.SetValue("ProductId", eventProductId); node.SetValue("StartDate", eventStartdate); node.SetValue("EndDate", eventEnddate); //this is the optional field which editors can update from CMS Desk. //node.SetValue("EventDetails", eventDescription); node.SetValue("EventCategory", eventCategory); node.SetValue("Location", eventLocation); //node.SetValue("TargetUrl", eventWebsite); //node.SetValue("Contact", eventContact); node.SetValue("email", eventEmail); node.SetValue("Address", eventAddress); node.SetValue("City", eventCity); node.SetValue("State_Province", eventStateProvince); node.SetValue("Zip_PostalCode", eventZipPostalCode); node.SetValue("Country", eventCountry); node.SetValue("Phone", eventPhone); //node.SetValue("Fax", eventFax); node.SetValue("LastUpdate", DateTime.Now); node.DocumentPageTemplateID = 24357; node.Update(); DocumentHelper.UpdateDocument(node); //node.Publish(); documentsAddedStatus.Append("Meeting " + eventName + " updated in kentico at " + DateTime.Now + Environment.NewLine); } else { documentsAddedStatus.Append("Meeting " + eventName + " skipped due to document setting in document at " + DateTime.Now + Environment.NewLine); } } } } } EventLogProvider.LogInformation("PersonifyMeeting", "Import", documentsAddedStatus.ToString()); } catch (Exception ex) { EventLogProvider.LogException("PersonifyMeeting", "Import", ex); } return(null); }
private void EnsureCmsUserAzureCustomField() { var cmsUserDataClass = DataClassInfoProvider.GetDataClassInfo("cms.user"); if (cmsUserDataClass == null) { return; } var formInfo = new FormInfo(cmsUserDataClass.ClassFormDefinition); if (formInfo.FieldExists("AzureADUsername")) { EventLogProvider.LogInformation("AzureADAuthentication", "Skip Create Field", "AzureADUsername"); return; } // Create "AzureADUsername" field if it doesn't exist EventLogProvider.LogInformation("AzureADAuthentication", "Create Field", "AzureADUsername"); var azureAdUsernameTextField = new FormFieldInfo { Name = "AzureADUsername", DataType = "text", Size = 200, Precision = -1, AllowEmpty = true, DefaultValue = string.Empty, System = false, FieldType = FormFieldControlTypeEnum.TextBoxControl, Visible = true, Caption = "Azure AD Username", Enabled = true }; using (var tr = new CMSLateBoundTransaction()) { var tm = new TableManager(cmsUserDataClass.ClassConnectionString); tr.BeginTransaction(); var newFieldHandler = (AbstractAdvancedHandler)null; try { newFieldHandler = DataDefinitionItemEvents.AddItem.StartEvent(cmsUserDataClass, azureAdUsernameTextField); var sqlType = DataTypeManager.GetSqlType(azureAdUsernameTextField.DataType, azureAdUsernameTextField.Size, azureAdUsernameTextField.Precision); tm.AddTableColumn(cmsUserDataClass.ClassTableName, azureAdUsernameTextField.Name, sqlType, azureAdUsernameTextField.AllowEmpty, azureAdUsernameTextField.DefaultValue); formInfo.AddFormItem(azureAdUsernameTextField); cmsUserDataClass.ClassFormDefinition = formInfo.GetXmlDefinition(); cmsUserDataClass.ClassXmlSchema = tm.GetXmlSchema(cmsUserDataClass.ClassTableName); DataClassInfoProvider.SetDataClassInfo(cmsUserDataClass); FormHelper.UpdateInheritedClasses(cmsUserDataClass); QueryInfoProvider.ClearDefaultQueries(cmsUserDataClass, true, true); newFieldHandler.FinishEvent(); tr.Commit(); ClearHashtables("cms.user"); } catch (Exception ex) { EventLogProvider.LogException("AzureADAuthentication", "Create Field", ex); } finally { newFieldHandler?.Dispose(); } } }
public void LogInfo(string source, string eventCode, string info) { EventLogProvider.LogInformation(source, eventCode, eventDescription: info); }
public void LogError(string source, string error) { EventLogProvider.LogInformation(source, "ERROR", error); }