コード例 #1
0
        public HttpResponseMessage Post(AssetValue val)
        {
            if (val == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            _rep.Create(val);
            var response = Request.CreateResponse(HttpStatusCode.Created, val);

            var odataPath = Request.GetODataPath();

            if (odataPath == null)
            {
                throw new InvalidOperationException("There is no ODataPath in the request.");
            }
            var entitySetPathSegment = odataPath.Segments.FirstOrDefault() as EntitySetPathSegment;

            if (entitySetPathSegment == null)
            {
                throw new InvalidOperationException("ODataPath doesn't start with EntitySetPathSegment.");
            }

            response.Headers.Location = new Uri(Url.ODataLink(entitySetPathSegment, new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(val.Id, ODataVersion.V3))));

            //response.Headers.Location = new Uri(Url.ODataLink(new EntitySetPathSegment("Governors"), new KeyValuePathSegment(gov.Id.ToString())));

            return(response);
        }
コード例 #2
0
        public object ActivateEmptyModel()
        {
            AssetValue a = new AssetValue();

            a.TakingDate    = DateTime.Today;
            a.InsuranceType = BL.Model.Enums.InsuranceType.OPS;
            //a.GovernorId = g.Id;
            a.Governor = null;
            return(a);
        }
コード例 #3
0
ファイル: Reference.cs プロジェクト: koder05/progs
        public static AssetValue CreateAssetValue(byte insuranceTypeValue, global::System.DateTime takingDate, decimal value, decimal cashFlow, global::System.Guid governorId, global::System.Guid ID)
        {
            AssetValue assetValue = new AssetValue();

            assetValue.InsuranceTypeValue = insuranceTypeValue;
            assetValue.TakingDate         = takingDate;
            assetValue.Value      = value;
            assetValue.CashFlow   = cashFlow;
            assetValue.GovernorId = governorId;
            assetValue.Id         = ID;
            return(assetValue);
        }
コード例 #4
0
        public IActionResult GetAllAssets(string libid, [FromQuery] string lastId = null, [FromQuery] int count = 0)
        {
            Library lib = Context.FindObjectById <Library>(libid);

            if (lib == null)
            {
                return(NotFound());
            }

            ICollection <Asset> assets = Context.GetAssets(lib, lastId, count);

            return(Ok(AssetValue.FromModel(assets)));
        }
コード例 #5
0
        public async Task <IActionResult> BasicUpload(IFormCollection formCollection, string libid)
        {
            Library lib = Context.FindObjectById <Library>(libid);

            if (lib == null)
            {
                return(NotFound());
            }

            var files = formCollection.Files;
            List <AssetValue> results = new List <AssetValue>();

            foreach (var formFile in files)
            {
                if (formFile.Length > 0)
                {
                    var fileExt = Path.GetExtension(formFile.FileName);
                    var fileId  = $"{fileStore.CreateFileId()}{fileExt}";
                    var asset   = new Asset
                    {
                        Name           = formFile.FileName,
                        Library        = lib,
                        CurrentVersion = 1
                    };
                    asset.AssetFiles.Add(new AssetFile
                    {
                        SourceFileName = formFile.FileName,
                        MimeType       = Mime.GetMimeFromExt(fileExt),
                        ResourceId     = fileId,
                        ComponentType  = FileComponent.RootFile,
                        Version        = 1
                    });

                    // add object to the db async.
                    Task addTask = asset.AddToCollection(lib.AssetCollection);

                    // write the content on the current thread
                    using (Stream inStream = formFile.OpenReadStream())
                        fileStore.SaveFile(fileId, inStream);

                    await addTask;
                    results.Add(AssetValue.FromModel(asset));
                }
            }
            return(Ok(results));
        }
コード例 #6
0
        public IActionResult GetAsset(string libid, string assetId)
        {
            Library lib = Context.FindObjectById <Library>(libid);

            if (lib == null)
            {
                return(NotFound());
            }

            Asset asset = Context.FindObjectById <Asset>(lib.AssetCollection, assetId);

            if (asset != null)
            {
                return(Ok(AssetValue.FromModel(asset)));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #7
0
ファイル: Reference.cs プロジェクト: koder05/fogel-ba
 public static AssetValue CreateAssetValue(byte insuranceTypeValue, global::System.DateTime takingDate, decimal value, decimal cashFlow, global::System.Guid governorId, global::System.Guid ID)
 {
     AssetValue assetValue = new AssetValue();
     assetValue.InsuranceTypeValue = insuranceTypeValue;
     assetValue.TakingDate = takingDate;
     assetValue.Value = value;
     assetValue.CashFlow = cashFlow;
     assetValue.GovernorId = governorId;
     assetValue.Id = ID;
     return assetValue;
 }
コード例 #8
0
ファイル: Reference.cs プロジェクト: koder05/fogel-ba
 public void AddToAssets(AssetValue assetValue)
 {
     base.AddObject("Assets", assetValue);
 }
コード例 #9
0
ファイル: Reference.cs プロジェクト: koder05/progs
 public void AddToAssets(AssetValue assetValue)
 {
     base.AddObject("Assets", assetValue);
 }
コード例 #10
0
        protected override void Execute(NativeActivityContext context)
        {
            EncryptionHelper encryptionHelper = new EncryptionHelper();

            string assetName  = AssetName.Get(context);
            string assetValue = AssetValue.Get(context);


            string tenantName         = TenantName.Get(context);
            string groupName          = GroupName.Get(context);
            string loginPassword      = LoginPassword.Get(context);
            string domainNameUserName = DomainNameUserName.Get(context);

            string[] struserDomain = null;
            if (domainNameUserName.Contains("/"))
            {
                struserDomain = domainNameUserName.Split('/');
            }
            else if (domainNameUserName.Contains("\\"))
            {
                struserDomain = domainNameUserName.Split('\\');
            }
            string strDomainName = struserDomain[0];
            string strUserName   = struserDomain[1];


            string encodePwd = string.Empty;

            byte[] encode = new byte[loginPassword.Length];
            encode        = Encoding.UTF8.GetBytes(loginPassword);
            encodePwd     = Convert.ToBase64String(encode);
            loginPassword = encodePwd;
            DataTable result = null;

            //consoleExecutionLog.AppendText("Calling Service");
            Logger.ServiceReference1.BOTServiceClient ser = new Logger.ServiceReference1.BOTServiceClient();
            result = ser.LoginUser(strDomainName, strUserName, loginPassword, tenantName, groupName);
            //consoleExecutionLog.AppendText("Got Data");

            if (result != null && result.Rows.Count > 0)
            {
                try
                {
                    int groupid  = int.Parse(result.Rows[0]["groupid"].ToString());
                    int TenantId = int.Parse(result.Rows[0]["tenantid"].ToString());

                    string resultGetKey = ser.getKey();



                    if (resultGetKey != null)
                    {
                        string EncryptedAssetValue     = encryptionHelper.Encrypt(assetValue, resultGetKey);
                        int    resultGetAddAssetStatus = ser.AddAssets(assetName, EncryptedAssetValue, TenantId, groupid, strUserName);
                        if (resultGetAddAssetStatus == 1)
                        {
                            Result.Set(context, true);
                            Log.Logger.LogData("Asset added to Asset Management successfully by activity Add Asset", LogLevel.Info);
                        }
                        else if (resultGetAddAssetStatus == -1)
                        {
                            Result.Set(context, false);
                            Log.Logger.LogData("Asset already exists in Asset Management in activity Add Asset", LogLevel.Info);
                        }
                        else
                        {
                            Result.Set(context, false);
                            Log.Logger.LogData("Asset does not validate(exist) in activity Add Asset", LogLevel.Info);
                        }
                    }
                    else
                    {
                        Log.Logger.LogData("Enter Key does not validate(exist) in activity Add Asset", LogLevel.Info);
                    }
                }
                catch (Exception ex)
                {
                    Log.Logger.LogData(ex.Message + " in activity Add Asset", LogLevel.Error);
                }
            }
            else
            {
                Log.Logger.LogData("User does not validate(exist) in activity Get Credentials", LogLevel.Info);
            }
        }
コード例 #11
0
        protected override void Execute(NativeActivityContext context)
        {
            EncryptionHelper encryptionHelper = new EncryptionHelper();
            string           assetName        = AssetName.Get(context);
            //    string key = Key.Get(context);
            //  bool Private = Private1.Get(context);

            string tenantName         = TenantName.Get(context);
            string groupName          = GroupName.Get(context);
            string loginPassword      = LoginPassword.Get(context);
            string domainNameUserName = DomainNameUserName.Get(context);

            string[] struserDomain = null;
            if (domainNameUserName.Contains("/"))
            {
                struserDomain = domainNameUserName.Split('/');
            }
            else if (domainNameUserName.Contains("\\"))
            {
                struserDomain = domainNameUserName.Split('\\');
            }
            string strDomainName = struserDomain[0];
            string strUserName   = struserDomain[1];


            string encodePwd = string.Empty;

            byte[] encode = new byte[loginPassword.Length];
            encode        = Encoding.UTF8.GetBytes(loginPassword);
            encodePwd     = Convert.ToBase64String(encode);
            loginPassword = encodePwd;
            DataTable result = null;

            //consoleExecutionLog.AppendText("Calling Service");
            Logger.ServiceReference1.BOTServiceClient ser = new Logger.ServiceReference1.BOTServiceClient();
            result = ser.LoginUser(strDomainName, strUserName, loginPassword, tenantName, groupName);
            //consoleExecutionLog.AppendText("Got Data");

            if (result != null && result.Rows.Count > 0)
            {
                //int keySize = 256;
                try
                {
                    int groupid  = int.Parse(result.Rows[0]["groupid"].ToString());
                    int TenantId = int.Parse(result.Rows[0]["tenantid"].ToString());

                    string resultGetKey = ser.getKey();

                    //int resultKeyExist = ser.KeyExist(key);

                    if (resultGetKey != null)
                    {
                        DataTable resultGetCredentials = ser.GetAssetsActivity(assetName, groupid, TenantId);
                        if (resultGetCredentials != null && resultGetCredentials.Rows.Count > 0)
                        {
                            string assetval = resultGetCredentials.Rows[0]["value"].ToString();
                            //Private = false;
                            //if (Private == false)    Commenting Private
                            //{ }
                            // password = Decrypt(password, key, keySize);

                            assetval = encryptionHelper.Decrypt(assetval, resultGetKey);


                            AssetValue.Set(context, assetval);
                        }
                        else
                        {
                            Log.Logger.LogData("Asset does not validate(exist) in activity Get Asset", LogLevel.Info);
                        }
                    }
                    else
                    {
                        Log.Logger.LogData("Enter Key does not validate(exist) in activity Get Asset", LogLevel.Info);
                    }
                }
                catch (Exception ex)
                {
                    Log.Logger.LogData(ex.Message + " in activity Get Asset", LogLevel.Error);
                }
            }
            else
            {
                Log.Logger.LogData("User does not validate(exist) in activity Get Credentials", LogLevel.Info);
            }
        }
コード例 #12
0
 public HttpResponseMessage Put([FromODataUri] Guid key, AssetValue val)
 {
     _rep.Update(val);
     return(Request.CreateResponse(HttpStatusCode.NoContent));
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: koder05/progs
        static void Main(string[] args)
        {
            OAuthProvider.Behavior = Activator.CreateInstance(OAuthConfiguration.Configuration.ClientSettings.WcfDSBehaviorType) as IOAuthBehavior;
            Logon.Page             = new LogonProc();
            var ctx = new WebApiCtx();
            FilterParameterCollection fc = new FilterParameterCollection();

            fc.Add("ShortName", "магомед ук");
            SortParameterCollection sc = new SortParameterCollection();

            sc.Add(null, "Company.Name", System.ComponentModel.ListSortDirection.Ascending);
            sc.Add(null, "Id", System.ComponentModel.ListSortDirection.Ascending);

            //var val = ctx.Governors.AddFilters(fc).AddOrders(sc).First();
            //var val = ctx.Governors.First();
            //val.Company.lawFormValue = 6;
            Guid g = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505");
            //var val = ctx.Governors.Where(gov => gov.Id == g).FirstOrDefault();
            Guid     g2   = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505");
            Governor val2 = null;

            //ctx.TryGetEntity(new Uri("http://localhost:555/Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')"), out val2);
            //Governor val2 = ctx.Governors.Where(gov => gov.Id == g2).FirstOrDefault();
            //val2 = ctx.Entities.FirstOrDefault(e => e.Identity.Contains("Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')")).Entity as Governor;
            //val2 = ctx.Governors.GetById(g);

            ctx.Governors.ToList();

            //Console.WriteLine(ctx.Governors.TotalCount());

            //var ass = ctx.Assets.Where(a => a.Id == new Guid("D3B67671-87C5-4B33-8DF1-7D83947E5FB8")).First();

            var ass = new AssetValue();

            ass.Id = Guid.NewGuid();
            ass.InsuranceTypeValue = 1;
            ass.TakingDate         = DateTime.Today;
            ass.Value      = 3344434.56m;
            ass.GovernorId = g2;

            string s    = JsonConvert.SerializeObject(ass);
            var    list = new List <string>();

            list.Add(s);

            UriBuilder urib = new UriBuilder(ctx.BaseUri);
            //urib.Path = string.Format("{0}/CreateBatch", ctx.Assets.RequestUri.PathAndQuery);
            //var r = ctx.Execute<bool>(urib.Uri, "POST", true, new BodyOperationParameter("Values", list)).FirstOrDefault();

            //ctx.AddToAssets(ass);
            //ctx.SetLink(ass, "Governor", val2);

            //ctx.SaveChanges();
            //ctx.AttachLink(ass, "Governor", val2);

            //Guid g = new Guid("32D3F7C1-97E1-4A69-8C8A-E3706490329E");
            //var val = ctx.Holidays.Where(h => h.Id == g).FirstOrDefault();

            //val.Comment = "Test Comment";


            var newc = new Company();

            newc.Id   = Guid.NewGuid();
            newc.Name = "Test Governor Company Name";
            var newg = new Governor();

            newg.Id        = Guid.NewGuid();
            newg.ShortName = "Test Governor Name";
            newg.Company   = newc;
            ctx.AddToGovernors(newg);
            ctx.SaveChanges();
            newg.ShortName = "Test Governor Name Updated";
            ctx.UpdateObject(newg);
            //ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate);
            System.Threading.Thread.Sleep(1000);
            ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);
            ctx.DeleteObject(newg);
            ctx.SaveChanges();

            //var serviceCreds = new NetworkCredential("Administrator", "SecurePassword");
            //var cache = new CredentialCache();
            //var serviceUri = new Uri("http://ipv4.fiddler:333/api/issue");
            //cache.Add(serviceUri, "Basic", serviceCreds);
            //ctx.Credentials = cache;
            //var r = ctx.Execute(new Uri("http://ipv4.fiddler:333/api/issue"), "POST", new BodyOperationParameter("rst", new TokenRequest() { GrantType = "client_credentials", Scope = "http://localhost" }));
            Console.ReadLine();
        }
コード例 #14
0
        private static void PrintAssetValue(AssetValue InValue, StreamWriter file)
        {
            file.Write(InValue.Name + ",");
            file.Write(InValue.IsReadOnly + ",");

            switch (InValue.ValueType)
            {
            case AssetValueTypeEnum.kAssetValueTypeBoolean:
                file.Write("Boolean,");

                var booleanValue = InValue as BooleanAssetValue;

                file.Write(booleanValue.Value + ",");
                break;

            case AssetValueTypeEnum.kAssetValueTypeChoice:
                file.Write("Choice,");

                var choiceValue = InValue as ChoiceAssetValue;

                file.Write(choiceValue.Value + ",");

                string[] names   = new string[] {};
                string[] choices = new string[] {};
                choiceValue.GetChoices(out names, out choices);
                for (int i = 0; i < names.Length; i++)
                {
                    file.Write(" " + names[i] + ":" + choices[i] + ",");
                }
                break;

            case AssetValueTypeEnum.kAssetValueTypeColor:
                file.Write("Color,");

                var colorValue = InValue as ColorAssetValue;

                file.Write(colorValue.HasConnectedTexture + ",");
                file.Write(colorValue.HasMultipleValues + ",");

                if (!colorValue.HasMultipleValues)
                {
                    file.Write(ColorString(colorValue.Value, file));
                }
                else
                {
                    file.Write("Colors,");

                    var colors = colorValue.get_Values();

                    foreach (var color in colors)
                    {
                        file.Write(ColorString(color, file));
                    }
                }
                break;

            case AssetValueTypeEnum.kAssetValueTypeFilename:
                file.Write("Filename,");

                var filenameValue = InValue as FilenameAssetValue;

                file.Write(filenameValue.Value + ",");
                break;

            case AssetValueTypeEnum.kAssetValueTypeFloat:
                file.Write("Float,");

                var floatValue = InValue as FloatAssetValue;

                file.Write(floatValue.Value + ",");
                break;

            case AssetValueTypeEnum.kAssetValueTypeInteger:
                file.Write("Integer,");

                var integerValue = InValue as IntegerAssetValue;

                file.Write(integerValue.Value + ",");
                break;

            case AssetValueTypeEnum.kAssetValueTypeReference:
                file.Write("Reference,");

                var refType = InValue as ReferenceAssetValue;
                break;

            case AssetValueTypeEnum.kAssetValueTypeString:
                file.Write("String,");

                var stringValue = InValue as StringAssetValue;

                file.Write(stringValue.Value + ",");
                break;
            }
            file.WriteLine();
        }