public void CreatenNewOptionSetSheet(OptionSetMetadata optionSetMetadata, AttributeMetadata currentAttribute)
        {
            GlobalApplicationData appData = GlobalApplicationData.Instance;
            string sheetName = optionSetMetadata.MetadataId.ToString();
            OptionSetExcelSheetsInfo excelSheet = new OptionSetExcelSheetsInfo(ExcelSheetInfo.ExcelSheetType.optionSet, optionSetMetadata, currentAttribute);

            CreatenNewExcelSheet(sheetName, excelSheet);
            GlobalOperations.Instance.ExcelOperations.refreshOptionSetSheet(GlobalApplicationData.Instance.eSheetsInfomation.getCurrentSheet());
        }
        public void CreatenNewEntitySheet()
        {
            GlobalApplicationData data = GlobalApplicationData.Instance;
            string sheetName           = string.Format("Entities List - {0}", data.currentSolution.SolutionName);

            EntityMetadata[]      allEntities = GetEntitiesWithAttributes();
            EntityExcelSheetsInfo excelSheet  = new EntityExcelSheetsInfo(ExcelSheetInfo.ExcelSheetType.entity, allEntities, sheetName);

            CreatenNewExcelSheet(sheetName, excelSheet);
            GlobalOperations.Instance.ExcelOperations.refreshEntitySheeet(data.eSheetsInfomation.getCurrentSheet(), allEntities);
        }
        public void CreatenNewAttributesSheet(Guid entityId)
        {
            GlobalApplicationData data          = GlobalApplicationData.Instance;
            EntityMetadata        currentEntity = CRMOpHelper.RetriveEntityAtrribute(entityId);
            string sheetName = Utils.getLocalizedLabel(currentEntity.DisplayName.LocalizedLabels, data.currentLanguage);
            AttributeExcelSheetsInfo attributesSheet = new AttributeExcelSheetsInfo(currentEntity, GlobalOperations.Instance.getCurrentSolutionPubblisher());

            CreatenNewExcelSheet(sheetName, attributesSheet);
            IEnumerable <string> formAttr = CRMOpHelper.GetAttributeOfTheMainForm(currentEntity.ObjectTypeCode.Value);

            ExcelOperations.refreshAttributeSheeet(data.eSheetsInfomation.getCurrentSheet(), currentEntity, GlobalApplicationData.Instance.allEntities, formAttr);
        }
Example #4
0
        public ActionResult <RegisterUserResponse> RegisterUser()
        {
            StreamReader            reader          = new StreamReader(HttpContext.Request.Body);
            string                  requestFromPost = reader.ReadToEnd();
            RegisterUserRequestBody requestBody     = JsonConvert.DeserializeObject <RegisterUserRequestBody>(requestFromPost.Replace("'", "\'"));
            IApp core = GlobalApplicationData.GetGlobalData <IApp>(GlobalDataKey.Core);
            var  userActivationCode = core.GetUserManager().RegisterUser(requestBody);

            return(new RegisterUserResponse
            {
                ActivationCode = userActivationCode
            });
        }
        public void CreatenNewFormSheet(Guid formId)
        {
            Entity form = CRMOpHelper.GetForm(formId);

            if (form != null && form.Contains("name") && form.Contains("formxml") && form.Contains("objecttypecode"))
            {
                GlobalApplicationData data = GlobalApplicationData.Instance;
                string   sheetName         = string.Format("{0} - {1}", form["name"].ToString(), form["objecttypecode"].ToString());
                FormType formObj           = FormXmlMapper.MapFormXmlToObj(form.Attributes["formxml"].ToString());
                CreatenNewExcelSheet(sheetName, new FormExcelSheetsInfo(formId, form.Attributes["formxml"].ToString(), formObj));
                data.eSheetsInfomation.getCurrentSheet().language = GlobalApplicationData.Instance.currentLanguage;
                ExcelOperations.RefreshFormSheet(data.eSheetsInfomation.getCurrentSheet());
            }
        }
    public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
    {
        IApp core         = GlobalApplicationData.GetGlobalData <IApp>(GlobalDataKey.Core);
        var  userManager  = core.GetUserManager();
        bool isAuthorized = userManager.IsUserAuthorised(context.HttpContext.Request.Headers["authorization"], _accountType);

        if (!isAuthorized)
        {
            context.Result = new UnauthorizedResult();
        }
        else
        {
            await next();
        }
    }
        public void CreatenNewViewSheet(string viewName, string viewDescription, Guid entity)
        {
            EntityMetadata etMetadata            = GlobalOperations.Instance.CRMOpHelper.RetriveEntityAtrribute(entity);
            IEnumerable <AttributeMetadata> attr = etMetadata.Attributes.Where(x => x.AttributeType != null && x.AttributeType == AttributeTypeCode.Lookup);
            GlobalApplicationData           data = GlobalApplicationData.Instance;
            string sheetName = string.Format("{0} - {1}", viewName, etMetadata.LogicalName.ToString());

            CreatenNewExcelSheet(sheetName, new ViewExcelSheetsInfo(Guid.NewGuid(), viewName, viewDescription, etMetadata.LogicalName, entity));
            ViewXml.GenerateNewFechXml((ViewExcelSheetsInfo)data.eSheetsInfomation.getCurrentSheet(), etMetadata);
            ViewExcelSheetsInfo currentSheet = ((ViewExcelSheetsInfo)data.eSheetsInfomation.getCurrentSheet());

            currentSheet.language      = GlobalApplicationData.Instance.currentLanguage;
            currentSheet.relationsList = ViewXml.GenerateViewRelatedObj(currentSheet);
            GlobalOperations.Instance.ExcelOperations.RefreshViewSheet(data.eSheetsInfomation.getCurrentSheet(), attr);
        }
Example #8
0
        public ActionResult <User> GetUserDetails()
        {
            string authCode    = HttpContext.Request.Headers["authorization"];
            IApp   core        = GlobalApplicationData.GetGlobalData <IApp>(GlobalDataKey.Core);
            var    userDetails = core.GetUserManager().GetUserDetailsByAuthCode(authCode);

            return(new User
            {
                DOB = userDetails.DOB,
                Email = userDetails.Email,
                FullName = userDetails.FullName,
                IsActive = userDetails.IsActive,
                UserName = userDetails.UserName,
                AccountType = userDetails.AccountType
            });
        }
        public void RefreshCurrentFormSheet()
        {
            GlobalApplicationData data = GlobalApplicationData.Instance;

            if (data.eSheetsInfomation.getCurrentSheet().sheetType == ExcelSheetInfo.ExcelSheetType.form)
            {
                Entity form = CRMOpHelper.GetForm(Guid.Parse(data.eSheetsInfomation.getCurrentSheet().objectName));
                if (form != null && form.Contains("name") && form.Contains("formxml") && form.Contains("objecttypecode"))
                {
                    string   sheetName = string.Format("{0} - {1}", form["name"].ToString(), form["objecttypecode"].ToString());
                    FormType formObj   = FormXmlMapper.MapFormXmlToObj(form.Attributes["formxml"].ToString());
                    data.eSheetsInfomation.getCurrentSheet().language = GlobalApplicationData.Instance.currentLanguage;
                    ExcelOperations.RefreshFormSheet(data.eSheetsInfomation.getCurrentSheet());
                }
            }
        }
Example #10
0
        public ActionResult <AuthenticationResponseBody> AuthenticateUser()
        {
            StreamReader reader                   = new StreamReader(HttpContext.Request.Body);
            string       requestFromPost          = reader.ReadToEnd();
            AuthenticationRequestBody requestBody = JsonConvert.DeserializeObject <AuthenticationRequestBody>(requestFromPost.Replace("'", "\'"));
            string loginAuthCode                  = HttpContext.Request.Headers["authorization"];
            IApp   core        = GlobalApplicationData.GetGlobalData <IApp>(GlobalDataKey.Core);
            var    userDetails = core.GetUserManager().AuthenticateUser(requestBody.UserName, loginAuthCode);

            return(new AuthenticationResponseBody
            {
                AccountType = userDetails.AccountType,
                AuthCode = userDetails.AuthCode,
                FullName = userDetails.FullName,
                IsActive = userDetails.IsActive,
                UserName = userDetails.UserName
            });
        }
Example #11
0
        public Startup(IConfiguration configuration, IHostingEnvironment env)
        {
            IConfigurationBuilder configBuilder = new ConfigurationBuilder()
                                                  .SetBasePath(env.ContentRootPath)
                                                  .AddJsonFile("appSettings.json", optional: true, reloadOnChange: true)
                                                  .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);

            configBuilder.AddEnvironmentVariables();
            Configuration = configBuilder.Build();

            var appConfig = Configuration.GetSection("AppConfig");

            GlobalApplicationData.SetGlobalData(GlobalDataKey.Core, new App(new AppConfig
            {
                DBConnectionString = appConfig.GetValue <string>("ConnectionString"),
                DatabaseName       = appConfig.GetValue <string>("DatabaseName")
            }));
        }
 public static int getSheetLangauge(GlobalApplicationData appData)
 {
     if (appData.eSheetsInfomation == null || appData.eSheetsInfomation.getCurrentSheet() == null || appData.eSheetsInfomation.getCurrentSheet().language == 0)
     {
         if (appData.crmInstalledLanguages == null || appData.crmInstalledLanguages.Count() == 0)
         {
             return(DEFAULTLANGUAGE);
         }
         else
         {
             if (appData.eSheetsInfomation.getCurrentSheet() != null)
             {
                 appData.eSheetsInfomation.getCurrentSheet().language = appData.crmInstalledLanguages[0];
             }
             return(appData.crmInstalledLanguages.First());
         }
     }
     return(appData.eSheetsInfomation.getCurrentSheet().language);
 }
        public void CreatenNewViewSheet(Guid viewId, Guid entity)
        {
            Entity         view                  = CRMOpHelper.GetView(viewId);
            EntityMetadata etMetadata            = CRMOpHelper.RetriveEntityAtrribute(entity);
            IEnumerable <AttributeMetadata> attr = etMetadata.Attributes.Where(x => x.AttributeType != null && x.AttributeType == AttributeTypeCode.Lookup);

            if (view != null && view.Contains("name") && view.Contains("layoutxml") && view.Contains("returnedtypecode") && view.Contains("fetchxml"))
            {
                GlobalApplicationData data      = GlobalApplicationData.Instance;
                string sheetName                = string.Format("{0} - {1}", view["name"].ToString(), view["returnedtypecode"].ToString());
                savedqueryLayoutxmlGrid viewObj = FormXmlMapper.MapViewXmlToObj(view.Attributes["layoutxml"].ToString());
                FetchType fatchObj              = FormXmlMapper.MapFetchXmlToObj(view.Attributes["fetchxml"].ToString());
                CreatenNewExcelSheet(sheetName, new ViewExcelSheetsInfo(viewId, view.Attributes["layoutxml"].ToString(), view.Attributes["fetchxml"].ToString(), viewObj, fatchObj, entity, etMetadata.LogicalName));
                ViewExcelSheetsInfo currentSheet = ((ViewExcelSheetsInfo)data.eSheetsInfomation.getCurrentSheet());
                currentSheet.language      = GlobalApplicationData.Instance.currentLanguage;
                currentSheet.relationsList = ViewXml.GenerateViewRelatedObj(currentSheet);
                ExcelOperations.RefreshViewSheet(data.eSheetsInfomation.getCurrentSheet(), attr);
            }
        }
        public void CreatenNewExcelSheet(string sheetName, ExcelSheetInfo excelInfo)
        {
            GlobalApplicationData data  = GlobalApplicationData.Instance;
            bool           sheetRemoved = false;
            ExcelSheetInfo currentSheet = data.eSheetsInfomation.getSheetByName(excelInfo.objectName);

            if (currentSheet != null)
            {
                data.eSheetsInfomation.setCurrentSheet(excelInfo.objectName);
                sheetRemoved = GlobalOperations.Instance.ExcelOperations.selectSheet(currentSheet.workSheetName, data.eSheetsInfomation.getCurrentSheet());
            }
            if (sheetRemoved)
            {
                data.eSheetsInfomation.removeSheetByName(excelInfo.objectName);
            }
            if (data.eSheetsInfomation.getSheetByName(excelInfo.objectName) == null || sheetRemoved)
            {
                string    excelName = GetValidWorksheetName(sheetName != string.Empty ? sheetName : excelInfo.objectName);
                Worksheet sheet     = GlobalOperations.Instance.ExcelOperations.createNewWorksheet(excelName);
                excelInfo.excelsheet    = sheet;
                excelInfo.workSheetName = excelName;
                data.eSheetsInfomation.addSheetAndSetAsCurrent(excelInfo, excelInfo.objectName);
            }
        }
 public ExcelSheetEventHandler(optioSetEventHandler optioSetEventHandlerDelegate, GlobalApplicationData appData, ExcelDataAccess excellData)
 {
     this.optioSetEventHandlerDelegate = optioSetEventHandlerDelegate;
     this.appData    = appData;
     this.excellData = excellData;
 }