public async Task <ActionResult> SaveHrefs(IEnumerable <HrefAssociation> newHrefs, IEnumerable <HrefAssociation> updateHrefs) { try { using (var context = SpManager.GetSharePointContext(HttpContext)) { if (!SpManager.IsUserAdmin(context)) { return(AccessDenied()); } var userKey = GetUserKey(); await SQLTemplateStorageManager.SaveNewHrefAssociations(userKey, newHrefs ?? Enumerable.Empty <HrefAssociation>()); await SQLTemplateStorageManager.UpdateHrefAssociations(userKey, updateHrefs ?? Enumerable.Empty <HrefAssociation>()); } } catch (Exception e) { return(Json(e.StackTrace)); } return(Json(new { success = true })); }
public async Task <ActionResult> ManageHrefs() { try { using (var context = SpManager.GetSharePointContext(HttpContext)) { if (!SpManager.IsUserAdmin(context)) { return(AccessDenied()); } var userKey = GetUserKey(); var templates = await GetTemplatesAsync(userKey); var hrefs = (await SQLTemplateStorageManager.ListHrefAssociations(userKey)).ToList(); return(View(new ManageHrefsModel { Hrefs = hrefs, Templates = templates })); } } catch (Exception e) { throw QfsUtility.HandleException(e); } }
public static string GetAllSpDetails(string pregistration_no) { SpManager spManager = new SpManager(); DataTable dt = new DataTable(); if (HttpContext.Current.Session["BranchId"] != null) { if (!HttpContext.Current.Session["BranchId"].ToString().Equals("0001")) { dt = spManager.GetSpDetailsByReg(pregistration_no); DataColumn[] columns = dt.Columns.Cast <DataColumn>().ToArray(); bool contains = dt.AsEnumerable() .Any(row => columns.Any(col => row[col].ToString() == HttpContext.Current.Session["BranchId"].ToString())); if (contains) { dt = dt.AsEnumerable().Where(r => r.Field <string>("BRANCH_NAME") == HttpContext.Current.Session["BranchId"].ToString()).CopyToDataTable(); } else { dt = new DataTable(); } } } return(DatatableToJson(dt)); }
public JsonResult GetRootSiteUrl() { string rootSiteUrl = null; var isSuccess = false; try { var hostUrl = SpManager.GetHostParam(HttpContext.Request); using (var clientContext = GetClientContext(hostUrl)) { var site = clientContext.Site; clientContext.Load(site); clientContext.ExecuteQuery(); rootSiteUrl = site.Url; } isSuccess = true; } catch (Exception ex) { rootSiteUrl = ex.StackTrace; } return(Json(new { Success = isSuccess, Url = rootSiteUrl }, JsonRequestBehavior.AllowGet)); }
public static string GetSpFacevalue(string pregistration_no, string pinstrument_number) { SpManager spManager = new SpManager(); Dictionary <string, object> inputParam = new Dictionary <string, object>(); inputParam.Add("pregistration_no", pregistration_no); inputParam.Add("pinstrument_number", pinstrument_number); DataTable dt = spManager.GetImportedSpFacevalue(inputParam); HttpContext.Current.Session["SpFaceValue"] = dt; DataTable filteredData = new DataTable(); filteredData.Columns.Add("INSTRUMENT_NUMBER"); filteredData.Columns.Add("DENOMINATION"); foreach (DataRow dr in dt.Rows) { DataRow row = filteredData.NewRow(); row["INSTRUMENT_NUMBER"] = dr["INSTRUMENT_NUMBER"]; row["DENOMINATION"] = dr["DENOMINATION"]; filteredData.Rows.Add(row); } return(DatatableToJson(filteredData)); }
protected void Application_Start(object sender, System.EventArgs e) { //suppose sp_config.json inside C:\Program Files\IIS Express //CSpConfig config = SpManager.SetConfig(false, //@"D:\cyetest\socketpro\samples\web_two\web_two\sp_config.json"); Master = SpManager.GetPool("masterdb") as CSqlMasterPool <CMysql, CDataSet>; CMysql handler = Master.Seek(); if (handler != null) //create a test database { string sql = @"CREATE DATABASE IF NOT EXISTS mysample character set utf8 collate utf8_general_ci;USE mysample;CREATE TABLE IF NOT EXISTS COMPANY(ID BIGINT PRIMARY KEY NOT NULL,Name CHAR(64)NOT NULL);CREATE TABLE IF NOT EXISTS EMPLOYEE(EMPLOYEEID BIGINT PRIMARY KEY AUTO_INCREMENT, CompanyId BIGINT NOT NULL,Name NCHAR(64)NOT NULL,JoinDate DATETIME(6) DEFAULT NULL,FOREIGN KEY(CompanyId)REFERENCES COMPANY(id));USE sakila; INSERT INTO mysample.COMPANY(ID,Name)VALUES(1,'Google Inc.'), (2,'Microsoft Inc.'),(3,'Amazon Inc.')"; handler.Execute(sql); } Cache = Master.Cache; Slave = SpManager.GetPool("slavedb0") as CSqlMasterPool <CMysql, CDataSet> .CSlavePool; Master_No_Backup = SpManager.GetPool("db_no_backup") as CSqlMasterPool <CMysql, CDataSet> .CSlavePool; }
public ActionResult SharePointFile(string path) { try { var hostUrl = SpManager.GetHostParam(HttpContext.Request); using (var clientContext = GetClientContext(hostUrl)) { var file = clientContext.Web.GetFileByServerRelativeUrl(path); var clientStream = file.OpenBinaryStream(); clientContext.Load(file); clientContext.ExecuteQuery(); using (var stream = clientStream.Value) using (var reader = new StreamReader(stream)) { var contents = reader.ReadToEnd(); return(new ObjectResult <object>(GetJsonResponse(data: contents))); } } } catch (Exception e) { return(Json(new { error = e.Message }, JsonRequestBehavior.AllowGet)); } }
private ClientContext GetClientContext(string location, bool isLibrarySubmit = false) { var appInstance = SqlCredentialManager.GetMatchingInstanceByUrl(location); var isValidInstance = appInstance != null && !String.IsNullOrWhiteSpace(appInstance.Username) && !String.IsNullOrWhiteSpace(appInstance.Password); var webUrl = isLibrarySubmit ? GetWebUrl(location) : location; if (!isValidInstance) { return(SpManager.GetSharePointContext(HttpContext, webUrl)); } var credentials = GetCredentials(webUrl, appInstance); var clientContext = new ClientContext(webUrl); clientContext.Credentials = credentials; return(clientContext); }
public async Task <ActionResult> GetTemplateInfo(string templateName) { if (String.IsNullOrWhiteSpace(templateName)) { return(new ObjectResult <string>(null)); } try { var template = await TemplateManager.GetTemplateRecord(SpManager.GetRealm(), templateName); if (template == null) { return(new ObjectResult <string>(null)); } var templateInfo = new { instanceId = template.CurrentInstanceId }; return(new ObjectResult <object>(templateInfo)); } catch (Exception ex) { return(new ObjectResult <ErrorModel>(ErrorModel.FromException(ex))); } }
public async Task <ActionResult> ManageTemplates() { try { var checkUsageCountData = await CheckIsUsageExceededAsync(); var location = checkUsageCountData.Item1; var monthlyFormOpenCount = checkUsageCountData.Item2; var isUsageExceeded = checkUsageCountData.Item3; using (var context = SpManager.GetSharePointContext(HttpContext)) { if (!SpManager.IsUserAdmin(context)) { return(AccessDenied()); } var templates = await GetTemplatesAsync(); return(View(new ManageTemplatesViewModel { Templates = templates, MonthlyFormOpenCount = monthlyFormOpenCount, Location = location, IsUsageExceeded = isUsageExceeded })); } } catch (Exception e) { throw QfsUtility.HandleException(e); } }
public static AppInstance GetMatchingInstanceByUrl(string requestUrl) { var instanceList = GetAppInstances(SpManager.GetRealm()); if (instanceList == null) { return(null); } var matchedInstances = instanceList .Where(instance => !String.IsNullOrWhiteSpace(instance.ServiceURL) && requestUrl.IndexOf(instance.ServiceURL, StringComparison.InvariantCultureIgnoreCase) == 0) .OrderByDescending(instance => instance.ServiceURL.Length); if (!matchedInstances.Any()) { return(null); } var matchedInstance = matchedInstances.First(); matchedInstance.InitializeCredentials(); return(matchedInstance); }
private void InitClientContext() { try { using (var clientContext = SpManager.GetSharePointContext(HttpContext)) { } } catch (Exception e) { throw; } }
public static string LockApprovedRequest(string requestId, int status, string paidAmount, string exceptionMessage) { SpManager spManager = new SpManager(); string approveUser = HttpContext.Current.Session["USER_ID"].ToString(); Dictionary <string, object> inputParam = new Dictionary <string, object>(); inputParam = ClaimSpRequest(requestId, status, approveUser, paidAmount, exceptionMessage); DataTable dt = spManager.ClaimSpRequest(inputParam); return(DatatableToJson(dt)); }
static void Main(string[] args) { CSpConfig config = SpManager.SetConfig(true, @"c:\cyetest\socketpro\samples\stream_system\sp_config.json"); CYourServer.Master = SpManager.GetPool("masterdb") as CSqlMasterPool <CMysql, CDataSet>; CYourServer.Slave = SpManager.GetPool("slavedb0") as CSqlMasterPool <CMysql, CDataSet> .CSlavePool; CDataSet Cache = CYourServer.Master.Cache; using (CYourServer server = new CYourServer(2)) { //Cache is ready for use now List <KeyValuePair <string, string> > v0 = Cache.DBTablePair; if (v0.Count == 0) { Console.WriteLine("There is no table cached"); } else { Console.WriteLine("Table cached:"); foreach (KeyValuePair <string, string> p in v0) { Console.WriteLine("DB name = {0}, table name = {1}", p.Key, p.Value); } DataColumn[] keys = Cache.FindKeys(v0[0].Key, v0[0].Value); foreach (DataColumn dc in keys) { Console.WriteLine("Key ordinal = {0}, key column name = {1}", dc.Ordinal, dc.ColumnName); } } DataTable tbl = Cache.Find("sakila", "actor", "actor_id >= 1 and actor_id <= 10"); CYourServer.CreateTestDB(); Console.WriteLine(); //test certificate and private key files are located at the directory ../socketpro/bin #if WIN32_64 //or load cert and private key from windows system cert store server.UseSSL("C:\\cyetest\\socketpro\\bin\\intermediate.pfx", "", "mypassword"); #else //non-windows platforms server.UseSSL("intermediate.cert.pem", "intermediate.key.pem", "mypassword"); #endif //start listening socket with standard TLSv1.x security if (!server.Run(20911)) { Console.WriteLine("Error happens with error message = " + CSocketProServer.ErrorMessage); } Console.WriteLine("Press any key to shut down the application ......"); Console.ReadLine(); CYourServer.Slave.ShutdownPool(); CYourServer.Master.ShutdownPool(); } }
public async Task <ActionResult> Index() { var isUsageExceeded = (await CheckIsUsageExceededAsync()).Item3; using (var context = SpManager.GetSharePointContext(HttpContext)) { return(View(new IndexViewModel { IsAdmin = SpManager.IsUserAdmin(context), Version = QfsUtility.InternalGetQFSVersion(), IsUsageExceeded = isUsageExceeded })); } }
public static string DeleteFile(string prequestId, int pdocsl_no) { SpManager spManager = new SpManager(); string make_by = HttpContext.Current.Session["USER_ID"].ToString(); Dictionary <string, object> inputParam = new Dictionary <string, object>(); inputParam.Add("prequest_id", prequestId); inputParam.Add("pmake_by", make_by); inputParam.Add("pdocsl_no", pdocsl_no); DataTable dt = spManager.DeleteFile(inputParam); return(DatatableToJson(dt)); }
public ActionResult UploadTemplate(string formName, bool update = false) { using (var context = SpManager.GetSharePointContext(HttpContext)) { if (!SpManager.IsUserAdmin(context)) { return(AccessDenied()); } return(View(new UploadTemplateViewModel { CreateNew = !update, FormName = formName })); } }
public static string GetSpDetails(string prequest_id) { SpManager spManager = new SpManager(); Dictionary <string, object> inputParam = new Dictionary <string, object>(); inputParam.Add("pbranch_id", string.Empty); inputParam.Add("prequest_id", prequest_id); inputParam.Add("prequest_status_id", string.Empty); inputParam.Add("pregistration_no", string.Empty); //inputParam.Add("psanchay_patra_no", string.Empty); inputParam.Add("pcustomer_name", string.Empty); inputParam.Add("pcustomer_mobile_no", string.Empty); DataTable dt = spManager.GetRspMasterData(inputParam); return(DatatableToJson(dt)); }
public async Task <ActionResult> DeleteTemplate(string templateName) { using (var context = SpManager.GetSharePointContext(HttpContext)) { if (!SpManager.IsUserAdmin(context)) { return(Json(false)); } } if (String.IsNullOrWhiteSpace(templateName)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var result = await TemplateManager.DeleteTemplate(templateName, StorageContext); return(Json(result)); }
public static string GetSpFacevalue(string prequest_id, string psanchay_patra_no) { SpManager spManager = new SpManager(); Dictionary <string, object> inputParam = new Dictionary <string, object>(); inputParam.Add("prequest_id", prequest_id); inputParam.Add("psanchay_patra_no", psanchay_patra_no); DataTable dt = spManager.GetSpFacevalue(inputParam); DataTable filteredData = new DataTable(); filteredData.Columns.Add("SANCHAY_PATRA_NO"); filteredData.Columns.Add("DENOMINATION"); foreach (DataRow dr in dt.Rows) { DataRow row = filteredData.NewRow(); row["SANCHAY_PATRA_NO"] = dr["SANCHAY_PATRA_NO"]; row["DENOMINATION"] = dr["DENOMINATION"]; filteredData.Rows.Add(row); } return(DatatableToJson(filteredData)); }
public static string EditRequestByBranch(string requestId, string branchId, string mobileNo, string customerAccNo, string faceValue, string startCupon, string endCupon, string prequest_status_id) { SpManager spManager = new SpManager(); string makeBy = HttpContext.Current.Session["USER_ID"].ToString(); Dictionary <string, object> claimParam = new Dictionary <string, object>(); claimParam.Add("pbranch_id", branchId); claimParam.Add("prequest_id", requestId); claimParam.Add("pregistration_No", string.Empty); //claimParam.Add("psanchay_Patra_No", string.Empty); claimParam.Add("pwalk_In_Customer", string.Empty); claimParam.Add("pcustomer_Acc_No", customerAccNo); claimParam.Add("pcustomer_Name", string.Empty); claimParam.Add("pcustomer_Mobile_No", mobileNo); claimParam.Add("pinvestment_Date", string.Empty); claimParam.Add("ptotal_Investment", string.Empty); //claimParam.Add("pface_Value", faceValue); claimParam.Add("pstart_Coupon_No", startCupon); claimParam.Add("pend_Coupon_No", endCupon); claimParam.Add("ppaid_Amount", string.Empty); claimParam.Add("prequest_status_id", prequest_status_id); claimParam.Add("pauthorize_status", string.Empty); claimParam.Add("pmake_By", makeBy); claimParam.Add("pmake_Date", string.Empty); claimParam.Add("pauthorize_By", makeBy); claimParam.Add("pauthorize_Date", string.Empty); claimParam.Add("papproved_by", string.Empty); claimParam.Add("papproved_dt", string.Empty); claimParam.Add("premarks", string.Empty); DataTable dt = spManager.ClaimSpRequest(claimParam); return(DatatableToJson(dt)); }
private static string GetCurrentLocation() { return(QfsUtility.FormatLocation(SpManager.GetSpHost())); }
public void ProcessRequest(HttpContext context) { SpManager spManager = new SpManager(); string makeby = context.Session["USER_ID"].ToString(); string requestId = context.Request.Form["requestId"]; string regNo = context.Request.Form["regNo"]; string docType = context.Request.Form["docType"]; string hoFlag = context.Session["BranchID"].ToString().Equals("0001") ? "1" : "0"; string branchFlag = context.Session["BranchID"].ToString().Equals("0001") ? "0" : "1"; bool fileAlreadyUploaded = false; List <Dictionary <string, object> > fileInfoParamList = new List <Dictionary <string, object> >(); foreach (string file in context.Request.Files) { var hpf = context.Request.Files[file] as HttpPostedFile; if (hpf.ContentLength == 0) { break; } List <Dictionary <string, object> > previousFileList = new List <Dictionary <string, object> >(); if (context.Session["NewBranchFileList"] != null) { previousFileList = (List <Dictionary <string, object> >)context.Session["NewBranchFileList"]; foreach (Dictionary <string, object> previousFile in previousFileList) { if (requestId.Equals(previousFile["prequest_id"].ToString()) && hpf.FileName.ToLower().Equals(previousFile["pfile_nm"].ToString().ToLower())) { fileAlreadyUploaded = true; } } } if (fileAlreadyUploaded) { break; } var savedFileName = context.Server.MapPath("~/SPFile/") + DateTime.Now.ToString("ddMMyyyyhhmmss") + Path.GetFileName(hpf.FileName); hpf.SaveAs(savedFileName); //save file Dictionary <string, object> fileParam = new Dictionary <string, object>(); fileParam.Add("pregistration_no", regNo); fileParam.Add("prequest_id", requestId); fileParam.Add("pdocsl_no", string.Empty); fileParam.Add("pdocuments_type_id", docType); fileParam.Add("pfile_nm", hpf.FileName.ToString()); fileParam.Add("pfile_navigate_url", savedFileName); fileParam.Add("pfolder_location", savedFileName.Substring(0, savedFileName.LastIndexOf(@"\"))); fileParam.Add("pho_upload_flag", hoFlag); fileParam.Add("pbr_upload_flag", branchFlag); fileParam.Add("premarks", string.Empty); fileParam.Add("psys_gen_flag", "S"); fileParam.Add("pauth_status_id", "A"); fileParam.Add("puser_id", makeby); fileInfoParamList.Add(fileParam); if (context.Session["NewBranchFileList"] != null) { previousFileList = (List <Dictionary <string, object> >)context.Session["NewBranchFileList"]; previousFileList.Add(fileParam); context.Session["NewBranchFileList"] = previousFileList; } else { context.Session["NewBranchFileList"] = fileInfoParamList; } } spManager.InsertAdditionalFile(fileInfoParamList, requestId); context.Response.ContentType = "text/plain"; context.Response.Write("Uploaded"); }
public async Task <ActionResult> TemplateDefinition(string libraryUrl = null, string xsnUrl = null, string templateName = null, bool includeTemplateXml = false, string instanceId = null) { try { using (var clientContext = GetSharePointContext()) { var userKey = SpManager.GetRealm(); if (xsnUrl != null) { var redirectTemplateName = await SQLTemplateStorageManager.FindRedirectTemplateName(userKey, xsnUrl); if (redirectTemplateName != null) { templateName = redirectTemplateName; xsnUrl = null; } } var manifest = await TemplateManager.ManifestWithProperties(clientContext, libraryUrl, xsnUrl, templateName, StorageContext, instanceId); if (manifest == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var template = new TemplateDefinition { TemplateName = templateName, XsnUrl = xsnUrl, LibraryUrl = libraryUrl }; template.Files.Add(manifest.FormFile); if (!String.IsNullOrWhiteSpace(templateName)) { template.InitializeInstanceId(manifest); } var tasks = GetContentList(manifest, includeTemplateXml) .Select(item => GetTemplateFileOrFail(clientContext, libraryUrl, xsnUrl, templateName, template.InstanceId, item, StorageContext)) .ToList(); while (tasks.Count > 0) { var task = await Task.WhenAny(tasks); tasks.Remove(task); template.Files.Add(await task); } await CheckAndUpdateOpenCountAsync(templateName, userKey); CheckAndAddExpiryHeader(instanceId); return(new ObjectResult <TemplateDefinition>(template)); } } catch (Exception e) { return(new ObjectResult <ErrorModel>(ErrorModel.FromException(e))); } }
public async Task <ActionResult> UploadTemplate(string formName, string location, bool update = false, bool allowDowngrade = false) { using (var context = SpManager.GetSharePointContext(HttpContext)) { if (!SpManager.IsUserAdmin(context)) { return(AccessDenied()); } if (!string.IsNullOrWhiteSpace(formName) && Request.Files.Count > 0) { location = QfsUtility.FormatLocation(location); if (!update && string.IsNullOrWhiteSpace(location)) { return(Json(new UploadTemplateViewModel { CreateNew = true, FormName = formName, Message = "Cannot add template, location is missing" })); } try { var template = Request.Files[0]; var realm = GetUserKey(); context.Load(context.Web); context.ExecuteQuery(); context.Load(context.Web.CurrentUser); context.ExecuteQuery(); var currentUser = context.Web.CurrentUser.Title; var tuple = await SQLTemplateStorageManager.StoreTemplate(realm, formName, !update, template.InputStream, template.FileName, allowDowngrade, StorageContext, currentUser, location); return(Json(new UploadTemplateViewModel { HideContent = true, Message = UploadedMessage(update), IsUploaded = tuple.Item1, OldVersion = tuple.Item2, NewVersion = tuple.Item3 })); } catch (Exception e) { return(Json(new UploadTemplateViewModel { CreateNew = !update, FormName = formName, Message = e.Message #if DEBUG , Stack = e.StackTrace #endif })); } } else { return(UploadTemplate(formName, update)); } } }
private static string GetUserKey() { return(SpManager.GetRealm()); }