Exemplo n.º 1
0
 public object this[ShareItem item]
 {
     get
     {
         if (ContainsKey(item))
         {
             return _internalDictionary[item];
         }
         else
         {
             return null;
         }
     }
     set
     {
         bool isExist = this.ContainsKey(item);
         _internalDictionary[item] = value;
         if (!isExist)
         {
             SendMessage(MessageType.ObjectAdd, item);
         }
         else
         {
             SendMessage(MessageType.ObjectModify, item);
         }
     }
 }
Exemplo n.º 2
0
        public static ShareItem query_share(CmsForm cmsForm, string num_iid, String pid)
        {
            try
            {
                HttpService httpservice    = cmsForm.httpService;
                long        user_id        = cmsForm.appBean.user_id;
                String      user_key       = cmsForm.appBean.user_token;
                String      user_name      = cmsForm.appBean.user_name;
                String      user_goods_url = "http://" + Constants.api_url + "/zhushou/goods/share";
                String      body           = httpservice.post_http(user_goods_url, "user_id=" + user_id
                                                                   + "&num_iid=" + num_iid
                                                                   + "&pid=" + pid
                                                                   + "&member_token=" + user_key, null);
                //LogUtil.log_cms_call(cmsForm, "body:" + body);
                body = body.Trim();

                ShareItem shareItem = new ShareItem();

                JsonData jo = JsonMapper.ToObject(body);
                if (jo["data"] != null &&
                    jo["data"]["share"] != null)
                {
                    shareItem.title = jo["data"]["share"]["title"].ToString();
                    try {
                        shareItem.tao_token = jo["data"]["share"]["tao_token"].ToString();
                    }
                    catch (Exception) { }
                    try {
                        shareItem.coupon_money = double.Parse(jo["data"]["share"]["coupon_money"].ToString());
                    }
                    catch (Exception) { }
                    try {
                        shareItem.short_url = jo["data"]["share"]["short_url"].ToString();
                    }
                    catch (Exception) { }
                    try {
                        shareItem.uland_url = jo["data"]["share"]["taoke_url"].ToString();
                    }
                    catch (Exception) { }
                    try
                    {
                        shareItem.price = double.Parse(jo["data"]["share"]["price"].ToString());
                    }
                    catch (Exception) { }

                    try
                    {
                        shareItem.user_type_name = jo["data"]["share"]["user_type_name"].ToString();
                    }
                    catch (Exception) { }
                }
                return(shareItem);
            }
            catch (Exception exception)
            {
                //LogUtil.log_call(cmsForm, "---------------35555-----------"+exception.ToString());
                return(null);
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <ShareItem> > Create([FromBody] ShareItem shareItem)
        {
            // TODO get current user
            shareItem.CreateDate = DateTime.Now;
            dbContext.ShareItems.Add(shareItem);
            await dbContext.SaveChangesAsync();

            return(shareItem);
        }
Exemplo n.º 4
0
 public static IShareItemInfo Create(ShareItem s, BlobItem b)
 {
     return(new IShareItemInfo
     {
         ShareId = s.Id,
         FileName = b.FileName,
         AvailableUntil = s.ActiveUntil
     });
 }
        public IDownloadFileResponse DownloadFile(int requestId)
        {
            ShareItem s = GetShareItem(requestId);

            if (s == null)
            {
                return(null);
            }
            return(GetBlobModel().DownloadFile(s.BlobId));
        }
        public ActionResult <ShareItem> Create([FromBody] ICreateSharable postData)
        {
            ShareItem s = this.handler.Create(postData);

            if (s == null)
            {
                return(Conflict("Something went wrong"));
            }
            return(Created("", s));
        }
        public IFileInformation DownloadFileAssistent(int requestId)
        {
            ShareItem s = GetShareItem(requestId);

            if (s == null)
            {
                return(null);
            }
            return(GetBlobModel().DownloadFileAssistent(s.BlobId));
        }
Exemplo n.º 8
0
        void Share(Xamarin.Social.Service service)
        {
            if (fileName == string.Empty || fileName == "in-progress")
            {
                return;
            }

            // 2. Create an item to share
            var text = "Xamarin.SoMA ... Social Mobile & Auth! ";

            if (shareItem != null)               // use the existing one passed to the activity
            {
                text     = shareItem.Text;
                fileName = shareItem.ImagePath;
                location = shareItem.Location;
            }
            var item = new Item {
                Text = text
            };

            item.Images.Add(new ImageData(fileName));
            if (isLocationSet)
            {
                item.Links.Add(new Uri("https://maps.google.com/maps?q=" + location));
            }

            // 3. Present the UI on Android
            var shareIntent = service.GetShareUI(this, item, result => {
                // result lets you know if the user shared the item or canceled
                if (result == ShareResult.Cancelled)
                {
                    return;
                }

                Console.WriteLine("{0} shared", service.Title);

                // 4. Now save to the database for the MainScreen list
                var si = new ShareItem {
                    Text      = item.Text,                // get the edited text from the share UI
                    ImagePath = fileName,
                    Location  = location
                };
                if (item.Links.Count > 0)
                {
                    si.Link = item.Links[0].AbsoluteUri;
                }
                si.SocialType = service.Title;

                App.Database.SaveItem(si);
                shareItem = si;                 // replace the one in the activity
            });

            StartActivity(shareIntent);
        }
        public void DeleteShareItem(BlobItem blob)
        {
            ShareItem s = _context.ShareItems.Where(s => s.Id == blob.FileId).FirstOrDefault();

            if (s == null)
            {
                return;
            }
            _context.Remove(s);
            _context.SaveChanges();
        }
Exemplo n.º 10
0
        public static CouponContent parseContent(CmsForm cmsForm, string content, string qun_pid)
        {
            CouponContent couponContent = new CouponContent();

            couponContent.content = content;
            couponContent.memo    = TaobaoUtil.toText(content);
            UrlParse.parseContentUrlList(couponContent, cmsForm, content);
            if (!string.IsNullOrEmpty(couponContent.num_iid))
            {
                string out_log = "";
                int    hours   = 1;
                try
                {
                    hours = int.Parse(cmsForm.textBox_qunfa_times.Text.Trim());
                }
                catch (Exception) { }
                ArrayList arrayList = cmsForm.sendSqlUtil.query_send_item(couponContent.num_iid, hours, out out_log);
                if (arrayList.Count > 0)
                {
                    couponContent.status = 4;
                    return(couponContent);
                }

                if (!string.IsNullOrEmpty(PidUtil.get_qq_com_pid_call(cmsForm, null)))
                {
                    qun_pid = PidUtil.get_qq_com_pid_call(cmsForm, cmsForm.appBean.member_id);
                }
                else if (!string.IsNullOrEmpty(PidUtil.get_qq_queqiao_pid_call(cmsForm, null)))
                {
                    qun_pid = PidUtil.get_qq_queqiao_pid_call(cmsForm, cmsForm.appBean.member_id);
                }
                else if (!string.IsNullOrEmpty(PidUtil.get_weixin_pid_call(cmsForm, null)))
                {
                    qun_pid = PidUtil.get_weixin_pid_call(cmsForm, cmsForm.appBean.member_id);
                }

                if (!string.IsNullOrEmpty(qun_pid))
                {
                    ShareItem shareItem = UrlParse.query_share(cmsForm, couponContent.num_iid, qun_pid);
                    if (shareItem != null)
                    {
                        couponContent.coupon_money = shareItem.coupon_money;
                        couponContent.price        = shareItem.price;
                    }
                    else
                    {
                        couponContent.status = 1;
                        return(couponContent);
                    }
                }
            }
            return(couponContent);
        }
        public ShareItem Create(int blobId)
        {
            if (!DoesBlobIdExists(blobId))
            {
                return(null);
            }
            ShareItem s = ShareItemFactory.Create(CreateId(), blobId);

            _context.ShareItems.Add(s);
            _context.SaveChanges();
            return(s);
        }
Exemplo n.º 12
0
        void Share(Service service)
        {
            // 2. Create an item to share
            var item = new Item {
                Text = "Xamarin.SoMA ... Social Mobile & Auth! "
            };

            if (fileName != "in-progress" && fileName != "cancelled" && fileName != string.Empty)             // was never set, no image
            {
                item.Images.Add(new ImageData(fileName));
            }

            if (isLocationSet)
            {
                item.Links.Add(new Uri("https://maps.google.com/maps?q=" + location));
            }

            // 3. Present the UI on iOS
            var shareController = service.GetShareUI(item, result => {
                DismissViewController(true, null);

                // result lets you know if the user shared the item or canceled
                if (result == ShareResult.Cancelled)
                {
                    return;
                }

                Console.WriteLine(service.Title + " shared");

                // 4. Now save to the database for the MainScreen list
                var si = new ShareItem {
                    Text           = item.Text,           // get the edited text from the share UI
                    ImagePath      = fileName,
                    ThumbImagePath = fileNameThumb,
                    Location       = location
                };

                if (item.Links.Count > 0)
                {
                    si.Link = item.Links[0].AbsoluteUri;
                }
                si.SocialType = service.Title;

                AppDelegate.Database.SaveItem(si);
                shareItem = si;

                // 5. Return to the MainScreen
                NavigationController.PopViewController(true);
            });

            PresentViewController(shareController, true, null);
        }
 public IShareItemInfo ShareItemInfo(int shareId)
 {
     try
     {
         ShareItem s = GetShareItem(shareId);
         BlobItem  b = GetBlobModel().GetSingleFile(s.BlobId);
         return(ShareItemInfoFactory.Create(s, b));
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 14
0
        public ExportSchedulePopupViewModel(BaseViewModel parent, ScheduleViewModel scheduleViewModel) : base(parent)
        {
            _scheduleViewModel = scheduleViewModel;

            Element = CreateView();

            ShareItems = new ShareItem[]
            {
                // TODO: Localize strings
                new ShareItem()
                {
                    Title       = LocalizedResources.GetString("String_ScheduleExportToImage_Clipboard_Title"),
                    Subtitle    = LocalizedResources.GetString("String_ScheduleExportToImage_Clipboard_Subtitle"),
                    ClickAction = ExportToClipboard
                },

                new ShareItem()
                {
                    Title       = LocalizedResources.GetString("String_ScheduleExportToImage_Save_Title"),
                    Subtitle    = LocalizedResources.GetString("String_ScheduleExportToImage_Save_Subtitle"),
                    ClickAction = ExportToFile
                },

                // Only include share if it's supported
                App.IsSharingSupported ? new ShareItem()
                {
                    Title       = LocalizedResources.GetString("String_ScheduleExportToImage_Share_Title"),
                    Subtitle    = LocalizedResources.GetString("String_ScheduleExportToImage_Share_Subtitle"),
                    ClickAction = ExportToShare
                } : null,

                // Cutting since implementing this is more complicated than expected.
                // See description below for more details.
                //new ShareItem()
                //{
                //    Title = "Send to printer",
                //    Subtitle = "Print an image of your schedule",
                //    ClickAction = ExportToPrinter
                //},

                new ShareItem()
                {
                    Title       = LocalizedResources.GetString("String_ScheduleExportToImage_Cancel_Title"),
                    Subtitle    = LocalizedResources.GetString("String_ScheduleExportToImage_Cancel_Subtitle"),
                    ClickAction = delegate { base.GoBack(); }
                }
            }.Where(i => i != null).ToArray();
        }
Exemplo n.º 15
0
 public ShareItemModel(ShareItem share, DateTime dateInNew, string uniqueCode)
 {
     //Todo make it via mapper
     ObjId            = share.Id;
     Barcode          = share.Barcode;
     CustomBarcode    = CustomBarcode;
     Type             = share.Type;
     ObjDescription   = share.Description;
     Percentage       = share.Percentage;
     images           = AutoMapper.Mapper.Map <IEnumerable <Image>, IList <ImageModel> >(share.Images) ?? new List <ImageModel>();
     OrganizationId   = share.Organization.Id;
     OrganizationName = share.Organization.Name;
     DateInNew        = dateInNew;
     UniqueCode       = uniqueCode;
     DownloadCount    = share.DownloadCount;
 }
        private ShareItem GetShareItem(int requestId)
        {
            ShareItem share = _context.ShareItems.Where(s => s.Id == requestId).FirstOrDefault();

            if (share == null)
            {
                return(null);
            }
            else if (DateTime.Compare(DateTime.Now, share.ActiveUntil) < 0)
            {
                return(share);
            }
            else
            {
                return(null);
            }
        }
        // </snippet_ListShareSnapshots>

        public ShareItem GetSnapshotItem()
        {
            ShareItem result = null;

            // Get the connection string from app settings
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            // Instatiate a ShareServiceClient
            ShareServiceClient shareServiceClient = new ShareServiceClient(connectionString);

            foreach (ShareItem item in shareServiceClient.GetShares(ShareTraits.All, ShareStates.Snapshots))
            {
                if (null != item.Snapshot)
                {
                    // Return the first share with a snapshot
                    return(item);
                }
            }

            return(result);
        }
Exemplo n.º 18
0
 public void Add(ShareItem key, object value)
 {
     _internalDictionary.Add(key, value);
     SendMessage(MessageType.ObjectAdd, key);
 }
Exemplo n.º 19
0
        protected override async void OnResume()
        {
            base.OnResume();

            int itemId = Intent.GetIntExtra(ShareItemIdExtraName, 0);

            if (itemId > 0)
            {
                shareItem = App.Database.GetItem(itemId);

                fileName = shareItem.ImagePath;
                Console.WriteLine("Image path: {0}", fileName);
                Bitmap b = BitmapFactory.DecodeFile(fileName);
                // Display the bitmap
                photoImageView.SetImageBitmap(b);
                locationText.Text = shareItem.Location;
                return;
            }

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = "in-progress";
                var picker = new MediaPicker(this);
                if (!picker.IsCameraAvailable)
                {
                    Console.WriteLine("No camera!");
                }
                else
                {
                    var options = new StoreCameraMediaOptions {
                        Name      = DateTime.Now.ToString("yyyyMMddHHmmss"),
                        Directory = "MediaPickerSample"
                    };

                    if (!picker.IsCameraAvailable || !picker.PhotosSupported)
                    {
                        ShowUnsupported();
                        return;
                    }

                    Intent intent = picker.GetTakePhotoUI(options);

                    StartActivityForResult(intent, 1);
                }
            }
            else
            {
                SetImage();
            }

            try {
                var locator = new Geolocator(this)
                {
                    DesiredAccuracy = 50
                };
                var position = await locator.GetPositionAsync(10000);

                Console.WriteLine("Position Latitude: {0}", position.Latitude);
                Console.WriteLine("Position Longitude: {0}", position.Longitude);

                location          = string.Format("{0},{1}", position.Latitude, position.Longitude);
                locationText.Text = location;
            } catch (Exception e) {
                Console.WriteLine("Position Exception: {0}", e.Message);
            }
        }
Exemplo n.º 20
0
 public bool Remove(ShareItem key)
 {
     SendMessage(MessageType.ObjectRemove, key);
     return _internalDictionary.Remove(key);
 }
Exemplo n.º 21
0
 public void SetItem(ShareItem item)
 {
     fileName = item.ImagePath;
     location = item.Location;
 }
Exemplo n.º 22
0
 public bool TryGetValue(ShareItem key, out object value)
 {
     return _internalDictionary.TryGetValue(key, out value);
 }
        // </snippet_UseMetrics>

        //-------------------------------------------------
        // Basic file operations menu
        //-------------------------------------------------
        public async Task <bool> Menu()
        {
            Console.Clear();
            Console.WriteLine("Choose a file share scenario:");
            Console.WriteLine("1) Create share");
            Console.WriteLine("2) Upload file using SAS");
            Console.WriteLine("3) Set maximum share size");
            Console.WriteLine("4) Copy file");
            Console.WriteLine("5) Copy file to a blob");
            Console.WriteLine("6) Create snapshot");
            Console.WriteLine("7) List snapshots");
            Console.WriteLine("8) Restore file from snapshot");
            Console.WriteLine("9) Delete snapshot");
            Console.WriteLine("10) Use metrics");
            Console.WriteLine("X) Exit");
            Console.Write("\r\nSelect an option: ");

            switch (Console.ReadLine())
            {
            // Create a share
            case "1":
                Console.WriteLine($"Calling: CreateShareAsync(\"logs\");");
                await CreateShareAsync("logs");

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Upload a file using a SAS
            case "2":
                Console.WriteLine($"Calling: UploadFileWithSasAsync();");
                await UploadFileWithSasAsync();

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Set the maximum size on a share
            case "3":
                Console.WriteLine($"Calling: SetMaxShareSizeAsync(\"logs\", 10);");
                await SetMaxShareSizeAsync("logs", 10);

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Copy a file
            case "4":
                Console.WriteLine($"Calling: CopyFileAsync(\"logs\", \"CustomLogs/Log1.txt\", \"CustomLogs/Log1Copy.txt\");");
                await CopyFileAsync("logs", "CustomLogs/Log1.txt", "CustomLogs/Log1Copy.txt");

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Copy a file to a blob
            case "5":
                Console.WriteLine($"Calling: CopyFileToBlobAsync(\"logs\", \"CustomLogs/Log1.txt\", \"sample-container\", \"sample-blob.txt\");");
                await CopyFileToBlobAsync("logs", "CustomLogs/Log1.txt", "sample-container", "sample-blob.txt");

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Create snapshot
            case "6":
                Console.WriteLine($"Calling: CreateShareSnapshotAsync(\"logs\");");
                await CreateShareSnapshotAsync("logs");

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            case "7":
                // List snapshots
                Console.WriteLine($"Calling: ListShareSnapshots();");
                ListShareSnapshots();
                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            case "8":
                // Restore a file from a snapshot
                ShareItem snapshot = GetSnapshotItem();
                Console.WriteLine($"Calling RestoreFileFromSnapshot(\"{snapshot.Name}\", \"CustomLogs\", \"Log1Copy.txt\", \"{snapshot.Snapshot}\");");
                await RestoreFileFromSnapshot(snapshot.Name, "CustomLogs", "Log1Copy.txt", snapshot.Snapshot);

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            case "9":
                // Delete a snapshot
                ShareItem shareItem = GetSnapshotItem();
                Console.WriteLine($"Calling DeleteSnapshotAsync(\"{shareItem.Name}\", \"{shareItem.Snapshot}\");");
                await DeleteSnapshotAsync(shareItem.Name, shareItem.Snapshot);

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Use metrics
            case "10":
                await UseMetricsAsync();

                Console.WriteLine("Press enter to continue");
                Console.ReadLine();
                return(true);

            // Exit to the main menu
            case "X":
            case "x":
                return(false);

            default:
                return(true);
            }
        }
Exemplo n.º 24
0
 public bool ContainsKey(ShareItem key)
 {
     return _internalDictionary.ContainsKey(key);
 }